babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * For internal use only. Please do not use.
  420. */
  421. reservedDataStore: any;
  422. /**
  423. * Gets or sets a boolean used to define if the node must be serialized
  424. */
  425. doNotSerialize: boolean;
  426. /** @hidden */
  427. _isDisposed: boolean;
  428. /**
  429. * Gets a list of Animations associated with the node
  430. */
  431. animations: Animation[];
  432. protected _ranges: {
  433. [name: string]: Nullable<AnimationRange>;
  434. };
  435. /**
  436. * Callback raised when the node is ready to be used
  437. */
  438. onReady: (node: Node) => void;
  439. private _isEnabled;
  440. private _isParentEnabled;
  441. private _isReady;
  442. /** @hidden */
  443. _currentRenderId: number;
  444. private _parentRenderId;
  445. protected _childRenderId: number;
  446. /** @hidden */
  447. _waitingParentId: Nullable<string>;
  448. /** @hidden */
  449. _scene: Scene;
  450. /** @hidden */
  451. _cache: any;
  452. private _parentNode;
  453. private _children;
  454. /** @hidden */
  455. _worldMatrix: Matrix;
  456. /** @hidden */
  457. _worldMatrixDeterminant: number;
  458. /** @hidden */
  459. private _sceneRootNodesIndex;
  460. /**
  461. * Gets a boolean indicating if the node has been disposed
  462. * @returns true if the node was disposed
  463. */
  464. isDisposed(): boolean;
  465. /**
  466. * Gets or sets the parent of the node
  467. */
  468. parent: Nullable<Node>;
  469. private addToSceneRootNodes;
  470. private removeFromSceneRootNodes;
  471. private _animationPropertiesOverride;
  472. /**
  473. * Gets or sets the animation properties override
  474. */
  475. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  476. /**
  477. * Gets a string idenfifying the name of the class
  478. * @returns "Node" string
  479. */
  480. getClassName(): string;
  481. /**
  482. * An event triggered when the mesh is disposed
  483. */
  484. onDisposeObservable: Observable<Node>;
  485. private _onDisposeObserver;
  486. /**
  487. * Sets a callback that will be raised when the node will be disposed
  488. */
  489. onDispose: () => void;
  490. /**
  491. * Creates a new Node
  492. * @param name the name and id to be given to this node
  493. * @param scene the scene this node will be added to
  494. * @param addToRootNodes the node will be added to scene.rootNodes
  495. */
  496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  497. /**
  498. * Gets the scene of the node
  499. * @returns a scene
  500. */
  501. getScene(): Scene;
  502. /**
  503. * Gets the engine of the node
  504. * @returns a Engine
  505. */
  506. getEngine(): Engine;
  507. private _behaviors;
  508. /**
  509. * Attach a behavior to the node
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  513. * @returns the current Node
  514. */
  515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  516. /**
  517. * Remove an attached behavior
  518. * @see http://doc.babylonjs.com/features/behaviour
  519. * @param behavior defines the behavior to attach
  520. * @returns the current Node
  521. */
  522. removeBehavior(behavior: Behavior<Node>): Node;
  523. /**
  524. * Gets the list of attached behaviors
  525. * @see http://doc.babylonjs.com/features/behaviour
  526. */
  527. readonly behaviors: Behavior<Node>[];
  528. /**
  529. * Gets an attached behavior by name
  530. * @param name defines the name of the behavior to look for
  531. * @see http://doc.babylonjs.com/features/behaviour
  532. * @returns null if behavior was not found else the requested behavior
  533. */
  534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  535. /**
  536. * Returns the latest update of the World matrix
  537. * @returns a Matrix
  538. */
  539. getWorldMatrix(): Matrix;
  540. /** @hidden */
  541. _getWorldMatrixDeterminant(): number;
  542. /**
  543. * Returns directly the latest state of the mesh World matrix.
  544. * A Matrix is returned.
  545. */
  546. readonly worldMatrixFromCache: Matrix;
  547. /** @hidden */
  548. _initCache(): void;
  549. /** @hidden */
  550. updateCache(force?: boolean): void;
  551. /** @hidden */
  552. _updateCache(ignoreParentClass?: boolean): void;
  553. /** @hidden */
  554. _isSynchronized(): boolean;
  555. /** @hidden */
  556. _markSyncedWithParent(): void;
  557. /** @hidden */
  558. isSynchronizedWithParent(): boolean;
  559. /** @hidden */
  560. isSynchronized(): boolean;
  561. /**
  562. * Is this node ready to be used/rendered
  563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  564. * @return true if the node is ready
  565. */
  566. isReady(completeCheck?: boolean): boolean;
  567. /**
  568. * Is this node enabled?
  569. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  570. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  571. * @return whether this node (and its parent) is enabled
  572. */
  573. isEnabled(checkAncestors?: boolean): boolean;
  574. /** @hidden */
  575. protected _syncParentEnabledState(): void;
  576. /**
  577. * Set the enabled state of this node
  578. * @param value defines the new enabled state
  579. */
  580. setEnabled(value: boolean): void;
  581. /**
  582. * Is this node a descendant of the given node?
  583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  584. * @param ancestor defines the parent node to inspect
  585. * @returns a boolean indicating if this node is a descendant of the given node
  586. */
  587. isDescendantOf(ancestor: Node): boolean;
  588. /** @hidden */
  589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  590. /**
  591. * Will return all nodes that have this node as ascendant
  592. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  593. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  594. * @return all children nodes of all types
  595. */
  596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  597. /**
  598. * Get all child-meshes of this node
  599. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  600. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  601. * @returns an array of AbstractMesh
  602. */
  603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  604. /**
  605. * Get all child-transformNodes of this node
  606. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  607. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  608. * @returns an array of TransformNode
  609. */
  610. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  611. /**
  612. * Get all direct children of this node
  613. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  614. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  615. * @returns an array of Node
  616. */
  617. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  618. /** @hidden */
  619. _setReady(state: boolean): void;
  620. /**
  621. * Get an animation by name
  622. * @param name defines the name of the animation to look for
  623. * @returns null if not found else the requested animation
  624. */
  625. getAnimationByName(name: string): Nullable<Animation>;
  626. /**
  627. * Creates an animation range for this node
  628. * @param name defines the name of the range
  629. * @param from defines the starting key
  630. * @param to defines the end key
  631. */
  632. createAnimationRange(name: string, from: number, to: number): void;
  633. /**
  634. * Delete a specific animation range
  635. * @param name defines the name of the range to delete
  636. * @param deleteFrames defines if animation frames from the range must be deleted as well
  637. */
  638. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  639. /**
  640. * Get an animation range by name
  641. * @param name defines the name of the animation range to look for
  642. * @returns null if not found else the requested animation range
  643. */
  644. getAnimationRange(name: string): Nullable<AnimationRange>;
  645. /**
  646. * Will start the animation sequence
  647. * @param name defines the range frames for animation sequence
  648. * @param loop defines if the animation should loop (false by default)
  649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  651. * @returns the object created for this animation. If range does not exist, it will return null
  652. */
  653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  654. /**
  655. * Serialize animation ranges into a JSON compatible object
  656. * @returns serialization object
  657. */
  658. serializeAnimationRanges(): any;
  659. /**
  660. * Computes the world matrix of the node
  661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  662. * @returns the world matrix
  663. */
  664. computeWorldMatrix(force?: boolean): Matrix;
  665. /**
  666. * Releases resources associated with this node.
  667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  669. */
  670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  671. /**
  672. * Parse animation range data from a serialization object and store them into a given node
  673. * @param node defines where to store the animation ranges
  674. * @param parsedNode defines the serialization object to read data from
  675. * @param scene defines the hosting scene
  676. */
  677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  678. }
  679. }
  680. declare module BABYLON {
  681. /**
  682. * Define an interface for all classes that will hold resources
  683. */
  684. interface IDisposable {
  685. /**
  686. * Releases all held resources
  687. */
  688. dispose(): void;
  689. }
  690. /**
  691. * This class is used by the onRenderingGroupObservable
  692. */
  693. class RenderingGroupInfo {
  694. /**
  695. * The Scene that being rendered
  696. */
  697. scene: Scene;
  698. /**
  699. * The camera currently used for the rendering pass
  700. */
  701. camera: Nullable<Camera>;
  702. /**
  703. * The ID of the renderingGroup being processed
  704. */
  705. renderingGroupId: number;
  706. }
  707. /** Interface defining initialization parameters for Scene class */
  708. interface SceneOptions {
  709. /**
  710. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryUniqueIdsMap?: boolean;
  714. /**
  715. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  716. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  717. */
  718. useMaterialMeshMap?: boolean;
  719. /**
  720. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  721. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  722. */
  723. useClonedMeshhMap?: boolean;
  724. }
  725. /**
  726. * Represents a scene to be rendered by the engine.
  727. * @see http://doc.babylonjs.com/features/scene
  728. */
  729. class Scene extends AbstractScene implements IAnimatable {
  730. private static _uniqueIdCounter;
  731. /** The fog is deactivated */
  732. static readonly FOGMODE_NONE: number;
  733. /** The fog density is following an exponential function */
  734. static readonly FOGMODE_EXP: number;
  735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  736. static readonly FOGMODE_EXP2: number;
  737. /** The fog density is following a linear function. */
  738. static readonly FOGMODE_LINEAR: number;
  739. /**
  740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  742. */
  743. static MinDeltaTime: number;
  744. /**
  745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  747. */
  748. static MaxDeltaTime: number;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  751. */
  752. autoClear: boolean;
  753. /**
  754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  755. */
  756. autoClearDepthAndStencil: boolean;
  757. /**
  758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  759. */
  760. clearColor: Color4;
  761. /**
  762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  763. */
  764. ambientColor: Color3;
  765. /** @hidden */
  766. _environmentBRDFTexture: BaseTexture;
  767. /** @hidden */
  768. protected _environmentTexture: Nullable<BaseTexture>;
  769. /**
  770. * Texture used in all pbr material as the reflection texture.
  771. * As in the majority of the scene they are the same (exception for multi room and so on),
  772. * this is easier to reference from here than from all the materials.
  773. */
  774. /**
  775. * Texture used in all pbr material as the reflection texture.
  776. * As in the majority of the scene they are the same (exception for multi room and so on),
  777. * this is easier to set here than in all the materials.
  778. */
  779. environmentTexture: Nullable<BaseTexture>;
  780. /** @hidden */
  781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  782. /**
  783. * Default image processing configuration used either in the rendering
  784. * Forward main pass or through the imageProcessingPostProcess if present.
  785. * As in the majority of the scene they are the same (exception for multi camera),
  786. * this is easier to reference from here than from all the materials and post process.
  787. *
  788. * No setter as we it is a shared configuration, you can set the values instead.
  789. */
  790. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  791. private _forceWireframe;
  792. /**
  793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  794. */
  795. forceWireframe: boolean;
  796. private _forcePointsCloud;
  797. /**
  798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  799. */
  800. forcePointsCloud: boolean;
  801. /**
  802. * Gets or sets the active clipplane 1
  803. */
  804. clipPlane: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 2
  807. */
  808. clipPlane2: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 3
  811. */
  812. clipPlane3: Nullable<Plane>;
  813. /**
  814. * Gets or sets the active clipplane 4
  815. */
  816. clipPlane4: Nullable<Plane>;
  817. /**
  818. * Gets or sets a boolean indicating if animations are enabled
  819. */
  820. animationsEnabled: boolean;
  821. private _animationPropertiesOverride;
  822. /**
  823. * Gets or sets the animation properties override
  824. */
  825. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  826. /**
  827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  829. */
  830. useConstantAnimationDeltaTime: boolean;
  831. /**
  832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  833. * Please note that it requires to run a ray cast through the scene on every frame
  834. */
  835. constantlyUpdateMeshUnderPointer: boolean;
  836. /**
  837. * Defines the HTML cursor to use when hovering over interactive elements
  838. */
  839. hoverCursor: string;
  840. /**
  841. * Defines the HTML default cursor to use (empty by default)
  842. */
  843. defaultCursor: string;
  844. /**
  845. * This is used to call preventDefault() on pointer down
  846. * in order to block unwanted artifacts like system double clicks
  847. */
  848. preventDefaultOnPointerDown: boolean;
  849. /**
  850. * This is used to call preventDefault() on pointer up
  851. * in order to block unwanted artifacts like system double clicks
  852. */
  853. preventDefaultOnPointerUp: boolean;
  854. /**
  855. * Gets or sets user defined metadata
  856. */
  857. metadata: any;
  858. /**
  859. * For internal use only. Please do not use.
  860. */
  861. reservedDataStore: any;
  862. /**
  863. * Gets the name of the plugin used to load this scene (null by default)
  864. */
  865. loadingPluginName: string;
  866. /**
  867. * Use this array to add regular expressions used to disable offline support for specific urls
  868. */
  869. disableOfflineSupportExceptionRules: RegExp[];
  870. /**
  871. * An event triggered when the scene is disposed.
  872. */
  873. onDisposeObservable: Observable<Scene>;
  874. private _onDisposeObserver;
  875. /** Sets a function to be executed when this scene is disposed. */
  876. onDispose: () => void;
  877. /**
  878. * An event triggered before rendering the scene (right after animations and physics)
  879. */
  880. onBeforeRenderObservable: Observable<Scene>;
  881. private _onBeforeRenderObserver;
  882. /** Sets a function to be executed before rendering this scene */
  883. beforeRender: Nullable<() => void>;
  884. /**
  885. * An event triggered after rendering the scene
  886. */
  887. onAfterRenderObservable: Observable<Scene>;
  888. private _onAfterRenderObserver;
  889. /** Sets a function to be executed after rendering this scene */
  890. afterRender: Nullable<() => void>;
  891. /**
  892. * An event triggered before animating the scene
  893. */
  894. onBeforeAnimationsObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after animations processing
  897. */
  898. onAfterAnimationsObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before draw calls are ready to be sent
  901. */
  902. onBeforeDrawPhaseObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after draw calls have been sent
  905. */
  906. onAfterDrawPhaseObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when the scene is ready
  909. */
  910. onReadyObservable: Observable<Scene>;
  911. /**
  912. * An event triggered before rendering a camera
  913. */
  914. onBeforeCameraRenderObservable: Observable<Camera>;
  915. private _onBeforeCameraRenderObserver;
  916. /** Sets a function to be executed before rendering a camera*/
  917. beforeCameraRender: () => void;
  918. /**
  919. * An event triggered after rendering a camera
  920. */
  921. onAfterCameraRenderObservable: Observable<Camera>;
  922. private _onAfterCameraRenderObserver;
  923. /** Sets a function to be executed after rendering a camera*/
  924. afterCameraRender: () => void;
  925. /**
  926. * An event triggered when active meshes evaluation is about to start
  927. */
  928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when active meshes evaluation is done
  931. */
  932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when particles rendering is about to start
  935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  936. */
  937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  938. /**
  939. * An event triggered when particles rendering is done
  940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  941. */
  942. onAfterParticlesRenderingObservable: Observable<Scene>;
  943. /**
  944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  945. */
  946. onDataLoadedObservable: Observable<Scene>;
  947. /**
  948. * An event triggered when a camera is created
  949. */
  950. onNewCameraAddedObservable: Observable<Camera>;
  951. /**
  952. * An event triggered when a camera is removed
  953. */
  954. onCameraRemovedObservable: Observable<Camera>;
  955. /**
  956. * An event triggered when a light is created
  957. */
  958. onNewLightAddedObservable: Observable<Light>;
  959. /**
  960. * An event triggered when a light is removed
  961. */
  962. onLightRemovedObservable: Observable<Light>;
  963. /**
  964. * An event triggered when a geometry is created
  965. */
  966. onNewGeometryAddedObservable: Observable<Geometry>;
  967. /**
  968. * An event triggered when a geometry is removed
  969. */
  970. onGeometryRemovedObservable: Observable<Geometry>;
  971. /**
  972. * An event triggered when a transform node is created
  973. */
  974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  975. /**
  976. * An event triggered when a transform node is removed
  977. */
  978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  979. /**
  980. * An event triggered when a mesh is created
  981. */
  982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  983. /**
  984. * An event triggered when a mesh is removed
  985. */
  986. onMeshRemovedObservable: Observable<AbstractMesh>;
  987. /**
  988. * An event triggered when a material is created
  989. */
  990. onNewMaterialAddedObservable: Observable<Material>;
  991. /**
  992. * An event triggered when a material is removed
  993. */
  994. onMaterialRemovedObservable: Observable<Material>;
  995. /**
  996. * An event triggered when a texture is created
  997. */
  998. onNewTextureAddedObservable: Observable<BaseTexture>;
  999. /**
  1000. * An event triggered when a texture is removed
  1001. */
  1002. onTextureRemovedObservable: Observable<BaseTexture>;
  1003. /**
  1004. * An event triggered when render targets are about to be rendered
  1005. * Can happen multiple times per frame.
  1006. */
  1007. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1008. /**
  1009. * An event triggered when render targets were rendered.
  1010. * Can happen multiple times per frame.
  1011. */
  1012. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered before calculating deterministic simulation step
  1015. */
  1016. onBeforeStepObservable: Observable<Scene>;
  1017. /**
  1018. * An event triggered after calculating deterministic simulation step
  1019. */
  1020. onAfterStepObservable: Observable<Scene>;
  1021. /**
  1022. * An event triggered when the activeCamera property is updated
  1023. */
  1024. onActiveCameraChanged: Observable<Scene>;
  1025. /**
  1026. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1028. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1029. */
  1030. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1031. /**
  1032. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1034. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1035. */
  1036. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1037. /**
  1038. * This Observable will when a mesh has been imported into the scene.
  1039. */
  1040. onMeshImportedObservable: Observable<AbstractMesh>;
  1041. private _registeredForLateAnimationBindings;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1044. */
  1045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1046. /**
  1047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1048. */
  1049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1050. /**
  1051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1052. */
  1053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1054. private _onPointerMove;
  1055. private _onPointerDown;
  1056. private _onPointerUp;
  1057. /** Callback called when a pointer move is detected */
  1058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1059. /** Callback called when a pointer down is detected */
  1060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1061. /** Callback called when a pointer up is detected */
  1062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1063. /** Callback called when a pointer pick is detected */
  1064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1065. /**
  1066. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  1067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1068. */
  1069. onPrePointerObservable: Observable<PointerInfoPre>;
  1070. /**
  1071. * Observable event triggered each time an input event is received from the rendering canvas
  1072. */
  1073. onPointerObservable: Observable<PointerInfo>;
  1074. /**
  1075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1076. */
  1077. readonly unTranslatedPointer: Vector2;
  1078. /** The distance in pixel that you have to move to prevent some events */
  1079. static DragMovementThreshold: number;
  1080. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1081. static LongPressDelay: number;
  1082. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1083. static DoubleClickDelay: number;
  1084. /** If you need to check double click without raising a single click at first click, enable this flag */
  1085. static ExclusiveDoubleClickMode: boolean;
  1086. private _initClickEvent;
  1087. private _initActionManager;
  1088. private _delayedSimpleClick;
  1089. private _delayedSimpleClickTimeout;
  1090. private _previousDelayedSimpleClickTimeout;
  1091. private _meshPickProceed;
  1092. private _previousButtonPressed;
  1093. private _currentPickResult;
  1094. private _previousPickResult;
  1095. private _totalPointersPressed;
  1096. private _doubleClickOccured;
  1097. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1098. cameraToUseForPointers: Nullable<Camera>;
  1099. private _pointerX;
  1100. private _pointerY;
  1101. private _unTranslatedPointerX;
  1102. private _unTranslatedPointerY;
  1103. private _startingPointerPosition;
  1104. private _previousStartingPointerPosition;
  1105. private _startingPointerTime;
  1106. private _previousStartingPointerTime;
  1107. private _pointerCaptures;
  1108. private _timeAccumulator;
  1109. private _currentStepId;
  1110. private _currentInternalStep;
  1111. /** @hidden */
  1112. _mirroredCameraPosition: Nullable<Vector3>;
  1113. /**
  1114. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1115. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1116. */
  1117. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1118. /**
  1119. * Observable event triggered each time an keyboard event is received from the hosting window
  1120. */
  1121. onKeyboardObservable: Observable<KeyboardInfo>;
  1122. private _onKeyDown;
  1123. private _onKeyUp;
  1124. private _onCanvasFocusObserver;
  1125. private _onCanvasBlurObserver;
  1126. private _useRightHandedSystem;
  1127. /**
  1128. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1129. */
  1130. useRightHandedSystem: boolean;
  1131. /**
  1132. * Sets the step Id used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @param newStepId defines the step Id
  1135. */
  1136. setStepId(newStepId: number): void;
  1137. /**
  1138. * Gets the step Id used by deterministic lock step
  1139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1140. * @returns the step Id
  1141. */
  1142. getStepId(): number;
  1143. /**
  1144. * Gets the internal step used by deterministic lock step
  1145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1146. * @returns the internal step
  1147. */
  1148. getInternalStep(): number;
  1149. private _fogEnabled;
  1150. /**
  1151. * Gets or sets a boolean indicating if fog is enabled on this scene
  1152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1153. * (Default is true)
  1154. */
  1155. fogEnabled: boolean;
  1156. private _fogMode;
  1157. /**
  1158. * Gets or sets the fog mode to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * | mode | value |
  1161. * | --- | --- |
  1162. * | FOGMODE_NONE | 0 |
  1163. * | FOGMODE_EXP | 1 |
  1164. * | FOGMODE_EXP2 | 2 |
  1165. * | FOGMODE_LINEAR | 3 |
  1166. */
  1167. fogMode: number;
  1168. /**
  1169. * Gets or sets the fog color to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is Color3(0.2, 0.2, 0.3))
  1172. */
  1173. fogColor: Color3;
  1174. /**
  1175. * Gets or sets the fog density to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 0.1)
  1178. */
  1179. fogDensity: number;
  1180. /**
  1181. * Gets or sets the fog start distance to use
  1182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1183. * (Default is 0)
  1184. */
  1185. fogStart: number;
  1186. /**
  1187. * Gets or sets the fog end distance to use
  1188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1189. * (Default is 1000)
  1190. */
  1191. fogEnd: number;
  1192. private _shadowsEnabled;
  1193. /**
  1194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1195. */
  1196. shadowsEnabled: boolean;
  1197. private _lightsEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if lights are enabled on this scene
  1200. */
  1201. lightsEnabled: boolean;
  1202. /** All of the active cameras added to this scene. */
  1203. activeCameras: Camera[];
  1204. private _activeCamera;
  1205. /** Gets or sets the current active camera */
  1206. activeCamera: Nullable<Camera>;
  1207. private _defaultMaterial;
  1208. /** The default material used on meshes when no material is affected */
  1209. /** The default material used on meshes when no material is affected */
  1210. defaultMaterial: Material;
  1211. private _texturesEnabled;
  1212. /**
  1213. * Gets or sets a boolean indicating if textures are enabled on this scene
  1214. */
  1215. texturesEnabled: boolean;
  1216. /**
  1217. * Gets or sets a boolean indicating if particles are enabled on this scene
  1218. */
  1219. particlesEnabled: boolean;
  1220. /**
  1221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1222. */
  1223. spritesEnabled: boolean;
  1224. private _skeletonsEnabled;
  1225. /**
  1226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1227. */
  1228. skeletonsEnabled: boolean;
  1229. /**
  1230. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1231. */
  1232. lensFlaresEnabled: boolean;
  1233. /**
  1234. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. collisionsEnabled: boolean;
  1238. private _workerCollisions;
  1239. /** @hidden */
  1240. collisionCoordinator: ICollisionCoordinator;
  1241. /**
  1242. * Defines the gravity applied to this scene (used only for collisions)
  1243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1244. */
  1245. gravity: Vector3;
  1246. /**
  1247. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1248. */
  1249. postProcessesEnabled: boolean;
  1250. /**
  1251. * The list of postprocesses added to the scene
  1252. */
  1253. postProcesses: PostProcess[];
  1254. /**
  1255. * Gets the current postprocess manager
  1256. */
  1257. postProcessManager: PostProcessManager;
  1258. /**
  1259. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1260. */
  1261. renderTargetsEnabled: boolean;
  1262. /**
  1263. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1264. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1265. */
  1266. dumpNextRenderTargets: boolean;
  1267. /**
  1268. * The list of user defined render targets added to the scene
  1269. */
  1270. customRenderTargets: RenderTargetTexture[];
  1271. /**
  1272. * Defines if texture loading must be delayed
  1273. * If true, textures will only be loaded when they need to be rendered
  1274. */
  1275. useDelayedTextureLoading: boolean;
  1276. /**
  1277. * Gets the list of meshes imported to the scene through SceneLoader
  1278. */
  1279. importedMeshesFiles: String[];
  1280. /**
  1281. * Gets or sets a boolean indicating if probes are enabled on this scene
  1282. */
  1283. probesEnabled: boolean;
  1284. /**
  1285. * Gets or sets the current offline provider to use to store scene data
  1286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1287. */
  1288. offlineProvider: IOfflineProvider;
  1289. /**
  1290. * Gets or sets the action manager associated with the scene
  1291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1292. */
  1293. actionManager: ActionManager;
  1294. private _meshesForIntersections;
  1295. /**
  1296. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1297. */
  1298. proceduralTexturesEnabled: boolean;
  1299. private _engine;
  1300. private _totalVertices;
  1301. /** @hidden */
  1302. _activeIndices: PerfCounter;
  1303. /** @hidden */
  1304. _activeParticles: PerfCounter;
  1305. /** @hidden */
  1306. _activeBones: PerfCounter;
  1307. private _animationRatio;
  1308. private _animationTimeLast;
  1309. private _animationTime;
  1310. /**
  1311. * Gets or sets a general scale for animation speed
  1312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1313. */
  1314. animationTimeScale: number;
  1315. /** @hidden */
  1316. _cachedMaterial: Nullable<Material>;
  1317. /** @hidden */
  1318. _cachedEffect: Nullable<Effect>;
  1319. /** @hidden */
  1320. _cachedVisibility: Nullable<number>;
  1321. private _renderId;
  1322. private _frameId;
  1323. private _executeWhenReadyTimeoutId;
  1324. private _intermediateRendering;
  1325. private _viewUpdateFlag;
  1326. private _projectionUpdateFlag;
  1327. private _alternateViewUpdateFlag;
  1328. private _alternateProjectionUpdateFlag;
  1329. /** @hidden */
  1330. _toBeDisposed: Nullable<IDisposable>[];
  1331. private _activeRequests;
  1332. private _pendingData;
  1333. private _isDisposed;
  1334. /**
  1335. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1336. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1337. */
  1338. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1339. private _activeMeshes;
  1340. private _processedMaterials;
  1341. private _renderTargets;
  1342. /** @hidden */
  1343. _activeParticleSystems: SmartArray<IParticleSystem>;
  1344. private _activeSkeletons;
  1345. private _softwareSkinnedMeshes;
  1346. private _renderingManager;
  1347. /** @hidden */
  1348. _activeAnimatables: Animatable[];
  1349. private _transformMatrix;
  1350. private _sceneUbo;
  1351. private _alternateSceneUbo;
  1352. private _pickWithRayInverseMatrix;
  1353. private _viewMatrix;
  1354. private _projectionMatrix;
  1355. private _alternateViewMatrix;
  1356. private _alternateProjectionMatrix;
  1357. private _alternateTransformMatrix;
  1358. private _useAlternateCameraConfiguration;
  1359. private _alternateRendering;
  1360. private _wheelEventName;
  1361. /** @hidden */
  1362. _forcedViewPosition: Nullable<Vector3>;
  1363. /** @hidden */
  1364. readonly _isAlternateRenderingEnabled: boolean;
  1365. private _frustumPlanes;
  1366. /**
  1367. * Gets the list of frustum planes (built from the active camera)
  1368. */
  1369. readonly frustumPlanes: Plane[];
  1370. /**
  1371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1372. * This is useful if there are more lights that the maximum simulteanous authorized
  1373. */
  1374. requireLightSorting: boolean;
  1375. /** @hidden */
  1376. readonly useMaterialMeshMap: boolean;
  1377. /** @hidden */
  1378. readonly useClonedMeshhMap: boolean;
  1379. private _pointerOverMesh;
  1380. private _pickedDownMesh;
  1381. private _pickedUpMesh;
  1382. private _externalData;
  1383. private _uid;
  1384. /**
  1385. * @hidden
  1386. * Backing store of defined scene components.
  1387. */
  1388. _components: ISceneComponent[];
  1389. /**
  1390. * @hidden
  1391. * Backing store of defined scene components.
  1392. */
  1393. _serializableComponents: ISceneSerializableComponent[];
  1394. /**
  1395. * List of components to register on the next registration step.
  1396. */
  1397. private _transientComponents;
  1398. /**
  1399. * Registers the transient components if needed.
  1400. */
  1401. private _registerTransientComponents;
  1402. /**
  1403. * @hidden
  1404. * Add a component to the scene.
  1405. * Note that the ccomponent could be registered on th next frame if this is called after
  1406. * the register component stage.
  1407. * @param component Defines the component to add to the scene
  1408. */
  1409. _addComponent(component: ISceneComponent): void;
  1410. /**
  1411. * @hidden
  1412. * Gets a component from the scene.
  1413. * @param name defines the name of the component to retrieve
  1414. * @returns the component or null if not present
  1415. */
  1416. _getComponent(name: string): Nullable<ISceneComponent>;
  1417. /**
  1418. * @hidden
  1419. * Defines the actions happening before camera updates.
  1420. */
  1421. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1422. /**
  1423. * @hidden
  1424. * Defines the actions happening before clear the canvas.
  1425. */
  1426. _beforeClearStage: Stage<SimpleStageAction>;
  1427. /**
  1428. * @hidden
  1429. * Defines the actions when collecting render targets for the frame.
  1430. */
  1431. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1432. /**
  1433. * @hidden
  1434. * Defines the actions happening for one camera in the frame.
  1435. */
  1436. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1437. /**
  1438. * @hidden
  1439. * Defines the actions happening during the per mesh ready checks.
  1440. */
  1441. _isReadyForMeshStage: Stage<MeshStageAction>;
  1442. /**
  1443. * @hidden
  1444. * Defines the actions happening before evaluate active mesh checks.
  1445. */
  1446. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1447. /**
  1448. * @hidden
  1449. * Defines the actions happening during the evaluate sub mesh checks.
  1450. */
  1451. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1452. /**
  1453. * @hidden
  1454. * Defines the actions happening during the active mesh stage.
  1455. */
  1456. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1457. /**
  1458. * @hidden
  1459. * Defines the actions happening during the per camera render target step.
  1460. */
  1461. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1462. /**
  1463. * @hidden
  1464. * Defines the actions happening just before the active camera is drawing.
  1465. */
  1466. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1467. /**
  1468. * @hidden
  1469. * Defines the actions happening just before a render target is drawing.
  1470. */
  1471. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1472. /**
  1473. * @hidden
  1474. * Defines the actions happening just before a rendering group is drawing.
  1475. */
  1476. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1477. /**
  1478. * @hidden
  1479. * Defines the actions happening just before a mesh is drawing.
  1480. */
  1481. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1482. /**
  1483. * @hidden
  1484. * Defines the actions happening just after a mesh has been drawn.
  1485. */
  1486. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1487. /**
  1488. * @hidden
  1489. * Defines the actions happening just after a rendering group has been drawn.
  1490. */
  1491. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1492. /**
  1493. * @hidden
  1494. * Defines the actions happening just after the active camera has been drawn.
  1495. */
  1496. _afterCameraDrawStage: Stage<CameraStageAction>;
  1497. /**
  1498. * @hidden
  1499. * Defines the actions happening just after a render target has been drawn.
  1500. */
  1501. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1502. /**
  1503. * @hidden
  1504. * Defines the actions happening just after rendering all cameras and computing intersections.
  1505. */
  1506. _afterRenderStage: Stage<SimpleStageAction>;
  1507. /**
  1508. * @hidden
  1509. * Defines the actions happening when a pointer move event happens.
  1510. */
  1511. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1512. /**
  1513. * @hidden
  1514. * Defines the actions happening when a pointer down event happens.
  1515. */
  1516. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1517. /**
  1518. * @hidden
  1519. * Defines the actions happening when a pointer up event happens.
  1520. */
  1521. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1522. /**
  1523. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1524. */
  1525. private geometriesByUniqueId;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @param onAnimationLoop defines the callback to call when an animation loops
  1778. * @returns the animatable object created for this animation
  1779. */
  1780. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1781. /**
  1782. * Will start the animation sequence of a given target
  1783. * @param target defines the target
  1784. * @param from defines from which frame should animation start
  1785. * @param to defines until which frame should animation run.
  1786. * @param loop defines if the animation loops
  1787. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1788. * @param onAnimationEnd defines the function to be executed when the animation ends
  1789. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1790. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1791. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  1792. * @param onAnimationLoop defines the callback to call when an animation loops
  1793. * @returns the animatable object created for this animation
  1794. */
  1795. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1796. /**
  1797. * Will start the animation sequence of a given target and its hierarchy
  1798. * @param target defines the target
  1799. * @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.
  1800. * @param from defines from which frame should animation start
  1801. * @param to defines until which frame should animation run.
  1802. * @param loop defines if the animation loops
  1803. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1804. * @param onAnimationEnd defines the function to be executed when the animation ends
  1805. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1806. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1807. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1808. * @param onAnimationLoop defines the callback to call when an animation loops
  1809. * @returns the list of created animatables
  1810. */
  1811. 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[];
  1812. /**
  1813. * Begin a new animation on a given node
  1814. * @param target defines the target where the animation will take place
  1815. * @param animations defines the list of animations to start
  1816. * @param from defines the initial value
  1817. * @param to defines the final value
  1818. * @param loop defines if you want animation to loop (off by default)
  1819. * @param speedRatio defines the speed ratio to apply to all animations
  1820. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1821. * @param onAnimationLoop defines the callback to call when an animation loops
  1822. * @returns the list of created animatables
  1823. */
  1824. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  1825. /**
  1826. * Begin a new animation on a given node and its hierarchy
  1827. * @param target defines the root node where the animation will take place
  1828. * @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.
  1829. * @param animations defines the list of animations to start
  1830. * @param from defines the initial value
  1831. * @param to defines the final value
  1832. * @param loop defines if you want animation to loop (off by default)
  1833. * @param speedRatio defines the speed ratio to apply to all animations
  1834. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1835. * @param onAnimationLoop defines the callback to call when an animation loops
  1836. * @returns the list of animatables created for all nodes
  1837. */
  1838. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  1839. /**
  1840. * Gets the animatable associated with a specific target
  1841. * @param target defines the target of the animatable
  1842. * @returns the required animatable if found
  1843. */
  1844. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1845. /**
  1846. * Gets all animatables associated with a given target
  1847. * @param target defines the target to look animatables for
  1848. * @returns an array of Animatables
  1849. */
  1850. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1851. /**
  1852. * Gets all animatable attached to the scene
  1853. */
  1854. readonly animatables: Animatable[];
  1855. /**
  1856. * Will stop the animation of the given target
  1857. * @param target - the target
  1858. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1859. * @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)
  1860. */
  1861. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1862. /**
  1863. * Stops and removes all animations that have been applied to the scene
  1864. */
  1865. stopAllAnimations(): void;
  1866. /**
  1867. * Resets the last animation time frame.
  1868. * Useful to override when animations start running when loading a scene for the first time.
  1869. */
  1870. resetLastAnimationTimeFrame(): void;
  1871. private _animate;
  1872. /** @hidden */
  1873. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1874. private _processLateAnimationBindingsForMatrices;
  1875. private _processLateAnimationBindingsForQuaternions;
  1876. private _processLateAnimationBindings;
  1877. /** @hidden */
  1878. _switchToAlternateCameraConfiguration(active: boolean): void;
  1879. /**
  1880. * Gets the current view matrix
  1881. * @returns a Matrix
  1882. */
  1883. getViewMatrix(): Matrix;
  1884. /**
  1885. * Gets the current projection matrix
  1886. * @returns a Matrix
  1887. */
  1888. getProjectionMatrix(): Matrix;
  1889. /**
  1890. * Gets the current transform matrix
  1891. * @returns a Matrix made of View * Projection
  1892. */
  1893. getTransformMatrix(): Matrix;
  1894. /**
  1895. * Sets the current transform matrix
  1896. * @param view defines the View matrix to use
  1897. * @param projection defines the Projection matrix to use
  1898. */
  1899. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1900. /** @hidden */
  1901. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1902. /**
  1903. * Gets the uniform buffer used to store scene data
  1904. * @returns a UniformBuffer
  1905. */
  1906. getSceneUniformBuffer(): UniformBuffer;
  1907. /**
  1908. * Gets an unique (relatively to the current scene) Id
  1909. * @returns an unique number for the scene
  1910. */
  1911. getUniqueId(): number;
  1912. /**
  1913. * Add a mesh to the list of scene's meshes
  1914. * @param newMesh defines the mesh to add
  1915. * @param recursive if all child meshes should also be added to the scene
  1916. */
  1917. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1918. /**
  1919. * Remove a mesh for the list of scene's meshes
  1920. * @param toRemove defines the mesh to remove
  1921. * @param recursive if all child meshes should also be removed from the scene
  1922. * @returns the index where the mesh was in the mesh list
  1923. */
  1924. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1925. /**
  1926. * Add a transform node to the list of scene's transform nodes
  1927. * @param newTransformNode defines the transform node to add
  1928. */
  1929. addTransformNode(newTransformNode: TransformNode): void;
  1930. /**
  1931. * Remove a transform node for the list of scene's transform nodes
  1932. * @param toRemove defines the transform node to remove
  1933. * @returns the index where the transform node was in the transform node list
  1934. */
  1935. removeTransformNode(toRemove: TransformNode): number;
  1936. /**
  1937. * Remove a skeleton for the list of scene's skeletons
  1938. * @param toRemove defines the skeleton to remove
  1939. * @returns the index where the skeleton was in the skeleton list
  1940. */
  1941. removeSkeleton(toRemove: Skeleton): number;
  1942. /**
  1943. * Remove a morph target for the list of scene's morph targets
  1944. * @param toRemove defines the morph target to remove
  1945. * @returns the index where the morph target was in the morph target list
  1946. */
  1947. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1948. /**
  1949. * Remove a light for the list of scene's lights
  1950. * @param toRemove defines the light to remove
  1951. * @returns the index where the light was in the light list
  1952. */
  1953. removeLight(toRemove: Light): number;
  1954. /**
  1955. * Remove a camera for the list of scene's cameras
  1956. * @param toRemove defines the camera to remove
  1957. * @returns the index where the camera was in the camera list
  1958. */
  1959. removeCamera(toRemove: Camera): number;
  1960. /**
  1961. * Remove a particle system for the list of scene's particle systems
  1962. * @param toRemove defines the particle system to remove
  1963. * @returns the index where the particle system was in the particle system list
  1964. */
  1965. removeParticleSystem(toRemove: IParticleSystem): number;
  1966. /**
  1967. * Remove a animation for the list of scene's animations
  1968. * @param toRemove defines the animation to remove
  1969. * @returns the index where the animation was in the animation list
  1970. */
  1971. removeAnimation(toRemove: Animation): number;
  1972. /**
  1973. * Removes the given animation group from this scene.
  1974. * @param toRemove The animation group to remove
  1975. * @returns The index of the removed animation group
  1976. */
  1977. removeAnimationGroup(toRemove: AnimationGroup): number;
  1978. /**
  1979. * Removes the given multi-material from this scene.
  1980. * @param toRemove The multi-material to remove
  1981. * @returns The index of the removed multi-material
  1982. */
  1983. removeMultiMaterial(toRemove: MultiMaterial): number;
  1984. /**
  1985. * Removes the given material from this scene.
  1986. * @param toRemove The material to remove
  1987. * @returns The index of the removed material
  1988. */
  1989. removeMaterial(toRemove: Material): number;
  1990. /**
  1991. * Removes the given action manager from this scene.
  1992. * @param toRemove The action manager to remove
  1993. * @returns The index of the removed action manager
  1994. */
  1995. removeActionManager(toRemove: ActionManager): number;
  1996. /**
  1997. * Removes the given texture from this scene.
  1998. * @param toRemove The texture to remove
  1999. * @returns The index of the removed texture
  2000. */
  2001. removeTexture(toRemove: BaseTexture): number;
  2002. /**
  2003. * Adds the given light to this scene
  2004. * @param newLight The light to add
  2005. */
  2006. addLight(newLight: Light): void;
  2007. /**
  2008. * Sorts the list list based on light priorities
  2009. */
  2010. sortLightsByPriority(): void;
  2011. /**
  2012. * Adds the given camera to this scene
  2013. * @param newCamera The camera to add
  2014. */
  2015. addCamera(newCamera: Camera): void;
  2016. /**
  2017. * Adds the given skeleton to this scene
  2018. * @param newSkeleton The skeleton to add
  2019. */
  2020. addSkeleton(newSkeleton: Skeleton): void;
  2021. /**
  2022. * Adds the given particle system to this scene
  2023. * @param newParticleSystem The particle system to add
  2024. */
  2025. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2026. /**
  2027. * Adds the given animation to this scene
  2028. * @param newAnimation The animation to add
  2029. */
  2030. addAnimation(newAnimation: Animation): void;
  2031. /**
  2032. * Adds the given animation group to this scene.
  2033. * @param newAnimationGroup The animation group to add
  2034. */
  2035. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2036. /**
  2037. * Adds the given multi-material to this scene
  2038. * @param newMultiMaterial The multi-material to add
  2039. */
  2040. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2041. /**
  2042. * Adds the given material to this scene
  2043. * @param newMaterial The material to add
  2044. */
  2045. addMaterial(newMaterial: Material): void;
  2046. /**
  2047. * Adds the given morph target to this scene
  2048. * @param newMorphTargetManager The morph target to add
  2049. */
  2050. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2051. /**
  2052. * Adds the given geometry to this scene
  2053. * @param newGeometry The geometry to add
  2054. */
  2055. addGeometry(newGeometry: Geometry): void;
  2056. /**
  2057. * Adds the given action manager to this scene
  2058. * @param newActionManager The action manager to add
  2059. */
  2060. addActionManager(newActionManager: ActionManager): void;
  2061. /**
  2062. * Adds the given texture to this scene.
  2063. * @param newTexture The texture to add
  2064. */
  2065. addTexture(newTexture: BaseTexture): void;
  2066. /**
  2067. * Switch active camera
  2068. * @param newCamera defines the new active camera
  2069. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2070. */
  2071. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2072. /**
  2073. * sets the active camera of the scene using its ID
  2074. * @param id defines the camera's ID
  2075. * @return the new active camera or null if none found.
  2076. */
  2077. setActiveCameraByID(id: string): Nullable<Camera>;
  2078. /**
  2079. * sets the active camera of the scene using its name
  2080. * @param name defines the camera's name
  2081. * @returns the new active camera or null if none found.
  2082. */
  2083. setActiveCameraByName(name: string): Nullable<Camera>;
  2084. /**
  2085. * get an animation group using its name
  2086. * @param name defines the material's name
  2087. * @return the animation group or null if none found.
  2088. */
  2089. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2090. /**
  2091. * get a material using its id
  2092. * @param id defines the material's ID
  2093. * @return the material or null if none found.
  2094. */
  2095. getMaterialByID(id: string): Nullable<Material>;
  2096. /**
  2097. * Gets a material using its name
  2098. * @param name defines the material's name
  2099. * @return the material or null if none found.
  2100. */
  2101. getMaterialByName(name: string): Nullable<Material>;
  2102. /**
  2103. * Gets a camera using its id
  2104. * @param id defines the id to look for
  2105. * @returns the camera or null if not found
  2106. */
  2107. getCameraByID(id: string): Nullable<Camera>;
  2108. /**
  2109. * Gets a camera using its unique id
  2110. * @param uniqueId defines the unique id to look for
  2111. * @returns the camera or null if not found
  2112. */
  2113. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2114. /**
  2115. * Gets a camera using its name
  2116. * @param name defines the camera's name
  2117. * @return the camera or null if none found.
  2118. */
  2119. getCameraByName(name: string): Nullable<Camera>;
  2120. /**
  2121. * Gets a bone using its id
  2122. * @param id defines the bone's id
  2123. * @return the bone or null if not found
  2124. */
  2125. getBoneByID(id: string): Nullable<Bone>;
  2126. /**
  2127. * Gets a bone using its id
  2128. * @param name defines the bone's name
  2129. * @return the bone or null if not found
  2130. */
  2131. getBoneByName(name: string): Nullable<Bone>;
  2132. /**
  2133. * Gets a light node using its name
  2134. * @param name defines the the light's name
  2135. * @return the light or null if none found.
  2136. */
  2137. getLightByName(name: string): Nullable<Light>;
  2138. /**
  2139. * Gets a light node using its id
  2140. * @param id defines the light's id
  2141. * @return the light or null if none found.
  2142. */
  2143. getLightByID(id: string): Nullable<Light>;
  2144. /**
  2145. * Gets a light node using its scene-generated unique ID
  2146. * @param uniqueId defines the light's unique id
  2147. * @return the light or null if none found.
  2148. */
  2149. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2150. /**
  2151. * Gets a particle system by id
  2152. * @param id defines the particle system id
  2153. * @return the corresponding system or null if none found
  2154. */
  2155. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2156. /**
  2157. * Gets a geometry using its ID
  2158. * @param id defines the geometry's id
  2159. * @return the geometry or null if none found.
  2160. */
  2161. getGeometryByID(id: string): Nullable<Geometry>;
  2162. private _getGeometryByUniqueID;
  2163. /**
  2164. * Add a new geometry to this scene
  2165. * @param geometry defines the geometry to be added to the scene.
  2166. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2167. * @return a boolean defining if the geometry was added or not
  2168. */
  2169. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2170. /**
  2171. * Removes an existing geometry
  2172. * @param geometry defines the geometry to be removed from the scene
  2173. * @return a boolean defining if the geometry was removed or not
  2174. */
  2175. removeGeometry(geometry: Geometry): boolean;
  2176. /**
  2177. * Gets the list of geometries attached to the scene
  2178. * @returns an array of Geometry
  2179. */
  2180. getGeometries(): Geometry[];
  2181. /**
  2182. * Gets the first added mesh found of a given ID
  2183. * @param id defines the id to search for
  2184. * @return the mesh found or null if not found at all
  2185. */
  2186. getMeshByID(id: string): Nullable<AbstractMesh>;
  2187. /**
  2188. * Gets a list of meshes using their id
  2189. * @param id defines the id to search for
  2190. * @returns a list of meshes
  2191. */
  2192. getMeshesByID(id: string): Array<AbstractMesh>;
  2193. /**
  2194. * Gets the first added transform node found of a given ID
  2195. * @param id defines the id to search for
  2196. * @return the found transform node or null if not found at all.
  2197. */
  2198. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2199. /**
  2200. * Gets a list of transform nodes using their id
  2201. * @param id defines the id to search for
  2202. * @returns a list of transform nodes
  2203. */
  2204. getTransformNodesByID(id: string): Array<TransformNode>;
  2205. /**
  2206. * Gets a mesh with its auto-generated unique id
  2207. * @param uniqueId defines the unique id to search for
  2208. * @return the found mesh or null if not found at all.
  2209. */
  2210. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2211. /**
  2212. * Gets a the last added mesh using a given id
  2213. * @param id defines the id to search for
  2214. * @return the found mesh or null if not found at all.
  2215. */
  2216. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2217. /**
  2218. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2219. * @param id defines the id to search for
  2220. * @return the found node or null if not found at all
  2221. */
  2222. getLastEntryByID(id: string): Nullable<Node>;
  2223. /**
  2224. * Gets a node (Mesh, Camera, Light) using a given id
  2225. * @param id defines the id to search for
  2226. * @return the found node or null if not found at all
  2227. */
  2228. getNodeByID(id: string): Nullable<Node>;
  2229. /**
  2230. * Gets a node (Mesh, Camera, Light) using a given name
  2231. * @param name defines the name to search for
  2232. * @return the found node or null if not found at all.
  2233. */
  2234. getNodeByName(name: string): Nullable<Node>;
  2235. /**
  2236. * Gets a mesh using a given name
  2237. * @param name defines the name to search for
  2238. * @return the found mesh or null if not found at all.
  2239. */
  2240. getMeshByName(name: string): Nullable<AbstractMesh>;
  2241. /**
  2242. * Gets a transform node using a given name
  2243. * @param name defines the name to search for
  2244. * @return the found transform node or null if not found at all.
  2245. */
  2246. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2247. /**
  2248. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2249. * @param id defines the id to search for
  2250. * @return the found skeleton or null if not found at all.
  2251. */
  2252. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2253. /**
  2254. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2255. * @param id defines the id to search for
  2256. * @return the found skeleton or null if not found at all.
  2257. */
  2258. getSkeletonById(id: string): Nullable<Skeleton>;
  2259. /**
  2260. * Gets a skeleton using a given name
  2261. * @param name defines the name to search for
  2262. * @return the found skeleton or null if not found at all.
  2263. */
  2264. getSkeletonByName(name: string): Nullable<Skeleton>;
  2265. /**
  2266. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2267. * @param id defines the id to search for
  2268. * @return the found morph target manager or null if not found at all.
  2269. */
  2270. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2271. /**
  2272. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2273. * @param id defines the id to search for
  2274. * @return the found morph target or null if not found at all.
  2275. */
  2276. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2277. /**
  2278. * Gets a boolean indicating if the given mesh is active
  2279. * @param mesh defines the mesh to look for
  2280. * @returns true if the mesh is in the active list
  2281. */
  2282. isActiveMesh(mesh: AbstractMesh): boolean;
  2283. /**
  2284. * Return a unique id as a string which can serve as an identifier for the scene
  2285. */
  2286. readonly uid: string;
  2287. /**
  2288. * Add an externaly attached data from its key.
  2289. * This method call will fail and return false, if such key already exists.
  2290. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2291. * @param key the unique key that identifies the data
  2292. * @param data the data object to associate to the key for this Engine instance
  2293. * @return true if no such key were already present and the data was added successfully, false otherwise
  2294. */
  2295. addExternalData<T>(key: string, data: T): boolean;
  2296. /**
  2297. * Get an externaly attached data from its key
  2298. * @param key the unique key that identifies the data
  2299. * @return the associated data, if present (can be null), or undefined if not present
  2300. */
  2301. getExternalData<T>(key: string): Nullable<T>;
  2302. /**
  2303. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2304. * @param key the unique key that identifies the data
  2305. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2306. * @return the associated data, can be null if the factory returned null.
  2307. */
  2308. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2309. /**
  2310. * Remove an externaly attached data from the Engine instance
  2311. * @param key the unique key that identifies the data
  2312. * @return true if the data was successfully removed, false if it doesn't exist
  2313. */
  2314. removeExternalData(key: string): boolean;
  2315. private _evaluateSubMesh;
  2316. /**
  2317. * Clear the processed materials smart array preventing retention point in material dispose.
  2318. */
  2319. freeProcessedMaterials(): void;
  2320. private _preventFreeActiveMeshesAndRenderingGroups;
  2321. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2322. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2323. * when disposing several meshes in a row or a hierarchy of meshes.
  2324. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2325. */
  2326. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2327. /**
  2328. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2329. */
  2330. freeActiveMeshes(): void;
  2331. /**
  2332. * Clear the info related to rendering groups preventing retention points during dispose.
  2333. */
  2334. freeRenderingGroups(): void;
  2335. /** @hidden */
  2336. _isInIntermediateRendering(): boolean;
  2337. /**
  2338. * Lambda returning the list of potentially active meshes.
  2339. */
  2340. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2341. /**
  2342. * Lambda returning the list of potentially active sub meshes.
  2343. */
  2344. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2345. /**
  2346. * Lambda returning the list of potentially intersecting sub meshes.
  2347. */
  2348. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2349. /**
  2350. * Lambda returning the list of potentially colliding sub meshes.
  2351. */
  2352. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2353. private _activeMeshesFrozen;
  2354. /**
  2355. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2356. * @returns the current scene
  2357. */
  2358. freezeActiveMeshes(): Scene;
  2359. /**
  2360. * Use this function to restart evaluating active meshes on every frame
  2361. * @returns the current scene
  2362. */
  2363. unfreezeActiveMeshes(): Scene;
  2364. private _evaluateActiveMeshes;
  2365. private _activeMesh;
  2366. /**
  2367. * Update the transform matrix to update from the current active camera
  2368. * @param force defines a boolean used to force the update even if cache is up to date
  2369. */
  2370. updateTransformMatrix(force?: boolean): void;
  2371. /**
  2372. * 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)
  2373. * @param alternateCamera defines the camera to use
  2374. */
  2375. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2376. /** @hidden */
  2377. _allowPostProcessClearColor: boolean;
  2378. private _renderForCamera;
  2379. private _processSubCameras;
  2380. private _checkIntersections;
  2381. /** @hidden */
  2382. _advancePhysicsEngineStep(step: number): void;
  2383. /**
  2384. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2385. */
  2386. getDeterministicFrameTime: () => number;
  2387. /**
  2388. * Render the scene
  2389. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2390. */
  2391. render(updateCameras?: boolean): void;
  2392. /**
  2393. * Freeze all materials
  2394. * A frozen material will not be updatable but should be faster to render
  2395. */
  2396. freezeMaterials(): void;
  2397. /**
  2398. * Unfreeze all materials
  2399. * A frozen material will not be updatable but should be faster to render
  2400. */
  2401. unfreezeMaterials(): void;
  2402. /**
  2403. * Releases all held ressources
  2404. */
  2405. dispose(): void;
  2406. /**
  2407. * Gets if the scene is already disposed
  2408. */
  2409. readonly isDisposed: boolean;
  2410. /**
  2411. * Call this function to reduce memory footprint of the scene.
  2412. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2413. */
  2414. clearCachedVertexData(): void;
  2415. /**
  2416. * This function will remove the local cached buffer data from texture.
  2417. * It will save memory but will prevent the texture from being rebuilt
  2418. */
  2419. cleanCachedTextureBuffer(): void;
  2420. /**
  2421. * Get the world extend vectors with an optional filter
  2422. *
  2423. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2424. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2425. */
  2426. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2427. min: Vector3;
  2428. max: Vector3;
  2429. };
  2430. /**
  2431. * Creates a ray that can be used to pick in the scene
  2432. * @param x defines the x coordinate of the origin (on-screen)
  2433. * @param y defines the y coordinate of the origin (on-screen)
  2434. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2435. * @param camera defines the camera to use for the picking
  2436. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2437. * @returns a Ray
  2438. */
  2439. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2440. /**
  2441. * Creates a ray that can be used to pick in the scene
  2442. * @param x defines the x coordinate of the origin (on-screen)
  2443. * @param y defines the y coordinate of the origin (on-screen)
  2444. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2445. * @param result defines the ray where to store the picking ray
  2446. * @param camera defines the camera to use for the picking
  2447. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2448. * @returns the current scene
  2449. */
  2450. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2451. /**
  2452. * Creates a ray that can be used to pick in the scene
  2453. * @param x defines the x coordinate of the origin (on-screen)
  2454. * @param y defines the y coordinate of the origin (on-screen)
  2455. * @param camera defines the camera to use for the picking
  2456. * @returns a Ray
  2457. */
  2458. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2459. /**
  2460. * Creates a ray that can be used to pick in the scene
  2461. * @param x defines the x coordinate of the origin (on-screen)
  2462. * @param y defines the y coordinate of the origin (on-screen)
  2463. * @param result defines the ray where to store the picking ray
  2464. * @param camera defines the camera to use for the picking
  2465. * @returns the current scene
  2466. */
  2467. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2468. private _internalPick;
  2469. private _internalMultiPick;
  2470. private _tempPickingRay;
  2471. /** Launch a ray to try to pick a mesh in the scene
  2472. * @param x position on screen
  2473. * @param y position on screen
  2474. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2475. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2476. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2477. * @returns a PickingInfo
  2478. */
  2479. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2480. private _cachedRayForTransform;
  2481. /** Use the given ray to pick a mesh in the scene
  2482. * @param ray The ray to use to pick meshes
  2483. * @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
  2484. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2485. * @returns a PickingInfo
  2486. */
  2487. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2488. /**
  2489. * Launch a ray to try to pick a mesh in the scene
  2490. * @param x X position on screen
  2491. * @param y Y position on screen
  2492. * @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
  2493. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2494. * @returns an array of PickingInfo
  2495. */
  2496. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2497. /**
  2498. * Launch a ray to try to pick a mesh in the scene
  2499. * @param ray Ray to use
  2500. * @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
  2501. * @returns an array of PickingInfo
  2502. */
  2503. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2504. /**
  2505. * Force the value of meshUnderPointer
  2506. * @param mesh defines the mesh to use
  2507. */
  2508. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2509. /**
  2510. * Gets the mesh under the pointer
  2511. * @returns a Mesh or null if no mesh is under the pointer
  2512. */
  2513. getPointerOverMesh(): Nullable<AbstractMesh>;
  2514. /** @hidden */
  2515. _rebuildGeometries(): void;
  2516. /** @hidden */
  2517. _rebuildTextures(): void;
  2518. private _getByTags;
  2519. /**
  2520. * Get a list of meshes by tags
  2521. * @param tagsQuery defines the tags query to use
  2522. * @param forEach defines a predicate used to filter results
  2523. * @returns an array of Mesh
  2524. */
  2525. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2526. /**
  2527. * Get a list of cameras by tags
  2528. * @param tagsQuery defines the tags query to use
  2529. * @param forEach defines a predicate used to filter results
  2530. * @returns an array of Camera
  2531. */
  2532. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2533. /**
  2534. * Get a list of lights by tags
  2535. * @param tagsQuery defines the tags query to use
  2536. * @param forEach defines a predicate used to filter results
  2537. * @returns an array of Light
  2538. */
  2539. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2540. /**
  2541. * Get a list of materials by tags
  2542. * @param tagsQuery defines the tags query to use
  2543. * @param forEach defines a predicate used to filter results
  2544. * @returns an array of Material
  2545. */
  2546. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2547. /**
  2548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2549. * This allowed control for front to back rendering or reversly depending of the special needs.
  2550. *
  2551. * @param renderingGroupId The rendering group id corresponding to its index
  2552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2555. */
  2556. 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;
  2557. /**
  2558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2559. *
  2560. * @param renderingGroupId The rendering group id corresponding to its index
  2561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2562. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2563. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2564. */
  2565. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2566. /**
  2567. * Gets the current auto clear configuration for one rendering group of the rendering
  2568. * manager.
  2569. * @param index the rendering group index to get the information for
  2570. * @returns The auto clear setup for the requested rendering group
  2571. */
  2572. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2573. private _blockMaterialDirtyMechanism;
  2574. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2575. blockMaterialDirtyMechanism: boolean;
  2576. /**
  2577. * Will flag all materials as dirty to trigger new shader compilation
  2578. * @param flag defines the flag used to specify which material part must be marked as dirty
  2579. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2580. */
  2581. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2582. /** @hidden */
  2583. _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;
  2584. /** @hidden */
  2585. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2586. }
  2587. }
  2588. declare module BABYLON {
  2589. /**
  2590. * Groups all the scene component constants in one place to ease maintenance.
  2591. * @hidden
  2592. */
  2593. class SceneComponentConstants {
  2594. static readonly NAME_EFFECTLAYER: string;
  2595. static readonly NAME_LAYER: string;
  2596. static readonly NAME_LENSFLARESYSTEM: string;
  2597. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2598. static readonly NAME_PARTICLESYSTEM: string;
  2599. static readonly NAME_GAMEPAD: string;
  2600. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2601. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2602. static readonly NAME_DEPTHRENDERER: string;
  2603. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2604. static readonly NAME_SPRITE: string;
  2605. static readonly NAME_OUTLINERENDERER: string;
  2606. static readonly NAME_PROCEDURALTEXTURE: string;
  2607. static readonly NAME_SHADOWGENERATOR: string;
  2608. static readonly NAME_OCTREE: string;
  2609. static readonly NAME_PHYSICSENGINE: string;
  2610. static readonly NAME_AUDIO: string;
  2611. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2612. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2613. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2614. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2615. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2616. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2617. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2618. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2619. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2620. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2621. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2622. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2623. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2624. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2625. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2626. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2627. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2628. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2629. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2630. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2631. static readonly STEP_AFTERRENDER_AUDIO: number;
  2632. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2633. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2634. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2635. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2636. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2637. static readonly STEP_POINTERMOVE_SPRITE: number;
  2638. static readonly STEP_POINTERDOWN_SPRITE: number;
  2639. static readonly STEP_POINTERUP_SPRITE: number;
  2640. }
  2641. /**
  2642. * This represents a scene component.
  2643. *
  2644. * This is used to decouple the dependency the scene is having on the different workloads like
  2645. * layers, post processes...
  2646. */
  2647. interface ISceneComponent {
  2648. /**
  2649. * The name of the component. Each component must have a unique name.
  2650. */
  2651. name: string;
  2652. /**
  2653. * The scene the component belongs to.
  2654. */
  2655. scene: Scene;
  2656. /**
  2657. * Register the component to one instance of a scene.
  2658. */
  2659. register(): void;
  2660. /**
  2661. * Rebuilds the elements related to this component in case of
  2662. * context lost for instance.
  2663. */
  2664. rebuild(): void;
  2665. /**
  2666. * Disposes the component and the associated ressources.
  2667. */
  2668. dispose(): void;
  2669. }
  2670. /**
  2671. * This represents a SERIALIZABLE scene component.
  2672. *
  2673. * This extends Scene Component to add Serialization methods on top.
  2674. */
  2675. interface ISceneSerializableComponent extends ISceneComponent {
  2676. /**
  2677. * Adds all the element from the container to the scene
  2678. * @param container the container holding the elements
  2679. */
  2680. addFromContainer(container: AbstractScene): void;
  2681. /**
  2682. * Removes all the elements in the container from the scene
  2683. * @param container contains the elements to remove
  2684. */
  2685. removeFromContainer(container: AbstractScene): void;
  2686. /**
  2687. * Serializes the component data to the specified json object
  2688. * @param serializationObject The object to serialize to
  2689. */
  2690. serialize(serializationObject: any): void;
  2691. }
  2692. /**
  2693. * Strong typing of a Mesh related stage step action
  2694. */
  2695. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2696. /**
  2697. * Strong typing of a Evaluate Sub Mesh related stage step action
  2698. */
  2699. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2700. /**
  2701. * Strong typing of a Active Mesh related stage step action
  2702. */
  2703. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2704. /**
  2705. * Strong typing of a Camera related stage step action
  2706. */
  2707. type CameraStageAction = (camera: Camera) => void;
  2708. /**
  2709. * Strong typing of a Render Target related stage step action
  2710. */
  2711. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2712. /**
  2713. * Strong typing of a RenderingGroup related stage step action
  2714. */
  2715. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2716. /**
  2717. * Strong typing of a Mesh Render related stage step action
  2718. */
  2719. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2720. /**
  2721. * Strong typing of a simple stage step action
  2722. */
  2723. type SimpleStageAction = () => void;
  2724. /**
  2725. * Strong typing of a render target action.
  2726. */
  2727. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2728. /**
  2729. * Strong typing of a pointer move action.
  2730. */
  2731. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2732. /**
  2733. * Strong typing of a pointer up/down action.
  2734. */
  2735. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2736. /**
  2737. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2738. * @hidden
  2739. */
  2740. class Stage<T extends Function> extends Array<{
  2741. index: number;
  2742. component: ISceneComponent;
  2743. action: T;
  2744. }> {
  2745. /**
  2746. * Hide ctor from the rest of the world.
  2747. * @param items The items to add.
  2748. */
  2749. private constructor();
  2750. /**
  2751. * Creates a new Stage.
  2752. * @returns A new instance of a Stage
  2753. */
  2754. static Create<T extends Function>(): Stage<T>;
  2755. /**
  2756. * Registers a step in an ordered way in the targeted stage.
  2757. * @param index Defines the position to register the step in
  2758. * @param component Defines the component attached to the step
  2759. * @param action Defines the action to launch during the step
  2760. */
  2761. registerStep(index: number, component: ISceneComponent, action: T): void;
  2762. /**
  2763. * Clears all the steps from the stage.
  2764. */
  2765. clear(): void;
  2766. }
  2767. }
  2768. declare module BABYLON {
  2769. /** Alias type for value that can be null */
  2770. type Nullable<T> = T | null;
  2771. /**
  2772. * Alias type for number that are floats
  2773. * @ignorenaming
  2774. */
  2775. type float = number;
  2776. /**
  2777. * Alias type for number that are doubles.
  2778. * @ignorenaming
  2779. */
  2780. type double = number;
  2781. /**
  2782. * Alias type for number that are integer
  2783. * @ignorenaming
  2784. */
  2785. type int = number;
  2786. /** Alias type for number array or Float32Array */
  2787. type FloatArray = number[] | Float32Array;
  2788. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2789. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2790. /**
  2791. * Alias for types that can be used by a Buffer or VertexBuffer.
  2792. */
  2793. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2794. /**
  2795. * Alias type for primitive types
  2796. * @ignorenaming
  2797. */
  2798. type Primitive = undefined | null | boolean | string | number | Function;
  2799. /**
  2800. * Type modifier to make all the properties of an object Readonly
  2801. */
  2802. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2803. /**
  2804. * Type modifier to make all the properties of an object Readonly recursively
  2805. */
  2806. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2807. /** @hidden */
  2808. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2809. }
  2810. /** @hidden */
  2811. /** @hidden */
  2812. type DeepImmutableObject<T> = {
  2813. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2814. };
  2815. }
  2816. declare module BABYLON {
  2817. /**
  2818. * The action to be carried out following a trigger
  2819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2820. */
  2821. class Action {
  2822. /** the trigger, with or without parameters, for the action */
  2823. triggerOptions: any;
  2824. /**
  2825. * Trigger for the action
  2826. */
  2827. trigger: number;
  2828. /**
  2829. * Internal only - manager for action
  2830. * @hidden
  2831. */
  2832. _actionManager: ActionManager;
  2833. private _nextActiveAction;
  2834. private _child;
  2835. private _condition?;
  2836. private _triggerParameter;
  2837. /**
  2838. * An event triggered prior to action being executed.
  2839. */
  2840. onBeforeExecuteObservable: Observable<Action>;
  2841. /**
  2842. * Creates a new Action
  2843. * @param triggerOptions the trigger, with or without parameters, for the action
  2844. * @param condition an optional determinant of action
  2845. */
  2846. constructor(
  2847. /** the trigger, with or without parameters, for the action */
  2848. triggerOptions: any, condition?: Condition);
  2849. /**
  2850. * Internal only
  2851. * @hidden
  2852. */
  2853. _prepare(): void;
  2854. /**
  2855. * Gets the trigger parameters
  2856. * @returns the trigger parameters
  2857. */
  2858. getTriggerParameter(): any;
  2859. /**
  2860. * Internal only - executes current action event
  2861. * @hidden
  2862. */
  2863. _executeCurrent(evt?: ActionEvent): void;
  2864. /**
  2865. * Execute placeholder for child classes
  2866. * @param evt optional action event
  2867. */
  2868. execute(evt?: ActionEvent): void;
  2869. /**
  2870. * Skips to next active action
  2871. */
  2872. skipToNextActiveAction(): void;
  2873. /**
  2874. * Adds action to chain of actions, may be a DoNothingAction
  2875. * @param action defines the next action to execute
  2876. * @returns The action passed in
  2877. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2878. */
  2879. then(action: Action): Action;
  2880. /**
  2881. * Internal only
  2882. * @hidden
  2883. */
  2884. _getProperty(propertyPath: string): string;
  2885. /**
  2886. * Internal only
  2887. * @hidden
  2888. */
  2889. _getEffectiveTarget(target: any, propertyPath: string): any;
  2890. /**
  2891. * Serialize placeholder for child classes
  2892. * @param parent of child
  2893. * @returns the serialized object
  2894. */
  2895. serialize(parent: any): any;
  2896. /**
  2897. * Internal only called by serialize
  2898. * @hidden
  2899. */
  2900. protected _serialize(serializedAction: any, parent?: any): any;
  2901. /**
  2902. * Internal only
  2903. * @hidden
  2904. */
  2905. static _SerializeValueAsString: (value: any) => string;
  2906. /**
  2907. * Internal only
  2908. * @hidden
  2909. */
  2910. static _GetTargetProperty: (target: Scene | Node) => {
  2911. name: string;
  2912. targetType: string;
  2913. value: string;
  2914. };
  2915. }
  2916. }
  2917. declare module BABYLON {
  2918. /**
  2919. * ActionEvent is the event being sent when an action is triggered.
  2920. */
  2921. class ActionEvent {
  2922. /** The mesh or sprite that triggered the action */
  2923. source: any;
  2924. /** The X mouse cursor position at the time of the event */
  2925. pointerX: number;
  2926. /** The Y mouse cursor position at the time of the event */
  2927. pointerY: number;
  2928. /** The mesh that is currently pointed at (can be null) */
  2929. meshUnderPointer: Nullable<AbstractMesh>;
  2930. /** the original (browser) event that triggered the ActionEvent */
  2931. sourceEvent?: any;
  2932. /** additional data for the event */
  2933. additionalData?: any;
  2934. /**
  2935. * Creates a new ActionEvent
  2936. * @param source The mesh or sprite that triggered the action
  2937. * @param pointerX The X mouse cursor position at the time of the event
  2938. * @param pointerY The Y mouse cursor position at the time of the event
  2939. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2940. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2941. * @param additionalData additional data for the event
  2942. */
  2943. constructor(
  2944. /** The mesh or sprite that triggered the action */
  2945. source: any,
  2946. /** The X mouse cursor position at the time of the event */
  2947. pointerX: number,
  2948. /** The Y mouse cursor position at the time of the event */
  2949. pointerY: number,
  2950. /** The mesh that is currently pointed at (can be null) */
  2951. meshUnderPointer: Nullable<AbstractMesh>,
  2952. /** the original (browser) event that triggered the ActionEvent */
  2953. sourceEvent?: any,
  2954. /** additional data for the event */
  2955. additionalData?: any);
  2956. /**
  2957. * Helper function to auto-create an ActionEvent from a source mesh.
  2958. * @param source The source mesh that triggered the event
  2959. * @param evt The original (browser) event
  2960. * @param additionalData additional data for the event
  2961. * @returns the new ActionEvent
  2962. */
  2963. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2964. /**
  2965. * Helper function to auto-create an ActionEvent from a source sprite
  2966. * @param source The source sprite that triggered the event
  2967. * @param scene Scene associated with the sprite
  2968. * @param evt The original (browser) event
  2969. * @param additionalData additional data for the event
  2970. * @returns the new ActionEvent
  2971. */
  2972. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2973. /**
  2974. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2975. * @param scene the scene where the event occurred
  2976. * @param evt The original (browser) event
  2977. * @returns the new ActionEvent
  2978. */
  2979. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2980. /**
  2981. * Helper function to auto-create an ActionEvent from a primitive
  2982. * @param prim defines the target primitive
  2983. * @param pointerPos defines the pointer position
  2984. * @param evt The original (browser) event
  2985. * @param additionalData additional data for the event
  2986. * @returns the new ActionEvent
  2987. */
  2988. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2989. }
  2990. /**
  2991. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2992. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2994. */
  2995. class ActionManager {
  2996. /**
  2997. * Nothing
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly NothingTrigger: number;
  3001. /**
  3002. * On pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnPickTrigger: number;
  3006. /**
  3007. * On left pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnLeftPickTrigger: number;
  3011. /**
  3012. * On right pick
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnRightPickTrigger: number;
  3016. /**
  3017. * On center pick
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnCenterPickTrigger: number;
  3021. /**
  3022. * On pick down
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnPickDownTrigger: number;
  3026. /**
  3027. * On double pick
  3028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3029. */
  3030. static readonly OnDoublePickTrigger: number;
  3031. /**
  3032. * On pick up
  3033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3034. */
  3035. static readonly OnPickUpTrigger: number;
  3036. /**
  3037. * On pick out.
  3038. * This trigger will only be raised if you also declared a OnPickDown
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnPickOutTrigger: number;
  3042. /**
  3043. * On long press
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnLongPressTrigger: number;
  3047. /**
  3048. * On pointer over
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnPointerOverTrigger: number;
  3052. /**
  3053. * On pointer out
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnPointerOutTrigger: number;
  3057. /**
  3058. * On every frame
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnEveryFrameTrigger: number;
  3062. /**
  3063. * On intersection enter
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnIntersectionEnterTrigger: number;
  3067. /**
  3068. * On intersection exit
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnIntersectionExitTrigger: number;
  3072. /**
  3073. * On key down
  3074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3075. */
  3076. static readonly OnKeyDownTrigger: number;
  3077. /**
  3078. * On key up
  3079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3080. */
  3081. static readonly OnKeyUpTrigger: number;
  3082. /** Gets the list of active triggers */
  3083. static Triggers: {
  3084. [key: string]: number;
  3085. };
  3086. /** Gets the list of actions */
  3087. actions: Action[];
  3088. /** Gets the cursor to use when hovering items */
  3089. hoverCursor: string;
  3090. private _scene;
  3091. /**
  3092. * Creates a new action manager
  3093. * @param scene defines the hosting scene
  3094. */
  3095. constructor(scene: Scene);
  3096. /**
  3097. * Releases all associated resources
  3098. */
  3099. dispose(): void;
  3100. /**
  3101. * Gets hosting scene
  3102. * @returns the hosting scene
  3103. */
  3104. getScene(): Scene;
  3105. /**
  3106. * Does this action manager handles actions of any of the given triggers
  3107. * @param triggers defines the triggers to be tested
  3108. * @return a boolean indicating whether one (or more) of the triggers is handled
  3109. */
  3110. hasSpecificTriggers(triggers: number[]): boolean;
  3111. /**
  3112. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3113. * speed.
  3114. * @param triggerA defines the trigger to be tested
  3115. * @param triggerB defines the trigger to be tested
  3116. * @return a boolean indicating whether one (or more) of the triggers is handled
  3117. */
  3118. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3119. /**
  3120. * Does this action manager handles actions of a given trigger
  3121. * @param trigger defines the trigger to be tested
  3122. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3123. * @return whether the trigger is handled
  3124. */
  3125. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3126. /**
  3127. * Does this action manager has pointer triggers
  3128. */
  3129. readonly hasPointerTriggers: boolean;
  3130. /**
  3131. * Does this action manager has pick triggers
  3132. */
  3133. readonly hasPickTriggers: boolean;
  3134. /**
  3135. * Does exist one action manager with at least one trigger
  3136. **/
  3137. static readonly HasTriggers: boolean;
  3138. /**
  3139. * Does exist one action manager with at least one pick trigger
  3140. **/
  3141. static readonly HasPickTriggers: boolean;
  3142. /**
  3143. * Does exist one action manager that handles actions of a given trigger
  3144. * @param trigger defines the trigger to be tested
  3145. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3146. **/
  3147. static HasSpecificTrigger(trigger: number): boolean;
  3148. /**
  3149. * Registers an action to this action manager
  3150. * @param action defines the action to be registered
  3151. * @return the action amended (prepared) after registration
  3152. */
  3153. registerAction(action: Action): Nullable<Action>;
  3154. /**
  3155. * Unregisters an action to this action manager
  3156. * @param action defines the action to be unregistered
  3157. * @return a boolean indicating whether the action has been unregistered
  3158. */
  3159. unregisterAction(action: Action): Boolean;
  3160. /**
  3161. * Process a specific trigger
  3162. * @param trigger defines the trigger to process
  3163. * @param evt defines the event details to be processed
  3164. */
  3165. processTrigger(trigger: number, evt?: ActionEvent): void;
  3166. /** @hidden */
  3167. _getEffectiveTarget(target: any, propertyPath: string): any;
  3168. /** @hidden */
  3169. _getProperty(propertyPath: string): string;
  3170. /**
  3171. * Serialize this manager to a JSON object
  3172. * @param name defines the property name to store this manager
  3173. * @returns a JSON representation of this manager
  3174. */
  3175. serialize(name: string): any;
  3176. /**
  3177. * Creates a new ActionManager from a JSON data
  3178. * @param parsedActions defines the JSON data to read from
  3179. * @param object defines the hosting mesh
  3180. * @param scene defines the hosting scene
  3181. */
  3182. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3183. /**
  3184. * Get a trigger name by index
  3185. * @param trigger defines the trigger index
  3186. * @returns a trigger name
  3187. */
  3188. static GetTriggerName(trigger: number): string;
  3189. }
  3190. }
  3191. declare module BABYLON {
  3192. /**
  3193. * A Condition applied to an Action
  3194. */
  3195. class Condition {
  3196. /**
  3197. * Internal only - manager for action
  3198. * @hidden
  3199. */
  3200. _actionManager: ActionManager;
  3201. /**
  3202. * Internal only
  3203. * @hidden
  3204. */
  3205. _evaluationId: number;
  3206. /**
  3207. * Internal only
  3208. * @hidden
  3209. */
  3210. _currentResult: boolean;
  3211. /**
  3212. * Creates a new Condition
  3213. * @param actionManager the manager of the action the condition is applied to
  3214. */
  3215. constructor(actionManager: ActionManager);
  3216. /**
  3217. * Check if the current condition is valid
  3218. * @returns a boolean
  3219. */
  3220. isValid(): boolean;
  3221. /**
  3222. * Internal only
  3223. * @hidden
  3224. */
  3225. _getProperty(propertyPath: string): string;
  3226. /**
  3227. * Internal only
  3228. * @hidden
  3229. */
  3230. _getEffectiveTarget(target: any, propertyPath: string): any;
  3231. /**
  3232. * Serialize placeholder for child classes
  3233. * @returns the serialized object
  3234. */
  3235. serialize(): any;
  3236. /**
  3237. * Internal only
  3238. * @hidden
  3239. */
  3240. protected _serialize(serializedCondition: any): any;
  3241. }
  3242. /**
  3243. * Defines specific conditional operators as extensions of Condition
  3244. */
  3245. class ValueCondition extends Condition {
  3246. /** path to specify the property of the target the conditional operator uses */
  3247. propertyPath: string;
  3248. /** the value compared by the conditional operator against the current value of the property */
  3249. value: any;
  3250. /** the conditional operator, default ValueCondition.IsEqual */
  3251. operator: number;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsEqual;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsDifferent;
  3262. /**
  3263. * Internal only
  3264. * @hidden
  3265. */
  3266. private static _IsGreater;
  3267. /**
  3268. * Internal only
  3269. * @hidden
  3270. */
  3271. private static _IsLesser;
  3272. /**
  3273. * returns the number for IsEqual
  3274. */
  3275. static readonly IsEqual: number;
  3276. /**
  3277. * Returns the number for IsDifferent
  3278. */
  3279. static readonly IsDifferent: number;
  3280. /**
  3281. * Returns the number for IsGreater
  3282. */
  3283. static readonly IsGreater: number;
  3284. /**
  3285. * Returns the number for IsLesser
  3286. */
  3287. static readonly IsLesser: number;
  3288. /**
  3289. * Internal only The action manager for the condition
  3290. * @hidden
  3291. */
  3292. _actionManager: ActionManager;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _target;
  3298. /**
  3299. * Internal only
  3300. * @hidden
  3301. */
  3302. private _effectiveTarget;
  3303. /**
  3304. * Internal only
  3305. * @hidden
  3306. */
  3307. private _property;
  3308. /**
  3309. * Creates a new ValueCondition
  3310. * @param actionManager manager for the action the condition applies to
  3311. * @param target for the action
  3312. * @param propertyPath path to specify the property of the target the conditional operator uses
  3313. * @param value the value compared by the conditional operator against the current value of the property
  3314. * @param operator the conditional operator, default ValueCondition.IsEqual
  3315. */
  3316. constructor(actionManager: ActionManager, target: any,
  3317. /** path to specify the property of the target the conditional operator uses */
  3318. propertyPath: string,
  3319. /** the value compared by the conditional operator against the current value of the property */
  3320. value: any,
  3321. /** the conditional operator, default ValueCondition.IsEqual */
  3322. operator?: number);
  3323. /**
  3324. * Compares the given value with the property value for the specified conditional operator
  3325. * @returns the result of the comparison
  3326. */
  3327. isValid(): boolean;
  3328. /**
  3329. * Serialize the ValueCondition into a JSON compatible object
  3330. * @returns serialization object
  3331. */
  3332. serialize(): any;
  3333. /**
  3334. * Gets the name of the conditional operator for the ValueCondition
  3335. * @param operator the conditional operator
  3336. * @returns the name
  3337. */
  3338. static GetOperatorName(operator: number): string;
  3339. }
  3340. /**
  3341. * Defines a predicate condition as an extension of Condition
  3342. */
  3343. class PredicateCondition extends Condition {
  3344. /** defines the predicate function used to validate the condition */
  3345. predicate: () => boolean;
  3346. /**
  3347. * Internal only - manager for action
  3348. * @hidden
  3349. */
  3350. _actionManager: ActionManager;
  3351. /**
  3352. * Creates a new PredicateCondition
  3353. * @param actionManager manager for the action the condition applies to
  3354. * @param predicate defines the predicate function used to validate the condition
  3355. */
  3356. constructor(actionManager: ActionManager,
  3357. /** defines the predicate function used to validate the condition */
  3358. predicate: () => boolean);
  3359. /**
  3360. * @returns the validity of the predicate condition
  3361. */
  3362. isValid(): boolean;
  3363. }
  3364. /**
  3365. * Defines a state condition as an extension of Condition
  3366. */
  3367. class StateCondition extends Condition {
  3368. /** Value to compare with target state */
  3369. value: string;
  3370. /**
  3371. * Internal only - manager for action
  3372. * @hidden
  3373. */
  3374. _actionManager: ActionManager;
  3375. /**
  3376. * Internal only
  3377. * @hidden
  3378. */
  3379. private _target;
  3380. /**
  3381. * Creates a new StateCondition
  3382. * @param actionManager manager for the action the condition applies to
  3383. * @param target of the condition
  3384. * @param value to compare with target state
  3385. */
  3386. constructor(actionManager: ActionManager, target: any,
  3387. /** Value to compare with target state */
  3388. value: string);
  3389. /**
  3390. * Gets a boolean indicating if the current condition is met
  3391. * @returns the validity of the state
  3392. */
  3393. isValid(): boolean;
  3394. /**
  3395. * Serialize the StateCondition into a JSON compatible object
  3396. * @returns serialization object
  3397. */
  3398. serialize(): any;
  3399. }
  3400. }
  3401. declare module BABYLON {
  3402. /**
  3403. * This defines an action responsible to toggle a boolean once triggered.
  3404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3405. */
  3406. class SwitchBooleanAction extends Action {
  3407. /**
  3408. * The path to the boolean property in the target object
  3409. */
  3410. propertyPath: string;
  3411. private _target;
  3412. private _effectiveTarget;
  3413. private _property;
  3414. /**
  3415. * Instantiate the action
  3416. * @param triggerOptions defines the trigger options
  3417. * @param target defines the object containing the boolean
  3418. * @param propertyPath defines the path to the boolean property in the target object
  3419. * @param condition defines the trigger related conditions
  3420. */
  3421. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3422. /** @hidden */
  3423. _prepare(): void;
  3424. /**
  3425. * Execute the action toggle the boolean value.
  3426. */
  3427. execute(): void;
  3428. /**
  3429. * Serializes the actions and its related information.
  3430. * @param parent defines the object to serialize in
  3431. * @returns the serialized object
  3432. */
  3433. serialize(parent: any): any;
  3434. }
  3435. /**
  3436. * This defines an action responsible to set a the state field of the target
  3437. * to a desired value once triggered.
  3438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3439. */
  3440. class SetStateAction extends Action {
  3441. /**
  3442. * The value to store in the state field.
  3443. */
  3444. value: string;
  3445. private _target;
  3446. /**
  3447. * Instantiate the action
  3448. * @param triggerOptions defines the trigger options
  3449. * @param target defines the object containing the state property
  3450. * @param value defines the value to store in the state field
  3451. * @param condition defines the trigger related conditions
  3452. */
  3453. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3454. /**
  3455. * Execute the action and store the value on the target state property.
  3456. */
  3457. execute(): void;
  3458. /**
  3459. * Serializes the actions and its related information.
  3460. * @param parent defines the object to serialize in
  3461. * @returns the serialized object
  3462. */
  3463. serialize(parent: any): any;
  3464. }
  3465. /**
  3466. * This defines an action responsible to set a property of the target
  3467. * to a desired value once triggered.
  3468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3469. */
  3470. class SetValueAction extends Action {
  3471. /**
  3472. * The path of the property to set in the target.
  3473. */
  3474. propertyPath: string;
  3475. /**
  3476. * The value to set in the property
  3477. */
  3478. value: any;
  3479. private _target;
  3480. private _effectiveTarget;
  3481. private _property;
  3482. /**
  3483. * Instantiate the action
  3484. * @param triggerOptions defines the trigger options
  3485. * @param target defines the object containing the property
  3486. * @param propertyPath defines the path of the property to set in the target
  3487. * @param value defines the value to set in the property
  3488. * @param condition defines the trigger related conditions
  3489. */
  3490. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3491. /** @hidden */
  3492. _prepare(): void;
  3493. /**
  3494. * Execute the action and set the targetted property to the desired value.
  3495. */
  3496. execute(): void;
  3497. /**
  3498. * Serializes the actions and its related information.
  3499. * @param parent defines the object to serialize in
  3500. * @returns the serialized object
  3501. */
  3502. serialize(parent: any): any;
  3503. }
  3504. /**
  3505. * This defines an action responsible to increment the target value
  3506. * to a desired value once triggered.
  3507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3508. */
  3509. class IncrementValueAction extends Action {
  3510. /**
  3511. * The path of the property to increment in the target.
  3512. */
  3513. propertyPath: string;
  3514. /**
  3515. * The value we should increment the property by.
  3516. */
  3517. value: any;
  3518. private _target;
  3519. private _effectiveTarget;
  3520. private _property;
  3521. /**
  3522. * Instantiate the action
  3523. * @param triggerOptions defines the trigger options
  3524. * @param target defines the object containing the property
  3525. * @param propertyPath defines the path of the property to increment in the target
  3526. * @param value defines the value value we should increment the property by
  3527. * @param condition defines the trigger related conditions
  3528. */
  3529. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3530. /** @hidden */
  3531. _prepare(): void;
  3532. /**
  3533. * Execute the action and increment the target of the value amount.
  3534. */
  3535. execute(): void;
  3536. /**
  3537. * Serializes the actions and its related information.
  3538. * @param parent defines the object to serialize in
  3539. * @returns the serialized object
  3540. */
  3541. serialize(parent: any): any;
  3542. }
  3543. /**
  3544. * This defines an action responsible to start an animation once triggered.
  3545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3546. */
  3547. class PlayAnimationAction extends Action {
  3548. /**
  3549. * Where the animation should start (animation frame)
  3550. */
  3551. from: number;
  3552. /**
  3553. * Where the animation should stop (animation frame)
  3554. */
  3555. to: number;
  3556. /**
  3557. * Define if the animation should loop or stop after the first play.
  3558. */
  3559. loop?: boolean;
  3560. private _target;
  3561. /**
  3562. * Instantiate the action
  3563. * @param triggerOptions defines the trigger options
  3564. * @param target defines the target animation or animation name
  3565. * @param from defines from where the animation should start (animation frame)
  3566. * @param end defines where the animation should stop (animation frame)
  3567. * @param loop defines if the animation should loop or stop after the first play
  3568. * @param condition defines the trigger related conditions
  3569. */
  3570. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3571. /** @hidden */
  3572. _prepare(): void;
  3573. /**
  3574. * Execute the action and play the animation.
  3575. */
  3576. execute(): void;
  3577. /**
  3578. * Serializes the actions and its related information.
  3579. * @param parent defines the object to serialize in
  3580. * @returns the serialized object
  3581. */
  3582. serialize(parent: any): any;
  3583. }
  3584. /**
  3585. * This defines an action responsible to stop an animation once triggered.
  3586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3587. */
  3588. class StopAnimationAction extends Action {
  3589. private _target;
  3590. /**
  3591. * Instantiate the action
  3592. * @param triggerOptions defines the trigger options
  3593. * @param target defines the target animation or animation name
  3594. * @param condition defines the trigger related conditions
  3595. */
  3596. constructor(triggerOptions: any, target: any, condition?: Condition);
  3597. /** @hidden */
  3598. _prepare(): void;
  3599. /**
  3600. * Execute the action and stop the animation.
  3601. */
  3602. execute(): void;
  3603. /**
  3604. * Serializes the actions and its related information.
  3605. * @param parent defines the object to serialize in
  3606. * @returns the serialized object
  3607. */
  3608. serialize(parent: any): any;
  3609. }
  3610. /**
  3611. * This defines an action responsible that does nothing once triggered.
  3612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3613. */
  3614. class DoNothingAction extends Action {
  3615. /**
  3616. * Instantiate the action
  3617. * @param triggerOptions defines the trigger options
  3618. * @param condition defines the trigger related conditions
  3619. */
  3620. constructor(triggerOptions?: any, condition?: Condition);
  3621. /**
  3622. * Execute the action and do nothing.
  3623. */
  3624. execute(): void;
  3625. /**
  3626. * Serializes the actions and its related information.
  3627. * @param parent defines the object to serialize in
  3628. * @returns the serialized object
  3629. */
  3630. serialize(parent: any): any;
  3631. }
  3632. /**
  3633. * This defines an action responsible to trigger several actions once triggered.
  3634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3635. */
  3636. class CombineAction extends Action {
  3637. /**
  3638. * The list of aggregated animations to run.
  3639. */
  3640. children: Action[];
  3641. /**
  3642. * Instantiate the action
  3643. * @param triggerOptions defines the trigger options
  3644. * @param children defines the list of aggregated animations to run
  3645. * @param condition defines the trigger related conditions
  3646. */
  3647. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3648. /** @hidden */
  3649. _prepare(): void;
  3650. /**
  3651. * Execute the action and executes all the aggregated actions.
  3652. */
  3653. execute(evt: ActionEvent): void;
  3654. /**
  3655. * Serializes the actions and its related information.
  3656. * @param parent defines the object to serialize in
  3657. * @returns the serialized object
  3658. */
  3659. serialize(parent: any): any;
  3660. }
  3661. /**
  3662. * This defines an action responsible to run code (external event) once triggered.
  3663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3664. */
  3665. class ExecuteCodeAction extends Action {
  3666. /**
  3667. * The callback function to run.
  3668. */
  3669. func: (evt: ActionEvent) => void;
  3670. /**
  3671. * Instantiate the action
  3672. * @param triggerOptions defines the trigger options
  3673. * @param func defines the callback function to run
  3674. * @param condition defines the trigger related conditions
  3675. */
  3676. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3677. /**
  3678. * Execute the action and run the attached code.
  3679. */
  3680. execute(evt: ActionEvent): void;
  3681. }
  3682. /**
  3683. * This defines an action responsible to set the parent property of the target once triggered.
  3684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3685. */
  3686. class SetParentAction extends Action {
  3687. private _parent;
  3688. private _target;
  3689. /**
  3690. * Instantiate the action
  3691. * @param triggerOptions defines the trigger options
  3692. * @param target defines the target containing the parent property
  3693. * @param parent defines from where the animation should start (animation frame)
  3694. * @param condition defines the trigger related conditions
  3695. */
  3696. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3697. /** @hidden */
  3698. _prepare(): void;
  3699. /**
  3700. * Execute the action and set the parent property.
  3701. */
  3702. execute(): void;
  3703. /**
  3704. * Serializes the actions and its related information.
  3705. * @param parent defines the object to serialize in
  3706. * @returns the serialized object
  3707. */
  3708. serialize(parent: any): any;
  3709. }
  3710. }
  3711. declare module BABYLON {
  3712. /**
  3713. * This defines an action helpful to play a defined sound on a triggered action.
  3714. */
  3715. class PlaySoundAction extends Action {
  3716. private _sound;
  3717. /**
  3718. * Instantiate the action
  3719. * @param triggerOptions defines the trigger options
  3720. * @param sound defines the sound to play
  3721. * @param condition defines the trigger related conditions
  3722. */
  3723. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3724. /** @hidden */
  3725. _prepare(): void;
  3726. /**
  3727. * Execute the action and play the sound.
  3728. */
  3729. execute(): void;
  3730. /**
  3731. * Serializes the actions and its related information.
  3732. * @param parent defines the object to serialize in
  3733. * @returns the serialized object
  3734. */
  3735. serialize(parent: any): any;
  3736. }
  3737. /**
  3738. * This defines an action helpful to stop a defined sound on a triggered action.
  3739. */
  3740. class StopSoundAction extends Action {
  3741. private _sound;
  3742. /**
  3743. * Instantiate the action
  3744. * @param triggerOptions defines the trigger options
  3745. * @param sound defines the sound to stop
  3746. * @param condition defines the trigger related conditions
  3747. */
  3748. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3749. /** @hidden */
  3750. _prepare(): void;
  3751. /**
  3752. * Execute the action and stop the sound.
  3753. */
  3754. execute(): void;
  3755. /**
  3756. * Serializes the actions and its related information.
  3757. * @param parent defines the object to serialize in
  3758. * @returns the serialized object
  3759. */
  3760. serialize(parent: any): any;
  3761. }
  3762. }
  3763. declare module BABYLON {
  3764. /**
  3765. * This defines an action responsible to change the value of a property
  3766. * by interpolating between its current value and the newly set one once triggered.
  3767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3768. */
  3769. class InterpolateValueAction extends Action {
  3770. /**
  3771. * Defines the path of the property where the value should be interpolated
  3772. */
  3773. propertyPath: string;
  3774. /**
  3775. * Defines the target value at the end of the interpolation.
  3776. */
  3777. value: any;
  3778. /**
  3779. * Defines the time it will take for the property to interpolate to the value.
  3780. */
  3781. duration: number;
  3782. /**
  3783. * Defines if the other scene animations should be stopped when the action has been triggered
  3784. */
  3785. stopOtherAnimations?: boolean;
  3786. /**
  3787. * Defines a callback raised once the interpolation animation has been done.
  3788. */
  3789. onInterpolationDone?: () => void;
  3790. /**
  3791. * Observable triggered once the interpolation animation has been done.
  3792. */
  3793. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3794. private _target;
  3795. private _effectiveTarget;
  3796. private _property;
  3797. /**
  3798. * Instantiate the action
  3799. * @param triggerOptions defines the trigger options
  3800. * @param target defines the object containing the value to interpolate
  3801. * @param propertyPath defines the path to the property in the target object
  3802. * @param value defines the target value at the end of the interpolation
  3803. * @param duration deines the time it will take for the property to interpolate to the value.
  3804. * @param condition defines the trigger related conditions
  3805. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3806. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3807. */
  3808. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3809. /** @hidden */
  3810. _prepare(): void;
  3811. /**
  3812. * Execute the action starts the value interpolation.
  3813. */
  3814. execute(): void;
  3815. /**
  3816. * Serializes the actions and its related information.
  3817. * @param parent defines the object to serialize in
  3818. * @returns the serialized object
  3819. */
  3820. serialize(parent: any): any;
  3821. }
  3822. }
  3823. declare module BABYLON {
  3824. /**
  3825. * Class used to store an actual running animation
  3826. */
  3827. class Animatable {
  3828. /** defines the target object */
  3829. target: any;
  3830. /** defines the starting frame number (default is 0) */
  3831. fromFrame: number;
  3832. /** defines the ending frame number (default is 100) */
  3833. toFrame: number;
  3834. /** defines if the animation must loop (default is false) */
  3835. loopAnimation: boolean;
  3836. /** defines a callback to call when animation ends if it is not looping */
  3837. onAnimationEnd?: (() => void) | null | undefined;
  3838. /** defines a callback to call when animation loops */
  3839. onAnimationLoop?: (() => void) | null | undefined;
  3840. private _localDelayOffset;
  3841. private _pausedDelay;
  3842. private _runtimeAnimations;
  3843. private _paused;
  3844. private _scene;
  3845. private _speedRatio;
  3846. private _weight;
  3847. private _syncRoot;
  3848. /**
  3849. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3850. * This will only apply for non looping animation (default is true)
  3851. */
  3852. disposeOnEnd: boolean;
  3853. /**
  3854. * Gets a boolean indicating if the animation has started
  3855. */
  3856. animationStarted: boolean;
  3857. /**
  3858. * Observer raised when the animation ends
  3859. */
  3860. onAnimationEndObservable: Observable<Animatable>;
  3861. /**
  3862. * Observer raised when the animation loops
  3863. */
  3864. onAnimationLoopObservable: Observable<Animatable>;
  3865. /**
  3866. * Gets the root Animatable used to synchronize and normalize animations
  3867. */
  3868. readonly syncRoot: Animatable;
  3869. /**
  3870. * Gets the current frame of the first RuntimeAnimation
  3871. * Used to synchronize Animatables
  3872. */
  3873. readonly masterFrame: number;
  3874. /**
  3875. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3876. */
  3877. weight: number;
  3878. /**
  3879. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3880. */
  3881. speedRatio: number;
  3882. /**
  3883. * Creates a new Animatable
  3884. * @param scene defines the hosting scene
  3885. * @param target defines the target object
  3886. * @param fromFrame defines the starting frame number (default is 0)
  3887. * @param toFrame defines the ending frame number (default is 100)
  3888. * @param loopAnimation defines if the animation must loop (default is false)
  3889. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3890. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3891. * @param animations defines a group of animation to add to the new Animatable
  3892. * @param onAnimationLoop defines a callback to call when animation loops
  3893. */
  3894. constructor(scene: Scene,
  3895. /** defines the target object */
  3896. target: any,
  3897. /** defines the starting frame number (default is 0) */
  3898. fromFrame?: number,
  3899. /** defines the ending frame number (default is 100) */
  3900. toFrame?: number,
  3901. /** defines if the animation must loop (default is false) */
  3902. loopAnimation?: boolean, speedRatio?: number,
  3903. /** defines a callback to call when animation ends if it is not looping */
  3904. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  3905. /** defines a callback to call when animation loops */
  3906. onAnimationLoop?: (() => void) | null | undefined);
  3907. /**
  3908. * Synchronize and normalize current Animatable with a source Animatable
  3909. * This is useful when using animation weights and when animations are not of the same length
  3910. * @param root defines the root Animatable to synchronize with
  3911. * @returns the current Animatable
  3912. */
  3913. syncWith(root: Animatable): Animatable;
  3914. /**
  3915. * Gets the list of runtime animations
  3916. * @returns an array of RuntimeAnimation
  3917. */
  3918. getAnimations(): RuntimeAnimation[];
  3919. /**
  3920. * Adds more animations to the current animatable
  3921. * @param target defines the target of the animations
  3922. * @param animations defines the new animations to add
  3923. */
  3924. appendAnimations(target: any, animations: Animation[]): void;
  3925. /**
  3926. * Gets the source animation for a specific property
  3927. * @param property defines the propertyu to look for
  3928. * @returns null or the source animation for the given property
  3929. */
  3930. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3931. /**
  3932. * Gets the runtime animation for a specific property
  3933. * @param property defines the propertyu to look for
  3934. * @returns null or the runtime animation for the given property
  3935. */
  3936. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3937. /**
  3938. * Resets the animatable to its original state
  3939. */
  3940. reset(): void;
  3941. /**
  3942. * Allows the animatable to blend with current running animations
  3943. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3944. * @param blendingSpeed defines the blending speed to use
  3945. */
  3946. enableBlending(blendingSpeed: number): void;
  3947. /**
  3948. * Disable animation blending
  3949. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3950. */
  3951. disableBlending(): void;
  3952. /**
  3953. * Jump directly to a given frame
  3954. * @param frame defines the frame to jump to
  3955. */
  3956. goToFrame(frame: number): void;
  3957. /**
  3958. * Pause the animation
  3959. */
  3960. pause(): void;
  3961. /**
  3962. * Restart the animation
  3963. */
  3964. restart(): void;
  3965. private _raiseOnAnimationEnd;
  3966. /**
  3967. * Stop and delete the current animation
  3968. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3969. * @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)
  3970. */
  3971. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3972. /**
  3973. * Wait asynchronously for the animation to end
  3974. * @returns a promise which will be fullfilled when the animation ends
  3975. */
  3976. waitAsync(): Promise<Animatable>;
  3977. /** @hidden */
  3978. _animate(delay: number): boolean;
  3979. }
  3980. }
  3981. declare module BABYLON {
  3982. /**
  3983. * Represents the range of an animation
  3984. */
  3985. class AnimationRange {
  3986. /**The name of the animation range**/
  3987. name: string;
  3988. /**The starting frame of the animation */
  3989. from: number;
  3990. /**The ending frame of the animation*/
  3991. to: number;
  3992. /**
  3993. * Initializes the range of an animation
  3994. * @param name The name of the animation range
  3995. * @param from The starting frame of the animation
  3996. * @param to The ending frame of the animation
  3997. */
  3998. constructor(
  3999. /**The name of the animation range**/
  4000. name: string,
  4001. /**The starting frame of the animation */
  4002. from: number,
  4003. /**The ending frame of the animation*/
  4004. to: number);
  4005. /**
  4006. * Makes a copy of the animation range
  4007. * @returns A copy of the animation range
  4008. */
  4009. clone(): AnimationRange;
  4010. }
  4011. /**
  4012. * Composed of a frame, and an action function
  4013. */
  4014. class AnimationEvent {
  4015. /** The frame for which the event is triggered **/
  4016. frame: number;
  4017. /** The event to perform when triggered **/
  4018. action: (currentFrame: number) => void;
  4019. /** Specifies if the event should be triggered only once**/
  4020. onlyOnce?: boolean | undefined;
  4021. /**
  4022. * Specifies if the animation event is done
  4023. */
  4024. isDone: boolean;
  4025. /**
  4026. * Initializes the animation event
  4027. * @param frame The frame for which the event is triggered
  4028. * @param action The event to perform when triggered
  4029. * @param onlyOnce Specifies if the event should be triggered only once
  4030. */
  4031. constructor(
  4032. /** The frame for which the event is triggered **/
  4033. frame: number,
  4034. /** The event to perform when triggered **/
  4035. action: (currentFrame: number) => void,
  4036. /** Specifies if the event should be triggered only once**/
  4037. onlyOnce?: boolean | undefined);
  4038. /** @hidden */
  4039. _clone(): AnimationEvent;
  4040. }
  4041. /**
  4042. * A cursor which tracks a point on a path
  4043. */
  4044. class PathCursor {
  4045. private path;
  4046. /**
  4047. * Stores path cursor callbacks for when an onchange event is triggered
  4048. */
  4049. private _onchange;
  4050. /**
  4051. * The value of the path cursor
  4052. */
  4053. value: number;
  4054. /**
  4055. * The animation array of the path cursor
  4056. */
  4057. animations: Animation[];
  4058. /**
  4059. * Initializes the path cursor
  4060. * @param path The path to track
  4061. */
  4062. constructor(path: Path2);
  4063. /**
  4064. * Gets the cursor point on the path
  4065. * @returns A point on the path cursor at the cursor location
  4066. */
  4067. getPoint(): Vector3;
  4068. /**
  4069. * Moves the cursor ahead by the step amount
  4070. * @param step The amount to move the cursor forward
  4071. * @returns This path cursor
  4072. */
  4073. moveAhead(step?: number): PathCursor;
  4074. /**
  4075. * Moves the cursor behind by the step amount
  4076. * @param step The amount to move the cursor back
  4077. * @returns This path cursor
  4078. */
  4079. moveBack(step?: number): PathCursor;
  4080. /**
  4081. * Moves the cursor by the step amount
  4082. * If the step amount is greater than one, an exception is thrown
  4083. * @param step The amount to move the cursor
  4084. * @returns This path cursor
  4085. */
  4086. move(step: number): PathCursor;
  4087. /**
  4088. * Ensures that the value is limited between zero and one
  4089. * @returns This path cursor
  4090. */
  4091. private ensureLimits;
  4092. /**
  4093. * Runs onchange callbacks on change (used by the animation engine)
  4094. * @returns This path cursor
  4095. */
  4096. private raiseOnChange;
  4097. /**
  4098. * Executes a function on change
  4099. * @param f A path cursor onchange callback
  4100. * @returns This path cursor
  4101. */
  4102. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4103. }
  4104. /**
  4105. * Defines an interface which represents an animation key frame
  4106. */
  4107. interface IAnimationKey {
  4108. /**
  4109. * Frame of the key frame
  4110. */
  4111. frame: number;
  4112. /**
  4113. * Value at the specifies key frame
  4114. */
  4115. value: any;
  4116. /**
  4117. * The input tangent for the cubic hermite spline
  4118. */
  4119. inTangent?: any;
  4120. /**
  4121. * The output tangent for the cubic hermite spline
  4122. */
  4123. outTangent?: any;
  4124. /**
  4125. * The animation interpolation type
  4126. */
  4127. interpolation?: AnimationKeyInterpolation;
  4128. }
  4129. /**
  4130. * Enum for the animation key frame interpolation type
  4131. */
  4132. enum AnimationKeyInterpolation {
  4133. /**
  4134. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4135. */
  4136. STEP = 1
  4137. }
  4138. /**
  4139. * Class used to store any kind of animation
  4140. */
  4141. class Animation {
  4142. /**Name of the animation */
  4143. name: string;
  4144. /**Property to animate */
  4145. targetProperty: string;
  4146. /**The frames per second of the animation */
  4147. framePerSecond: number;
  4148. /**The data type of the animation */
  4149. dataType: number;
  4150. /**The loop mode of the animation */
  4151. loopMode?: number | undefined;
  4152. /**Specifies if blending should be enabled */
  4153. enableBlending?: boolean | undefined;
  4154. /**
  4155. * Use matrix interpolation instead of using direct key value when animating matrices
  4156. */
  4157. static AllowMatricesInterpolation: boolean;
  4158. /**
  4159. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4160. */
  4161. static AllowMatrixDecomposeForInterpolation: boolean;
  4162. /**
  4163. * Stores the key frames of the animation
  4164. */
  4165. private _keys;
  4166. /**
  4167. * Stores the easing function of the animation
  4168. */
  4169. private _easingFunction;
  4170. /**
  4171. * @hidden Internal use only
  4172. */
  4173. _runtimeAnimations: RuntimeAnimation[];
  4174. /**
  4175. * The set of event that will be linked to this animation
  4176. */
  4177. private _events;
  4178. /**
  4179. * Stores an array of target property paths
  4180. */
  4181. targetPropertyPath: string[];
  4182. /**
  4183. * Stores the blending speed of the animation
  4184. */
  4185. blendingSpeed: number;
  4186. /**
  4187. * Stores the animation ranges for the animation
  4188. */
  4189. private _ranges;
  4190. /**
  4191. * @hidden Internal use
  4192. */
  4193. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4194. /**
  4195. * Sets up an animation
  4196. * @param property The property to animate
  4197. * @param animationType The animation type to apply
  4198. * @param framePerSecond The frames per second of the animation
  4199. * @param easingFunction The easing function used in the animation
  4200. * @returns The created animation
  4201. */
  4202. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4203. /**
  4204. * Create and start an animation on a node
  4205. * @param name defines the name of the global animation that will be run on all nodes
  4206. * @param node defines the root node where the animation will take place
  4207. * @param targetProperty defines property to animate
  4208. * @param framePerSecond defines the number of frame per second yo use
  4209. * @param totalFrame defines the number of frames in total
  4210. * @param from defines the initial value
  4211. * @param to defines the final value
  4212. * @param loopMode defines which loop mode you want to use (off by default)
  4213. * @param easingFunction defines the easing function to use (linear by default)
  4214. * @param onAnimationEnd defines the callback to call when animation end
  4215. * @returns the animatable created for this animation
  4216. */
  4217. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4218. /**
  4219. * Create and start an animation on a node and its descendants
  4220. * @param name defines the name of the global animation that will be run on all nodes
  4221. * @param node defines the root node where the animation will take place
  4222. * @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
  4223. * @param targetProperty defines property to animate
  4224. * @param framePerSecond defines the number of frame per second to use
  4225. * @param totalFrame defines the number of frames in total
  4226. * @param from defines the initial value
  4227. * @param to defines the final value
  4228. * @param loopMode defines which loop mode you want to use (off by default)
  4229. * @param easingFunction defines the easing function to use (linear by default)
  4230. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4231. * @returns the list of animatables created for all nodes
  4232. * @example https://www.babylonjs-playground.com/#MH0VLI
  4233. */
  4234. 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[]>;
  4235. /**
  4236. * Creates a new animation, merges it with the existing animations and starts it
  4237. * @param name Name of the animation
  4238. * @param node Node which contains the scene that begins the animations
  4239. * @param targetProperty Specifies which property to animate
  4240. * @param framePerSecond The frames per second of the animation
  4241. * @param totalFrame The total number of frames
  4242. * @param from The frame at the beginning of the animation
  4243. * @param to The frame at the end of the animation
  4244. * @param loopMode Specifies the loop mode of the animation
  4245. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4246. * @param onAnimationEnd Callback to run once the animation is complete
  4247. * @returns Nullable animation
  4248. */
  4249. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4250. /**
  4251. * Transition property of an host to the target Value
  4252. * @param property The property to transition
  4253. * @param targetValue The target Value of the property
  4254. * @param host The object where the property to animate belongs
  4255. * @param scene Scene used to run the animation
  4256. * @param frameRate Framerate (in frame/s) to use
  4257. * @param transition The transition type we want to use
  4258. * @param duration The duration of the animation, in milliseconds
  4259. * @param onAnimationEnd Callback trigger at the end of the animation
  4260. * @returns Nullable animation
  4261. */
  4262. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4263. /**
  4264. * Return the array of runtime animations currently using this animation
  4265. */
  4266. readonly runtimeAnimations: RuntimeAnimation[];
  4267. /**
  4268. * Specifies if any of the runtime animations are currently running
  4269. */
  4270. readonly hasRunningRuntimeAnimations: boolean;
  4271. /**
  4272. * Initializes the animation
  4273. * @param name Name of the animation
  4274. * @param targetProperty Property to animate
  4275. * @param framePerSecond The frames per second of the animation
  4276. * @param dataType The data type of the animation
  4277. * @param loopMode The loop mode of the animation
  4278. * @param enableBlendings Specifies if blending should be enabled
  4279. */
  4280. constructor(
  4281. /**Name of the animation */
  4282. name: string,
  4283. /**Property to animate */
  4284. targetProperty: string,
  4285. /**The frames per second of the animation */
  4286. framePerSecond: number,
  4287. /**The data type of the animation */
  4288. dataType: number,
  4289. /**The loop mode of the animation */
  4290. loopMode?: number | undefined,
  4291. /**Specifies if blending should be enabled */
  4292. enableBlending?: boolean | undefined);
  4293. /**
  4294. * Converts the animation to a string
  4295. * @param fullDetails support for multiple levels of logging within scene loading
  4296. * @returns String form of the animation
  4297. */
  4298. toString(fullDetails?: boolean): string;
  4299. /**
  4300. * Add an event to this animation
  4301. * @param event Event to add
  4302. */
  4303. addEvent(event: AnimationEvent): void;
  4304. /**
  4305. * Remove all events found at the given frame
  4306. * @param frame The frame to remove events from
  4307. */
  4308. removeEvents(frame: number): void;
  4309. /**
  4310. * Retrieves all the events from the animation
  4311. * @returns Events from the animation
  4312. */
  4313. getEvents(): AnimationEvent[];
  4314. /**
  4315. * Creates an animation range
  4316. * @param name Name of the animation range
  4317. * @param from Starting frame of the animation range
  4318. * @param to Ending frame of the animation
  4319. */
  4320. createRange(name: string, from: number, to: number): void;
  4321. /**
  4322. * Deletes an animation range by name
  4323. * @param name Name of the animation range to delete
  4324. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4325. */
  4326. deleteRange(name: string, deleteFrames?: boolean): void;
  4327. /**
  4328. * Gets the animation range by name, or null if not defined
  4329. * @param name Name of the animation range
  4330. * @returns Nullable animation range
  4331. */
  4332. getRange(name: string): Nullable<AnimationRange>;
  4333. /**
  4334. * Gets the key frames from the animation
  4335. * @returns The key frames of the animation
  4336. */
  4337. getKeys(): Array<IAnimationKey>;
  4338. /**
  4339. * Gets the highest frame rate of the animation
  4340. * @returns Highest frame rate of the animation
  4341. */
  4342. getHighestFrame(): number;
  4343. /**
  4344. * Gets the easing function of the animation
  4345. * @returns Easing function of the animation
  4346. */
  4347. getEasingFunction(): IEasingFunction;
  4348. /**
  4349. * Sets the easing function of the animation
  4350. * @param easingFunction A custom mathematical formula for animation
  4351. */
  4352. setEasingFunction(easingFunction: EasingFunction): void;
  4353. /**
  4354. * Interpolates a scalar linearly
  4355. * @param startValue Start value of the animation curve
  4356. * @param endValue End value of the animation curve
  4357. * @param gradient Scalar amount to interpolate
  4358. * @returns Interpolated scalar value
  4359. */
  4360. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4361. /**
  4362. * Interpolates a scalar cubically
  4363. * @param startValue Start value of the animation curve
  4364. * @param outTangent End tangent of the animation
  4365. * @param endValue End value of the animation curve
  4366. * @param inTangent Start tangent of the animation curve
  4367. * @param gradient Scalar amount to interpolate
  4368. * @returns Interpolated scalar value
  4369. */
  4370. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4371. /**
  4372. * Interpolates a quaternion using a spherical linear interpolation
  4373. * @param startValue Start value of the animation curve
  4374. * @param endValue End value of the animation curve
  4375. * @param gradient Scalar amount to interpolate
  4376. * @returns Interpolated quaternion value
  4377. */
  4378. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4379. /**
  4380. * Interpolates a quaternion cubically
  4381. * @param startValue Start value of the animation curve
  4382. * @param outTangent End tangent of the animation curve
  4383. * @param endValue End value of the animation curve
  4384. * @param inTangent Start tangent of the animation curve
  4385. * @param gradient Scalar amount to interpolate
  4386. * @returns Interpolated quaternion value
  4387. */
  4388. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4389. /**
  4390. * Interpolates a Vector3 linearl
  4391. * @param startValue Start value of the animation curve
  4392. * @param endValue End value of the animation curve
  4393. * @param gradient Scalar amount to interpolate
  4394. * @returns Interpolated scalar value
  4395. */
  4396. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4397. /**
  4398. * Interpolates a Vector3 cubically
  4399. * @param startValue Start value of the animation curve
  4400. * @param outTangent End tangent of the animation
  4401. * @param endValue End value of the animation curve
  4402. * @param inTangent Start tangent of the animation curve
  4403. * @param gradient Scalar amount to interpolate
  4404. * @returns InterpolatedVector3 value
  4405. */
  4406. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4407. /**
  4408. * Interpolates a Vector2 linearly
  4409. * @param startValue Start value of the animation curve
  4410. * @param endValue End value of the animation curve
  4411. * @param gradient Scalar amount to interpolate
  4412. * @returns Interpolated Vector2 value
  4413. */
  4414. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4415. /**
  4416. * Interpolates a Vector2 cubically
  4417. * @param startValue Start value of the animation curve
  4418. * @param outTangent End tangent of the animation
  4419. * @param endValue End value of the animation curve
  4420. * @param inTangent Start tangent of the animation curve
  4421. * @param gradient Scalar amount to interpolate
  4422. * @returns Interpolated Vector2 value
  4423. */
  4424. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4425. /**
  4426. * Interpolates a size linearly
  4427. * @param startValue Start value of the animation curve
  4428. * @param endValue End value of the animation curve
  4429. * @param gradient Scalar amount to interpolate
  4430. * @returns Interpolated Size value
  4431. */
  4432. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4433. /**
  4434. * Interpolates a Color3 linearly
  4435. * @param startValue Start value of the animation curve
  4436. * @param endValue End value of the animation curve
  4437. * @param gradient Scalar amount to interpolate
  4438. * @returns Interpolated Color3 value
  4439. */
  4440. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4441. /**
  4442. * @hidden Internal use only
  4443. */
  4444. _getKeyValue(value: any): any;
  4445. /**
  4446. * @hidden Internal use only
  4447. */
  4448. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4449. /**
  4450. * Defines the function to use to interpolate matrices
  4451. * @param startValue defines the start matrix
  4452. * @param endValue defines the end matrix
  4453. * @param gradient defines the gradient between both matrices
  4454. * @param result defines an optional target matrix where to store the interpolation
  4455. * @returns the interpolated matrix
  4456. */
  4457. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4458. /**
  4459. * Makes a copy of the animation
  4460. * @returns Cloned animation
  4461. */
  4462. clone(): Animation;
  4463. /**
  4464. * Sets the key frames of the animation
  4465. * @param values The animation key frames to set
  4466. */
  4467. setKeys(values: Array<IAnimationKey>): void;
  4468. /**
  4469. * Serializes the animation to an object
  4470. * @returns Serialized object
  4471. */
  4472. serialize(): any;
  4473. /**
  4474. * Float animation type
  4475. */
  4476. private static _ANIMATIONTYPE_FLOAT;
  4477. /**
  4478. * Vector3 animation type
  4479. */
  4480. private static _ANIMATIONTYPE_VECTOR3;
  4481. /**
  4482. * Quaternion animation type
  4483. */
  4484. private static _ANIMATIONTYPE_QUATERNION;
  4485. /**
  4486. * Matrix animation type
  4487. */
  4488. private static _ANIMATIONTYPE_MATRIX;
  4489. /**
  4490. * Color3 animation type
  4491. */
  4492. private static _ANIMATIONTYPE_COLOR3;
  4493. /**
  4494. * Vector2 animation type
  4495. */
  4496. private static _ANIMATIONTYPE_VECTOR2;
  4497. /**
  4498. * Size animation type
  4499. */
  4500. private static _ANIMATIONTYPE_SIZE;
  4501. /**
  4502. * Relative Loop Mode
  4503. */
  4504. private static _ANIMATIONLOOPMODE_RELATIVE;
  4505. /**
  4506. * Cycle Loop Mode
  4507. */
  4508. private static _ANIMATIONLOOPMODE_CYCLE;
  4509. /**
  4510. * Constant Loop Mode
  4511. */
  4512. private static _ANIMATIONLOOPMODE_CONSTANT;
  4513. /**
  4514. * Get the float animation type
  4515. */
  4516. static readonly ANIMATIONTYPE_FLOAT: number;
  4517. /**
  4518. * Get the Vector3 animation type
  4519. */
  4520. static readonly ANIMATIONTYPE_VECTOR3: number;
  4521. /**
  4522. * Get the Vector2 animation type
  4523. */
  4524. static readonly ANIMATIONTYPE_VECTOR2: number;
  4525. /**
  4526. * Get the Size animation type
  4527. */
  4528. static readonly ANIMATIONTYPE_SIZE: number;
  4529. /**
  4530. * Get the Quaternion animation type
  4531. */
  4532. static readonly ANIMATIONTYPE_QUATERNION: number;
  4533. /**
  4534. * Get the Matrix animation type
  4535. */
  4536. static readonly ANIMATIONTYPE_MATRIX: number;
  4537. /**
  4538. * Get the Color3 animation type
  4539. */
  4540. static readonly ANIMATIONTYPE_COLOR3: number;
  4541. /**
  4542. * Get the Relative Loop Mode
  4543. */
  4544. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4545. /**
  4546. * Get the Cycle Loop Mode
  4547. */
  4548. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4549. /**
  4550. * Get the Constant Loop Mode
  4551. */
  4552. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4553. /** @hidden */
  4554. static _UniversalLerp(left: any, right: any, amount: number): any;
  4555. /**
  4556. * Parses an animation object and creates an animation
  4557. * @param parsedAnimation Parsed animation object
  4558. * @returns Animation object
  4559. */
  4560. static Parse(parsedAnimation: any): Animation;
  4561. /**
  4562. * Appends the serialized animations from the source animations
  4563. * @param source Source containing the animations
  4564. * @param destination Target to store the animations
  4565. */
  4566. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4567. }
  4568. }
  4569. declare module BABYLON {
  4570. /**
  4571. * This class defines the direct association between an animation and a target
  4572. */
  4573. class TargetedAnimation {
  4574. /**
  4575. * Animation to perform
  4576. */
  4577. animation: Animation;
  4578. /**
  4579. * Target to animate
  4580. */
  4581. target: any;
  4582. }
  4583. /**
  4584. * Use this class to create coordinated animations on multiple targets
  4585. */
  4586. class AnimationGroup implements IDisposable {
  4587. /** The name of the animation group */
  4588. name: string;
  4589. private _scene;
  4590. private _targetedAnimations;
  4591. private _animatables;
  4592. private _from;
  4593. private _to;
  4594. private _isStarted;
  4595. private _isPaused;
  4596. private _speedRatio;
  4597. /**
  4598. * Gets or sets the unique id of the node
  4599. */
  4600. uniqueId: number;
  4601. /**
  4602. * This observable will notify when one animation have ended
  4603. */
  4604. onAnimationEndObservable: Observable<TargetedAnimation>;
  4605. /**
  4606. * Observer raised when one animation loops
  4607. */
  4608. onAnimationLoopObservable: Observable<TargetedAnimation>;
  4609. /**
  4610. * This observable will notify when all animations have ended.
  4611. */
  4612. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4613. /**
  4614. * This observable will notify when all animations have paused.
  4615. */
  4616. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4617. /**
  4618. * This observable will notify when all animations are playing.
  4619. */
  4620. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4621. /**
  4622. * Gets the first frame
  4623. */
  4624. readonly from: number;
  4625. /**
  4626. * Gets the last frame
  4627. */
  4628. readonly to: number;
  4629. /**
  4630. * Define if the animations are started
  4631. */
  4632. readonly isStarted: boolean;
  4633. /**
  4634. * Gets a value indicating that the current group is playing
  4635. */
  4636. readonly isPlaying: boolean;
  4637. /**
  4638. * Gets or sets the speed ratio to use for all animations
  4639. */
  4640. /**
  4641. * Gets or sets the speed ratio to use for all animations
  4642. */
  4643. speedRatio: number;
  4644. /**
  4645. * Gets the targeted animations for this animation group
  4646. */
  4647. readonly targetedAnimations: Array<TargetedAnimation>;
  4648. /**
  4649. * returning the list of animatables controlled by this animation group.
  4650. */
  4651. readonly animatables: Array<Animatable>;
  4652. /**
  4653. * Instantiates a new Animation Group.
  4654. * This helps managing several animations at once.
  4655. * @see http://doc.babylonjs.com/how_to/group
  4656. * @param name Defines the name of the group
  4657. * @param scene Defines the scene the group belongs to
  4658. */
  4659. constructor(
  4660. /** The name of the animation group */
  4661. name: string, scene?: Nullable<Scene>);
  4662. /**
  4663. * Add an animation (with its target) in the group
  4664. * @param animation defines the animation we want to add
  4665. * @param target defines the target of the animation
  4666. * @returns the TargetedAnimation object
  4667. */
  4668. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4669. /**
  4670. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4671. * It can add constant keys at begin or end
  4672. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4673. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4674. * @returns the animation group
  4675. */
  4676. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4677. /**
  4678. * Start all animations on given targets
  4679. * @param loop defines if animations must loop
  4680. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4681. * @param from defines the from key (optional)
  4682. * @param to defines the to key (optional)
  4683. * @returns the current animation group
  4684. */
  4685. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4686. /**
  4687. * Pause all animations
  4688. * @returns the animation group
  4689. */
  4690. pause(): AnimationGroup;
  4691. /**
  4692. * Play all animations to initial state
  4693. * This function will start() the animations if they were not started or will restart() them if they were paused
  4694. * @param loop defines if animations must loop
  4695. * @returns the animation group
  4696. */
  4697. play(loop?: boolean): AnimationGroup;
  4698. /**
  4699. * Reset all animations to initial state
  4700. * @returns the animation group
  4701. */
  4702. reset(): AnimationGroup;
  4703. /**
  4704. * Restart animations from key 0
  4705. * @returns the animation group
  4706. */
  4707. restart(): AnimationGroup;
  4708. /**
  4709. * Stop all animations
  4710. * @returns the animation group
  4711. */
  4712. stop(): AnimationGroup;
  4713. /**
  4714. * Set animation weight for all animatables
  4715. * @param weight defines the weight to use
  4716. * @return the animationGroup
  4717. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4718. */
  4719. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4720. /**
  4721. * Synchronize and normalize all animatables with a source animatable
  4722. * @param root defines the root animatable to synchronize with
  4723. * @return the animationGroup
  4724. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4725. */
  4726. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4727. /**
  4728. * Goes to a specific frame in this animation group
  4729. * @param frame the frame number to go to
  4730. * @return the animationGroup
  4731. */
  4732. goToFrame(frame: number): AnimationGroup;
  4733. /**
  4734. * Dispose all associated resources
  4735. */
  4736. dispose(): void;
  4737. private _checkAnimationGroupEnded;
  4738. /**
  4739. * Returns a new AnimationGroup object parsed from the source provided.
  4740. * @param parsedAnimationGroup defines the source
  4741. * @param scene defines the scene that will receive the animationGroup
  4742. * @returns a new AnimationGroup
  4743. */
  4744. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4745. /**
  4746. * Returns the string "AnimationGroup"
  4747. * @returns "AnimationGroup"
  4748. */
  4749. getClassName(): string;
  4750. /**
  4751. * Creates a detailled string about the object
  4752. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4753. * @returns a string representing the object
  4754. */
  4755. toString(fullDetails?: boolean): string;
  4756. }
  4757. }
  4758. declare module BABYLON {
  4759. /**
  4760. * Class used to override all child animations of a given target
  4761. */
  4762. class AnimationPropertiesOverride {
  4763. /**
  4764. * Gets or sets a value indicating if animation blending must be used
  4765. */
  4766. enableBlending: boolean;
  4767. /**
  4768. * Gets or sets the blending speed to use when enableBlending is true
  4769. */
  4770. blendingSpeed: number;
  4771. /**
  4772. * Gets or sets the default loop mode to use
  4773. */
  4774. loopMode: number;
  4775. }
  4776. }
  4777. declare module BABYLON {
  4778. /**
  4779. * This represents the main contract an easing function should follow.
  4780. * Easing functions are used throughout the animation system.
  4781. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4782. */
  4783. interface IEasingFunction {
  4784. /**
  4785. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4786. * of the easing function.
  4787. * The link below provides some of the most common examples of easing functions.
  4788. * @see https://easings.net/
  4789. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4790. * @returns the corresponding value on the curve defined by the easing function
  4791. */
  4792. ease(gradient: number): number;
  4793. }
  4794. /**
  4795. * Base class used for every default easing function.
  4796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4797. */
  4798. class EasingFunction implements IEasingFunction {
  4799. /**
  4800. * Interpolation follows the mathematical formula associated with the easing function.
  4801. */
  4802. static readonly EASINGMODE_EASEIN: number;
  4803. /**
  4804. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4805. */
  4806. static readonly EASINGMODE_EASEOUT: number;
  4807. /**
  4808. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4809. */
  4810. static readonly EASINGMODE_EASEINOUT: number;
  4811. private _easingMode;
  4812. /**
  4813. * Sets the easing mode of the current function.
  4814. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4815. */
  4816. setEasingMode(easingMode: number): void;
  4817. /**
  4818. * Gets the current easing mode.
  4819. * @returns the easing mode
  4820. */
  4821. getEasingMode(): number;
  4822. /**
  4823. * @hidden
  4824. */
  4825. easeInCore(gradient: number): number;
  4826. /**
  4827. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4828. * of the easing function.
  4829. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4830. * @returns the corresponding value on the curve defined by the easing function
  4831. */
  4832. ease(gradient: number): number;
  4833. }
  4834. /**
  4835. * Easing function with a circle shape (see link below).
  4836. * @see https://easings.net/#easeInCirc
  4837. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4838. */
  4839. class CircleEase extends EasingFunction implements IEasingFunction {
  4840. /** @hidden */
  4841. easeInCore(gradient: number): number;
  4842. }
  4843. /**
  4844. * Easing function with a ease back shape (see link below).
  4845. * @see https://easings.net/#easeInBack
  4846. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4847. */
  4848. class BackEase extends EasingFunction implements IEasingFunction {
  4849. /** Defines the amplitude of the function */
  4850. amplitude: number;
  4851. /**
  4852. * Instantiates a back ease easing
  4853. * @see https://easings.net/#easeInBack
  4854. * @param amplitude Defines the amplitude of the function
  4855. */
  4856. constructor(
  4857. /** Defines the amplitude of the function */
  4858. amplitude?: number);
  4859. /** @hidden */
  4860. easeInCore(gradient: number): number;
  4861. }
  4862. /**
  4863. * Easing function with a bouncing shape (see link below).
  4864. * @see https://easings.net/#easeInBounce
  4865. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4866. */
  4867. class BounceEase extends EasingFunction implements IEasingFunction {
  4868. /** Defines the number of bounces */
  4869. bounces: number;
  4870. /** Defines the amplitude of the bounce */
  4871. bounciness: number;
  4872. /**
  4873. * Instantiates a bounce easing
  4874. * @see https://easings.net/#easeInBounce
  4875. * @param bounces Defines the number of bounces
  4876. * @param bounciness Defines the amplitude of the bounce
  4877. */
  4878. constructor(
  4879. /** Defines the number of bounces */
  4880. bounces?: number,
  4881. /** Defines the amplitude of the bounce */
  4882. bounciness?: number);
  4883. /** @hidden */
  4884. easeInCore(gradient: number): number;
  4885. }
  4886. /**
  4887. * Easing function with a power of 3 shape (see link below).
  4888. * @see https://easings.net/#easeInCubic
  4889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4890. */
  4891. class CubicEase extends EasingFunction implements IEasingFunction {
  4892. /** @hidden */
  4893. easeInCore(gradient: number): number;
  4894. }
  4895. /**
  4896. * Easing function with an elastic shape (see link below).
  4897. * @see https://easings.net/#easeInElastic
  4898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4899. */
  4900. class ElasticEase extends EasingFunction implements IEasingFunction {
  4901. /** Defines the number of oscillations*/
  4902. oscillations: number;
  4903. /** Defines the amplitude of the oscillations*/
  4904. springiness: number;
  4905. /**
  4906. * Instantiates an elastic easing function
  4907. * @see https://easings.net/#easeInElastic
  4908. * @param oscillations Defines the number of oscillations
  4909. * @param springiness Defines the amplitude of the oscillations
  4910. */
  4911. constructor(
  4912. /** Defines the number of oscillations*/
  4913. oscillations?: number,
  4914. /** Defines the amplitude of the oscillations*/
  4915. springiness?: number);
  4916. /** @hidden */
  4917. easeInCore(gradient: number): number;
  4918. }
  4919. /**
  4920. * Easing function with an exponential shape (see link below).
  4921. * @see https://easings.net/#easeInExpo
  4922. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4923. */
  4924. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4925. /** Defines the exponent of the function */
  4926. exponent: number;
  4927. /**
  4928. * Instantiates an exponential easing function
  4929. * @see https://easings.net/#easeInExpo
  4930. * @param exponent Defines the exponent of the function
  4931. */
  4932. constructor(
  4933. /** Defines the exponent of the function */
  4934. exponent?: number);
  4935. /** @hidden */
  4936. easeInCore(gradient: number): number;
  4937. }
  4938. /**
  4939. * Easing function with a power shape (see link below).
  4940. * @see https://easings.net/#easeInQuad
  4941. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4942. */
  4943. class PowerEase extends EasingFunction implements IEasingFunction {
  4944. /** Defines the power of the function */
  4945. power: number;
  4946. /**
  4947. * Instantiates an power base easing function
  4948. * @see https://easings.net/#easeInQuad
  4949. * @param power Defines the power of the function
  4950. */
  4951. constructor(
  4952. /** Defines the power of the function */
  4953. power?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a power of 2 shape (see link below).
  4959. * @see https://easings.net/#easeInQuad
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4963. /** @hidden */
  4964. easeInCore(gradient: number): number;
  4965. }
  4966. /**
  4967. * Easing function with a power of 4 shape (see link below).
  4968. * @see https://easings.net/#easeInQuart
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. class QuarticEase extends EasingFunction implements IEasingFunction {
  4972. /** @hidden */
  4973. easeInCore(gradient: number): number;
  4974. }
  4975. /**
  4976. * Easing function with a power of 5 shape (see link below).
  4977. * @see https://easings.net/#easeInQuint
  4978. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4979. */
  4980. class QuinticEase extends EasingFunction implements IEasingFunction {
  4981. /** @hidden */
  4982. easeInCore(gradient: number): number;
  4983. }
  4984. /**
  4985. * Easing function with a sin shape (see link below).
  4986. * @see https://easings.net/#easeInSine
  4987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4988. */
  4989. class SineEase extends EasingFunction implements IEasingFunction {
  4990. /** @hidden */
  4991. easeInCore(gradient: number): number;
  4992. }
  4993. /**
  4994. * Easing function with a bezier shape (see link below).
  4995. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4997. */
  4998. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4999. /** Defines the x component of the start tangent in the bezier curve */
  5000. x1: number;
  5001. /** Defines the y component of the start tangent in the bezier curve */
  5002. y1: number;
  5003. /** Defines the x component of the end tangent in the bezier curve */
  5004. x2: number;
  5005. /** Defines the y component of the end tangent in the bezier curve */
  5006. y2: number;
  5007. /**
  5008. * Instantiates a bezier function
  5009. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5010. * @param x1 Defines the x component of the start tangent in the bezier curve
  5011. * @param y1 Defines the y component of the start tangent in the bezier curve
  5012. * @param x2 Defines the x component of the end tangent in the bezier curve
  5013. * @param y2 Defines the y component of the end tangent in the bezier curve
  5014. */
  5015. constructor(
  5016. /** Defines the x component of the start tangent in the bezier curve */
  5017. x1?: number,
  5018. /** Defines the y component of the start tangent in the bezier curve */
  5019. y1?: number,
  5020. /** Defines the x component of the end tangent in the bezier curve */
  5021. x2?: number,
  5022. /** Defines the y component of the end tangent in the bezier curve */
  5023. y2?: number);
  5024. /** @hidden */
  5025. easeInCore(gradient: number): number;
  5026. }
  5027. }
  5028. declare module BABYLON {
  5029. /**
  5030. * Defines a runtime animation
  5031. */
  5032. class RuntimeAnimation {
  5033. private _events;
  5034. /**
  5035. * The current frame of the runtime animation
  5036. */
  5037. private _currentFrame;
  5038. /**
  5039. * The animation used by the runtime animation
  5040. */
  5041. private _animation;
  5042. /**
  5043. * The target of the runtime animation
  5044. */
  5045. private _target;
  5046. /**
  5047. * The initiating animatable
  5048. */
  5049. private _host;
  5050. /**
  5051. * The original value of the runtime animation
  5052. */
  5053. private _originalValue;
  5054. /**
  5055. * The original blend value of the runtime animation
  5056. */
  5057. private _originalBlendValue;
  5058. /**
  5059. * The offsets cache of the runtime animation
  5060. */
  5061. private _offsetsCache;
  5062. /**
  5063. * The high limits cache of the runtime animation
  5064. */
  5065. private _highLimitsCache;
  5066. /**
  5067. * Specifies if the runtime animation has been stopped
  5068. */
  5069. private _stopped;
  5070. /**
  5071. * The blending factor of the runtime animation
  5072. */
  5073. private _blendingFactor;
  5074. /**
  5075. * The BabylonJS scene
  5076. */
  5077. private _scene;
  5078. /**
  5079. * The current value of the runtime animation
  5080. */
  5081. private _currentValue;
  5082. /** @hidden */
  5083. _workValue: any;
  5084. /**
  5085. * The active target of the runtime animation
  5086. */
  5087. private _activeTarget;
  5088. /**
  5089. * The target path of the runtime animation
  5090. */
  5091. private _targetPath;
  5092. /**
  5093. * The weight of the runtime animation
  5094. */
  5095. private _weight;
  5096. /**
  5097. * The ratio offset of the runtime animation
  5098. */
  5099. private _ratioOffset;
  5100. /**
  5101. * The previous delay of the runtime animation
  5102. */
  5103. private _previousDelay;
  5104. /**
  5105. * The previous ratio of the runtime animation
  5106. */
  5107. private _previousRatio;
  5108. /**
  5109. * Gets the current frame of the runtime animation
  5110. */
  5111. readonly currentFrame: number;
  5112. /**
  5113. * Gets the weight of the runtime animation
  5114. */
  5115. readonly weight: number;
  5116. /**
  5117. * Gets the current value of the runtime animation
  5118. */
  5119. readonly currentValue: any;
  5120. /**
  5121. * Gets the target path of the runtime animation
  5122. */
  5123. readonly targetPath: string;
  5124. /**
  5125. * Gets the actual target of the runtime animation
  5126. */
  5127. readonly target: any;
  5128. /**
  5129. * Create a new RuntimeAnimation object
  5130. * @param target defines the target of the animation
  5131. * @param animation defines the source animation object
  5132. * @param scene defines the hosting scene
  5133. * @param host defines the initiating Animatable
  5134. */
  5135. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5136. /**
  5137. * Gets the animation from the runtime animation
  5138. */
  5139. readonly animation: Animation;
  5140. /**
  5141. * Resets the runtime animation to the beginning
  5142. * @param restoreOriginal defines whether to restore the target property to the original value
  5143. */
  5144. reset(restoreOriginal?: boolean): void;
  5145. /**
  5146. * Specifies if the runtime animation is stopped
  5147. * @returns Boolean specifying if the runtime animation is stopped
  5148. */
  5149. isStopped(): boolean;
  5150. /**
  5151. * Disposes of the runtime animation
  5152. */
  5153. dispose(): void;
  5154. /**
  5155. * Interpolates the animation from the current frame
  5156. * @param currentFrame The frame to interpolate the animation to
  5157. * @param repeatCount The number of times that the animation should loop
  5158. * @param loopMode The type of looping mode to use
  5159. * @param offsetValue Animation offset value
  5160. * @param highLimitValue The high limit value
  5161. * @returns The interpolated value
  5162. */
  5163. private _interpolate;
  5164. /**
  5165. * Apply the interpolated value to the target
  5166. * @param currentValue defines the value computed by the animation
  5167. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5168. */
  5169. setValue(currentValue: any, weight?: number): void;
  5170. private _setValue;
  5171. /**
  5172. * Gets the loop pmode of the runtime animation
  5173. * @returns Loop Mode
  5174. */
  5175. private _getCorrectLoopMode;
  5176. /**
  5177. * Move the current animation to a given frame
  5178. * @param frame defines the frame to move to
  5179. */
  5180. goToFrame(frame: number): void;
  5181. /**
  5182. * @hidden Internal use only
  5183. */
  5184. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5185. /**
  5186. * Execute the current animation
  5187. * @param delay defines the delay to add to the current frame
  5188. * @param from defines the lower bound of the animation range
  5189. * @param to defines the upper bound of the animation range
  5190. * @param loop defines if the current animation must loop
  5191. * @param speedRatio defines the current speed ratio
  5192. * @param weight defines the weight of the animation (default is -1 so no weight)
  5193. * @param onLoop optional callback called when animation loops
  5194. * @returns a boolean indicating if the animation is running
  5195. */
  5196. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  5197. }
  5198. }
  5199. declare module BABYLON {
  5200. /**
  5201. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5203. */
  5204. class Analyser {
  5205. /**
  5206. * Gets or sets the smoothing
  5207. * @ignorenaming
  5208. */
  5209. SMOOTHING: number;
  5210. /**
  5211. * Gets or sets the FFT table size
  5212. * @ignorenaming
  5213. */
  5214. FFT_SIZE: number;
  5215. /**
  5216. * Gets or sets the bar graph amplitude
  5217. * @ignorenaming
  5218. */
  5219. BARGRAPHAMPLITUDE: number;
  5220. /**
  5221. * Gets or sets the position of the debug canvas
  5222. * @ignorenaming
  5223. */
  5224. DEBUGCANVASPOS: {
  5225. x: number;
  5226. y: number;
  5227. };
  5228. /**
  5229. * Gets or sets the debug canvas size
  5230. * @ignorenaming
  5231. */
  5232. DEBUGCANVASSIZE: {
  5233. width: number;
  5234. height: number;
  5235. };
  5236. private _byteFreqs;
  5237. private _byteTime;
  5238. private _floatFreqs;
  5239. private _webAudioAnalyser;
  5240. private _debugCanvas;
  5241. private _debugCanvasContext;
  5242. private _scene;
  5243. private _registerFunc;
  5244. private _audioEngine;
  5245. /**
  5246. * Creates a new analyser
  5247. * @param scene defines hosting scene
  5248. */
  5249. constructor(scene: Scene);
  5250. /**
  5251. * Get the number of data values you will have to play with for the visualization
  5252. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5253. * @returns a number
  5254. */
  5255. getFrequencyBinCount(): number;
  5256. /**
  5257. * Gets the current frequency data as a byte array
  5258. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5259. * @returns a Uint8Array
  5260. */
  5261. getByteFrequencyData(): Uint8Array;
  5262. /**
  5263. * Gets the current waveform as a byte array
  5264. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5265. * @returns a Uint8Array
  5266. */
  5267. getByteTimeDomainData(): Uint8Array;
  5268. /**
  5269. * Gets the current frequency data as a float array
  5270. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5271. * @returns a Float32Array
  5272. */
  5273. getFloatFrequencyData(): Float32Array;
  5274. /**
  5275. * Renders the debug canvas
  5276. */
  5277. drawDebugCanvas(): void;
  5278. /**
  5279. * Stops rendering the debug canvas and removes it
  5280. */
  5281. stopDebugCanvas(): void;
  5282. /**
  5283. * Connects two audio nodes
  5284. * @param inputAudioNode defines first node to connect
  5285. * @param outputAudioNode defines second node to connect
  5286. */
  5287. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5288. /**
  5289. * Releases all associated resources
  5290. */
  5291. dispose(): void;
  5292. }
  5293. }
  5294. declare module BABYLON {
  5295. /**
  5296. * This represents an audio engine and it is responsible
  5297. * to play, synchronize and analyse sounds throughout the application.
  5298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5299. */
  5300. interface IAudioEngine extends IDisposable {
  5301. /**
  5302. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5303. */
  5304. readonly canUseWebAudio: boolean;
  5305. /**
  5306. * Gets the current AudioContext if available.
  5307. */
  5308. readonly audioContext: Nullable<AudioContext>;
  5309. /**
  5310. * The master gain node defines the global audio volume of your audio engine.
  5311. */
  5312. readonly masterGain: GainNode;
  5313. /**
  5314. * Gets whether or not mp3 are supported by your browser.
  5315. */
  5316. readonly isMP3supported: boolean;
  5317. /**
  5318. * Gets whether or not ogg are supported by your browser.
  5319. */
  5320. readonly isOGGsupported: boolean;
  5321. /**
  5322. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5323. * @ignoreNaming
  5324. */
  5325. WarnedWebAudioUnsupported: boolean;
  5326. /**
  5327. * Defines if the audio engine relies on a custom unlocked button.
  5328. * In this case, the embedded button will not be displayed.
  5329. */
  5330. useCustomUnlockedButton: boolean;
  5331. /**
  5332. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5333. */
  5334. readonly unlocked: boolean;
  5335. /**
  5336. * Event raised when audio has been unlocked on the browser.
  5337. */
  5338. onAudioUnlockedObservable: Observable<AudioEngine>;
  5339. /**
  5340. * Event raised when audio has been locked on the browser.
  5341. */
  5342. onAudioLockedObservable: Observable<AudioEngine>;
  5343. /**
  5344. * Flags the audio engine in Locked state.
  5345. * This happens due to new browser policies preventing audio to autoplay.
  5346. */
  5347. lock(): void;
  5348. /**
  5349. * Unlocks the audio engine once a user action has been done on the dom.
  5350. * This is helpful to resume play once browser policies have been satisfied.
  5351. */
  5352. unlock(): void;
  5353. }
  5354. /**
  5355. * This represents the default audio engine used in babylon.
  5356. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5358. */
  5359. class AudioEngine implements IAudioEngine {
  5360. private _audioContext;
  5361. private _audioContextInitialized;
  5362. private _muteButton;
  5363. private _hostElement;
  5364. /**
  5365. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5366. */
  5367. canUseWebAudio: boolean;
  5368. /**
  5369. * The master gain node defines the global audio volume of your audio engine.
  5370. */
  5371. masterGain: GainNode;
  5372. /**
  5373. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5374. * @ignoreNaming
  5375. */
  5376. WarnedWebAudioUnsupported: boolean;
  5377. /**
  5378. * Gets whether or not mp3 are supported by your browser.
  5379. */
  5380. isMP3supported: boolean;
  5381. /**
  5382. * Gets whether or not ogg are supported by your browser.
  5383. */
  5384. isOGGsupported: boolean;
  5385. /**
  5386. * Gets whether audio has been unlocked on the device.
  5387. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5388. * a user interaction has happened.
  5389. */
  5390. unlocked: boolean;
  5391. /**
  5392. * Defines if the audio engine relies on a custom unlocked button.
  5393. * In this case, the embedded button will not be displayed.
  5394. */
  5395. useCustomUnlockedButton: boolean;
  5396. /**
  5397. * Event raised when audio has been unlocked on the browser.
  5398. */
  5399. onAudioUnlockedObservable: Observable<AudioEngine>;
  5400. /**
  5401. * Event raised when audio has been locked on the browser.
  5402. */
  5403. onAudioLockedObservable: Observable<AudioEngine>;
  5404. /**
  5405. * Gets the current AudioContext if available.
  5406. */
  5407. readonly audioContext: Nullable<AudioContext>;
  5408. private _connectedAnalyser;
  5409. /**
  5410. * Instantiates a new audio engine.
  5411. *
  5412. * There should be only one per page as some browsers restrict the number
  5413. * of audio contexts you can create.
  5414. * @param hostElement defines the host element where to display the mute icon if necessary
  5415. */
  5416. constructor(hostElement?: Nullable<HTMLElement>);
  5417. /**
  5418. * Flags the audio engine in Locked state.
  5419. * This happens due to new browser policies preventing audio to autoplay.
  5420. */
  5421. lock(): void;
  5422. /**
  5423. * Unlocks the audio engine once a user action has been done on the dom.
  5424. * This is helpful to resume play once browser policies have been satisfied.
  5425. */
  5426. unlock(): void;
  5427. private _resumeAudioContext;
  5428. private _initializeAudioContext;
  5429. private _tryToRun;
  5430. private _triggerRunningState;
  5431. private _triggerSuspendedState;
  5432. private _displayMuteButton;
  5433. private _moveButtonToTopLeft;
  5434. private _onResize;
  5435. private _hideMuteButton;
  5436. /**
  5437. * Destroy and release the resources associated with the audio ccontext.
  5438. */
  5439. dispose(): void;
  5440. /**
  5441. * Gets the global volume sets on the master gain.
  5442. * @returns the global volume if set or -1 otherwise
  5443. */
  5444. getGlobalVolume(): number;
  5445. /**
  5446. * Sets the global volume of your experience (sets on the master gain).
  5447. * @param newVolume Defines the new global volume of the application
  5448. */
  5449. setGlobalVolume(newVolume: number): void;
  5450. /**
  5451. * Connect the audio engine to an audio analyser allowing some amazing
  5452. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5454. * @param analyser The analyser to connect to the engine
  5455. */
  5456. connectToAnalyser(analyser: Analyser): void;
  5457. }
  5458. }
  5459. declare module BABYLON {
  5460. interface AbstractScene {
  5461. /**
  5462. * The list of sounds used in the scene.
  5463. */
  5464. sounds: Nullable<Array<Sound>>;
  5465. }
  5466. interface Scene {
  5467. /**
  5468. * @hidden
  5469. * Backing field
  5470. */
  5471. _mainSoundTrack: SoundTrack;
  5472. /**
  5473. * The main sound track played by the scene.
  5474. * It cotains your primary collection of sounds.
  5475. */
  5476. mainSoundTrack: SoundTrack;
  5477. /**
  5478. * The list of sound tracks added to the scene
  5479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5480. */
  5481. soundTracks: Nullable<Array<SoundTrack>>;
  5482. /**
  5483. * Gets a sound using a given name
  5484. * @param name defines the name to search for
  5485. * @return the found sound or null if not found at all.
  5486. */
  5487. getSoundByName(name: string): Nullable<Sound>;
  5488. /**
  5489. * Gets or sets if audio support is enabled
  5490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5491. */
  5492. audioEnabled: boolean;
  5493. /**
  5494. * Gets or sets if audio will be output to headphones
  5495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5496. */
  5497. headphone: boolean;
  5498. }
  5499. /**
  5500. * Defines the sound scene component responsible to manage any sounds
  5501. * in a given scene.
  5502. */
  5503. class AudioSceneComponent implements ISceneSerializableComponent {
  5504. /**
  5505. * The component name helpfull to identify the component in the list of scene components.
  5506. */
  5507. readonly name: string;
  5508. /**
  5509. * The scene the component belongs to.
  5510. */
  5511. scene: Scene;
  5512. private _audioEnabled;
  5513. /**
  5514. * Gets whether audio is enabled or not.
  5515. * Please use related enable/disable method to switch state.
  5516. */
  5517. readonly audioEnabled: boolean;
  5518. private _headphone;
  5519. /**
  5520. * Gets whether audio is outputing to headphone or not.
  5521. * Please use the according Switch methods to change output.
  5522. */
  5523. readonly headphone: boolean;
  5524. /**
  5525. * Creates a new instance of the component for the given scene
  5526. * @param scene Defines the scene to register the component in
  5527. */
  5528. constructor(scene: Scene);
  5529. /**
  5530. * Registers the component in a given scene
  5531. */
  5532. register(): void;
  5533. /**
  5534. * Rebuilds the elements related to this component in case of
  5535. * context lost for instance.
  5536. */
  5537. rebuild(): void;
  5538. /**
  5539. * Serializes the component data to the specified json object
  5540. * @param serializationObject The object to serialize to
  5541. */
  5542. serialize(serializationObject: any): void;
  5543. /**
  5544. * Adds all the element from the container to the scene
  5545. * @param container the container holding the elements
  5546. */
  5547. addFromContainer(container: AbstractScene): void;
  5548. /**
  5549. * Removes all the elements in the container from the scene
  5550. * @param container contains the elements to remove
  5551. */
  5552. removeFromContainer(container: AbstractScene): void;
  5553. /**
  5554. * Disposes the component and the associated ressources.
  5555. */
  5556. dispose(): void;
  5557. /**
  5558. * Disables audio in the associated scene.
  5559. */
  5560. disableAudio(): void;
  5561. /**
  5562. * Enables audio in the associated scene.
  5563. */
  5564. enableAudio(): void;
  5565. /**
  5566. * Switch audio to headphone output.
  5567. */
  5568. switchAudioModeForHeadphones(): void;
  5569. /**
  5570. * Switch audio to normal speakers.
  5571. */
  5572. switchAudioModeForNormalSpeakers(): void;
  5573. private _afterRender;
  5574. }
  5575. }
  5576. declare module BABYLON {
  5577. /**
  5578. * Defines a sound that can be played in the application.
  5579. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5581. */
  5582. class Sound {
  5583. /**
  5584. * The name of the sound in the scene.
  5585. */
  5586. name: string;
  5587. /**
  5588. * Does the sound autoplay once loaded.
  5589. */
  5590. autoplay: boolean;
  5591. /**
  5592. * Does the sound loop after it finishes playing once.
  5593. */
  5594. loop: boolean;
  5595. /**
  5596. * Does the sound use a custom attenuation curve to simulate the falloff
  5597. * happening when the source gets further away from the camera.
  5598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5599. */
  5600. useCustomAttenuation: boolean;
  5601. /**
  5602. * The sound track id this sound belongs to.
  5603. */
  5604. soundTrackId: number;
  5605. /**
  5606. * Is this sound currently played.
  5607. */
  5608. isPlaying: boolean;
  5609. /**
  5610. * Is this sound currently paused.
  5611. */
  5612. isPaused: boolean;
  5613. /**
  5614. * Does this sound enables spatial sound.
  5615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5616. */
  5617. spatialSound: boolean;
  5618. /**
  5619. * Define the reference distance the sound should be heard perfectly.
  5620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5621. */
  5622. refDistance: number;
  5623. /**
  5624. * Define the roll off factor of spatial sounds.
  5625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5626. */
  5627. rolloffFactor: number;
  5628. /**
  5629. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5631. */
  5632. maxDistance: number;
  5633. /**
  5634. * Define the distance attenuation model the sound will follow.
  5635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5636. */
  5637. distanceModel: string;
  5638. /**
  5639. * @hidden
  5640. * Back Compat
  5641. **/
  5642. onended: () => any;
  5643. /**
  5644. * Observable event when the current playing sound finishes.
  5645. */
  5646. onEndedObservable: Observable<Sound>;
  5647. private _panningModel;
  5648. private _playbackRate;
  5649. private _streaming;
  5650. private _startTime;
  5651. private _startOffset;
  5652. private _position;
  5653. /** @hidden */
  5654. _positionInEmitterSpace: boolean;
  5655. private _localDirection;
  5656. private _volume;
  5657. private _isReadyToPlay;
  5658. private _isDirectional;
  5659. private _readyToPlayCallback;
  5660. private _audioBuffer;
  5661. private _soundSource;
  5662. private _streamingSource;
  5663. private _soundPanner;
  5664. private _soundGain;
  5665. private _inputAudioNode;
  5666. private _outputAudioNode;
  5667. private _coneInnerAngle;
  5668. private _coneOuterAngle;
  5669. private _coneOuterGain;
  5670. private _scene;
  5671. private _connectedTransformNode;
  5672. private _customAttenuationFunction;
  5673. private _registerFunc;
  5674. private _isOutputConnected;
  5675. private _htmlAudioElement;
  5676. private _urlType;
  5677. /**
  5678. * Create a sound and attach it to a scene
  5679. * @param name Name of your sound
  5680. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5681. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5682. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5683. */
  5684. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5685. /**
  5686. * Release the sound and its associated resources
  5687. */
  5688. dispose(): void;
  5689. /**
  5690. * Gets if the sounds is ready to be played or not.
  5691. * @returns true if ready, otherwise false
  5692. */
  5693. isReady(): boolean;
  5694. private _soundLoaded;
  5695. /**
  5696. * Sets the data of the sound from an audiobuffer
  5697. * @param audioBuffer The audioBuffer containing the data
  5698. */
  5699. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5700. /**
  5701. * Updates the current sounds options such as maxdistance, loop...
  5702. * @param options A JSON object containing values named as the object properties
  5703. */
  5704. updateOptions(options: any): void;
  5705. private _createSpatialParameters;
  5706. private _updateSpatialParameters;
  5707. /**
  5708. * Switch the panning model to HRTF:
  5709. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5711. */
  5712. switchPanningModelToHRTF(): void;
  5713. /**
  5714. * Switch the panning model to Equal Power:
  5715. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5717. */
  5718. switchPanningModelToEqualPower(): void;
  5719. private _switchPanningModel;
  5720. /**
  5721. * Connect this sound to a sound track audio node like gain...
  5722. * @param soundTrackAudioNode the sound track audio node to connect to
  5723. */
  5724. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5725. /**
  5726. * Transform this sound into a directional source
  5727. * @param coneInnerAngle Size of the inner cone in degree
  5728. * @param coneOuterAngle Size of the outer cone in degree
  5729. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5730. */
  5731. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5732. /**
  5733. * Gets or sets the inner angle for the directional cone.
  5734. */
  5735. /**
  5736. * Gets or sets the inner angle for the directional cone.
  5737. */
  5738. directionalConeInnerAngle: number;
  5739. /**
  5740. * Gets or sets the outer angle for the directional cone.
  5741. */
  5742. /**
  5743. * Gets or sets the outer angle for the directional cone.
  5744. */
  5745. directionalConeOuterAngle: number;
  5746. /**
  5747. * Sets the position of the emitter if spatial sound is enabled
  5748. * @param newPosition Defines the new posisiton
  5749. */
  5750. setPosition(newPosition: Vector3): void;
  5751. /**
  5752. * Sets the local direction of the emitter if spatial sound is enabled
  5753. * @param newLocalDirection Defines the new local direction
  5754. */
  5755. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5756. private _updateDirection;
  5757. /** @hidden */
  5758. updateDistanceFromListener(): void;
  5759. /**
  5760. * Sets a new custom attenuation function for the sound.
  5761. * @param callback Defines the function used for the attenuation
  5762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5763. */
  5764. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5765. /**
  5766. * Play the sound
  5767. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5768. * @param offset (optional) Start the sound setting it at a specific time
  5769. */
  5770. play(time?: number, offset?: number): void;
  5771. private _onended;
  5772. /**
  5773. * Stop the sound
  5774. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5775. */
  5776. stop(time?: number): void;
  5777. /**
  5778. * Put the sound in pause
  5779. */
  5780. pause(): void;
  5781. /**
  5782. * Sets a dedicated volume for this sounds
  5783. * @param newVolume Define the new volume of the sound
  5784. * @param time Define in how long the sound should be at this value
  5785. */
  5786. setVolume(newVolume: number, time?: number): void;
  5787. /**
  5788. * Set the sound play back rate
  5789. * @param newPlaybackRate Define the playback rate the sound should be played at
  5790. */
  5791. setPlaybackRate(newPlaybackRate: number): void;
  5792. /**
  5793. * Gets the volume of the sound.
  5794. * @returns the volume of the sound
  5795. */
  5796. getVolume(): number;
  5797. /**
  5798. * Attach the sound to a dedicated mesh
  5799. * @param transformNode The transform node to connect the sound with
  5800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5801. */
  5802. attachToMesh(transformNode: TransformNode): void;
  5803. /**
  5804. * Detach the sound from the previously attached mesh
  5805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5806. */
  5807. detachFromMesh(): void;
  5808. private _onRegisterAfterWorldMatrixUpdate;
  5809. /**
  5810. * Clone the current sound in the scene.
  5811. * @returns the new sound clone
  5812. */
  5813. clone(): Nullable<Sound>;
  5814. /**
  5815. * Gets the current underlying audio buffer containing the data
  5816. * @returns the audio buffer
  5817. */
  5818. getAudioBuffer(): Nullable<AudioBuffer>;
  5819. /**
  5820. * Serializes the Sound in a JSON representation
  5821. * @returns the JSON representation of the sound
  5822. */
  5823. serialize(): any;
  5824. /**
  5825. * Parse a JSON representation of a sound to innstantiate in a given scene
  5826. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5827. * @param scene Define the scene the new parsed sound should be created in
  5828. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5829. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5830. * @returns the newly parsed sound
  5831. */
  5832. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5833. }
  5834. }
  5835. declare module BABYLON {
  5836. /**
  5837. * Options allowed during the creation of a sound track.
  5838. */
  5839. interface ISoundTrackOptions {
  5840. /**
  5841. * The volume the sound track should take during creation
  5842. */
  5843. volume?: number;
  5844. /**
  5845. * Define if the sound track is the main sound track of the scene
  5846. */
  5847. mainTrack?: boolean;
  5848. }
  5849. /**
  5850. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5851. * It will be also used in a future release to apply effects on a specific track.
  5852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5853. */
  5854. class SoundTrack {
  5855. /**
  5856. * The unique identifier of the sound track in the scene.
  5857. */
  5858. id: number;
  5859. /**
  5860. * The list of sounds included in the sound track.
  5861. */
  5862. soundCollection: Array<Sound>;
  5863. private _outputAudioNode;
  5864. private _scene;
  5865. private _isMainTrack;
  5866. private _connectedAnalyser;
  5867. private _options;
  5868. private _isInitialized;
  5869. /**
  5870. * Creates a new sound track.
  5871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5872. * @param scene Define the scene the sound track belongs to
  5873. * @param options
  5874. */
  5875. constructor(scene: Scene, options?: ISoundTrackOptions);
  5876. private _initializeSoundTrackAudioGraph;
  5877. /**
  5878. * Release the sound track and its associated resources
  5879. */
  5880. dispose(): void;
  5881. /**
  5882. * Adds a sound to this sound track
  5883. * @param sound define the cound to add
  5884. * @ignoreNaming
  5885. */
  5886. AddSound(sound: Sound): void;
  5887. /**
  5888. * Removes a sound to this sound track
  5889. * @param sound define the cound to remove
  5890. * @ignoreNaming
  5891. */
  5892. RemoveSound(sound: Sound): void;
  5893. /**
  5894. * Set a global volume for the full sound track.
  5895. * @param newVolume Define the new volume of the sound track
  5896. */
  5897. setVolume(newVolume: number): void;
  5898. /**
  5899. * Switch the panning model to HRTF:
  5900. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5902. */
  5903. switchPanningModelToHRTF(): void;
  5904. /**
  5905. * Switch the panning model to Equal Power:
  5906. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5908. */
  5909. switchPanningModelToEqualPower(): void;
  5910. /**
  5911. * Connect the sound track to an audio analyser allowing some amazing
  5912. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5914. * @param analyser The analyser to connect to the engine
  5915. */
  5916. connectToAnalyser(analyser: Analyser): void;
  5917. }
  5918. }
  5919. declare module BABYLON {
  5920. /**
  5921. * Wraps one or more Sound objects and selects one with random weight for playback.
  5922. */
  5923. class WeightedSound {
  5924. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5925. loop: boolean;
  5926. private _coneInnerAngle;
  5927. private _coneOuterAngle;
  5928. private _volume;
  5929. /** A Sound is currently playing. */
  5930. isPlaying: boolean;
  5931. /** A Sound is currently paused. */
  5932. isPaused: boolean;
  5933. private _sounds;
  5934. private _weights;
  5935. private _currentIndex?;
  5936. /**
  5937. * Creates a new WeightedSound from the list of sounds given.
  5938. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5939. * @param sounds Array of Sounds that will be selected from.
  5940. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5941. */
  5942. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5943. /**
  5944. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5945. */
  5946. /**
  5947. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5948. */
  5949. directionalConeInnerAngle: number;
  5950. /**
  5951. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5952. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5953. */
  5954. /**
  5955. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5956. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5957. */
  5958. directionalConeOuterAngle: number;
  5959. /**
  5960. * Playback volume.
  5961. */
  5962. /**
  5963. * Playback volume.
  5964. */
  5965. volume: number;
  5966. private _onended;
  5967. /**
  5968. * Suspend playback
  5969. */
  5970. pause(): void;
  5971. /**
  5972. * Stop playback
  5973. */
  5974. stop(): void;
  5975. /**
  5976. * Start playback.
  5977. * @param startOffset Position the clip head at a specific time in seconds.
  5978. */
  5979. play(startOffset?: number): void;
  5980. }
  5981. }
  5982. declare module BABYLON {
  5983. /**
  5984. * Interface used to define a behavior
  5985. */
  5986. interface Behavior<T> {
  5987. /** gets or sets behavior's name */
  5988. name: string;
  5989. /**
  5990. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5991. */
  5992. init(): void;
  5993. /**
  5994. * Called when the behavior is attached to a target
  5995. * @param target defines the target where the behavior is attached to
  5996. */
  5997. attach(target: T): void;
  5998. /**
  5999. * Called when the behavior is detached from its target
  6000. */
  6001. detach(): void;
  6002. }
  6003. /**
  6004. * Interface implemented by classes supporting behaviors
  6005. */
  6006. interface IBehaviorAware<T> {
  6007. /**
  6008. * Attach a behavior
  6009. * @param behavior defines the behavior to attach
  6010. * @returns the current host
  6011. */
  6012. addBehavior(behavior: Behavior<T>): T;
  6013. /**
  6014. * Remove a behavior from the current object
  6015. * @param behavior defines the behavior to detach
  6016. * @returns the current host
  6017. */
  6018. removeBehavior(behavior: Behavior<T>): T;
  6019. /**
  6020. * Gets a behavior using its name to search
  6021. * @param name defines the name to search
  6022. * @returns the behavior or null if not found
  6023. */
  6024. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6025. }
  6026. }
  6027. declare module BABYLON {
  6028. /**
  6029. * Class used to store bone information
  6030. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6031. */
  6032. class Bone extends Node {
  6033. /**
  6034. * defines the bone name
  6035. */
  6036. name: string;
  6037. private static _tmpVecs;
  6038. private static _tmpQuat;
  6039. private static _tmpMats;
  6040. /**
  6041. * Gets the list of child bones
  6042. */
  6043. children: Bone[];
  6044. /** Gets the animations associated with this bone */
  6045. animations: Animation[];
  6046. /**
  6047. * Gets or sets bone length
  6048. */
  6049. length: number;
  6050. /**
  6051. * @hidden Internal only
  6052. * Set this value to map this bone to a different index in the transform matrices
  6053. * Set this value to -1 to exclude the bone from the transform matrices
  6054. */
  6055. _index: Nullable<number>;
  6056. private _skeleton;
  6057. private _localMatrix;
  6058. private _restPose;
  6059. private _baseMatrix;
  6060. private _absoluteTransform;
  6061. private _invertedAbsoluteTransform;
  6062. private _parent;
  6063. private _scalingDeterminant;
  6064. private _worldTransform;
  6065. private _localScaling;
  6066. private _localRotation;
  6067. private _localPosition;
  6068. private _needToDecompose;
  6069. private _needToCompose;
  6070. /** @hidden */
  6071. _linkedTransformNode: Nullable<TransformNode>;
  6072. /** @hidden */
  6073. /** @hidden */
  6074. _matrix: Matrix;
  6075. /**
  6076. * Create a new bone
  6077. * @param name defines the bone name
  6078. * @param skeleton defines the parent skeleton
  6079. * @param parentBone defines the parent (can be null if the bone is the root)
  6080. * @param localMatrix defines the local matrix
  6081. * @param restPose defines the rest pose matrix
  6082. * @param baseMatrix defines the base matrix
  6083. * @param index defines index of the bone in the hiearchy
  6084. */
  6085. constructor(
  6086. /**
  6087. * defines the bone name
  6088. */
  6089. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6090. /**
  6091. * Gets the parent skeleton
  6092. * @returns a skeleton
  6093. */
  6094. getSkeleton(): Skeleton;
  6095. /**
  6096. * Gets parent bone
  6097. * @returns a bone or null if the bone is the root of the bone hierarchy
  6098. */
  6099. getParent(): Nullable<Bone>;
  6100. /**
  6101. * Sets the parent bone
  6102. * @param parent defines the parent (can be null if the bone is the root)
  6103. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6104. */
  6105. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6106. /**
  6107. * Gets the local matrix
  6108. * @returns a matrix
  6109. */
  6110. getLocalMatrix(): Matrix;
  6111. /**
  6112. * Gets the base matrix (initial matrix which remains unchanged)
  6113. * @returns a matrix
  6114. */
  6115. getBaseMatrix(): Matrix;
  6116. /**
  6117. * Gets the rest pose matrix
  6118. * @returns a matrix
  6119. */
  6120. getRestPose(): Matrix;
  6121. /**
  6122. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6123. */
  6124. getWorldMatrix(): Matrix;
  6125. /**
  6126. * Sets the local matrix to rest pose matrix
  6127. */
  6128. returnToRest(): void;
  6129. /**
  6130. * Gets the inverse of the absolute transform matrix.
  6131. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6132. * @returns a matrix
  6133. */
  6134. getInvertedAbsoluteTransform(): Matrix;
  6135. /**
  6136. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6137. * @returns a matrix
  6138. */
  6139. getAbsoluteTransform(): Matrix;
  6140. /**
  6141. * Links with the given transform node.
  6142. * The local matrix of this bone is copied from the transform node every frame.
  6143. * @param transformNode defines the transform node to link to
  6144. */
  6145. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6146. /** Gets or sets current position (in local space) */
  6147. position: Vector3;
  6148. /** Gets or sets current rotation (in local space) */
  6149. rotation: Vector3;
  6150. /** Gets or sets current rotation quaternion (in local space) */
  6151. rotationQuaternion: Quaternion;
  6152. /** Gets or sets current scaling (in local space) */
  6153. scaling: Vector3;
  6154. /**
  6155. * Gets the animation properties override
  6156. */
  6157. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6158. private _decompose;
  6159. private _compose;
  6160. /**
  6161. * Update the base and local matrices
  6162. * @param matrix defines the new base or local matrix
  6163. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6164. * @param updateLocalMatrix defines if the local matrix should be updated
  6165. */
  6166. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6167. /** @hidden */
  6168. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6169. /**
  6170. * Flag the bone as dirty (Forcing it to update everything)
  6171. */
  6172. markAsDirty(): void;
  6173. private _markAsDirtyAndCompose;
  6174. private _markAsDirtyAndDecompose;
  6175. /**
  6176. * Copy an animation range from another bone
  6177. * @param source defines the source bone
  6178. * @param rangeName defines the range name to copy
  6179. * @param frameOffset defines the frame offset
  6180. * @param rescaleAsRequired defines if rescaling must be applied if required
  6181. * @param skelDimensionsRatio defines the scaling ratio
  6182. * @returns true if operation was successful
  6183. */
  6184. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6185. /**
  6186. * Translate the bone in local or world space
  6187. * @param vec The amount to translate the bone
  6188. * @param space The space that the translation is in
  6189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6190. */
  6191. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6192. /**
  6193. * Set the postion of the bone in local or world space
  6194. * @param position The position to set the bone
  6195. * @param space The space that the position is in
  6196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6197. */
  6198. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6199. /**
  6200. * Set the absolute position of the bone (world space)
  6201. * @param position The position to set the bone
  6202. * @param mesh The mesh that this bone is attached to
  6203. */
  6204. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6205. /**
  6206. * Scale the bone on the x, y and z axes (in local space)
  6207. * @param x The amount to scale the bone on the x axis
  6208. * @param y The amount to scale the bone on the y axis
  6209. * @param z The amount to scale the bone on the z axis
  6210. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6211. */
  6212. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6213. /**
  6214. * Set the bone scaling in local space
  6215. * @param scale defines the scaling vector
  6216. */
  6217. setScale(scale: Vector3): void;
  6218. /**
  6219. * Gets the current scaling in local space
  6220. * @returns the current scaling vector
  6221. */
  6222. getScale(): Vector3;
  6223. /**
  6224. * Gets the current scaling in local space and stores it in a target vector
  6225. * @param result defines the target vector
  6226. */
  6227. getScaleToRef(result: Vector3): void;
  6228. /**
  6229. * Set the yaw, pitch, and roll of the bone in local or world space
  6230. * @param yaw The rotation of the bone on the y axis
  6231. * @param pitch The rotation of the bone on the x axis
  6232. * @param roll The rotation of the bone on the z axis
  6233. * @param space The space that the axes of rotation are in
  6234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6235. */
  6236. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6237. /**
  6238. * Add a rotation to the bone on an axis in local or world space
  6239. * @param axis The axis to rotate the bone on
  6240. * @param amount The amount to rotate the bone
  6241. * @param space The space that the axis is in
  6242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6243. */
  6244. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6245. /**
  6246. * Set the rotation of the bone to a particular axis angle in local or world space
  6247. * @param axis The axis to rotate the bone on
  6248. * @param angle The angle that the bone should be rotated to
  6249. * @param space The space that the axis is in
  6250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6251. */
  6252. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6253. /**
  6254. * Set the euler rotation of the bone in local of world space
  6255. * @param rotation The euler rotation that the bone should be set to
  6256. * @param space The space that the rotation is in
  6257. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6258. */
  6259. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6260. /**
  6261. * Set the quaternion rotation of the bone in local of world space
  6262. * @param quat The quaternion rotation that the bone should be set to
  6263. * @param space The space that the rotation is in
  6264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6265. */
  6266. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6267. /**
  6268. * Set the rotation matrix of the bone in local of world space
  6269. * @param rotMat The rotation matrix that the bone should be set to
  6270. * @param space The space that the rotation is in
  6271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6272. */
  6273. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6274. private _rotateWithMatrix;
  6275. private _getNegativeRotationToRef;
  6276. /**
  6277. * Get the position of the bone in local or world space
  6278. * @param space The space that the returned position is in
  6279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6280. * @returns The position of the bone
  6281. */
  6282. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6283. /**
  6284. * Copy the position of the bone to a vector3 in local or world space
  6285. * @param space The space that the returned position is in
  6286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6287. * @param result The vector3 to copy the position to
  6288. */
  6289. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6290. /**
  6291. * Get the absolute position of the bone (world space)
  6292. * @param mesh The mesh that this bone is attached to
  6293. * @returns The absolute position of the bone
  6294. */
  6295. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6296. /**
  6297. * Copy the absolute position of the bone (world space) to the result param
  6298. * @param mesh The mesh that this bone is attached to
  6299. * @param result The vector3 to copy the absolute position to
  6300. */
  6301. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6302. /**
  6303. * Compute the absolute transforms of this bone and its children
  6304. */
  6305. computeAbsoluteTransforms(): void;
  6306. /**
  6307. * Get the world direction from an axis that is in the local space of the bone
  6308. * @param localAxis The local direction that is used to compute the world direction
  6309. * @param mesh The mesh that this bone is attached to
  6310. * @returns The world direction
  6311. */
  6312. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6313. /**
  6314. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6315. * @param localAxis The local direction that is used to compute the world direction
  6316. * @param mesh The mesh that this bone is attached to
  6317. * @param result The vector3 that the world direction will be copied to
  6318. */
  6319. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6320. /**
  6321. * Get the euler rotation of the bone in local or world space
  6322. * @param space The space that the rotation should be in
  6323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6324. * @returns The euler rotation
  6325. */
  6326. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6327. /**
  6328. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6329. * @param space The space that the rotation should be in
  6330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6331. * @param result The vector3 that the rotation should be copied to
  6332. */
  6333. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6334. /**
  6335. * Get the quaternion rotation of the bone in either local or world space
  6336. * @param space The space that the rotation should be in
  6337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6338. * @returns The quaternion rotation
  6339. */
  6340. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6341. /**
  6342. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6343. * @param space The space that the rotation should be in
  6344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6345. * @param result The quaternion that the rotation should be copied to
  6346. */
  6347. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6348. /**
  6349. * Get the rotation matrix of the bone in local or world space
  6350. * @param space The space that the rotation should be in
  6351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6352. * @returns The rotation matrix
  6353. */
  6354. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6355. /**
  6356. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6357. * @param space The space that the rotation should be in
  6358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6359. * @param result The quaternion that the rotation should be copied to
  6360. */
  6361. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6362. /**
  6363. * Get the world position of a point that is in the local space of the bone
  6364. * @param position The local position
  6365. * @param mesh The mesh that this bone is attached to
  6366. * @returns The world position
  6367. */
  6368. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6369. /**
  6370. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6371. * @param position The local position
  6372. * @param mesh The mesh that this bone is attached to
  6373. * @param result The vector3 that the world position should be copied to
  6374. */
  6375. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6376. /**
  6377. * Get the local position of a point that is in world space
  6378. * @param position The world position
  6379. * @param mesh The mesh that this bone is attached to
  6380. * @returns The local position
  6381. */
  6382. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6383. /**
  6384. * Get the local position of a point that is in world space and copy it to the result param
  6385. * @param position The world position
  6386. * @param mesh The mesh that this bone is attached to
  6387. * @param result The vector3 that the local position should be copied to
  6388. */
  6389. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6390. }
  6391. }
  6392. declare module BABYLON {
  6393. /**
  6394. * Class used to apply inverse kinematics to bones
  6395. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6396. */
  6397. class BoneIKController {
  6398. private static _tmpVecs;
  6399. private static _tmpQuat;
  6400. private static _tmpMats;
  6401. /**
  6402. * Gets or sets the target mesh
  6403. */
  6404. targetMesh: AbstractMesh;
  6405. /** Gets or sets the mesh used as pole */
  6406. poleTargetMesh: AbstractMesh;
  6407. /**
  6408. * Gets or sets the bone used as pole
  6409. */
  6410. poleTargetBone: Nullable<Bone>;
  6411. /**
  6412. * Gets or sets the target position
  6413. */
  6414. targetPosition: Vector3;
  6415. /**
  6416. * Gets or sets the pole target position
  6417. */
  6418. poleTargetPosition: Vector3;
  6419. /**
  6420. * Gets or sets the pole target local offset
  6421. */
  6422. poleTargetLocalOffset: Vector3;
  6423. /**
  6424. * Gets or sets the pole angle
  6425. */
  6426. poleAngle: number;
  6427. /**
  6428. * Gets or sets the mesh associated with the controller
  6429. */
  6430. mesh: AbstractMesh;
  6431. /**
  6432. * 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)
  6433. */
  6434. slerpAmount: number;
  6435. private _bone1Quat;
  6436. private _bone1Mat;
  6437. private _bone2Ang;
  6438. private _bone1;
  6439. private _bone2;
  6440. private _bone1Length;
  6441. private _bone2Length;
  6442. private _maxAngle;
  6443. private _maxReach;
  6444. private _rightHandedSystem;
  6445. private _bendAxis;
  6446. private _slerping;
  6447. private _adjustRoll;
  6448. /**
  6449. * Gets or sets maximum allowed angle
  6450. */
  6451. maxAngle: number;
  6452. /**
  6453. * Creates a new BoneIKController
  6454. * @param mesh defines the mesh to control
  6455. * @param bone defines the bone to control
  6456. * @param options defines options to set up the controller
  6457. */
  6458. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6459. targetMesh?: AbstractMesh;
  6460. poleTargetMesh?: AbstractMesh;
  6461. poleTargetBone?: Bone;
  6462. poleTargetLocalOffset?: Vector3;
  6463. poleAngle?: number;
  6464. bendAxis?: Vector3;
  6465. maxAngle?: number;
  6466. slerpAmount?: number;
  6467. });
  6468. private _setMaxAngle;
  6469. /**
  6470. * Force the controller to update the bones
  6471. */
  6472. update(): void;
  6473. }
  6474. }
  6475. declare module BABYLON {
  6476. /**
  6477. * Class used to make a bone look toward a point in space
  6478. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6479. */
  6480. class BoneLookController {
  6481. private static _tmpVecs;
  6482. private static _tmpQuat;
  6483. private static _tmpMats;
  6484. /**
  6485. * The target Vector3 that the bone will look at
  6486. */
  6487. target: Vector3;
  6488. /**
  6489. * The mesh that the bone is attached to
  6490. */
  6491. mesh: AbstractMesh;
  6492. /**
  6493. * The bone that will be looking to the target
  6494. */
  6495. bone: Bone;
  6496. /**
  6497. * The up axis of the coordinate system that is used when the bone is rotated
  6498. */
  6499. upAxis: Vector3;
  6500. /**
  6501. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6502. */
  6503. upAxisSpace: Space;
  6504. /**
  6505. * Used to make an adjustment to the yaw of the bone
  6506. */
  6507. adjustYaw: number;
  6508. /**
  6509. * Used to make an adjustment to the pitch of the bone
  6510. */
  6511. adjustPitch: number;
  6512. /**
  6513. * Used to make an adjustment to the roll of the bone
  6514. */
  6515. adjustRoll: number;
  6516. /**
  6517. * 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)
  6518. */
  6519. slerpAmount: number;
  6520. private _minYaw;
  6521. private _maxYaw;
  6522. private _minPitch;
  6523. private _maxPitch;
  6524. private _minYawSin;
  6525. private _minYawCos;
  6526. private _maxYawSin;
  6527. private _maxYawCos;
  6528. private _midYawConstraint;
  6529. private _minPitchTan;
  6530. private _maxPitchTan;
  6531. private _boneQuat;
  6532. private _slerping;
  6533. private _transformYawPitch;
  6534. private _transformYawPitchInv;
  6535. private _firstFrameSkipped;
  6536. private _yawRange;
  6537. private _fowardAxis;
  6538. /**
  6539. * Gets or sets the minimum yaw angle that the bone can look to
  6540. */
  6541. minYaw: number;
  6542. /**
  6543. * Gets or sets the maximum yaw angle that the bone can look to
  6544. */
  6545. maxYaw: number;
  6546. /**
  6547. * Gets or sets the minimum pitch angle that the bone can look to
  6548. */
  6549. minPitch: number;
  6550. /**
  6551. * Gets or sets the maximum pitch angle that the bone can look to
  6552. */
  6553. maxPitch: number;
  6554. /**
  6555. * Create a BoneLookController
  6556. * @param mesh the mesh that the bone belongs to
  6557. * @param bone the bone that will be looking to the target
  6558. * @param target the target Vector3 to look at
  6559. * @param settings optional settings:
  6560. * * maxYaw: the maximum angle the bone will yaw to
  6561. * * minYaw: the minimum angle the bone will yaw to
  6562. * * maxPitch: the maximum angle the bone will pitch to
  6563. * * minPitch: the minimum angle the bone will yaw to
  6564. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6565. * * upAxis: the up axis of the coordinate system
  6566. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6567. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6568. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6569. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6570. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6571. * * adjustRoll: used to make an adjustment to the roll of the bone
  6572. **/
  6573. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6574. maxYaw?: number;
  6575. minYaw?: number;
  6576. maxPitch?: number;
  6577. minPitch?: number;
  6578. slerpAmount?: number;
  6579. upAxis?: Vector3;
  6580. upAxisSpace?: Space;
  6581. yawAxis?: Vector3;
  6582. pitchAxis?: Vector3;
  6583. adjustYaw?: number;
  6584. adjustPitch?: number;
  6585. adjustRoll?: number;
  6586. });
  6587. /**
  6588. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6589. */
  6590. update(): void;
  6591. private _getAngleDiff;
  6592. private _getAngleBetween;
  6593. private _isAngleBetween;
  6594. }
  6595. }
  6596. declare module BABYLON {
  6597. /**
  6598. * Class used to handle skinning animations
  6599. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6600. */
  6601. class Skeleton implements IAnimatable {
  6602. /** defines the skeleton name */
  6603. name: string;
  6604. /** defines the skeleton Id */
  6605. id: string;
  6606. /**
  6607. * Defines the list of child bones
  6608. */
  6609. bones: Bone[];
  6610. /**
  6611. * Defines an estimate of the dimension of the skeleton at rest
  6612. */
  6613. dimensionsAtRest: Vector3;
  6614. /**
  6615. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6616. */
  6617. needInitialSkinMatrix: boolean;
  6618. /**
  6619. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6620. */
  6621. overrideMesh: Nullable<AbstractMesh>;
  6622. /**
  6623. * Gets the list of animations attached to this skeleton
  6624. */
  6625. animations: Array<Animation>;
  6626. private _scene;
  6627. private _isDirty;
  6628. private _transformMatrices;
  6629. private _transformMatrixTexture;
  6630. private _meshesWithPoseMatrix;
  6631. private _animatables;
  6632. private _identity;
  6633. private _synchronizedWithMesh;
  6634. private _ranges;
  6635. private _lastAbsoluteTransformsUpdateId;
  6636. private _canUseTextureForBones;
  6637. /** @hidden */
  6638. _numBonesWithLinkedTransformNode: number;
  6639. /**
  6640. * Specifies if the skeleton should be serialized
  6641. */
  6642. doNotSerialize: boolean;
  6643. /**
  6644. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6645. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6646. */
  6647. useTextureToStoreBoneMatrices: boolean;
  6648. private _animationPropertiesOverride;
  6649. /**
  6650. * Gets or sets the animation properties override
  6651. */
  6652. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6653. /**
  6654. * An observable triggered before computing the skeleton's matrices
  6655. */
  6656. onBeforeComputeObservable: Observable<Skeleton>;
  6657. /**
  6658. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6659. */
  6660. readonly isUsingTextureForMatrices: boolean;
  6661. /**
  6662. * Creates a new skeleton
  6663. * @param name defines the skeleton name
  6664. * @param id defines the skeleton Id
  6665. * @param scene defines the hosting scene
  6666. */
  6667. constructor(
  6668. /** defines the skeleton name */
  6669. name: string,
  6670. /** defines the skeleton Id */
  6671. id: string, scene: Scene);
  6672. /**
  6673. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6674. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6675. * @returns a Float32Array containing matrices data
  6676. */
  6677. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6678. /**
  6679. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6680. * @returns a raw texture containing the data
  6681. */
  6682. getTransformMatrixTexture(): Nullable<RawTexture>;
  6683. /**
  6684. * Gets the current hosting scene
  6685. * @returns a scene object
  6686. */
  6687. getScene(): Scene;
  6688. /**
  6689. * Gets a string representing the current skeleton data
  6690. * @param fullDetails defines a boolean indicating if we want a verbose version
  6691. * @returns a string representing the current skeleton data
  6692. */
  6693. toString(fullDetails?: boolean): string;
  6694. /**
  6695. * Get bone's index searching by name
  6696. * @param name defines bone's name to search for
  6697. * @return the indice of the bone. Returns -1 if not found
  6698. */
  6699. getBoneIndexByName(name: string): number;
  6700. /**
  6701. * Creater a new animation range
  6702. * @param name defines the name of the range
  6703. * @param from defines the start key
  6704. * @param to defines the end key
  6705. */
  6706. createAnimationRange(name: string, from: number, to: number): void;
  6707. /**
  6708. * Delete a specific animation range
  6709. * @param name defines the name of the range
  6710. * @param deleteFrames defines if frames must be removed as well
  6711. */
  6712. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6713. /**
  6714. * Gets a specific animation range
  6715. * @param name defines the name of the range to look for
  6716. * @returns the requested animation range or null if not found
  6717. */
  6718. getAnimationRange(name: string): Nullable<AnimationRange>;
  6719. /**
  6720. * Gets the list of all animation ranges defined on this skeleton
  6721. * @returns an array
  6722. */
  6723. getAnimationRanges(): Nullable<AnimationRange>[];
  6724. /**
  6725. * Copy animation range from a source skeleton.
  6726. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6727. * @param source defines the source skeleton
  6728. * @param name defines the name of the range to copy
  6729. * @param rescaleAsRequired defines if rescaling must be applied if required
  6730. * @returns true if operation was successful
  6731. */
  6732. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6733. /**
  6734. * Forces the skeleton to go to rest pose
  6735. */
  6736. returnToRest(): void;
  6737. private _getHighestAnimationFrame;
  6738. /**
  6739. * Begin a specific animation range
  6740. * @param name defines the name of the range to start
  6741. * @param loop defines if looping must be turned on (false by default)
  6742. * @param speedRatio defines the speed ratio to apply (1 by default)
  6743. * @param onAnimationEnd defines a callback which will be called when animation will end
  6744. * @returns a new animatable
  6745. */
  6746. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6747. /** @hidden */
  6748. _markAsDirty(): void;
  6749. /** @hidden */
  6750. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6751. /** @hidden */
  6752. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6753. private _computeTransformMatrices;
  6754. /**
  6755. * Build all resources required to render a skeleton
  6756. */
  6757. prepare(): void;
  6758. /**
  6759. * Gets the list of animatables currently running for this skeleton
  6760. * @returns an array of animatables
  6761. */
  6762. getAnimatables(): IAnimatable[];
  6763. /**
  6764. * Clone the current skeleton
  6765. * @param name defines the name of the new skeleton
  6766. * @param id defines the id of the enw skeleton
  6767. * @returns the new skeleton
  6768. */
  6769. clone(name: string, id: string): Skeleton;
  6770. /**
  6771. * Enable animation blending for this skeleton
  6772. * @param blendingSpeed defines the blending speed to apply
  6773. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6774. */
  6775. enableBlending(blendingSpeed?: number): void;
  6776. /**
  6777. * Releases all resources associated with the current skeleton
  6778. */
  6779. dispose(): void;
  6780. /**
  6781. * Serialize the skeleton in a JSON object
  6782. * @returns a JSON object
  6783. */
  6784. serialize(): any;
  6785. /**
  6786. * Creates a new skeleton from serialized data
  6787. * @param parsedSkeleton defines the serialized data
  6788. * @param scene defines the hosting scene
  6789. * @returns a new skeleton
  6790. */
  6791. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6792. /**
  6793. * Compute all node absolute transforms
  6794. * @param forceUpdate defines if computation must be done even if cache is up to date
  6795. */
  6796. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6797. /**
  6798. * Gets the root pose matrix
  6799. * @returns a matrix
  6800. */
  6801. getPoseMatrix(): Nullable<Matrix>;
  6802. /**
  6803. * Sorts bones per internal index
  6804. */
  6805. sortBones(): void;
  6806. private _sortBones;
  6807. }
  6808. }
  6809. declare module BABYLON {
  6810. /**
  6811. * Class used to store bounding box information
  6812. */
  6813. class BoundingBox implements ICullable {
  6814. /**
  6815. * Gets the 8 vectors representing the bounding box in local space
  6816. */
  6817. readonly vectors: Vector3[];
  6818. /**
  6819. * Gets the center of the bounding box in local space
  6820. */
  6821. readonly center: Vector3;
  6822. /**
  6823. * Gets the center of the bounding box in world space
  6824. */
  6825. readonly centerWorld: Vector3;
  6826. /**
  6827. * Gets the extend size in local space
  6828. */
  6829. readonly extendSize: Vector3;
  6830. /**
  6831. * Gets the extend size in world space
  6832. */
  6833. readonly extendSizeWorld: Vector3;
  6834. /**
  6835. * Gets the OBB (object bounding box) directions
  6836. */
  6837. readonly directions: Vector3[];
  6838. /**
  6839. * Gets the 8 vectors representing the bounding box in world space
  6840. */
  6841. readonly vectorsWorld: Vector3[];
  6842. /**
  6843. * Gets the minimum vector in world space
  6844. */
  6845. readonly minimumWorld: Vector3;
  6846. /**
  6847. * Gets the maximum vector in world space
  6848. */
  6849. readonly maximumWorld: Vector3;
  6850. /**
  6851. * Gets the minimum vector in local space
  6852. */
  6853. readonly minimum: Vector3;
  6854. /**
  6855. * Gets the maximum vector in local space
  6856. */
  6857. readonly maximum: Vector3;
  6858. private _worldMatrix;
  6859. private static readonly TmpVector3;
  6860. /**
  6861. * @hidden
  6862. */
  6863. _tag: number;
  6864. /**
  6865. * Creates a new bounding box
  6866. * @param min defines the minimum vector (in local space)
  6867. * @param max defines the maximum vector (in local space)
  6868. * @param worldMatrix defines the new world matrix
  6869. */
  6870. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6871. /**
  6872. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6873. * @param min defines the new minimum vector (in local space)
  6874. * @param max defines the new maximum vector (in local space)
  6875. * @param worldMatrix defines the new world matrix
  6876. */
  6877. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6878. /**
  6879. * Scale the current bounding box by applying a scale factor
  6880. * @param factor defines the scale factor to apply
  6881. * @returns the current bounding box
  6882. */
  6883. scale(factor: number): BoundingBox;
  6884. /**
  6885. * Gets the world matrix of the bounding box
  6886. * @returns a matrix
  6887. */
  6888. getWorldMatrix(): DeepImmutable<Matrix>;
  6889. /** @hidden */
  6890. _update(world: DeepImmutable<Matrix>): void;
  6891. /**
  6892. * Tests if the bounding box is intersecting the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an intersection
  6895. */
  6896. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if the bounding box is entirely inside the frustum planes
  6899. * @param frustumPlanes defines the frustum planes to test
  6900. * @returns true if there is an inclusion
  6901. */
  6902. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6903. /**
  6904. * Tests if a point is inside the bounding box
  6905. * @param point defines the point to test
  6906. * @returns true if the point is inside the bounding box
  6907. */
  6908. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a bounding sphere
  6911. * @param sphere defines the sphere to test
  6912. * @returns true if there is an intersection
  6913. */
  6914. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6915. /**
  6916. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6917. * @param min defines the min vector to use
  6918. * @param max defines the max vector to use
  6919. * @returns true if there is an intersection
  6920. */
  6921. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6922. /**
  6923. * Tests if two bounding boxes are intersections
  6924. * @param box0 defines the first box to test
  6925. * @param box1 defines the second box to test
  6926. * @returns true if there is an intersection
  6927. */
  6928. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6929. /**
  6930. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6931. * @param minPoint defines the minimum vector of the bounding box
  6932. * @param maxPoint defines the maximum vector of the bounding box
  6933. * @param sphereCenter defines the sphere center
  6934. * @param sphereRadius defines the sphere radius
  6935. * @returns true if there is an intersection
  6936. */
  6937. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6938. /**
  6939. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6940. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @return true if there is an inclusion
  6943. */
  6944. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6947. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @return true if there is an intersection
  6950. */
  6951. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. }
  6953. }
  6954. declare module BABYLON {
  6955. /**
  6956. * Interface for cullable objects
  6957. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6958. */
  6959. interface ICullable {
  6960. /**
  6961. * Checks if the object or part of the object is in the frustum
  6962. * @param frustumPlanes Camera near/planes
  6963. * @returns true if the object is in frustum otherwise false
  6964. */
  6965. isInFrustum(frustumPlanes: Plane[]): boolean;
  6966. /**
  6967. * Checks if a cullable object (mesh...) is in the camera frustum
  6968. * Unlike isInFrustum this cheks the full bounding box
  6969. * @param frustumPlanes Camera near/planes
  6970. * @returns true if the object is in frustum otherwise false
  6971. */
  6972. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6973. }
  6974. /**
  6975. * Info for a bounding data of a mesh
  6976. */
  6977. class BoundingInfo implements ICullable {
  6978. /**
  6979. * Bounding box for the mesh
  6980. */
  6981. readonly boundingBox: BoundingBox;
  6982. /**
  6983. * Bounding sphere for the mesh
  6984. */
  6985. readonly boundingSphere: BoundingSphere;
  6986. private _isLocked;
  6987. private static readonly TmpVector3;
  6988. /**
  6989. * Constructs bounding info
  6990. * @param minimum min vector of the bounding box/sphere
  6991. * @param maximum max vector of the bounding box/sphere
  6992. * @param worldMatrix defines the new world matrix
  6993. */
  6994. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6995. /**
  6996. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6997. * @param min defines the new minimum vector (in local space)
  6998. * @param max defines the new maximum vector (in local space)
  6999. * @param worldMatrix defines the new world matrix
  7000. */
  7001. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7002. /**
  7003. * min vector of the bounding box/sphere
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * max vector of the bounding box/sphere
  7008. */
  7009. readonly maximum: Vector3;
  7010. /**
  7011. * If the info is locked and won't be updated to avoid perf overhead
  7012. */
  7013. isLocked: boolean;
  7014. /**
  7015. * Updates the bounding sphere and box
  7016. * @param world world matrix to be used to update
  7017. */
  7018. update(world: DeepImmutable<Matrix>): void;
  7019. /**
  7020. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7021. * @param center New center of the bounding info
  7022. * @param extend New extend of the bounding info
  7023. * @returns the current bounding info
  7024. */
  7025. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7026. /**
  7027. * Scale the current bounding info by applying a scale factor
  7028. * @param factor defines the scale factor to apply
  7029. * @returns the current bounding info
  7030. */
  7031. scale(factor: number): BoundingInfo;
  7032. /**
  7033. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7034. * @param frustumPlanes defines the frustum to test
  7035. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7036. * @returns true if the bounding info is in the frustum planes
  7037. */
  7038. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7039. /**
  7040. * Gets the world distance between the min and max points of the bounding box
  7041. */
  7042. readonly diagonalLength: number;
  7043. /**
  7044. * Checks if a cullable object (mesh...) is in the camera frustum
  7045. * Unlike isInFrustum this cheks the full bounding box
  7046. * @param frustumPlanes Camera near/planes
  7047. * @returns true if the object is in frustum otherwise false
  7048. */
  7049. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7050. /** @hidden */
  7051. _checkCollision(collider: Collider): boolean;
  7052. /**
  7053. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7054. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7055. * @param point the point to check intersection with
  7056. * @returns if the point intersects
  7057. */
  7058. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7059. /**
  7060. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7061. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7062. * @param boundingInfo the bounding info to check intersection with
  7063. * @param precise if the intersection should be done using OBB
  7064. * @returns if the bounding info intersects
  7065. */
  7066. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7067. }
  7068. }
  7069. declare module BABYLON {
  7070. /**
  7071. * Class used to store bounding sphere information
  7072. */
  7073. class BoundingSphere {
  7074. /**
  7075. * Gets the center of the bounding sphere in local space
  7076. */
  7077. readonly center: Vector3;
  7078. /**
  7079. * Radius of the bounding sphere in local space
  7080. */
  7081. radius: number;
  7082. /**
  7083. * Gets the center of the bounding sphere in world space
  7084. */
  7085. readonly centerWorld: Vector3;
  7086. /**
  7087. * Radius of the bounding sphere in world space
  7088. */
  7089. radiusWorld: number;
  7090. /**
  7091. * Gets the minimum vector in local space
  7092. */
  7093. readonly minimum: Vector3;
  7094. /**
  7095. * Gets the maximum vector in local space
  7096. */
  7097. readonly maximum: Vector3;
  7098. private _worldMatrix;
  7099. private static readonly TmpVector3;
  7100. /**
  7101. * Creates a new bounding sphere
  7102. * @param min defines the minimum vector (in local space)
  7103. * @param max defines the maximum vector (in local space)
  7104. * @param worldMatrix defines the new world matrix
  7105. */
  7106. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7107. /**
  7108. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7109. * @param min defines the new minimum vector (in local space)
  7110. * @param max defines the new maximum vector (in local space)
  7111. * @param worldMatrix defines the new world matrix
  7112. */
  7113. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7114. /**
  7115. * Scale the current bounding sphere by applying a scale factor
  7116. * @param factor defines the scale factor to apply
  7117. * @returns the current bounding box
  7118. */
  7119. scale(factor: number): BoundingSphere;
  7120. /**
  7121. * Gets the world matrix of the bounding box
  7122. * @returns a matrix
  7123. */
  7124. getWorldMatrix(): DeepImmutable<Matrix>;
  7125. /** @hidden */
  7126. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7127. /**
  7128. * Tests if the bounding sphere is intersecting the frustum planes
  7129. * @param frustumPlanes defines the frustum planes to test
  7130. * @returns true if there is an intersection
  7131. */
  7132. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7133. /**
  7134. * Tests if the bounding sphere center is in between the frustum planes.
  7135. * Used for optimistic fast inclusion.
  7136. * @param frustumPlanes defines the frustum planes to test
  7137. * @returns true if the sphere center is in between the frustum planes
  7138. */
  7139. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7140. /**
  7141. * Tests if a point is inside the bounding sphere
  7142. * @param point defines the point to test
  7143. * @returns true if the point is inside the bounding sphere
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if two sphere intersct
  7148. * @param sphere0 sphere 0
  7149. * @param sphere1 sphere 1
  7150. * @returns true if the speres intersect
  7151. */
  7152. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7153. }
  7154. }
  7155. declare module BABYLON {
  7156. /**
  7157. * Class representing a ray with position and direction
  7158. */
  7159. class Ray {
  7160. /** origin point */
  7161. origin: Vector3;
  7162. /** direction */
  7163. direction: Vector3;
  7164. /** length of the ray */
  7165. length: number;
  7166. private static readonly TmpVector3;
  7167. private _tmpRay;
  7168. /**
  7169. * Creates a new ray
  7170. * @param origin origin point
  7171. * @param direction direction
  7172. * @param length length of the ray
  7173. */
  7174. constructor(
  7175. /** origin point */
  7176. origin: Vector3,
  7177. /** direction */
  7178. direction: Vector3,
  7179. /** length of the ray */
  7180. length?: number);
  7181. /**
  7182. * Checks if the ray intersects a box
  7183. * @param minimum bound of the box
  7184. * @param maximum bound of the box
  7185. * @param intersectionTreshold extra extend to be added to the box in all direction
  7186. * @returns if the box was hit
  7187. */
  7188. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7189. /**
  7190. * Checks if the ray intersects a box
  7191. * @param box the bounding box to check
  7192. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7193. * @returns if the box was hit
  7194. */
  7195. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7196. /**
  7197. * If the ray hits a sphere
  7198. * @param sphere the bounding sphere to check
  7199. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7200. * @returns true if it hits the sphere
  7201. */
  7202. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7203. /**
  7204. * If the ray hits a triange
  7205. * @param vertex0 triangle vertex
  7206. * @param vertex1 triangle vertex
  7207. * @param vertex2 triangle vertex
  7208. * @returns intersection information if hit
  7209. */
  7210. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7211. /**
  7212. * Checks if ray intersects a plane
  7213. * @param plane the plane to check
  7214. * @returns the distance away it was hit
  7215. */
  7216. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7217. /**
  7218. * Checks if ray intersects a mesh
  7219. * @param mesh the mesh to check
  7220. * @param fastCheck if only the bounding box should checked
  7221. * @returns picking info of the intersecton
  7222. */
  7223. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7224. /**
  7225. * Checks if ray intersects a mesh
  7226. * @param meshes the meshes to check
  7227. * @param fastCheck if only the bounding box should checked
  7228. * @param results array to store result in
  7229. * @returns Array of picking infos
  7230. */
  7231. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7232. private _comparePickingInfo;
  7233. private static smallnum;
  7234. private static rayl;
  7235. /**
  7236. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7237. * @param sega the first point of the segment to test the intersection against
  7238. * @param segb the second point of the segment to test the intersection against
  7239. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7240. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7241. */
  7242. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7243. /**
  7244. * Update the ray from viewport position
  7245. * @param x position
  7246. * @param y y position
  7247. * @param viewportWidth viewport width
  7248. * @param viewportHeight viewport height
  7249. * @param world world matrix
  7250. * @param view view matrix
  7251. * @param projection projection matrix
  7252. * @returns this ray updated
  7253. */
  7254. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7255. /**
  7256. * Creates a ray with origin and direction of 0,0,0
  7257. * @returns the new ray
  7258. */
  7259. static Zero(): Ray;
  7260. /**
  7261. * Creates a new ray from screen space and viewport
  7262. * @param x position
  7263. * @param y y position
  7264. * @param viewportWidth viewport width
  7265. * @param viewportHeight viewport height
  7266. * @param world world matrix
  7267. * @param view view matrix
  7268. * @param projection projection matrix
  7269. * @returns new ray
  7270. */
  7271. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7272. /**
  7273. * 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
  7274. * transformed to the given world matrix.
  7275. * @param origin The origin point
  7276. * @param end The end point
  7277. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7278. * @returns the new ray
  7279. */
  7280. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7281. /**
  7282. * Transforms a ray by a matrix
  7283. * @param ray ray to transform
  7284. * @param matrix matrix to apply
  7285. * @returns the resulting new ray
  7286. */
  7287. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7288. /**
  7289. * Transforms a ray by a matrix
  7290. * @param ray ray to transform
  7291. * @param matrix matrix to apply
  7292. * @param result ray to store result in
  7293. */
  7294. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7295. }
  7296. }
  7297. declare module BABYLON {
  7298. /**
  7299. * This represents an orbital type of camera.
  7300. *
  7301. * 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.
  7302. * 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.
  7303. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7304. */
  7305. class ArcRotateCamera extends TargetCamera {
  7306. /**
  7307. * Defines the rotation angle of the camera along the longitudinal axis.
  7308. */
  7309. alpha: number;
  7310. /**
  7311. * Defines the rotation angle of the camera along the latitudinal axis.
  7312. */
  7313. beta: number;
  7314. /**
  7315. * Defines the radius of the camera from it s target point.
  7316. */
  7317. radius: number;
  7318. protected _target: Vector3;
  7319. protected _targetHost: Nullable<AbstractMesh>;
  7320. /**
  7321. * Defines the target point of the camera.
  7322. * The camera looks towards it form the radius distance.
  7323. */
  7324. target: Vector3;
  7325. /**
  7326. * Current inertia value on the longitudinal axis.
  7327. * The bigger this number the longer it will take for the camera to stop.
  7328. */
  7329. inertialAlphaOffset: number;
  7330. /**
  7331. * Current inertia value on the latitudinal axis.
  7332. * The bigger this number the longer it will take for the camera to stop.
  7333. */
  7334. inertialBetaOffset: number;
  7335. /**
  7336. * Current inertia value on the radius axis.
  7337. * The bigger this number the longer it will take for the camera to stop.
  7338. */
  7339. inertialRadiusOffset: number;
  7340. /**
  7341. * Minimum allowed angle on the longitudinal axis.
  7342. * This can help limiting how the Camera is able to move in the scene.
  7343. */
  7344. lowerAlphaLimit: Nullable<number>;
  7345. /**
  7346. * Maximum allowed angle on the longitudinal axis.
  7347. * This can help limiting how the Camera is able to move in the scene.
  7348. */
  7349. upperAlphaLimit: Nullable<number>;
  7350. /**
  7351. * Minimum allowed angle on the latitudinal axis.
  7352. * This can help limiting how the Camera is able to move in the scene.
  7353. */
  7354. lowerBetaLimit: number;
  7355. /**
  7356. * Maximum allowed angle on the latitudinal axis.
  7357. * This can help limiting how the Camera is able to move in the scene.
  7358. */
  7359. upperBetaLimit: number;
  7360. /**
  7361. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7362. * This can help limiting how the Camera is able to move in the scene.
  7363. */
  7364. lowerRadiusLimit: Nullable<number>;
  7365. /**
  7366. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7367. * This can help limiting how the Camera is able to move in the scene.
  7368. */
  7369. upperRadiusLimit: Nullable<number>;
  7370. /**
  7371. * Defines the current inertia value used during panning of the camera along the X axis.
  7372. */
  7373. inertialPanningX: number;
  7374. /**
  7375. * Defines the current inertia value used during panning of the camera along the Y axis.
  7376. */
  7377. inertialPanningY: number;
  7378. /**
  7379. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7380. * Basically if your fingers moves away from more than this distance you will be considered
  7381. * in pinch mode.
  7382. */
  7383. pinchToPanMaxDistance: number;
  7384. /**
  7385. * Defines the maximum distance the camera can pan.
  7386. * This could help keeping the cammera always in your scene.
  7387. */
  7388. panningDistanceLimit: Nullable<number>;
  7389. /**
  7390. * Defines the target of the camera before paning.
  7391. */
  7392. panningOriginTarget: Vector3;
  7393. /**
  7394. * Defines the value of the inertia used during panning.
  7395. * 0 would mean stop inertia and one would mean no decelleration at all.
  7396. */
  7397. panningInertia: number;
  7398. /**
  7399. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7400. */
  7401. angularSensibilityX: number;
  7402. /**
  7403. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7404. */
  7405. angularSensibilityY: number;
  7406. /**
  7407. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7408. */
  7409. pinchPrecision: number;
  7410. /**
  7411. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7412. * It will be used instead of pinchDeltaPrecision if different from 0.
  7413. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7414. */
  7415. pinchDeltaPercentage: number;
  7416. /**
  7417. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7418. */
  7419. panningSensibility: number;
  7420. /**
  7421. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7422. */
  7423. keysUp: number[];
  7424. /**
  7425. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7426. */
  7427. keysDown: number[];
  7428. /**
  7429. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7430. */
  7431. keysLeft: number[];
  7432. /**
  7433. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7434. */
  7435. keysRight: number[];
  7436. /**
  7437. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7438. */
  7439. wheelPrecision: number;
  7440. /**
  7441. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7442. * It will be used instead of pinchDeltaPrecision if different from 0.
  7443. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7444. */
  7445. wheelDeltaPercentage: number;
  7446. /**
  7447. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7448. */
  7449. zoomOnFactor: number;
  7450. /**
  7451. * Defines a screen offset for the camera position.
  7452. */
  7453. targetScreenOffset: Vector2;
  7454. /**
  7455. * Allows the camera to be completely reversed.
  7456. * If false the camera can not arrive upside down.
  7457. */
  7458. allowUpsideDown: boolean;
  7459. /**
  7460. * Define if double tap/click is used to restore the previously saved state of the camera.
  7461. */
  7462. useInputToRestoreState: boolean;
  7463. /** @hidden */
  7464. _viewMatrix: Matrix;
  7465. /** @hidden */
  7466. _useCtrlForPanning: boolean;
  7467. /** @hidden */
  7468. _panningMouseButton: number;
  7469. /**
  7470. * Defines the inpute associated to the camera.
  7471. */
  7472. inputs: ArcRotateCameraInputsManager;
  7473. /** @hidden */
  7474. _reset: () => void;
  7475. /**
  7476. * Defines the allowed panning axis.
  7477. */
  7478. panningAxis: Vector3;
  7479. protected _localDirection: Vector3;
  7480. protected _transformedDirection: Vector3;
  7481. private _bouncingBehavior;
  7482. /**
  7483. * Gets the bouncing behavior of the camera if it has been enabled.
  7484. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7485. */
  7486. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7487. /**
  7488. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7489. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7490. */
  7491. useBouncingBehavior: boolean;
  7492. private _framingBehavior;
  7493. /**
  7494. * Gets the framing behavior of the camera if it has been enabled.
  7495. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7496. */
  7497. readonly framingBehavior: Nullable<FramingBehavior>;
  7498. /**
  7499. * Defines if the framing behavior of the camera is enabled on the camera.
  7500. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7501. */
  7502. useFramingBehavior: boolean;
  7503. private _autoRotationBehavior;
  7504. /**
  7505. * Gets the auto rotation behavior of the camera if it has been enabled.
  7506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7507. */
  7508. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7509. /**
  7510. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7512. */
  7513. useAutoRotationBehavior: boolean;
  7514. /**
  7515. * Observable triggered when the mesh target has been changed on the camera.
  7516. */
  7517. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7518. /**
  7519. * Event raised when the camera is colliding with a mesh.
  7520. */
  7521. onCollide: (collidedMesh: AbstractMesh) => void;
  7522. /**
  7523. * Defines whether the camera should check collision with the objects oh the scene.
  7524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7525. */
  7526. checkCollisions: boolean;
  7527. /**
  7528. * Defines the collision radius of the camera.
  7529. * This simulates a sphere around the camera.
  7530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7531. */
  7532. collisionRadius: Vector3;
  7533. protected _collider: Collider;
  7534. protected _previousPosition: Vector3;
  7535. protected _collisionVelocity: Vector3;
  7536. protected _newPosition: Vector3;
  7537. protected _previousAlpha: number;
  7538. protected _previousBeta: number;
  7539. protected _previousRadius: number;
  7540. protected _collisionTriggered: boolean;
  7541. protected _targetBoundingCenter: Nullable<Vector3>;
  7542. private _computationVector;
  7543. private _tempAxisVector;
  7544. private _tempAxisRotationMatrix;
  7545. /**
  7546. * Instantiates a new ArcRotateCamera in a given scene
  7547. * @param name Defines the name of the camera
  7548. * @param alpha Defines the camera rotation along the logitudinal axis
  7549. * @param beta Defines the camera rotation along the latitudinal axis
  7550. * @param radius Defines the camera distance from its target
  7551. * @param target Defines the camera target
  7552. * @param scene Defines the scene the camera belongs to
  7553. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7554. */
  7555. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7556. /** @hidden */
  7557. _initCache(): void;
  7558. /** @hidden */
  7559. _updateCache(ignoreParentClass?: boolean): void;
  7560. protected _getTargetPosition(): Vector3;
  7561. private _storedAlpha;
  7562. private _storedBeta;
  7563. private _storedRadius;
  7564. private _storedTarget;
  7565. /**
  7566. * Stores the current state of the camera (alpha, beta, radius and target)
  7567. * @returns the camera itself
  7568. */
  7569. storeState(): Camera;
  7570. /**
  7571. * @hidden
  7572. * Restored camera state. You must call storeState() first
  7573. */
  7574. _restoreStateValues(): boolean;
  7575. /** @hidden */
  7576. _isSynchronizedViewMatrix(): boolean;
  7577. /**
  7578. * Attached controls to the current camera.
  7579. * @param element Defines the element the controls should be listened from
  7580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7581. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7582. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7583. */
  7584. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7585. /**
  7586. * Detach the current controls from the camera.
  7587. * The camera will stop reacting to inputs.
  7588. * @param element Defines the element to stop listening the inputs from
  7589. */
  7590. detachControl(element: HTMLElement): void;
  7591. /** @hidden */
  7592. _checkInputs(): void;
  7593. protected _checkLimits(): void;
  7594. /**
  7595. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7596. */
  7597. rebuildAnglesAndRadius(): void;
  7598. /**
  7599. * Use a position to define the current camera related information like aplha, beta and radius
  7600. * @param position Defines the position to set the camera at
  7601. */
  7602. setPosition(position: Vector3): void;
  7603. /**
  7604. * Defines the target the camera should look at.
  7605. * This will automatically adapt alpha beta and radius to fit within the new target.
  7606. * @param target Defines the new target as a Vector or a mesh
  7607. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7608. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7609. */
  7610. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7611. /** @hidden */
  7612. _getViewMatrix(): Matrix;
  7613. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7614. /**
  7615. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7616. * @param meshes Defines the mesh to zoom on
  7617. * @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)
  7618. */
  7619. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7620. /**
  7621. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7622. * The target will be changed but the radius
  7623. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7624. * @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)
  7625. */
  7626. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7627. min: Vector3;
  7628. max: Vector3;
  7629. distance: number;
  7630. }, doNotUpdateMaxZ?: boolean): void;
  7631. /**
  7632. * @override
  7633. * Override Camera.createRigCamera
  7634. */
  7635. createRigCamera(name: string, cameraIndex: number): Camera;
  7636. /**
  7637. * @hidden
  7638. * @override
  7639. * Override Camera._updateRigCameras
  7640. */
  7641. _updateRigCameras(): void;
  7642. /**
  7643. * Destroy the camera and release the current resources hold by it.
  7644. */
  7645. dispose(): void;
  7646. /**
  7647. * Gets the current object class name.
  7648. * @return the class name
  7649. */
  7650. getClassName(): string;
  7651. }
  7652. }
  7653. declare module BABYLON {
  7654. /**
  7655. * Default Inputs manager for the ArcRotateCamera.
  7656. * It groups all the default supported inputs for ease of use.
  7657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7658. */
  7659. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7660. /**
  7661. * Instantiates a new ArcRotateCameraInputsManager.
  7662. * @param camera Defines the camera the inputs belong to
  7663. */
  7664. constructor(camera: ArcRotateCamera);
  7665. /**
  7666. * Add mouse wheel input support to the input manager.
  7667. * @returns the current input manager
  7668. */
  7669. addMouseWheel(): ArcRotateCameraInputsManager;
  7670. /**
  7671. * Add pointers input support to the input manager.
  7672. * @returns the current input manager
  7673. */
  7674. addPointers(): ArcRotateCameraInputsManager;
  7675. /**
  7676. * Add keyboard input support to the input manager.
  7677. * @returns the current input manager
  7678. */
  7679. addKeyboard(): ArcRotateCameraInputsManager;
  7680. /**
  7681. * Add orientation input support to the input manager.
  7682. * @returns the current input manager
  7683. */
  7684. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7685. }
  7686. }
  7687. declare module BABYLON {
  7688. /**
  7689. * This is the base class of all the camera used in the application.
  7690. * @see http://doc.babylonjs.com/features/cameras
  7691. */
  7692. class Camera extends Node {
  7693. /**
  7694. * This is the default projection mode used by the cameras.
  7695. * It helps recreating a feeling of perspective and better appreciate depth.
  7696. * This is the best way to simulate real life cameras.
  7697. */
  7698. static readonly PERSPECTIVE_CAMERA: number;
  7699. /**
  7700. * This helps creating camera with an orthographic mode.
  7701. * 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.
  7702. */
  7703. static readonly ORTHOGRAPHIC_CAMERA: number;
  7704. /**
  7705. * This is the default FOV mode for perspective cameras.
  7706. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7707. */
  7708. static readonly FOVMODE_VERTICAL_FIXED: number;
  7709. /**
  7710. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7711. */
  7712. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7713. /**
  7714. * This specifies ther is no need for a camera rig.
  7715. * Basically only one eye is rendered corresponding to the camera.
  7716. */
  7717. static readonly RIG_MODE_NONE: number;
  7718. /**
  7719. * Simulates a camera Rig with one blue eye and one red eye.
  7720. * This can be use with 3d blue and red glasses.
  7721. */
  7722. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7723. /**
  7724. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7725. */
  7726. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7727. /**
  7728. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7729. */
  7730. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7731. /**
  7732. * Defines that both eyes of the camera will be rendered over under each other.
  7733. */
  7734. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7735. /**
  7736. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7737. */
  7738. static readonly RIG_MODE_VR: number;
  7739. /**
  7740. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7741. */
  7742. static readonly RIG_MODE_WEBVR: number;
  7743. /**
  7744. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7745. */
  7746. static readonly RIG_MODE_CUSTOM: number;
  7747. /**
  7748. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7749. */
  7750. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7751. /**
  7752. * @hidden
  7753. * Might be removed once multiview will be a thing
  7754. */
  7755. static UseAlternateWebVRRendering: boolean;
  7756. /**
  7757. * Define the input manager associated with the camera.
  7758. */
  7759. inputs: CameraInputsManager<Camera>;
  7760. /**
  7761. * Define the current local position of the camera in the scene
  7762. */
  7763. position: Vector3;
  7764. /**
  7765. * The vector the camera should consider as up.
  7766. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7767. */
  7768. upVector: Vector3;
  7769. /**
  7770. * Define the current limit on the left side for an orthographic camera
  7771. * In scene unit
  7772. */
  7773. orthoLeft: Nullable<number>;
  7774. /**
  7775. * Define the current limit on the right side for an orthographic camera
  7776. * In scene unit
  7777. */
  7778. orthoRight: Nullable<number>;
  7779. /**
  7780. * Define the current limit on the bottom side for an orthographic camera
  7781. * In scene unit
  7782. */
  7783. orthoBottom: Nullable<number>;
  7784. /**
  7785. * Define the current limit on the top side for an orthographic camera
  7786. * In scene unit
  7787. */
  7788. orthoTop: Nullable<number>;
  7789. /**
  7790. * Field Of View is set in Radians. (default is 0.8)
  7791. */
  7792. fov: number;
  7793. /**
  7794. * Define the minimum distance the camera can see from.
  7795. * This is important to note that the depth buffer are not infinite and the closer it starts
  7796. * the more your scene might encounter depth fighting issue.
  7797. */
  7798. minZ: number;
  7799. /**
  7800. * Define the maximum distance the camera can see to.
  7801. * This is important to note that the depth buffer are not infinite and the further it end
  7802. * the more your scene might encounter depth fighting issue.
  7803. */
  7804. maxZ: number;
  7805. /**
  7806. * Define the default inertia of the camera.
  7807. * This helps giving a smooth feeling to the camera movement.
  7808. */
  7809. inertia: number;
  7810. /**
  7811. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7812. */
  7813. mode: number;
  7814. /**
  7815. * Define wether the camera is intermediate.
  7816. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7817. */
  7818. isIntermediate: boolean;
  7819. /**
  7820. * Define the viewport of the camera.
  7821. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7822. */
  7823. viewport: Viewport;
  7824. /**
  7825. * Restricts the camera to viewing objects with the same layerMask.
  7826. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7827. */
  7828. layerMask: number;
  7829. /**
  7830. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7831. */
  7832. fovMode: number;
  7833. /**
  7834. * Rig mode of the camera.
  7835. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7836. * This is normally controlled byt the camera themselves as internal use.
  7837. */
  7838. cameraRigMode: number;
  7839. /**
  7840. * Defines the distance between both "eyes" in case of a RIG
  7841. */
  7842. interaxialDistance: number;
  7843. /**
  7844. * Defines if stereoscopic rendering is done side by side or over under.
  7845. */
  7846. isStereoscopicSideBySide: boolean;
  7847. /**
  7848. * 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
  7849. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7850. * else in the scene.
  7851. */
  7852. customRenderTargets: RenderTargetTexture[];
  7853. /**
  7854. * When set, the camera will render to this render target instead of the default canvas
  7855. */
  7856. outputRenderTarget: Nullable<RenderTargetTexture>;
  7857. /**
  7858. * Observable triggered when the camera view matrix has changed.
  7859. */
  7860. onViewMatrixChangedObservable: Observable<Camera>;
  7861. /**
  7862. * Observable triggered when the camera Projection matrix has changed.
  7863. */
  7864. onProjectionMatrixChangedObservable: Observable<Camera>;
  7865. /**
  7866. * Observable triggered when the inputs have been processed.
  7867. */
  7868. onAfterCheckInputsObservable: Observable<Camera>;
  7869. /**
  7870. * Observable triggered when reset has been called and applied to the camera.
  7871. */
  7872. onRestoreStateObservable: Observable<Camera>;
  7873. /** @hidden */
  7874. _cameraRigParams: any;
  7875. /** @hidden */
  7876. _rigCameras: Camera[];
  7877. /** @hidden */
  7878. _rigPostProcess: Nullable<PostProcess>;
  7879. protected _webvrViewMatrix: Matrix;
  7880. /** @hidden */
  7881. _skipRendering: boolean;
  7882. /** @hidden */
  7883. _alternateCamera: Camera;
  7884. /** @hidden */
  7885. _projectionMatrix: Matrix;
  7886. /** @hidden */
  7887. _postProcesses: Nullable<PostProcess>[];
  7888. /** @hidden */
  7889. _activeMeshes: SmartArray<AbstractMesh>;
  7890. protected _globalPosition: Vector3;
  7891. /** hidden */
  7892. _computedViewMatrix: Matrix;
  7893. private _doNotComputeProjectionMatrix;
  7894. private _transformMatrix;
  7895. private _frustumPlanes;
  7896. private _refreshFrustumPlanes;
  7897. private _storedFov;
  7898. private _stateStored;
  7899. /**
  7900. * Instantiates a new camera object.
  7901. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7902. * @see http://doc.babylonjs.com/features/cameras
  7903. * @param name Defines the name of the camera in the scene
  7904. * @param position Defines the position of the camera
  7905. * @param scene Defines the scene the camera belongs too
  7906. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7907. */
  7908. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7909. /**
  7910. * Store current camera state (fov, position, etc..)
  7911. * @returns the camera
  7912. */
  7913. storeState(): Camera;
  7914. /**
  7915. * Restores the camera state values if it has been stored. You must call storeState() first
  7916. */
  7917. protected _restoreStateValues(): boolean;
  7918. /**
  7919. * Restored camera state. You must call storeState() first.
  7920. * @returns true if restored and false otherwise
  7921. */
  7922. restoreState(): boolean;
  7923. /**
  7924. * Gets the class name of the camera.
  7925. * @returns the class name
  7926. */
  7927. getClassName(): string;
  7928. /**
  7929. * Gets a string representation of the camera useful for debug purpose.
  7930. * @param fullDetails Defines that a more verboe level of logging is required
  7931. * @returns the string representation
  7932. */
  7933. toString(fullDetails?: boolean): string;
  7934. /**
  7935. * Gets the current world space position of the camera.
  7936. */
  7937. readonly globalPosition: Vector3;
  7938. /**
  7939. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7940. * @returns the active meshe list
  7941. */
  7942. getActiveMeshes(): SmartArray<AbstractMesh>;
  7943. /**
  7944. * Check wether a mesh is part of the current active mesh list of the camera
  7945. * @param mesh Defines the mesh to check
  7946. * @returns true if active, false otherwise
  7947. */
  7948. isActiveMesh(mesh: Mesh): boolean;
  7949. /**
  7950. * Is this camera ready to be used/rendered
  7951. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7952. * @return true if the camera is ready
  7953. */
  7954. isReady(completeCheck?: boolean): boolean;
  7955. /** @hidden */
  7956. _initCache(): void;
  7957. /** @hidden */
  7958. _updateCache(ignoreParentClass?: boolean): void;
  7959. /** @hidden */
  7960. _isSynchronized(): boolean;
  7961. /** @hidden */
  7962. _isSynchronizedViewMatrix(): boolean;
  7963. /** @hidden */
  7964. _isSynchronizedProjectionMatrix(): boolean;
  7965. /**
  7966. * Attach the input controls to a specific dom element to get the input from.
  7967. * @param element Defines the element the controls should be listened from
  7968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7969. */
  7970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7971. /**
  7972. * Detach the current controls from the specified dom element.
  7973. * @param element Defines the element to stop listening the inputs from
  7974. */
  7975. detachControl(element: HTMLElement): void;
  7976. /**
  7977. * Update the camera state according to the different inputs gathered during the frame.
  7978. */
  7979. update(): void;
  7980. /** @hidden */
  7981. _checkInputs(): void;
  7982. /** @hidden */
  7983. readonly rigCameras: Camera[];
  7984. /**
  7985. * Gets the post process used by the rig cameras
  7986. */
  7987. readonly rigPostProcess: Nullable<PostProcess>;
  7988. /**
  7989. * Internal, gets the first post proces.
  7990. * @returns the first post process to be run on this camera.
  7991. */
  7992. _getFirstPostProcess(): Nullable<PostProcess>;
  7993. private _cascadePostProcessesToRigCams;
  7994. /**
  7995. * Attach a post process to the camera.
  7996. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7997. * @param postProcess The post process to attach to the camera
  7998. * @param insertAt The position of the post process in case several of them are in use in the scene
  7999. * @returns the position the post process has been inserted at
  8000. */
  8001. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8002. /**
  8003. * Detach a post process to the camera.
  8004. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8005. * @param postProcess The post process to detach from the camera
  8006. */
  8007. detachPostProcess(postProcess: PostProcess): void;
  8008. /**
  8009. * Gets the current world matrix of the camera
  8010. */
  8011. getWorldMatrix(): Matrix;
  8012. /** @hidden */
  8013. protected _getViewMatrix(): Matrix;
  8014. /**
  8015. * Gets the current view matrix of the camera.
  8016. * @param force forces the camera to recompute the matrix without looking at the cached state
  8017. * @returns the view matrix
  8018. */
  8019. getViewMatrix(force?: boolean): Matrix;
  8020. /**
  8021. * Freeze the projection matrix.
  8022. * It will prevent the cache check of the camera projection compute and can speed up perf
  8023. * if no parameter of the camera are meant to change
  8024. * @param projection Defines manually a projection if necessary
  8025. */
  8026. freezeProjectionMatrix(projection?: Matrix): void;
  8027. /**
  8028. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8029. */
  8030. unfreezeProjectionMatrix(): void;
  8031. /**
  8032. * Gets the current projection matrix of the camera.
  8033. * @param force forces the camera to recompute the matrix without looking at the cached state
  8034. * @returns the projection matrix
  8035. */
  8036. getProjectionMatrix(force?: boolean): Matrix;
  8037. /**
  8038. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8039. * @returns a Matrix
  8040. */
  8041. getTransformationMatrix(): Matrix;
  8042. private _updateFrustumPlanes;
  8043. /**
  8044. * Checks if a cullable object (mesh...) is in the camera frustum
  8045. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8046. * @param target The object to check
  8047. * @returns true if the object is in frustum otherwise false
  8048. */
  8049. isInFrustum(target: ICullable): boolean;
  8050. /**
  8051. * Checks if a cullable object (mesh...) is in the camera frustum
  8052. * Unlike isInFrustum this cheks the full bounding box
  8053. * @param target The object to check
  8054. * @returns true if the object is in frustum otherwise false
  8055. */
  8056. isCompletelyInFrustum(target: ICullable): boolean;
  8057. /**
  8058. * Gets a ray in the forward direction from the camera.
  8059. * @param length Defines the length of the ray to create
  8060. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8061. * @param origin Defines the start point of the ray which defaults to the camera position
  8062. * @returns the forward ray
  8063. */
  8064. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8065. /**
  8066. * Releases resources associated with this node.
  8067. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8068. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8069. */
  8070. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8071. /**
  8072. * Gets the left camera of a rig setup in case of Rigged Camera
  8073. */
  8074. readonly leftCamera: Nullable<FreeCamera>;
  8075. /**
  8076. * Gets the right camera of a rig setup in case of Rigged Camera
  8077. */
  8078. readonly rightCamera: Nullable<FreeCamera>;
  8079. /**
  8080. * Gets the left camera target of a rig setup in case of Rigged Camera
  8081. * @returns the target position
  8082. */
  8083. getLeftTarget(): Nullable<Vector3>;
  8084. /**
  8085. * Gets the right camera target of a rig setup in case of Rigged Camera
  8086. * @returns the target position
  8087. */
  8088. getRightTarget(): Nullable<Vector3>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. setCameraRigMode(mode: number, rigParams: any): void;
  8093. private _getVRProjectionMatrix;
  8094. protected _updateCameraRotationMatrix(): void;
  8095. protected _updateWebVRCameraRotationMatrix(): void;
  8096. /**
  8097. * This function MUST be overwritten by the different WebVR cameras available.
  8098. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8099. */
  8100. protected _getWebVRProjectionMatrix(): Matrix;
  8101. /**
  8102. * This function MUST be overwritten by the different WebVR cameras available.
  8103. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8104. */
  8105. protected _getWebVRViewMatrix(): Matrix;
  8106. /** @hidden */
  8107. setCameraRigParameter(name: string, value: any): void;
  8108. /**
  8109. * needs to be overridden by children so sub has required properties to be copied
  8110. * @hidden
  8111. */
  8112. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8113. /**
  8114. * May need to be overridden by children
  8115. * @hidden
  8116. */
  8117. _updateRigCameras(): void;
  8118. /** @hidden */
  8119. _setupInputs(): void;
  8120. /**
  8121. * Serialiaze the camera setup to a json represention
  8122. * @returns the JSON representation
  8123. */
  8124. serialize(): any;
  8125. /**
  8126. * Clones the current camera.
  8127. * @param name The cloned camera name
  8128. * @returns the cloned camera
  8129. */
  8130. clone(name: string): Camera;
  8131. /**
  8132. * Gets the direction of the camera relative to a given local axis.
  8133. * @param localAxis Defines the reference axis to provide a relative direction.
  8134. * @return the direction
  8135. */
  8136. getDirection(localAxis: Vector3): Vector3;
  8137. /**
  8138. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8139. * @param localAxis Defines the reference axis to provide a relative direction.
  8140. * @param result Defines the vector to store the result in
  8141. */
  8142. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8143. /**
  8144. * Gets a camera constructor for a given camera type
  8145. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8146. * @param name The name of the camera the result will be able to instantiate
  8147. * @param scene The scene the result will construct the camera in
  8148. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8149. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8150. * @returns a factory method to construc the camera
  8151. */
  8152. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8153. /**
  8154. * Compute the world matrix of the camera.
  8155. * @returns the camera workd matrix
  8156. */
  8157. computeWorldMatrix(): Matrix;
  8158. /**
  8159. * Parse a JSON and creates the camera from the parsed information
  8160. * @param parsedCamera The JSON to parse
  8161. * @param scene The scene to instantiate the camera in
  8162. * @returns the newly constructed camera
  8163. */
  8164. static Parse(parsedCamera: any, scene: Scene): Camera;
  8165. }
  8166. }
  8167. declare module BABYLON {
  8168. /**
  8169. * @ignore
  8170. * This is a list of all the different input types that are available in the application.
  8171. * Fo instance: ArcRotateCameraGamepadInput...
  8172. */
  8173. var CameraInputTypes: {};
  8174. /**
  8175. * This is the contract to implement in order to create a new input class.
  8176. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8177. */
  8178. interface ICameraInput<TCamera extends Camera> {
  8179. /**
  8180. * Defines the camera the input is attached to.
  8181. */
  8182. camera: Nullable<TCamera>;
  8183. /**
  8184. * Gets the class name of the current intput.
  8185. * @returns the class name
  8186. */
  8187. getClassName(): string;
  8188. /**
  8189. * Get the friendly name associated with the input class.
  8190. * @returns the input friendly name
  8191. */
  8192. getSimpleName(): string;
  8193. /**
  8194. * Attach the input controls to a specific dom element to get the input from.
  8195. * @param element Defines the element the controls should be listened from
  8196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8197. */
  8198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8199. /**
  8200. * Detach the current controls from the specified dom element.
  8201. * @param element Defines the element to stop listening the inputs from
  8202. */
  8203. detachControl(element: Nullable<HTMLElement>): void;
  8204. /**
  8205. * Update the current camera state depending on the inputs that have been used this frame.
  8206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8207. */
  8208. checkInputs?: () => void;
  8209. }
  8210. /**
  8211. * Represents a map of input types to input instance or input index to input instance.
  8212. */
  8213. interface CameraInputsMap<TCamera extends Camera> {
  8214. /**
  8215. * Accessor to the input by input type.
  8216. */
  8217. [name: string]: ICameraInput<TCamera>;
  8218. /**
  8219. * Accessor to the input by input index.
  8220. */
  8221. [idx: number]: ICameraInput<TCamera>;
  8222. }
  8223. /**
  8224. * This represents the input manager used within a camera.
  8225. * It helps dealing with all the different kind of input attached to a camera.
  8226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8227. */
  8228. class CameraInputsManager<TCamera extends Camera> {
  8229. /**
  8230. * Defines the list of inputs attahed to the camera.
  8231. */
  8232. attached: CameraInputsMap<TCamera>;
  8233. /**
  8234. * Defines the dom element the camera is collecting inputs from.
  8235. * This is null if the controls have not been attached.
  8236. */
  8237. attachedElement: Nullable<HTMLElement>;
  8238. /**
  8239. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8240. */
  8241. noPreventDefault: boolean;
  8242. /**
  8243. * Defined the camera the input manager belongs to.
  8244. */
  8245. camera: TCamera;
  8246. /**
  8247. * Update the current camera state depending on the inputs that have been used this frame.
  8248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8249. */
  8250. checkInputs: () => void;
  8251. /**
  8252. * Instantiate a new Camera Input Manager.
  8253. * @param camera Defines the camera the input manager blongs to
  8254. */
  8255. constructor(camera: TCamera);
  8256. /**
  8257. * Add an input method to a camera
  8258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8259. * @param input camera input method
  8260. */
  8261. add(input: ICameraInput<TCamera>): void;
  8262. /**
  8263. * Remove a specific input method from a camera
  8264. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8265. * @param inputToRemove camera input method
  8266. */
  8267. remove(inputToRemove: ICameraInput<TCamera>): void;
  8268. /**
  8269. * Remove a specific input type from a camera
  8270. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8271. * @param inputType the type of the input to remove
  8272. */
  8273. removeByType(inputType: string): void;
  8274. private _addCheckInputs;
  8275. /**
  8276. * Attach the input controls to the currently attached dom element to listen the events from.
  8277. * @param input Defines the input to attach
  8278. */
  8279. attachInput(input: ICameraInput<TCamera>): void;
  8280. /**
  8281. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8282. * @param element Defines the dom element to collect the events from
  8283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8284. */
  8285. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8286. /**
  8287. * Detach the current manager inputs controls from a specific dom element.
  8288. * @param element Defines the dom element to collect the events from
  8289. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8290. */
  8291. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8292. /**
  8293. * Rebuild the dynamic inputCheck function from the current list of
  8294. * defined inputs in the manager.
  8295. */
  8296. rebuildInputCheck(): void;
  8297. /**
  8298. * Remove all attached input methods from a camera
  8299. */
  8300. clear(): void;
  8301. /**
  8302. * Serialize the current input manager attached to a camera.
  8303. * This ensures than once parsed,
  8304. * the input associated to the camera will be identical to the current ones
  8305. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8306. */
  8307. serialize(serializedCamera: any): void;
  8308. /**
  8309. * Parses an input manager serialized JSON to restore the previous list of inputs
  8310. * and states associated to a camera.
  8311. * @param parsedCamera Defines the JSON to parse
  8312. */
  8313. parse(parsedCamera: any): void;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8319. * being tilted forward or back and left or right.
  8320. */
  8321. class DeviceOrientationCamera extends FreeCamera {
  8322. private _initialQuaternion;
  8323. private _quaternionCache;
  8324. /**
  8325. * Creates a new device orientation camera
  8326. * @param name The name of the camera
  8327. * @param position The start position camera
  8328. * @param scene The scene the camera belongs to
  8329. */
  8330. constructor(name: string, position: Vector3, scene: Scene);
  8331. /**
  8332. * Gets the current instance class name ("DeviceOrientationCamera").
  8333. * This helps avoiding instanceof at run time.
  8334. * @returns the class name
  8335. */
  8336. getClassName(): string;
  8337. /**
  8338. * @hidden
  8339. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8340. */
  8341. _checkInputs(): void;
  8342. /**
  8343. * Reset the camera to its default orientation on the specified axis only.
  8344. * @param axis The axis to reset
  8345. */
  8346. resetToCurrentRotation(axis?: Axis): void;
  8347. }
  8348. }
  8349. declare module BABYLON {
  8350. /**
  8351. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8352. * such as in a 3D Space Shooter or a Flight Simulator.
  8353. */
  8354. class FlyCamera extends TargetCamera {
  8355. /**
  8356. * Define the collision ellipsoid of the camera.
  8357. * This is helpful for simulating a camera body, like a player's body.
  8358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8359. */
  8360. ellipsoid: Vector3;
  8361. /**
  8362. * Define an offset for the position of the ellipsoid around the camera.
  8363. * This can be helpful if the camera is attached away from the player's body center,
  8364. * such as at its head.
  8365. */
  8366. ellipsoidOffset: Vector3;
  8367. /**
  8368. * Enable or disable collisions of the camera with the rest of the scene objects.
  8369. */
  8370. checkCollisions: boolean;
  8371. /**
  8372. * Enable or disable gravity on the camera.
  8373. */
  8374. applyGravity: boolean;
  8375. /**
  8376. * Define the current direction the camera is moving to.
  8377. */
  8378. cameraDirection: Vector3;
  8379. /**
  8380. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8381. * This overrides and empties cameraRotation.
  8382. */
  8383. rotationQuaternion: BABYLON.Quaternion;
  8384. /**
  8385. * Track Roll to maintain the wanted Rolling when looking around.
  8386. */
  8387. _trackRoll: number;
  8388. /**
  8389. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8390. */
  8391. rollCorrect: number;
  8392. /**
  8393. * Mimic a banked turn, Rolling the camera when Yawing.
  8394. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8395. */
  8396. bankedTurn: boolean;
  8397. /**
  8398. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8399. */
  8400. bankedTurnLimit: number;
  8401. /**
  8402. * Value of 0 disables the banked Roll.
  8403. * Value of 1 is equal to the Yaw angle in radians.
  8404. */
  8405. bankedTurnMultiplier: number;
  8406. /**
  8407. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8408. */
  8409. inputs: FlyCameraInputsManager;
  8410. /**
  8411. * Gets the input sensibility for mouse input.
  8412. * Higher values reduce sensitivity.
  8413. */
  8414. /**
  8415. * Sets the input sensibility for a mouse input.
  8416. * Higher values reduce sensitivity.
  8417. */
  8418. angularSensibility: number;
  8419. /**
  8420. * Get the keys for camera movement forward.
  8421. */
  8422. /**
  8423. * Set the keys for camera movement forward.
  8424. */
  8425. keysForward: number[];
  8426. /**
  8427. * Get the keys for camera movement backward.
  8428. */
  8429. keysBackward: number[];
  8430. /**
  8431. * Get the keys for camera movement up.
  8432. */
  8433. /**
  8434. * Set the keys for camera movement up.
  8435. */
  8436. keysUp: number[];
  8437. /**
  8438. * Get the keys for camera movement down.
  8439. */
  8440. /**
  8441. * Set the keys for camera movement down.
  8442. */
  8443. keysDown: number[];
  8444. /**
  8445. * Get the keys for camera movement left.
  8446. */
  8447. /**
  8448. * Set the keys for camera movement left.
  8449. */
  8450. keysLeft: number[];
  8451. /**
  8452. * Set the keys for camera movement right.
  8453. */
  8454. /**
  8455. * Set the keys for camera movement right.
  8456. */
  8457. keysRight: number[];
  8458. /**
  8459. * Event raised when the camera collides with a mesh in the scene.
  8460. */
  8461. onCollide: (collidedMesh: AbstractMesh) => void;
  8462. private _collider;
  8463. private _needMoveForGravity;
  8464. private _oldPosition;
  8465. private _diffPosition;
  8466. private _newPosition;
  8467. /** @hidden */
  8468. _localDirection: Vector3;
  8469. /** @hidden */
  8470. _transformedDirection: Vector3;
  8471. /**
  8472. * Instantiates a FlyCamera.
  8473. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8474. * such as in a 3D Space Shooter or a Flight Simulator.
  8475. * @param name Define the name of the camera in the scene.
  8476. * @param position Define the starting position of the camera in the scene.
  8477. * @param scene Define the scene the camera belongs to.
  8478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8479. */
  8480. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8481. /**
  8482. * Attach a control to the HTML DOM element.
  8483. * @param element Defines the element that listens to the input events.
  8484. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8485. */
  8486. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8487. /**
  8488. * Detach a control from the HTML DOM element.
  8489. * The camera will stop reacting to that input.
  8490. * @param element Defines the element that listens to the input events.
  8491. */
  8492. detachControl(element: HTMLElement): void;
  8493. private _collisionMask;
  8494. /**
  8495. * Get the mask that the camera ignores in collision events.
  8496. */
  8497. /**
  8498. * Set the mask that the camera ignores in collision events.
  8499. */
  8500. collisionMask: number;
  8501. /** @hidden */
  8502. _collideWithWorld(displacement: Vector3): void;
  8503. /** @hidden */
  8504. private _onCollisionPositionChange;
  8505. /** @hidden */
  8506. _checkInputs(): void;
  8507. /** @hidden */
  8508. _decideIfNeedsToMove(): boolean;
  8509. /** @hidden */
  8510. _updatePosition(): void;
  8511. /**
  8512. * Restore the Roll to its target value at the rate specified.
  8513. * @param rate - Higher means slower restoring.
  8514. * @hidden
  8515. */
  8516. restoreRoll(rate: number): void;
  8517. /**
  8518. * Destroy the camera and release the current resources held by it.
  8519. */
  8520. dispose(): void;
  8521. /**
  8522. * Get the current object class name.
  8523. * @returns the class name.
  8524. */
  8525. getClassName(): string;
  8526. }
  8527. }
  8528. declare module BABYLON {
  8529. /**
  8530. * Default Inputs manager for the FlyCamera.
  8531. * It groups all the default supported inputs for ease of use.
  8532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8533. */
  8534. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8535. /**
  8536. * Instantiates a new FlyCameraInputsManager.
  8537. * @param camera Defines the camera the inputs belong to.
  8538. */
  8539. constructor(camera: FlyCamera);
  8540. /**
  8541. * Add keyboard input support to the input manager.
  8542. * @returns the new FlyCameraKeyboardMoveInput().
  8543. */
  8544. addKeyboard(): FlyCameraInputsManager;
  8545. /**
  8546. * Add mouse input support to the input manager.
  8547. * @param touchEnabled Enable touch screen support.
  8548. * @returns the new FlyCameraMouseInput().
  8549. */
  8550. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8551. }
  8552. }
  8553. declare module BABYLON {
  8554. /**
  8555. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8556. * an arc rotate version arcFollowCamera are available.
  8557. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8558. */
  8559. class FollowCamera extends TargetCamera {
  8560. /**
  8561. * Distance the follow camera should follow an object at
  8562. */
  8563. radius: number;
  8564. /**
  8565. * Define a rotation offset between the camera and the object it follows
  8566. */
  8567. rotationOffset: number;
  8568. /**
  8569. * Define a height offset between the camera and the object it follows.
  8570. * It can help following an object from the top (like a car chaing a plane)
  8571. */
  8572. heightOffset: number;
  8573. /**
  8574. * Define how fast the camera can accelerate to follow it s target.
  8575. */
  8576. cameraAcceleration: number;
  8577. /**
  8578. * Define the speed limit of the camera following an object.
  8579. */
  8580. maxCameraSpeed: number;
  8581. /**
  8582. * Define the target of the camera.
  8583. */
  8584. lockedTarget: Nullable<AbstractMesh>;
  8585. /**
  8586. * Instantiates the follow camera.
  8587. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8588. * @param name Define the name of the camera in the scene
  8589. * @param position Define the position of the camera
  8590. * @param scene Define the scene the camera belong to
  8591. * @param lockedTarget Define the target of the camera
  8592. */
  8593. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8594. private _follow;
  8595. /** @hidden */
  8596. _checkInputs(): void;
  8597. /**
  8598. * Gets the camera class name.
  8599. * @returns the class name
  8600. */
  8601. getClassName(): string;
  8602. }
  8603. /**
  8604. * Arc Rotate version of the follow camera.
  8605. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8606. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8607. */
  8608. class ArcFollowCamera extends TargetCamera {
  8609. /** The longitudinal angle of the camera */
  8610. alpha: number;
  8611. /** The latitudinal angle of the camera */
  8612. beta: number;
  8613. /** The radius of the camera from its target */
  8614. radius: number;
  8615. /** Define the camera target (the messh it should follow) */
  8616. target: Nullable<AbstractMesh>;
  8617. private _cartesianCoordinates;
  8618. /**
  8619. * Instantiates a new ArcFollowCamera
  8620. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8621. * @param name Define the name of the camera
  8622. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8623. * @param beta Define the rotation angle of the camera around the elevation axis
  8624. * @param radius Define the radius of the camera from its target point
  8625. * @param target Define the target of the camera
  8626. * @param scene Define the scene the camera belongs to
  8627. */
  8628. constructor(name: string,
  8629. /** The longitudinal angle of the camera */
  8630. alpha: number,
  8631. /** The latitudinal angle of the camera */
  8632. beta: number,
  8633. /** The radius of the camera from its target */
  8634. radius: number,
  8635. /** Define the camera target (the messh it should follow) */
  8636. target: Nullable<AbstractMesh>, scene: Scene);
  8637. private _follow;
  8638. /** @hidden */
  8639. _checkInputs(): void;
  8640. /**
  8641. * Returns the class name of the object.
  8642. * It is mostly used internally for serialization purposes.
  8643. */
  8644. getClassName(): string;
  8645. }
  8646. }
  8647. declare module BABYLON {
  8648. /**
  8649. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8650. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8652. */
  8653. class FreeCamera extends TargetCamera {
  8654. /**
  8655. * Define the collision ellipsoid of the camera.
  8656. * This is helpful to simulate a camera body like the player body around the camera
  8657. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8658. */
  8659. ellipsoid: Vector3;
  8660. /**
  8661. * Define an offset for the position of the ellipsoid around the camera.
  8662. * This can be helpful to determine the center of the body near the gravity center of the body
  8663. * instead of its head.
  8664. */
  8665. ellipsoidOffset: Vector3;
  8666. /**
  8667. * Enable or disable collisions of the camera with the rest of the scene objects.
  8668. */
  8669. checkCollisions: boolean;
  8670. /**
  8671. * Enable or disable gravity on the camera.
  8672. */
  8673. applyGravity: boolean;
  8674. /**
  8675. * Define the input manager associated to the camera.
  8676. */
  8677. inputs: FreeCameraInputsManager;
  8678. /**
  8679. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8680. * Higher values reduce sensitivity.
  8681. */
  8682. /**
  8683. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8684. * Higher values reduce sensitivity.
  8685. */
  8686. angularSensibility: number;
  8687. /**
  8688. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8689. */
  8690. keysUp: number[];
  8691. /**
  8692. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8693. */
  8694. keysDown: number[];
  8695. /**
  8696. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8697. */
  8698. keysLeft: number[];
  8699. /**
  8700. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8701. */
  8702. keysRight: number[];
  8703. /**
  8704. * Event raised when the camera collide with a mesh in the scene.
  8705. */
  8706. onCollide: (collidedMesh: AbstractMesh) => void;
  8707. private _collider;
  8708. private _needMoveForGravity;
  8709. private _oldPosition;
  8710. private _diffPosition;
  8711. private _newPosition;
  8712. /** @hidden */
  8713. _localDirection: Vector3;
  8714. /** @hidden */
  8715. _transformedDirection: Vector3;
  8716. /**
  8717. * Instantiates a Free Camera.
  8718. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8719. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8720. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8721. * @param name Define the name of the camera in the scene
  8722. * @param position Define the start position of the camera in the scene
  8723. * @param scene Define the scene the camera belongs to
  8724. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8725. */
  8726. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8727. /**
  8728. * Attached controls to the current camera.
  8729. * @param element Defines the element the controls should be listened from
  8730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8731. */
  8732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8733. /**
  8734. * Detach the current controls from the camera.
  8735. * The camera will stop reacting to inputs.
  8736. * @param element Defines the element to stop listening the inputs from
  8737. */
  8738. detachControl(element: HTMLElement): void;
  8739. private _collisionMask;
  8740. /**
  8741. * Define a collision mask to limit the list of object the camera can collide with
  8742. */
  8743. collisionMask: number;
  8744. /** @hidden */
  8745. _collideWithWorld(displacement: Vector3): void;
  8746. private _onCollisionPositionChange;
  8747. /** @hidden */
  8748. _checkInputs(): void;
  8749. /** @hidden */
  8750. _decideIfNeedsToMove(): boolean;
  8751. /** @hidden */
  8752. _updatePosition(): void;
  8753. /**
  8754. * Destroy the camera and release the current resources hold by it.
  8755. */
  8756. dispose(): void;
  8757. /**
  8758. * Gets the current object class name.
  8759. * @return the class name
  8760. */
  8761. getClassName(): string;
  8762. }
  8763. }
  8764. declare module BABYLON {
  8765. /**
  8766. * Default Inputs manager for the FreeCamera.
  8767. * It groups all the default supported inputs for ease of use.
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. */
  8770. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8771. /**
  8772. * Instantiates a new FreeCameraInputsManager.
  8773. * @param camera Defines the camera the inputs belong to
  8774. */
  8775. constructor(camera: FreeCamera);
  8776. /**
  8777. * Add keyboard input support to the input manager.
  8778. * @returns the current input manager
  8779. */
  8780. addKeyboard(): FreeCameraInputsManager;
  8781. /**
  8782. * Add mouse input support to the input manager.
  8783. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8784. * @returns the current input manager
  8785. */
  8786. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8787. /**
  8788. * Add orientation input support to the input manager.
  8789. * @returns the current input manager
  8790. */
  8791. addDeviceOrientation(): FreeCameraInputsManager;
  8792. /**
  8793. * Add touch input support to the input manager.
  8794. * @returns the current input manager
  8795. */
  8796. addTouch(): FreeCameraInputsManager;
  8797. /**
  8798. * Add virtual joystick input support to the input manager.
  8799. * @returns the current input manager
  8800. */
  8801. addVirtualJoystick(): FreeCameraInputsManager;
  8802. }
  8803. }
  8804. declare module BABYLON {
  8805. /**
  8806. * This represents a FPS type of camera. This is only here for back compat purpose.
  8807. * Please use the UniversalCamera instead as both are identical.
  8808. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8809. */
  8810. class GamepadCamera extends UniversalCamera {
  8811. /**
  8812. * Instantiates a new Gamepad Camera
  8813. * This represents a FPS type of camera. This is only here for back compat purpose.
  8814. * Please use the UniversalCamera instead as both are identical.
  8815. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8816. * @param name Define the name of the camera in the scene
  8817. * @param position Define the start position of the camera in the scene
  8818. * @param scene Define the scene the camera belongs to
  8819. */
  8820. constructor(name: string, position: Vector3, scene: Scene);
  8821. /**
  8822. * Gets the current object class name.
  8823. * @return the class name
  8824. */
  8825. getClassName(): string;
  8826. }
  8827. }
  8828. declare module BABYLON {
  8829. /**
  8830. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8831. * This is the base of the follow, arc rotate cameras and Free camera
  8832. * @see http://doc.babylonjs.com/features/cameras
  8833. */
  8834. class TargetCamera extends Camera {
  8835. private static _RigCamTransformMatrix;
  8836. private static _TargetTransformMatrix;
  8837. private static _TargetFocalPoint;
  8838. /**
  8839. * Define the current direction the camera is moving to
  8840. */
  8841. cameraDirection: Vector3;
  8842. /**
  8843. * Define the current rotation the camera is rotating to
  8844. */
  8845. cameraRotation: Vector2;
  8846. /**
  8847. * When set, the up vector of the camera will be updated by the rotation of the camera
  8848. */
  8849. updateUpVectorFromRotation: boolean;
  8850. private _tmpQuaternion;
  8851. /**
  8852. * Define the current rotation of the camera
  8853. */
  8854. rotation: Vector3;
  8855. /**
  8856. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8857. */
  8858. rotationQuaternion: Quaternion;
  8859. /**
  8860. * Define the current speed of the camera
  8861. */
  8862. speed: number;
  8863. /**
  8864. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8865. * around all axis.
  8866. */
  8867. noRotationConstraint: boolean;
  8868. /**
  8869. * Define the current target of the camera as an object or a position.
  8870. */
  8871. lockedTarget: any;
  8872. /** @hidden */
  8873. _currentTarget: Vector3;
  8874. /** @hidden */
  8875. _initialFocalDistance: number;
  8876. /** @hidden */
  8877. _viewMatrix: Matrix;
  8878. /** @hidden */
  8879. _camMatrix: Matrix;
  8880. /** @hidden */
  8881. _cameraTransformMatrix: Matrix;
  8882. /** @hidden */
  8883. _cameraRotationMatrix: Matrix;
  8884. /** @hidden */
  8885. _referencePoint: Vector3;
  8886. /** @hidden */
  8887. _transformedReferencePoint: Vector3;
  8888. protected _globalCurrentTarget: Vector3;
  8889. protected _globalCurrentUpVector: Vector3;
  8890. /** @hidden */
  8891. _reset: () => void;
  8892. private _defaultUp;
  8893. /**
  8894. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8895. * This is the base of the follow, arc rotate cameras and Free camera
  8896. * @see http://doc.babylonjs.com/features/cameras
  8897. * @param name Defines the name of the camera in the scene
  8898. * @param position Defines the start position of the camera in the scene
  8899. * @param scene Defines the scene the camera belongs to
  8900. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8901. */
  8902. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8903. /**
  8904. * Gets the position in front of the camera at a given distance.
  8905. * @param distance The distance from the camera we want the position to be
  8906. * @returns the position
  8907. */
  8908. getFrontPosition(distance: number): Vector3;
  8909. /** @hidden */
  8910. _getLockedTargetPosition(): Nullable<Vector3>;
  8911. private _storedPosition;
  8912. private _storedRotation;
  8913. private _storedRotationQuaternion;
  8914. /**
  8915. * Store current camera state of the camera (fov, position, rotation, etc..)
  8916. * @returns the camera
  8917. */
  8918. storeState(): Camera;
  8919. /**
  8920. * Restored camera state. You must call storeState() first
  8921. * @returns whether it was successful or not
  8922. * @hidden
  8923. */
  8924. _restoreStateValues(): boolean;
  8925. /** @hidden */
  8926. _initCache(): void;
  8927. /** @hidden */
  8928. _updateCache(ignoreParentClass?: boolean): void;
  8929. /** @hidden */
  8930. _isSynchronizedViewMatrix(): boolean;
  8931. /** @hidden */
  8932. _computeLocalCameraSpeed(): number;
  8933. /** @hidden */
  8934. setTarget(target: Vector3): void;
  8935. /**
  8936. * Return the current target position of the camera. This value is expressed in local space.
  8937. * @returns the target position
  8938. */
  8939. getTarget(): Vector3;
  8940. /** @hidden */
  8941. _decideIfNeedsToMove(): boolean;
  8942. /** @hidden */
  8943. _updatePosition(): void;
  8944. /** @hidden */
  8945. _checkInputs(): void;
  8946. protected _updateCameraRotationMatrix(): void;
  8947. /**
  8948. * 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)
  8949. * @returns the current camera
  8950. */
  8951. private _rotateUpVectorWithCameraRotationMatrix;
  8952. private _cachedRotationZ;
  8953. private _cachedQuaternionRotationZ;
  8954. /** @hidden */
  8955. _getViewMatrix(): Matrix;
  8956. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8957. /**
  8958. * @hidden
  8959. */
  8960. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8961. /**
  8962. * @hidden
  8963. */
  8964. _updateRigCameras(): void;
  8965. private _getRigCamPositionAndTarget;
  8966. /**
  8967. * Gets the current object class name.
  8968. * @return the class name
  8969. */
  8970. getClassName(): string;
  8971. }
  8972. }
  8973. declare module BABYLON {
  8974. /**
  8975. * This represents a FPS type of camera controlled by touch.
  8976. * This is like a universal camera minus the Gamepad controls.
  8977. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8978. */
  8979. class TouchCamera extends FreeCamera {
  8980. /**
  8981. * Defines the touch sensibility for rotation.
  8982. * The higher the faster.
  8983. */
  8984. touchAngularSensibility: number;
  8985. /**
  8986. * Defines the touch sensibility for move.
  8987. * The higher the faster.
  8988. */
  8989. touchMoveSensibility: number;
  8990. /**
  8991. * Instantiates a new touch camera.
  8992. * This represents a FPS type of camera controlled by touch.
  8993. * This is like a universal camera minus the Gamepad controls.
  8994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8995. * @param name Define the name of the camera in the scene
  8996. * @param position Define the start position of the camera in the scene
  8997. * @param scene Define the scene the camera belongs to
  8998. */
  8999. constructor(name: string, position: Vector3, scene: Scene);
  9000. /**
  9001. * Gets the current object class name.
  9002. * @return the class name
  9003. */
  9004. getClassName(): string;
  9005. /** @hidden */
  9006. _setupInputs(): void;
  9007. }
  9008. }
  9009. declare module BABYLON {
  9010. /**
  9011. * 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,
  9012. * which still works and will still be found in many Playgrounds.
  9013. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9014. */
  9015. class UniversalCamera extends TouchCamera {
  9016. /**
  9017. * Defines the gamepad rotation sensiblity.
  9018. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9019. */
  9020. gamepadAngularSensibility: number;
  9021. /**
  9022. * Defines the gamepad move sensiblity.
  9023. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9024. */
  9025. gamepadMoveSensibility: number;
  9026. /**
  9027. * 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,
  9028. * which still works and will still be found in many Playgrounds.
  9029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9030. * @param name Define the name of the camera in the scene
  9031. * @param position Define the start position of the camera in the scene
  9032. * @param scene Define the scene the camera belongs to
  9033. */
  9034. constructor(name: string, position: Vector3, scene: Scene);
  9035. /**
  9036. * Gets the current object class name.
  9037. * @return the class name
  9038. */
  9039. getClassName(): string;
  9040. }
  9041. }
  9042. declare module BABYLON {
  9043. /**
  9044. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9045. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9046. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9047. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9048. */
  9049. class VirtualJoysticksCamera extends FreeCamera {
  9050. /**
  9051. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  9052. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9053. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9054. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9055. * @param name Define the name of the camera in the scene
  9056. * @param position Define the start position of the camera in the scene
  9057. * @param scene Define the scene the camera belongs to
  9058. */
  9059. constructor(name: string, position: Vector3, scene: Scene);
  9060. /**
  9061. * Gets the current object class name.
  9062. * @return the class name
  9063. */
  9064. getClassName(): string;
  9065. }
  9066. }
  9067. interface VRDisplay extends EventTarget {
  9068. /**
  9069. * Dictionary of capabilities describing the VRDisplay.
  9070. */
  9071. readonly capabilities: VRDisplayCapabilities;
  9072. /**
  9073. * z-depth defining the far plane of the eye view frustum
  9074. * enables mapping of values in the render target depth
  9075. * attachment to scene coordinates. Initially set to 10000.0.
  9076. */
  9077. depthFar: number;
  9078. /**
  9079. * z-depth defining the near plane of the eye view frustum
  9080. * enables mapping of values in the render target depth
  9081. * attachment to scene coordinates. Initially set to 0.01.
  9082. */
  9083. depthNear: number;
  9084. /**
  9085. * An identifier for this distinct VRDisplay. Used as an
  9086. * association point in the Gamepad API.
  9087. */
  9088. readonly displayId: number;
  9089. /**
  9090. * A display name, a user-readable name identifying it.
  9091. */
  9092. readonly displayName: string;
  9093. readonly isConnected: boolean;
  9094. readonly isPresenting: boolean;
  9095. /**
  9096. * If this VRDisplay supports room-scale experiences, the optional
  9097. * stage attribute contains details on the room-scale parameters.
  9098. */
  9099. readonly stageParameters: VRStageParameters | null;
  9100. /**
  9101. * Passing the value returned by `requestAnimationFrame` to
  9102. * `cancelAnimationFrame` will unregister the callback.
  9103. * @param handle Define the hanle of the request to cancel
  9104. */
  9105. cancelAnimationFrame(handle: number): void;
  9106. /**
  9107. * Stops presenting to the VRDisplay.
  9108. * @returns a promise to know when it stopped
  9109. */
  9110. exitPresent(): Promise<void>;
  9111. /**
  9112. * Return the current VREyeParameters for the given eye.
  9113. * @param whichEye Define the eye we want the parameter for
  9114. * @returns the eye parameters
  9115. */
  9116. getEyeParameters(whichEye: string): VREyeParameters;
  9117. /**
  9118. * Populates the passed VRFrameData with the information required to render
  9119. * the current frame.
  9120. * @param frameData Define the data structure to populate
  9121. * @returns true if ok otherwise false
  9122. */
  9123. getFrameData(frameData: VRFrameData): boolean;
  9124. /**
  9125. * Get the layers currently being presented.
  9126. * @returns the list of VR layers
  9127. */
  9128. getLayers(): VRLayer[];
  9129. /**
  9130. * Return a VRPose containing the future predicted pose of the VRDisplay
  9131. * when the current frame will be presented. The value returned will not
  9132. * change until JavaScript has returned control to the browser.
  9133. *
  9134. * The VRPose will contain the position, orientation, velocity,
  9135. * and acceleration of each of these properties.
  9136. * @returns the pose object
  9137. */
  9138. getPose(): VRPose;
  9139. /**
  9140. * Return the current instantaneous pose of the VRDisplay, with no
  9141. * prediction applied.
  9142. * @returns the current instantaneous pose
  9143. */
  9144. getImmediatePose(): VRPose;
  9145. /**
  9146. * The callback passed to `requestAnimationFrame` will be called
  9147. * any time a new frame should be rendered. When the VRDisplay is
  9148. * presenting the callback will be called at the native refresh
  9149. * rate of the HMD. When not presenting this function acts
  9150. * identically to how window.requestAnimationFrame acts. Content should
  9151. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9152. * asynchronously from other displays and at differing refresh rates.
  9153. * @param callback Define the eaction to run next frame
  9154. * @returns the request handle it
  9155. */
  9156. requestAnimationFrame(callback: FrameRequestCallback): number;
  9157. /**
  9158. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9159. * Repeat calls while already presenting will update the VRLayers being displayed.
  9160. * @param layers Define the list of layer to present
  9161. * @returns a promise to know when the request has been fulfilled
  9162. */
  9163. requestPresent(layers: VRLayer[]): Promise<void>;
  9164. /**
  9165. * Reset the pose for this display, treating its current position and
  9166. * orientation as the "origin/zero" values. VRPose.position,
  9167. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9168. * updated when calling resetPose(). This should be called in only
  9169. * sitting-space experiences.
  9170. */
  9171. resetPose(): void;
  9172. /**
  9173. * The VRLayer provided to the VRDisplay will be captured and presented
  9174. * in the HMD. Calling this function has the same effect on the source
  9175. * canvas as any other operation that uses its source image, and canvases
  9176. * created without preserveDrawingBuffer set to true will be cleared.
  9177. * @param pose Define the pose to submit
  9178. */
  9179. submitFrame(pose?: VRPose): void;
  9180. }
  9181. declare var VRDisplay: {
  9182. prototype: VRDisplay;
  9183. new (): VRDisplay;
  9184. };
  9185. interface VRLayer {
  9186. leftBounds?: number[] | Float32Array | null;
  9187. rightBounds?: number[] | Float32Array | null;
  9188. source?: HTMLCanvasElement | null;
  9189. }
  9190. interface VRDisplayCapabilities {
  9191. readonly canPresent: boolean;
  9192. readonly hasExternalDisplay: boolean;
  9193. readonly hasOrientation: boolean;
  9194. readonly hasPosition: boolean;
  9195. readonly maxLayers: number;
  9196. }
  9197. interface VREyeParameters {
  9198. /** @deprecated */
  9199. readonly fieldOfView: VRFieldOfView;
  9200. readonly offset: Float32Array;
  9201. readonly renderHeight: number;
  9202. readonly renderWidth: number;
  9203. }
  9204. interface VRFieldOfView {
  9205. readonly downDegrees: number;
  9206. readonly leftDegrees: number;
  9207. readonly rightDegrees: number;
  9208. readonly upDegrees: number;
  9209. }
  9210. interface VRFrameData {
  9211. readonly leftProjectionMatrix: Float32Array;
  9212. readonly leftViewMatrix: Float32Array;
  9213. readonly pose: VRPose;
  9214. readonly rightProjectionMatrix: Float32Array;
  9215. readonly rightViewMatrix: Float32Array;
  9216. readonly timestamp: number;
  9217. }
  9218. interface VRPose {
  9219. readonly angularAcceleration: Float32Array | null;
  9220. readonly angularVelocity: Float32Array | null;
  9221. readonly linearAcceleration: Float32Array | null;
  9222. readonly linearVelocity: Float32Array | null;
  9223. readonly orientation: Float32Array | null;
  9224. readonly position: Float32Array | null;
  9225. readonly timestamp: number;
  9226. }
  9227. interface VRStageParameters {
  9228. sittingToStandingTransform?: Float32Array;
  9229. sizeX?: number;
  9230. sizeY?: number;
  9231. }
  9232. interface Navigator {
  9233. getVRDisplays(): Promise<VRDisplay[]>;
  9234. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9235. }
  9236. interface Window {
  9237. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9238. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9239. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9240. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9241. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9242. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9243. }
  9244. interface Gamepad {
  9245. readonly displayId: number;
  9246. }
  9247. declare module BABYLON {
  9248. /** @hidden */
  9249. class Collider {
  9250. /** Define if a collision was found */
  9251. collisionFound: boolean;
  9252. /**
  9253. * Define last intersection point in local space
  9254. */
  9255. intersectionPoint: Vector3;
  9256. /**
  9257. * Define last collided mesh
  9258. */
  9259. collidedMesh: Nullable<AbstractMesh>;
  9260. private _collisionPoint;
  9261. private _planeIntersectionPoint;
  9262. private _tempVector;
  9263. private _tempVector2;
  9264. private _tempVector3;
  9265. private _tempVector4;
  9266. private _edge;
  9267. private _baseToVertex;
  9268. private _destinationPoint;
  9269. private _slidePlaneNormal;
  9270. private _displacementVector;
  9271. /** @hidden */
  9272. _radius: Vector3;
  9273. /** @hidden */
  9274. _retry: number;
  9275. private _velocity;
  9276. private _basePoint;
  9277. private _epsilon;
  9278. /** @hidden */
  9279. _velocityWorldLength: number;
  9280. /** @hidden */
  9281. _basePointWorld: Vector3;
  9282. private _velocityWorld;
  9283. private _normalizedVelocity;
  9284. /** @hidden */
  9285. _initialVelocity: Vector3;
  9286. /** @hidden */
  9287. _initialPosition: Vector3;
  9288. private _nearestDistance;
  9289. private _collisionMask;
  9290. collisionMask: number;
  9291. /**
  9292. * Gets the plane normal used to compute the sliding response (in local space)
  9293. */
  9294. readonly slidePlaneNormal: Vector3;
  9295. /** @hidden */
  9296. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9297. /** @hidden */
  9298. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9299. /** @hidden */
  9300. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9301. /** @hidden */
  9302. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9303. /** @hidden */
  9304. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9305. /** @hidden */
  9306. _getResponse(pos: Vector3, vel: Vector3): void;
  9307. }
  9308. }
  9309. declare module BABYLON {
  9310. /** @hidden */
  9311. var CollisionWorker: string;
  9312. /** @hidden */
  9313. interface ICollisionCoordinator {
  9314. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9315. init(scene: Scene): void;
  9316. destroy(): void;
  9317. onMeshAdded(mesh: AbstractMesh): void;
  9318. onMeshUpdated(mesh: AbstractMesh): void;
  9319. onMeshRemoved(mesh: AbstractMesh): void;
  9320. onGeometryAdded(geometry: Geometry): void;
  9321. onGeometryUpdated(geometry: Geometry): void;
  9322. onGeometryDeleted(geometry: Geometry): void;
  9323. }
  9324. /** @hidden */
  9325. interface SerializedMesh {
  9326. id: string;
  9327. name: string;
  9328. uniqueId: number;
  9329. geometryId: Nullable<string>;
  9330. sphereCenter: Array<number>;
  9331. sphereRadius: number;
  9332. boxMinimum: Array<number>;
  9333. boxMaximum: Array<number>;
  9334. worldMatrixFromCache: any;
  9335. subMeshes: Array<SerializedSubMesh>;
  9336. checkCollisions: boolean;
  9337. }
  9338. /** @hidden */
  9339. interface SerializedSubMesh {
  9340. position: number;
  9341. verticesStart: number;
  9342. verticesCount: number;
  9343. indexStart: number;
  9344. indexCount: number;
  9345. hasMaterial: boolean;
  9346. sphereCenter: Array<number>;
  9347. sphereRadius: number;
  9348. boxMinimum: Array<number>;
  9349. boxMaximum: Array<number>;
  9350. }
  9351. /**
  9352. * Interface describing the value associated with a geometry.
  9353. * @hidden
  9354. */
  9355. interface SerializedGeometry {
  9356. /**
  9357. * Defines the unique ID of the geometry
  9358. */
  9359. id: string;
  9360. /**
  9361. * Defines the array containing the positions
  9362. */
  9363. positions: Float32Array;
  9364. /**
  9365. * Defines the array containing the indices
  9366. */
  9367. indices: Uint32Array;
  9368. /**
  9369. * Defines the array containing the normals
  9370. */
  9371. normals: Float32Array;
  9372. }
  9373. /** @hidden */
  9374. interface BabylonMessage {
  9375. taskType: WorkerTaskType;
  9376. payload: InitPayload | CollidePayload | UpdatePayload;
  9377. }
  9378. /** @hidden */
  9379. interface SerializedColliderToWorker {
  9380. position: Array<number>;
  9381. velocity: Array<number>;
  9382. radius: Array<number>;
  9383. }
  9384. /** Defines supported task for worker process */
  9385. enum WorkerTaskType {
  9386. /** Initialization */
  9387. INIT = 0,
  9388. /** Update of geometry */
  9389. UPDATE = 1,
  9390. /** Evaluate collision */
  9391. COLLIDE = 2
  9392. }
  9393. /** @hidden */
  9394. interface WorkerReply {
  9395. error: WorkerReplyType;
  9396. taskType: WorkerTaskType;
  9397. payload?: any;
  9398. }
  9399. /** @hidden */
  9400. interface CollisionReplyPayload {
  9401. newPosition: Array<number>;
  9402. collisionId: number;
  9403. collidedMeshUniqueId: number;
  9404. }
  9405. /** @hidden */
  9406. interface InitPayload {
  9407. }
  9408. /** @hidden */
  9409. interface CollidePayload {
  9410. collisionId: number;
  9411. collider: SerializedColliderToWorker;
  9412. maximumRetry: number;
  9413. excludedMeshUniqueId: Nullable<number>;
  9414. }
  9415. /** @hidden */
  9416. interface UpdatePayload {
  9417. updatedMeshes: {
  9418. [n: number]: SerializedMesh;
  9419. };
  9420. updatedGeometries: {
  9421. [s: string]: SerializedGeometry;
  9422. };
  9423. removedMeshes: Array<number>;
  9424. removedGeometries: Array<string>;
  9425. }
  9426. /** Defines kind of replies returned by worker */
  9427. enum WorkerReplyType {
  9428. /** Success */
  9429. SUCCESS = 0,
  9430. /** Unkown error */
  9431. UNKNOWN_ERROR = 1
  9432. }
  9433. /** @hidden */
  9434. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9435. private _scene;
  9436. private _scaledPosition;
  9437. private _scaledVelocity;
  9438. private _collisionsCallbackArray;
  9439. private _init;
  9440. private _runningUpdated;
  9441. private _worker;
  9442. private _addUpdateMeshesList;
  9443. private _addUpdateGeometriesList;
  9444. private _toRemoveMeshesArray;
  9445. private _toRemoveGeometryArray;
  9446. constructor();
  9447. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9448. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9449. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9450. init(scene: Scene): void;
  9451. destroy(): void;
  9452. onMeshAdded(mesh: AbstractMesh): void;
  9453. onMeshUpdated: (transformNode: TransformNode) => void;
  9454. onMeshRemoved(mesh: AbstractMesh): void;
  9455. onGeometryAdded(geometry: Geometry): void;
  9456. onGeometryUpdated: (geometry: Geometry) => void;
  9457. onGeometryDeleted(geometry: Geometry): void;
  9458. private _afterRender;
  9459. private _onMessageFromWorker;
  9460. }
  9461. /** @hidden */
  9462. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9463. private _scene;
  9464. private _scaledPosition;
  9465. private _scaledVelocity;
  9466. private _finalPosition;
  9467. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9468. init(scene: Scene): void;
  9469. destroy(): void;
  9470. onMeshAdded(mesh: AbstractMesh): void;
  9471. onMeshUpdated(mesh: AbstractMesh): void;
  9472. onMeshRemoved(mesh: AbstractMesh): void;
  9473. onGeometryAdded(geometry: Geometry): void;
  9474. onGeometryUpdated(geometry: Geometry): void;
  9475. onGeometryDeleted(geometry: Geometry): void;
  9476. private _collideWithWorld;
  9477. }
  9478. }
  9479. declare function importScripts(...urls: string[]): void;
  9480. declare const safePostMessage: any;
  9481. declare module BABYLON {
  9482. /** @hidden */
  9483. var WorkerIncluded: boolean;
  9484. /** @hidden */
  9485. class CollisionCache {
  9486. private _meshes;
  9487. private _geometries;
  9488. getMeshes(): {
  9489. [n: number]: SerializedMesh;
  9490. };
  9491. getGeometries(): {
  9492. [s: number]: SerializedGeometry;
  9493. };
  9494. getMesh(id: any): SerializedMesh;
  9495. addMesh(mesh: SerializedMesh): void;
  9496. removeMesh(uniqueId: number): void;
  9497. getGeometry(id: string): SerializedGeometry;
  9498. addGeometry(geometry: SerializedGeometry): void;
  9499. removeGeometry(id: string): void;
  9500. }
  9501. /** @hidden */
  9502. class CollideWorker {
  9503. collider: Collider;
  9504. private _collisionCache;
  9505. private finalPosition;
  9506. private collisionsScalingMatrix;
  9507. private collisionTranformationMatrix;
  9508. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9509. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9510. private checkCollision;
  9511. private processCollisionsForSubMeshes;
  9512. private collideForSubMesh;
  9513. private checkSubmeshCollision;
  9514. }
  9515. /** @hidden */
  9516. interface ICollisionDetector {
  9517. onInit(payload: InitPayload): void;
  9518. onUpdate(payload: UpdatePayload): void;
  9519. onCollision(payload: CollidePayload): void;
  9520. }
  9521. /** @hidden */
  9522. class CollisionDetectorTransferable implements ICollisionDetector {
  9523. private _collisionCache;
  9524. onInit(payload: InitPayload): void;
  9525. onUpdate(payload: UpdatePayload): void;
  9526. onCollision(payload: CollidePayload): void;
  9527. }
  9528. }
  9529. declare module BABYLON {
  9530. /**
  9531. * @hidden
  9532. */
  9533. class IntersectionInfo {
  9534. bu: Nullable<number>;
  9535. bv: Nullable<number>;
  9536. distance: number;
  9537. faceId: number;
  9538. subMeshId: number;
  9539. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9540. }
  9541. /**
  9542. * Information about the result of picking within a scene
  9543. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9544. */
  9545. class PickingInfo {
  9546. /**
  9547. * If the pick collided with an object
  9548. */
  9549. hit: boolean;
  9550. /**
  9551. * Distance away where the pick collided
  9552. */
  9553. distance: number;
  9554. /**
  9555. * The location of pick collision
  9556. */
  9557. pickedPoint: Nullable<Vector3>;
  9558. /**
  9559. * The mesh corresponding the the pick collision
  9560. */
  9561. pickedMesh: Nullable<AbstractMesh>;
  9562. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9563. bu: number;
  9564. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9565. bv: number;
  9566. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  9567. faceId: number;
  9568. /** Id of the the submesh that was picked */
  9569. subMeshId: number;
  9570. /** If a sprite was picked, this will be the sprite the pick collided with */
  9571. pickedSprite: Nullable<Sprite>;
  9572. /**
  9573. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9574. */
  9575. originMesh: Nullable<AbstractMesh>;
  9576. /**
  9577. * The ray that was used to perform the picking.
  9578. */
  9579. ray: Nullable<Ray>;
  9580. /**
  9581. * Gets the normal correspodning to the face the pick collided with
  9582. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9583. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9584. * @returns The normal correspodning to the face the pick collided with
  9585. */
  9586. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9587. /**
  9588. * Gets the texture coordinates of where the pick occured
  9589. * @returns the vector containing the coordnates of the texture
  9590. */
  9591. getTextureCoordinates(): Nullable<Vector2>;
  9592. }
  9593. }
  9594. /**
  9595. * Module Debug contains the (visual) components to debug a scene correctly
  9596. */
  9597. declare module BABYLON.Debug {
  9598. /**
  9599. * The Axes viewer will show 3 axes in a specific point in space
  9600. */
  9601. class AxesViewer {
  9602. private _xAxis;
  9603. private _yAxis;
  9604. private _zAxis;
  9605. private _scaleLinesFactor;
  9606. private _instanced;
  9607. /**
  9608. * Gets the hosting scene
  9609. */
  9610. scene: Scene;
  9611. /**
  9612. * Gets or sets a number used to scale line length
  9613. */
  9614. scaleLines: number;
  9615. /** Gets the node hierarchy used to render x-axis */
  9616. readonly xAxis: TransformNode;
  9617. /** Gets the node hierarchy used to render y-axis */
  9618. readonly yAxis: TransformNode;
  9619. /** Gets the node hierarchy used to render z-axis */
  9620. readonly zAxis: TransformNode;
  9621. /**
  9622. * Creates a new AxesViewer
  9623. * @param scene defines the hosting scene
  9624. * @param scaleLines defines a number used to scale line length (1 by default)
  9625. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  9626. * @param xAxis defines the node hierarchy used to render the x-axis
  9627. * @param yAxis defines the node hierarchy used to render the y-axis
  9628. * @param zAxis defines the node hierarchy used to render the z-axis
  9629. */
  9630. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  9631. /**
  9632. * Force the viewer to update
  9633. * @param position defines the position of the viewer
  9634. * @param xaxis defines the x axis of the viewer
  9635. * @param yaxis defines the y axis of the viewer
  9636. * @param zaxis defines the z axis of the viewer
  9637. */
  9638. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9639. /**
  9640. * Creates an instance of this axes viewer.
  9641. * @returns a new axes viewer with instanced meshes
  9642. */
  9643. createInstance(): AxesViewer;
  9644. /** Releases resources */
  9645. dispose(): void;
  9646. private static _SetRenderingGroupId;
  9647. }
  9648. }
  9649. declare module BABYLON.Debug {
  9650. /**
  9651. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9652. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9653. */
  9654. class BoneAxesViewer extends AxesViewer {
  9655. /**
  9656. * Gets or sets the target mesh where to display the axes viewer
  9657. */
  9658. mesh: Nullable<Mesh>;
  9659. /**
  9660. * Gets or sets the target bone where to display the axes viewer
  9661. */
  9662. bone: Nullable<Bone>;
  9663. /** Gets current position */
  9664. pos: Vector3;
  9665. /** Gets direction of X axis */
  9666. xaxis: Vector3;
  9667. /** Gets direction of Y axis */
  9668. yaxis: Vector3;
  9669. /** Gets direction of Z axis */
  9670. zaxis: Vector3;
  9671. /**
  9672. * Creates a new BoneAxesViewer
  9673. * @param scene defines the hosting scene
  9674. * @param bone defines the target bone
  9675. * @param mesh defines the target mesh
  9676. * @param scaleLines defines a scaling factor for line length (1 by default)
  9677. */
  9678. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9679. /**
  9680. * Force the viewer to update
  9681. */
  9682. update(): void;
  9683. /** Releases resources */
  9684. dispose(): void;
  9685. }
  9686. }
  9687. declare module BABYLON {
  9688. /**
  9689. * Interface used to define scene explorer extensibility option
  9690. */
  9691. interface IExplorerExtensibilityOption {
  9692. /**
  9693. * Define the option label
  9694. */
  9695. label: string;
  9696. /**
  9697. * Defines the action to execute on click
  9698. */
  9699. action: (entity: any) => void;
  9700. }
  9701. /**
  9702. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9703. */
  9704. interface IExplorerExtensibilityGroup {
  9705. /**
  9706. * Defines a predicate to test if a given type mut be extended
  9707. */
  9708. predicate: (entity: any) => boolean;
  9709. /**
  9710. * Gets the list of options added to a type
  9711. */
  9712. entries: IExplorerExtensibilityOption[];
  9713. }
  9714. /**
  9715. * Interface used to define the options to use to create the Inspector
  9716. */
  9717. interface IInspectorOptions {
  9718. /**
  9719. * Display in overlay mode (default: false)
  9720. */
  9721. overlay?: boolean;
  9722. /**
  9723. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9724. */
  9725. globalRoot?: HTMLElement;
  9726. /**
  9727. * Display the Scene explorer
  9728. */
  9729. showExplorer?: boolean;
  9730. /**
  9731. * Display the property inspector
  9732. */
  9733. showInspector?: boolean;
  9734. /**
  9735. * Display in embed mode (both panes on the right)
  9736. */
  9737. embedMode?: boolean;
  9738. /**
  9739. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9740. */
  9741. handleResize?: boolean;
  9742. /**
  9743. * Allow the panes to popup (default: true)
  9744. */
  9745. enablePopup?: boolean;
  9746. /**
  9747. * Allow the panes to be closed by users (default: true)
  9748. */
  9749. enableClose?: boolean;
  9750. /**
  9751. * Optional list of extensibility entries
  9752. */
  9753. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9754. }
  9755. interface Scene {
  9756. /**
  9757. * @hidden
  9758. * Backing field
  9759. */
  9760. _debugLayer: DebugLayer;
  9761. /**
  9762. * Gets the debug layer (aka Inspector) associated with the scene
  9763. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9764. */
  9765. debugLayer: DebugLayer;
  9766. }
  9767. /**
  9768. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9769. * what is happening in your scene
  9770. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9771. */
  9772. class DebugLayer {
  9773. /**
  9774. * Define the url to get the inspector script from.
  9775. * By default it uses the babylonjs CDN.
  9776. * @ignoreNaming
  9777. */
  9778. static InspectorURL: string;
  9779. private _scene;
  9780. private BJSINSPECTOR;
  9781. /**
  9782. * Observable triggered when a property is changed through the inspector.
  9783. */
  9784. onPropertyChangedObservable: Observable<{
  9785. object: any;
  9786. property: string;
  9787. value: any;
  9788. initialValue: any;
  9789. }>;
  9790. /**
  9791. * Instantiates a new debug layer.
  9792. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9793. * what is happening in your scene
  9794. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9795. * @param scene Defines the scene to inspect
  9796. */
  9797. constructor(scene: Scene);
  9798. /** Creates the inspector window. */
  9799. private _createInspector;
  9800. /** Get the inspector from bundle or global */
  9801. private _getGlobalInspector;
  9802. /**
  9803. * Get if the inspector is visible or not.
  9804. * @returns true if visible otherwise, false
  9805. */
  9806. isVisible(): boolean;
  9807. /**
  9808. * Hide the inspector and close its window.
  9809. */
  9810. hide(): void;
  9811. /**
  9812. * Launch the debugLayer.
  9813. * @param config Define the configuration of the inspector
  9814. */
  9815. show(config?: IInspectorOptions): void;
  9816. }
  9817. }
  9818. declare module BABYLON.Debug {
  9819. /**
  9820. * Used to show the physics impostor around the specific mesh
  9821. */
  9822. class PhysicsViewer {
  9823. /** @hidden */
  9824. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9825. /** @hidden */
  9826. protected _meshes: Array<Nullable<AbstractMesh>>;
  9827. /** @hidden */
  9828. protected _scene: Nullable<Scene>;
  9829. /** @hidden */
  9830. protected _numMeshes: number;
  9831. /** @hidden */
  9832. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9833. private _renderFunction;
  9834. private _utilityLayer;
  9835. private _debugBoxMesh;
  9836. private _debugSphereMesh;
  9837. private _debugMaterial;
  9838. /**
  9839. * Creates a new PhysicsViewer
  9840. * @param scene defines the hosting scene
  9841. */
  9842. constructor(scene: Scene);
  9843. /** @hidden */
  9844. protected _updateDebugMeshes(): void;
  9845. /**
  9846. * Renders a specified physic impostor
  9847. * @param impostor defines the impostor to render
  9848. * @returns the new debug mesh used to render the impostor
  9849. */
  9850. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9851. /**
  9852. * Hides a specified physic impostor
  9853. * @param impostor defines the impostor to hide
  9854. */
  9855. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9856. private _getDebugMaterial;
  9857. private _getDebugBoxMesh;
  9858. private _getDebugSphereMesh;
  9859. private _getDebugMesh;
  9860. /** Releases all resources */
  9861. dispose(): void;
  9862. }
  9863. }
  9864. declare module BABYLON {
  9865. /**
  9866. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9867. * in order to better appreciate the issue one might have.
  9868. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9869. */
  9870. class RayHelper {
  9871. /**
  9872. * Defines the ray we are currently tryin to visualize.
  9873. */
  9874. ray: Nullable<Ray>;
  9875. private _renderPoints;
  9876. private _renderLine;
  9877. private _renderFunction;
  9878. private _scene;
  9879. private _updateToMeshFunction;
  9880. private _attachedToMesh;
  9881. private _meshSpaceDirection;
  9882. private _meshSpaceOrigin;
  9883. /**
  9884. * Helper function to create a colored helper in a scene in one line.
  9885. * @param ray Defines the ray we are currently tryin to visualize
  9886. * @param scene Defines the scene the ray is used in
  9887. * @param color Defines the color we want to see the ray in
  9888. * @returns The newly created ray helper.
  9889. */
  9890. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9891. /**
  9892. * Instantiate a new ray helper.
  9893. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9894. * in order to better appreciate the issue one might have.
  9895. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9896. * @param ray Defines the ray we are currently tryin to visualize
  9897. */
  9898. constructor(ray: Ray);
  9899. /**
  9900. * Shows the ray we are willing to debug.
  9901. * @param scene Defines the scene the ray needs to be rendered in
  9902. * @param color Defines the color the ray needs to be rendered in
  9903. */
  9904. show(scene: Scene, color?: Color3): void;
  9905. /**
  9906. * Hides the ray we are debugging.
  9907. */
  9908. hide(): void;
  9909. private _render;
  9910. /**
  9911. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9912. * @param mesh Defines the mesh we want the helper attached to
  9913. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9914. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9915. * @param length Defines the length of the ray
  9916. */
  9917. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9918. /**
  9919. * Detach the ray helper from the mesh it has previously been attached to.
  9920. */
  9921. detachFromMesh(): void;
  9922. private _updateToMesh;
  9923. /**
  9924. * Dispose the helper and release its associated resources.
  9925. */
  9926. dispose(): void;
  9927. }
  9928. }
  9929. declare module BABYLON.Debug {
  9930. /**
  9931. * Class used to render a debug view of a given skeleton
  9932. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9933. */
  9934. class SkeletonViewer {
  9935. /** defines the skeleton to render */
  9936. skeleton: Skeleton;
  9937. /** defines the mesh attached to the skeleton */
  9938. mesh: AbstractMesh;
  9939. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9940. autoUpdateBonesMatrices: boolean;
  9941. /** defines the rendering group id to use with the viewer */
  9942. renderingGroupId: number;
  9943. /** Gets or sets the color used to render the skeleton */
  9944. color: Color3;
  9945. private _scene;
  9946. private _debugLines;
  9947. private _debugMesh;
  9948. private _isEnabled;
  9949. private _renderFunction;
  9950. private _utilityLayer;
  9951. /**
  9952. * Returns the mesh used to render the bones
  9953. */
  9954. readonly debugMesh: Nullable<LinesMesh>;
  9955. /**
  9956. * Creates a new SkeletonViewer
  9957. * @param skeleton defines the skeleton to render
  9958. * @param mesh defines the mesh attached to the skeleton
  9959. * @param scene defines the hosting scene
  9960. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9961. * @param renderingGroupId defines the rendering group id to use with the viewer
  9962. */
  9963. constructor(
  9964. /** defines the skeleton to render */
  9965. skeleton: Skeleton,
  9966. /** defines the mesh attached to the skeleton */
  9967. mesh: AbstractMesh, scene: Scene,
  9968. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9969. autoUpdateBonesMatrices?: boolean,
  9970. /** defines the rendering group id to use with the viewer */
  9971. renderingGroupId?: number);
  9972. /** Gets or sets a boolean indicating if the viewer is enabled */
  9973. isEnabled: boolean;
  9974. private _getBonePosition;
  9975. private _getLinesForBonesWithLength;
  9976. private _getLinesForBonesNoLength;
  9977. /** Update the viewer to sync with current skeleton state */
  9978. update(): void;
  9979. /** Release associated resources */
  9980. dispose(): void;
  9981. }
  9982. }
  9983. declare module BABYLON {
  9984. /**
  9985. * Interface for attribute information associated with buffer instanciation
  9986. */
  9987. class InstancingAttributeInfo {
  9988. /**
  9989. * Index/offset of the attribute in the vertex shader
  9990. */
  9991. index: number;
  9992. /**
  9993. * size of the attribute, 1, 2, 3 or 4
  9994. */
  9995. attributeSize: number;
  9996. /**
  9997. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9998. * default is FLOAT
  9999. */
  10000. attribyteType: number;
  10001. /**
  10002. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  10003. */
  10004. normalized: boolean;
  10005. /**
  10006. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  10007. */
  10008. offset: number;
  10009. /**
  10010. * Name of the GLSL attribute, for debugging purpose only
  10011. */
  10012. attributeName: string;
  10013. }
  10014. /**
  10015. * Define options used to create a render target texture
  10016. */
  10017. class RenderTargetCreationOptions {
  10018. /**
  10019. * Specifies is mipmaps must be generated
  10020. */
  10021. generateMipMaps?: boolean;
  10022. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  10023. generateDepthBuffer?: boolean;
  10024. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  10025. generateStencilBuffer?: boolean;
  10026. /** Defines texture type (int by default) */
  10027. type?: number;
  10028. /** Defines sampling mode (trilinear by default) */
  10029. samplingMode?: number;
  10030. /** Defines format (RGBA by default) */
  10031. format?: number;
  10032. }
  10033. /**
  10034. * Define options used to create a depth texture
  10035. */
  10036. class DepthTextureCreationOptions {
  10037. /** Specifies whether or not a stencil should be allocated in the texture */
  10038. generateStencil?: boolean;
  10039. /** Specifies whether or not bilinear filtering is enable on the texture */
  10040. bilinearFiltering?: boolean;
  10041. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10042. comparisonFunction?: number;
  10043. /** Specifies if the created texture is a cube texture */
  10044. isCube?: boolean;
  10045. }
  10046. /**
  10047. * Class used to describe the capabilities of the engine relatively to the current browser
  10048. */
  10049. class EngineCapabilities {
  10050. /** Maximum textures units per fragment shader */
  10051. maxTexturesImageUnits: number;
  10052. /** Maximum texture units per vertex shader */
  10053. maxVertexTextureImageUnits: number;
  10054. /** Maximum textures units in the entire pipeline */
  10055. maxCombinedTexturesImageUnits: number;
  10056. /** Maximum texture size */
  10057. maxTextureSize: number;
  10058. /** Maximum cube texture size */
  10059. maxCubemapTextureSize: number;
  10060. /** Maximum render texture size */
  10061. maxRenderTextureSize: number;
  10062. /** Maximum number of vertex attributes */
  10063. maxVertexAttribs: number;
  10064. /** Maximum number of varyings */
  10065. maxVaryingVectors: number;
  10066. /** Maximum number of uniforms per vertex shader */
  10067. maxVertexUniformVectors: number;
  10068. /** Maximum number of uniforms per fragment shader */
  10069. maxFragmentUniformVectors: number;
  10070. /** Defines if standard derivates (dx/dy) are supported */
  10071. standardDerivatives: boolean;
  10072. /** Defines if s3tc texture compression is supported */
  10073. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10074. /** Defines if pvrtc texture compression is supported */
  10075. pvrtc: any;
  10076. /** Defines if etc1 texture compression is supported */
  10077. etc1: any;
  10078. /** Defines if etc2 texture compression is supported */
  10079. etc2: any;
  10080. /** Defines if astc texture compression is supported */
  10081. astc: any;
  10082. /** Defines if float textures are supported */
  10083. textureFloat: boolean;
  10084. /** Defines if vertex array objects are supported */
  10085. vertexArrayObject: boolean;
  10086. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10087. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10088. /** Gets the maximum level of anisotropy supported */
  10089. maxAnisotropy: number;
  10090. /** Defines if instancing is supported */
  10091. instancedArrays: boolean;
  10092. /** Defines if 32 bits indices are supported */
  10093. uintIndices: boolean;
  10094. /** Defines if high precision shaders are supported */
  10095. highPrecisionShaderSupported: boolean;
  10096. /** Defines if depth reading in the fragment shader is supported */
  10097. fragmentDepthSupported: boolean;
  10098. /** Defines if float texture linear filtering is supported*/
  10099. textureFloatLinearFiltering: boolean;
  10100. /** Defines if rendering to float textures is supported */
  10101. textureFloatRender: boolean;
  10102. /** Defines if half float textures are supported*/
  10103. textureHalfFloat: boolean;
  10104. /** Defines if half float texture linear filtering is supported*/
  10105. textureHalfFloatLinearFiltering: boolean;
  10106. /** Defines if rendering to half float textures is supported */
  10107. textureHalfFloatRender: boolean;
  10108. /** Defines if textureLOD shader command is supported */
  10109. textureLOD: boolean;
  10110. /** Defines if draw buffers extension is supported */
  10111. drawBuffersExtension: boolean;
  10112. /** Defines if depth textures are supported */
  10113. depthTextureExtension: boolean;
  10114. /** Defines if float color buffer are supported */
  10115. colorBufferFloat: boolean;
  10116. /** Gets disjoint timer query extension (null if not supported) */
  10117. timerQuery: EXT_disjoint_timer_query;
  10118. /** Defines if timestamp can be used with timer query */
  10119. canUseTimestampForTimerQuery: boolean;
  10120. /** Function used to let the system compiles shaders in background */
  10121. parallelShaderCompile: {
  10122. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10123. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10124. COMPLETION_STATUS_KHR: number;
  10125. };
  10126. }
  10127. /** Interface defining initialization parameters for Engine class */
  10128. interface EngineOptions extends WebGLContextAttributes {
  10129. /**
  10130. * Defines if the engine should no exceed a specified device ratio
  10131. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10132. */
  10133. limitDeviceRatio?: number;
  10134. /**
  10135. * Defines if webvr should be enabled automatically
  10136. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10137. */
  10138. autoEnableWebVR?: boolean;
  10139. /**
  10140. * Defines if webgl2 should be turned off even if supported
  10141. * @see http://doc.babylonjs.com/features/webgl2
  10142. */
  10143. disableWebGL2Support?: boolean;
  10144. /**
  10145. * Defines if webaudio should be initialized as well
  10146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10147. */
  10148. audioEngine?: boolean;
  10149. /**
  10150. * Defines if animations should run using a deterministic lock step
  10151. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10152. */
  10153. deterministicLockstep?: boolean;
  10154. /** Defines the maximum steps to use with deterministic lock step mode */
  10155. lockstepMaxSteps?: number;
  10156. /**
  10157. * Defines that engine should ignore context lost events
  10158. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10159. */
  10160. doNotHandleContextLost?: boolean;
  10161. /**
  10162. * Defines that engine should ignore modifying touch action attribute and style
  10163. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  10164. */
  10165. doNotHandleTouchAction?: boolean;
  10166. }
  10167. /**
  10168. * Defines the interface used by display changed events
  10169. */
  10170. interface IDisplayChangedEventArgs {
  10171. /** Gets the vrDisplay object (if any) */
  10172. vrDisplay: Nullable<any>;
  10173. /** Gets a boolean indicating if webVR is supported */
  10174. vrSupported: boolean;
  10175. }
  10176. /**
  10177. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10178. */
  10179. class Engine {
  10180. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10181. static ExceptionList: ({
  10182. key: string;
  10183. capture: string;
  10184. captureConstraint: number;
  10185. targets: string[];
  10186. } | {
  10187. key: string;
  10188. capture: null;
  10189. captureConstraint: null;
  10190. targets: string[];
  10191. })[];
  10192. /** Gets the list of created engines */
  10193. static Instances: Engine[];
  10194. /**
  10195. * Gets the latest created engine
  10196. */
  10197. static readonly LastCreatedEngine: Nullable<Engine>;
  10198. /**
  10199. * Gets the latest created scene
  10200. */
  10201. static readonly LastCreatedScene: Nullable<Scene>;
  10202. /**
  10203. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10204. * @param flag defines which part of the materials must be marked as dirty
  10205. * @param predicate defines a predicate used to filter which materials should be affected
  10206. */
  10207. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10208. /**
  10209. * Hidden
  10210. */
  10211. static _TextureLoaders: IInternalTextureLoader[];
  10212. /** Defines that alpha blending is disabled */
  10213. static readonly ALPHA_DISABLE: number;
  10214. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10215. static readonly ALPHA_ADD: number;
  10216. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10217. static readonly ALPHA_COMBINE: number;
  10218. /** Defines that alpha blending to DEST - SRC * DEST */
  10219. static readonly ALPHA_SUBTRACT: number;
  10220. /** Defines that alpha blending to SRC * DEST */
  10221. static readonly ALPHA_MULTIPLY: number;
  10222. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10223. static readonly ALPHA_MAXIMIZED: number;
  10224. /** Defines that alpha blending to SRC + DEST */
  10225. static readonly ALPHA_ONEONE: number;
  10226. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10227. static readonly ALPHA_PREMULTIPLIED: number;
  10228. /**
  10229. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10230. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10231. */
  10232. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10233. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10234. static readonly ALPHA_INTERPOLATE: number;
  10235. /**
  10236. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10237. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10238. */
  10239. static readonly ALPHA_SCREENMODE: number;
  10240. /** Defines that the ressource is not delayed*/
  10241. static readonly DELAYLOADSTATE_NONE: number;
  10242. /** Defines that the ressource was successfully delay loaded */
  10243. static readonly DELAYLOADSTATE_LOADED: number;
  10244. /** Defines that the ressource is currently delay loading */
  10245. static readonly DELAYLOADSTATE_LOADING: number;
  10246. /** Defines that the ressource is delayed and has not started loading */
  10247. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10249. static readonly NEVER: number;
  10250. /** 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 */
  10251. static readonly ALWAYS: number;
  10252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10253. static readonly LESS: number;
  10254. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10255. static readonly EQUAL: number;
  10256. /** 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 */
  10257. static readonly LEQUAL: number;
  10258. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10259. static readonly GREATER: number;
  10260. /** 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 */
  10261. static readonly GEQUAL: number;
  10262. /** 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 */
  10263. static readonly NOTEQUAL: number;
  10264. /** Passed to stencilOperation to specify that stencil value must be kept */
  10265. static readonly KEEP: number;
  10266. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10267. static readonly REPLACE: number;
  10268. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10269. static readonly INCR: number;
  10270. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10271. static readonly DECR: number;
  10272. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10273. static readonly INVERT: number;
  10274. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10275. static readonly INCR_WRAP: number;
  10276. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10277. static readonly DECR_WRAP: number;
  10278. /** Texture is not repeating outside of 0..1 UVs */
  10279. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10280. /** Texture is repeating outside of 0..1 UVs */
  10281. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10282. /** Texture is repeating and mirrored */
  10283. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10284. /** ALPHA */
  10285. static readonly TEXTUREFORMAT_ALPHA: number;
  10286. /** LUMINANCE */
  10287. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10288. /** LUMINANCE_ALPHA */
  10289. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10290. /** RGB */
  10291. static readonly TEXTUREFORMAT_RGB: number;
  10292. /** RGBA */
  10293. static readonly TEXTUREFORMAT_RGBA: number;
  10294. /** RED */
  10295. static readonly TEXTUREFORMAT_RED: number;
  10296. /** RED (2nd reference) */
  10297. static readonly TEXTUREFORMAT_R: number;
  10298. /** RG */
  10299. static readonly TEXTUREFORMAT_RG: number;
  10300. /** RED_INTEGER */
  10301. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10302. /** RED_INTEGER (2nd reference) */
  10303. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10304. /** RG_INTEGER */
  10305. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10306. /** RGB_INTEGER */
  10307. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10308. /** RGBA_INTEGER */
  10309. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10310. /** UNSIGNED_BYTE */
  10311. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10312. /** UNSIGNED_BYTE (2nd reference) */
  10313. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10314. /** FLOAT */
  10315. static readonly TEXTURETYPE_FLOAT: number;
  10316. /** HALF_FLOAT */
  10317. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10318. /** BYTE */
  10319. static readonly TEXTURETYPE_BYTE: number;
  10320. /** SHORT */
  10321. static readonly TEXTURETYPE_SHORT: number;
  10322. /** UNSIGNED_SHORT */
  10323. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10324. /** INT */
  10325. static readonly TEXTURETYPE_INT: number;
  10326. /** UNSIGNED_INT */
  10327. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10328. /** UNSIGNED_SHORT_4_4_4_4 */
  10329. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10330. /** UNSIGNED_SHORT_5_5_5_1 */
  10331. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10332. /** UNSIGNED_SHORT_5_6_5 */
  10333. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10334. /** UNSIGNED_INT_2_10_10_10_REV */
  10335. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10336. /** UNSIGNED_INT_24_8 */
  10337. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10338. /** UNSIGNED_INT_10F_11F_11F_REV */
  10339. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10340. /** UNSIGNED_INT_5_9_9_9_REV */
  10341. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10342. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10343. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10344. /** nearest is mag = nearest and min = nearest and mip = linear */
  10345. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10346. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10347. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10348. /** Trilinear is mag = linear and min = linear and mip = linear */
  10349. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10350. /** nearest is mag = nearest and min = nearest and mip = linear */
  10351. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10352. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10353. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10354. /** Trilinear is mag = linear and min = linear and mip = linear */
  10355. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10356. /** mag = nearest and min = nearest and mip = nearest */
  10357. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10358. /** mag = nearest and min = linear and mip = nearest */
  10359. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10360. /** mag = nearest and min = linear and mip = linear */
  10361. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10362. /** mag = nearest and min = linear and mip = none */
  10363. static readonly TEXTURE_NEAREST_LINEAR: number;
  10364. /** mag = nearest and min = nearest and mip = none */
  10365. static readonly TEXTURE_NEAREST_NEAREST: number;
  10366. /** mag = linear and min = nearest and mip = nearest */
  10367. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10368. /** mag = linear and min = nearest and mip = linear */
  10369. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10370. /** mag = linear and min = linear and mip = none */
  10371. static readonly TEXTURE_LINEAR_LINEAR: number;
  10372. /** mag = linear and min = nearest and mip = none */
  10373. static readonly TEXTURE_LINEAR_NEAREST: number;
  10374. /** Explicit coordinates mode */
  10375. static readonly TEXTURE_EXPLICIT_MODE: number;
  10376. /** Spherical coordinates mode */
  10377. static readonly TEXTURE_SPHERICAL_MODE: number;
  10378. /** Planar coordinates mode */
  10379. static readonly TEXTURE_PLANAR_MODE: number;
  10380. /** Cubic coordinates mode */
  10381. static readonly TEXTURE_CUBIC_MODE: number;
  10382. /** Projection coordinates mode */
  10383. static readonly TEXTURE_PROJECTION_MODE: number;
  10384. /** Skybox coordinates mode */
  10385. static readonly TEXTURE_SKYBOX_MODE: number;
  10386. /** Inverse Cubic coordinates mode */
  10387. static readonly TEXTURE_INVCUBIC_MODE: number;
  10388. /** Equirectangular coordinates mode */
  10389. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10390. /** Equirectangular Fixed coordinates mode */
  10391. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10392. /** Equirectangular Fixed Mirrored coordinates mode */
  10393. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10394. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10395. static readonly SCALEMODE_FLOOR: number;
  10396. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10397. static readonly SCALEMODE_NEAREST: number;
  10398. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10399. static readonly SCALEMODE_CEILING: number;
  10400. /**
  10401. * Returns the current version of the framework
  10402. */
  10403. static readonly Version: string;
  10404. /**
  10405. * Returns a string describing the current engine
  10406. */
  10407. readonly description: string;
  10408. /**
  10409. * Gets or sets the epsilon value used by collision engine
  10410. */
  10411. static CollisionsEpsilon: number;
  10412. /**
  10413. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10414. */
  10415. static CodeRepository: string;
  10416. /**
  10417. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10418. */
  10419. static ShadersRepository: string;
  10420. /**
  10421. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10422. */
  10423. forcePOTTextures: boolean;
  10424. /**
  10425. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10426. */
  10427. isFullscreen: boolean;
  10428. /**
  10429. * Gets a boolean indicating if the pointer is currently locked
  10430. */
  10431. isPointerLock: boolean;
  10432. /**
  10433. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10434. */
  10435. cullBackFaces: boolean;
  10436. /**
  10437. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10438. */
  10439. renderEvenInBackground: boolean;
  10440. /**
  10441. * Gets or sets a boolean indicating that cache can be kept between frames
  10442. */
  10443. preventCacheWipeBetweenFrames: boolean;
  10444. /**
  10445. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10446. **/
  10447. enableOfflineSupport: boolean;
  10448. /**
  10449. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10450. **/
  10451. disableManifestCheck: boolean;
  10452. /**
  10453. * Gets the list of created scenes
  10454. */
  10455. scenes: Scene[];
  10456. /**
  10457. * Event raised when a new scene is created
  10458. */
  10459. onNewSceneAddedObservable: Observable<Scene>;
  10460. /**
  10461. * Gets the list of created postprocesses
  10462. */
  10463. postProcesses: PostProcess[];
  10464. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10465. validateShaderPrograms: boolean;
  10466. /**
  10467. * Observable event triggered each time the rendering canvas is resized
  10468. */
  10469. onResizeObservable: Observable<Engine>;
  10470. /**
  10471. * Observable event triggered each time the canvas loses focus
  10472. */
  10473. onCanvasBlurObservable: Observable<Engine>;
  10474. /**
  10475. * Observable event triggered each time the canvas gains focus
  10476. */
  10477. onCanvasFocusObservable: Observable<Engine>;
  10478. /**
  10479. * Observable event triggered each time the canvas receives pointerout event
  10480. */
  10481. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10482. /**
  10483. * Observable event triggered before each texture is initialized
  10484. */
  10485. onBeforeTextureInitObservable: Observable<Texture>;
  10486. private _vrDisplay;
  10487. private _vrSupported;
  10488. private _oldSize;
  10489. private _oldHardwareScaleFactor;
  10490. private _vrExclusivePointerMode;
  10491. private _webVRInitPromise;
  10492. /**
  10493. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10494. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10495. */
  10496. readonly isInVRExclusivePointerMode: boolean;
  10497. /**
  10498. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10499. */
  10500. disableUniformBuffers: boolean;
  10501. /** @hidden */
  10502. _uniformBuffers: UniformBuffer[];
  10503. /**
  10504. * Gets a boolean indicating that the engine supports uniform buffers
  10505. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10506. */
  10507. readonly supportsUniformBuffers: boolean;
  10508. /**
  10509. * Observable raised when the engine begins a new frame
  10510. */
  10511. onBeginFrameObservable: Observable<Engine>;
  10512. /**
  10513. * If set, will be used to request the next animation frame for the render loop
  10514. */
  10515. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10516. /**
  10517. * Observable raised when the engine ends the current frame
  10518. */
  10519. onEndFrameObservable: Observable<Engine>;
  10520. /**
  10521. * Observable raised when the engine is about to compile a shader
  10522. */
  10523. onBeforeShaderCompilationObservable: Observable<Engine>;
  10524. /**
  10525. * Observable raised when the engine has jsut compiled a shader
  10526. */
  10527. onAfterShaderCompilationObservable: Observable<Engine>;
  10528. /** @hidden */
  10529. _gl: WebGLRenderingContext;
  10530. private _renderingCanvas;
  10531. private _windowIsBackground;
  10532. private _webGLVersion;
  10533. /**
  10534. * Gets a boolean indicating that only power of 2 textures are supported
  10535. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10536. */
  10537. readonly needPOTTextures: boolean;
  10538. /** @hidden */
  10539. _badOS: boolean;
  10540. /** @hidden */
  10541. _badDesktopOS: boolean;
  10542. /**
  10543. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10544. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10545. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10546. */
  10547. disableTextureBindingOptimization: boolean;
  10548. /**
  10549. * Gets the audio engine
  10550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10551. * @ignorenaming
  10552. */
  10553. static audioEngine: IAudioEngine;
  10554. /**
  10555. * Default AudioEngine factory responsible of creating the Audio Engine.
  10556. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10557. */
  10558. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10559. /**
  10560. * Default offline support factory responsible of creating a tool used to store data locally.
  10561. * By default, this will create a Database object if the workload has been embedded.
  10562. */
  10563. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10564. private _onFocus;
  10565. private _onBlur;
  10566. private _onCanvasPointerOut;
  10567. private _onCanvasBlur;
  10568. private _onCanvasFocus;
  10569. private _onFullscreenChange;
  10570. private _onPointerLockChange;
  10571. private _onVRDisplayPointerRestricted;
  10572. private _onVRDisplayPointerUnrestricted;
  10573. private _onVrDisplayConnect;
  10574. private _onVrDisplayDisconnect;
  10575. private _onVrDisplayPresentChange;
  10576. /**
  10577. * Observable signaled when VR display mode changes
  10578. */
  10579. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10580. /**
  10581. * Observable signaled when VR request present is complete
  10582. */
  10583. onVRRequestPresentComplete: Observable<boolean>;
  10584. /**
  10585. * Observable signaled when VR request present starts
  10586. */
  10587. onVRRequestPresentStart: Observable<Engine>;
  10588. private _hardwareScalingLevel;
  10589. /** @hidden */
  10590. protected _caps: EngineCapabilities;
  10591. private _pointerLockRequested;
  10592. private _isStencilEnable;
  10593. private _colorWrite;
  10594. private _loadingScreen;
  10595. /** @hidden */
  10596. _drawCalls: PerfCounter;
  10597. /** @hidden */
  10598. _textureCollisions: PerfCounter;
  10599. private _glVersion;
  10600. private _glRenderer;
  10601. private _glVendor;
  10602. private _videoTextureSupported;
  10603. private _renderingQueueLaunched;
  10604. private _activeRenderLoops;
  10605. private _deterministicLockstep;
  10606. private _lockstepMaxSteps;
  10607. /**
  10608. * Observable signaled when a context lost event is raised
  10609. */
  10610. onContextLostObservable: Observable<Engine>;
  10611. /**
  10612. * Observable signaled when a context restored event is raised
  10613. */
  10614. onContextRestoredObservable: Observable<Engine>;
  10615. private _onContextLost;
  10616. private _onContextRestored;
  10617. private _contextWasLost;
  10618. private _doNotHandleContextLost;
  10619. /**
  10620. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10622. */
  10623. doNotHandleContextLost: boolean;
  10624. private _performanceMonitor;
  10625. private _fps;
  10626. private _deltaTime;
  10627. /**
  10628. * Turn this value on if you want to pause FPS computation when in background
  10629. */
  10630. disablePerformanceMonitorInBackground: boolean;
  10631. /**
  10632. * Gets the performance monitor attached to this engine
  10633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10634. */
  10635. readonly performanceMonitor: PerformanceMonitor;
  10636. /** @hidden */
  10637. protected _depthCullingState: _DepthCullingState;
  10638. /** @hidden */
  10639. protected _stencilState: _StencilState;
  10640. /** @hidden */
  10641. protected _alphaState: _AlphaState;
  10642. /** @hidden */
  10643. protected _alphaMode: number;
  10644. protected _internalTexturesCache: InternalTexture[];
  10645. /** @hidden */
  10646. protected _activeChannel: number;
  10647. private _currentTextureChannel;
  10648. /** @hidden */
  10649. protected _boundTexturesCache: {
  10650. [key: string]: Nullable<InternalTexture>;
  10651. };
  10652. /** @hidden */
  10653. protected _currentEffect: Nullable<Effect>;
  10654. /** @hidden */
  10655. protected _currentProgram: Nullable<WebGLProgram>;
  10656. private _compiledEffects;
  10657. private _vertexAttribArraysEnabled;
  10658. /** @hidden */
  10659. protected _cachedViewport: Nullable<Viewport>;
  10660. private _cachedVertexArrayObject;
  10661. /** @hidden */
  10662. protected _cachedVertexBuffers: any;
  10663. /** @hidden */
  10664. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10665. /** @hidden */
  10666. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10667. /** @hidden */
  10668. protected _currentRenderTarget: Nullable<InternalTexture>;
  10669. private _uintIndicesCurrentlySet;
  10670. private _currentBoundBuffer;
  10671. /** @hidden */
  10672. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10673. private _currentBufferPointers;
  10674. private _currentInstanceLocations;
  10675. private _currentInstanceBuffers;
  10676. private _textureUnits;
  10677. private _firstBoundInternalTextureTracker;
  10678. private _lastBoundInternalTextureTracker;
  10679. private _workingCanvas;
  10680. private _workingContext;
  10681. private _rescalePostProcess;
  10682. private _dummyFramebuffer;
  10683. private _externalData;
  10684. private _bindedRenderFunction;
  10685. private _vaoRecordInProgress;
  10686. private _mustWipeVertexAttributes;
  10687. private _emptyTexture;
  10688. private _emptyCubeTexture;
  10689. private _emptyTexture3D;
  10690. /** @hidden */
  10691. _frameHandler: number;
  10692. private _nextFreeTextureSlots;
  10693. private _maxSimultaneousTextures;
  10694. private _activeRequests;
  10695. private _texturesSupported;
  10696. private _textureFormatInUse;
  10697. /**
  10698. * Gets the list of texture formats supported
  10699. */
  10700. readonly texturesSupported: Array<string>;
  10701. /**
  10702. * Gets the list of texture formats in use
  10703. */
  10704. readonly textureFormatInUse: Nullable<string>;
  10705. /**
  10706. * Gets the current viewport
  10707. */
  10708. readonly currentViewport: Nullable<Viewport>;
  10709. /**
  10710. * Gets the default empty texture
  10711. */
  10712. readonly emptyTexture: InternalTexture;
  10713. /**
  10714. * Gets the default empty 3D texture
  10715. */
  10716. readonly emptyTexture3D: InternalTexture;
  10717. /**
  10718. * Gets the default empty cube texture
  10719. */
  10720. readonly emptyCubeTexture: InternalTexture;
  10721. /**
  10722. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10723. */
  10724. readonly premultipliedAlpha: boolean;
  10725. /**
  10726. * Creates a new engine
  10727. * @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
  10728. * @param antialias defines enable antialiasing (default: false)
  10729. * @param options defines further options to be sent to the getContext() function
  10730. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10731. */
  10732. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10733. private _disableTouchAction;
  10734. private _rebuildInternalTextures;
  10735. private _rebuildEffects;
  10736. /**
  10737. * Gets a boolean indicating if all created effects are ready
  10738. * @returns true if all effects are ready
  10739. */
  10740. areAllEffectsReady(): boolean;
  10741. private _rebuildBuffers;
  10742. private _initGLContext;
  10743. /**
  10744. * Gets version of the current webGL context
  10745. */
  10746. readonly webGLVersion: number;
  10747. /**
  10748. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10749. */
  10750. readonly isStencilEnable: boolean;
  10751. private _prepareWorkingCanvas;
  10752. /**
  10753. * Reset the texture cache to empty state
  10754. */
  10755. resetTextureCache(): void;
  10756. /**
  10757. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10759. * @returns true if engine is in deterministic lock step mode
  10760. */
  10761. isDeterministicLockStep(): boolean;
  10762. /**
  10763. * Gets the max steps when engine is running in deterministic lock step
  10764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10765. * @returns the max steps
  10766. */
  10767. getLockstepMaxSteps(): number;
  10768. /**
  10769. * Gets an object containing information about the current webGL context
  10770. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10771. */
  10772. getGlInfo(): {
  10773. vendor: string;
  10774. renderer: string;
  10775. version: string;
  10776. };
  10777. /**
  10778. * Gets current aspect ratio
  10779. * @param camera defines the camera to use to get the aspect ratio
  10780. * @param useScreen defines if screen size must be used (or the current render target if any)
  10781. * @returns a number defining the aspect ratio
  10782. */
  10783. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10784. /**
  10785. * Gets current screen aspect ratio
  10786. * @returns a number defining the aspect ratio
  10787. */
  10788. getScreenAspectRatio(): number;
  10789. /**
  10790. * Gets the current render width
  10791. * @param useScreen defines if screen size must be used (or the current render target if any)
  10792. * @returns a number defining the current render width
  10793. */
  10794. getRenderWidth(useScreen?: boolean): number;
  10795. /**
  10796. * Gets the current render height
  10797. * @param useScreen defines if screen size must be used (or the current render target if any)
  10798. * @returns a number defining the current render height
  10799. */
  10800. getRenderHeight(useScreen?: boolean): number;
  10801. /**
  10802. * Gets the HTML canvas attached with the current webGL context
  10803. * @returns a HTML canvas
  10804. */
  10805. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10806. /**
  10807. * Gets the client rect of the HTML canvas attached with the current webGL context
  10808. * @returns a client rectanglee
  10809. */
  10810. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10811. /**
  10812. * Defines the hardware scaling level.
  10813. * By default the hardware scaling level is computed from the window device ratio.
  10814. * 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.
  10815. * @param level defines the level to use
  10816. */
  10817. setHardwareScalingLevel(level: number): void;
  10818. /**
  10819. * Gets the current hardware scaling level.
  10820. * By default the hardware scaling level is computed from the window device ratio.
  10821. * 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.
  10822. * @returns a number indicating the current hardware scaling level
  10823. */
  10824. getHardwareScalingLevel(): number;
  10825. /**
  10826. * Gets the list of loaded textures
  10827. * @returns an array containing all loaded textures
  10828. */
  10829. getLoadedTexturesCache(): InternalTexture[];
  10830. /**
  10831. * Gets the object containing all engine capabilities
  10832. * @returns the EngineCapabilities object
  10833. */
  10834. getCaps(): EngineCapabilities;
  10835. /**
  10836. * Gets the current depth function
  10837. * @returns a number defining the depth function
  10838. */
  10839. getDepthFunction(): Nullable<number>;
  10840. /**
  10841. * Sets the current depth function
  10842. * @param depthFunc defines the function to use
  10843. */
  10844. setDepthFunction(depthFunc: number): void;
  10845. /**
  10846. * Sets the current depth function to GREATER
  10847. */
  10848. setDepthFunctionToGreater(): void;
  10849. /**
  10850. * Sets the current depth function to GEQUAL
  10851. */
  10852. setDepthFunctionToGreaterOrEqual(): void;
  10853. /**
  10854. * Sets the current depth function to LESS
  10855. */
  10856. setDepthFunctionToLess(): void;
  10857. /**
  10858. * Sets the current depth function to LEQUAL
  10859. */
  10860. setDepthFunctionToLessOrEqual(): void;
  10861. /**
  10862. * Gets a boolean indicating if stencil buffer is enabled
  10863. * @returns the current stencil buffer state
  10864. */
  10865. getStencilBuffer(): boolean;
  10866. /**
  10867. * Enable or disable the stencil buffer
  10868. * @param enable defines if the stencil buffer must be enabled or disabled
  10869. */
  10870. setStencilBuffer(enable: boolean): void;
  10871. /**
  10872. * Gets the current stencil mask
  10873. * @returns a number defining the new stencil mask to use
  10874. */
  10875. getStencilMask(): number;
  10876. /**
  10877. * Sets the current stencil mask
  10878. * @param mask defines the new stencil mask to use
  10879. */
  10880. setStencilMask(mask: number): void;
  10881. /**
  10882. * Gets the current stencil function
  10883. * @returns a number defining the stencil function to use
  10884. */
  10885. getStencilFunction(): number;
  10886. /**
  10887. * Gets the current stencil reference value
  10888. * @returns a number defining the stencil reference value to use
  10889. */
  10890. getStencilFunctionReference(): number;
  10891. /**
  10892. * Gets the current stencil mask
  10893. * @returns a number defining the stencil mask to use
  10894. */
  10895. getStencilFunctionMask(): number;
  10896. /**
  10897. * Sets the current stencil function
  10898. * @param stencilFunc defines the new stencil function to use
  10899. */
  10900. setStencilFunction(stencilFunc: number): void;
  10901. /**
  10902. * Sets the current stencil reference
  10903. * @param reference defines the new stencil reference to use
  10904. */
  10905. setStencilFunctionReference(reference: number): void;
  10906. /**
  10907. * Sets the current stencil mask
  10908. * @param mask defines the new stencil mask to use
  10909. */
  10910. setStencilFunctionMask(mask: number): void;
  10911. /**
  10912. * Gets the current stencil operation when stencil fails
  10913. * @returns a number defining stencil operation to use when stencil fails
  10914. */
  10915. getStencilOperationFail(): number;
  10916. /**
  10917. * Gets the current stencil operation when depth fails
  10918. * @returns a number defining stencil operation to use when depth fails
  10919. */
  10920. getStencilOperationDepthFail(): number;
  10921. /**
  10922. * Gets the current stencil operation when stencil passes
  10923. * @returns a number defining stencil operation to use when stencil passes
  10924. */
  10925. getStencilOperationPass(): number;
  10926. /**
  10927. * Sets the stencil operation to use when stencil fails
  10928. * @param operation defines the stencil operation to use when stencil fails
  10929. */
  10930. setStencilOperationFail(operation: number): void;
  10931. /**
  10932. * Sets the stencil operation to use when depth fails
  10933. * @param operation defines the stencil operation to use when depth fails
  10934. */
  10935. setStencilOperationDepthFail(operation: number): void;
  10936. /**
  10937. * Sets the stencil operation to use when stencil passes
  10938. * @param operation defines the stencil operation to use when stencil passes
  10939. */
  10940. setStencilOperationPass(operation: number): void;
  10941. /**
  10942. * Sets a boolean indicating if the dithering state is enabled or disabled
  10943. * @param value defines the dithering state
  10944. */
  10945. setDitheringState(value: boolean): void;
  10946. /**
  10947. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10948. * @param value defines the rasterizer state
  10949. */
  10950. setRasterizerState(value: boolean): void;
  10951. /**
  10952. * stop executing a render loop function and remove it from the execution array
  10953. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10954. */
  10955. stopRenderLoop(renderFunction?: () => void): void;
  10956. /** @hidden */
  10957. _renderLoop(): void;
  10958. /**
  10959. * Register and execute a render loop. The engine can have more than one render function
  10960. * @param renderFunction defines the function to continuously execute
  10961. */
  10962. runRenderLoop(renderFunction: () => void): void;
  10963. /**
  10964. * Toggle full screen mode
  10965. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10966. */
  10967. switchFullscreen(requestPointerLock: boolean): void;
  10968. /**
  10969. * Clear the current render buffer or the current render target (if any is set up)
  10970. * @param color defines the color to use
  10971. * @param backBuffer defines if the back buffer must be cleared
  10972. * @param depth defines if the depth buffer must be cleared
  10973. * @param stencil defines if the stencil buffer must be cleared
  10974. */
  10975. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10976. /**
  10977. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10978. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10979. * @param y defines the y-coordinate of the corner of the clear rectangle
  10980. * @param width defines the width of the clear rectangle
  10981. * @param height defines the height of the clear rectangle
  10982. * @param clearColor defines the clear color
  10983. */
  10984. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10985. /**
  10986. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  10987. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10988. * @param y defines the y-coordinate of the corner of the clear rectangle
  10989. * @param width defines the width of the clear rectangle
  10990. * @param height defines the height of the clear rectangle
  10991. */
  10992. enableScissor(x: number, y: number, width: number, height: number): void;
  10993. /**
  10994. * Disable previously set scissor test rectangle
  10995. */
  10996. disableScissor(): void;
  10997. private _viewportCached;
  10998. /** @hidden */
  10999. _viewport(x: number, y: number, width: number, height: number): void;
  11000. /**
  11001. * Set the WebGL's viewport
  11002. * @param viewport defines the viewport element to be used
  11003. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  11004. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  11005. */
  11006. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11007. /**
  11008. * Directly set the WebGL Viewport
  11009. * @param x defines the x coordinate of the viewport (in screen space)
  11010. * @param y defines the y coordinate of the viewport (in screen space)
  11011. * @param width defines the width of the viewport (in screen space)
  11012. * @param height defines the height of the viewport (in screen space)
  11013. * @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
  11014. */
  11015. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  11016. /**
  11017. * Begin a new frame
  11018. */
  11019. beginFrame(): void;
  11020. /**
  11021. * Enf the current frame
  11022. */
  11023. endFrame(): void;
  11024. /**
  11025. * Resize the view according to the canvas' size
  11026. */
  11027. resize(): void;
  11028. /**
  11029. * Force a specific size of the canvas
  11030. * @param width defines the new canvas' width
  11031. * @param height defines the new canvas' height
  11032. */
  11033. setSize(width: number, height: number): void;
  11034. /**
  11035. * Gets a boolean indicating if a webVR device was detected
  11036. * @returns true if a webVR device was detected
  11037. */
  11038. isVRDevicePresent(): boolean;
  11039. /**
  11040. * Gets the current webVR device
  11041. * @returns the current webVR device (or null)
  11042. */
  11043. getVRDevice(): any;
  11044. /**
  11045. * Initializes a webVR display and starts listening to display change events
  11046. * The onVRDisplayChangedObservable will be notified upon these changes
  11047. * @returns The onVRDisplayChangedObservable
  11048. */
  11049. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11050. /**
  11051. * Initializes a webVR display and starts listening to display change events
  11052. * The onVRDisplayChangedObservable will be notified upon these changes
  11053. * @returns A promise containing a VRDisplay and if vr is supported
  11054. */
  11055. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11056. /**
  11057. * Call this function to switch to webVR mode
  11058. * Will do nothing if webVR is not supported or if there is no webVR device
  11059. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11060. */
  11061. enableVR(): void;
  11062. /**
  11063. * Call this function to leave webVR mode
  11064. * Will do nothing if webVR is not supported or if there is no webVR device
  11065. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11066. */
  11067. disableVR(): void;
  11068. private _onVRFullScreenTriggered;
  11069. private _getVRDisplaysAsync;
  11070. /**
  11071. * Binds the frame buffer to the specified texture.
  11072. * @param texture The texture to render to or null for the default canvas
  11073. * @param faceIndex The face of the texture to render to in case of cube texture
  11074. * @param requiredWidth The width of the target to render to
  11075. * @param requiredHeight The height of the target to render to
  11076. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11077. * @param depthStencilTexture The depth stencil texture to use to render
  11078. * @param lodLevel defines le lod level to bind to the frame buffer
  11079. */
  11080. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11081. private bindUnboundFramebuffer;
  11082. /**
  11083. * Unbind the current render target texture from the webGL context
  11084. * @param texture defines the render target texture to unbind
  11085. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11086. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11087. */
  11088. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11089. /**
  11090. * Unbind a list of render target textures from the webGL context
  11091. * This is used only when drawBuffer extension or webGL2 are active
  11092. * @param textures defines the render target textures to unbind
  11093. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11094. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11095. */
  11096. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11097. /**
  11098. * Force the mipmap generation for the given render target texture
  11099. * @param texture defines the render target texture to use
  11100. */
  11101. generateMipMapsForCubemap(texture: InternalTexture): void;
  11102. /**
  11103. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11104. */
  11105. flushFramebuffer(): void;
  11106. /**
  11107. * Unbind the current render target and bind the default framebuffer
  11108. */
  11109. restoreDefaultFramebuffer(): void;
  11110. /**
  11111. * Create an uniform buffer
  11112. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11113. * @param elements defines the content of the uniform buffer
  11114. * @returns the webGL uniform buffer
  11115. */
  11116. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11117. /**
  11118. * Create a dynamic uniform buffer
  11119. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11120. * @param elements defines the content of the uniform buffer
  11121. * @returns the webGL uniform buffer
  11122. */
  11123. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11124. /**
  11125. * Update an existing uniform buffer
  11126. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11127. * @param uniformBuffer defines the target uniform buffer
  11128. * @param elements defines the content to update
  11129. * @param offset defines the offset in the uniform buffer where update should start
  11130. * @param count defines the size of the data to update
  11131. */
  11132. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11133. private _resetVertexBufferBinding;
  11134. /**
  11135. * Creates a vertex buffer
  11136. * @param data the data for the vertex buffer
  11137. * @returns the new WebGL static buffer
  11138. */
  11139. createVertexBuffer(data: DataArray): WebGLBuffer;
  11140. /**
  11141. * Creates a dynamic vertex buffer
  11142. * @param data the data for the dynamic vertex buffer
  11143. * @returns the new WebGL dynamic buffer
  11144. */
  11145. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11146. /**
  11147. * Update a dynamic index buffer
  11148. * @param indexBuffer defines the target index buffer
  11149. * @param indices defines the data to update
  11150. * @param offset defines the offset in the target index buffer where update should start
  11151. */
  11152. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11153. /**
  11154. * Updates a dynamic vertex buffer.
  11155. * @param vertexBuffer the vertex buffer to update
  11156. * @param data the data used to update the vertex buffer
  11157. * @param byteOffset the byte offset of the data
  11158. * @param byteLength the byte length of the data
  11159. */
  11160. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11161. private _resetIndexBufferBinding;
  11162. /**
  11163. * Creates a new index buffer
  11164. * @param indices defines the content of the index buffer
  11165. * @param updatable defines if the index buffer must be updatable
  11166. * @returns a new webGL buffer
  11167. */
  11168. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11169. /**
  11170. * Bind a webGL buffer to the webGL context
  11171. * @param buffer defines the buffer to bind
  11172. */
  11173. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11174. /**
  11175. * Bind an uniform buffer to the current webGL context
  11176. * @param buffer defines the buffer to bind
  11177. */
  11178. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11179. /**
  11180. * Bind a buffer to the current webGL context at a given location
  11181. * @param buffer defines the buffer to bind
  11182. * @param location defines the index where to bind the buffer
  11183. */
  11184. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11185. /**
  11186. * Bind a specific block at a given index in a specific shader program
  11187. * @param shaderProgram defines the shader program
  11188. * @param blockName defines the block name
  11189. * @param index defines the index where to bind the block
  11190. */
  11191. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11192. private bindIndexBuffer;
  11193. private bindBuffer;
  11194. /**
  11195. * update the bound buffer with the given data
  11196. * @param data defines the data to update
  11197. */
  11198. updateArrayBuffer(data: Float32Array): void;
  11199. private _vertexAttribPointer;
  11200. private _bindIndexBufferWithCache;
  11201. private _bindVertexBuffersAttributes;
  11202. /**
  11203. * Records a vertex array object
  11204. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11205. * @param vertexBuffers defines the list of vertex buffers to store
  11206. * @param indexBuffer defines the index buffer to store
  11207. * @param effect defines the effect to store
  11208. * @returns the new vertex array object
  11209. */
  11210. recordVertexArrayObject(vertexBuffers: {
  11211. [key: string]: VertexBuffer;
  11212. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11213. /**
  11214. * Bind a specific vertex array object
  11215. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11216. * @param vertexArrayObject defines the vertex array object to bind
  11217. * @param indexBuffer defines the index buffer to bind
  11218. */
  11219. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11220. /**
  11221. * Bind webGl buffers directly to the webGL context
  11222. * @param vertexBuffer defines the vertex buffer to bind
  11223. * @param indexBuffer defines the index buffer to bind
  11224. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11225. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11226. * @param effect defines the effect associated with the vertex buffer
  11227. */
  11228. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11229. private _unbindVertexArrayObject;
  11230. /**
  11231. * Bind a list of vertex buffers to the webGL context
  11232. * @param vertexBuffers defines the list of vertex buffers to bind
  11233. * @param indexBuffer defines the index buffer to bind
  11234. * @param effect defines the effect associated with the vertex buffers
  11235. */
  11236. bindBuffers(vertexBuffers: {
  11237. [key: string]: Nullable<VertexBuffer>;
  11238. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11239. /**
  11240. * Unbind all instance attributes
  11241. */
  11242. unbindInstanceAttributes(): void;
  11243. /**
  11244. * Release and free the memory of a vertex array object
  11245. * @param vao defines the vertex array object to delete
  11246. */
  11247. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11248. /** @hidden */
  11249. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11250. /**
  11251. * Creates a webGL buffer to use with instanciation
  11252. * @param capacity defines the size of the buffer
  11253. * @returns the webGL buffer
  11254. */
  11255. createInstancesBuffer(capacity: number): WebGLBuffer;
  11256. /**
  11257. * Delete a webGL buffer used with instanciation
  11258. * @param buffer defines the webGL buffer to delete
  11259. */
  11260. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11261. /**
  11262. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11263. * @param instancesBuffer defines the webGL buffer to update and bind
  11264. * @param data defines the data to store in the buffer
  11265. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11266. */
  11267. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11268. /**
  11269. * Apply all cached states (depth, culling, stencil and alpha)
  11270. */
  11271. applyStates(): void;
  11272. /**
  11273. * Send a draw order
  11274. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11275. * @param indexStart defines the starting index
  11276. * @param indexCount defines the number of index to draw
  11277. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11278. */
  11279. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11280. /**
  11281. * Draw a list of points
  11282. * @param verticesStart defines the index of first vertex to draw
  11283. * @param verticesCount defines the count of vertices to draw
  11284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11285. */
  11286. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11287. /**
  11288. * Draw a list of unindexed primitives
  11289. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11290. * @param verticesStart defines the index of first vertex to draw
  11291. * @param verticesCount defines the count of vertices to draw
  11292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11293. */
  11294. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11295. /**
  11296. * Draw a list of indexed primitives
  11297. * @param fillMode defines the primitive to use
  11298. * @param indexStart defines the starting index
  11299. * @param indexCount defines the number of index to draw
  11300. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11301. */
  11302. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11303. /**
  11304. * Draw a list of unindexed primitives
  11305. * @param fillMode defines the primitive to use
  11306. * @param verticesStart defines the index of first vertex to draw
  11307. * @param verticesCount defines the count of vertices to draw
  11308. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11309. */
  11310. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11311. private _drawMode;
  11312. /** @hidden */
  11313. _releaseEffect(effect: Effect): void;
  11314. /** @hidden */
  11315. _deleteProgram(program: WebGLProgram): void;
  11316. /**
  11317. * Create a new effect (used to store vertex/fragment shaders)
  11318. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11319. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11320. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11321. * @param samplers defines an array of string used to represent textures
  11322. * @param defines defines the string containing the defines to use to compile the shaders
  11323. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11324. * @param onCompiled defines a function to call when the effect creation is successful
  11325. * @param onError defines a function to call when the effect creation has failed
  11326. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11327. * @returns the new Effect
  11328. */
  11329. 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;
  11330. private _compileShader;
  11331. private _compileRawShader;
  11332. /**
  11333. * Directly creates a webGL program
  11334. * @param vertexCode defines the vertex shader code to use
  11335. * @param fragmentCode defines the fragment shader code to use
  11336. * @param context defines the webGL context to use (if not set, the current one will be used)
  11337. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11338. * @returns the new webGL program
  11339. */
  11340. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11341. /**
  11342. * Creates a webGL program
  11343. * @param vertexCode defines the vertex shader code to use
  11344. * @param fragmentCode defines the fragment shader code to use
  11345. * @param defines defines the string containing the defines to use to compile the shaders
  11346. * @param context defines the webGL context to use (if not set, the current one will be used)
  11347. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11348. * @returns the new webGL program
  11349. */
  11350. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11351. private _createShaderProgram;
  11352. private _finalizeProgram;
  11353. /** @hidden */
  11354. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11355. /** @hidden */
  11356. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11357. /**
  11358. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11359. * @param shaderProgram defines the webGL program to use
  11360. * @param uniformsNames defines the list of uniform names
  11361. * @returns an array of webGL uniform locations
  11362. */
  11363. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11364. /**
  11365. * Gets the lsit of active attributes for a given webGL program
  11366. * @param shaderProgram defines the webGL program to use
  11367. * @param attributesNames defines the list of attribute names to get
  11368. * @returns an array of indices indicating the offset of each attribute
  11369. */
  11370. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11371. /**
  11372. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11373. * @param effect defines the effect to activate
  11374. */
  11375. enableEffect(effect: Nullable<Effect>): void;
  11376. /**
  11377. * Set the value of an uniform to an array of int32
  11378. * @param uniform defines the webGL uniform location where to store the value
  11379. * @param array defines the array of int32 to store
  11380. */
  11381. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11382. /**
  11383. * Set the value of an uniform to an array of int32 (stored as vec2)
  11384. * @param uniform defines the webGL uniform location where to store the value
  11385. * @param array defines the array of int32 to store
  11386. */
  11387. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11388. /**
  11389. * Set the value of an uniform to an array of int32 (stored as vec3)
  11390. * @param uniform defines the webGL uniform location where to store the value
  11391. * @param array defines the array of int32 to store
  11392. */
  11393. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11394. /**
  11395. * Set the value of an uniform to an array of int32 (stored as vec4)
  11396. * @param uniform defines the webGL uniform location where to store the value
  11397. * @param array defines the array of int32 to store
  11398. */
  11399. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11400. /**
  11401. * Set the value of an uniform to an array of float32
  11402. * @param uniform defines the webGL uniform location where to store the value
  11403. * @param array defines the array of float32 to store
  11404. */
  11405. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11406. /**
  11407. * Set the value of an uniform to an array of float32 (stored as vec2)
  11408. * @param uniform defines the webGL uniform location where to store the value
  11409. * @param array defines the array of float32 to store
  11410. */
  11411. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11412. /**
  11413. * Set the value of an uniform to an array of float32 (stored as vec3)
  11414. * @param uniform defines the webGL uniform location where to store the value
  11415. * @param array defines the array of float32 to store
  11416. */
  11417. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11418. /**
  11419. * Set the value of an uniform to an array of float32 (stored as vec4)
  11420. * @param uniform defines the webGL uniform location where to store the value
  11421. * @param array defines the array of float32 to store
  11422. */
  11423. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11424. /**
  11425. * Set the value of an uniform to an array of number
  11426. * @param uniform defines the webGL uniform location where to store the value
  11427. * @param array defines the array of number to store
  11428. */
  11429. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11430. /**
  11431. * Set the value of an uniform to an array of number (stored as vec2)
  11432. * @param uniform defines the webGL uniform location where to store the value
  11433. * @param array defines the array of number to store
  11434. */
  11435. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11436. /**
  11437. * Set the value of an uniform to an array of number (stored as vec3)
  11438. * @param uniform defines the webGL uniform location where to store the value
  11439. * @param array defines the array of number to store
  11440. */
  11441. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11442. /**
  11443. * Set the value of an uniform to an array of number (stored as vec4)
  11444. * @param uniform defines the webGL uniform location where to store the value
  11445. * @param array defines the array of number to store
  11446. */
  11447. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11448. /**
  11449. * Set the value of an uniform to an array of float32 (stored as matrices)
  11450. * @param uniform defines the webGL uniform location where to store the value
  11451. * @param matrices defines the array of float32 to store
  11452. */
  11453. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11454. /**
  11455. * Set the value of an uniform to a matrix
  11456. * @param uniform defines the webGL uniform location where to store the value
  11457. * @param matrix defines the matrix to store
  11458. */
  11459. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11460. /**
  11461. * Set the value of an uniform to a matrix (3x3)
  11462. * @param uniform defines the webGL uniform location where to store the value
  11463. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11464. */
  11465. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11466. /**
  11467. * Set the value of an uniform to a matrix (2x2)
  11468. * @param uniform defines the webGL uniform location where to store the value
  11469. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11470. */
  11471. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11472. /**
  11473. * Set the value of an uniform to a number (int)
  11474. * @param uniform defines the webGL uniform location where to store the value
  11475. * @param value defines the int number to store
  11476. */
  11477. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11478. /**
  11479. * Set the value of an uniform to a number (float)
  11480. * @param uniform defines the webGL uniform location where to store the value
  11481. * @param value defines the float number to store
  11482. */
  11483. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11484. /**
  11485. * Set the value of an uniform to a vec2
  11486. * @param uniform defines the webGL uniform location where to store the value
  11487. * @param x defines the 1st component of the value
  11488. * @param y defines the 2nd component of the value
  11489. */
  11490. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11491. /**
  11492. * Set the value of an uniform to a vec3
  11493. * @param uniform defines the webGL uniform location where to store the value
  11494. * @param x defines the 1st component of the value
  11495. * @param y defines the 2nd component of the value
  11496. * @param z defines the 3rd component of the value
  11497. */
  11498. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11499. /**
  11500. * Set the value of an uniform to a boolean
  11501. * @param uniform defines the webGL uniform location where to store the value
  11502. * @param bool defines the boolean to store
  11503. */
  11504. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11505. /**
  11506. * Set the value of an uniform to a vec4
  11507. * @param uniform defines the webGL uniform location where to store the value
  11508. * @param x defines the 1st component of the value
  11509. * @param y defines the 2nd component of the value
  11510. * @param z defines the 3rd component of the value
  11511. * @param w defines the 4th component of the value
  11512. */
  11513. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11514. /**
  11515. * Set the value of an uniform to a Color3
  11516. * @param uniform defines the webGL uniform location where to store the value
  11517. * @param color3 defines the color to store
  11518. */
  11519. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11520. /**
  11521. * Set the value of an uniform to a Color3 and an alpha value
  11522. * @param uniform defines the webGL uniform location where to store the value
  11523. * @param color3 defines the color to store
  11524. * @param alpha defines the alpha component to store
  11525. */
  11526. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11527. /**
  11528. * Sets a Color4 on a uniform variable
  11529. * @param uniform defines the uniform location
  11530. * @param color4 defines the value to be set
  11531. */
  11532. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11533. /**
  11534. * Set various states to the webGL context
  11535. * @param culling defines backface culling state
  11536. * @param zOffset defines the value to apply to zOffset (0 by default)
  11537. * @param force defines if states must be applied even if cache is up to date
  11538. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11539. */
  11540. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11541. /**
  11542. * Set the z offset to apply to current rendering
  11543. * @param value defines the offset to apply
  11544. */
  11545. setZOffset(value: number): void;
  11546. /**
  11547. * Gets the current value of the zOffset
  11548. * @returns the current zOffset state
  11549. */
  11550. getZOffset(): number;
  11551. /**
  11552. * Enable or disable depth buffering
  11553. * @param enable defines the state to set
  11554. */
  11555. setDepthBuffer(enable: boolean): void;
  11556. /**
  11557. * Gets a boolean indicating if depth writing is enabled
  11558. * @returns the current depth writing state
  11559. */
  11560. getDepthWrite(): boolean;
  11561. /**
  11562. * Enable or disable depth writing
  11563. * @param enable defines the state to set
  11564. */
  11565. setDepthWrite(enable: boolean): void;
  11566. /**
  11567. * Enable or disable color writing
  11568. * @param enable defines the state to set
  11569. */
  11570. setColorWrite(enable: boolean): void;
  11571. /**
  11572. * Gets a boolean indicating if color writing is enabled
  11573. * @returns the current color writing state
  11574. */
  11575. getColorWrite(): boolean;
  11576. /**
  11577. * Sets alpha constants used by some alpha blending modes
  11578. * @param r defines the red component
  11579. * @param g defines the green component
  11580. * @param b defines the blue component
  11581. * @param a defines the alpha component
  11582. */
  11583. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11584. /**
  11585. * Sets the current alpha mode
  11586. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11587. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11589. */
  11590. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11591. /**
  11592. * Gets the current alpha mode
  11593. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11594. * @returns the current alpha mode
  11595. */
  11596. getAlphaMode(): number;
  11597. /**
  11598. * Clears the list of texture accessible through engine.
  11599. * This can help preventing texture load conflict due to name collision.
  11600. */
  11601. clearInternalTexturesCache(): void;
  11602. /**
  11603. * Force the entire cache to be cleared
  11604. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11605. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11606. */
  11607. wipeCaches(bruteForce?: boolean): void;
  11608. /**
  11609. * Set the compressed texture format to use, based on the formats you have, and the formats
  11610. * supported by the hardware / browser.
  11611. *
  11612. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11613. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11614. * to API arguments needed to compressed textures. This puts the burden on the container
  11615. * generator to house the arcane code for determining these for current & future formats.
  11616. *
  11617. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11618. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11619. *
  11620. * Note: The result of this call is not taken into account when a texture is base64.
  11621. *
  11622. * @param formatsAvailable defines the list of those format families you have created
  11623. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11624. *
  11625. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11626. * @returns The extension selected.
  11627. */
  11628. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11629. private _getSamplingParameters;
  11630. private _partialLoadImg;
  11631. private _cascadeLoadImgs;
  11632. /** @hidden */
  11633. _createTexture(): WebGLTexture;
  11634. /**
  11635. * Usually called from BABYLON.Texture.ts.
  11636. * Passed information to create a WebGLTexture
  11637. * @param urlArg defines a value which contains one of the following:
  11638. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11639. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11640. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11642. * @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)
  11643. * @param scene needed for loading to the correct scene
  11644. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11645. * @param onLoad optional callback to be called upon successful completion
  11646. * @param onError optional callback to be called upon failure
  11647. * @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
  11648. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11649. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11650. * @param forcedExtension defines the extension to use to pick the right loader
  11651. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11652. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11653. */
  11654. 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;
  11655. private _rescaleTexture;
  11656. /**
  11657. * Update a raw texture
  11658. * @param texture defines the texture to update
  11659. * @param data defines the data to store in the texture
  11660. * @param format defines the format of the data
  11661. * @param invertY defines if data must be stored with Y axis inverted
  11662. * @param compression defines the compression used (null by default)
  11663. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11664. */
  11665. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11666. /**
  11667. * Creates a raw texture
  11668. * @param data defines the data to store in the texture
  11669. * @param width defines the width of the texture
  11670. * @param height defines the height of the texture
  11671. * @param format defines the format of the data
  11672. * @param generateMipMaps defines if the engine should generate the mip levels
  11673. * @param invertY defines if data must be stored with Y axis inverted
  11674. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11675. * @param compression defines the compression used (null by default)
  11676. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11677. * @returns the raw texture inside an InternalTexture
  11678. */
  11679. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11680. private _unpackFlipYCached;
  11681. /**
  11682. * In case you are sharing the context with other applications, it might
  11683. * be interested to not cache the unpack flip y state to ensure a consistent
  11684. * value would be set.
  11685. */
  11686. enableUnpackFlipYCached: boolean;
  11687. /** @hidden */
  11688. _unpackFlipY(value: boolean): void;
  11689. /** @hidden */
  11690. _getUnpackAlignement(): number;
  11691. /**
  11692. * Creates a dynamic texture
  11693. * @param width defines the width of the texture
  11694. * @param height defines the height of the texture
  11695. * @param generateMipMaps defines if the engine should generate the mip levels
  11696. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11697. * @returns the dynamic texture inside an InternalTexture
  11698. */
  11699. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11700. /**
  11701. * Update the sampling mode of a given texture
  11702. * @param samplingMode defines the required sampling mode
  11703. * @param texture defines the texture to update
  11704. */
  11705. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11706. /**
  11707. * Update the content of a dynamic texture
  11708. * @param texture defines the texture to update
  11709. * @param canvas defines the canvas containing the source
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. * @param premulAlpha defines if alpha is stored as premultiplied
  11712. * @param format defines the format of the data
  11713. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11714. */
  11715. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11716. /**
  11717. * Update a video texture
  11718. * @param texture defines the texture to update
  11719. * @param video defines the video element to use
  11720. * @param invertY defines if data must be stored with Y axis inverted
  11721. */
  11722. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11723. /**
  11724. * Updates a depth texture Comparison Mode and Function.
  11725. * If the comparison Function is equal to 0, the mode will be set to none.
  11726. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11727. * @param texture The texture to set the comparison function for
  11728. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11729. */
  11730. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11731. private _setupDepthStencilTexture;
  11732. /**
  11733. * Creates a depth stencil texture.
  11734. * This is only available in WebGL 2 or with the depth texture extension available.
  11735. * @param size The size of face edge in the texture.
  11736. * @param options The options defining the texture.
  11737. * @returns The texture
  11738. */
  11739. createDepthStencilTexture(size: number | {
  11740. width: number;
  11741. height: number;
  11742. }, options: DepthTextureCreationOptions): InternalTexture;
  11743. /**
  11744. * Creates a depth stencil texture.
  11745. * This is only available in WebGL 2 or with the depth texture extension available.
  11746. * @param size The size of face edge in the texture.
  11747. * @param options The options defining the texture.
  11748. * @returns The texture
  11749. */
  11750. private _createDepthStencilTexture;
  11751. /**
  11752. * Creates a depth stencil cube texture.
  11753. * This is only available in WebGL 2.
  11754. * @param size The size of face edge in the cube texture.
  11755. * @param options The options defining the cube texture.
  11756. * @returns The cube texture
  11757. */
  11758. private _createDepthStencilCubeTexture;
  11759. /**
  11760. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11761. * @param renderTarget The render target to set the frame buffer for
  11762. */
  11763. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11764. /**
  11765. * Creates a new render target texture
  11766. * @param size defines the size of the texture
  11767. * @param options defines the options used to create the texture
  11768. * @returns a new render target texture stored in an InternalTexture
  11769. */
  11770. createRenderTargetTexture(size: number | {
  11771. width: number;
  11772. height: number;
  11773. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11774. /**
  11775. * Create a multi render target texture
  11776. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11777. * @param size defines the size of the texture
  11778. * @param options defines the creation options
  11779. * @returns the cube texture as an InternalTexture
  11780. */
  11781. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11782. private _setupFramebufferDepthAttachments;
  11783. /**
  11784. * Updates the sample count of a render target texture
  11785. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11786. * @param texture defines the texture to update
  11787. * @param samples defines the sample count to set
  11788. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11789. */
  11790. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11791. /**
  11792. * Update the sample count for a given multiple render target texture
  11793. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11794. * @param textures defines the textures to update
  11795. * @param samples defines the sample count to set
  11796. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11797. */
  11798. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11799. /** @hidden */
  11800. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11801. /** @hidden */
  11802. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11803. /** @hidden */
  11804. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11805. /** @hidden */
  11806. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11807. /**
  11808. * Creates a new render target cube texture
  11809. * @param size defines the size of the texture
  11810. * @param options defines the options used to create the texture
  11811. * @returns a new render target cube texture stored in an InternalTexture
  11812. */
  11813. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11814. /**
  11815. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11816. * @param rootUrl defines the url where the file to load is located
  11817. * @param scene defines the current scene
  11818. * @param lodScale defines scale to apply to the mip map selection
  11819. * @param lodOffset defines offset to apply to the mip map selection
  11820. * @param onLoad defines an optional callback raised when the texture is loaded
  11821. * @param onError defines an optional callback raised if there is an issue to load the texture
  11822. * @param format defines the format of the data
  11823. * @param forcedExtension defines the extension to use to pick the right loader
  11824. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11825. * @returns the cube texture as an InternalTexture
  11826. */
  11827. 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;
  11828. /**
  11829. * Creates a cube texture
  11830. * @param rootUrl defines the url where the files to load is located
  11831. * @param scene defines the current scene
  11832. * @param files defines the list of files to load (1 per face)
  11833. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11834. * @param onLoad defines an optional callback raised when the texture is loaded
  11835. * @param onError defines an optional callback raised if there is an issue to load the texture
  11836. * @param format defines the format of the data
  11837. * @param forcedExtension defines the extension to use to pick the right loader
  11838. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11839. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11840. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11841. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11842. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11843. * @returns the cube texture as an InternalTexture
  11844. */
  11845. 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;
  11846. /**
  11847. * @hidden
  11848. */
  11849. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11850. /**
  11851. * Update a raw cube texture
  11852. * @param texture defines the texture to udpdate
  11853. * @param data defines the data to store
  11854. * @param format defines the data format
  11855. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11856. * @param invertY defines if data must be stored with Y axis inverted
  11857. * @param compression defines the compression used (null by default)
  11858. * @param level defines which level of the texture to update
  11859. */
  11860. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11861. /**
  11862. * Creates a new raw cube texture
  11863. * @param data defines the array of data to use to create each face
  11864. * @param size defines the size of the textures
  11865. * @param format defines the format of the data
  11866. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11867. * @param generateMipMaps defines if the engine should generate the mip levels
  11868. * @param invertY defines if data must be stored with Y axis inverted
  11869. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11870. * @param compression defines the compression used (null by default)
  11871. * @returns the cube texture as an InternalTexture
  11872. */
  11873. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11874. /**
  11875. * Creates a new raw cube texture from a specified url
  11876. * @param url defines the url where the data is located
  11877. * @param scene defines the current scene
  11878. * @param size defines the size of the textures
  11879. * @param format defines the format of the data
  11880. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11881. * @param noMipmap defines if the engine should avoid generating the mip levels
  11882. * @param callback defines a callback used to extract texture data from loaded data
  11883. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11884. * @param onLoad defines a callback called when texture is loaded
  11885. * @param onError defines a callback called if there is an error
  11886. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11887. * @param invertY defines if data must be stored with Y axis inverted
  11888. * @returns the cube texture as an InternalTexture
  11889. */
  11890. 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;
  11891. /**
  11892. * Update a raw 3D texture
  11893. * @param texture defines the texture to update
  11894. * @param data defines the data to store
  11895. * @param format defines the data format
  11896. * @param invertY defines if data must be stored with Y axis inverted
  11897. * @param compression defines the used compression (can be null)
  11898. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11899. */
  11900. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11901. /**
  11902. * Creates a new raw 3D texture
  11903. * @param data defines the data used to create the texture
  11904. * @param width defines the width of the texture
  11905. * @param height defines the height of the texture
  11906. * @param depth defines the depth of the texture
  11907. * @param format defines the format of the texture
  11908. * @param generateMipMaps defines if the engine must generate mip levels
  11909. * @param invertY defines if data must be stored with Y axis inverted
  11910. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11911. * @param compression defines the compressed used (can be null)
  11912. * @param textureType defines the compressed used (can be null)
  11913. * @returns a new raw 3D texture (stored in an InternalTexture)
  11914. */
  11915. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11916. private _prepareWebGLTextureContinuation;
  11917. private _prepareWebGLTexture;
  11918. private _convertRGBtoRGBATextureData;
  11919. /** @hidden */
  11920. _releaseFramebufferObjects(texture: InternalTexture): void;
  11921. /** @hidden */
  11922. _releaseTexture(texture: InternalTexture): void;
  11923. private setProgram;
  11924. private _boundUniforms;
  11925. /**
  11926. * Binds an effect to the webGL context
  11927. * @param effect defines the effect to bind
  11928. */
  11929. bindSamplers(effect: Effect): void;
  11930. private _moveBoundTextureOnTop;
  11931. private _getCorrectTextureChannel;
  11932. private _linkTrackers;
  11933. private _removeDesignatedSlot;
  11934. private _activateCurrentTexture;
  11935. /** @hidden */
  11936. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11937. /** @hidden */
  11938. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11939. /**
  11940. * Sets a texture to the webGL context from a postprocess
  11941. * @param channel defines the channel to use
  11942. * @param postProcess defines the source postprocess
  11943. */
  11944. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11945. /**
  11946. * Binds the output of the passed in post process to the texture channel specified
  11947. * @param channel The channel the texture should be bound to
  11948. * @param postProcess The post process which's output should be bound
  11949. */
  11950. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11951. /**
  11952. * Unbind all textures from the webGL context
  11953. */
  11954. unbindAllTextures(): void;
  11955. /**
  11956. * Sets a texture to the according uniform.
  11957. * @param channel The texture channel
  11958. * @param uniform The uniform to set
  11959. * @param texture The texture to apply
  11960. */
  11961. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11962. /**
  11963. * Sets a depth stencil texture from a render target to the according uniform.
  11964. * @param channel The texture channel
  11965. * @param uniform The uniform to set
  11966. * @param texture The render target texture containing the depth stencil texture to apply
  11967. */
  11968. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11969. private _bindSamplerUniformToChannel;
  11970. private _getTextureWrapMode;
  11971. private _setTexture;
  11972. /**
  11973. * Sets an array of texture to the webGL context
  11974. * @param channel defines the channel where the texture array must be set
  11975. * @param uniform defines the associated uniform location
  11976. * @param textures defines the array of textures to bind
  11977. */
  11978. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11979. /** @hidden */
  11980. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11981. private _setTextureParameterFloat;
  11982. private _setTextureParameterInteger;
  11983. /**
  11984. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11985. * @param x defines the x coordinate of the rectangle where pixels must be read
  11986. * @param y defines the y coordinate of the rectangle where pixels must be read
  11987. * @param width defines the width of the rectangle where pixels must be read
  11988. * @param height defines the height of the rectangle where pixels must be read
  11989. * @returns a Uint8Array containing RGBA colors
  11990. */
  11991. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11992. /**
  11993. * Add an externaly attached data from its key.
  11994. * This method call will fail and return false, if such key already exists.
  11995. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11996. * @param key the unique key that identifies the data
  11997. * @param data the data object to associate to the key for this Engine instance
  11998. * @return true if no such key were already present and the data was added successfully, false otherwise
  11999. */
  12000. addExternalData<T>(key: string, data: T): boolean;
  12001. /**
  12002. * Get an externaly attached data from its key
  12003. * @param key the unique key that identifies the data
  12004. * @return the associated data, if present (can be null), or undefined if not present
  12005. */
  12006. getExternalData<T>(key: string): T;
  12007. /**
  12008. * Get an externaly attached data from its key, create it using a factory if it's not already present
  12009. * @param key the unique key that identifies the data
  12010. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  12011. * @return the associated data, can be null if the factory returned null.
  12012. */
  12013. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  12014. /**
  12015. * Remove an externaly attached data from the Engine instance
  12016. * @param key the unique key that identifies the data
  12017. * @return true if the data was successfully removed, false if it doesn't exist
  12018. */
  12019. removeExternalData(key: string): boolean;
  12020. /**
  12021. * Unbind all vertex attributes from the webGL context
  12022. */
  12023. unbindAllAttributes(): void;
  12024. /**
  12025. * 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
  12026. */
  12027. releaseEffects(): void;
  12028. /**
  12029. * Dispose and release all associated resources
  12030. */
  12031. dispose(): void;
  12032. /**
  12033. * Display the loading screen
  12034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12035. */
  12036. displayLoadingUI(): void;
  12037. /**
  12038. * Hide the loading screen
  12039. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12040. */
  12041. hideLoadingUI(): void;
  12042. /**
  12043. * Gets the current loading screen object
  12044. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12045. */
  12046. /**
  12047. * Sets the current loading screen object
  12048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12049. */
  12050. loadingScreen: ILoadingScreen;
  12051. /**
  12052. * Sets the current loading screen text
  12053. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12054. */
  12055. loadingUIText: string;
  12056. /**
  12057. * Sets the current loading screen background color
  12058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12059. */
  12060. loadingUIBackgroundColor: string;
  12061. /**
  12062. * Attach a new callback raised when context lost event is fired
  12063. * @param callback defines the callback to call
  12064. */
  12065. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12066. /**
  12067. * Attach a new callback raised when context restored event is fired
  12068. * @param callback defines the callback to call
  12069. */
  12070. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12071. /**
  12072. * Gets the source code of the vertex shader associated with a specific webGL program
  12073. * @param program defines the program to use
  12074. * @returns a string containing the source code of the vertex shader associated with the program
  12075. */
  12076. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12077. /**
  12078. * Gets the source code of the fragment shader associated with a specific webGL program
  12079. * @param program defines the program to use
  12080. * @returns a string containing the source code of the fragment shader associated with the program
  12081. */
  12082. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12083. /**
  12084. * Get the current error code of the webGL context
  12085. * @returns the error code
  12086. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12087. */
  12088. getError(): number;
  12089. /**
  12090. * Gets the current framerate
  12091. * @returns a number representing the framerate
  12092. */
  12093. getFps(): number;
  12094. /**
  12095. * Gets the time spent between current and previous frame
  12096. * @returns a number representing the delta time in ms
  12097. */
  12098. getDeltaTime(): number;
  12099. private _measureFps;
  12100. /** @hidden */
  12101. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12102. private _canRenderToFloatFramebuffer;
  12103. private _canRenderToHalfFloatFramebuffer;
  12104. private _canRenderToFramebuffer;
  12105. /** @hidden */
  12106. _getWebGLTextureType(type: number): number;
  12107. private _getInternalFormat;
  12108. /** @hidden */
  12109. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12110. /** @hidden */
  12111. _getRGBAMultiSampleBufferFormat(type: number): number;
  12112. /** @hidden */
  12113. _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;
  12114. /** @hidden */
  12115. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12116. private _partialLoadFile;
  12117. private _cascadeLoadFiles;
  12118. /**
  12119. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12120. * @returns true if the engine can be created
  12121. * @ignorenaming
  12122. */
  12123. static isSupported(): boolean;
  12124. }
  12125. }
  12126. declare module BABYLON {
  12127. /**
  12128. * Options to create the null engine
  12129. */
  12130. class NullEngineOptions {
  12131. /**
  12132. * Render width (Default: 512)
  12133. */
  12134. renderWidth: number;
  12135. /**
  12136. * Render height (Default: 256)
  12137. */
  12138. renderHeight: number;
  12139. /**
  12140. * Texture size (Default: 512)
  12141. */
  12142. textureSize: number;
  12143. /**
  12144. * If delta time between frames should be constant
  12145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12146. */
  12147. deterministicLockstep: boolean;
  12148. /**
  12149. * Maximum about of steps between frames (Default: 4)
  12150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12151. */
  12152. lockstepMaxSteps: number;
  12153. }
  12154. /**
  12155. * The null engine class provides support for headless version of babylon.js.
  12156. * This can be used in server side scenario or for testing purposes
  12157. */
  12158. class NullEngine extends Engine {
  12159. private _options;
  12160. /**
  12161. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12162. */
  12163. isDeterministicLockStep(): boolean;
  12164. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12165. getLockstepMaxSteps(): number;
  12166. /**
  12167. * Sets hardware scaling, used to save performance if needed
  12168. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12169. */
  12170. getHardwareScalingLevel(): number;
  12171. constructor(options?: NullEngineOptions);
  12172. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12173. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12174. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12175. getRenderWidth(useScreen?: boolean): number;
  12176. getRenderHeight(useScreen?: boolean): number;
  12177. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12178. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12179. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12180. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12181. bindSamplers(effect: Effect): void;
  12182. enableEffect(effect: Effect): void;
  12183. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12184. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12185. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12186. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12187. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12188. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12189. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12190. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12191. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12192. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12193. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12194. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12195. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12196. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12197. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12198. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12199. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12200. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12201. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12202. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12203. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12204. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12205. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12206. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12207. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12208. bindBuffers(vertexBuffers: {
  12209. [key: string]: VertexBuffer;
  12210. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12211. wipeCaches(bruteForce?: boolean): void;
  12212. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12213. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12214. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12215. /** @hidden */
  12216. _createTexture(): WebGLTexture;
  12217. /** @hidden */
  12218. _releaseTexture(texture: InternalTexture): void;
  12219. 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;
  12220. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12221. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12222. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12223. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12224. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12225. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12226. areAllEffectsReady(): boolean;
  12227. /**
  12228. * @hidden
  12229. * Get the current error code of the webGL context
  12230. * @returns the error code
  12231. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12232. */
  12233. getError(): number;
  12234. /** @hidden */
  12235. _getUnpackAlignement(): number;
  12236. /** @hidden */
  12237. _unpackFlipY(value: boolean): void;
  12238. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12239. /**
  12240. * Updates a dynamic vertex buffer.
  12241. * @param vertexBuffer the vertex buffer to update
  12242. * @param data the data used to update the vertex buffer
  12243. * @param byteOffset the byte offset of the data (optional)
  12244. * @param byteLength the byte length of the data (optional)
  12245. */
  12246. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12247. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12248. /** @hidden */
  12249. _bindTexture(channel: number, texture: InternalTexture): void;
  12250. /** @hidden */
  12251. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12252. releaseEffects(): void;
  12253. displayLoadingUI(): void;
  12254. hideLoadingUI(): void;
  12255. /** @hidden */
  12256. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12257. /** @hidden */
  12258. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12259. /** @hidden */
  12260. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12261. /** @hidden */
  12262. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12263. }
  12264. }
  12265. interface WebGLRenderingContext {
  12266. readonly RASTERIZER_DISCARD: number;
  12267. readonly DEPTH_COMPONENT24: number;
  12268. readonly TEXTURE_3D: number;
  12269. readonly TEXTURE_2D_ARRAY: number;
  12270. readonly TEXTURE_COMPARE_FUNC: number;
  12271. readonly TEXTURE_COMPARE_MODE: number;
  12272. readonly COMPARE_REF_TO_TEXTURE: number;
  12273. readonly TEXTURE_WRAP_R: number;
  12274. readonly HALF_FLOAT: number;
  12275. readonly RGB8: number;
  12276. readonly RED_INTEGER: number;
  12277. readonly RG_INTEGER: number;
  12278. readonly RGB_INTEGER: number;
  12279. readonly RGBA_INTEGER: number;
  12280. readonly R8_SNORM: number;
  12281. readonly RG8_SNORM: number;
  12282. readonly RGB8_SNORM: number;
  12283. readonly RGBA8_SNORM: number;
  12284. readonly R8I: number;
  12285. readonly RG8I: number;
  12286. readonly RGB8I: number;
  12287. readonly RGBA8I: number;
  12288. readonly R8UI: number;
  12289. readonly RG8UI: number;
  12290. readonly RGB8UI: number;
  12291. readonly RGBA8UI: number;
  12292. readonly R16I: number;
  12293. readonly RG16I: number;
  12294. readonly RGB16I: number;
  12295. readonly RGBA16I: number;
  12296. readonly R16UI: number;
  12297. readonly RG16UI: number;
  12298. readonly RGB16UI: number;
  12299. readonly RGBA16UI: number;
  12300. readonly R32I: number;
  12301. readonly RG32I: number;
  12302. readonly RGB32I: number;
  12303. readonly RGBA32I: number;
  12304. readonly R32UI: number;
  12305. readonly RG32UI: number;
  12306. readonly RGB32UI: number;
  12307. readonly RGBA32UI: number;
  12308. readonly RGB10_A2UI: number;
  12309. readonly R11F_G11F_B10F: number;
  12310. readonly RGB9_E5: number;
  12311. readonly RGB10_A2: number;
  12312. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12313. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12314. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12315. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12316. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12317. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12318. 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;
  12319. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12320. readonly TRANSFORM_FEEDBACK: number;
  12321. readonly INTERLEAVED_ATTRIBS: number;
  12322. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12323. createTransformFeedback(): WebGLTransformFeedback;
  12324. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12325. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12326. beginTransformFeedback(primitiveMode: number): void;
  12327. endTransformFeedback(): void;
  12328. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12329. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12330. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12331. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12332. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12333. }
  12334. interface ImageBitmap {
  12335. readonly width: number;
  12336. readonly height: number;
  12337. close(): void;
  12338. }
  12339. interface WebGLQuery extends WebGLObject {
  12340. }
  12341. declare var WebGLQuery: {
  12342. prototype: WebGLQuery;
  12343. new (): WebGLQuery;
  12344. };
  12345. interface WebGLSampler extends WebGLObject {
  12346. }
  12347. declare var WebGLSampler: {
  12348. prototype: WebGLSampler;
  12349. new (): WebGLSampler;
  12350. };
  12351. interface WebGLSync extends WebGLObject {
  12352. }
  12353. declare var WebGLSync: {
  12354. prototype: WebGLSync;
  12355. new (): WebGLSync;
  12356. };
  12357. interface WebGLTransformFeedback extends WebGLObject {
  12358. }
  12359. declare var WebGLTransformFeedback: {
  12360. prototype: WebGLTransformFeedback;
  12361. new (): WebGLTransformFeedback;
  12362. };
  12363. interface WebGLVertexArrayObject extends WebGLObject {
  12364. }
  12365. declare var WebGLVertexArrayObject: {
  12366. prototype: WebGLVertexArrayObject;
  12367. new (): WebGLVertexArrayObject;
  12368. };
  12369. declare module BABYLON {
  12370. /**
  12371. * Gather the list of clipboard event types as constants.
  12372. */
  12373. class ClipboardEventTypes {
  12374. /**
  12375. * The clipboard event is fired when a copy command is active (pressed).
  12376. */
  12377. static readonly COPY: number;
  12378. /**
  12379. * The clipboard event is fired when a cut command is active (pressed).
  12380. */
  12381. static readonly CUT: number;
  12382. /**
  12383. * The clipboard event is fired when a paste command is active (pressed).
  12384. */
  12385. static readonly PASTE: number;
  12386. }
  12387. /**
  12388. * This class is used to store clipboard related info for the onClipboardObservable event.
  12389. */
  12390. class ClipboardInfo {
  12391. /**
  12392. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12393. */
  12394. type: number;
  12395. /**
  12396. * Defines the related dom event
  12397. */
  12398. event: ClipboardEvent;
  12399. /**
  12400. *Creates an instance of ClipboardInfo.
  12401. * @param {number} type
  12402. * @param {ClipboardEvent} event
  12403. */
  12404. constructor(
  12405. /**
  12406. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12407. */
  12408. type: number,
  12409. /**
  12410. * Defines the related dom event
  12411. */
  12412. event: ClipboardEvent);
  12413. /**
  12414. * Get the clipboard event's type from the keycode.
  12415. * @param keyCode Defines the keyCode for the current keyboard event.
  12416. * @return {number}
  12417. */
  12418. static GetTypeFromCharacter(keyCode: number): number;
  12419. }
  12420. }
  12421. declare module BABYLON {
  12422. /**
  12423. * Gather the list of keyboard event types as constants.
  12424. */
  12425. class KeyboardEventTypes {
  12426. /**
  12427. * The keydown event is fired when a key becomes active (pressed).
  12428. */
  12429. static readonly KEYDOWN: number;
  12430. /**
  12431. * The keyup event is fired when a key has been released.
  12432. */
  12433. static readonly KEYUP: number;
  12434. }
  12435. /**
  12436. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12437. */
  12438. class KeyboardInfo {
  12439. /**
  12440. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12441. */
  12442. type: number;
  12443. /**
  12444. * Defines the related dom event
  12445. */
  12446. event: KeyboardEvent;
  12447. /**
  12448. * Instantiates a new keyboard info.
  12449. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12450. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12451. * @param event Defines the related dom event
  12452. */
  12453. constructor(
  12454. /**
  12455. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12456. */
  12457. type: number,
  12458. /**
  12459. * Defines the related dom event
  12460. */
  12461. event: KeyboardEvent);
  12462. }
  12463. /**
  12464. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12465. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12466. */
  12467. class KeyboardInfoPre extends KeyboardInfo {
  12468. /**
  12469. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12470. */
  12471. type: number;
  12472. /**
  12473. * Defines the related dom event
  12474. */
  12475. event: KeyboardEvent;
  12476. /**
  12477. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12478. */
  12479. skipOnPointerObservable: boolean;
  12480. /**
  12481. * Instantiates a new keyboard pre info.
  12482. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12483. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12484. * @param event Defines the related dom event
  12485. */
  12486. constructor(
  12487. /**
  12488. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12489. */
  12490. type: number,
  12491. /**
  12492. * Defines the related dom event
  12493. */
  12494. event: KeyboardEvent);
  12495. }
  12496. }
  12497. declare module BABYLON {
  12498. /**
  12499. * Gather the list of pointer event types as constants.
  12500. */
  12501. class PointerEventTypes {
  12502. /**
  12503. * 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.
  12504. */
  12505. static readonly POINTERDOWN: number;
  12506. /**
  12507. * The pointerup event is fired when a pointer is no longer active.
  12508. */
  12509. static readonly POINTERUP: number;
  12510. /**
  12511. * The pointermove event is fired when a pointer changes coordinates.
  12512. */
  12513. static readonly POINTERMOVE: number;
  12514. /**
  12515. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12516. */
  12517. static readonly POINTERWHEEL: number;
  12518. /**
  12519. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12520. */
  12521. static readonly POINTERPICK: number;
  12522. /**
  12523. * The pointertap event is fired when a the object has been touched and released without drag.
  12524. */
  12525. static readonly POINTERTAP: number;
  12526. /**
  12527. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12528. */
  12529. static readonly POINTERDOUBLETAP: number;
  12530. }
  12531. /**
  12532. * Base class of pointer info types.
  12533. */
  12534. class PointerInfoBase {
  12535. /**
  12536. * Defines the type of event (BABYLON.PointerEventTypes)
  12537. */
  12538. type: number;
  12539. /**
  12540. * Defines the related dom event
  12541. */
  12542. event: PointerEvent | MouseWheelEvent;
  12543. /**
  12544. * Instantiates the base class of pointers info.
  12545. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12546. * @param event Defines the related dom event
  12547. */
  12548. constructor(
  12549. /**
  12550. * Defines the type of event (BABYLON.PointerEventTypes)
  12551. */
  12552. type: number,
  12553. /**
  12554. * Defines the related dom event
  12555. */
  12556. event: PointerEvent | MouseWheelEvent);
  12557. }
  12558. /**
  12559. * This class is used to store pointer related info for the onPrePointerObservable event.
  12560. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12561. */
  12562. class PointerInfoPre extends PointerInfoBase {
  12563. /**
  12564. * Ray from a pointer if availible (eg. 6dof controller)
  12565. */
  12566. ray: Nullable<Ray>;
  12567. /**
  12568. * Defines the local position of the pointer on the canvas.
  12569. */
  12570. localPosition: Vector2;
  12571. /**
  12572. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12573. */
  12574. skipOnPointerObservable: boolean;
  12575. /**
  12576. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12577. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12578. * @param event Defines the related dom event
  12579. * @param localX Defines the local x coordinates of the pointer when the event occured
  12580. * @param localY Defines the local y coordinates of the pointer when the event occured
  12581. */
  12582. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12583. }
  12584. /**
  12585. * This type contains all the data related to a pointer event in Babylon.js.
  12586. * 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.
  12587. */
  12588. class PointerInfo extends PointerInfoBase {
  12589. /**
  12590. * Defines the picking info associated to the info (if any)\
  12591. */
  12592. pickInfo: Nullable<PickingInfo>;
  12593. /**
  12594. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12595. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12596. * @param event Defines the related dom event
  12597. * @param pickInfo Defines the picking info associated to the info (if any)\
  12598. */
  12599. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12600. /**
  12601. * Defines the picking info associated to the info (if any)\
  12602. */
  12603. pickInfo: Nullable<PickingInfo>);
  12604. }
  12605. }
  12606. declare module BABYLON {
  12607. /**
  12608. * Represents a gamepad control stick position
  12609. */
  12610. class StickValues {
  12611. /**
  12612. * The x component of the control stick
  12613. */
  12614. x: number;
  12615. /**
  12616. * The y component of the control stick
  12617. */
  12618. y: number;
  12619. /**
  12620. * Initializes the gamepad x and y control stick values
  12621. * @param x The x component of the gamepad control stick value
  12622. * @param y The y component of the gamepad control stick value
  12623. */
  12624. constructor(
  12625. /**
  12626. * The x component of the control stick
  12627. */
  12628. x: number,
  12629. /**
  12630. * The y component of the control stick
  12631. */
  12632. y: number);
  12633. }
  12634. /**
  12635. * An interface which manages callbacks for gamepad button changes
  12636. */
  12637. interface GamepadButtonChanges {
  12638. /**
  12639. * Called when a gamepad has been changed
  12640. */
  12641. changed: boolean;
  12642. /**
  12643. * Called when a gamepad press event has been triggered
  12644. */
  12645. pressChanged: boolean;
  12646. /**
  12647. * Called when a touch event has been triggered
  12648. */
  12649. touchChanged: boolean;
  12650. /**
  12651. * Called when a value has changed
  12652. */
  12653. valueChanged: boolean;
  12654. }
  12655. /**
  12656. * Represents a gamepad
  12657. */
  12658. class Gamepad {
  12659. /**
  12660. * The id of the gamepad
  12661. */
  12662. id: string;
  12663. /**
  12664. * The index of the gamepad
  12665. */
  12666. index: number;
  12667. /**
  12668. * The browser gamepad
  12669. */
  12670. browserGamepad: any;
  12671. /**
  12672. * Specifies what type of gamepad this represents
  12673. */
  12674. type: number;
  12675. private _leftStick;
  12676. private _rightStick;
  12677. /** @hidden */
  12678. _isConnected: boolean;
  12679. private _leftStickAxisX;
  12680. private _leftStickAxisY;
  12681. private _rightStickAxisX;
  12682. private _rightStickAxisY;
  12683. /**
  12684. * Triggered when the left control stick has been changed
  12685. */
  12686. private _onleftstickchanged;
  12687. /**
  12688. * Triggered when the right control stick has been changed
  12689. */
  12690. private _onrightstickchanged;
  12691. /**
  12692. * Represents a gamepad controller
  12693. */
  12694. static GAMEPAD: number;
  12695. /**
  12696. * Represents a generic controller
  12697. */
  12698. static GENERIC: number;
  12699. /**
  12700. * Represents an XBox controller
  12701. */
  12702. static XBOX: number;
  12703. /**
  12704. * Represents a pose-enabled controller
  12705. */
  12706. static POSE_ENABLED: number;
  12707. /**
  12708. * Specifies whether the left control stick should be Y-inverted
  12709. */
  12710. protected _invertLeftStickY: boolean;
  12711. /**
  12712. * Specifies if the gamepad has been connected
  12713. */
  12714. readonly isConnected: boolean;
  12715. /**
  12716. * Initializes the gamepad
  12717. * @param id The id of the gamepad
  12718. * @param index The index of the gamepad
  12719. * @param browserGamepad The browser gamepad
  12720. * @param leftStickX The x component of the left joystick
  12721. * @param leftStickY The y component of the left joystick
  12722. * @param rightStickX The x component of the right joystick
  12723. * @param rightStickY The y component of the right joystick
  12724. */
  12725. constructor(
  12726. /**
  12727. * The id of the gamepad
  12728. */
  12729. id: string,
  12730. /**
  12731. * The index of the gamepad
  12732. */
  12733. index: number,
  12734. /**
  12735. * The browser gamepad
  12736. */
  12737. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12738. /**
  12739. * Callback triggered when the left joystick has changed
  12740. * @param callback
  12741. */
  12742. onleftstickchanged(callback: (values: StickValues) => void): void;
  12743. /**
  12744. * Callback triggered when the right joystick has changed
  12745. * @param callback
  12746. */
  12747. onrightstickchanged(callback: (values: StickValues) => void): void;
  12748. /**
  12749. * Gets the left joystick
  12750. */
  12751. /**
  12752. * Sets the left joystick values
  12753. */
  12754. leftStick: StickValues;
  12755. /**
  12756. * Gets the right joystick
  12757. */
  12758. /**
  12759. * Sets the right joystick value
  12760. */
  12761. rightStick: StickValues;
  12762. /**
  12763. * Updates the gamepad joystick positions
  12764. */
  12765. update(): void;
  12766. /**
  12767. * Disposes the gamepad
  12768. */
  12769. dispose(): void;
  12770. }
  12771. /**
  12772. * Represents a generic gamepad
  12773. */
  12774. class GenericPad extends Gamepad {
  12775. private _buttons;
  12776. private _onbuttondown;
  12777. private _onbuttonup;
  12778. /**
  12779. * Observable triggered when a button has been pressed
  12780. */
  12781. onButtonDownObservable: Observable<number>;
  12782. /**
  12783. * Observable triggered when a button has been released
  12784. */
  12785. onButtonUpObservable: Observable<number>;
  12786. /**
  12787. * Callback triggered when a button has been pressed
  12788. * @param callback Called when a button has been pressed
  12789. */
  12790. onbuttondown(callback: (buttonPressed: number) => void): void;
  12791. /**
  12792. * Callback triggered when a button has been released
  12793. * @param callback Called when a button has been released
  12794. */
  12795. onbuttonup(callback: (buttonReleased: number) => void): void;
  12796. /**
  12797. * Initializes the generic gamepad
  12798. * @param id The id of the generic gamepad
  12799. * @param index The index of the generic gamepad
  12800. * @param browserGamepad The browser gamepad
  12801. */
  12802. constructor(id: string, index: number, browserGamepad: any);
  12803. private _setButtonValue;
  12804. /**
  12805. * Updates the generic gamepad
  12806. */
  12807. update(): void;
  12808. /**
  12809. * Disposes the generic gamepad
  12810. */
  12811. dispose(): void;
  12812. }
  12813. }
  12814. declare module BABYLON {
  12815. /**
  12816. * Manager for handling gamepads
  12817. */
  12818. class GamepadManager {
  12819. private _scene?;
  12820. private _babylonGamepads;
  12821. private _oneGamepadConnected;
  12822. /** @hidden */
  12823. _isMonitoring: boolean;
  12824. private _gamepadEventSupported;
  12825. private _gamepadSupport;
  12826. /**
  12827. * observable to be triggered when the gamepad controller has been connected
  12828. */
  12829. onGamepadConnectedObservable: Observable<Gamepad>;
  12830. /**
  12831. * observable to be triggered when the gamepad controller has been disconnected
  12832. */
  12833. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12834. private _onGamepadConnectedEvent;
  12835. private _onGamepadDisconnectedEvent;
  12836. /**
  12837. * Initializes the gamepad manager
  12838. * @param _scene BabylonJS scene
  12839. */
  12840. constructor(_scene?: Scene | undefined);
  12841. /**
  12842. * The gamepads in the game pad manager
  12843. */
  12844. readonly gamepads: Gamepad[];
  12845. /**
  12846. * Get the gamepad controllers based on type
  12847. * @param type The type of gamepad controller
  12848. * @returns Nullable gamepad
  12849. */
  12850. getGamepadByType(type?: number): Nullable<Gamepad>;
  12851. /**
  12852. * Disposes the gamepad manager
  12853. */
  12854. dispose(): void;
  12855. private _addNewGamepad;
  12856. private _startMonitoringGamepads;
  12857. private _stopMonitoringGamepads;
  12858. /** @hidden */
  12859. _checkGamepadsStatus(): void;
  12860. private _updateGamepadObjects;
  12861. }
  12862. }
  12863. declare module BABYLON {
  12864. interface Scene {
  12865. /** @hidden */
  12866. _gamepadManager: Nullable<GamepadManager>;
  12867. /**
  12868. * Gets the gamepad manager associated with the scene
  12869. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12870. */
  12871. gamepadManager: GamepadManager;
  12872. }
  12873. /**
  12874. * Interface representing a free camera inputs manager
  12875. */
  12876. interface FreeCameraInputsManager {
  12877. /**
  12878. * Adds gamepad input support to the FreeCameraInputsManager.
  12879. * @returns the FreeCameraInputsManager
  12880. */
  12881. addGamepad(): FreeCameraInputsManager;
  12882. }
  12883. /**
  12884. * Interface representing an arc rotate camera inputs manager
  12885. */
  12886. interface ArcRotateCameraInputsManager {
  12887. /**
  12888. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12889. * @returns the camera inputs manager
  12890. */
  12891. addGamepad(): ArcRotateCameraInputsManager;
  12892. }
  12893. /**
  12894. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12895. */
  12896. class GamepadSystemSceneComponent implements ISceneComponent {
  12897. /**
  12898. * The component name helpfull to identify the component in the list of scene components.
  12899. */
  12900. readonly name: string;
  12901. /**
  12902. * The scene the component belongs to.
  12903. */
  12904. scene: Scene;
  12905. /**
  12906. * Creates a new instance of the component for the given scene
  12907. * @param scene Defines the scene to register the component in
  12908. */
  12909. constructor(scene: Scene);
  12910. /**
  12911. * Registers the component in a given scene
  12912. */
  12913. register(): void;
  12914. /**
  12915. * Rebuilds the elements related to this component in case of
  12916. * context lost for instance.
  12917. */
  12918. rebuild(): void;
  12919. /**
  12920. * Disposes the component and the associated ressources
  12921. */
  12922. dispose(): void;
  12923. private _beforeCameraUpdate;
  12924. }
  12925. }
  12926. declare module BABYLON {
  12927. /**
  12928. * Defines supported buttons for XBox360 compatible gamepads
  12929. */
  12930. enum Xbox360Button {
  12931. /** A */
  12932. A = 0,
  12933. /** B */
  12934. B = 1,
  12935. /** X */
  12936. X = 2,
  12937. /** Y */
  12938. Y = 3,
  12939. /** Start */
  12940. Start = 4,
  12941. /** Back */
  12942. Back = 5,
  12943. /** Left button */
  12944. LB = 6,
  12945. /** Right button */
  12946. RB = 7,
  12947. /** Left stick */
  12948. LeftStick = 8,
  12949. /** Right stick */
  12950. RightStick = 9
  12951. }
  12952. /** Defines values for XBox360 DPad */
  12953. enum Xbox360Dpad {
  12954. /** Up */
  12955. Up = 0,
  12956. /** Down */
  12957. Down = 1,
  12958. /** Left */
  12959. Left = 2,
  12960. /** Right */
  12961. Right = 3
  12962. }
  12963. /**
  12964. * Defines a XBox360 gamepad
  12965. */
  12966. class Xbox360Pad extends Gamepad {
  12967. private _leftTrigger;
  12968. private _rightTrigger;
  12969. private _onlefttriggerchanged;
  12970. private _onrighttriggerchanged;
  12971. private _onbuttondown;
  12972. private _onbuttonup;
  12973. private _ondpaddown;
  12974. private _ondpadup;
  12975. /** Observable raised when a button is pressed */
  12976. onButtonDownObservable: Observable<Xbox360Button>;
  12977. /** Observable raised when a button is released */
  12978. onButtonUpObservable: Observable<Xbox360Button>;
  12979. /** Observable raised when a pad is pressed */
  12980. onPadDownObservable: Observable<Xbox360Dpad>;
  12981. /** Observable raised when a pad is released */
  12982. onPadUpObservable: Observable<Xbox360Dpad>;
  12983. private _buttonA;
  12984. private _buttonB;
  12985. private _buttonX;
  12986. private _buttonY;
  12987. private _buttonBack;
  12988. private _buttonStart;
  12989. private _buttonLB;
  12990. private _buttonRB;
  12991. private _buttonLeftStick;
  12992. private _buttonRightStick;
  12993. private _dPadUp;
  12994. private _dPadDown;
  12995. private _dPadLeft;
  12996. private _dPadRight;
  12997. private _isXboxOnePad;
  12998. /**
  12999. * Creates a new XBox360 gamepad object
  13000. * @param id defines the id of this gamepad
  13001. * @param index defines its index
  13002. * @param gamepad defines the internal HTML gamepad object
  13003. * @param xboxOne defines if it is a XBox One gamepad
  13004. */
  13005. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  13006. /**
  13007. * Defines the callback to call when left trigger is pressed
  13008. * @param callback defines the callback to use
  13009. */
  13010. onlefttriggerchanged(callback: (value: number) => void): void;
  13011. /**
  13012. * Defines the callback to call when right trigger is pressed
  13013. * @param callback defines the callback to use
  13014. */
  13015. onrighttriggerchanged(callback: (value: number) => void): void;
  13016. /**
  13017. * Gets the left trigger value
  13018. */
  13019. /**
  13020. * Sets the left trigger value
  13021. */
  13022. leftTrigger: number;
  13023. /**
  13024. * Gets the right trigger value
  13025. */
  13026. /**
  13027. * Sets the right trigger value
  13028. */
  13029. rightTrigger: number;
  13030. /**
  13031. * Defines the callback to call when a button is pressed
  13032. * @param callback defines the callback to use
  13033. */
  13034. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  13035. /**
  13036. * Defines the callback to call when a button is released
  13037. * @param callback defines the callback to use
  13038. */
  13039. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13040. /**
  13041. * Defines the callback to call when a pad is pressed
  13042. * @param callback defines the callback to use
  13043. */
  13044. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13045. /**
  13046. * Defines the callback to call when a pad is released
  13047. * @param callback defines the callback to use
  13048. */
  13049. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13050. private _setButtonValue;
  13051. private _setDPadValue;
  13052. /**
  13053. * Gets the value of the `A` button
  13054. */
  13055. /**
  13056. * Sets the value of the `A` button
  13057. */
  13058. buttonA: number;
  13059. /**
  13060. * Gets the value of the `B` button
  13061. */
  13062. /**
  13063. * Sets the value of the `B` button
  13064. */
  13065. buttonB: number;
  13066. /**
  13067. * Gets the value of the `X` button
  13068. */
  13069. /**
  13070. * Sets the value of the `X` button
  13071. */
  13072. buttonX: number;
  13073. /**
  13074. * Gets the value of the `Y` button
  13075. */
  13076. /**
  13077. * Sets the value of the `Y` button
  13078. */
  13079. buttonY: number;
  13080. /**
  13081. * Gets the value of the `Start` button
  13082. */
  13083. /**
  13084. * Sets the value of the `Start` button
  13085. */
  13086. buttonStart: number;
  13087. /**
  13088. * Gets the value of the `Back` button
  13089. */
  13090. /**
  13091. * Sets the value of the `Back` button
  13092. */
  13093. buttonBack: number;
  13094. /**
  13095. * Gets the value of the `Left` button
  13096. */
  13097. /**
  13098. * Sets the value of the `Left` button
  13099. */
  13100. buttonLB: number;
  13101. /**
  13102. * Gets the value of the `Right` button
  13103. */
  13104. /**
  13105. * Sets the value of the `Right` button
  13106. */
  13107. buttonRB: number;
  13108. /**
  13109. * Gets the value of the Left joystick
  13110. */
  13111. /**
  13112. * Sets the value of the Left joystick
  13113. */
  13114. buttonLeftStick: number;
  13115. /**
  13116. * Gets the value of the Right joystick
  13117. */
  13118. /**
  13119. * Sets the value of the Right joystick
  13120. */
  13121. buttonRightStick: number;
  13122. /**
  13123. * Gets the value of D-pad up
  13124. */
  13125. /**
  13126. * Sets the value of D-pad up
  13127. */
  13128. dPadUp: number;
  13129. /**
  13130. * Gets the value of D-pad down
  13131. */
  13132. /**
  13133. * Sets the value of D-pad down
  13134. */
  13135. dPadDown: number;
  13136. /**
  13137. * Gets the value of D-pad left
  13138. */
  13139. /**
  13140. * Sets the value of D-pad left
  13141. */
  13142. dPadLeft: number;
  13143. /**
  13144. * Gets the value of D-pad right
  13145. */
  13146. /**
  13147. * Sets the value of D-pad right
  13148. */
  13149. dPadRight: number;
  13150. /**
  13151. * Force the gamepad to synchronize with device values
  13152. */
  13153. update(): void;
  13154. /**
  13155. * Disposes the gamepad
  13156. */
  13157. dispose(): void;
  13158. }
  13159. }
  13160. declare module BABYLON {
  13161. /**
  13162. * Single axis drag gizmo
  13163. */
  13164. class AxisDragGizmo extends Gizmo {
  13165. /**
  13166. * Drag behavior responsible for the gizmos dragging interactions
  13167. */
  13168. dragBehavior: PointerDragBehavior;
  13169. private _pointerObserver;
  13170. /**
  13171. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13172. */
  13173. snapDistance: number;
  13174. /**
  13175. * Event that fires each time the gizmo snaps to a new location.
  13176. * * snapDistance is the the change in distance
  13177. */
  13178. onSnapObservable: Observable<{
  13179. snapDistance: number;
  13180. }>;
  13181. /** @hidden */
  13182. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13183. /** @hidden */
  13184. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13185. /**
  13186. * Creates an AxisDragGizmo
  13187. * @param gizmoLayer The utility layer the gizmo will be added to
  13188. * @param dragAxis The axis which the gizmo will be able to drag on
  13189. * @param color The color of the gizmo
  13190. */
  13191. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13192. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13193. /**
  13194. * Disposes of the gizmo
  13195. */
  13196. dispose(): void;
  13197. }
  13198. }
  13199. declare module BABYLON {
  13200. /**
  13201. * Single axis scale gizmo
  13202. */
  13203. class AxisScaleGizmo extends Gizmo {
  13204. private _coloredMaterial;
  13205. /**
  13206. * Drag behavior responsible for the gizmos dragging interactions
  13207. */
  13208. dragBehavior: PointerDragBehavior;
  13209. private _pointerObserver;
  13210. /**
  13211. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13212. */
  13213. snapDistance: number;
  13214. /**
  13215. * Event that fires each time the gizmo snaps to a new location.
  13216. * * snapDistance is the the change in distance
  13217. */
  13218. onSnapObservable: Observable<{
  13219. snapDistance: number;
  13220. }>;
  13221. /**
  13222. * If the scaling operation should be done on all axis (default: false)
  13223. */
  13224. uniformScaling: boolean;
  13225. /**
  13226. * Creates an AxisScaleGizmo
  13227. * @param gizmoLayer The utility layer the gizmo will be added to
  13228. * @param dragAxis The axis which the gizmo will be able to scale on
  13229. * @param color The color of the gizmo
  13230. */
  13231. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13232. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13233. /**
  13234. * Disposes of the gizmo
  13235. */
  13236. dispose(): void;
  13237. /**
  13238. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13239. * @param mesh The mesh to replace the default mesh of the gizmo
  13240. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13241. */
  13242. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13243. }
  13244. }
  13245. declare module BABYLON {
  13246. /**
  13247. * Bounding box gizmo
  13248. */
  13249. class BoundingBoxGizmo extends Gizmo {
  13250. private _lineBoundingBox;
  13251. private _rotateSpheresParent;
  13252. private _scaleBoxesParent;
  13253. private _boundingDimensions;
  13254. private _renderObserver;
  13255. private _pointerObserver;
  13256. private _scaleDragSpeed;
  13257. private _tmpQuaternion;
  13258. private _tmpVector;
  13259. private _tmpRotationMatrix;
  13260. /**
  13261. * 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)
  13262. */
  13263. ignoreChildren: boolean;
  13264. /**
  13265. * 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)
  13266. */
  13267. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13268. /**
  13269. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13270. */
  13271. rotationSphereSize: number;
  13272. /**
  13273. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13274. */
  13275. scaleBoxSize: number;
  13276. /**
  13277. * 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)
  13278. */
  13279. fixedDragMeshScreenSize: boolean;
  13280. /**
  13281. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13282. */
  13283. fixedDragMeshScreenSizeDistanceFactor: number;
  13284. /**
  13285. * Fired when a rotation sphere or scale box is dragged
  13286. */
  13287. onDragStartObservable: Observable<{}>;
  13288. /**
  13289. * Fired when a scale box is dragged
  13290. */
  13291. onScaleBoxDragObservable: Observable<{}>;
  13292. /**
  13293. * Fired when a scale box drag is ended
  13294. */
  13295. onScaleBoxDragEndObservable: Observable<{}>;
  13296. /**
  13297. * Fired when a rotation sphere is dragged
  13298. */
  13299. onRotationSphereDragObservable: Observable<{}>;
  13300. /**
  13301. * Fired when a rotation sphere drag is ended
  13302. */
  13303. onRotationSphereDragEndObservable: Observable<{}>;
  13304. /**
  13305. * 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)
  13306. */
  13307. scalePivot: Nullable<Vector3>;
  13308. private _anchorMesh;
  13309. private _existingMeshScale;
  13310. private _dragMesh;
  13311. private pointerDragBehavior;
  13312. private static _PivotCached;
  13313. private static _OldPivotPoint;
  13314. private static _PivotTranslation;
  13315. private static _PivotTmpVector;
  13316. /** @hidden */
  13317. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13318. /** @hidden */
  13319. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13320. /**
  13321. * Creates an BoundingBoxGizmo
  13322. * @param gizmoLayer The utility layer the gizmo will be added to
  13323. * @param color The color of the gizmo
  13324. */
  13325. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13326. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13327. private _selectNode;
  13328. /**
  13329. * Updates the bounding box information for the Gizmo
  13330. */
  13331. updateBoundingBox(): void;
  13332. private _updateRotationSpheres;
  13333. private _updateScaleBoxes;
  13334. /**
  13335. * Enables rotation on the specified axis and disables rotation on the others
  13336. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13337. */
  13338. setEnabledRotationAxis(axis: string): void;
  13339. /**
  13340. * Enables/disables scaling
  13341. * @param enable if scaling should be enabled
  13342. */
  13343. setEnabledScaling(enable: boolean): void;
  13344. private _updateDummy;
  13345. /**
  13346. * Enables a pointer drag behavior on the bounding box of the gizmo
  13347. */
  13348. enableDragBehavior(): void;
  13349. /**
  13350. * Disposes of the gizmo
  13351. */
  13352. dispose(): void;
  13353. /**
  13354. * 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)
  13355. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13356. * @returns the bounding box mesh with the passed in mesh as a child
  13357. */
  13358. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13359. /**
  13360. * CustomMeshes are not supported by this gizmo
  13361. * @param mesh The mesh to replace the default mesh of the gizmo
  13362. */
  13363. setCustomMesh(mesh: Mesh): void;
  13364. }
  13365. }
  13366. declare module BABYLON {
  13367. /**
  13368. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13369. */
  13370. class Gizmo implements IDisposable {
  13371. /** The utility layer the gizmo will be added to */
  13372. gizmoLayer: UtilityLayerRenderer;
  13373. /**
  13374. * The root mesh of the gizmo
  13375. */
  13376. protected _rootMesh: Mesh;
  13377. private _attachedMesh;
  13378. /**
  13379. * Ratio for the scale of the gizmo (Default: 1)
  13380. */
  13381. scaleRatio: number;
  13382. private _tmpMatrix;
  13383. /**
  13384. * If a custom mesh has been set (Default: false)
  13385. */
  13386. protected _customMeshSet: boolean;
  13387. /**
  13388. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13389. * * When set, interactions will be enabled
  13390. */
  13391. attachedMesh: Nullable<AbstractMesh>;
  13392. /**
  13393. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13394. * @param mesh The mesh to replace the default mesh of the gizmo
  13395. */
  13396. setCustomMesh(mesh: Mesh): void;
  13397. /**
  13398. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13399. */
  13400. updateGizmoRotationToMatchAttachedMesh: boolean;
  13401. /**
  13402. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13403. */
  13404. updateGizmoPositionToMatchAttachedMesh: boolean;
  13405. /**
  13406. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13407. */
  13408. protected _updateScale: boolean;
  13409. protected _interactionsEnabled: boolean;
  13410. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13411. private _beforeRenderObserver;
  13412. /**
  13413. * Creates a gizmo
  13414. * @param gizmoLayer The utility layer the gizmo will be added to
  13415. */
  13416. constructor(
  13417. /** The utility layer the gizmo will be added to */
  13418. gizmoLayer?: UtilityLayerRenderer);
  13419. private _tempVector;
  13420. /**
  13421. * @hidden
  13422. * Updates the gizmo to match the attached mesh's position/rotation
  13423. */
  13424. protected _update(): void;
  13425. /**
  13426. * Disposes of the gizmo
  13427. */
  13428. dispose(): void;
  13429. }
  13430. }
  13431. declare module BABYLON {
  13432. /**
  13433. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13434. */
  13435. class GizmoManager implements IDisposable {
  13436. private scene;
  13437. /**
  13438. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13439. */
  13440. gizmos: {
  13441. positionGizmo: Nullable<PositionGizmo>;
  13442. rotationGizmo: Nullable<RotationGizmo>;
  13443. scaleGizmo: Nullable<ScaleGizmo>;
  13444. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13445. };
  13446. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13447. clearGizmoOnEmptyPointerEvent: boolean;
  13448. /** Fires an event when the manager is attached to a mesh */
  13449. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13450. private _gizmosEnabled;
  13451. private _pointerObserver;
  13452. private _attachedMesh;
  13453. private _boundingBoxColor;
  13454. private _defaultUtilityLayer;
  13455. private _defaultKeepDepthUtilityLayer;
  13456. /**
  13457. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13458. */
  13459. boundingBoxDragBehavior: SixDofDragBehavior;
  13460. /**
  13461. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13462. */
  13463. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13464. /**
  13465. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13466. */
  13467. usePointerToAttachGizmos: boolean;
  13468. /**
  13469. * Instatiates a gizmo manager
  13470. * @param scene the scene to overlay the gizmos on top of
  13471. */
  13472. constructor(scene: Scene);
  13473. /**
  13474. * Attaches a set of gizmos to the specified mesh
  13475. * @param mesh The mesh the gizmo's should be attached to
  13476. */
  13477. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13478. /**
  13479. * If the position gizmo is enabled
  13480. */
  13481. positionGizmoEnabled: boolean;
  13482. /**
  13483. * If the rotation gizmo is enabled
  13484. */
  13485. rotationGizmoEnabled: boolean;
  13486. /**
  13487. * If the scale gizmo is enabled
  13488. */
  13489. scaleGizmoEnabled: boolean;
  13490. /**
  13491. * If the boundingBox gizmo is enabled
  13492. */
  13493. boundingBoxGizmoEnabled: boolean;
  13494. /**
  13495. * Disposes of the gizmo manager
  13496. */
  13497. dispose(): void;
  13498. }
  13499. }
  13500. declare module BABYLON {
  13501. /**
  13502. * Single plane rotation gizmo
  13503. */
  13504. class PlaneRotationGizmo extends Gizmo {
  13505. /**
  13506. * Drag behavior responsible for the gizmos dragging interactions
  13507. */
  13508. dragBehavior: PointerDragBehavior;
  13509. private _pointerObserver;
  13510. /**
  13511. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13512. */
  13513. snapDistance: number;
  13514. /**
  13515. * Event that fires each time the gizmo snaps to a new location.
  13516. * * snapDistance is the the change in distance
  13517. */
  13518. onSnapObservable: Observable<{
  13519. snapDistance: number;
  13520. }>;
  13521. /**
  13522. * Creates a PlaneRotationGizmo
  13523. * @param gizmoLayer The utility layer the gizmo will be added to
  13524. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13525. * @param color The color of the gizmo
  13526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13527. */
  13528. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13529. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13530. /**
  13531. * Disposes of the gizmo
  13532. */
  13533. dispose(): void;
  13534. }
  13535. }
  13536. declare module BABYLON {
  13537. /**
  13538. * Gizmo that enables dragging a mesh along 3 axis
  13539. */
  13540. class PositionGizmo extends Gizmo {
  13541. /**
  13542. * Internal gizmo used for interactions on the x axis
  13543. */
  13544. xGizmo: AxisDragGizmo;
  13545. /**
  13546. * Internal gizmo used for interactions on the y axis
  13547. */
  13548. yGizmo: AxisDragGizmo;
  13549. /**
  13550. * Internal gizmo used for interactions on the z axis
  13551. */
  13552. zGizmo: AxisDragGizmo;
  13553. /** Fires an event when any of it's sub gizmos are dragged */
  13554. onDragStartObservable: Observable<{}>;
  13555. /** Fires an event when any of it's sub gizmos are released from dragging */
  13556. onDragEndObservable: Observable<{}>;
  13557. attachedMesh: Nullable<AbstractMesh>;
  13558. /**
  13559. * Creates a PositionGizmo
  13560. * @param gizmoLayer The utility layer the gizmo will be added to
  13561. */
  13562. constructor(gizmoLayer?: UtilityLayerRenderer);
  13563. updateGizmoRotationToMatchAttachedMesh: boolean;
  13564. /**
  13565. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13566. */
  13567. snapDistance: number;
  13568. /**
  13569. * Ratio for the scale of the gizmo (Default: 1)
  13570. */
  13571. scaleRatio: number;
  13572. /**
  13573. * Disposes of the gizmo
  13574. */
  13575. dispose(): void;
  13576. /**
  13577. * CustomMeshes are not supported by this gizmo
  13578. * @param mesh The mesh to replace the default mesh of the gizmo
  13579. */
  13580. setCustomMesh(mesh: Mesh): void;
  13581. }
  13582. }
  13583. declare module BABYLON {
  13584. /**
  13585. * Gizmo that enables rotating a mesh along 3 axis
  13586. */
  13587. class RotationGizmo extends Gizmo {
  13588. /**
  13589. * Internal gizmo used for interactions on the x axis
  13590. */
  13591. xGizmo: PlaneRotationGizmo;
  13592. /**
  13593. * Internal gizmo used for interactions on the y axis
  13594. */
  13595. yGizmo: PlaneRotationGizmo;
  13596. /**
  13597. * Internal gizmo used for interactions on the z axis
  13598. */
  13599. zGizmo: PlaneRotationGizmo;
  13600. /** Fires an event when any of it's sub gizmos are dragged */
  13601. onDragStartObservable: Observable<{}>;
  13602. /** Fires an event when any of it's sub gizmos are released from dragging */
  13603. onDragEndObservable: Observable<{}>;
  13604. attachedMesh: Nullable<AbstractMesh>;
  13605. /**
  13606. * Creates a RotationGizmo
  13607. * @param gizmoLayer The utility layer the gizmo will be added to
  13608. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13609. */
  13610. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13611. updateGizmoRotationToMatchAttachedMesh: boolean;
  13612. /**
  13613. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13614. */
  13615. snapDistance: number;
  13616. /**
  13617. * Ratio for the scale of the gizmo (Default: 1)
  13618. */
  13619. scaleRatio: number;
  13620. /**
  13621. * Disposes of the gizmo
  13622. */
  13623. dispose(): void;
  13624. /**
  13625. * CustomMeshes are not supported by this gizmo
  13626. * @param mesh The mesh to replace the default mesh of the gizmo
  13627. */
  13628. setCustomMesh(mesh: Mesh): void;
  13629. }
  13630. }
  13631. declare module BABYLON {
  13632. /**
  13633. * Gizmo that enables scaling a mesh along 3 axis
  13634. */
  13635. class ScaleGizmo extends Gizmo {
  13636. /**
  13637. * Internal gizmo used for interactions on the x axis
  13638. */
  13639. xGizmo: AxisScaleGizmo;
  13640. /**
  13641. * Internal gizmo used for interactions on the y axis
  13642. */
  13643. yGizmo: AxisScaleGizmo;
  13644. /**
  13645. * Internal gizmo used for interactions on the z axis
  13646. */
  13647. zGizmo: AxisScaleGizmo;
  13648. /**
  13649. * Internal gizmo used to scale all axis equally
  13650. */
  13651. uniformScaleGizmo: AxisScaleGizmo;
  13652. /** Fires an event when any of it's sub gizmos are dragged */
  13653. onDragStartObservable: Observable<{}>;
  13654. /** Fires an event when any of it's sub gizmos are released from dragging */
  13655. onDragEndObservable: Observable<{}>;
  13656. attachedMesh: Nullable<AbstractMesh>;
  13657. /**
  13658. * Creates a ScaleGizmo
  13659. * @param gizmoLayer The utility layer the gizmo will be added to
  13660. */
  13661. constructor(gizmoLayer?: UtilityLayerRenderer);
  13662. updateGizmoRotationToMatchAttachedMesh: boolean;
  13663. /**
  13664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13665. */
  13666. snapDistance: number;
  13667. /**
  13668. * Ratio for the scale of the gizmo (Default: 1)
  13669. */
  13670. scaleRatio: number;
  13671. /**
  13672. * Disposes of the gizmo
  13673. */
  13674. dispose(): void;
  13675. }
  13676. }
  13677. declare module BABYLON {
  13678. /**
  13679. * Represents the different options available during the creation of
  13680. * a Environment helper.
  13681. *
  13682. * This can control the default ground, skybox and image processing setup of your scene.
  13683. */
  13684. interface IEnvironmentHelperOptions {
  13685. /**
  13686. * Specifies wether or not to create a ground.
  13687. * True by default.
  13688. */
  13689. createGround: boolean;
  13690. /**
  13691. * Specifies the ground size.
  13692. * 15 by default.
  13693. */
  13694. groundSize: number;
  13695. /**
  13696. * The texture used on the ground for the main color.
  13697. * Comes from the BabylonJS CDN by default.
  13698. *
  13699. * Remarks: Can be either a texture or a url.
  13700. */
  13701. groundTexture: string | BaseTexture;
  13702. /**
  13703. * The color mixed in the ground texture by default.
  13704. * BabylonJS clearColor by default.
  13705. */
  13706. groundColor: Color3;
  13707. /**
  13708. * Specifies the ground opacity.
  13709. * 1 by default.
  13710. */
  13711. groundOpacity: number;
  13712. /**
  13713. * Enables the ground to receive shadows.
  13714. * True by default.
  13715. */
  13716. enableGroundShadow: boolean;
  13717. /**
  13718. * Helps preventing the shadow to be fully black on the ground.
  13719. * 0.5 by default.
  13720. */
  13721. groundShadowLevel: number;
  13722. /**
  13723. * Creates a mirror texture attach to the ground.
  13724. * false by default.
  13725. */
  13726. enableGroundMirror: boolean;
  13727. /**
  13728. * Specifies the ground mirror size ratio.
  13729. * 0.3 by default as the default kernel is 64.
  13730. */
  13731. groundMirrorSizeRatio: number;
  13732. /**
  13733. * Specifies the ground mirror blur kernel size.
  13734. * 64 by default.
  13735. */
  13736. groundMirrorBlurKernel: number;
  13737. /**
  13738. * Specifies the ground mirror visibility amount.
  13739. * 1 by default
  13740. */
  13741. groundMirrorAmount: number;
  13742. /**
  13743. * Specifies the ground mirror reflectance weight.
  13744. * This uses the standard weight of the background material to setup the fresnel effect
  13745. * of the mirror.
  13746. * 1 by default.
  13747. */
  13748. groundMirrorFresnelWeight: number;
  13749. /**
  13750. * Specifies the ground mirror Falloff distance.
  13751. * This can helps reducing the size of the reflection.
  13752. * 0 by Default.
  13753. */
  13754. groundMirrorFallOffDistance: number;
  13755. /**
  13756. * Specifies the ground mirror texture type.
  13757. * Unsigned Int by Default.
  13758. */
  13759. groundMirrorTextureType: number;
  13760. /**
  13761. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13762. * the shown objects.
  13763. */
  13764. groundYBias: number;
  13765. /**
  13766. * Specifies wether or not to create a skybox.
  13767. * True by default.
  13768. */
  13769. createSkybox: boolean;
  13770. /**
  13771. * Specifies the skybox size.
  13772. * 20 by default.
  13773. */
  13774. skyboxSize: number;
  13775. /**
  13776. * The texture used on the skybox for the main color.
  13777. * Comes from the BabylonJS CDN by default.
  13778. *
  13779. * Remarks: Can be either a texture or a url.
  13780. */
  13781. skyboxTexture: string | BaseTexture;
  13782. /**
  13783. * The color mixed in the skybox texture by default.
  13784. * BabylonJS clearColor by default.
  13785. */
  13786. skyboxColor: Color3;
  13787. /**
  13788. * The background rotation around the Y axis of the scene.
  13789. * This helps aligning the key lights of your scene with the background.
  13790. * 0 by default.
  13791. */
  13792. backgroundYRotation: number;
  13793. /**
  13794. * Compute automatically the size of the elements to best fit with the scene.
  13795. */
  13796. sizeAuto: boolean;
  13797. /**
  13798. * Default position of the rootMesh if autoSize is not true.
  13799. */
  13800. rootPosition: Vector3;
  13801. /**
  13802. * Sets up the image processing in the scene.
  13803. * true by default.
  13804. */
  13805. setupImageProcessing: boolean;
  13806. /**
  13807. * The texture used as your environment texture in the scene.
  13808. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13809. *
  13810. * Remarks: Can be either a texture or a url.
  13811. */
  13812. environmentTexture: string | BaseTexture;
  13813. /**
  13814. * The value of the exposure to apply to the scene.
  13815. * 0.6 by default if setupImageProcessing is true.
  13816. */
  13817. cameraExposure: number;
  13818. /**
  13819. * The value of the contrast to apply to the scene.
  13820. * 1.6 by default if setupImageProcessing is true.
  13821. */
  13822. cameraContrast: number;
  13823. /**
  13824. * Specifies wether or not tonemapping should be enabled in the scene.
  13825. * true by default if setupImageProcessing is true.
  13826. */
  13827. toneMappingEnabled: boolean;
  13828. }
  13829. /**
  13830. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13831. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13832. * It also helps with the default setup of your imageProcessing configuration.
  13833. */
  13834. class EnvironmentHelper {
  13835. /**
  13836. * Default ground texture URL.
  13837. */
  13838. private static _groundTextureCDNUrl;
  13839. /**
  13840. * Default skybox texture URL.
  13841. */
  13842. private static _skyboxTextureCDNUrl;
  13843. /**
  13844. * Default environment texture URL.
  13845. */
  13846. private static _environmentTextureCDNUrl;
  13847. /**
  13848. * Creates the default options for the helper.
  13849. */
  13850. private static _getDefaultOptions;
  13851. private _rootMesh;
  13852. /**
  13853. * Gets the root mesh created by the helper.
  13854. */
  13855. readonly rootMesh: Mesh;
  13856. private _skybox;
  13857. /**
  13858. * Gets the skybox created by the helper.
  13859. */
  13860. readonly skybox: Nullable<Mesh>;
  13861. private _skyboxTexture;
  13862. /**
  13863. * Gets the skybox texture created by the helper.
  13864. */
  13865. readonly skyboxTexture: Nullable<BaseTexture>;
  13866. private _skyboxMaterial;
  13867. /**
  13868. * Gets the skybox material created by the helper.
  13869. */
  13870. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13871. private _ground;
  13872. /**
  13873. * Gets the ground mesh created by the helper.
  13874. */
  13875. readonly ground: Nullable<Mesh>;
  13876. private _groundTexture;
  13877. /**
  13878. * Gets the ground texture created by the helper.
  13879. */
  13880. readonly groundTexture: Nullable<BaseTexture>;
  13881. private _groundMirror;
  13882. /**
  13883. * Gets the ground mirror created by the helper.
  13884. */
  13885. readonly groundMirror: Nullable<MirrorTexture>;
  13886. /**
  13887. * Gets the ground mirror render list to helps pushing the meshes
  13888. * you wish in the ground reflection.
  13889. */
  13890. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13891. private _groundMaterial;
  13892. /**
  13893. * Gets the ground material created by the helper.
  13894. */
  13895. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13896. /**
  13897. * Stores the creation options.
  13898. */
  13899. private readonly _scene;
  13900. private _options;
  13901. /**
  13902. * This observable will be notified with any error during the creation of the environment,
  13903. * mainly texture creation errors.
  13904. */
  13905. onErrorObservable: Observable<{
  13906. message?: string;
  13907. exception?: any;
  13908. }>;
  13909. /**
  13910. * constructor
  13911. * @param options
  13912. * @param scene The scene to add the material to
  13913. */
  13914. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13915. /**
  13916. * Updates the background according to the new options
  13917. * @param options
  13918. */
  13919. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13920. /**
  13921. * Sets the primary color of all the available elements.
  13922. * @param color the main color to affect to the ground and the background
  13923. */
  13924. setMainColor(color: Color3): void;
  13925. /**
  13926. * Setup the image processing according to the specified options.
  13927. */
  13928. private _setupImageProcessing;
  13929. /**
  13930. * Setup the environment texture according to the specified options.
  13931. */
  13932. private _setupEnvironmentTexture;
  13933. /**
  13934. * Setup the background according to the specified options.
  13935. */
  13936. private _setupBackground;
  13937. /**
  13938. * Get the scene sizes according to the setup.
  13939. */
  13940. private _getSceneSize;
  13941. /**
  13942. * Setup the ground according to the specified options.
  13943. */
  13944. private _setupGround;
  13945. /**
  13946. * Setup the ground material according to the specified options.
  13947. */
  13948. private _setupGroundMaterial;
  13949. /**
  13950. * Setup the ground diffuse texture according to the specified options.
  13951. */
  13952. private _setupGroundDiffuseTexture;
  13953. /**
  13954. * Setup the ground mirror texture according to the specified options.
  13955. */
  13956. private _setupGroundMirrorTexture;
  13957. /**
  13958. * Setup the ground to receive the mirror texture.
  13959. */
  13960. private _setupMirrorInGroundMaterial;
  13961. /**
  13962. * Setup the skybox according to the specified options.
  13963. */
  13964. private _setupSkybox;
  13965. /**
  13966. * Setup the skybox material according to the specified options.
  13967. */
  13968. private _setupSkyboxMaterial;
  13969. /**
  13970. * Setup the skybox reflection texture according to the specified options.
  13971. */
  13972. private _setupSkyboxReflectionTexture;
  13973. private _errorHandler;
  13974. /**
  13975. * Dispose all the elements created by the Helper.
  13976. */
  13977. dispose(): void;
  13978. }
  13979. }
  13980. declare module BABYLON {
  13981. /**
  13982. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13983. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13984. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13985. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13986. */
  13987. class PhotoDome extends TransformNode {
  13988. private _useDirectMapping;
  13989. /**
  13990. * The texture being displayed on the sphere
  13991. */
  13992. protected _photoTexture: Texture;
  13993. /**
  13994. * Gets or sets the texture being displayed on the sphere
  13995. */
  13996. photoTexture: Texture;
  13997. /**
  13998. * Observable raised when an error occured while loading the 360 image
  13999. */
  14000. onLoadErrorObservable: Observable<string>;
  14001. /**
  14002. * The skybox material
  14003. */
  14004. protected _material: BackgroundMaterial;
  14005. /**
  14006. * The surface used for the skybox
  14007. */
  14008. protected _mesh: Mesh;
  14009. /**
  14010. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14011. * Also see the options.resolution property.
  14012. */
  14013. fovMultiplier: number;
  14014. /**
  14015. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  14016. * @param name Element's name, child elements will append suffixes for their own names.
  14017. * @param urlsOfPhoto defines the url of the photo to display
  14018. * @param options defines an object containing optional or exposed sub element properties
  14019. * @param onError defines a callback called when an error occured while loading the texture
  14020. */
  14021. constructor(name: string, urlOfPhoto: string, options: {
  14022. resolution?: number;
  14023. size?: number;
  14024. useDirectMapping?: boolean;
  14025. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  14026. /**
  14027. * Releases resources associated with this node.
  14028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14030. */
  14031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14032. }
  14033. }
  14034. declare module BABYLON {
  14035. interface Scene {
  14036. /**
  14037. * Creates a default light for the scene.
  14038. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  14039. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  14040. */
  14041. createDefaultLight(replace?: boolean): void;
  14042. /**
  14043. * Creates a default camera for the scene.
  14044. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  14045. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14046. * @param replace has default false, when true replaces the active camera in the scene
  14047. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  14048. */
  14049. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14050. /**
  14051. * Creates a default camera and a default light.
  14052. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  14053. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14054. * @param replace has the default false, when true replaces the active camera/light in the scene
  14055. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  14056. */
  14057. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14058. /**
  14059. * Creates a new sky box
  14060. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  14061. * @param environmentTexture defines the texture to use as environment texture
  14062. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  14063. * @param scale defines the overall scale of the skybox
  14064. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14065. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14066. * @returns a new mesh holding the sky box
  14067. */
  14068. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14069. /**
  14070. * Creates a new environment
  14071. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14072. * @param options defines the options you can use to configure the environment
  14073. * @returns the new EnvironmentHelper
  14074. */
  14075. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14076. /**
  14077. * Creates a new VREXperienceHelper
  14078. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14079. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14080. * @returns a new VREXperienceHelper
  14081. */
  14082. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14083. /**
  14084. * Creates a new XREXperienceHelper
  14085. * @see http://doc.babylonjs.com/how_to/webxr
  14086. * @returns a promise for a new XREXperienceHelper
  14087. */
  14088. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14089. }
  14090. }
  14091. declare module BABYLON {
  14092. /**
  14093. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14094. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14095. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14096. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14097. */
  14098. class VideoDome extends TransformNode {
  14099. private _useDirectMapping;
  14100. /**
  14101. * The video texture being displayed on the sphere
  14102. */
  14103. protected _videoTexture: VideoTexture;
  14104. /**
  14105. * Gets the video texture being displayed on the sphere
  14106. */
  14107. readonly videoTexture: VideoTexture;
  14108. /**
  14109. * The skybox material
  14110. */
  14111. protected _material: BackgroundMaterial;
  14112. /**
  14113. * The surface used for the skybox
  14114. */
  14115. protected _mesh: Mesh;
  14116. /**
  14117. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14118. * Also see the options.resolution property.
  14119. */
  14120. fovMultiplier: number;
  14121. /**
  14122. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14123. * @param name Element's name, child elements will append suffixes for their own names.
  14124. * @param urlsOrVideo defines the url(s) or the video element to use
  14125. * @param options An object containing optional or exposed sub element properties
  14126. */
  14127. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14128. resolution?: number;
  14129. clickToPlay?: boolean;
  14130. autoPlay?: boolean;
  14131. loop?: boolean;
  14132. size?: number;
  14133. poster?: string;
  14134. useDirectMapping?: boolean;
  14135. }, scene: Scene);
  14136. /**
  14137. * Releases resources associated with this node.
  14138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14140. */
  14141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14142. }
  14143. }
  14144. declare module BABYLON {
  14145. /**
  14146. * This class can be used to get instrumentation data from a Babylon engine
  14147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14148. */
  14149. class EngineInstrumentation implements IDisposable {
  14150. /**
  14151. * Define the instrumented engine.
  14152. */
  14153. engine: Engine;
  14154. private _captureGPUFrameTime;
  14155. private _gpuFrameTimeToken;
  14156. private _gpuFrameTime;
  14157. private _captureShaderCompilationTime;
  14158. private _shaderCompilationTime;
  14159. private _onBeginFrameObserver;
  14160. private _onEndFrameObserver;
  14161. private _onBeforeShaderCompilationObserver;
  14162. private _onAfterShaderCompilationObserver;
  14163. /**
  14164. * Gets the perf counter used for GPU frame time
  14165. */
  14166. readonly gpuFrameTimeCounter: PerfCounter;
  14167. /**
  14168. * Gets the GPU frame time capture status
  14169. */
  14170. /**
  14171. * Enable or disable the GPU frame time capture
  14172. */
  14173. captureGPUFrameTime: boolean;
  14174. /**
  14175. * Gets the perf counter used for shader compilation time
  14176. */
  14177. readonly shaderCompilationTimeCounter: PerfCounter;
  14178. /**
  14179. * Gets the shader compilation time capture status
  14180. */
  14181. /**
  14182. * Enable or disable the shader compilation time capture
  14183. */
  14184. captureShaderCompilationTime: boolean;
  14185. /**
  14186. * Instantiates a new engine instrumentation.
  14187. * This class can be used to get instrumentation data from a Babylon engine
  14188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14189. * @param engine Defines the engine to instrument
  14190. */
  14191. constructor(
  14192. /**
  14193. * Define the instrumented engine.
  14194. */
  14195. engine: Engine);
  14196. /**
  14197. * Dispose and release associated resources.
  14198. */
  14199. dispose(): void;
  14200. }
  14201. }
  14202. declare module BABYLON {
  14203. /**
  14204. * This class can be used to get instrumentation data from a Babylon engine
  14205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14206. */
  14207. class SceneInstrumentation implements IDisposable {
  14208. /**
  14209. * Defines the scene to instrument
  14210. */
  14211. scene: Scene;
  14212. private _captureActiveMeshesEvaluationTime;
  14213. private _activeMeshesEvaluationTime;
  14214. private _captureRenderTargetsRenderTime;
  14215. private _renderTargetsRenderTime;
  14216. private _captureFrameTime;
  14217. private _frameTime;
  14218. private _captureRenderTime;
  14219. private _renderTime;
  14220. private _captureInterFrameTime;
  14221. private _interFrameTime;
  14222. private _captureParticlesRenderTime;
  14223. private _particlesRenderTime;
  14224. private _captureSpritesRenderTime;
  14225. private _spritesRenderTime;
  14226. private _capturePhysicsTime;
  14227. private _physicsTime;
  14228. private _captureAnimationsTime;
  14229. private _animationsTime;
  14230. private _captureCameraRenderTime;
  14231. private _cameraRenderTime;
  14232. private _onBeforeActiveMeshesEvaluationObserver;
  14233. private _onAfterActiveMeshesEvaluationObserver;
  14234. private _onBeforeRenderTargetsRenderObserver;
  14235. private _onAfterRenderTargetsRenderObserver;
  14236. private _onAfterRenderObserver;
  14237. private _onBeforeDrawPhaseObserver;
  14238. private _onAfterDrawPhaseObserver;
  14239. private _onBeforeAnimationsObserver;
  14240. private _onBeforeParticlesRenderingObserver;
  14241. private _onAfterParticlesRenderingObserver;
  14242. private _onBeforeSpritesRenderingObserver;
  14243. private _onAfterSpritesRenderingObserver;
  14244. private _onBeforePhysicsObserver;
  14245. private _onAfterPhysicsObserver;
  14246. private _onAfterAnimationsObserver;
  14247. private _onBeforeCameraRenderObserver;
  14248. private _onAfterCameraRenderObserver;
  14249. /**
  14250. * Gets the perf counter used for active meshes evaluation time
  14251. */
  14252. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14253. /**
  14254. * Gets the active meshes evaluation time capture status
  14255. */
  14256. /**
  14257. * Enable or disable the active meshes evaluation time capture
  14258. */
  14259. captureActiveMeshesEvaluationTime: boolean;
  14260. /**
  14261. * Gets the perf counter used for render targets render time
  14262. */
  14263. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14264. /**
  14265. * Gets the render targets render time capture status
  14266. */
  14267. /**
  14268. * Enable or disable the render targets render time capture
  14269. */
  14270. captureRenderTargetsRenderTime: boolean;
  14271. /**
  14272. * Gets the perf counter used for particles render time
  14273. */
  14274. readonly particlesRenderTimeCounter: PerfCounter;
  14275. /**
  14276. * Gets the particles render time capture status
  14277. */
  14278. /**
  14279. * Enable or disable the particles render time capture
  14280. */
  14281. captureParticlesRenderTime: boolean;
  14282. /**
  14283. * Gets the perf counter used for sprites render time
  14284. */
  14285. readonly spritesRenderTimeCounter: PerfCounter;
  14286. /**
  14287. * Gets the sprites render time capture status
  14288. */
  14289. /**
  14290. * Enable or disable the sprites render time capture
  14291. */
  14292. captureSpritesRenderTime: boolean;
  14293. /**
  14294. * Gets the perf counter used for physics time
  14295. */
  14296. readonly physicsTimeCounter: PerfCounter;
  14297. /**
  14298. * Gets the physics time capture status
  14299. */
  14300. /**
  14301. * Enable or disable the physics time capture
  14302. */
  14303. capturePhysicsTime: boolean;
  14304. /**
  14305. * Gets the perf counter used for animations time
  14306. */
  14307. readonly animationsTimeCounter: PerfCounter;
  14308. /**
  14309. * Gets the animations time capture status
  14310. */
  14311. /**
  14312. * Enable or disable the animations time capture
  14313. */
  14314. captureAnimationsTime: boolean;
  14315. /**
  14316. * Gets the perf counter used for frame time capture
  14317. */
  14318. readonly frameTimeCounter: PerfCounter;
  14319. /**
  14320. * Gets the frame time capture status
  14321. */
  14322. /**
  14323. * Enable or disable the frame time capture
  14324. */
  14325. captureFrameTime: boolean;
  14326. /**
  14327. * Gets the perf counter used for inter-frames time capture
  14328. */
  14329. readonly interFrameTimeCounter: PerfCounter;
  14330. /**
  14331. * Gets the inter-frames time capture status
  14332. */
  14333. /**
  14334. * Enable or disable the inter-frames time capture
  14335. */
  14336. captureInterFrameTime: boolean;
  14337. /**
  14338. * Gets the perf counter used for render time capture
  14339. */
  14340. readonly renderTimeCounter: PerfCounter;
  14341. /**
  14342. * Gets the render time capture status
  14343. */
  14344. /**
  14345. * Enable or disable the render time capture
  14346. */
  14347. captureRenderTime: boolean;
  14348. /**
  14349. * Gets the perf counter used for camera render time capture
  14350. */
  14351. readonly cameraRenderTimeCounter: PerfCounter;
  14352. /**
  14353. * Gets the camera render time capture status
  14354. */
  14355. /**
  14356. * Enable or disable the camera render time capture
  14357. */
  14358. captureCameraRenderTime: boolean;
  14359. /**
  14360. * Gets the perf counter used for draw calls
  14361. */
  14362. readonly drawCallsCounter: PerfCounter;
  14363. /**
  14364. * Gets the perf counter used for texture collisions
  14365. */
  14366. readonly textureCollisionsCounter: PerfCounter;
  14367. /**
  14368. * Instantiates a new scene instrumentation.
  14369. * This class can be used to get instrumentation data from a Babylon engine
  14370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14371. * @param scene Defines the scene to instrument
  14372. */
  14373. constructor(
  14374. /**
  14375. * Defines the scene to instrument
  14376. */
  14377. scene: Scene);
  14378. /**
  14379. * Dispose and release associated resources.
  14380. */
  14381. dispose(): void;
  14382. }
  14383. }
  14384. declare module BABYLON {
  14385. /**
  14386. * @hidden
  14387. **/
  14388. class _TimeToken {
  14389. _startTimeQuery: Nullable<WebGLQuery>;
  14390. _endTimeQuery: Nullable<WebGLQuery>;
  14391. _timeElapsedQuery: Nullable<WebGLQuery>;
  14392. _timeElapsedQueryEnded: boolean;
  14393. }
  14394. }
  14395. declare module BABYLON {
  14396. /**
  14397. * Effect layer options. This helps customizing the behaviour
  14398. * of the effect layer.
  14399. */
  14400. interface IEffectLayerOptions {
  14401. /**
  14402. * Multiplication factor apply to the canvas size to compute the render target size
  14403. * used to generated the objects (the smaller the faster).
  14404. */
  14405. mainTextureRatio: number;
  14406. /**
  14407. * Enforces a fixed size texture to ensure effect stability across devices.
  14408. */
  14409. mainTextureFixedSize?: number;
  14410. /**
  14411. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14412. */
  14413. alphaBlendingMode: number;
  14414. /**
  14415. * The camera attached to the layer.
  14416. */
  14417. camera: Nullable<Camera>;
  14418. /**
  14419. * The rendering group to draw the layer in.
  14420. */
  14421. renderingGroupId: number;
  14422. }
  14423. /**
  14424. * The effect layer Helps adding post process effect blended with the main pass.
  14425. *
  14426. * This can be for instance use to generate glow or higlight effects on the scene.
  14427. *
  14428. * The effect layer class can not be used directly and is intented to inherited from to be
  14429. * customized per effects.
  14430. */
  14431. abstract class EffectLayer {
  14432. private _vertexBuffers;
  14433. private _indexBuffer;
  14434. private _cachedDefines;
  14435. private _effectLayerMapGenerationEffect;
  14436. private _effectLayerOptions;
  14437. private _mergeEffect;
  14438. protected _scene: Scene;
  14439. protected _engine: Engine;
  14440. protected _maxSize: number;
  14441. protected _mainTextureDesiredSize: ISize;
  14442. protected _mainTexture: RenderTargetTexture;
  14443. protected _shouldRender: boolean;
  14444. protected _postProcesses: PostProcess[];
  14445. protected _textures: BaseTexture[];
  14446. protected _emissiveTextureAndColor: {
  14447. texture: Nullable<BaseTexture>;
  14448. color: Color4;
  14449. };
  14450. /**
  14451. * The name of the layer
  14452. */
  14453. name: string;
  14454. /**
  14455. * The clear color of the texture used to generate the glow map.
  14456. */
  14457. neutralColor: Color4;
  14458. /**
  14459. * Specifies wether the highlight layer is enabled or not.
  14460. */
  14461. isEnabled: boolean;
  14462. /**
  14463. * Gets the camera attached to the layer.
  14464. */
  14465. readonly camera: Nullable<Camera>;
  14466. /**
  14467. * Gets the rendering group id the layer should render in.
  14468. */
  14469. readonly renderingGroupId: number;
  14470. /**
  14471. * An event triggered when the effect layer has been disposed.
  14472. */
  14473. onDisposeObservable: Observable<EffectLayer>;
  14474. /**
  14475. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14476. */
  14477. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14478. /**
  14479. * An event triggered when the generated texture is being merged in the scene.
  14480. */
  14481. onBeforeComposeObservable: Observable<EffectLayer>;
  14482. /**
  14483. * An event triggered when the generated texture has been merged in the scene.
  14484. */
  14485. onAfterComposeObservable: Observable<EffectLayer>;
  14486. /**
  14487. * An event triggered when the efffect layer changes its size.
  14488. */
  14489. onSizeChangedObservable: Observable<EffectLayer>;
  14490. /**
  14491. * Instantiates a new effect Layer and references it in the scene.
  14492. * @param name The name of the layer
  14493. * @param scene The scene to use the layer in
  14494. */
  14495. constructor(
  14496. /** The Friendly of the effect in the scene */
  14497. name: string, scene: Scene);
  14498. /**
  14499. * Get the effect name of the layer.
  14500. * @return The effect name
  14501. */
  14502. abstract getEffectName(): string;
  14503. /**
  14504. * Checks for the readiness of the element composing the layer.
  14505. * @param subMesh the mesh to check for
  14506. * @param useInstances specify wether or not to use instances to render the mesh
  14507. * @return true if ready otherwise, false
  14508. */
  14509. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14510. /**
  14511. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14512. * @returns true if the effect requires stencil during the main canvas render pass.
  14513. */
  14514. abstract needStencil(): boolean;
  14515. /**
  14516. * Create the merge effect. This is the shader use to blit the information back
  14517. * to the main canvas at the end of the scene rendering.
  14518. * @returns The effect containing the shader used to merge the effect on the main canvas
  14519. */
  14520. protected abstract _createMergeEffect(): Effect;
  14521. /**
  14522. * Creates the render target textures and post processes used in the effect layer.
  14523. */
  14524. protected abstract _createTextureAndPostProcesses(): void;
  14525. /**
  14526. * Implementation specific of rendering the generating effect on the main canvas.
  14527. * @param effect The effect used to render through
  14528. */
  14529. protected abstract _internalRender(effect: Effect): void;
  14530. /**
  14531. * Sets the required values for both the emissive texture and and the main color.
  14532. */
  14533. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14534. /**
  14535. * Free any resources and references associated to a mesh.
  14536. * Internal use
  14537. * @param mesh The mesh to free.
  14538. */
  14539. abstract _disposeMesh(mesh: Mesh): void;
  14540. /**
  14541. * Serializes this layer (Glow or Highlight for example)
  14542. * @returns a serialized layer object
  14543. */
  14544. abstract serialize?(): any;
  14545. /**
  14546. * Initializes the effect layer with the required options.
  14547. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14548. */
  14549. protected _init(options: Partial<IEffectLayerOptions>): void;
  14550. /**
  14551. * Generates the index buffer of the full screen quad blending to the main canvas.
  14552. */
  14553. private _generateIndexBuffer;
  14554. /**
  14555. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14556. */
  14557. private _genrateVertexBuffer;
  14558. /**
  14559. * Sets the main texture desired size which is the closest power of two
  14560. * of the engine canvas size.
  14561. */
  14562. private _setMainTextureSize;
  14563. /**
  14564. * Creates the main texture for the effect layer.
  14565. */
  14566. protected _createMainTexture(): void;
  14567. /**
  14568. * Checks for the readiness of the element composing the layer.
  14569. * @param subMesh the mesh to check for
  14570. * @param useInstances specify wether or not to use instances to render the mesh
  14571. * @param emissiveTexture the associated emissive texture used to generate the glow
  14572. * @return true if ready otherwise, false
  14573. */
  14574. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14575. /**
  14576. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14577. */
  14578. render(): void;
  14579. /**
  14580. * Determine if a given mesh will be used in the current effect.
  14581. * @param mesh mesh to test
  14582. * @returns true if the mesh will be used
  14583. */
  14584. hasMesh(mesh: AbstractMesh): boolean;
  14585. /**
  14586. * Returns true if the layer contains information to display, otherwise false.
  14587. * @returns true if the glow layer should be rendered
  14588. */
  14589. shouldRender(): boolean;
  14590. /**
  14591. * Returns true if the mesh should render, otherwise false.
  14592. * @param mesh The mesh to render
  14593. * @returns true if it should render otherwise false
  14594. */
  14595. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14596. /**
  14597. * Returns true if the mesh should render, otherwise false.
  14598. * @param mesh The mesh to render
  14599. * @returns true if it should render otherwise false
  14600. */
  14601. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14602. /**
  14603. * Renders the submesh passed in parameter to the generation map.
  14604. */
  14605. protected _renderSubMesh(subMesh: SubMesh): void;
  14606. /**
  14607. * Rebuild the required buffers.
  14608. * @hidden Internal use only.
  14609. */
  14610. _rebuild(): void;
  14611. /**
  14612. * Dispose only the render target textures and post process.
  14613. */
  14614. private _disposeTextureAndPostProcesses;
  14615. /**
  14616. * Dispose the highlight layer and free resources.
  14617. */
  14618. dispose(): void;
  14619. /**
  14620. * Gets the class name of the effect layer
  14621. * @returns the string with the class name of the effect layer
  14622. */
  14623. getClassName(): string;
  14624. /**
  14625. * Creates an effect layer from parsed effect layer data
  14626. * @param parsedEffectLayer defines effect layer data
  14627. * @param scene defines the current scene
  14628. * @param rootUrl defines the root URL containing the effect layer information
  14629. * @returns a parsed effect Layer
  14630. */
  14631. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14632. }
  14633. }
  14634. declare module BABYLON {
  14635. interface AbstractScene {
  14636. /**
  14637. * The list of effect layers (highlights/glow) added to the scene
  14638. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14639. * @see http://doc.babylonjs.com/how_to/glow_layer
  14640. */
  14641. effectLayers: Array<EffectLayer>;
  14642. /**
  14643. * Removes the given effect layer from this scene.
  14644. * @param toRemove defines the effect layer to remove
  14645. * @returns the index of the removed effect layer
  14646. */
  14647. removeEffectLayer(toRemove: EffectLayer): number;
  14648. /**
  14649. * Adds the given effect layer to this scene
  14650. * @param newEffectLayer defines the effect layer to add
  14651. */
  14652. addEffectLayer(newEffectLayer: EffectLayer): void;
  14653. }
  14654. /**
  14655. * Defines the layer scene component responsible to manage any effect layers
  14656. * in a given scene.
  14657. */
  14658. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14659. /**
  14660. * The component name helpfull to identify the component in the list of scene components.
  14661. */
  14662. readonly name: string;
  14663. /**
  14664. * The scene the component belongs to.
  14665. */
  14666. scene: Scene;
  14667. private _engine;
  14668. private _renderEffects;
  14669. private _needStencil;
  14670. private _previousStencilState;
  14671. /**
  14672. * Creates a new instance of the component for the given scene
  14673. * @param scene Defines the scene to register the component in
  14674. */
  14675. constructor(scene: Scene);
  14676. /**
  14677. * Registers the component in a given scene
  14678. */
  14679. register(): void;
  14680. /**
  14681. * Rebuilds the elements related to this component in case of
  14682. * context lost for instance.
  14683. */
  14684. rebuild(): void;
  14685. /**
  14686. * Serializes the component data to the specified json object
  14687. * @param serializationObject The object to serialize to
  14688. */
  14689. serialize(serializationObject: any): void;
  14690. /**
  14691. * Adds all the element from the container to the scene
  14692. * @param container the container holding the elements
  14693. */
  14694. addFromContainer(container: AbstractScene): void;
  14695. /**
  14696. * Removes all the elements in the container from the scene
  14697. * @param container contains the elements to remove
  14698. */
  14699. removeFromContainer(container: AbstractScene): void;
  14700. /**
  14701. * Disposes the component and the associated ressources.
  14702. */
  14703. dispose(): void;
  14704. private _isReadyForMesh;
  14705. private _renderMainTexture;
  14706. private _setStencil;
  14707. private _setStencilBack;
  14708. private _draw;
  14709. private _drawCamera;
  14710. private _drawRenderingGroup;
  14711. }
  14712. }
  14713. declare module BABYLON {
  14714. interface AbstractScene {
  14715. /**
  14716. * Return a the first highlight layer of the scene with a given name.
  14717. * @param name The name of the highlight layer to look for.
  14718. * @return The highlight layer if found otherwise null.
  14719. */
  14720. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14721. }
  14722. /**
  14723. * Glow layer options. This helps customizing the behaviour
  14724. * of the glow layer.
  14725. */
  14726. interface IGlowLayerOptions {
  14727. /**
  14728. * Multiplication factor apply to the canvas size to compute the render target size
  14729. * used to generated the glowing objects (the smaller the faster).
  14730. */
  14731. mainTextureRatio: number;
  14732. /**
  14733. * Enforces a fixed size texture to ensure resize independant blur.
  14734. */
  14735. mainTextureFixedSize?: number;
  14736. /**
  14737. * How big is the kernel of the blur texture.
  14738. */
  14739. blurKernelSize: number;
  14740. /**
  14741. * The camera attached to the layer.
  14742. */
  14743. camera: Nullable<Camera>;
  14744. /**
  14745. * Enable MSAA by chosing the number of samples.
  14746. */
  14747. mainTextureSamples?: number;
  14748. /**
  14749. * The rendering group to draw the layer in.
  14750. */
  14751. renderingGroupId: number;
  14752. }
  14753. /**
  14754. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14755. *
  14756. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14757. * glowy meshes to your scene.
  14758. *
  14759. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14760. */
  14761. class GlowLayer extends EffectLayer {
  14762. /**
  14763. * Effect Name of the layer.
  14764. */
  14765. static readonly EffectName: string;
  14766. /**
  14767. * The default blur kernel size used for the glow.
  14768. */
  14769. static DefaultBlurKernelSize: number;
  14770. /**
  14771. * The default texture size ratio used for the glow.
  14772. */
  14773. static DefaultTextureRatio: number;
  14774. /**
  14775. * Sets the kernel size of the blur.
  14776. */
  14777. /**
  14778. * Gets the kernel size of the blur.
  14779. */
  14780. blurKernelSize: number;
  14781. /**
  14782. * Sets the glow intensity.
  14783. */
  14784. /**
  14785. * Gets the glow intensity.
  14786. */
  14787. intensity: number;
  14788. private _options;
  14789. private _intensity;
  14790. private _horizontalBlurPostprocess1;
  14791. private _verticalBlurPostprocess1;
  14792. private _horizontalBlurPostprocess2;
  14793. private _verticalBlurPostprocess2;
  14794. private _blurTexture1;
  14795. private _blurTexture2;
  14796. private _postProcesses1;
  14797. private _postProcesses2;
  14798. private _includedOnlyMeshes;
  14799. private _excludedMeshes;
  14800. /**
  14801. * Callback used to let the user override the color selection on a per mesh basis
  14802. */
  14803. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14804. /**
  14805. * Callback used to let the user override the texture selection on a per mesh basis
  14806. */
  14807. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14808. /**
  14809. * Instantiates a new glow Layer and references it to the scene.
  14810. * @param name The name of the layer
  14811. * @param scene The scene to use the layer in
  14812. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14813. */
  14814. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14815. /**
  14816. * Get the effect name of the layer.
  14817. * @return The effect name
  14818. */
  14819. getEffectName(): string;
  14820. /**
  14821. * Create the merge effect. This is the shader use to blit the information back
  14822. * to the main canvas at the end of the scene rendering.
  14823. */
  14824. protected _createMergeEffect(): Effect;
  14825. /**
  14826. * Creates the render target textures and post processes used in the glow layer.
  14827. */
  14828. protected _createTextureAndPostProcesses(): void;
  14829. /**
  14830. * Checks for the readiness of the element composing the layer.
  14831. * @param subMesh the mesh to check for
  14832. * @param useInstances specify wether or not to use instances to render the mesh
  14833. * @param emissiveTexture the associated emissive texture used to generate the glow
  14834. * @return true if ready otherwise, false
  14835. */
  14836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14837. /**
  14838. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14839. */
  14840. needStencil(): boolean;
  14841. /**
  14842. * Implementation specific of rendering the generating effect on the main canvas.
  14843. * @param effect The effect used to render through
  14844. */
  14845. protected _internalRender(effect: Effect): void;
  14846. /**
  14847. * Sets the required values for both the emissive texture and and the main color.
  14848. */
  14849. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14850. /**
  14851. * Returns true if the mesh should render, otherwise false.
  14852. * @param mesh The mesh to render
  14853. * @returns true if it should render otherwise false
  14854. */
  14855. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14856. /**
  14857. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14858. * @param mesh The mesh to exclude from the glow layer
  14859. */
  14860. addExcludedMesh(mesh: Mesh): void;
  14861. /**
  14862. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14863. * @param mesh The mesh to remove
  14864. */
  14865. removeExcludedMesh(mesh: Mesh): void;
  14866. /**
  14867. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14868. * @param mesh The mesh to include in the glow layer
  14869. */
  14870. addIncludedOnlyMesh(mesh: Mesh): void;
  14871. /**
  14872. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14873. * @param mesh The mesh to remove
  14874. */
  14875. removeIncludedOnlyMesh(mesh: Mesh): void;
  14876. /**
  14877. * Determine if a given mesh will be used in the glow layer
  14878. * @param mesh The mesh to test
  14879. * @returns true if the mesh will be highlighted by the current glow layer
  14880. */
  14881. hasMesh(mesh: AbstractMesh): boolean;
  14882. /**
  14883. * Free any resources and references associated to a mesh.
  14884. * Internal use
  14885. * @param mesh The mesh to free.
  14886. * @hidden
  14887. */
  14888. _disposeMesh(mesh: Mesh): void;
  14889. /**
  14890. * Gets the class name of the effect layer
  14891. * @returns the string with the class name of the effect layer
  14892. */
  14893. getClassName(): string;
  14894. /**
  14895. * Serializes this glow layer
  14896. * @returns a serialized glow layer object
  14897. */
  14898. serialize(): any;
  14899. /**
  14900. * Creates a Glow Layer from parsed glow layer data
  14901. * @param parsedGlowLayer defines glow layer data
  14902. * @param scene defines the current scene
  14903. * @param rootUrl defines the root URL containing the glow layer information
  14904. * @returns a parsed Glow Layer
  14905. */
  14906. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14907. }
  14908. }
  14909. declare module BABYLON {
  14910. interface AbstractScene {
  14911. /**
  14912. * Return a the first highlight layer of the scene with a given name.
  14913. * @param name The name of the highlight layer to look for.
  14914. * @return The highlight layer if found otherwise null.
  14915. */
  14916. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14917. }
  14918. /**
  14919. * Highlight layer options. This helps customizing the behaviour
  14920. * of the highlight layer.
  14921. */
  14922. interface IHighlightLayerOptions {
  14923. /**
  14924. * Multiplication factor apply to the canvas size to compute the render target size
  14925. * used to generated the glowing objects (the smaller the faster).
  14926. */
  14927. mainTextureRatio: number;
  14928. /**
  14929. * Enforces a fixed size texture to ensure resize independant blur.
  14930. */
  14931. mainTextureFixedSize?: number;
  14932. /**
  14933. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14934. * of the picture to blur (the smaller the faster).
  14935. */
  14936. blurTextureSizeRatio: number;
  14937. /**
  14938. * How big in texel of the blur texture is the vertical blur.
  14939. */
  14940. blurVerticalSize: number;
  14941. /**
  14942. * How big in texel of the blur texture is the horizontal blur.
  14943. */
  14944. blurHorizontalSize: number;
  14945. /**
  14946. * Alpha blending mode used to apply the blur. Default is combine.
  14947. */
  14948. alphaBlendingMode: number;
  14949. /**
  14950. * The camera attached to the layer.
  14951. */
  14952. camera: Nullable<Camera>;
  14953. /**
  14954. * Should we display highlight as a solid stroke?
  14955. */
  14956. isStroke?: boolean;
  14957. /**
  14958. * The rendering group to draw the layer in.
  14959. */
  14960. renderingGroupId: number;
  14961. }
  14962. /**
  14963. * The highlight layer Helps adding a glow effect around a mesh.
  14964. *
  14965. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14966. * glowy meshes to your scene.
  14967. *
  14968. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14969. */
  14970. class HighlightLayer extends EffectLayer {
  14971. name: string;
  14972. /**
  14973. * Effect Name of the highlight layer.
  14974. */
  14975. static readonly EffectName: string;
  14976. /**
  14977. * The neutral color used during the preparation of the glow effect.
  14978. * This is black by default as the blend operation is a blend operation.
  14979. */
  14980. static NeutralColor: Color4;
  14981. /**
  14982. * Stencil value used for glowing meshes.
  14983. */
  14984. static GlowingMeshStencilReference: number;
  14985. /**
  14986. * Stencil value used for the other meshes in the scene.
  14987. */
  14988. static NormalMeshStencilReference: number;
  14989. /**
  14990. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14991. */
  14992. innerGlow: boolean;
  14993. /**
  14994. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14995. */
  14996. outerGlow: boolean;
  14997. /**
  14998. * Specifies the horizontal size of the blur.
  14999. */
  15000. /**
  15001. * Gets the horizontal size of the blur.
  15002. */
  15003. blurHorizontalSize: number;
  15004. /**
  15005. * Specifies the vertical size of the blur.
  15006. */
  15007. /**
  15008. * Gets the vertical size of the blur.
  15009. */
  15010. blurVerticalSize: number;
  15011. /**
  15012. * An event triggered when the highlight layer is being blurred.
  15013. */
  15014. onBeforeBlurObservable: Observable<HighlightLayer>;
  15015. /**
  15016. * An event triggered when the highlight layer has been blurred.
  15017. */
  15018. onAfterBlurObservable: Observable<HighlightLayer>;
  15019. private _instanceGlowingMeshStencilReference;
  15020. private _options;
  15021. private _downSamplePostprocess;
  15022. private _horizontalBlurPostprocess;
  15023. private _verticalBlurPostprocess;
  15024. private _blurTexture;
  15025. private _meshes;
  15026. private _excludedMeshes;
  15027. /**
  15028. * Instantiates a new highlight Layer and references it to the scene..
  15029. * @param name The name of the layer
  15030. * @param scene The scene to use the layer in
  15031. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15032. */
  15033. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15034. /**
  15035. * Get the effect name of the layer.
  15036. * @return The effect name
  15037. */
  15038. getEffectName(): string;
  15039. /**
  15040. * Create the merge effect. This is the shader use to blit the information back
  15041. * to the main canvas at the end of the scene rendering.
  15042. */
  15043. protected _createMergeEffect(): Effect;
  15044. /**
  15045. * Creates the render target textures and post processes used in the highlight layer.
  15046. */
  15047. protected _createTextureAndPostProcesses(): void;
  15048. /**
  15049. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15050. */
  15051. needStencil(): boolean;
  15052. /**
  15053. * Checks for the readiness of the element composing the layer.
  15054. * @param subMesh the mesh to check for
  15055. * @param useInstances specify wether or not to use instances to render the mesh
  15056. * @param emissiveTexture the associated emissive texture used to generate the glow
  15057. * @return true if ready otherwise, false
  15058. */
  15059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15060. /**
  15061. * Implementation specific of rendering the generating effect on the main canvas.
  15062. * @param effect The effect used to render through
  15063. */
  15064. protected _internalRender(effect: Effect): void;
  15065. /**
  15066. * Returns true if the layer contains information to display, otherwise false.
  15067. */
  15068. shouldRender(): boolean;
  15069. /**
  15070. * Returns true if the mesh should render, otherwise false.
  15071. * @param mesh The mesh to render
  15072. * @returns true if it should render otherwise false
  15073. */
  15074. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15075. /**
  15076. * Sets the required values for both the emissive texture and and the main color.
  15077. */
  15078. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15079. /**
  15080. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15081. * @param mesh The mesh to exclude from the highlight layer
  15082. */
  15083. addExcludedMesh(mesh: Mesh): void;
  15084. /**
  15085. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15086. * @param mesh The mesh to highlight
  15087. */
  15088. removeExcludedMesh(mesh: Mesh): void;
  15089. /**
  15090. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15091. * @param mesh mesh to test
  15092. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15093. */
  15094. hasMesh(mesh: AbstractMesh): boolean;
  15095. /**
  15096. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15097. * @param mesh The mesh to highlight
  15098. * @param color The color of the highlight
  15099. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15100. */
  15101. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15102. /**
  15103. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15104. * @param mesh The mesh to highlight
  15105. */
  15106. removeMesh(mesh: Mesh): void;
  15107. /**
  15108. * Force the stencil to the normal expected value for none glowing parts
  15109. */
  15110. private _defaultStencilReference;
  15111. /**
  15112. * Free any resources and references associated to a mesh.
  15113. * Internal use
  15114. * @param mesh The mesh to free.
  15115. * @hidden
  15116. */
  15117. _disposeMesh(mesh: Mesh): void;
  15118. /**
  15119. * Dispose the highlight layer and free resources.
  15120. */
  15121. dispose(): void;
  15122. /**
  15123. * Gets the class name of the effect layer
  15124. * @returns the string with the class name of the effect layer
  15125. */
  15126. getClassName(): string;
  15127. /**
  15128. * Serializes this Highlight layer
  15129. * @returns a serialized Highlight layer object
  15130. */
  15131. serialize(): any;
  15132. /**
  15133. * Creates a Highlight layer from parsed Highlight layer data
  15134. * @param parsedHightlightLayer defines the Highlight layer data
  15135. * @param scene defines the current scene
  15136. * @param rootUrl defines the root URL containing the Highlight layer information
  15137. * @returns a parsed Highlight layer
  15138. */
  15139. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15140. }
  15141. }
  15142. declare module BABYLON {
  15143. /**
  15144. * This represents a full screen 2d layer.
  15145. * This can be useful to display a picture in the background of your scene for instance.
  15146. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15147. */
  15148. class Layer {
  15149. /**
  15150. * Define the name of the layer.
  15151. */
  15152. name: string;
  15153. /**
  15154. * Define the texture the layer should display.
  15155. */
  15156. texture: Nullable<Texture>;
  15157. /**
  15158. * Is the layer in background or foreground.
  15159. */
  15160. isBackground: boolean;
  15161. /**
  15162. * Define the color of the layer (instead of texture).
  15163. */
  15164. color: Color4;
  15165. /**
  15166. * Define the scale of the layer in order to zoom in out of the texture.
  15167. */
  15168. scale: Vector2;
  15169. /**
  15170. * Define an offset for the layer in order to shift the texture.
  15171. */
  15172. offset: Vector2;
  15173. /**
  15174. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15175. */
  15176. alphaBlendingMode: number;
  15177. /**
  15178. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15179. * Alpha test will not mix with the background color in case of transparency.
  15180. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15181. */
  15182. alphaTest: boolean;
  15183. /**
  15184. * Define a mask to restrict the layer to only some of the scene cameras.
  15185. */
  15186. layerMask: number;
  15187. /**
  15188. * Define the list of render target the layer is visible into.
  15189. */
  15190. renderTargetTextures: RenderTargetTexture[];
  15191. /**
  15192. * Define if the layer is only used in renderTarget or if it also
  15193. * renders in the main frame buffer of the canvas.
  15194. */
  15195. renderOnlyInRenderTargetTextures: boolean;
  15196. private _scene;
  15197. private _vertexBuffers;
  15198. private _indexBuffer;
  15199. private _effect;
  15200. private _alphaTestEffect;
  15201. /**
  15202. * An event triggered when the layer is disposed.
  15203. */
  15204. onDisposeObservable: Observable<Layer>;
  15205. private _onDisposeObserver;
  15206. /**
  15207. * Back compatibility with callback before the onDisposeObservable existed.
  15208. * The set callback will be triggered when the layer has been disposed.
  15209. */
  15210. onDispose: () => void;
  15211. /**
  15212. * An event triggered before rendering the scene
  15213. */
  15214. onBeforeRenderObservable: Observable<Layer>;
  15215. private _onBeforeRenderObserver;
  15216. /**
  15217. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15218. * The set callback will be triggered just before rendering the layer.
  15219. */
  15220. onBeforeRender: () => void;
  15221. /**
  15222. * An event triggered after rendering the scene
  15223. */
  15224. onAfterRenderObservable: Observable<Layer>;
  15225. private _onAfterRenderObserver;
  15226. /**
  15227. * Back compatibility with callback before the onAfterRenderObservable existed.
  15228. * The set callback will be triggered just after rendering the layer.
  15229. */
  15230. onAfterRender: () => void;
  15231. /**
  15232. * Instantiates a new layer.
  15233. * This represents a full screen 2d layer.
  15234. * This can be useful to display a picture in the background of your scene for instance.
  15235. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15236. * @param name Define the name of the layer in the scene
  15237. * @param imgUrl Define the url of the texture to display in the layer
  15238. * @param scene Define the scene the layer belongs to
  15239. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15240. * @param color Defines a color for the layer
  15241. */
  15242. constructor(
  15243. /**
  15244. * Define the name of the layer.
  15245. */
  15246. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15247. private _createIndexBuffer;
  15248. /** @hidden */
  15249. _rebuild(): void;
  15250. /**
  15251. * Renders the layer in the scene.
  15252. */
  15253. render(): void;
  15254. /**
  15255. * Disposes and releases the associated ressources.
  15256. */
  15257. dispose(): void;
  15258. }
  15259. }
  15260. declare module BABYLON {
  15261. interface AbstractScene {
  15262. /**
  15263. * The list of layers (background and foreground) of the scene
  15264. */
  15265. layers: Array<Layer>;
  15266. }
  15267. /**
  15268. * Defines the layer scene component responsible to manage any layers
  15269. * in a given scene.
  15270. */
  15271. class LayerSceneComponent implements ISceneComponent {
  15272. /**
  15273. * The component name helpfull to identify the component in the list of scene components.
  15274. */
  15275. readonly name: string;
  15276. /**
  15277. * The scene the component belongs to.
  15278. */
  15279. scene: Scene;
  15280. private _engine;
  15281. /**
  15282. * Creates a new instance of the component for the given scene
  15283. * @param scene Defines the scene to register the component in
  15284. */
  15285. constructor(scene: Scene);
  15286. /**
  15287. * Registers the component in a given scene
  15288. */
  15289. register(): void;
  15290. /**
  15291. * Rebuilds the elements related to this component in case of
  15292. * context lost for instance.
  15293. */
  15294. rebuild(): void;
  15295. /**
  15296. * Disposes the component and the associated ressources.
  15297. */
  15298. dispose(): void;
  15299. private _draw;
  15300. private _drawCameraPredicate;
  15301. private _drawCameraBackground;
  15302. private _drawCameraForeground;
  15303. private _drawRenderTargetPredicate;
  15304. private _drawRenderTargetBackground;
  15305. private _drawRenderTargetForeground;
  15306. }
  15307. }
  15308. declare module BABYLON {
  15309. /**
  15310. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15311. * It controls one of the indiviual texture used in the effect.
  15312. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15313. */
  15314. class LensFlare {
  15315. /**
  15316. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15317. */
  15318. size: number;
  15319. /**
  15320. * 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.
  15321. */
  15322. position: number;
  15323. /**
  15324. * Define the lens color.
  15325. */
  15326. color: Color3;
  15327. /**
  15328. * Define the lens texture.
  15329. */
  15330. texture: Nullable<Texture>;
  15331. /**
  15332. * Define the alpha mode to render this particular lens.
  15333. */
  15334. alphaMode: number;
  15335. private _system;
  15336. /**
  15337. * Creates a new Lens Flare.
  15338. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15339. * It controls one of the indiviual texture used in the effect.
  15340. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15341. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15342. * @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.
  15343. * @param color Define the lens color
  15344. * @param imgUrl Define the lens texture url
  15345. * @param system Define the `lensFlareSystem` this flare is part of
  15346. * @returns The newly created Lens Flare
  15347. */
  15348. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15349. /**
  15350. * Instantiates a new Lens Flare.
  15351. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15352. * It controls one of the indiviual texture used in the effect.
  15353. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15354. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15355. * @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.
  15356. * @param color Define the lens color
  15357. * @param imgUrl Define the lens texture url
  15358. * @param system Define the `lensFlareSystem` this flare is part of
  15359. */
  15360. constructor(
  15361. /**
  15362. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15363. */
  15364. size: number,
  15365. /**
  15366. * 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.
  15367. */
  15368. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15369. /**
  15370. * Dispose and release the lens flare with its associated resources.
  15371. */
  15372. dispose(): void;
  15373. }
  15374. }
  15375. declare module BABYLON {
  15376. /**
  15377. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15378. * It is usually composed of several `BABYLON.lensFlare`.
  15379. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15380. */
  15381. class LensFlareSystem {
  15382. /**
  15383. * Define the name of the lens flare system
  15384. */
  15385. name: string;
  15386. /**
  15387. * List of lens flares used in this system.
  15388. */
  15389. lensFlares: LensFlare[];
  15390. /**
  15391. * Define a limit from the border the lens flare can be visible.
  15392. */
  15393. borderLimit: number;
  15394. /**
  15395. * Define a viewport border we do not want to see the lens flare in.
  15396. */
  15397. viewportBorder: number;
  15398. /**
  15399. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15400. */
  15401. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15402. /**
  15403. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15404. */
  15405. layerMask: number;
  15406. /**
  15407. * Define the id of the lens flare system in the scene.
  15408. * (equal to name by default)
  15409. */
  15410. id: string;
  15411. private _scene;
  15412. private _emitter;
  15413. private _vertexBuffers;
  15414. private _indexBuffer;
  15415. private _effect;
  15416. private _positionX;
  15417. private _positionY;
  15418. private _isEnabled;
  15419. /**
  15420. * Instantiates a lens flare system.
  15421. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15422. * It is usually composed of several `BABYLON.lensFlare`.
  15423. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15424. * @param name Define the name of the lens flare system in the scene
  15425. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15426. * @param scene Define the scene the lens flare system belongs to
  15427. */
  15428. constructor(
  15429. /**
  15430. * Define the name of the lens flare system
  15431. */
  15432. name: string, emitter: any, scene: Scene);
  15433. /**
  15434. * Define if the lens flare system is enabled.
  15435. */
  15436. isEnabled: boolean;
  15437. /**
  15438. * Get the scene the effects belongs to.
  15439. * @returns the scene holding the lens flare system
  15440. */
  15441. getScene(): Scene;
  15442. /**
  15443. * Get the emitter of the lens flare system.
  15444. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15445. * @returns the emitter of the lens flare system
  15446. */
  15447. getEmitter(): any;
  15448. /**
  15449. * Set the emitter of the lens flare system.
  15450. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15451. * @param newEmitter Define the new emitter of the system
  15452. */
  15453. setEmitter(newEmitter: any): void;
  15454. /**
  15455. * Get the lens flare system emitter position.
  15456. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15457. * @returns the position
  15458. */
  15459. getEmitterPosition(): Vector3;
  15460. /**
  15461. * @hidden
  15462. */
  15463. computeEffectivePosition(globalViewport: Viewport): boolean;
  15464. /** @hidden */
  15465. _isVisible(): boolean;
  15466. /**
  15467. * @hidden
  15468. */
  15469. render(): boolean;
  15470. /**
  15471. * Dispose and release the lens flare with its associated resources.
  15472. */
  15473. dispose(): void;
  15474. /**
  15475. * Parse a lens flare system from a JSON repressentation
  15476. * @param parsedLensFlareSystem Define the JSON to parse
  15477. * @param scene Define the scene the parsed system should be instantiated in
  15478. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15479. * @returns the parsed system
  15480. */
  15481. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15482. /**
  15483. * Serialize the current Lens Flare System into a JSON representation.
  15484. * @returns the serialized JSON
  15485. */
  15486. serialize(): any;
  15487. }
  15488. }
  15489. declare module BABYLON {
  15490. interface AbstractScene {
  15491. /**
  15492. * The list of lens flare system added to the scene
  15493. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15494. */
  15495. lensFlareSystems: Array<LensFlareSystem>;
  15496. /**
  15497. * Removes the given lens flare system from this scene.
  15498. * @param toRemove The lens flare system to remove
  15499. * @returns The index of the removed lens flare system
  15500. */
  15501. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15502. /**
  15503. * Adds the given lens flare system to this scene
  15504. * @param newLensFlareSystem The lens flare system to add
  15505. */
  15506. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15507. /**
  15508. * Gets a lens flare system using its name
  15509. * @param name defines the name to look for
  15510. * @returns the lens flare system or null if not found
  15511. */
  15512. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15513. /**
  15514. * Gets a lens flare system using its id
  15515. * @param id defines the id to look for
  15516. * @returns the lens flare system or null if not found
  15517. */
  15518. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15519. }
  15520. /**
  15521. * Defines the lens flare scene component responsible to manage any lens flares
  15522. * in a given scene.
  15523. */
  15524. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15525. /**
  15526. * The component name helpfull to identify the component in the list of scene components.
  15527. */
  15528. readonly name: string;
  15529. /**
  15530. * The scene the component belongs to.
  15531. */
  15532. scene: Scene;
  15533. /**
  15534. * Creates a new instance of the component for the given scene
  15535. * @param scene Defines the scene to register the component in
  15536. */
  15537. constructor(scene: Scene);
  15538. /**
  15539. * Registers the component in a given scene
  15540. */
  15541. register(): void;
  15542. /**
  15543. * Rebuilds the elements related to this component in case of
  15544. * context lost for instance.
  15545. */
  15546. rebuild(): void;
  15547. /**
  15548. * Adds all the element from the container to the scene
  15549. * @param container the container holding the elements
  15550. */
  15551. addFromContainer(container: AbstractScene): void;
  15552. /**
  15553. * Removes all the elements in the container from the scene
  15554. * @param container contains the elements to remove
  15555. */
  15556. removeFromContainer(container: AbstractScene): void;
  15557. /**
  15558. * Serializes the component data to the specified json object
  15559. * @param serializationObject The object to serialize to
  15560. */
  15561. serialize(serializationObject: any): void;
  15562. /**
  15563. * Disposes the component and the associated ressources.
  15564. */
  15565. dispose(): void;
  15566. private _draw;
  15567. }
  15568. }
  15569. declare module BABYLON {
  15570. /**
  15571. * A directional light is defined by a direction (what a surprise!).
  15572. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15573. * 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.
  15574. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15575. */
  15576. class DirectionalLight extends ShadowLight {
  15577. private _shadowFrustumSize;
  15578. /**
  15579. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15580. */
  15581. /**
  15582. * Specifies a fix frustum size for the shadow generation.
  15583. */
  15584. shadowFrustumSize: number;
  15585. private _shadowOrthoScale;
  15586. /**
  15587. * Gets the shadow projection scale against the optimal computed one.
  15588. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15589. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15590. */
  15591. /**
  15592. * Sets the shadow projection scale against the optimal computed one.
  15593. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15594. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15595. */
  15596. shadowOrthoScale: number;
  15597. /**
  15598. * Automatically compute the projection matrix to best fit (including all the casters)
  15599. * on each frame.
  15600. */
  15601. autoUpdateExtends: boolean;
  15602. private _orthoLeft;
  15603. private _orthoRight;
  15604. private _orthoTop;
  15605. private _orthoBottom;
  15606. /**
  15607. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15608. * The directional light is emitted from everywhere in the given direction.
  15609. * It can cast shadows.
  15610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15611. * @param name The friendly name of the light
  15612. * @param direction The direction of the light
  15613. * @param scene The scene the light belongs to
  15614. */
  15615. constructor(name: string, direction: Vector3, scene: Scene);
  15616. /**
  15617. * Returns the string "DirectionalLight".
  15618. * @return The class name
  15619. */
  15620. getClassName(): string;
  15621. /**
  15622. * Returns the integer 1.
  15623. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15624. */
  15625. getTypeID(): number;
  15626. /**
  15627. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15628. * Returns the DirectionalLight Shadow projection matrix.
  15629. */
  15630. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15631. /**
  15632. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15633. * Returns the DirectionalLight Shadow projection matrix.
  15634. */
  15635. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15636. /**
  15637. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15638. * Returns the DirectionalLight Shadow projection matrix.
  15639. */
  15640. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15641. protected _buildUniformLayout(): void;
  15642. /**
  15643. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15644. * @param effect The effect to update
  15645. * @param lightIndex The index of the light in the effect to update
  15646. * @returns The directional light
  15647. */
  15648. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15649. /**
  15650. * Gets the minZ used for shadow according to both the scene and the light.
  15651. *
  15652. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15653. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15654. * @param activeCamera The camera we are returning the min for
  15655. * @returns the depth min z
  15656. */
  15657. getDepthMinZ(activeCamera: Camera): number;
  15658. /**
  15659. * Gets the maxZ used for shadow according to both the scene and the light.
  15660. *
  15661. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15662. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15663. * @param activeCamera The camera we are returning the max for
  15664. * @returns the depth max z
  15665. */
  15666. getDepthMaxZ(activeCamera: Camera): number;
  15667. /**
  15668. * Prepares the list of defines specific to the light type.
  15669. * @param defines the list of defines
  15670. * @param lightIndex defines the index of the light for the effect
  15671. */
  15672. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15673. }
  15674. }
  15675. declare module BABYLON {
  15676. /**
  15677. * The HemisphericLight simulates the ambient environment light,
  15678. * so the passed direction is the light reflection direction, not the incoming direction.
  15679. */
  15680. class HemisphericLight extends Light {
  15681. /**
  15682. * The groundColor is the light in the opposite direction to the one specified during creation.
  15683. * 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.
  15684. */
  15685. groundColor: Color3;
  15686. /**
  15687. * The light reflection direction, not the incoming direction.
  15688. */
  15689. direction: Vector3;
  15690. /**
  15691. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15692. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15693. * The HemisphericLight can't cast shadows.
  15694. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15695. * @param name The friendly name of the light
  15696. * @param direction The direction of the light reflection
  15697. * @param scene The scene the light belongs to
  15698. */
  15699. constructor(name: string, direction: Vector3, scene: Scene);
  15700. protected _buildUniformLayout(): void;
  15701. /**
  15702. * Returns the string "HemisphericLight".
  15703. * @return The class name
  15704. */
  15705. getClassName(): string;
  15706. /**
  15707. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15708. * Returns the updated direction.
  15709. * @param target The target the direction should point to
  15710. * @return The computed direction
  15711. */
  15712. setDirectionToTarget(target: Vector3): Vector3;
  15713. /**
  15714. * Returns the shadow generator associated to the light.
  15715. * @returns Always null for hemispheric lights because it does not support shadows.
  15716. */
  15717. getShadowGenerator(): Nullable<IShadowGenerator>;
  15718. /**
  15719. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15720. * @param effect The effect to update
  15721. * @param lightIndex The index of the light in the effect to update
  15722. * @returns The hemispheric light
  15723. */
  15724. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15725. /**
  15726. * Computes the world matrix of the node
  15727. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15728. * @param useWasUpdatedFlag defines a reserved property
  15729. * @returns the world matrix
  15730. */
  15731. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15732. /**
  15733. * Returns the integer 3.
  15734. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15735. */
  15736. getTypeID(): number;
  15737. /**
  15738. * Prepares the list of defines specific to the light type.
  15739. * @param defines the list of defines
  15740. * @param lightIndex defines the index of the light for the effect
  15741. */
  15742. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15743. }
  15744. }
  15745. declare module BABYLON {
  15746. /**
  15747. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15748. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15749. * 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.
  15750. */
  15751. abstract class Light extends Node {
  15752. /**
  15753. * Falloff Default: light is falling off following the material specification:
  15754. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15755. */
  15756. static readonly FALLOFF_DEFAULT: number;
  15757. /**
  15758. * Falloff Physical: light is falling off following the inverse squared distance law.
  15759. */
  15760. static readonly FALLOFF_PHYSICAL: number;
  15761. /**
  15762. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15763. * to enhance interoperability with other engines.
  15764. */
  15765. static readonly FALLOFF_GLTF: number;
  15766. /**
  15767. * Falloff Standard: light is falling off like in the standard material
  15768. * to enhance interoperability with other materials.
  15769. */
  15770. static readonly FALLOFF_STANDARD: number;
  15771. /**
  15772. * If every light affecting the material is in this lightmapMode,
  15773. * material.lightmapTexture adds or multiplies
  15774. * (depends on material.useLightmapAsShadowmap)
  15775. * after every other light calculations.
  15776. */
  15777. static readonly LIGHTMAP_DEFAULT: number;
  15778. /**
  15779. * material.lightmapTexture as only diffuse lighting from this light
  15780. * adds only specular lighting from this light
  15781. * adds dynamic shadows
  15782. */
  15783. static readonly LIGHTMAP_SPECULAR: number;
  15784. /**
  15785. * material.lightmapTexture as only lighting
  15786. * no light calculation from this light
  15787. * only adds dynamic shadows from this light
  15788. */
  15789. static readonly LIGHTMAP_SHADOWSONLY: number;
  15790. /**
  15791. * Each light type uses the default quantity according to its type:
  15792. * point/spot lights use luminous intensity
  15793. * directional lights use illuminance
  15794. */
  15795. static readonly INTENSITYMODE_AUTOMATIC: number;
  15796. /**
  15797. * lumen (lm)
  15798. */
  15799. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15800. /**
  15801. * candela (lm/sr)
  15802. */
  15803. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15804. /**
  15805. * lux (lm/m^2)
  15806. */
  15807. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15808. /**
  15809. * nit (cd/m^2)
  15810. */
  15811. static readonly INTENSITYMODE_LUMINANCE: number;
  15812. /**
  15813. * Light type const id of the point light.
  15814. */
  15815. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15816. /**
  15817. * Light type const id of the directional light.
  15818. */
  15819. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15820. /**
  15821. * Light type const id of the spot light.
  15822. */
  15823. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15824. /**
  15825. * Light type const id of the hemispheric light.
  15826. */
  15827. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15828. /**
  15829. * Diffuse gives the basic color to an object.
  15830. */
  15831. diffuse: Color3;
  15832. /**
  15833. * Specular produces a highlight color on an object.
  15834. * Note: This is note affecting PBR materials.
  15835. */
  15836. specular: Color3;
  15837. /**
  15838. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15839. * falling off base on range or angle.
  15840. * This can be set to any values in Light.FALLOFF_x.
  15841. *
  15842. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15843. * other types of materials.
  15844. */
  15845. falloffType: number;
  15846. /**
  15847. * Strength of the light.
  15848. * Note: By default it is define in the framework own unit.
  15849. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15850. */
  15851. intensity: number;
  15852. private _range;
  15853. protected _inverseSquaredRange: number;
  15854. /**
  15855. * Defines how far from the source the light is impacting in scene units.
  15856. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15857. */
  15858. /**
  15859. * Defines how far from the source the light is impacting in scene units.
  15860. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15861. */
  15862. range: number;
  15863. /**
  15864. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15865. * of light.
  15866. */
  15867. private _photometricScale;
  15868. private _intensityMode;
  15869. /**
  15870. * Gets the photometric scale used to interpret the intensity.
  15871. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15872. */
  15873. /**
  15874. * Sets the photometric scale used to interpret the intensity.
  15875. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15876. */
  15877. intensityMode: number;
  15878. private _radius;
  15879. /**
  15880. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15881. */
  15882. /**
  15883. * sets the light radius used by PBR Materials to simulate soft area lights.
  15884. */
  15885. radius: number;
  15886. private _renderPriority;
  15887. /**
  15888. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15889. * exceeding the number allowed of the materials.
  15890. */
  15891. renderPriority: number;
  15892. private _shadowEnabled;
  15893. /**
  15894. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15895. * the current shadow generator.
  15896. */
  15897. /**
  15898. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15899. * the current shadow generator.
  15900. */
  15901. shadowEnabled: boolean;
  15902. private _includedOnlyMeshes;
  15903. /**
  15904. * Gets the only meshes impacted by this light.
  15905. */
  15906. /**
  15907. * Sets the only meshes impacted by this light.
  15908. */
  15909. includedOnlyMeshes: AbstractMesh[];
  15910. private _excludedMeshes;
  15911. /**
  15912. * Gets the meshes not impacted by this light.
  15913. */
  15914. /**
  15915. * Sets the meshes not impacted by this light.
  15916. */
  15917. excludedMeshes: AbstractMesh[];
  15918. private _excludeWithLayerMask;
  15919. /**
  15920. * Gets the layer id use to find what meshes are not impacted by the light.
  15921. * Inactive if 0
  15922. */
  15923. /**
  15924. * Sets the layer id use to find what meshes are not impacted by the light.
  15925. * Inactive if 0
  15926. */
  15927. excludeWithLayerMask: number;
  15928. private _includeOnlyWithLayerMask;
  15929. /**
  15930. * Gets the layer id use to find what meshes are impacted by the light.
  15931. * Inactive if 0
  15932. */
  15933. /**
  15934. * Sets the layer id use to find what meshes are impacted by the light.
  15935. * Inactive if 0
  15936. */
  15937. includeOnlyWithLayerMask: number;
  15938. private _lightmapMode;
  15939. /**
  15940. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15941. */
  15942. /**
  15943. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15944. */
  15945. lightmapMode: number;
  15946. /**
  15947. * Shadow generator associted to the light.
  15948. * @hidden Internal use only.
  15949. */
  15950. _shadowGenerator: Nullable<IShadowGenerator>;
  15951. /**
  15952. * @hidden Internal use only.
  15953. */
  15954. _excludedMeshesIds: string[];
  15955. /**
  15956. * @hidden Internal use only.
  15957. */
  15958. _includedOnlyMeshesIds: string[];
  15959. /**
  15960. * The current light unifom buffer.
  15961. * @hidden Internal use only.
  15962. */
  15963. _uniformBuffer: UniformBuffer;
  15964. /**
  15965. * Creates a Light object in the scene.
  15966. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15967. * @param name The firendly name of the light
  15968. * @param scene The scene the light belongs too
  15969. */
  15970. constructor(name: string, scene: Scene);
  15971. protected abstract _buildUniformLayout(): void;
  15972. /**
  15973. * Sets the passed Effect "effect" with the Light information.
  15974. * @param effect The effect to update
  15975. * @param lightIndex The index of the light in the effect to update
  15976. * @returns The light
  15977. */
  15978. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15979. /**
  15980. * Returns the string "Light".
  15981. * @returns the class name
  15982. */
  15983. getClassName(): string;
  15984. /**
  15985. * Converts the light information to a readable string for debug purpose.
  15986. * @param fullDetails Supports for multiple levels of logging within scene loading
  15987. * @returns the human readable light info
  15988. */
  15989. toString(fullDetails?: boolean): string;
  15990. /** @hidden */
  15991. protected _syncParentEnabledState(): void;
  15992. /**
  15993. * Set the enabled state of this node.
  15994. * @param value - the new enabled state
  15995. */
  15996. setEnabled(value: boolean): void;
  15997. /**
  15998. * Returns the Light associated shadow generator if any.
  15999. * @return the associated shadow generator.
  16000. */
  16001. getShadowGenerator(): Nullable<IShadowGenerator>;
  16002. /**
  16003. * Returns a Vector3, the absolute light position in the World.
  16004. * @returns the world space position of the light
  16005. */
  16006. getAbsolutePosition(): Vector3;
  16007. /**
  16008. * Specifies if the light will affect the passed mesh.
  16009. * @param mesh The mesh to test against the light
  16010. * @return true the mesh is affected otherwise, false.
  16011. */
  16012. canAffectMesh(mesh: AbstractMesh): boolean;
  16013. /**
  16014. * Sort function to order lights for rendering.
  16015. * @param a First Light object to compare to second.
  16016. * @param b Second Light object to compare first.
  16017. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16018. */
  16019. static CompareLightsPriority(a: Light, b: Light): number;
  16020. /**
  16021. * Releases resources associated with this node.
  16022. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16023. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16024. */
  16025. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16026. /**
  16027. * Returns the light type ID (integer).
  16028. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16029. */
  16030. getTypeID(): number;
  16031. /**
  16032. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16033. * @returns the scaled intensity in intensity mode unit
  16034. */
  16035. getScaledIntensity(): number;
  16036. /**
  16037. * Returns a new Light object, named "name", from the current one.
  16038. * @param name The name of the cloned light
  16039. * @returns the new created light
  16040. */
  16041. clone(name: string): Nullable<Light>;
  16042. /**
  16043. * Serializes the current light into a Serialization object.
  16044. * @returns the serialized object.
  16045. */
  16046. serialize(): any;
  16047. /**
  16048. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16049. * This new light is named "name" and added to the passed scene.
  16050. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16051. * @param name The friendly name of the light
  16052. * @param scene The scene the new light will belong to
  16053. * @returns the constructor function
  16054. */
  16055. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16056. /**
  16057. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16058. * @param parsedLight The JSON representation of the light
  16059. * @param scene The scene to create the parsed light in
  16060. * @returns the created light after parsing
  16061. */
  16062. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16063. private _hookArrayForExcluded;
  16064. private _hookArrayForIncludedOnly;
  16065. private _resyncMeshes;
  16066. /**
  16067. * Forces the meshes to update their light related information in their rendering used effects
  16068. * @hidden Internal Use Only
  16069. */
  16070. _markMeshesAsLightDirty(): void;
  16071. /**
  16072. * Recomputes the cached photometric scale if needed.
  16073. */
  16074. private _computePhotometricScale;
  16075. /**
  16076. * Returns the Photometric Scale according to the light type and intensity mode.
  16077. */
  16078. private _getPhotometricScale;
  16079. /**
  16080. * Reorder the light in the scene according to their defined priority.
  16081. * @hidden Internal Use Only
  16082. */
  16083. _reorderLightsInScene(): void;
  16084. /**
  16085. * Prepares the list of defines specific to the light type.
  16086. * @param defines the list of defines
  16087. * @param lightIndex defines the index of the light for the effect
  16088. */
  16089. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16090. }
  16091. }
  16092. declare module BABYLON {
  16093. /**
  16094. * A point light is a light defined by an unique point in world space.
  16095. * The light is emitted in every direction from this point.
  16096. * A good example of a point light is a standard light bulb.
  16097. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16098. */
  16099. class PointLight extends ShadowLight {
  16100. private _shadowAngle;
  16101. /**
  16102. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16103. * This specifies what angle the shadow will use to be created.
  16104. *
  16105. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16106. */
  16107. /**
  16108. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16109. * This specifies what angle the shadow will use to be created.
  16110. *
  16111. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16112. */
  16113. shadowAngle: number;
  16114. /**
  16115. * Gets the direction if it has been set.
  16116. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16117. */
  16118. /**
  16119. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16120. */
  16121. direction: Vector3;
  16122. /**
  16123. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16124. * A PointLight emits the light in every direction.
  16125. * It can cast shadows.
  16126. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16127. * ```javascript
  16128. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16129. * ```
  16130. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16131. * @param name The light friendly name
  16132. * @param position The position of the point light in the scene
  16133. * @param scene The scene the lights belongs to
  16134. */
  16135. constructor(name: string, position: Vector3, scene: Scene);
  16136. /**
  16137. * Returns the string "PointLight"
  16138. * @returns the class name
  16139. */
  16140. getClassName(): string;
  16141. /**
  16142. * Returns the integer 0.
  16143. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16144. */
  16145. getTypeID(): number;
  16146. /**
  16147. * Specifies wether or not the shadowmap should be a cube texture.
  16148. * @returns true if the shadowmap needs to be a cube texture.
  16149. */
  16150. needCube(): boolean;
  16151. /**
  16152. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16153. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16154. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16155. */
  16156. getShadowDirection(faceIndex?: number): Vector3;
  16157. /**
  16158. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16159. * - fov = PI / 2
  16160. * - aspect ratio : 1.0
  16161. * - z-near and far equal to the active camera minZ and maxZ.
  16162. * Returns the PointLight.
  16163. */
  16164. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16165. protected _buildUniformLayout(): void;
  16166. /**
  16167. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16168. * @param effect The effect to update
  16169. * @param lightIndex The index of the light in the effect to update
  16170. * @returns The point light
  16171. */
  16172. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16173. /**
  16174. * Prepares the list of defines specific to the light type.
  16175. * @param defines the list of defines
  16176. * @param lightIndex defines the index of the light for the effect
  16177. */
  16178. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16179. }
  16180. }
  16181. declare module BABYLON {
  16182. /**
  16183. * Interface describing all the common properties and methods a shadow light needs to implement.
  16184. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16185. * as well as binding the different shadow properties to the effects.
  16186. */
  16187. interface IShadowLight extends Light {
  16188. /**
  16189. * The light id in the scene (used in scene.findLighById for instance)
  16190. */
  16191. id: string;
  16192. /**
  16193. * The position the shdow will be casted from.
  16194. */
  16195. position: Vector3;
  16196. /**
  16197. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16198. */
  16199. direction: Vector3;
  16200. /**
  16201. * The transformed position. Position of the light in world space taking parenting in account.
  16202. */
  16203. transformedPosition: Vector3;
  16204. /**
  16205. * The transformed direction. Direction of the light in world space taking parenting in account.
  16206. */
  16207. transformedDirection: Vector3;
  16208. /**
  16209. * The friendly name of the light in the scene.
  16210. */
  16211. name: string;
  16212. /**
  16213. * Defines the shadow projection clipping minimum z value.
  16214. */
  16215. shadowMinZ: number;
  16216. /**
  16217. * Defines the shadow projection clipping maximum z value.
  16218. */
  16219. shadowMaxZ: number;
  16220. /**
  16221. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16222. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16223. */
  16224. computeTransformedInformation(): boolean;
  16225. /**
  16226. * Gets the scene the light belongs to.
  16227. * @returns The scene
  16228. */
  16229. getScene(): Scene;
  16230. /**
  16231. * Callback defining a custom Projection Matrix Builder.
  16232. * This can be used to override the default projection matrix computation.
  16233. */
  16234. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16235. /**
  16236. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16237. * @param matrix The materix to updated with the projection information
  16238. * @param viewMatrix The transform matrix of the light
  16239. * @param renderList The list of mesh to render in the map
  16240. * @returns The current light
  16241. */
  16242. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16243. /**
  16244. * Gets the current depth scale used in ESM.
  16245. * @returns The scale
  16246. */
  16247. getDepthScale(): number;
  16248. /**
  16249. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16250. * @returns true if a cube texture needs to be use
  16251. */
  16252. needCube(): boolean;
  16253. /**
  16254. * Detects if the projection matrix requires to be recomputed this frame.
  16255. * @returns true if it requires to be recomputed otherwise, false.
  16256. */
  16257. needProjectionMatrixCompute(): boolean;
  16258. /**
  16259. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16260. */
  16261. forceProjectionMatrixCompute(): void;
  16262. /**
  16263. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16264. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16265. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16266. */
  16267. getShadowDirection(faceIndex?: number): Vector3;
  16268. /**
  16269. * Gets the minZ used for shadow according to both the scene and the light.
  16270. * @param activeCamera The camera we are returning the min for
  16271. * @returns the depth min z
  16272. */
  16273. getDepthMinZ(activeCamera: Camera): number;
  16274. /**
  16275. * Gets the maxZ used for shadow according to both the scene and the light.
  16276. * @param activeCamera The camera we are returning the max for
  16277. * @returns the depth max z
  16278. */
  16279. getDepthMaxZ(activeCamera: Camera): number;
  16280. }
  16281. /**
  16282. * Base implementation IShadowLight
  16283. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16284. */
  16285. abstract class ShadowLight extends Light implements IShadowLight {
  16286. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16287. protected _position: Vector3;
  16288. protected _setPosition(value: Vector3): void;
  16289. /**
  16290. * Sets the position the shadow will be casted from. Also use as the light position for both
  16291. * point and spot lights.
  16292. */
  16293. /**
  16294. * Sets the position the shadow will be casted from. Also use as the light position for both
  16295. * point and spot lights.
  16296. */
  16297. position: Vector3;
  16298. protected _direction: Vector3;
  16299. protected _setDirection(value: Vector3): void;
  16300. /**
  16301. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16302. * Also use as the light direction on spot and directional lights.
  16303. */
  16304. /**
  16305. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16306. * Also use as the light direction on spot and directional lights.
  16307. */
  16308. direction: Vector3;
  16309. private _shadowMinZ;
  16310. /**
  16311. * Gets the shadow projection clipping minimum z value.
  16312. */
  16313. /**
  16314. * Sets the shadow projection clipping minimum z value.
  16315. */
  16316. shadowMinZ: number;
  16317. private _shadowMaxZ;
  16318. /**
  16319. * Sets the shadow projection clipping maximum z value.
  16320. */
  16321. /**
  16322. * Gets the shadow projection clipping maximum z value.
  16323. */
  16324. shadowMaxZ: number;
  16325. /**
  16326. * Callback defining a custom Projection Matrix Builder.
  16327. * This can be used to override the default projection matrix computation.
  16328. */
  16329. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16330. /**
  16331. * The transformed position. Position of the light in world space taking parenting in account.
  16332. */
  16333. transformedPosition: Vector3;
  16334. /**
  16335. * The transformed direction. Direction of the light in world space taking parenting in account.
  16336. */
  16337. transformedDirection: Vector3;
  16338. private _needProjectionMatrixCompute;
  16339. /**
  16340. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16341. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16342. */
  16343. computeTransformedInformation(): boolean;
  16344. /**
  16345. * Return the depth scale used for the shadow map.
  16346. * @returns the depth scale.
  16347. */
  16348. getDepthScale(): number;
  16349. /**
  16350. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16351. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16352. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16353. */
  16354. getShadowDirection(faceIndex?: number): Vector3;
  16355. /**
  16356. * Returns the ShadowLight absolute position in the World.
  16357. * @returns the position vector in world space
  16358. */
  16359. getAbsolutePosition(): Vector3;
  16360. /**
  16361. * Sets the ShadowLight direction toward the passed target.
  16362. * @param target The point tot target in local space
  16363. * @returns the updated ShadowLight direction
  16364. */
  16365. setDirectionToTarget(target: Vector3): Vector3;
  16366. /**
  16367. * Returns the light rotation in euler definition.
  16368. * @returns the x y z rotation in local space.
  16369. */
  16370. getRotation(): Vector3;
  16371. /**
  16372. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16373. * @returns true if a cube texture needs to be use
  16374. */
  16375. needCube(): boolean;
  16376. /**
  16377. * Detects if the projection matrix requires to be recomputed this frame.
  16378. * @returns true if it requires to be recomputed otherwise, false.
  16379. */
  16380. needProjectionMatrixCompute(): boolean;
  16381. /**
  16382. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16383. */
  16384. forceProjectionMatrixCompute(): void;
  16385. /** @hidden */
  16386. _initCache(): void;
  16387. /** @hidden */
  16388. _isSynchronized(): boolean;
  16389. /**
  16390. * Computes the world matrix of the node
  16391. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16392. * @returns the world matrix
  16393. */
  16394. computeWorldMatrix(force?: boolean): Matrix;
  16395. /**
  16396. * Gets the minZ used for shadow according to both the scene and the light.
  16397. * @param activeCamera The camera we are returning the min for
  16398. * @returns the depth min z
  16399. */
  16400. getDepthMinZ(activeCamera: Camera): number;
  16401. /**
  16402. * Gets the maxZ used for shadow according to both the scene and the light.
  16403. * @param activeCamera The camera we are returning the max for
  16404. * @returns the depth max z
  16405. */
  16406. getDepthMaxZ(activeCamera: Camera): number;
  16407. /**
  16408. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16409. * @param matrix The materix to updated with the projection information
  16410. * @param viewMatrix The transform matrix of the light
  16411. * @param renderList The list of mesh to render in the map
  16412. * @returns The current light
  16413. */
  16414. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16415. }
  16416. }
  16417. declare module BABYLON {
  16418. /**
  16419. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16420. * These values define a cone of light starting from the position, emitting toward the direction.
  16421. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16422. * and the exponent defines the speed of the decay of the light with distance (reach).
  16423. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16424. */
  16425. class SpotLight extends ShadowLight {
  16426. private _angle;
  16427. private _innerAngle;
  16428. private _cosHalfAngle;
  16429. private _lightAngleScale;
  16430. private _lightAngleOffset;
  16431. /**
  16432. * Gets the cone angle of the spot light in Radians.
  16433. */
  16434. /**
  16435. * Sets the cone angle of the spot light in Radians.
  16436. */
  16437. angle: number;
  16438. /**
  16439. * Only used in gltf falloff mode, this defines the angle where
  16440. * the directional falloff will start before cutting at angle which could be seen
  16441. * as outer angle.
  16442. */
  16443. /**
  16444. * Only used in gltf falloff mode, this defines the angle where
  16445. * the directional falloff will start before cutting at angle which could be seen
  16446. * as outer angle.
  16447. */
  16448. innerAngle: number;
  16449. private _shadowAngleScale;
  16450. /**
  16451. * Allows scaling the angle of the light for shadow generation only.
  16452. */
  16453. /**
  16454. * Allows scaling the angle of the light for shadow generation only.
  16455. */
  16456. shadowAngleScale: number;
  16457. /**
  16458. * The light decay speed with the distance from the emission spot.
  16459. */
  16460. exponent: number;
  16461. private _projectionTextureMatrix;
  16462. /**
  16463. * Allows reading the projecton texture
  16464. */
  16465. readonly projectionTextureMatrix: Matrix;
  16466. protected _projectionTextureLightNear: number;
  16467. /**
  16468. * Gets the near clip of the Spotlight for texture projection.
  16469. */
  16470. /**
  16471. * Sets the near clip of the Spotlight for texture projection.
  16472. */
  16473. projectionTextureLightNear: number;
  16474. protected _projectionTextureLightFar: number;
  16475. /**
  16476. * Gets the far clip of the Spotlight for texture projection.
  16477. */
  16478. /**
  16479. * Sets the far clip of the Spotlight for texture projection.
  16480. */
  16481. projectionTextureLightFar: number;
  16482. protected _projectionTextureUpDirection: Vector3;
  16483. /**
  16484. * Gets the Up vector of the Spotlight for texture projection.
  16485. */
  16486. /**
  16487. * Sets the Up vector of the Spotlight for texture projection.
  16488. */
  16489. projectionTextureUpDirection: Vector3;
  16490. private _projectionTexture;
  16491. /**
  16492. * Gets the projection texture of the light.
  16493. */
  16494. /**
  16495. * Sets the projection texture of the light.
  16496. */
  16497. projectionTexture: Nullable<BaseTexture>;
  16498. private _projectionTextureViewLightDirty;
  16499. private _projectionTextureProjectionLightDirty;
  16500. private _projectionTextureDirty;
  16501. private _projectionTextureViewTargetVector;
  16502. private _projectionTextureViewLightMatrix;
  16503. private _projectionTextureProjectionLightMatrix;
  16504. private _projectionTextureScalingMatrix;
  16505. /**
  16506. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16507. * It can cast shadows.
  16508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16509. * @param name The light friendly name
  16510. * @param position The position of the spot light in the scene
  16511. * @param direction The direction of the light in the scene
  16512. * @param angle The cone angle of the light in Radians
  16513. * @param exponent The light decay speed with the distance from the emission spot
  16514. * @param scene The scene the lights belongs to
  16515. */
  16516. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16517. /**
  16518. * Returns the string "SpotLight".
  16519. * @returns the class name
  16520. */
  16521. getClassName(): string;
  16522. /**
  16523. * Returns the integer 2.
  16524. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16525. */
  16526. getTypeID(): number;
  16527. /**
  16528. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16529. */
  16530. protected _setDirection(value: Vector3): void;
  16531. /**
  16532. * Overrides the position setter to recompute the projection texture view light Matrix.
  16533. */
  16534. protected _setPosition(value: Vector3): void;
  16535. /**
  16536. * 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.
  16537. * Returns the SpotLight.
  16538. */
  16539. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16540. protected _computeProjectionTextureViewLightMatrix(): void;
  16541. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16542. /**
  16543. * Main function for light texture projection matrix computing.
  16544. */
  16545. protected _computeProjectionTextureMatrix(): void;
  16546. protected _buildUniformLayout(): void;
  16547. private _computeAngleValues;
  16548. /**
  16549. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16550. * @param effect The effect to update
  16551. * @param lightIndex The index of the light in the effect to update
  16552. * @returns The spot light
  16553. */
  16554. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16555. /**
  16556. * Disposes the light and the associated resources.
  16557. */
  16558. dispose(): void;
  16559. /**
  16560. * Prepares the list of defines specific to the light type.
  16561. * @param defines the list of defines
  16562. * @param lightIndex defines the index of the light for the effect
  16563. */
  16564. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16565. }
  16566. }
  16567. declare module BABYLON {
  16568. /**
  16569. * Interface used to present a loading screen while loading a scene
  16570. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16571. */
  16572. interface ILoadingScreen {
  16573. /**
  16574. * Function called to display the loading screen
  16575. */
  16576. displayLoadingUI: () => void;
  16577. /**
  16578. * Function called to hide the loading screen
  16579. */
  16580. hideLoadingUI: () => void;
  16581. /**
  16582. * Gets or sets the color to use for the background
  16583. */
  16584. loadingUIBackgroundColor: string;
  16585. /**
  16586. * Gets or sets the text to display while loading
  16587. */
  16588. loadingUIText: string;
  16589. }
  16590. /**
  16591. * Class used for the default loading screen
  16592. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16593. */
  16594. class DefaultLoadingScreen implements ILoadingScreen {
  16595. private _renderingCanvas;
  16596. private _loadingText;
  16597. private _loadingDivBackgroundColor;
  16598. private _loadingDiv;
  16599. private _loadingTextDiv;
  16600. /**
  16601. * Creates a new default loading screen
  16602. * @param _renderingCanvas defines the canvas used to render the scene
  16603. * @param _loadingText defines the default text to display
  16604. * @param _loadingDivBackgroundColor defines the default background color
  16605. */
  16606. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16607. /**
  16608. * Function called to display the loading screen
  16609. */
  16610. displayLoadingUI(): void;
  16611. /**
  16612. * Function called to hide the loading screen
  16613. */
  16614. hideLoadingUI(): void;
  16615. /**
  16616. * Gets or sets the text to display while loading
  16617. */
  16618. loadingUIText: string;
  16619. /**
  16620. * Gets or sets the color to use for the background
  16621. */
  16622. loadingUIBackgroundColor: string;
  16623. private _resizeLoadingUI;
  16624. }
  16625. }
  16626. declare module BABYLON {
  16627. /**
  16628. * Class used to represent data loading progression
  16629. */
  16630. class SceneLoaderProgressEvent {
  16631. /** defines if data length to load can be evaluated */
  16632. readonly lengthComputable: boolean;
  16633. /** defines the loaded data length */
  16634. readonly loaded: number;
  16635. /** defines the data length to load */
  16636. readonly total: number;
  16637. /**
  16638. * Create a new progress event
  16639. * @param lengthComputable defines if data length to load can be evaluated
  16640. * @param loaded defines the loaded data length
  16641. * @param total defines the data length to load
  16642. */
  16643. constructor(
  16644. /** defines if data length to load can be evaluated */
  16645. lengthComputable: boolean,
  16646. /** defines the loaded data length */
  16647. loaded: number,
  16648. /** defines the data length to load */
  16649. total: number);
  16650. /**
  16651. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16652. * @param event defines the source event
  16653. * @returns a new SceneLoaderProgressEvent
  16654. */
  16655. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16656. }
  16657. /**
  16658. * Interface used by SceneLoader plugins to define supported file extensions
  16659. */
  16660. interface ISceneLoaderPluginExtensions {
  16661. /**
  16662. * Defines the list of supported extensions
  16663. */
  16664. [extension: string]: {
  16665. isBinary: boolean;
  16666. };
  16667. }
  16668. /**
  16669. * Interface used by SceneLoader plugin factory
  16670. */
  16671. interface ISceneLoaderPluginFactory {
  16672. /**
  16673. * Defines the name of the factory
  16674. */
  16675. name: string;
  16676. /**
  16677. * Function called to create a new plugin
  16678. * @return the new plugin
  16679. */
  16680. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16681. /**
  16682. * Boolean indicating if the plugin can direct load specific data
  16683. */
  16684. canDirectLoad?: (data: string) => boolean;
  16685. }
  16686. /**
  16687. * Interface used to define a SceneLoader plugin
  16688. */
  16689. interface ISceneLoaderPlugin {
  16690. /**
  16691. * The friendly name of this plugin.
  16692. */
  16693. name: string;
  16694. /**
  16695. * The file extensions supported by this plugin.
  16696. */
  16697. extensions: string | ISceneLoaderPluginExtensions;
  16698. /**
  16699. * Import meshes into a scene.
  16700. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16701. * @param scene The scene to import into
  16702. * @param data The data to import
  16703. * @param rootUrl The root url for scene and resources
  16704. * @param meshes The meshes array to import into
  16705. * @param particleSystems The particle systems array to import into
  16706. * @param skeletons The skeletons array to import into
  16707. * @param onError The callback when import fails
  16708. * @returns True if successful or false otherwise
  16709. */
  16710. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16711. /**
  16712. * Load into a scene.
  16713. * @param scene The scene to load into
  16714. * @param data The data to import
  16715. * @param rootUrl The root url for scene and resources
  16716. * @param onError The callback when import fails
  16717. * @returns true if successful or false otherwise
  16718. */
  16719. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16720. /**
  16721. * The callback that returns true if the data can be directly loaded.
  16722. */
  16723. canDirectLoad?: (data: string) => boolean;
  16724. /**
  16725. * The callback that allows custom handling of the root url based on the response url.
  16726. */
  16727. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16728. /**
  16729. * Load into an asset container.
  16730. * @param scene The scene to load into
  16731. * @param data The data to import
  16732. * @param rootUrl The root url for scene and resources
  16733. * @param onError The callback when import fails
  16734. * @returns The loaded asset container
  16735. */
  16736. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16737. }
  16738. /**
  16739. * Interface used to define an async SceneLoader plugin
  16740. */
  16741. interface ISceneLoaderPluginAsync {
  16742. /**
  16743. * The friendly name of this plugin.
  16744. */
  16745. name: string;
  16746. /**
  16747. * The file extensions supported by this plugin.
  16748. */
  16749. extensions: string | ISceneLoaderPluginExtensions;
  16750. /**
  16751. * Import meshes into a scene.
  16752. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16753. * @param scene The scene to import into
  16754. * @param data The data to import
  16755. * @param rootUrl The root url for scene and resources
  16756. * @param onProgress The callback when the load progresses
  16757. * @param fileName Defines the name of the file to load
  16758. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16759. */
  16760. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16761. meshes: AbstractMesh[];
  16762. particleSystems: IParticleSystem[];
  16763. skeletons: Skeleton[];
  16764. animationGroups: AnimationGroup[];
  16765. }>;
  16766. /**
  16767. * Load into a scene.
  16768. * @param scene The scene to load into
  16769. * @param data The data to import
  16770. * @param rootUrl The root url for scene and resources
  16771. * @param onProgress The callback when the load progresses
  16772. * @param fileName Defines the name of the file to load
  16773. * @returns Nothing
  16774. */
  16775. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16776. /**
  16777. * The callback that returns true if the data can be directly loaded.
  16778. */
  16779. canDirectLoad?: (data: string) => boolean;
  16780. /**
  16781. * The callback that allows custom handling of the root url based on the response url.
  16782. */
  16783. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16784. /**
  16785. * Load into an asset container.
  16786. * @param scene The scene to load into
  16787. * @param data The data to import
  16788. * @param rootUrl The root url for scene and resources
  16789. * @param onProgress The callback when the load progresses
  16790. * @param fileName Defines the name of the file to load
  16791. * @returns The loaded asset container
  16792. */
  16793. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16794. }
  16795. /**
  16796. * Class used to load scene from various file formats using registered plugins
  16797. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16798. */
  16799. class SceneLoader {
  16800. private static _ForceFullSceneLoadingForIncremental;
  16801. private static _ShowLoadingScreen;
  16802. private static _CleanBoneMatrixWeights;
  16803. /**
  16804. * No logging while loading
  16805. */
  16806. static readonly NO_LOGGING: number;
  16807. /**
  16808. * Minimal logging while loading
  16809. */
  16810. static readonly MINIMAL_LOGGING: number;
  16811. /**
  16812. * Summary logging while loading
  16813. */
  16814. static readonly SUMMARY_LOGGING: number;
  16815. /**
  16816. * Detailled logging while loading
  16817. */
  16818. static readonly DETAILED_LOGGING: number;
  16819. private static _loggingLevel;
  16820. /**
  16821. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16822. */
  16823. static ForceFullSceneLoadingForIncremental: boolean;
  16824. /**
  16825. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16826. */
  16827. static ShowLoadingScreen: boolean;
  16828. /**
  16829. * Defines the current logging level (while loading the scene)
  16830. * @ignorenaming
  16831. */
  16832. static loggingLevel: number;
  16833. /**
  16834. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16835. */
  16836. static CleanBoneMatrixWeights: boolean;
  16837. /**
  16838. * Event raised when a plugin is used to load a scene
  16839. */
  16840. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16841. private static _registeredPlugins;
  16842. private static _getDefaultPlugin;
  16843. private static _getPluginForExtension;
  16844. private static _getPluginForDirectLoad;
  16845. private static _getPluginForFilename;
  16846. private static _getDirectLoad;
  16847. private static _loadData;
  16848. private static _getFileInfo;
  16849. /**
  16850. * Gets a plugin that can load the given extension
  16851. * @param extension defines the extension to load
  16852. * @returns a plugin or null if none works
  16853. */
  16854. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16855. /**
  16856. * Gets a boolean indicating that the given extension can be loaded
  16857. * @param extension defines the extension to load
  16858. * @returns true if the extension is supported
  16859. */
  16860. static IsPluginForExtensionAvailable(extension: string): boolean;
  16861. /**
  16862. * Adds a new plugin to the list of registered plugins
  16863. * @param plugin defines the plugin to add
  16864. */
  16865. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16866. /**
  16867. * Import meshes into a scene
  16868. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16869. * @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)
  16870. * @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)
  16871. * @param scene the instance of BABYLON.Scene to append to
  16872. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16873. * @param onProgress a callback with a progress event for each file being loaded
  16874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16875. * @param pluginExtension the extension used to determine the plugin
  16876. * @returns The loaded plugin
  16877. */
  16878. 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>;
  16879. /**
  16880. * Import meshes into a scene
  16881. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16882. * @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)
  16883. * @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)
  16884. * @param scene the instance of BABYLON.Scene to append to
  16885. * @param onProgress a callback with a progress event for each file being loaded
  16886. * @param pluginExtension the extension used to determine the plugin
  16887. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16888. */
  16889. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16890. meshes: AbstractMesh[];
  16891. particleSystems: IParticleSystem[];
  16892. skeletons: Skeleton[];
  16893. animationGroups: AnimationGroup[];
  16894. }>;
  16895. /**
  16896. * Load a scene
  16897. * @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)
  16898. * @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)
  16899. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16900. * @param onSuccess a callback with the scene when import succeeds
  16901. * @param onProgress a callback with a progress event for each file being loaded
  16902. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16903. * @param pluginExtension the extension used to determine the plugin
  16904. * @returns The loaded plugin
  16905. */
  16906. 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>;
  16907. /**
  16908. * Load a scene
  16909. * @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)
  16910. * @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)
  16911. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16912. * @param onProgress a callback with a progress event for each file being loaded
  16913. * @param pluginExtension the extension used to determine the plugin
  16914. * @returns The loaded scene
  16915. */
  16916. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16917. /**
  16918. * Append a scene
  16919. * @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)
  16920. * @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)
  16921. * @param scene is the instance of BABYLON.Scene to append to
  16922. * @param onSuccess a callback with the scene when import succeeds
  16923. * @param onProgress a callback with a progress event for each file being loaded
  16924. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16925. * @param pluginExtension the extension used to determine the plugin
  16926. * @returns The loaded plugin
  16927. */
  16928. 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>;
  16929. /**
  16930. * Append a scene
  16931. * @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)
  16932. * @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)
  16933. * @param scene is the instance of BABYLON.Scene to append to
  16934. * @param onProgress a callback with a progress event for each file being loaded
  16935. * @param pluginExtension the extension used to determine the plugin
  16936. * @returns The given scene
  16937. */
  16938. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16939. /**
  16940. * Load a scene into an asset container
  16941. * @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)
  16942. * @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)
  16943. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16944. * @param onSuccess a callback with the scene when import succeeds
  16945. * @param onProgress a callback with a progress event for each file being loaded
  16946. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16947. * @param pluginExtension the extension used to determine the plugin
  16948. * @returns The loaded plugin
  16949. */
  16950. 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>;
  16951. /**
  16952. * Load a scene into an asset container
  16953. * @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)
  16954. * @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)
  16955. * @param scene is the instance of BABYLON.Scene to append to
  16956. * @param onProgress a callback with a progress event for each file being loaded
  16957. * @param pluginExtension the extension used to determine the plugin
  16958. * @returns The loaded asset container
  16959. */
  16960. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16961. }
  16962. }
  16963. declare module BABYLON {
  16964. /**
  16965. * Scalar computation library
  16966. */
  16967. class Scalar {
  16968. /**
  16969. * Two pi constants convenient for computation.
  16970. */
  16971. static TwoPi: number;
  16972. /**
  16973. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16974. * @param a number
  16975. * @param b number
  16976. * @param epsilon (default = 1.401298E-45)
  16977. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16978. */
  16979. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  16980. /**
  16981. * Returns a string : the upper case translation of the number i to hexadecimal.
  16982. * @param i number
  16983. * @returns the upper case translation of the number i to hexadecimal.
  16984. */
  16985. static ToHex(i: number): string;
  16986. /**
  16987. * Returns -1 if value is negative and +1 is value is positive.
  16988. * @param value the value
  16989. * @returns the value itself if it's equal to zero.
  16990. */
  16991. static Sign(value: number): number;
  16992. /**
  16993. * Returns the value itself if it's between min and max.
  16994. * Returns min if the value is lower than min.
  16995. * Returns max if the value is greater than max.
  16996. * @param value the value to clmap
  16997. * @param min the min value to clamp to (default: 0)
  16998. * @param max the max value to clamp to (default: 1)
  16999. * @returns the clamped value
  17000. */
  17001. static Clamp(value: number, min?: number, max?: number): number;
  17002. /**
  17003. * the log2 of value.
  17004. * @param value the value to compute log2 of
  17005. * @returns the log2 of value.
  17006. */
  17007. static Log2(value: number): number;
  17008. /**
  17009. * Loops the value, so that it is never larger than length and never smaller than 0.
  17010. *
  17011. * This is similar to the modulo operator but it works with floating point numbers.
  17012. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  17013. * With t = 5 and length = 2.5, the result would be 0.0.
  17014. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  17015. * @param value the value
  17016. * @param length the length
  17017. * @returns the looped value
  17018. */
  17019. static Repeat(value: number, length: number): number;
  17020. /**
  17021. * Normalize the value between 0.0 and 1.0 using min and max values
  17022. * @param value value to normalize
  17023. * @param min max to normalize between
  17024. * @param max min to normalize between
  17025. * @returns the normalized value
  17026. */
  17027. static Normalize(value: number, min: number, max: number): number;
  17028. /**
  17029. * Denormalize the value from 0.0 and 1.0 using min and max values
  17030. * @param normalized value to denormalize
  17031. * @param min max to denormalize between
  17032. * @param max min to denormalize between
  17033. * @returns the denormalized value
  17034. */
  17035. static Denormalize(normalized: number, min: number, max: number): number;
  17036. /**
  17037. * Calculates the shortest difference between two given angles given in degrees.
  17038. * @param current current angle in degrees
  17039. * @param target target angle in degrees
  17040. * @returns the delta
  17041. */
  17042. static DeltaAngle(current: number, target: number): number;
  17043. /**
  17044. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  17045. * @param tx value
  17046. * @param length length
  17047. * @returns The returned value will move back and forth between 0 and length
  17048. */
  17049. static PingPong(tx: number, length: number): number;
  17050. /**
  17051. * Interpolates between min and max with smoothing at the limits.
  17052. *
  17053. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  17054. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  17055. * @param from from
  17056. * @param to to
  17057. * @param tx value
  17058. * @returns the smooth stepped value
  17059. */
  17060. static SmoothStep(from: number, to: number, tx: number): number;
  17061. /**
  17062. * Moves a value current towards target.
  17063. *
  17064. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  17065. * Negative values of maxDelta pushes the value away from target.
  17066. * @param current current value
  17067. * @param target target value
  17068. * @param maxDelta max distance to move
  17069. * @returns resulting value
  17070. */
  17071. static MoveTowards(current: number, target: number, maxDelta: number): number;
  17072. /**
  17073. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  17074. *
  17075. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  17076. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  17077. * @param current current value
  17078. * @param target target value
  17079. * @param maxDelta max distance to move
  17080. * @returns resulting angle
  17081. */
  17082. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  17083. /**
  17084. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  17085. * @param start start value
  17086. * @param end target value
  17087. * @param amount amount to lerp between
  17088. * @returns the lerped value
  17089. */
  17090. static Lerp(start: number, end: number, amount: number): number;
  17091. /**
  17092. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  17093. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  17094. * @param start start value
  17095. * @param end target value
  17096. * @param amount amount to lerp between
  17097. * @returns the lerped value
  17098. */
  17099. static LerpAngle(start: number, end: number, amount: number): number;
  17100. /**
  17101. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  17102. * @param a start value
  17103. * @param b target value
  17104. * @param value value between a and b
  17105. * @returns the inverseLerp value
  17106. */
  17107. static InverseLerp(a: number, b: number, value: number): number;
  17108. /**
  17109. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  17110. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  17111. * @param value1 spline value
  17112. * @param tangent1 spline value
  17113. * @param value2 spline value
  17114. * @param tangent2 spline value
  17115. * @param amount input value
  17116. * @returns hermite result
  17117. */
  17118. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  17119. /**
  17120. * Returns a random float number between and min and max values
  17121. * @param min min value of random
  17122. * @param max max value of random
  17123. * @returns random value
  17124. */
  17125. static RandomRange(min: number, max: number): number;
  17126. /**
  17127. * This function returns percentage of a number in a given range.
  17128. *
  17129. * RangeToPercent(40,20,60) will return 0.5 (50%)
  17130. * RangeToPercent(34,0,100) will return 0.34 (34%)
  17131. * @param number to convert to percentage
  17132. * @param min min range
  17133. * @param max max range
  17134. * @returns the percentage
  17135. */
  17136. static RangeToPercent(number: number, min: number, max: number): number;
  17137. /**
  17138. * This function returns number that corresponds to the percentage in a given range.
  17139. *
  17140. * PercentToRange(0.34,0,100) will return 34.
  17141. * @param percent to convert to number
  17142. * @param min min range
  17143. * @param max max range
  17144. * @returns the number
  17145. */
  17146. static PercentToRange(percent: number, min: number, max: number): number;
  17147. /**
  17148. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  17149. * @param angle The angle to normalize in radian.
  17150. * @return The converted angle.
  17151. */
  17152. static NormalizeRadians(angle: number): number;
  17153. }
  17154. }
  17155. declare module BABYLON {
  17156. /**
  17157. * Constant used to convert a value to gamma space
  17158. * @ignorenaming
  17159. */
  17160. const ToGammaSpace: number;
  17161. /**
  17162. * Constant used to convert a value to linear space
  17163. * @ignorenaming
  17164. */
  17165. const ToLinearSpace = 2.2;
  17166. /**
  17167. * Constant used to define the minimal number value in Babylon.js
  17168. * @ignorenaming
  17169. */
  17170. const Epsilon = 0.001;
  17171. /**
  17172. * Class used to hold a RBG color
  17173. */
  17174. class Color3 {
  17175. /**
  17176. * Defines the red component (between 0 and 1, default is 0)
  17177. */
  17178. r: number;
  17179. /**
  17180. * Defines the green component (between 0 and 1, default is 0)
  17181. */
  17182. g: number;
  17183. /**
  17184. * Defines the blue component (between 0 and 1, default is 0)
  17185. */
  17186. b: number;
  17187. /**
  17188. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  17189. * @param r defines the red component (between 0 and 1, default is 0)
  17190. * @param g defines the green component (between 0 and 1, default is 0)
  17191. * @param b defines the blue component (between 0 and 1, default is 0)
  17192. */
  17193. constructor(
  17194. /**
  17195. * Defines the red component (between 0 and 1, default is 0)
  17196. */
  17197. r?: number,
  17198. /**
  17199. * Defines the green component (between 0 and 1, default is 0)
  17200. */
  17201. g?: number,
  17202. /**
  17203. * Defines the blue component (between 0 and 1, default is 0)
  17204. */
  17205. b?: number);
  17206. /**
  17207. * Creates a string with the Color3 current values
  17208. * @returns the string representation of the Color3 object
  17209. */
  17210. toString(): string;
  17211. /**
  17212. * Returns the string "Color3"
  17213. * @returns "Color3"
  17214. */
  17215. getClassName(): string;
  17216. /**
  17217. * Compute the Color3 hash code
  17218. * @returns an unique number that can be used to hash Color3 objects
  17219. */
  17220. getHashCode(): number;
  17221. /**
  17222. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  17223. * @param array defines the array where to store the r,g,b components
  17224. * @param index defines an optional index in the target array to define where to start storing values
  17225. * @returns the current Color3 object
  17226. */
  17227. toArray(array: FloatArray, index?: number): Color3;
  17228. /**
  17229. * Returns a new Color4 object from the current Color3 and the given alpha
  17230. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  17231. * @returns a new Color4 object
  17232. */
  17233. toColor4(alpha?: number): Color4;
  17234. /**
  17235. * Returns a new array populated with 3 numeric elements : red, green and blue values
  17236. * @returns the new array
  17237. */
  17238. asArray(): number[];
  17239. /**
  17240. * Returns the luminance value
  17241. * @returns a float value
  17242. */
  17243. toLuminance(): number;
  17244. /**
  17245. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  17246. * @param otherColor defines the second operand
  17247. * @returns the new Color3 object
  17248. */
  17249. multiply(otherColor: DeepImmutable<Color3>): Color3;
  17250. /**
  17251. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  17252. * @param otherColor defines the second operand
  17253. * @param result defines the Color3 object where to store the result
  17254. * @returns the current Color3
  17255. */
  17256. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17257. /**
  17258. * Determines equality between Color3 objects
  17259. * @param otherColor defines the second operand
  17260. * @returns true if the rgb values are equal to the given ones
  17261. */
  17262. equals(otherColor: DeepImmutable<Color3>): boolean;
  17263. /**
  17264. * Determines equality between the current Color3 object and a set of r,b,g values
  17265. * @param r defines the red component to check
  17266. * @param g defines the green component to check
  17267. * @param b defines the blue component to check
  17268. * @returns true if the rgb values are equal to the given ones
  17269. */
  17270. equalsFloats(r: number, g: number, b: number): boolean;
  17271. /**
  17272. * Multiplies in place each rgb value by scale
  17273. * @param scale defines the scaling factor
  17274. * @returns the updated Color3
  17275. */
  17276. scale(scale: number): Color3;
  17277. /**
  17278. * Multiplies the rgb values by scale and stores the result into "result"
  17279. * @param scale defines the scaling factor
  17280. * @param result defines the Color3 object where to store the result
  17281. * @returns the unmodified current Color3
  17282. */
  17283. scaleToRef(scale: number, result: Color3): Color3;
  17284. /**
  17285. * Scale the current Color3 values by a factor and add the result to a given Color3
  17286. * @param scale defines the scale factor
  17287. * @param result defines color to store the result into
  17288. * @returns the unmodified current Color3
  17289. */
  17290. scaleAndAddToRef(scale: number, result: Color3): Color3;
  17291. /**
  17292. * Clamps the rgb values by the min and max values and stores the result into "result"
  17293. * @param min defines minimum clamping value (default is 0)
  17294. * @param max defines maximum clamping value (default is 1)
  17295. * @param result defines color to store the result into
  17296. * @returns the original Color3
  17297. */
  17298. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  17299. /**
  17300. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  17301. * @param otherColor defines the second operand
  17302. * @returns the new Color3
  17303. */
  17304. add(otherColor: DeepImmutable<Color3>): Color3;
  17305. /**
  17306. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  17307. * @param otherColor defines the second operand
  17308. * @param result defines Color3 object to store the result into
  17309. * @returns the unmodified current Color3
  17310. */
  17311. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17312. /**
  17313. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  17314. * @param otherColor defines the second operand
  17315. * @returns the new Color3
  17316. */
  17317. subtract(otherColor: DeepImmutable<Color3>): Color3;
  17318. /**
  17319. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  17320. * @param otherColor defines the second operand
  17321. * @param result defines Color3 object to store the result into
  17322. * @returns the unmodified current Color3
  17323. */
  17324. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17325. /**
  17326. * Copy the current object
  17327. * @returns a new Color3 copied the current one
  17328. */
  17329. clone(): Color3;
  17330. /**
  17331. * Copies the rgb values from the source in the current Color3
  17332. * @param source defines the source Color3 object
  17333. * @returns the updated Color3 object
  17334. */
  17335. copyFrom(source: DeepImmutable<Color3>): Color3;
  17336. /**
  17337. * Updates the Color3 rgb values from the given floats
  17338. * @param r defines the red component to read from
  17339. * @param g defines the green component to read from
  17340. * @param b defines the blue component to read from
  17341. * @returns the current Color3 object
  17342. */
  17343. copyFromFloats(r: number, g: number, b: number): Color3;
  17344. /**
  17345. * Updates the Color3 rgb values from the given floats
  17346. * @param r defines the red component to read from
  17347. * @param g defines the green component to read from
  17348. * @param b defines the blue component to read from
  17349. * @returns the current Color3 object
  17350. */
  17351. set(r: number, g: number, b: number): Color3;
  17352. /**
  17353. * Compute the Color3 hexadecimal code as a string
  17354. * @returns a string containing the hexadecimal representation of the Color3 object
  17355. */
  17356. toHexString(): string;
  17357. /**
  17358. * Computes a new Color3 converted from the current one to linear space
  17359. * @returns a new Color3 object
  17360. */
  17361. toLinearSpace(): Color3;
  17362. /**
  17363. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  17364. * @param convertedColor defines the Color3 object where to store the linear space version
  17365. * @returns the unmodified Color3
  17366. */
  17367. toLinearSpaceToRef(convertedColor: Color3): Color3;
  17368. /**
  17369. * Computes a new Color3 converted from the current one to gamma space
  17370. * @returns a new Color3 object
  17371. */
  17372. toGammaSpace(): Color3;
  17373. /**
  17374. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  17375. * @param convertedColor defines the Color3 object where to store the gamma space version
  17376. * @returns the unmodified Color3
  17377. */
  17378. toGammaSpaceToRef(convertedColor: Color3): Color3;
  17379. private static _BlackReadOnly;
  17380. /**
  17381. * Creates a new Color3 from the string containing valid hexadecimal values
  17382. * @param hex defines a string containing valid hexadecimal values
  17383. * @returns a new Color3 object
  17384. */
  17385. static FromHexString(hex: string): Color3;
  17386. /**
  17387. * Creates a new Vector3 from the starting index of the given array
  17388. * @param array defines the source array
  17389. * @param offset defines an offset in the source array
  17390. * @returns a new Color3 object
  17391. */
  17392. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  17393. /**
  17394. * Creates a new Color3 from integer values (< 256)
  17395. * @param r defines the red component to read from (value between 0 and 255)
  17396. * @param g defines the green component to read from (value between 0 and 255)
  17397. * @param b defines the blue component to read from (value between 0 and 255)
  17398. * @returns a new Color3 object
  17399. */
  17400. static FromInts(r: number, g: number, b: number): Color3;
  17401. /**
  17402. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17403. * @param start defines the start Color3 value
  17404. * @param end defines the end Color3 value
  17405. * @param amount defines the gradient value between start and end
  17406. * @returns a new Color3 object
  17407. */
  17408. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  17409. /**
  17410. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17411. * @param left defines the start value
  17412. * @param right defines the end value
  17413. * @param amount defines the gradient factor
  17414. * @param result defines the Color3 object where to store the result
  17415. */
  17416. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  17417. /**
  17418. * Returns a Color3 value containing a red color
  17419. * @returns a new Color3 object
  17420. */
  17421. static Red(): Color3;
  17422. /**
  17423. * Returns a Color3 value containing a green color
  17424. * @returns a new Color3 object
  17425. */
  17426. static Green(): Color3;
  17427. /**
  17428. * Returns a Color3 value containing a blue color
  17429. * @returns a new Color3 object
  17430. */
  17431. static Blue(): Color3;
  17432. /**
  17433. * Returns a Color3 value containing a black color
  17434. * @returns a new Color3 object
  17435. */
  17436. static Black(): Color3;
  17437. /**
  17438. * Gets a Color3 value containing a black color that must not be updated
  17439. */
  17440. static readonly BlackReadOnly: DeepImmutable<Color3>;
  17441. /**
  17442. * Returns a Color3 value containing a white color
  17443. * @returns a new Color3 object
  17444. */
  17445. static White(): Color3;
  17446. /**
  17447. * Returns a Color3 value containing a purple color
  17448. * @returns a new Color3 object
  17449. */
  17450. static Purple(): Color3;
  17451. /**
  17452. * Returns a Color3 value containing a magenta color
  17453. * @returns a new Color3 object
  17454. */
  17455. static Magenta(): Color3;
  17456. /**
  17457. * Returns a Color3 value containing a yellow color
  17458. * @returns a new Color3 object
  17459. */
  17460. static Yellow(): Color3;
  17461. /**
  17462. * Returns a Color3 value containing a gray color
  17463. * @returns a new Color3 object
  17464. */
  17465. static Gray(): Color3;
  17466. /**
  17467. * Returns a Color3 value containing a teal color
  17468. * @returns a new Color3 object
  17469. */
  17470. static Teal(): Color3;
  17471. /**
  17472. * Returns a Color3 value containing a random color
  17473. * @returns a new Color3 object
  17474. */
  17475. static Random(): Color3;
  17476. }
  17477. /**
  17478. * Class used to hold a RBGA color
  17479. */
  17480. class Color4 {
  17481. /**
  17482. * Defines the red component (between 0 and 1, default is 0)
  17483. */
  17484. r: number;
  17485. /**
  17486. * Defines the green component (between 0 and 1, default is 0)
  17487. */
  17488. g: number;
  17489. /**
  17490. * Defines the blue component (between 0 and 1, default is 0)
  17491. */
  17492. b: number;
  17493. /**
  17494. * Defines the alpha component (between 0 and 1, default is 1)
  17495. */
  17496. a: number;
  17497. /**
  17498. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  17499. * @param r defines the red component (between 0 and 1, default is 0)
  17500. * @param g defines the green component (between 0 and 1, default is 0)
  17501. * @param b defines the blue component (between 0 and 1, default is 0)
  17502. * @param a defines the alpha component (between 0 and 1, default is 1)
  17503. */
  17504. constructor(
  17505. /**
  17506. * Defines the red component (between 0 and 1, default is 0)
  17507. */
  17508. r?: number,
  17509. /**
  17510. * Defines the green component (between 0 and 1, default is 0)
  17511. */
  17512. g?: number,
  17513. /**
  17514. * Defines the blue component (between 0 and 1, default is 0)
  17515. */
  17516. b?: number,
  17517. /**
  17518. * Defines the alpha component (between 0 and 1, default is 1)
  17519. */
  17520. a?: number);
  17521. /**
  17522. * Adds in place the given Color4 values to the current Color4 object
  17523. * @param right defines the second operand
  17524. * @returns the current updated Color4 object
  17525. */
  17526. addInPlace(right: DeepImmutable<Color4>): Color4;
  17527. /**
  17528. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  17529. * @returns the new array
  17530. */
  17531. asArray(): number[];
  17532. /**
  17533. * Stores from the starting index in the given array the Color4 successive values
  17534. * @param array defines the array where to store the r,g,b components
  17535. * @param index defines an optional index in the target array to define where to start storing values
  17536. * @returns the current Color4 object
  17537. */
  17538. toArray(array: number[], index?: number): Color4;
  17539. /**
  17540. * Determines equality between Color4 objects
  17541. * @param otherColor defines the second operand
  17542. * @returns true if the rgba values are equal to the given ones
  17543. */
  17544. equals(otherColor: DeepImmutable<Color4>): boolean;
  17545. /**
  17546. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  17547. * @param right defines the second operand
  17548. * @returns a new Color4 object
  17549. */
  17550. add(right: DeepImmutable<Color4>): Color4;
  17551. /**
  17552. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  17553. * @param right defines the second operand
  17554. * @returns a new Color4 object
  17555. */
  17556. subtract(right: DeepImmutable<Color4>): Color4;
  17557. /**
  17558. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  17559. * @param right defines the second operand
  17560. * @param result defines the Color4 object where to store the result
  17561. * @returns the current Color4 object
  17562. */
  17563. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  17564. /**
  17565. * Creates a new Color4 with the current Color4 values multiplied by scale
  17566. * @param scale defines the scaling factor to apply
  17567. * @returns a new Color4 object
  17568. */
  17569. scale(scale: number): Color4;
  17570. /**
  17571. * Multiplies the current Color4 values by scale and stores the result in "result"
  17572. * @param scale defines the scaling factor to apply
  17573. * @param result defines the Color4 object where to store the result
  17574. * @returns the current unmodified Color4
  17575. */
  17576. scaleToRef(scale: number, result: Color4): Color4;
  17577. /**
  17578. * Scale the current Color4 values by a factor and add the result to a given Color4
  17579. * @param scale defines the scale factor
  17580. * @param result defines the Color4 object where to store the result
  17581. * @returns the unmodified current Color4
  17582. */
  17583. scaleAndAddToRef(scale: number, result: Color4): Color4;
  17584. /**
  17585. * Clamps the rgb values by the min and max values and stores the result into "result"
  17586. * @param min defines minimum clamping value (default is 0)
  17587. * @param max defines maximum clamping value (default is 1)
  17588. * @param result defines color to store the result into.
  17589. * @returns the cuurent Color4
  17590. */
  17591. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  17592. /**
  17593. * Multipy an Color4 value by another and return a new Color4 object
  17594. * @param color defines the Color4 value to multiply by
  17595. * @returns a new Color4 object
  17596. */
  17597. multiply(color: Color4): Color4;
  17598. /**
  17599. * Multipy a Color4 value by another and push the result in a reference value
  17600. * @param color defines the Color4 value to multiply by
  17601. * @param result defines the Color4 to fill the result in
  17602. * @returns the result Color4
  17603. */
  17604. multiplyToRef(color: Color4, result: Color4): Color4;
  17605. /**
  17606. * Creates a string with the Color4 current values
  17607. * @returns the string representation of the Color4 object
  17608. */
  17609. toString(): string;
  17610. /**
  17611. * Returns the string "Color4"
  17612. * @returns "Color4"
  17613. */
  17614. getClassName(): string;
  17615. /**
  17616. * Compute the Color4 hash code
  17617. * @returns an unique number that can be used to hash Color4 objects
  17618. */
  17619. getHashCode(): number;
  17620. /**
  17621. * Creates a new Color4 copied from the current one
  17622. * @returns a new Color4 object
  17623. */
  17624. clone(): Color4;
  17625. /**
  17626. * Copies the given Color4 values into the current one
  17627. * @param source defines the source Color4 object
  17628. * @returns the current updated Color4 object
  17629. */
  17630. copyFrom(source: Color4): Color4;
  17631. /**
  17632. * Copies the given float values into the current one
  17633. * @param r defines the red component to read from
  17634. * @param g defines the green component to read from
  17635. * @param b defines the blue component to read from
  17636. * @param a defines the alpha component to read from
  17637. * @returns the current updated Color4 object
  17638. */
  17639. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  17640. /**
  17641. * Copies the given float values into the current one
  17642. * @param r defines the red component to read from
  17643. * @param g defines the green component to read from
  17644. * @param b defines the blue component to read from
  17645. * @param a defines the alpha component to read from
  17646. * @returns the current updated Color4 object
  17647. */
  17648. set(r: number, g: number, b: number, a: number): Color4;
  17649. /**
  17650. * Compute the Color4 hexadecimal code as a string
  17651. * @returns a string containing the hexadecimal representation of the Color4 object
  17652. */
  17653. toHexString(): string;
  17654. /**
  17655. * Computes a new Color4 converted from the current one to linear space
  17656. * @returns a new Color4 object
  17657. */
  17658. toLinearSpace(): Color4;
  17659. /**
  17660. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  17661. * @param convertedColor defines the Color4 object where to store the linear space version
  17662. * @returns the unmodified Color4
  17663. */
  17664. toLinearSpaceToRef(convertedColor: Color4): Color4;
  17665. /**
  17666. * Computes a new Color4 converted from the current one to gamma space
  17667. * @returns a new Color4 object
  17668. */
  17669. toGammaSpace(): Color4;
  17670. /**
  17671. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  17672. * @param convertedColor defines the Color4 object where to store the gamma space version
  17673. * @returns the unmodified Color4
  17674. */
  17675. toGammaSpaceToRef(convertedColor: Color4): Color4;
  17676. /**
  17677. * Creates a new Color4 from the string containing valid hexadecimal values
  17678. * @param hex defines a string containing valid hexadecimal values
  17679. * @returns a new Color4 object
  17680. */
  17681. static FromHexString(hex: string): Color4;
  17682. /**
  17683. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17684. * @param left defines the start value
  17685. * @param right defines the end value
  17686. * @param amount defines the gradient factor
  17687. * @returns a new Color4 object
  17688. */
  17689. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  17690. /**
  17691. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17692. * @param left defines the start value
  17693. * @param right defines the end value
  17694. * @param amount defines the gradient factor
  17695. * @param result defines the Color4 object where to store data
  17696. */
  17697. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  17698. /**
  17699. * Creates a new Color4 from a Color3 and an alpha value
  17700. * @param color3 defines the source Color3 to read from
  17701. * @param alpha defines the alpha component (1.0 by default)
  17702. * @returns a new Color4 object
  17703. */
  17704. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  17705. /**
  17706. * Creates a new Color4 from the starting index element of the given array
  17707. * @param array defines the source array to read from
  17708. * @param offset defines the offset in the source array
  17709. * @returns a new Color4 object
  17710. */
  17711. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  17712. /**
  17713. * Creates a new Color3 from integer values (< 256)
  17714. * @param r defines the red component to read from (value between 0 and 255)
  17715. * @param g defines the green component to read from (value between 0 and 255)
  17716. * @param b defines the blue component to read from (value between 0 and 255)
  17717. * @param a defines the alpha component to read from (value between 0 and 255)
  17718. * @returns a new Color3 object
  17719. */
  17720. static FromInts(r: number, g: number, b: number, a: number): Color4;
  17721. /**
  17722. * Check the content of a given array and convert it to an array containing RGBA data
  17723. * If the original array was already containing count * 4 values then it is returned directly
  17724. * @param colors defines the array to check
  17725. * @param count defines the number of RGBA data to expect
  17726. * @returns an array containing count * 4 values (RGBA)
  17727. */
  17728. static CheckColors4(colors: number[], count: number): number[];
  17729. }
  17730. /**
  17731. * Class representing a vector containing 2 coordinates
  17732. */
  17733. class Vector2 {
  17734. /** defines the first coordinate */
  17735. x: number;
  17736. /** defines the second coordinate */
  17737. y: number;
  17738. /**
  17739. * Creates a new Vector2 from the given x and y coordinates
  17740. * @param x defines the first coordinate
  17741. * @param y defines the second coordinate
  17742. */
  17743. constructor(
  17744. /** defines the first coordinate */
  17745. x?: number,
  17746. /** defines the second coordinate */
  17747. y?: number);
  17748. /**
  17749. * Gets a string with the Vector2 coordinates
  17750. * @returns a string with the Vector2 coordinates
  17751. */
  17752. toString(): string;
  17753. /**
  17754. * Gets class name
  17755. * @returns the string "Vector2"
  17756. */
  17757. getClassName(): string;
  17758. /**
  17759. * Gets current vector hash code
  17760. * @returns the Vector2 hash code as a number
  17761. */
  17762. getHashCode(): number;
  17763. /**
  17764. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  17765. * @param array defines the source array
  17766. * @param index defines the offset in source array
  17767. * @returns the current Vector2
  17768. */
  17769. toArray(array: FloatArray, index?: number): Vector2;
  17770. /**
  17771. * Copy the current vector to an array
  17772. * @returns a new array with 2 elements: the Vector2 coordinates.
  17773. */
  17774. asArray(): number[];
  17775. /**
  17776. * Sets the Vector2 coordinates with the given Vector2 coordinates
  17777. * @param source defines the source Vector2
  17778. * @returns the current updated Vector2
  17779. */
  17780. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  17781. /**
  17782. * Sets the Vector2 coordinates with the given floats
  17783. * @param x defines the first coordinate
  17784. * @param y defines the second coordinate
  17785. * @returns the current updated Vector2
  17786. */
  17787. copyFromFloats(x: number, y: number): Vector2;
  17788. /**
  17789. * Sets the Vector2 coordinates with the given floats
  17790. * @param x defines the first coordinate
  17791. * @param y defines the second coordinate
  17792. * @returns the current updated Vector2
  17793. */
  17794. set(x: number, y: number): Vector2;
  17795. /**
  17796. * Add another vector with the current one
  17797. * @param otherVector defines the other vector
  17798. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  17799. */
  17800. add(otherVector: DeepImmutable<Vector2>): Vector2;
  17801. /**
  17802. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  17803. * @param otherVector defines the other vector
  17804. * @param result defines the target vector
  17805. * @returns the unmodified current Vector2
  17806. */
  17807. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17808. /**
  17809. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  17810. * @param otherVector defines the other vector
  17811. * @returns the current updated Vector2
  17812. */
  17813. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17814. /**
  17815. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  17816. * @param otherVector defines the other vector
  17817. * @returns a new Vector2
  17818. */
  17819. addVector3(otherVector: Vector3): Vector2;
  17820. /**
  17821. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  17822. * @param otherVector defines the other vector
  17823. * @returns a new Vector2
  17824. */
  17825. subtract(otherVector: Vector2): Vector2;
  17826. /**
  17827. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  17828. * @param otherVector defines the other vector
  17829. * @param result defines the target vector
  17830. * @returns the unmodified current Vector2
  17831. */
  17832. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17833. /**
  17834. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  17835. * @param otherVector defines the other vector
  17836. * @returns the current updated Vector2
  17837. */
  17838. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17839. /**
  17840. * Multiplies in place the current Vector2 coordinates by the given ones
  17841. * @param otherVector defines the other vector
  17842. * @returns the current updated Vector2
  17843. */
  17844. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17845. /**
  17846. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  17847. * @param otherVector defines the other vector
  17848. * @returns a new Vector2
  17849. */
  17850. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  17851. /**
  17852. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  17853. * @param otherVector defines the other vector
  17854. * @param result defines the target vector
  17855. * @returns the unmodified current Vector2
  17856. */
  17857. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17858. /**
  17859. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  17860. * @param x defines the first coordinate
  17861. * @param y defines the second coordinate
  17862. * @returns a new Vector2
  17863. */
  17864. multiplyByFloats(x: number, y: number): Vector2;
  17865. /**
  17866. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  17867. * @param otherVector defines the other vector
  17868. * @returns a new Vector2
  17869. */
  17870. divide(otherVector: Vector2): Vector2;
  17871. /**
  17872. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  17873. * @param otherVector defines the other vector
  17874. * @param result defines the target vector
  17875. * @returns the unmodified current Vector2
  17876. */
  17877. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17878. /**
  17879. * Divides the current Vector2 coordinates by the given ones
  17880. * @param otherVector defines the other vector
  17881. * @returns the current updated Vector2
  17882. */
  17883. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17884. /**
  17885. * Gets a new Vector2 with current Vector2 negated coordinates
  17886. * @returns a new Vector2
  17887. */
  17888. negate(): Vector2;
  17889. /**
  17890. * Multiply the Vector2 coordinates by scale
  17891. * @param scale defines the scaling factor
  17892. * @returns the current updated Vector2
  17893. */
  17894. scaleInPlace(scale: number): Vector2;
  17895. /**
  17896. * Returns a new Vector2 scaled by "scale" from the current Vector2
  17897. * @param scale defines the scaling factor
  17898. * @returns a new Vector2
  17899. */
  17900. scale(scale: number): Vector2;
  17901. /**
  17902. * Scale the current Vector2 values by a factor to a given Vector2
  17903. * @param scale defines the scale factor
  17904. * @param result defines the Vector2 object where to store the result
  17905. * @returns the unmodified current Vector2
  17906. */
  17907. scaleToRef(scale: number, result: Vector2): Vector2;
  17908. /**
  17909. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  17910. * @param scale defines the scale factor
  17911. * @param result defines the Vector2 object where to store the result
  17912. * @returns the unmodified current Vector2
  17913. */
  17914. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  17915. /**
  17916. * Gets a boolean if two vectors are equals
  17917. * @param otherVector defines the other vector
  17918. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  17919. */
  17920. equals(otherVector: DeepImmutable<Vector2>): boolean;
  17921. /**
  17922. * Gets a boolean if two vectors are equals (using an epsilon value)
  17923. * @param otherVector defines the other vector
  17924. * @param epsilon defines the minimal distance to consider equality
  17925. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  17926. */
  17927. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  17928. /**
  17929. * Gets a new Vector2 from current Vector2 floored values
  17930. * @returns a new Vector2
  17931. */
  17932. floor(): Vector2;
  17933. /**
  17934. * Gets a new Vector2 from current Vector2 floored values
  17935. * @returns a new Vector2
  17936. */
  17937. fract(): Vector2;
  17938. /**
  17939. * Gets the length of the vector
  17940. * @returns the vector length (float)
  17941. */
  17942. length(): number;
  17943. /**
  17944. * Gets the vector squared length
  17945. * @returns the vector squared length (float)
  17946. */
  17947. lengthSquared(): number;
  17948. /**
  17949. * Normalize the vector
  17950. * @returns the current updated Vector2
  17951. */
  17952. normalize(): Vector2;
  17953. /**
  17954. * Gets a new Vector2 copied from the Vector2
  17955. * @returns a new Vector2
  17956. */
  17957. clone(): Vector2;
  17958. /**
  17959. * Gets a new Vector2(0, 0)
  17960. * @returns a new Vector2
  17961. */
  17962. static Zero(): Vector2;
  17963. /**
  17964. * Gets a new Vector2(1, 1)
  17965. * @returns a new Vector2
  17966. */
  17967. static One(): Vector2;
  17968. /**
  17969. * Gets a new Vector2 set from the given index element of the given array
  17970. * @param array defines the data source
  17971. * @param offset defines the offset in the data source
  17972. * @returns a new Vector2
  17973. */
  17974. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  17975. /**
  17976. * Sets "result" from the given index element of the given array
  17977. * @param array defines the data source
  17978. * @param offset defines the offset in the data source
  17979. * @param result defines the target vector
  17980. */
  17981. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  17982. /**
  17983. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  17984. * @param value1 defines 1st point of control
  17985. * @param value2 defines 2nd point of control
  17986. * @param value3 defines 3rd point of control
  17987. * @param value4 defines 4th point of control
  17988. * @param amount defines the interpolation factor
  17989. * @returns a new Vector2
  17990. */
  17991. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  17992. /**
  17993. * 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".
  17994. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  17995. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  17996. * @param value defines the value to clamp
  17997. * @param min defines the lower limit
  17998. * @param max defines the upper limit
  17999. * @returns a new Vector2
  18000. */
  18001. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  18002. /**
  18003. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  18004. * @param value1 defines the 1st control point
  18005. * @param tangent1 defines the outgoing tangent
  18006. * @param value2 defines the 2nd control point
  18007. * @param tangent2 defines the incoming tangent
  18008. * @param amount defines the interpolation factor
  18009. * @returns a new Vector2
  18010. */
  18011. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  18012. /**
  18013. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  18014. * @param start defines the start vector
  18015. * @param end defines the end vector
  18016. * @param amount defines the interpolation factor
  18017. * @returns a new Vector2
  18018. */
  18019. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  18020. /**
  18021. * Gets the dot product of the vector "left" and the vector "right"
  18022. * @param left defines first vector
  18023. * @param right defines second vector
  18024. * @returns the dot product (float)
  18025. */
  18026. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  18027. /**
  18028. * Returns a new Vector2 equal to the normalized given vector
  18029. * @param vector defines the vector to normalize
  18030. * @returns a new Vector2
  18031. */
  18032. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  18033. /**
  18034. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  18035. * @param left defines 1st vector
  18036. * @param right defines 2nd vector
  18037. * @returns a new Vector2
  18038. */
  18039. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  18040. /**
  18041. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  18042. * @param left defines 1st vector
  18043. * @param right defines 2nd vector
  18044. * @returns a new Vector2
  18045. */
  18046. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  18047. /**
  18048. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  18049. * @param vector defines the vector to transform
  18050. * @param transformation defines the matrix to apply
  18051. * @returns a new Vector2
  18052. */
  18053. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  18054. /**
  18055. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  18056. * @param vector defines the vector to transform
  18057. * @param transformation defines the matrix to apply
  18058. * @param result defines the target vector
  18059. */
  18060. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  18061. /**
  18062. * Determines if a given vector is included in a triangle
  18063. * @param p defines the vector to test
  18064. * @param p0 defines 1st triangle point
  18065. * @param p1 defines 2nd triangle point
  18066. * @param p2 defines 3rd triangle point
  18067. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  18068. */
  18069. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  18070. /**
  18071. * Gets the distance between the vectors "value1" and "value2"
  18072. * @param value1 defines first vector
  18073. * @param value2 defines second vector
  18074. * @returns the distance between vectors
  18075. */
  18076. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  18077. /**
  18078. * Returns the squared distance between the vectors "value1" and "value2"
  18079. * @param value1 defines first vector
  18080. * @param value2 defines second vector
  18081. * @returns the squared distance between vectors
  18082. */
  18083. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  18084. /**
  18085. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  18086. * @param value1 defines first vector
  18087. * @param value2 defines second vector
  18088. * @returns a new Vector2
  18089. */
  18090. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  18091. /**
  18092. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  18093. * @param p defines the middle point
  18094. * @param segA defines one point of the segment
  18095. * @param segB defines the other point of the segment
  18096. * @returns the shortest distance
  18097. */
  18098. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  18099. }
  18100. /**
  18101. * Classed used to store (x,y,z) vector representation
  18102. * A Vector3 is the main object used in 3D geometry
  18103. * It can represent etiher the coordinates of a point the space, either a direction
  18104. * Reminder: Babylon.js uses a left handed forward facing system
  18105. */
  18106. class Vector3 {
  18107. /**
  18108. * Defines the first coordinates (on X axis)
  18109. */
  18110. x: number;
  18111. /**
  18112. * Defines the second coordinates (on Y axis)
  18113. */
  18114. y: number;
  18115. /**
  18116. * Defines the third coordinates (on Z axis)
  18117. */
  18118. z: number;
  18119. private static _UpReadOnly;
  18120. /**
  18121. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  18122. * @param x defines the first coordinates (on X axis)
  18123. * @param y defines the second coordinates (on Y axis)
  18124. * @param z defines the third coordinates (on Z axis)
  18125. */
  18126. constructor(
  18127. /**
  18128. * Defines the first coordinates (on X axis)
  18129. */
  18130. x?: number,
  18131. /**
  18132. * Defines the second coordinates (on Y axis)
  18133. */
  18134. y?: number,
  18135. /**
  18136. * Defines the third coordinates (on Z axis)
  18137. */
  18138. z?: number);
  18139. /**
  18140. * Creates a string representation of the Vector3
  18141. * @returns a string with the Vector3 coordinates.
  18142. */
  18143. toString(): string;
  18144. /**
  18145. * Gets the class name
  18146. * @returns the string "Vector3"
  18147. */
  18148. getClassName(): string;
  18149. /**
  18150. * Creates the Vector3 hash code
  18151. * @returns a number which tends to be unique between Vector3 instances
  18152. */
  18153. getHashCode(): number;
  18154. /**
  18155. * Creates an array containing three elements : the coordinates of the Vector3
  18156. * @returns a new array of numbers
  18157. */
  18158. asArray(): number[];
  18159. /**
  18160. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  18161. * @param array defines the destination array
  18162. * @param index defines the offset in the destination array
  18163. * @returns the current Vector3
  18164. */
  18165. toArray(array: FloatArray, index?: number): Vector3;
  18166. /**
  18167. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  18168. * @returns a new Quaternion object, computed from the Vector3 coordinates
  18169. */
  18170. toQuaternion(): Quaternion;
  18171. /**
  18172. * Adds the given vector to the current Vector3
  18173. * @param otherVector defines the second operand
  18174. * @returns the current updated Vector3
  18175. */
  18176. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18177. /**
  18178. * Adds the given coordinates to the current Vector3
  18179. * @param x defines the x coordinate of the operand
  18180. * @param y defines the y coordinate of the operand
  18181. * @param z defines the z coordinate of the operand
  18182. * @returns the current updated Vector3
  18183. */
  18184. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18185. /**
  18186. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  18187. * @param otherVector defines the second operand
  18188. * @returns the resulting Vector3
  18189. */
  18190. add(otherVector: DeepImmutable<Vector3>): Vector3;
  18191. /**
  18192. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  18193. * @param otherVector defines the second operand
  18194. * @param result defines the Vector3 object where to store the result
  18195. * @returns the current Vector3
  18196. */
  18197. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18198. /**
  18199. * Subtract the given vector from the current Vector3
  18200. * @param otherVector defines the second operand
  18201. * @returns the current updated Vector3
  18202. */
  18203. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18204. /**
  18205. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  18206. * @param otherVector defines the second operand
  18207. * @returns the resulting Vector3
  18208. */
  18209. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  18210. /**
  18211. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  18212. * @param otherVector defines the second operand
  18213. * @param result defines the Vector3 object where to store the result
  18214. * @returns the current Vector3
  18215. */
  18216. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18217. /**
  18218. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  18219. * @param x defines the x coordinate of the operand
  18220. * @param y defines the y coordinate of the operand
  18221. * @param z defines the z coordinate of the operand
  18222. * @returns the resulting Vector3
  18223. */
  18224. subtractFromFloats(x: number, y: number, z: number): Vector3;
  18225. /**
  18226. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  18227. * @param x defines the x coordinate of the operand
  18228. * @param y defines the y coordinate of the operand
  18229. * @param z defines the z coordinate of the operand
  18230. * @param result defines the Vector3 object where to store the result
  18231. * @returns the current Vector3
  18232. */
  18233. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  18234. /**
  18235. * Gets a new Vector3 set with the current Vector3 negated coordinates
  18236. * @returns a new Vector3
  18237. */
  18238. negate(): Vector3;
  18239. /**
  18240. * Multiplies the Vector3 coordinates by the float "scale"
  18241. * @param scale defines the multiplier factor
  18242. * @returns the current updated Vector3
  18243. */
  18244. scaleInPlace(scale: number): Vector3;
  18245. /**
  18246. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  18247. * @param scale defines the multiplier factor
  18248. * @returns a new Vector3
  18249. */
  18250. scale(scale: number): Vector3;
  18251. /**
  18252. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  18253. * @param scale defines the multiplier factor
  18254. * @param result defines the Vector3 object where to store the result
  18255. * @returns the current Vector3
  18256. */
  18257. scaleToRef(scale: number, result: Vector3): Vector3;
  18258. /**
  18259. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  18260. * @param scale defines the scale factor
  18261. * @param result defines the Vector3 object where to store the result
  18262. * @returns the unmodified current Vector3
  18263. */
  18264. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  18265. /**
  18266. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  18267. * @param otherVector defines the second operand
  18268. * @returns true if both vectors are equals
  18269. */
  18270. equals(otherVector: DeepImmutable<Vector3>): boolean;
  18271. /**
  18272. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  18273. * @param otherVector defines the second operand
  18274. * @param epsilon defines the minimal distance to define values as equals
  18275. * @returns true if both vectors are distant less than epsilon
  18276. */
  18277. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  18278. /**
  18279. * Returns true if the current Vector3 coordinates equals the given floats
  18280. * @param x defines the x coordinate of the operand
  18281. * @param y defines the y coordinate of the operand
  18282. * @param z defines the z coordinate of the operand
  18283. * @returns true if both vectors are equals
  18284. */
  18285. equalsToFloats(x: number, y: number, z: number): boolean;
  18286. /**
  18287. * Multiplies the current Vector3 coordinates by the given ones
  18288. * @param otherVector defines the second operand
  18289. * @returns the current updated Vector3
  18290. */
  18291. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18292. /**
  18293. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  18294. * @param otherVector defines the second operand
  18295. * @returns the new Vector3
  18296. */
  18297. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  18298. /**
  18299. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  18300. * @param otherVector defines the second operand
  18301. * @param result defines the Vector3 object where to store the result
  18302. * @returns the current Vector3
  18303. */
  18304. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18305. /**
  18306. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  18307. * @param x defines the x coordinate of the operand
  18308. * @param y defines the y coordinate of the operand
  18309. * @param z defines the z coordinate of the operand
  18310. * @returns the new Vector3
  18311. */
  18312. multiplyByFloats(x: number, y: number, z: number): Vector3;
  18313. /**
  18314. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  18315. * @param otherVector defines the second operand
  18316. * @returns the new Vector3
  18317. */
  18318. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  18319. /**
  18320. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  18321. * @param otherVector defines the second operand
  18322. * @param result defines the Vector3 object where to store the result
  18323. * @returns the current Vector3
  18324. */
  18325. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18326. /**
  18327. * Divides the current Vector3 coordinates by the given ones.
  18328. * @param otherVector defines the second operand
  18329. * @returns the current updated Vector3
  18330. */
  18331. divideInPlace(otherVector: Vector3): Vector3;
  18332. /**
  18333. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  18334. * @param other defines the second operand
  18335. * @returns the current updated Vector3
  18336. */
  18337. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18338. /**
  18339. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  18340. * @param other defines the second operand
  18341. * @returns the current updated Vector3
  18342. */
  18343. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18344. /**
  18345. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  18346. * @param x defines the x coordinate of the operand
  18347. * @param y defines the y coordinate of the operand
  18348. * @param z defines the z coordinate of the operand
  18349. * @returns the current updated Vector3
  18350. */
  18351. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18352. /**
  18353. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  18354. * @param x defines the x coordinate of the operand
  18355. * @param y defines the y coordinate of the operand
  18356. * @param z defines the z coordinate of the operand
  18357. * @returns the current updated Vector3
  18358. */
  18359. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18360. /**
  18361. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  18362. * Check if is non uniform within a certain amount of decimal places to account for this
  18363. * @param epsilon the amount the values can differ
  18364. * @returns if the the vector is non uniform to a certain number of decimal places
  18365. */
  18366. isNonUniformWithinEpsilon(epsilon: number): boolean;
  18367. /**
  18368. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  18369. */
  18370. readonly isNonUniform: boolean;
  18371. /**
  18372. * Gets a new Vector3 from current Vector3 floored values
  18373. * @returns a new Vector3
  18374. */
  18375. floor(): Vector3;
  18376. /**
  18377. * Gets a new Vector3 from current Vector3 floored values
  18378. * @returns a new Vector3
  18379. */
  18380. fract(): Vector3;
  18381. /**
  18382. * Gets the length of the Vector3
  18383. * @returns the length of the Vecto3
  18384. */
  18385. length(): number;
  18386. /**
  18387. * Gets the squared length of the Vector3
  18388. * @returns squared length of the Vector3
  18389. */
  18390. lengthSquared(): number;
  18391. /**
  18392. * Normalize the current Vector3.
  18393. * Please note that this is an in place operation.
  18394. * @returns the current updated Vector3
  18395. */
  18396. normalize(): Vector3;
  18397. /**
  18398. * Reorders the x y z properties of the vector in place
  18399. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  18400. * @returns the current updated vector
  18401. */
  18402. reorderInPlace(order: string): this;
  18403. /**
  18404. * Rotates the vector around 0,0,0 by a quaternion
  18405. * @param quaternion the rotation quaternion
  18406. * @param result vector to store the result
  18407. * @returns the resulting vector
  18408. */
  18409. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  18410. /**
  18411. * Rotates a vector around a given point
  18412. * @param quaternion the rotation quaternion
  18413. * @param point the point to rotate around
  18414. * @param result vector to store the result
  18415. * @returns the resulting vector
  18416. */
  18417. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  18418. /**
  18419. * Normalize the current Vector3 with the given input length.
  18420. * Please note that this is an in place operation.
  18421. * @param len the length of the vector
  18422. * @returns the current updated Vector3
  18423. */
  18424. normalizeFromLength(len: number): Vector3;
  18425. /**
  18426. * Normalize the current Vector3 to a new vector
  18427. * @returns the new Vector3
  18428. */
  18429. normalizeToNew(): Vector3;
  18430. /**
  18431. * Normalize the current Vector3 to the reference
  18432. * @param reference define the Vector3 to update
  18433. * @returns the updated Vector3
  18434. */
  18435. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  18436. /**
  18437. * Creates a new Vector3 copied from the current Vector3
  18438. * @returns the new Vector3
  18439. */
  18440. clone(): Vector3;
  18441. /**
  18442. * Copies the given vector coordinates to the current Vector3 ones
  18443. * @param source defines the source Vector3
  18444. * @returns the current updated Vector3
  18445. */
  18446. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  18447. /**
  18448. * Copies the given floats to the current Vector3 coordinates
  18449. * @param x defines the x coordinate of the operand
  18450. * @param y defines the y coordinate of the operand
  18451. * @param z defines the z coordinate of the operand
  18452. * @returns the current updated Vector3
  18453. */
  18454. copyFromFloats(x: number, y: number, z: number): Vector3;
  18455. /**
  18456. * Copies the given floats to the current Vector3 coordinates
  18457. * @param x defines the x coordinate of the operand
  18458. * @param y defines the y coordinate of the operand
  18459. * @param z defines the z coordinate of the operand
  18460. * @returns the current updated Vector3
  18461. */
  18462. set(x: number, y: number, z: number): Vector3;
  18463. /**
  18464. * Copies the given float to the current Vector3 coordinates
  18465. * @param v defines the x, y and z coordinates of the operand
  18466. * @returns the current updated Vector3
  18467. */
  18468. setAll(v: number): Vector3;
  18469. /**
  18470. * Get the clip factor between two vectors
  18471. * @param vector0 defines the first operand
  18472. * @param vector1 defines the second operand
  18473. * @param axis defines the axis to use
  18474. * @param size defines the size along the axis
  18475. * @returns the clip factor
  18476. */
  18477. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  18478. /**
  18479. * Get angle between two vectors
  18480. * @param vector0 angle between vector0 and vector1
  18481. * @param vector1 angle between vector0 and vector1
  18482. * @param normal direction of the normal
  18483. * @return the angle between vector0 and vector1
  18484. */
  18485. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  18486. /**
  18487. * Returns a new Vector3 set from the index "offset" of the given array
  18488. * @param array defines the source array
  18489. * @param offset defines the offset in the source array
  18490. * @returns the new Vector3
  18491. */
  18492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  18493. /**
  18494. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  18495. * This function is deprecated. Use FromArray instead
  18496. * @param array defines the source array
  18497. * @param offset defines the offset in the source array
  18498. * @returns the new Vector3
  18499. */
  18500. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  18501. /**
  18502. * Sets the given vector "result" with the element values from the index "offset" of the given array
  18503. * @param array defines the source array
  18504. * @param offset defines the offset in the source array
  18505. * @param result defines the Vector3 where to store the result
  18506. */
  18507. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  18508. /**
  18509. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  18510. * This function is deprecated. Use FromArrayToRef instead.
  18511. * @param array defines the source array
  18512. * @param offset defines the offset in the source array
  18513. * @param result defines the Vector3 where to store the result
  18514. */
  18515. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  18516. /**
  18517. * Sets the given vector "result" with the given floats.
  18518. * @param x defines the x coordinate of the source
  18519. * @param y defines the y coordinate of the source
  18520. * @param z defines the z coordinate of the source
  18521. * @param result defines the Vector3 where to store the result
  18522. */
  18523. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  18524. /**
  18525. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  18526. * @returns a new empty Vector3
  18527. */
  18528. static Zero(): Vector3;
  18529. /**
  18530. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  18531. * @returns a new unit Vector3
  18532. */
  18533. static One(): Vector3;
  18534. /**
  18535. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  18536. * @returns a new up Vector3
  18537. */
  18538. static Up(): Vector3;
  18539. /**
  18540. * Gets a up Vector3 that must not be updated
  18541. */
  18542. static readonly UpReadOnly: DeepImmutable<Vector3>;
  18543. /**
  18544. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  18545. * @returns a new down Vector3
  18546. */
  18547. static Down(): Vector3;
  18548. /**
  18549. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  18550. * @returns a new forward Vector3
  18551. */
  18552. static Forward(): Vector3;
  18553. /**
  18554. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  18555. * @returns a new forward Vector3
  18556. */
  18557. static Backward(): Vector3;
  18558. /**
  18559. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  18560. * @returns a new right Vector3
  18561. */
  18562. static Right(): Vector3;
  18563. /**
  18564. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  18565. * @returns a new left Vector3
  18566. */
  18567. static Left(): Vector3;
  18568. /**
  18569. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  18570. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18571. * @param vector defines the Vector3 to transform
  18572. * @param transformation defines the transformation matrix
  18573. * @returns the transformed Vector3
  18574. */
  18575. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18576. /**
  18577. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  18578. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18579. * @param vector defines the Vector3 to transform
  18580. * @param transformation defines the transformation matrix
  18581. * @param result defines the Vector3 where to store the result
  18582. */
  18583. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18584. /**
  18585. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  18586. * This method computes tranformed coordinates only, not transformed direction vectors
  18587. * @param x define the x coordinate of the source vector
  18588. * @param y define the y coordinate of the source vector
  18589. * @param z define the z coordinate of the source vector
  18590. * @param transformation defines the transformation matrix
  18591. * @param result defines the Vector3 where to store the result
  18592. */
  18593. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18594. /**
  18595. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  18596. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18597. * @param vector defines the Vector3 to transform
  18598. * @param transformation defines the transformation matrix
  18599. * @returns the new Vector3
  18600. */
  18601. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18602. /**
  18603. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  18604. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18605. * @param vector defines the Vector3 to transform
  18606. * @param transformation defines the transformation matrix
  18607. * @param result defines the Vector3 where to store the result
  18608. */
  18609. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18610. /**
  18611. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  18612. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18613. * @param x define the x coordinate of the source vector
  18614. * @param y define the y coordinate of the source vector
  18615. * @param z define the z coordinate of the source vector
  18616. * @param transformation defines the transformation matrix
  18617. * @param result defines the Vector3 where to store the result
  18618. */
  18619. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18620. /**
  18621. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  18622. * @param value1 defines the first control point
  18623. * @param value2 defines the second control point
  18624. * @param value3 defines the third control point
  18625. * @param value4 defines the fourth control point
  18626. * @param amount defines the amount on the spline to use
  18627. * @returns the new Vector3
  18628. */
  18629. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  18630. /**
  18631. * 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"
  18632. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18633. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18634. * @param value defines the current value
  18635. * @param min defines the lower range value
  18636. * @param max defines the upper range value
  18637. * @returns the new Vector3
  18638. */
  18639. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  18640. /**
  18641. * 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"
  18642. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18643. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18644. * @param value defines the current value
  18645. * @param min defines the lower range value
  18646. * @param max defines the upper range value
  18647. * @param result defines the Vector3 where to store the result
  18648. */
  18649. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  18650. /**
  18651. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  18652. * @param value1 defines the first control point
  18653. * @param tangent1 defines the first tangent vector
  18654. * @param value2 defines the second control point
  18655. * @param tangent2 defines the second tangent vector
  18656. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  18657. * @returns the new Vector3
  18658. */
  18659. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  18660. /**
  18661. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  18662. * @param start defines the start value
  18663. * @param end defines the end value
  18664. * @param amount max defines amount between both (between 0 and 1)
  18665. * @returns the new Vector3
  18666. */
  18667. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  18668. /**
  18669. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  18670. * @param start defines the start value
  18671. * @param end defines the end value
  18672. * @param amount max defines amount between both (between 0 and 1)
  18673. * @param result defines the Vector3 where to store the result
  18674. */
  18675. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  18676. /**
  18677. * Returns the dot product (float) between the vectors "left" and "right"
  18678. * @param left defines the left operand
  18679. * @param right defines the right operand
  18680. * @returns the dot product
  18681. */
  18682. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  18683. /**
  18684. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  18685. * The cross product is then orthogonal to both "left" and "right"
  18686. * @param left defines the left operand
  18687. * @param right defines the right operand
  18688. * @returns the cross product
  18689. */
  18690. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18691. /**
  18692. * Sets the given vector "result" with the cross product of "left" and "right"
  18693. * The cross product is then orthogonal to both "left" and "right"
  18694. * @param left defines the left operand
  18695. * @param right defines the right operand
  18696. * @param result defines the Vector3 where to store the result
  18697. */
  18698. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  18699. /**
  18700. * Returns a new Vector3 as the normalization of the given vector
  18701. * @param vector defines the Vector3 to normalize
  18702. * @returns the new Vector3
  18703. */
  18704. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  18705. /**
  18706. * Sets the given vector "result" with the normalization of the given first vector
  18707. * @param vector defines the Vector3 to normalize
  18708. * @param result defines the Vector3 where to store the result
  18709. */
  18710. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  18711. /**
  18712. * Project a Vector3 onto screen space
  18713. * @param vector defines the Vector3 to project
  18714. * @param world defines the world matrix to use
  18715. * @param transform defines the transform (view x projection) matrix to use
  18716. * @param viewport defines the screen viewport to use
  18717. * @returns the new Vector3
  18718. */
  18719. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  18720. /** @hidden */
  18721. private static UnprojectFromInvertedMatrixToRef;
  18722. /**
  18723. * Unproject from screen space to object space
  18724. * @param source defines the screen space Vector3 to use
  18725. * @param viewportWidth defines the current width of the viewport
  18726. * @param viewportHeight defines the current height of the viewport
  18727. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18728. * @param transform defines the transform (view x projection) matrix to use
  18729. * @returns the new Vector3
  18730. */
  18731. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  18732. /**
  18733. * Unproject from screen space to object space
  18734. * @param source defines the screen space Vector3 to use
  18735. * @param viewportWidth defines the current width of the viewport
  18736. * @param viewportHeight defines the current height of the viewport
  18737. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18738. * @param view defines the view matrix to use
  18739. * @param projection defines the projection matrix to use
  18740. * @returns the new Vector3
  18741. */
  18742. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  18743. /**
  18744. * Unproject from screen space to object space
  18745. * @param source defines the screen space Vector3 to use
  18746. * @param viewportWidth defines the current width of the viewport
  18747. * @param viewportHeight defines the current height of the viewport
  18748. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18749. * @param view defines the view matrix to use
  18750. * @param projection defines the projection matrix to use
  18751. * @param result defines the Vector3 where to store the result
  18752. */
  18753. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18754. /**
  18755. * Unproject from screen space to object space
  18756. * @param sourceX defines the screen space x coordinate to use
  18757. * @param sourceY defines the screen space y coordinate to use
  18758. * @param sourceZ defines the screen space z coordinate to use
  18759. * @param viewportWidth defines the current width of the viewport
  18760. * @param viewportHeight defines the current height of the viewport
  18761. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18762. * @param view defines the view matrix to use
  18763. * @param projection defines the projection matrix to use
  18764. * @param result defines the Vector3 where to store the result
  18765. */
  18766. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18767. /**
  18768. * Unproject a ray from screen space to object space
  18769. * @param sourceX defines the screen space x coordinate to use
  18770. * @param sourceY defines the screen space y coordinate to use
  18771. * @param viewportWidth defines the current width of the viewport
  18772. * @param viewportHeight defines the current height of the viewport
  18773. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18774. * @param view defines the view matrix to use
  18775. * @param projection defines the projection matrix to use
  18776. * @param ray defines the Ray where to store the result
  18777. */
  18778. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  18779. /**
  18780. * Gets the minimal coordinate values between two Vector3
  18781. * @param left defines the first operand
  18782. * @param right defines the second operand
  18783. * @returns the new Vector3
  18784. */
  18785. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18786. /**
  18787. * Gets the maximal coordinate values between two Vector3
  18788. * @param left defines the first operand
  18789. * @param right defines the second operand
  18790. * @returns the new Vector3
  18791. */
  18792. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18793. /**
  18794. * Returns the distance between the vectors "value1" and "value2"
  18795. * @param value1 defines the first operand
  18796. * @param value2 defines the second operand
  18797. * @returns the distance
  18798. */
  18799. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18800. /**
  18801. * Returns the squared distance between the vectors "value1" and "value2"
  18802. * @param value1 defines the first operand
  18803. * @param value2 defines the second operand
  18804. * @returns the squared distance
  18805. */
  18806. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18807. /**
  18808. * Returns a new Vector3 located at the center between "value1" and "value2"
  18809. * @param value1 defines the first operand
  18810. * @param value2 defines the second operand
  18811. * @returns the new Vector3
  18812. */
  18813. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  18814. /**
  18815. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  18816. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  18817. * to something in order to rotate it from its local system to the given target system
  18818. * Note: axis1, axis2 and axis3 are normalized during this operation
  18819. * @param axis1 defines the first axis
  18820. * @param axis2 defines the second axis
  18821. * @param axis3 defines the third axis
  18822. * @returns a new Vector3
  18823. */
  18824. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  18825. /**
  18826. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  18827. * @param axis1 defines the first axis
  18828. * @param axis2 defines the second axis
  18829. * @param axis3 defines the third axis
  18830. * @param ref defines the Vector3 where to store the result
  18831. */
  18832. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  18833. }
  18834. /**
  18835. * Vector4 class created for EulerAngle class conversion to Quaternion
  18836. */
  18837. class Vector4 {
  18838. /** x value of the vector */
  18839. x: number;
  18840. /** y value of the vector */
  18841. y: number;
  18842. /** z value of the vector */
  18843. z: number;
  18844. /** w value of the vector */
  18845. w: number;
  18846. /**
  18847. * Creates a Vector4 object from the given floats.
  18848. * @param x x value of the vector
  18849. * @param y y value of the vector
  18850. * @param z z value of the vector
  18851. * @param w w value of the vector
  18852. */
  18853. constructor(
  18854. /** x value of the vector */
  18855. x: number,
  18856. /** y value of the vector */
  18857. y: number,
  18858. /** z value of the vector */
  18859. z: number,
  18860. /** w value of the vector */
  18861. w: number);
  18862. /**
  18863. * Returns the string with the Vector4 coordinates.
  18864. * @returns a string containing all the vector values
  18865. */
  18866. toString(): string;
  18867. /**
  18868. * Returns the string "Vector4".
  18869. * @returns "Vector4"
  18870. */
  18871. getClassName(): string;
  18872. /**
  18873. * Returns the Vector4 hash code.
  18874. * @returns a unique hash code
  18875. */
  18876. getHashCode(): number;
  18877. /**
  18878. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  18879. * @returns the resulting array
  18880. */
  18881. asArray(): number[];
  18882. /**
  18883. * Populates the given array from the given index with the Vector4 coordinates.
  18884. * @param array array to populate
  18885. * @param index index of the array to start at (default: 0)
  18886. * @returns the Vector4.
  18887. */
  18888. toArray(array: FloatArray, index?: number): Vector4;
  18889. /**
  18890. * Adds the given vector to the current Vector4.
  18891. * @param otherVector the vector to add
  18892. * @returns the updated Vector4.
  18893. */
  18894. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18895. /**
  18896. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  18897. * @param otherVector the vector to add
  18898. * @returns the resulting vector
  18899. */
  18900. add(otherVector: DeepImmutable<Vector4>): Vector4;
  18901. /**
  18902. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  18903. * @param otherVector the vector to add
  18904. * @param result the vector to store the result
  18905. * @returns the current Vector4.
  18906. */
  18907. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18908. /**
  18909. * Subtract in place the given vector from the current Vector4.
  18910. * @param otherVector the vector to subtract
  18911. * @returns the updated Vector4.
  18912. */
  18913. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18914. /**
  18915. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  18916. * @param otherVector the vector to add
  18917. * @returns the new vector with the result
  18918. */
  18919. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  18920. /**
  18921. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  18922. * @param otherVector the vector to subtract
  18923. * @param result the vector to store the result
  18924. * @returns the current Vector4.
  18925. */
  18926. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18927. /**
  18928. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18929. */
  18930. /**
  18931. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18932. * @param x value to subtract
  18933. * @param y value to subtract
  18934. * @param z value to subtract
  18935. * @param w value to subtract
  18936. * @returns new vector containing the result
  18937. */
  18938. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18939. /**
  18940. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18941. * @param x value to subtract
  18942. * @param y value to subtract
  18943. * @param z value to subtract
  18944. * @param w value to subtract
  18945. * @param result the vector to store the result in
  18946. * @returns the current Vector4.
  18947. */
  18948. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  18949. /**
  18950. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  18951. * @returns a new vector with the negated values
  18952. */
  18953. negate(): Vector4;
  18954. /**
  18955. * Multiplies the current Vector4 coordinates by scale (float).
  18956. * @param scale the number to scale with
  18957. * @returns the updated Vector4.
  18958. */
  18959. scaleInPlace(scale: number): Vector4;
  18960. /**
  18961. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  18962. * @param scale the number to scale with
  18963. * @returns a new vector with the result
  18964. */
  18965. scale(scale: number): Vector4;
  18966. /**
  18967. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  18968. * @param scale the number to scale with
  18969. * @param result a vector to store the result in
  18970. * @returns the current Vector4.
  18971. */
  18972. scaleToRef(scale: number, result: Vector4): Vector4;
  18973. /**
  18974. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  18975. * @param scale defines the scale factor
  18976. * @param result defines the Vector4 object where to store the result
  18977. * @returns the unmodified current Vector4
  18978. */
  18979. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  18980. /**
  18981. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  18982. * @param otherVector the vector to compare against
  18983. * @returns true if they are equal
  18984. */
  18985. equals(otherVector: DeepImmutable<Vector4>): boolean;
  18986. /**
  18987. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  18988. * @param otherVector vector to compare against
  18989. * @param epsilon (Default: very small number)
  18990. * @returns true if they are equal
  18991. */
  18992. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  18993. /**
  18994. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  18995. * @param x x value to compare against
  18996. * @param y y value to compare against
  18997. * @param z z value to compare against
  18998. * @param w w value to compare against
  18999. * @returns true if equal
  19000. */
  19001. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  19002. /**
  19003. * Multiplies in place the current Vector4 by the given one.
  19004. * @param otherVector vector to multiple with
  19005. * @returns the updated Vector4.
  19006. */
  19007. multiplyInPlace(otherVector: Vector4): Vector4;
  19008. /**
  19009. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  19010. * @param otherVector vector to multiple with
  19011. * @returns resulting new vector
  19012. */
  19013. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  19014. /**
  19015. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  19016. * @param otherVector vector to multiple with
  19017. * @param result vector to store the result
  19018. * @returns the current Vector4.
  19019. */
  19020. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  19021. /**
  19022. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  19023. * @param x x value multiply with
  19024. * @param y y value multiply with
  19025. * @param z z value multiply with
  19026. * @param w w value multiply with
  19027. * @returns resulting new vector
  19028. */
  19029. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  19030. /**
  19031. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  19032. * @param otherVector vector to devide with
  19033. * @returns resulting new vector
  19034. */
  19035. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  19036. /**
  19037. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  19038. * @param otherVector vector to devide with
  19039. * @param result vector to store the result
  19040. * @returns the current Vector4.
  19041. */
  19042. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  19043. /**
  19044. * Divides the current Vector3 coordinates by the given ones.
  19045. * @param otherVector vector to devide with
  19046. * @returns the updated Vector3.
  19047. */
  19048. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  19049. /**
  19050. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  19051. * @param other defines the second operand
  19052. * @returns the current updated Vector4
  19053. */
  19054. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  19055. /**
  19056. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  19057. * @param other defines the second operand
  19058. * @returns the current updated Vector4
  19059. */
  19060. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  19061. /**
  19062. * Gets a new Vector4 from current Vector4 floored values
  19063. * @returns a new Vector4
  19064. */
  19065. floor(): Vector4;
  19066. /**
  19067. * Gets a new Vector4 from current Vector3 floored values
  19068. * @returns a new Vector4
  19069. */
  19070. fract(): Vector4;
  19071. /**
  19072. * Returns the Vector4 length (float).
  19073. * @returns the length
  19074. */
  19075. length(): number;
  19076. /**
  19077. * Returns the Vector4 squared length (float).
  19078. * @returns the length squared
  19079. */
  19080. lengthSquared(): number;
  19081. /**
  19082. * Normalizes in place the Vector4.
  19083. * @returns the updated Vector4.
  19084. */
  19085. normalize(): Vector4;
  19086. /**
  19087. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  19088. * @returns this converted to a new vector3
  19089. */
  19090. toVector3(): Vector3;
  19091. /**
  19092. * Returns a new Vector4 copied from the current one.
  19093. * @returns the new cloned vector
  19094. */
  19095. clone(): Vector4;
  19096. /**
  19097. * Updates the current Vector4 with the given one coordinates.
  19098. * @param source the source vector to copy from
  19099. * @returns the updated Vector4.
  19100. */
  19101. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  19102. /**
  19103. * Updates the current Vector4 coordinates with the given floats.
  19104. * @param x float to copy from
  19105. * @param y float to copy from
  19106. * @param z float to copy from
  19107. * @param w float to copy from
  19108. * @returns the updated Vector4.
  19109. */
  19110. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  19111. /**
  19112. * Updates the current Vector4 coordinates with the given floats.
  19113. * @param x float to set from
  19114. * @param y float to set from
  19115. * @param z float to set from
  19116. * @param w float to set from
  19117. * @returns the updated Vector4.
  19118. */
  19119. set(x: number, y: number, z: number, w: number): Vector4;
  19120. /**
  19121. * Copies the given float to the current Vector3 coordinates
  19122. * @param v defines the x, y, z and w coordinates of the operand
  19123. * @returns the current updated Vector3
  19124. */
  19125. setAll(v: number): Vector4;
  19126. /**
  19127. * Returns a new Vector4 set from the starting index of the given array.
  19128. * @param array the array to pull values from
  19129. * @param offset the offset into the array to start at
  19130. * @returns the new vector
  19131. */
  19132. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  19133. /**
  19134. * Updates the given vector "result" from the starting index of the given array.
  19135. * @param array the array to pull values from
  19136. * @param offset the offset into the array to start at
  19137. * @param result the vector to store the result in
  19138. */
  19139. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  19140. /**
  19141. * Updates the given vector "result" from the starting index of the given Float32Array.
  19142. * @param array the array to pull values from
  19143. * @param offset the offset into the array to start at
  19144. * @param result the vector to store the result in
  19145. */
  19146. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  19147. /**
  19148. * Updates the given vector "result" coordinates from the given floats.
  19149. * @param x float to set from
  19150. * @param y float to set from
  19151. * @param z float to set from
  19152. * @param w float to set from
  19153. * @param result the vector to the floats in
  19154. */
  19155. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  19156. /**
  19157. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  19158. * @returns the new vector
  19159. */
  19160. static Zero(): Vector4;
  19161. /**
  19162. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  19163. * @returns the new vector
  19164. */
  19165. static One(): Vector4;
  19166. /**
  19167. * Returns a new normalized Vector4 from the given one.
  19168. * @param vector the vector to normalize
  19169. * @returns the vector
  19170. */
  19171. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  19172. /**
  19173. * Updates the given vector "result" from the normalization of the given one.
  19174. * @param vector the vector to normalize
  19175. * @param result the vector to store the result in
  19176. */
  19177. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  19178. /**
  19179. * Returns a vector with the minimum values from the left and right vectors
  19180. * @param left left vector to minimize
  19181. * @param right right vector to minimize
  19182. * @returns a new vector with the minimum of the left and right vector values
  19183. */
  19184. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  19185. /**
  19186. * Returns a vector with the maximum values from the left and right vectors
  19187. * @param left left vector to maximize
  19188. * @param right right vector to maximize
  19189. * @returns a new vector with the maximum of the left and right vector values
  19190. */
  19191. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  19192. /**
  19193. * Returns the distance (float) between the vectors "value1" and "value2".
  19194. * @param value1 value to calulate the distance between
  19195. * @param value2 value to calulate the distance between
  19196. * @return the distance between the two vectors
  19197. */
  19198. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  19199. /**
  19200. * Returns the squared distance (float) between the vectors "value1" and "value2".
  19201. * @param value1 value to calulate the distance between
  19202. * @param value2 value to calulate the distance between
  19203. * @return the distance between the two vectors squared
  19204. */
  19205. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  19206. /**
  19207. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  19208. * @param value1 value to calulate the center between
  19209. * @param value2 value to calulate the center between
  19210. * @return the center between the two vectors
  19211. */
  19212. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  19213. /**
  19214. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  19215. * This methods computes transformed normalized direction vectors only.
  19216. * @param vector the vector to transform
  19217. * @param transformation the transformation matrix to apply
  19218. * @returns the new vector
  19219. */
  19220. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  19221. /**
  19222. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  19223. * This methods computes transformed normalized direction vectors only.
  19224. * @param vector the vector to transform
  19225. * @param transformation the transformation matrix to apply
  19226. * @param result the vector to store the result in
  19227. */
  19228. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19229. /**
  19230. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  19231. * This methods computes transformed normalized direction vectors only.
  19232. * @param x value to transform
  19233. * @param y value to transform
  19234. * @param z value to transform
  19235. * @param w value to transform
  19236. * @param transformation the transformation matrix to apply
  19237. * @param result the vector to store the results in
  19238. */
  19239. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19240. /**
  19241. * Creates a new Vector4 from a Vector3
  19242. * @param source defines the source data
  19243. * @param w defines the 4th component (default is 0)
  19244. * @returns a new Vector4
  19245. */
  19246. static FromVector3(source: Vector3, w?: number): Vector4;
  19247. }
  19248. /**
  19249. * Interface for the size containing width and height
  19250. */
  19251. interface ISize {
  19252. /**
  19253. * Width
  19254. */
  19255. width: number;
  19256. /**
  19257. * Heighht
  19258. */
  19259. height: number;
  19260. }
  19261. /**
  19262. * Size containing widht and height
  19263. */
  19264. class Size implements ISize {
  19265. /**
  19266. * Width
  19267. */
  19268. width: number;
  19269. /**
  19270. * Height
  19271. */
  19272. height: number;
  19273. /**
  19274. * Creates a Size object from the given width and height (floats).
  19275. * @param width width of the new size
  19276. * @param height height of the new size
  19277. */
  19278. constructor(width: number, height: number);
  19279. /**
  19280. * Returns a string with the Size width and height
  19281. * @returns a string with the Size width and height
  19282. */
  19283. toString(): string;
  19284. /**
  19285. * "Size"
  19286. * @returns the string "Size"
  19287. */
  19288. getClassName(): string;
  19289. /**
  19290. * Returns the Size hash code.
  19291. * @returns a hash code for a unique width and height
  19292. */
  19293. getHashCode(): number;
  19294. /**
  19295. * Updates the current size from the given one.
  19296. * @param src the given size
  19297. */
  19298. copyFrom(src: Size): void;
  19299. /**
  19300. * Updates in place the current Size from the given floats.
  19301. * @param width width of the new size
  19302. * @param height height of the new size
  19303. * @returns the updated Size.
  19304. */
  19305. copyFromFloats(width: number, height: number): Size;
  19306. /**
  19307. * Updates in place the current Size from the given floats.
  19308. * @param width width to set
  19309. * @param height height to set
  19310. * @returns the updated Size.
  19311. */
  19312. set(width: number, height: number): Size;
  19313. /**
  19314. * Multiplies the width and height by numbers
  19315. * @param w factor to multiple the width by
  19316. * @param h factor to multiple the height by
  19317. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  19318. */
  19319. multiplyByFloats(w: number, h: number): Size;
  19320. /**
  19321. * Clones the size
  19322. * @returns a new Size copied from the given one.
  19323. */
  19324. clone(): Size;
  19325. /**
  19326. * True if the current Size and the given one width and height are strictly equal.
  19327. * @param other the other size to compare against
  19328. * @returns True if the current Size and the given one width and height are strictly equal.
  19329. */
  19330. equals(other: Size): boolean;
  19331. /**
  19332. * The surface of the Size : width * height (float).
  19333. */
  19334. readonly surface: number;
  19335. /**
  19336. * Create a new size of zero
  19337. * @returns a new Size set to (0.0, 0.0)
  19338. */
  19339. static Zero(): Size;
  19340. /**
  19341. * Sums the width and height of two sizes
  19342. * @param otherSize size to add to this size
  19343. * @returns a new Size set as the addition result of the current Size and the given one.
  19344. */
  19345. add(otherSize: Size): Size;
  19346. /**
  19347. * Subtracts the width and height of two
  19348. * @param otherSize size to subtract to this size
  19349. * @returns a new Size set as the subtraction result of the given one from the current Size.
  19350. */
  19351. subtract(otherSize: Size): Size;
  19352. /**
  19353. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  19354. * @param start starting size to lerp between
  19355. * @param end end size to lerp between
  19356. * @param amount amount to lerp between the start and end values
  19357. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  19358. */
  19359. static Lerp(start: Size, end: Size, amount: number): Size;
  19360. }
  19361. /**
  19362. * Class used to store quaternion data
  19363. * @see https://en.wikipedia.org/wiki/Quaternion
  19364. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  19365. */
  19366. class Quaternion {
  19367. /** defines the first component (0 by default) */
  19368. x: number;
  19369. /** defines the second component (0 by default) */
  19370. y: number;
  19371. /** defines the third component (0 by default) */
  19372. z: number;
  19373. /** defines the fourth component (1.0 by default) */
  19374. w: number;
  19375. /**
  19376. * Creates a new Quaternion from the given floats
  19377. * @param x defines the first component (0 by default)
  19378. * @param y defines the second component (0 by default)
  19379. * @param z defines the third component (0 by default)
  19380. * @param w defines the fourth component (1.0 by default)
  19381. */
  19382. constructor(
  19383. /** defines the first component (0 by default) */
  19384. x?: number,
  19385. /** defines the second component (0 by default) */
  19386. y?: number,
  19387. /** defines the third component (0 by default) */
  19388. z?: number,
  19389. /** defines the fourth component (1.0 by default) */
  19390. w?: number);
  19391. /**
  19392. * Gets a string representation for the current quaternion
  19393. * @returns a string with the Quaternion coordinates
  19394. */
  19395. toString(): string;
  19396. /**
  19397. * Gets the class name of the quaternion
  19398. * @returns the string "Quaternion"
  19399. */
  19400. getClassName(): string;
  19401. /**
  19402. * Gets a hash code for this quaternion
  19403. * @returns the quaternion hash code
  19404. */
  19405. getHashCode(): number;
  19406. /**
  19407. * Copy the quaternion to an array
  19408. * @returns a new array populated with 4 elements from the quaternion coordinates
  19409. */
  19410. asArray(): number[];
  19411. /**
  19412. * Check if two quaternions are equals
  19413. * @param otherQuaternion defines the second operand
  19414. * @return true if the current quaternion and the given one coordinates are strictly equals
  19415. */
  19416. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  19417. /**
  19418. * Clone the current quaternion
  19419. * @returns a new quaternion copied from the current one
  19420. */
  19421. clone(): Quaternion;
  19422. /**
  19423. * Copy a quaternion to the current one
  19424. * @param other defines the other quaternion
  19425. * @returns the updated current quaternion
  19426. */
  19427. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  19428. /**
  19429. * Updates the current quaternion with the given float coordinates
  19430. * @param x defines the x coordinate
  19431. * @param y defines the y coordinate
  19432. * @param z defines the z coordinate
  19433. * @param w defines the w coordinate
  19434. * @returns the updated current quaternion
  19435. */
  19436. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  19437. /**
  19438. * Updates the current quaternion from the given float coordinates
  19439. * @param x defines the x coordinate
  19440. * @param y defines the y coordinate
  19441. * @param z defines the z coordinate
  19442. * @param w defines the w coordinate
  19443. * @returns the updated current quaternion
  19444. */
  19445. set(x: number, y: number, z: number, w: number): Quaternion;
  19446. /**
  19447. * Adds two quaternions
  19448. * @param other defines the second operand
  19449. * @returns a new quaternion as the addition result of the given one and the current quaternion
  19450. */
  19451. add(other: DeepImmutable<Quaternion>): Quaternion;
  19452. /**
  19453. * Add a quaternion to the current one
  19454. * @param other defines the quaternion to add
  19455. * @returns the current quaternion
  19456. */
  19457. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  19458. /**
  19459. * Subtract two quaternions
  19460. * @param other defines the second operand
  19461. * @returns a new quaternion as the subtraction result of the given one from the current one
  19462. */
  19463. subtract(other: Quaternion): Quaternion;
  19464. /**
  19465. * Multiplies the current quaternion by a scale factor
  19466. * @param value defines the scale factor
  19467. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  19468. */
  19469. scale(value: number): Quaternion;
  19470. /**
  19471. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  19472. * @param scale defines the scale factor
  19473. * @param result defines the Quaternion object where to store the result
  19474. * @returns the unmodified current quaternion
  19475. */
  19476. scaleToRef(scale: number, result: Quaternion): Quaternion;
  19477. /**
  19478. * Multiplies in place the current quaternion by a scale factor
  19479. * @param value defines the scale factor
  19480. * @returns the current modified quaternion
  19481. */
  19482. scaleInPlace(value: number): Quaternion;
  19483. /**
  19484. * Scale the current quaternion values by a factor and add the result to a given quaternion
  19485. * @param scale defines the scale factor
  19486. * @param result defines the Quaternion object where to store the result
  19487. * @returns the unmodified current quaternion
  19488. */
  19489. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  19490. /**
  19491. * Multiplies two quaternions
  19492. * @param q1 defines the second operand
  19493. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  19494. */
  19495. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  19496. /**
  19497. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  19498. * @param q1 defines the second operand
  19499. * @param result defines the target quaternion
  19500. * @returns the current quaternion
  19501. */
  19502. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  19503. /**
  19504. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  19505. * @param q1 defines the second operand
  19506. * @returns the currentupdated quaternion
  19507. */
  19508. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  19509. /**
  19510. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  19511. * @param ref defines the target quaternion
  19512. * @returns the current quaternion
  19513. */
  19514. conjugateToRef(ref: Quaternion): Quaternion;
  19515. /**
  19516. * Conjugates in place (1-q) the current quaternion
  19517. * @returns the current updated quaternion
  19518. */
  19519. conjugateInPlace(): Quaternion;
  19520. /**
  19521. * Conjugates in place (1-q) the current quaternion
  19522. * @returns a new quaternion
  19523. */
  19524. conjugate(): Quaternion;
  19525. /**
  19526. * Gets length of current quaternion
  19527. * @returns the quaternion length (float)
  19528. */
  19529. length(): number;
  19530. /**
  19531. * Normalize in place the current quaternion
  19532. * @returns the current updated quaternion
  19533. */
  19534. normalize(): Quaternion;
  19535. /**
  19536. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  19537. * @param order is a reserved parameter and is ignore for now
  19538. * @returns a new Vector3 containing the Euler angles
  19539. */
  19540. toEulerAngles(order?: string): Vector3;
  19541. /**
  19542. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  19543. * @param result defines the vector which will be filled with the Euler angles
  19544. * @param order is a reserved parameter and is ignore for now
  19545. * @returns the current unchanged quaternion
  19546. */
  19547. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  19548. /**
  19549. * Updates the given rotation matrix with the current quaternion values
  19550. * @param result defines the target matrix
  19551. * @returns the current unchanged quaternion
  19552. */
  19553. toRotationMatrix(result: Matrix): Quaternion;
  19554. /**
  19555. * Updates the current quaternion from the given rotation matrix values
  19556. * @param matrix defines the source matrix
  19557. * @returns the current updated quaternion
  19558. */
  19559. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19560. /**
  19561. * Creates a new quaternion from a rotation matrix
  19562. * @param matrix defines the source matrix
  19563. * @returns a new quaternion created from the given rotation matrix values
  19564. */
  19565. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19566. /**
  19567. * Updates the given quaternion with the given rotation matrix values
  19568. * @param matrix defines the source matrix
  19569. * @param result defines the target quaternion
  19570. */
  19571. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  19572. /**
  19573. * Returns the dot product (float) between the quaternions "left" and "right"
  19574. * @param left defines the left operand
  19575. * @param right defines the right operand
  19576. * @returns the dot product
  19577. */
  19578. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  19579. /**
  19580. * Checks if the two quaternions are close to each other
  19581. * @param quat0 defines the first quaternion to check
  19582. * @param quat1 defines the second quaternion to check
  19583. * @returns true if the two quaternions are close to each other
  19584. */
  19585. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  19586. /**
  19587. * Creates an empty quaternion
  19588. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  19589. */
  19590. static Zero(): Quaternion;
  19591. /**
  19592. * Inverse a given quaternion
  19593. * @param q defines the source quaternion
  19594. * @returns a new quaternion as the inverted current quaternion
  19595. */
  19596. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  19597. /**
  19598. * Inverse a given quaternion
  19599. * @param q defines the source quaternion
  19600. * @param result the quaternion the result will be stored in
  19601. * @returns the result quaternion
  19602. */
  19603. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  19604. /**
  19605. * Creates an identity quaternion
  19606. * @returns the identity quaternion
  19607. */
  19608. static Identity(): Quaternion;
  19609. /**
  19610. * Gets a boolean indicating if the given quaternion is identity
  19611. * @param quaternion defines the quaternion to check
  19612. * @returns true if the quaternion is identity
  19613. */
  19614. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  19615. /**
  19616. * Creates a quaternion from a rotation around an axis
  19617. * @param axis defines the axis to use
  19618. * @param angle defines the angle to use
  19619. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  19620. */
  19621. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  19622. /**
  19623. * Creates a rotation around an axis and stores it into the given quaternion
  19624. * @param axis defines the axis to use
  19625. * @param angle defines the angle to use
  19626. * @param result defines the target quaternion
  19627. * @returns the target quaternion
  19628. */
  19629. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  19630. /**
  19631. * Creates a new quaternion from data stored into an array
  19632. * @param array defines the data source
  19633. * @param offset defines the offset in the source array where the data starts
  19634. * @returns a new quaternion
  19635. */
  19636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  19637. /**
  19638. * Create a quaternion from Euler rotation angles
  19639. * @param x Pitch
  19640. * @param y Yaw
  19641. * @param z Roll
  19642. * @returns the new Quaternion
  19643. */
  19644. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  19645. /**
  19646. * Updates a quaternion from Euler rotation angles
  19647. * @param x Pitch
  19648. * @param y Yaw
  19649. * @param z Roll
  19650. * @param result the quaternion to store the result
  19651. * @returns the updated quaternion
  19652. */
  19653. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  19654. /**
  19655. * Create a quaternion from Euler rotation vector
  19656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19657. * @returns the new Quaternion
  19658. */
  19659. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  19660. /**
  19661. * Updates a quaternion from Euler rotation vector
  19662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19663. * @param result the quaternion to store the result
  19664. * @returns the updated quaternion
  19665. */
  19666. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  19667. /**
  19668. * Creates a new quaternion from the given Euler float angles (y, x, z)
  19669. * @param yaw defines the rotation around Y axis
  19670. * @param pitch defines the rotation around X axis
  19671. * @param roll defines the rotation around Z axis
  19672. * @returns the new quaternion
  19673. */
  19674. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  19675. /**
  19676. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  19677. * @param yaw defines the rotation around Y axis
  19678. * @param pitch defines the rotation around X axis
  19679. * @param roll defines the rotation around Z axis
  19680. * @param result defines the target quaternion
  19681. */
  19682. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  19683. /**
  19684. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  19685. * @param alpha defines the rotation around first axis
  19686. * @param beta defines the rotation around second axis
  19687. * @param gamma defines the rotation around third axis
  19688. * @returns the new quaternion
  19689. */
  19690. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  19691. /**
  19692. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  19693. * @param alpha defines the rotation around first axis
  19694. * @param beta defines the rotation around second axis
  19695. * @param gamma defines the rotation around third axis
  19696. * @param result defines the target quaternion
  19697. */
  19698. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  19699. /**
  19700. * 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)
  19701. * @param axis1 defines the first axis
  19702. * @param axis2 defines the second axis
  19703. * @param axis3 defines the third axis
  19704. * @returns the new quaternion
  19705. */
  19706. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  19707. /**
  19708. * 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
  19709. * @param axis1 defines the first axis
  19710. * @param axis2 defines the second axis
  19711. * @param axis3 defines the third axis
  19712. * @param ref defines the target quaternion
  19713. */
  19714. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  19715. /**
  19716. * Interpolates between two quaternions
  19717. * @param left defines first quaternion
  19718. * @param right defines second quaternion
  19719. * @param amount defines the gradient to use
  19720. * @returns the new interpolated quaternion
  19721. */
  19722. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19723. /**
  19724. * Interpolates between two quaternions and stores it into a target quaternion
  19725. * @param left defines first quaternion
  19726. * @param right defines second quaternion
  19727. * @param amount defines the gradient to use
  19728. * @param result defines the target quaternion
  19729. */
  19730. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  19731. /**
  19732. * Interpolate between two quaternions using Hermite interpolation
  19733. * @param value1 defines first quaternion
  19734. * @param tangent1 defines the incoming tangent
  19735. * @param value2 defines second quaternion
  19736. * @param tangent2 defines the outgoing tangent
  19737. * @param amount defines the target quaternion
  19738. * @returns the new interpolated quaternion
  19739. */
  19740. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19741. }
  19742. /**
  19743. * Class used to store matrix data (4x4)
  19744. */
  19745. class Matrix {
  19746. private static _updateFlagSeed;
  19747. private static _identityReadOnly;
  19748. private _isIdentity;
  19749. private _isIdentityDirty;
  19750. private _isIdentity3x2;
  19751. private _isIdentity3x2Dirty;
  19752. /**
  19753. * Gets the update flag of the matrix which is an unique number for the matrix.
  19754. * It will be incremented every time the matrix data change.
  19755. * You can use it to speed the comparison between two versions of the same matrix.
  19756. */
  19757. updateFlag: number;
  19758. private readonly _m;
  19759. /**
  19760. * Gets the internal data of the matrix
  19761. */
  19762. readonly m: DeepImmutable<Float32Array>;
  19763. /** @hidden */
  19764. _markAsUpdated(): void;
  19765. /** @hidden */
  19766. private _updateIdentityStatus;
  19767. /**
  19768. * Creates an empty matrix (filled with zeros)
  19769. */
  19770. constructor();
  19771. /**
  19772. * Check if the current matrix is identity
  19773. * @returns true is the matrix is the identity matrix
  19774. */
  19775. isIdentity(): boolean;
  19776. /**
  19777. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  19778. * @returns true is the matrix is the identity matrix
  19779. */
  19780. isIdentityAs3x2(): boolean;
  19781. /**
  19782. * Gets the determinant of the matrix
  19783. * @returns the matrix determinant
  19784. */
  19785. determinant(): number;
  19786. /**
  19787. * Returns the matrix as a Float32Array
  19788. * @returns the matrix underlying array
  19789. */
  19790. toArray(): DeepImmutable<Float32Array>;
  19791. /**
  19792. * Returns the matrix as a Float32Array
  19793. * @returns the matrix underlying array.
  19794. */
  19795. asArray(): DeepImmutable<Float32Array>;
  19796. /**
  19797. * Inverts the current matrix in place
  19798. * @returns the current inverted matrix
  19799. */
  19800. invert(): Matrix;
  19801. /**
  19802. * Sets all the matrix elements to zero
  19803. * @returns the current matrix
  19804. */
  19805. reset(): Matrix;
  19806. /**
  19807. * Adds the current matrix with a second one
  19808. * @param other defines the matrix to add
  19809. * @returns a new matrix as the addition of the current matrix and the given one
  19810. */
  19811. add(other: DeepImmutable<Matrix>): Matrix;
  19812. /**
  19813. * Sets the given matrix "result" to the addition of the current matrix and the given one
  19814. * @param other defines the matrix to add
  19815. * @param result defines the target matrix
  19816. * @returns the current matrix
  19817. */
  19818. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19819. /**
  19820. * Adds in place the given matrix to the current matrix
  19821. * @param other defines the second operand
  19822. * @returns the current updated matrix
  19823. */
  19824. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  19825. /**
  19826. * Sets the given matrix to the current inverted Matrix
  19827. * @param other defines the target matrix
  19828. * @returns the unmodified current matrix
  19829. */
  19830. invertToRef(other: Matrix): Matrix;
  19831. /**
  19832. * add a value at the specified position in the current Matrix
  19833. * @param index the index of the value within the matrix. between 0 and 15.
  19834. * @param value the value to be added
  19835. * @returns the current updated matrix
  19836. */
  19837. addAtIndex(index: number, value: number): Matrix;
  19838. /**
  19839. * mutiply the specified position in the current Matrix by a value
  19840. * @param index the index of the value within the matrix. between 0 and 15.
  19841. * @param value the value to be added
  19842. * @returns the current updated matrix
  19843. */
  19844. multiplyAtIndex(index: number, value: number): Matrix;
  19845. /**
  19846. * Inserts the translation vector (using 3 floats) in the current matrix
  19847. * @param x defines the 1st component of the translation
  19848. * @param y defines the 2nd component of the translation
  19849. * @param z defines the 3rd component of the translation
  19850. * @returns the current updated matrix
  19851. */
  19852. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  19853. /**
  19854. * Inserts the translation vector in the current matrix
  19855. * @param vector3 defines the translation to insert
  19856. * @returns the current updated matrix
  19857. */
  19858. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  19859. /**
  19860. * Gets the translation value of the current matrix
  19861. * @returns a new Vector3 as the extracted translation from the matrix
  19862. */
  19863. getTranslation(): Vector3;
  19864. /**
  19865. * Fill a Vector3 with the extracted translation from the matrix
  19866. * @param result defines the Vector3 where to store the translation
  19867. * @returns the current matrix
  19868. */
  19869. getTranslationToRef(result: Vector3): Matrix;
  19870. /**
  19871. * Remove rotation and scaling part from the matrix
  19872. * @returns the updated matrix
  19873. */
  19874. removeRotationAndScaling(): Matrix;
  19875. /**
  19876. * Multiply two matrices
  19877. * @param other defines the second operand
  19878. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  19879. */
  19880. multiply(other: DeepImmutable<Matrix>): Matrix;
  19881. /**
  19882. * Copy the current matrix from the given one
  19883. * @param other defines the source matrix
  19884. * @returns the current updated matrix
  19885. */
  19886. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  19887. /**
  19888. * Populates the given array from the starting index with the current matrix values
  19889. * @param array defines the target array
  19890. * @param offset defines the offset in the target array where to start storing values
  19891. * @returns the current matrix
  19892. */
  19893. copyToArray(array: Float32Array, offset?: number): Matrix;
  19894. /**
  19895. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  19896. * @param other defines the second operand
  19897. * @param result defines the matrix where to store the multiplication
  19898. * @returns the current matrix
  19899. */
  19900. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19901. /**
  19902. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  19903. * @param other defines the second operand
  19904. * @param result defines the array where to store the multiplication
  19905. * @param offset defines the offset in the target array where to start storing values
  19906. * @returns the current matrix
  19907. */
  19908. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  19909. /**
  19910. * Check equality between this matrix and a second one
  19911. * @param value defines the second matrix to compare
  19912. * @returns true is the current matrix and the given one values are strictly equal
  19913. */
  19914. equals(value: DeepImmutable<Matrix>): boolean;
  19915. /**
  19916. * Clone the current matrix
  19917. * @returns a new matrix from the current matrix
  19918. */
  19919. clone(): Matrix;
  19920. /**
  19921. * Returns the name of the current matrix class
  19922. * @returns the string "Matrix"
  19923. */
  19924. getClassName(): string;
  19925. /**
  19926. * Gets the hash code of the current matrix
  19927. * @returns the hash code
  19928. */
  19929. getHashCode(): number;
  19930. /**
  19931. * Decomposes the current Matrix into a translation, rotation and scaling components
  19932. * @param scale defines the scale vector3 given as a reference to update
  19933. * @param rotation defines the rotation quaternion given as a reference to update
  19934. * @param translation defines the translation vector3 given as a reference to update
  19935. * @returns true if operation was successful
  19936. */
  19937. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  19938. /**
  19939. * Gets specific row of the matrix
  19940. * @param index defines the number of the row to get
  19941. * @returns the index-th row of the current matrix as a new Vector4
  19942. */
  19943. getRow(index: number): Nullable<Vector4>;
  19944. /**
  19945. * Sets the index-th row of the current matrix to the vector4 values
  19946. * @param index defines the number of the row to set
  19947. * @param row defines the target vector4
  19948. * @returns the updated current matrix
  19949. */
  19950. setRow(index: number, row: Vector4): Matrix;
  19951. /**
  19952. * Compute the transpose of the matrix
  19953. * @returns the new transposed matrix
  19954. */
  19955. transpose(): Matrix;
  19956. /**
  19957. * Compute the transpose of the matrix and store it in a given matrix
  19958. * @param result defines the target matrix
  19959. * @returns the current matrix
  19960. */
  19961. transposeToRef(result: Matrix): Matrix;
  19962. /**
  19963. * Sets the index-th row of the current matrix with the given 4 x float values
  19964. * @param index defines the row index
  19965. * @param x defines the x component to set
  19966. * @param y defines the y component to set
  19967. * @param z defines the z component to set
  19968. * @param w defines the w component to set
  19969. * @returns the updated current matrix
  19970. */
  19971. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  19972. /**
  19973. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  19974. * @param scale defines the scale factor
  19975. * @returns a new matrix
  19976. */
  19977. scale(scale: number): Matrix;
  19978. /**
  19979. * Scale the current matrix values by a factor to a given result matrix
  19980. * @param scale defines the scale factor
  19981. * @param result defines the matrix to store the result
  19982. * @returns the current matrix
  19983. */
  19984. scaleToRef(scale: number, result: Matrix): Matrix;
  19985. /**
  19986. * Scale the current matrix values by a factor and add the result to a given matrix
  19987. * @param scale defines the scale factor
  19988. * @param result defines the Matrix to store the result
  19989. * @returns the current matrix
  19990. */
  19991. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  19992. /**
  19993. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  19994. * @param ref matrix to store the result
  19995. */
  19996. toNormalMatrix(ref: Matrix): void;
  19997. /**
  19998. * Gets only rotation part of the current matrix
  19999. * @returns a new matrix sets to the extracted rotation matrix from the current one
  20000. */
  20001. getRotationMatrix(): Matrix;
  20002. /**
  20003. * Extracts the rotation matrix from the current one and sets it as the given "result"
  20004. * @param result defines the target matrix to store data to
  20005. * @returns the current matrix
  20006. */
  20007. getRotationMatrixToRef(result: Matrix): Matrix;
  20008. /**
  20009. * Toggles model matrix from being right handed to left handed in place and vice versa
  20010. */
  20011. toggleModelMatrixHandInPlace(): void;
  20012. /**
  20013. * Toggles projection matrix from being right handed to left handed in place and vice versa
  20014. */
  20015. toggleProjectionMatrixHandInPlace(): void;
  20016. /**
  20017. * Creates a matrix from an array
  20018. * @param array defines the source array
  20019. * @param offset defines an offset in the source array
  20020. * @returns a new Matrix set from the starting index of the given array
  20021. */
  20022. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  20023. /**
  20024. * Copy the content of an array into a given matrix
  20025. * @param array defines the source array
  20026. * @param offset defines an offset in the source array
  20027. * @param result defines the target matrix
  20028. */
  20029. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  20030. /**
  20031. * Stores an array into a matrix after having multiplied each component by a given factor
  20032. * @param array defines the source array
  20033. * @param offset defines the offset in the source array
  20034. * @param scale defines the scaling factor
  20035. * @param result defines the target matrix
  20036. */
  20037. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  20038. /**
  20039. * Gets an identity matrix that must not be updated
  20040. */
  20041. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  20042. /**
  20043. * Stores a list of values (16) inside a given matrix
  20044. * @param initialM11 defines 1st value of 1st row
  20045. * @param initialM12 defines 2nd value of 1st row
  20046. * @param initialM13 defines 3rd value of 1st row
  20047. * @param initialM14 defines 4th value of 1st row
  20048. * @param initialM21 defines 1st value of 2nd row
  20049. * @param initialM22 defines 2nd value of 2nd row
  20050. * @param initialM23 defines 3rd value of 2nd row
  20051. * @param initialM24 defines 4th value of 2nd row
  20052. * @param initialM31 defines 1st value of 3rd row
  20053. * @param initialM32 defines 2nd value of 3rd row
  20054. * @param initialM33 defines 3rd value of 3rd row
  20055. * @param initialM34 defines 4th value of 3rd row
  20056. * @param initialM41 defines 1st value of 4th row
  20057. * @param initialM42 defines 2nd value of 4th row
  20058. * @param initialM43 defines 3rd value of 4th row
  20059. * @param initialM44 defines 4th value of 4th row
  20060. * @param result defines the target matrix
  20061. */
  20062. 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;
  20063. /**
  20064. * Creates new matrix from a list of values (16)
  20065. * @param initialM11 defines 1st value of 1st row
  20066. * @param initialM12 defines 2nd value of 1st row
  20067. * @param initialM13 defines 3rd value of 1st row
  20068. * @param initialM14 defines 4th value of 1st row
  20069. * @param initialM21 defines 1st value of 2nd row
  20070. * @param initialM22 defines 2nd value of 2nd row
  20071. * @param initialM23 defines 3rd value of 2nd row
  20072. * @param initialM24 defines 4th value of 2nd row
  20073. * @param initialM31 defines 1st value of 3rd row
  20074. * @param initialM32 defines 2nd value of 3rd row
  20075. * @param initialM33 defines 3rd value of 3rd row
  20076. * @param initialM34 defines 4th value of 3rd row
  20077. * @param initialM41 defines 1st value of 4th row
  20078. * @param initialM42 defines 2nd value of 4th row
  20079. * @param initialM43 defines 3rd value of 4th row
  20080. * @param initialM44 defines 4th value of 4th row
  20081. * @returns the new matrix
  20082. */
  20083. 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;
  20084. /**
  20085. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  20086. * @param scale defines the scale vector3
  20087. * @param rotation defines the rotation quaternion
  20088. * @param translation defines the translation vector3
  20089. * @returns a new matrix
  20090. */
  20091. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  20092. /**
  20093. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  20094. * @param scale defines the scale vector3
  20095. * @param rotation defines the rotation quaternion
  20096. * @param translation defines the translation vector3
  20097. * @param result defines the target matrix
  20098. */
  20099. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  20100. /**
  20101. * Creates a new identity matrix
  20102. * @returns a new identity matrix
  20103. */
  20104. static Identity(): Matrix;
  20105. /**
  20106. * Creates a new identity matrix and stores the result in a given matrix
  20107. * @param result defines the target matrix
  20108. */
  20109. static IdentityToRef(result: Matrix): void;
  20110. /**
  20111. * Creates a new zero matrix
  20112. * @returns a new zero matrix
  20113. */
  20114. static Zero(): Matrix;
  20115. /**
  20116. * Creates a new rotation matrix for "angle" radians around the X axis
  20117. * @param angle defines the angle (in radians) to use
  20118. * @return the new matrix
  20119. */
  20120. static RotationX(angle: number): Matrix;
  20121. /**
  20122. * Creates a new matrix as the invert of a given matrix
  20123. * @param source defines the source matrix
  20124. * @returns the new matrix
  20125. */
  20126. static Invert(source: DeepImmutable<Matrix>): Matrix;
  20127. /**
  20128. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  20129. * @param angle defines the angle (in radians) to use
  20130. * @param result defines the target matrix
  20131. */
  20132. static RotationXToRef(angle: number, result: Matrix): void;
  20133. /**
  20134. * Creates a new rotation matrix for "angle" radians around the Y axis
  20135. * @param angle defines the angle (in radians) to use
  20136. * @return the new matrix
  20137. */
  20138. static RotationY(angle: number): Matrix;
  20139. /**
  20140. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  20141. * @param angle defines the angle (in radians) to use
  20142. * @param result defines the target matrix
  20143. */
  20144. static RotationYToRef(angle: number, result: Matrix): void;
  20145. /**
  20146. * Creates a new rotation matrix for "angle" radians around the Z axis
  20147. * @param angle defines the angle (in radians) to use
  20148. * @return the new matrix
  20149. */
  20150. static RotationZ(angle: number): Matrix;
  20151. /**
  20152. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  20153. * @param angle defines the angle (in radians) to use
  20154. * @param result defines the target matrix
  20155. */
  20156. static RotationZToRef(angle: number, result: Matrix): void;
  20157. /**
  20158. * Creates a new rotation matrix for "angle" radians around the given axis
  20159. * @param axis defines the axis to use
  20160. * @param angle defines the angle (in radians) to use
  20161. * @return the new matrix
  20162. */
  20163. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  20164. /**
  20165. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  20166. * @param axis defines the axis to use
  20167. * @param angle defines the angle (in radians) to use
  20168. * @param result defines the target matrix
  20169. */
  20170. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  20171. /**
  20172. * Creates a rotation matrix
  20173. * @param yaw defines the yaw angle in radians (Y axis)
  20174. * @param pitch defines the pitch angle in radians (X axis)
  20175. * @param roll defines the roll angle in radians (X axis)
  20176. * @returns the new rotation matrix
  20177. */
  20178. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  20179. /**
  20180. * Creates a rotation matrix and stores it in a given matrix
  20181. * @param yaw defines the yaw angle in radians (Y axis)
  20182. * @param pitch defines the pitch angle in radians (X axis)
  20183. * @param roll defines the roll angle in radians (X axis)
  20184. * @param result defines the target matrix
  20185. */
  20186. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  20187. /**
  20188. * Creates a scaling matrix
  20189. * @param x defines the scale factor on X axis
  20190. * @param y defines the scale factor on Y axis
  20191. * @param z defines the scale factor on Z axis
  20192. * @returns the new matrix
  20193. */
  20194. static Scaling(x: number, y: number, z: number): Matrix;
  20195. /**
  20196. * Creates a scaling matrix and stores it in a given matrix
  20197. * @param x defines the scale factor on X axis
  20198. * @param y defines the scale factor on Y axis
  20199. * @param z defines the scale factor on Z axis
  20200. * @param result defines the target matrix
  20201. */
  20202. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  20203. /**
  20204. * Creates a translation matrix
  20205. * @param x defines the translation on X axis
  20206. * @param y defines the translation on Y axis
  20207. * @param z defines the translationon Z axis
  20208. * @returns the new matrix
  20209. */
  20210. static Translation(x: number, y: number, z: number): Matrix;
  20211. /**
  20212. * Creates a translation matrix and stores it in a given matrix
  20213. * @param x defines the translation on X axis
  20214. * @param y defines the translation on Y axis
  20215. * @param z defines the translationon Z axis
  20216. * @param result defines the target matrix
  20217. */
  20218. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  20219. /**
  20220. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  20221. * @param startValue defines the start value
  20222. * @param endValue defines the end value
  20223. * @param gradient defines the gradient factor
  20224. * @returns the new matrix
  20225. */
  20226. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20227. /**
  20228. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  20229. * @param startValue defines the start value
  20230. * @param endValue defines the end value
  20231. * @param gradient defines the gradient factor
  20232. * @param result defines the Matrix object where to store data
  20233. */
  20234. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20235. /**
  20236. * Builds a new matrix whose values are computed by:
  20237. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20238. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20239. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20240. * @param startValue defines the first matrix
  20241. * @param endValue defines the second matrix
  20242. * @param gradient defines the gradient between the two matrices
  20243. * @returns the new matrix
  20244. */
  20245. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20246. /**
  20247. * Update a matrix to values which are computed by:
  20248. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20249. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20250. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20251. * @param startValue defines the first matrix
  20252. * @param endValue defines the second matrix
  20253. * @param gradient defines the gradient between the two matrices
  20254. * @param result defines the target matrix
  20255. */
  20256. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20257. /**
  20258. * 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"
  20259. * This function works in left handed mode
  20260. * @param eye defines the final position of the entity
  20261. * @param target defines where the entity should look at
  20262. * @param up defines the up vector for the entity
  20263. * @returns the new matrix
  20264. */
  20265. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20266. /**
  20267. * 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".
  20268. * This function works in left handed mode
  20269. * @param eye defines the final position of the entity
  20270. * @param target defines where the entity should look at
  20271. * @param up defines the up vector for the entity
  20272. * @param result defines the target matrix
  20273. */
  20274. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20275. /**
  20276. * 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"
  20277. * This function works in right handed mode
  20278. * @param eye defines the final position of the entity
  20279. * @param target defines where the entity should look at
  20280. * @param up defines the up vector for the entity
  20281. * @returns the new matrix
  20282. */
  20283. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20284. /**
  20285. * 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".
  20286. * This function works in right handed mode
  20287. * @param eye defines the final position of the entity
  20288. * @param target defines where the entity should look at
  20289. * @param up defines the up vector for the entity
  20290. * @param result defines the target matrix
  20291. */
  20292. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20293. /**
  20294. * Create a left-handed orthographic projection matrix
  20295. * @param width defines the viewport width
  20296. * @param height defines the viewport height
  20297. * @param znear defines the near clip plane
  20298. * @param zfar defines the far clip plane
  20299. * @returns a new matrix as a left-handed orthographic projection matrix
  20300. */
  20301. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20302. /**
  20303. * Store a left-handed orthographic projection to a given matrix
  20304. * @param width defines the viewport width
  20305. * @param height defines the viewport height
  20306. * @param znear defines the near clip plane
  20307. * @param zfar defines the far clip plane
  20308. * @param result defines the target matrix
  20309. */
  20310. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  20311. /**
  20312. * Create a left-handed orthographic projection matrix
  20313. * @param left defines the viewport left coordinate
  20314. * @param right defines the viewport right coordinate
  20315. * @param bottom defines the viewport bottom coordinate
  20316. * @param top defines the viewport top coordinate
  20317. * @param znear defines the near clip plane
  20318. * @param zfar defines the far clip plane
  20319. * @returns a new matrix as a left-handed orthographic projection matrix
  20320. */
  20321. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20322. /**
  20323. * Stores a left-handed orthographic projection into a given matrix
  20324. * @param left defines the viewport left coordinate
  20325. * @param right defines the viewport right coordinate
  20326. * @param bottom defines the viewport bottom coordinate
  20327. * @param top defines the viewport top coordinate
  20328. * @param znear defines the near clip plane
  20329. * @param zfar defines the far clip plane
  20330. * @param result defines the target matrix
  20331. */
  20332. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20333. /**
  20334. * Creates a right-handed orthographic projection matrix
  20335. * @param left defines the viewport left coordinate
  20336. * @param right defines the viewport right coordinate
  20337. * @param bottom defines the viewport bottom coordinate
  20338. * @param top defines the viewport top coordinate
  20339. * @param znear defines the near clip plane
  20340. * @param zfar defines the far clip plane
  20341. * @returns a new matrix as a right-handed orthographic projection matrix
  20342. */
  20343. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20344. /**
  20345. * Stores a right-handed orthographic projection into a given matrix
  20346. * @param left defines the viewport left coordinate
  20347. * @param right defines the viewport right coordinate
  20348. * @param bottom defines the viewport bottom coordinate
  20349. * @param top defines the viewport top coordinate
  20350. * @param znear defines the near clip plane
  20351. * @param zfar defines the far clip plane
  20352. * @param result defines the target matrix
  20353. */
  20354. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20355. /**
  20356. * Creates a left-handed perspective projection matrix
  20357. * @param width defines the viewport width
  20358. * @param height defines the viewport height
  20359. * @param znear defines the near clip plane
  20360. * @param zfar defines the far clip plane
  20361. * @returns a new matrix as a left-handed perspective projection matrix
  20362. */
  20363. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20364. /**
  20365. * Creates a left-handed perspective projection matrix
  20366. * @param fov defines the horizontal field of view
  20367. * @param aspect defines the aspect ratio
  20368. * @param znear defines the near clip plane
  20369. * @param zfar defines the far clip plane
  20370. * @returns a new matrix as a left-handed perspective projection matrix
  20371. */
  20372. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20373. /**
  20374. * Stores a left-handed perspective projection into a given matrix
  20375. * @param fov defines the horizontal field of view
  20376. * @param aspect defines the aspect ratio
  20377. * @param znear defines the near clip plane
  20378. * @param zfar defines the far clip plane
  20379. * @param result defines the target matrix
  20380. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20381. */
  20382. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20383. /**
  20384. * Creates a right-handed perspective projection matrix
  20385. * @param fov defines the horizontal field of view
  20386. * @param aspect defines the aspect ratio
  20387. * @param znear defines the near clip plane
  20388. * @param zfar defines the far clip plane
  20389. * @returns a new matrix as a right-handed perspective projection matrix
  20390. */
  20391. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20392. /**
  20393. * Stores a right-handed perspective projection into a given matrix
  20394. * @param fov defines the horizontal field of view
  20395. * @param aspect defines the aspect ratio
  20396. * @param znear defines the near clip plane
  20397. * @param zfar defines the far clip plane
  20398. * @param result defines the target matrix
  20399. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20400. */
  20401. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20402. /**
  20403. * Stores a perspective projection for WebVR info a given matrix
  20404. * @param fov defines the field of view
  20405. * @param znear defines the near clip plane
  20406. * @param zfar defines the far clip plane
  20407. * @param result defines the target matrix
  20408. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  20409. */
  20410. static PerspectiveFovWebVRToRef(fov: {
  20411. upDegrees: number;
  20412. downDegrees: number;
  20413. leftDegrees: number;
  20414. rightDegrees: number;
  20415. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  20416. /**
  20417. * Computes a complete transformation matrix
  20418. * @param viewport defines the viewport to use
  20419. * @param world defines the world matrix
  20420. * @param view defines the view matrix
  20421. * @param projection defines the projection matrix
  20422. * @param zmin defines the near clip plane
  20423. * @param zmax defines the far clip plane
  20424. * @returns the transformation matrix
  20425. */
  20426. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  20427. /**
  20428. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  20429. * @param matrix defines the matrix to use
  20430. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  20431. */
  20432. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  20433. /**
  20434. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  20435. * @param matrix defines the matrix to use
  20436. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  20437. */
  20438. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  20439. /**
  20440. * Compute the transpose of a given matrix
  20441. * @param matrix defines the matrix to transpose
  20442. * @returns the new matrix
  20443. */
  20444. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  20445. /**
  20446. * Compute the transpose of a matrix and store it in a target matrix
  20447. * @param matrix defines the matrix to transpose
  20448. * @param result defines the target matrix
  20449. */
  20450. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  20451. /**
  20452. * Computes a reflection matrix from a plane
  20453. * @param plane defines the reflection plane
  20454. * @returns a new matrix
  20455. */
  20456. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  20457. /**
  20458. * Computes a reflection matrix from a plane
  20459. * @param plane defines the reflection plane
  20460. * @param result defines the target matrix
  20461. */
  20462. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  20463. /**
  20464. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  20465. * @param xaxis defines the value of the 1st axis
  20466. * @param yaxis defines the value of the 2nd axis
  20467. * @param zaxis defines the value of the 3rd axis
  20468. * @param result defines the target matrix
  20469. */
  20470. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  20471. /**
  20472. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  20473. * @param quat defines the quaternion to use
  20474. * @param result defines the target matrix
  20475. */
  20476. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  20477. }
  20478. /**
  20479. * Represens a plane by the equation ax + by + cz + d = 0
  20480. */
  20481. class Plane {
  20482. /**
  20483. * Normal of the plane (a,b,c)
  20484. */
  20485. normal: Vector3;
  20486. /**
  20487. * d component of the plane
  20488. */
  20489. d: number;
  20490. /**
  20491. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  20492. * @param a a component of the plane
  20493. * @param b b component of the plane
  20494. * @param c c component of the plane
  20495. * @param d d component of the plane
  20496. */
  20497. constructor(a: number, b: number, c: number, d: number);
  20498. /**
  20499. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  20500. */
  20501. asArray(): number[];
  20502. /**
  20503. * @returns a new plane copied from the current Plane.
  20504. */
  20505. clone(): Plane;
  20506. /**
  20507. * @returns the string "Plane".
  20508. */
  20509. getClassName(): string;
  20510. /**
  20511. * @returns the Plane hash code.
  20512. */
  20513. getHashCode(): number;
  20514. /**
  20515. * Normalize the current Plane in place.
  20516. * @returns the updated Plane.
  20517. */
  20518. normalize(): Plane;
  20519. /**
  20520. * Applies a transformation the plane and returns the result
  20521. * @param transformation the transformation matrix to be applied to the plane
  20522. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  20523. */
  20524. transform(transformation: DeepImmutable<Matrix>): Plane;
  20525. /**
  20526. * Calcualtte the dot product between the point and the plane normal
  20527. * @param point point to calculate the dot product with
  20528. * @returns the dot product (float) of the point coordinates and the plane normal.
  20529. */
  20530. dotCoordinate(point: DeepImmutable<Vector3>): number;
  20531. /**
  20532. * Updates the current Plane from the plane defined by the three given points.
  20533. * @param point1 one of the points used to contruct the plane
  20534. * @param point2 one of the points used to contruct the plane
  20535. * @param point3 one of the points used to contruct the plane
  20536. * @returns the updated Plane.
  20537. */
  20538. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20539. /**
  20540. * Checks if the plane is facing a given direction
  20541. * @param direction the direction to check if the plane is facing
  20542. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  20543. * @returns True is the vector "direction" is the same side than the plane normal.
  20544. */
  20545. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  20546. /**
  20547. * Calculates the distance to a point
  20548. * @param point point to calculate distance to
  20549. * @returns the signed distance (float) from the given point to the Plane.
  20550. */
  20551. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  20552. /**
  20553. * Creates a plane from an array
  20554. * @param array the array to create a plane from
  20555. * @returns a new Plane from the given array.
  20556. */
  20557. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  20558. /**
  20559. * Creates a plane from three points
  20560. * @param point1 point used to create the plane
  20561. * @param point2 point used to create the plane
  20562. * @param point3 point used to create the plane
  20563. * @returns a new Plane defined by the three given points.
  20564. */
  20565. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20566. /**
  20567. * Creates a plane from an origin point and a normal
  20568. * @param origin origin of the plane to be constructed
  20569. * @param normal normal of the plane to be constructed
  20570. * @returns a new Plane the normal vector to this plane at the given origin point.
  20571. * Note : the vector "normal" is updated because normalized.
  20572. */
  20573. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  20574. /**
  20575. * Calculates the distance from a plane and a point
  20576. * @param origin origin of the plane to be constructed
  20577. * @param normal normal of the plane to be constructed
  20578. * @param point point to calculate distance to
  20579. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  20580. */
  20581. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  20582. }
  20583. /**
  20584. * Class used to represent a viewport on screen
  20585. */
  20586. class Viewport {
  20587. /** viewport left coordinate */
  20588. x: number;
  20589. /** viewport top coordinate */
  20590. y: number;
  20591. /**viewport width */
  20592. width: number;
  20593. /** viewport height */
  20594. height: number;
  20595. /**
  20596. * Creates a Viewport object located at (x, y) and sized (width, height)
  20597. * @param x defines viewport left coordinate
  20598. * @param y defines viewport top coordinate
  20599. * @param width defines the viewport width
  20600. * @param height defines the viewport height
  20601. */
  20602. constructor(
  20603. /** viewport left coordinate */
  20604. x: number,
  20605. /** viewport top coordinate */
  20606. y: number,
  20607. /**viewport width */
  20608. width: number,
  20609. /** viewport height */
  20610. height: number);
  20611. /**
  20612. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  20613. * @param renderWidthOrEngine defines either an engine or the rendering width
  20614. * @param renderHeight defines the rendering height
  20615. * @returns a new Viewport
  20616. */
  20617. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  20618. /**
  20619. * Returns a new Viewport copied from the current one
  20620. * @returns a new Viewport
  20621. */
  20622. clone(): Viewport;
  20623. }
  20624. /**
  20625. * Reprasents a camera frustum
  20626. */
  20627. class Frustum {
  20628. /**
  20629. * Gets the planes representing the frustum
  20630. * @param transform matrix to be applied to the returned planes
  20631. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  20632. */
  20633. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  20634. /**
  20635. * Gets the near frustum plane transformed by the transform matrix
  20636. * @param transform transformation matrix to be applied to the resulting frustum plane
  20637. * @param frustumPlane the resuling frustum plane
  20638. */
  20639. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20640. /**
  20641. * Gets the far frustum plane transformed by the transform matrix
  20642. * @param transform transformation matrix to be applied to the resulting frustum plane
  20643. * @param frustumPlane the resuling frustum plane
  20644. */
  20645. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20646. /**
  20647. * Gets the left frustum plane transformed by the transform matrix
  20648. * @param transform transformation matrix to be applied to the resulting frustum plane
  20649. * @param frustumPlane the resuling frustum plane
  20650. */
  20651. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20652. /**
  20653. * Gets the right frustum plane transformed by the transform matrix
  20654. * @param transform transformation matrix to be applied to the resulting frustum plane
  20655. * @param frustumPlane the resuling frustum plane
  20656. */
  20657. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20658. /**
  20659. * Gets the top frustum plane transformed by the transform matrix
  20660. * @param transform transformation matrix to be applied to the resulting frustum plane
  20661. * @param frustumPlane the resuling frustum plane
  20662. */
  20663. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20664. /**
  20665. * Gets the bottom frustum plane transformed by the transform matrix
  20666. * @param transform transformation matrix to be applied to the resulting frustum plane
  20667. * @param frustumPlane the resuling frustum plane
  20668. */
  20669. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20670. /**
  20671. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  20672. * @param transform transformation matrix to be applied to the resulting frustum planes
  20673. * @param frustumPlanes the resuling frustum planes
  20674. */
  20675. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  20676. }
  20677. /** Defines supported spaces */
  20678. enum Space {
  20679. /** Local (object) space */
  20680. LOCAL = 0,
  20681. /** World space */
  20682. WORLD = 1,
  20683. /** Bone space */
  20684. BONE = 2
  20685. }
  20686. /** Defines the 3 main axes */
  20687. class Axis {
  20688. /** X axis */
  20689. static X: Vector3;
  20690. /** Y axis */
  20691. static Y: Vector3;
  20692. /** Z axis */
  20693. static Z: Vector3;
  20694. }
  20695. /** Class used to represent a Bezier curve */
  20696. class BezierCurve {
  20697. /**
  20698. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  20699. * @param t defines the time
  20700. * @param x1 defines the left coordinate on X axis
  20701. * @param y1 defines the left coordinate on Y axis
  20702. * @param x2 defines the right coordinate on X axis
  20703. * @param y2 defines the right coordinate on Y axis
  20704. * @returns the interpolated value
  20705. */
  20706. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  20707. }
  20708. /**
  20709. * Defines potential orientation for back face culling
  20710. */
  20711. enum Orientation {
  20712. /**
  20713. * Clockwise
  20714. */
  20715. CW = 0,
  20716. /** Counter clockwise */
  20717. CCW = 1
  20718. }
  20719. /**
  20720. * Defines angle representation
  20721. */
  20722. class Angle {
  20723. private _radians;
  20724. /**
  20725. * Creates an Angle object of "radians" radians (float).
  20726. */
  20727. constructor(radians: number);
  20728. /**
  20729. * Get value in degrees
  20730. * @returns the Angle value in degrees (float)
  20731. */
  20732. degrees(): number;
  20733. /**
  20734. * Get value in radians
  20735. * @returns the Angle value in radians (float)
  20736. */
  20737. radians(): number;
  20738. /**
  20739. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  20740. * @param a defines first vector
  20741. * @param b defines second vector
  20742. * @returns a new Angle
  20743. */
  20744. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  20745. /**
  20746. * Gets a new Angle object from the given float in radians
  20747. * @param radians defines the angle value in radians
  20748. * @returns a new Angle
  20749. */
  20750. static FromRadians(radians: number): Angle;
  20751. /**
  20752. * Gets a new Angle object from the given float in degrees
  20753. * @param degrees defines the angle value in degrees
  20754. * @returns a new Angle
  20755. */
  20756. static FromDegrees(degrees: number): Angle;
  20757. }
  20758. /**
  20759. * This represents an arc in a 2d space.
  20760. */
  20761. class Arc2 {
  20762. /** Defines the start point of the arc */
  20763. startPoint: Vector2;
  20764. /** Defines the mid point of the arc */
  20765. midPoint: Vector2;
  20766. /** Defines the end point of the arc */
  20767. endPoint: Vector2;
  20768. /**
  20769. * Defines the center point of the arc.
  20770. */
  20771. centerPoint: Vector2;
  20772. /**
  20773. * Defines the radius of the arc.
  20774. */
  20775. radius: number;
  20776. /**
  20777. * Defines the angle of the arc (from mid point to end point).
  20778. */
  20779. angle: Angle;
  20780. /**
  20781. * Defines the start angle of the arc (from start point to middle point).
  20782. */
  20783. startAngle: Angle;
  20784. /**
  20785. * Defines the orientation of the arc (clock wise/counter clock wise).
  20786. */
  20787. orientation: Orientation;
  20788. /**
  20789. * Creates an Arc object from the three given points : start, middle and end.
  20790. * @param startPoint Defines the start point of the arc
  20791. * @param midPoint Defines the midlle point of the arc
  20792. * @param endPoint Defines the end point of the arc
  20793. */
  20794. constructor(
  20795. /** Defines the start point of the arc */
  20796. startPoint: Vector2,
  20797. /** Defines the mid point of the arc */
  20798. midPoint: Vector2,
  20799. /** Defines the end point of the arc */
  20800. endPoint: Vector2);
  20801. }
  20802. /**
  20803. * Represents a 2D path made up of multiple 2D points
  20804. */
  20805. class Path2 {
  20806. private _points;
  20807. private _length;
  20808. /**
  20809. * If the path start and end point are the same
  20810. */
  20811. closed: boolean;
  20812. /**
  20813. * Creates a Path2 object from the starting 2D coordinates x and y.
  20814. * @param x the starting points x value
  20815. * @param y the starting points y value
  20816. */
  20817. constructor(x: number, y: number);
  20818. /**
  20819. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  20820. * @param x the added points x value
  20821. * @param y the added points y value
  20822. * @returns the updated Path2.
  20823. */
  20824. addLineTo(x: number, y: number): Path2;
  20825. /**
  20826. * 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.
  20827. * @param midX middle point x value
  20828. * @param midY middle point y value
  20829. * @param endX end point x value
  20830. * @param endY end point y value
  20831. * @param numberOfSegments (default: 36)
  20832. * @returns the updated Path2.
  20833. */
  20834. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  20835. /**
  20836. * Closes the Path2.
  20837. * @returns the Path2.
  20838. */
  20839. close(): Path2;
  20840. /**
  20841. * Gets the sum of the distance between each sequential point in the path
  20842. * @returns the Path2 total length (float).
  20843. */
  20844. length(): number;
  20845. /**
  20846. * Gets the points which construct the path
  20847. * @returns the Path2 internal array of points.
  20848. */
  20849. getPoints(): Vector2[];
  20850. /**
  20851. * Retreives the point at the distance aways from the starting point
  20852. * @param normalizedLengthPosition the length along the path to retreive the point from
  20853. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  20854. */
  20855. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  20856. /**
  20857. * Creates a new path starting from an x and y position
  20858. * @param x starting x value
  20859. * @param y starting y value
  20860. * @returns a new Path2 starting at the coordinates (x, y).
  20861. */
  20862. static StartingAt(x: number, y: number): Path2;
  20863. }
  20864. /**
  20865. * Represents a 3D path made up of multiple 3D points
  20866. */
  20867. class Path3D {
  20868. /**
  20869. * an array of Vector3, the curve axis of the Path3D
  20870. */
  20871. path: Vector3[];
  20872. private _curve;
  20873. private _distances;
  20874. private _tangents;
  20875. private _normals;
  20876. private _binormals;
  20877. private _raw;
  20878. /**
  20879. * new Path3D(path, normal, raw)
  20880. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  20881. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  20882. * @param path an array of Vector3, the curve axis of the Path3D
  20883. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  20884. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  20885. */
  20886. constructor(
  20887. /**
  20888. * an array of Vector3, the curve axis of the Path3D
  20889. */
  20890. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  20891. /**
  20892. * Returns the Path3D array of successive Vector3 designing its curve.
  20893. * @returns the Path3D array of successive Vector3 designing its curve.
  20894. */
  20895. getCurve(): Vector3[];
  20896. /**
  20897. * Returns an array populated with tangent vectors on each Path3D curve point.
  20898. * @returns an array populated with tangent vectors on each Path3D curve point.
  20899. */
  20900. getTangents(): Vector3[];
  20901. /**
  20902. * Returns an array populated with normal vectors on each Path3D curve point.
  20903. * @returns an array populated with normal vectors on each Path3D curve point.
  20904. */
  20905. getNormals(): Vector3[];
  20906. /**
  20907. * Returns an array populated with binormal vectors on each Path3D curve point.
  20908. * @returns an array populated with binormal vectors on each Path3D curve point.
  20909. */
  20910. getBinormals(): Vector3[];
  20911. /**
  20912. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  20913. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  20914. */
  20915. getDistances(): number[];
  20916. /**
  20917. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  20918. * @param path path which all values are copied into the curves points
  20919. * @param firstNormal which should be projected onto the curve
  20920. * @returns the same object updated.
  20921. */
  20922. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  20923. private _compute;
  20924. private _getFirstNonNullVector;
  20925. private _getLastNonNullVector;
  20926. private _normalVector;
  20927. }
  20928. /**
  20929. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20930. * A Curve3 is designed from a series of successive Vector3.
  20931. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  20932. */
  20933. class Curve3 {
  20934. private _points;
  20935. private _length;
  20936. /**
  20937. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  20938. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  20939. * @param v1 (Vector3) the control point
  20940. * @param v2 (Vector3) the end point of the Quadratic Bezier
  20941. * @param nbPoints (integer) the wanted number of points in the curve
  20942. * @returns the created Curve3
  20943. */
  20944. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20945. /**
  20946. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  20947. * @param v0 (Vector3) the origin point of the Cubic Bezier
  20948. * @param v1 (Vector3) the first control point
  20949. * @param v2 (Vector3) the second control point
  20950. * @param v3 (Vector3) the end point of the Cubic Bezier
  20951. * @param nbPoints (integer) the wanted number of points in the curve
  20952. * @returns the created Curve3
  20953. */
  20954. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20955. /**
  20956. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  20957. * @param p1 (Vector3) the origin point of the Hermite Spline
  20958. * @param t1 (Vector3) the tangent vector at the origin point
  20959. * @param p2 (Vector3) the end point of the Hermite Spline
  20960. * @param t2 (Vector3) the tangent vector at the end point
  20961. * @param nbPoints (integer) the wanted number of points in the curve
  20962. * @returns the created Curve3
  20963. */
  20964. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20965. /**
  20966. * Returns a Curve3 object along a CatmullRom Spline curve :
  20967. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  20968. * @param nbPoints (integer) the wanted number of points between each curve control points
  20969. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  20970. * @returns the created Curve3
  20971. */
  20972. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  20973. /**
  20974. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20975. * A Curve3 is designed from a series of successive Vector3.
  20976. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  20977. * @param points points which make up the curve
  20978. */
  20979. constructor(points: Vector3[]);
  20980. /**
  20981. * @returns the Curve3 stored array of successive Vector3
  20982. */
  20983. getPoints(): Vector3[];
  20984. /**
  20985. * @returns the computed length (float) of the curve.
  20986. */
  20987. length(): number;
  20988. /**
  20989. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  20990. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  20991. * curveA and curveB keep unchanged.
  20992. * @param curve the curve to continue from this curve
  20993. * @returns the newly constructed curve
  20994. */
  20995. continue(curve: DeepImmutable<Curve3>): Curve3;
  20996. private _computeLength;
  20997. }
  20998. /**
  20999. * Contains position and normal vectors for a vertex
  21000. */
  21001. class PositionNormalVertex {
  21002. /** the position of the vertex (defaut: 0,0,0) */
  21003. position: Vector3;
  21004. /** the normal of the vertex (defaut: 0,1,0) */
  21005. normal: Vector3;
  21006. /**
  21007. * Creates a PositionNormalVertex
  21008. * @param position the position of the vertex (defaut: 0,0,0)
  21009. * @param normal the normal of the vertex (defaut: 0,1,0)
  21010. */
  21011. constructor(
  21012. /** the position of the vertex (defaut: 0,0,0) */
  21013. position?: Vector3,
  21014. /** the normal of the vertex (defaut: 0,1,0) */
  21015. normal?: Vector3);
  21016. /**
  21017. * Clones the PositionNormalVertex
  21018. * @returns the cloned PositionNormalVertex
  21019. */
  21020. clone(): PositionNormalVertex;
  21021. }
  21022. /**
  21023. * Contains position, normal and uv vectors for a vertex
  21024. */
  21025. class PositionNormalTextureVertex {
  21026. /** the position of the vertex (defaut: 0,0,0) */
  21027. position: Vector3;
  21028. /** the normal of the vertex (defaut: 0,1,0) */
  21029. normal: Vector3;
  21030. /** the uv of the vertex (default: 0,0) */
  21031. uv: Vector2;
  21032. /**
  21033. * Creates a PositionNormalTextureVertex
  21034. * @param position the position of the vertex (defaut: 0,0,0)
  21035. * @param normal the normal of the vertex (defaut: 0,1,0)
  21036. * @param uv the uv of the vertex (default: 0,0)
  21037. */
  21038. constructor(
  21039. /** the position of the vertex (defaut: 0,0,0) */
  21040. position?: Vector3,
  21041. /** the normal of the vertex (defaut: 0,1,0) */
  21042. normal?: Vector3,
  21043. /** the uv of the vertex (default: 0,0) */
  21044. uv?: Vector2);
  21045. /**
  21046. * Clones the PositionNormalTextureVertex
  21047. * @returns the cloned PositionNormalTextureVertex
  21048. */
  21049. clone(): PositionNormalTextureVertex;
  21050. }
  21051. /**
  21052. * @hidden
  21053. */
  21054. class Tmp {
  21055. static Color3: Color3[];
  21056. static Color4: Color4[];
  21057. static Vector2: Vector2[];
  21058. static Vector3: Vector3[];
  21059. static Vector4: Vector4[];
  21060. static Quaternion: Quaternion[];
  21061. static Matrix: Matrix[];
  21062. }
  21063. }
  21064. declare module BABYLON {
  21065. /**
  21066. * Class representing spherical polynomial coefficients to the 3rd degree
  21067. */
  21068. class SphericalPolynomial {
  21069. /**
  21070. * The x coefficients of the spherical polynomial
  21071. */
  21072. x: Vector3;
  21073. /**
  21074. * The y coefficients of the spherical polynomial
  21075. */
  21076. y: Vector3;
  21077. /**
  21078. * The z coefficients of the spherical polynomial
  21079. */
  21080. z: Vector3;
  21081. /**
  21082. * The xx coefficients of the spherical polynomial
  21083. */
  21084. xx: Vector3;
  21085. /**
  21086. * The yy coefficients of the spherical polynomial
  21087. */
  21088. yy: Vector3;
  21089. /**
  21090. * The zz coefficients of the spherical polynomial
  21091. */
  21092. zz: Vector3;
  21093. /**
  21094. * The xy coefficients of the spherical polynomial
  21095. */
  21096. xy: Vector3;
  21097. /**
  21098. * The yz coefficients of the spherical polynomial
  21099. */
  21100. yz: Vector3;
  21101. /**
  21102. * The zx coefficients of the spherical polynomial
  21103. */
  21104. zx: Vector3;
  21105. /**
  21106. * Adds an ambient color to the spherical polynomial
  21107. * @param color the color to add
  21108. */
  21109. addAmbient(color: Color3): void;
  21110. /**
  21111. * Scales the spherical polynomial by the given amount
  21112. * @param scale the amount to scale
  21113. */
  21114. scale(scale: number): void;
  21115. /**
  21116. * Gets the spherical polynomial from harmonics
  21117. * @param harmonics the spherical harmonics
  21118. * @returns the spherical polynomial
  21119. */
  21120. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21121. /**
  21122. * Constructs a spherical polynomial from an array.
  21123. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21124. * @returns the spherical polynomial
  21125. */
  21126. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21127. }
  21128. /**
  21129. * Class representing spherical harmonics coefficients to the 3rd degree
  21130. */
  21131. class SphericalHarmonics {
  21132. /**
  21133. * The l0,0 coefficients of the spherical harmonics
  21134. */
  21135. l00: Vector3;
  21136. /**
  21137. * The l1,-1 coefficients of the spherical harmonics
  21138. */
  21139. l1_1: Vector3;
  21140. /**
  21141. * The l1,0 coefficients of the spherical harmonics
  21142. */
  21143. l10: Vector3;
  21144. /**
  21145. * The l1,1 coefficients of the spherical harmonics
  21146. */
  21147. l11: Vector3;
  21148. /**
  21149. * The l2,-2 coefficients of the spherical harmonics
  21150. */
  21151. l2_2: Vector3;
  21152. /**
  21153. * The l2,-1 coefficients of the spherical harmonics
  21154. */
  21155. l2_1: Vector3;
  21156. /**
  21157. * The l2,0 coefficients of the spherical harmonics
  21158. */
  21159. l20: Vector3;
  21160. /**
  21161. * The l2,1 coefficients of the spherical harmonics
  21162. */
  21163. l21: Vector3;
  21164. /**
  21165. * The l2,2 coefficients of the spherical harmonics
  21166. */
  21167. lL22: Vector3;
  21168. /**
  21169. * Adds a light to the spherical harmonics
  21170. * @param direction the direction of the light
  21171. * @param color the color of the light
  21172. * @param deltaSolidAngle the delta solid angle of the light
  21173. */
  21174. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21175. /**
  21176. * Scales the spherical harmonics by the given amount
  21177. * @param scale the amount to scale
  21178. */
  21179. scale(scale: number): void;
  21180. /**
  21181. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21182. *
  21183. * ```
  21184. * E_lm = A_l * L_lm
  21185. * ```
  21186. *
  21187. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21188. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21189. * the scaling factors are given in equation 9.
  21190. */
  21191. convertIncidentRadianceToIrradiance(): void;
  21192. /**
  21193. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21194. *
  21195. * ```
  21196. * L = (1/pi) * E * rho
  21197. * ```
  21198. *
  21199. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21200. */
  21201. convertIrradianceToLambertianRadiance(): void;
  21202. /**
  21203. * Gets the spherical harmonics from polynomial
  21204. * @param polynomial the spherical polynomial
  21205. * @returns the spherical harmonics
  21206. */
  21207. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21208. /**
  21209. * Constructs a spherical harmonics from an array.
  21210. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21211. * @returns the spherical harmonics
  21212. */
  21213. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21214. }
  21215. }
  21216. declare module BABYLON {
  21217. /**
  21218. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21219. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21220. * 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;
  21221. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21222. */
  21223. class ColorCurves {
  21224. private _dirty;
  21225. private _tempColor;
  21226. private _globalCurve;
  21227. private _highlightsCurve;
  21228. private _midtonesCurve;
  21229. private _shadowsCurve;
  21230. private _positiveCurve;
  21231. private _negativeCurve;
  21232. private _globalHue;
  21233. private _globalDensity;
  21234. private _globalSaturation;
  21235. private _globalExposure;
  21236. /**
  21237. * Gets the global Hue value.
  21238. * 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).
  21239. */
  21240. /**
  21241. * Sets the global Hue value.
  21242. * 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).
  21243. */
  21244. globalHue: number;
  21245. /**
  21246. * Gets the global Density value.
  21247. * 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.
  21248. * Values less than zero provide a filter of opposite hue.
  21249. */
  21250. /**
  21251. * Sets the global Density value.
  21252. * 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.
  21253. * Values less than zero provide a filter of opposite hue.
  21254. */
  21255. globalDensity: number;
  21256. /**
  21257. * Gets the global Saturation value.
  21258. * 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.
  21259. */
  21260. /**
  21261. * Sets the global Saturation value.
  21262. * 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.
  21263. */
  21264. globalSaturation: number;
  21265. /**
  21266. * Gets the global Exposure value.
  21267. * 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.
  21268. */
  21269. /**
  21270. * Sets the global Exposure value.
  21271. * 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.
  21272. */
  21273. globalExposure: number;
  21274. private _highlightsHue;
  21275. private _highlightsDensity;
  21276. private _highlightsSaturation;
  21277. private _highlightsExposure;
  21278. /**
  21279. * Gets the highlights Hue value.
  21280. * 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).
  21281. */
  21282. /**
  21283. * Sets the highlights Hue value.
  21284. * 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).
  21285. */
  21286. highlightsHue: number;
  21287. /**
  21288. * Gets the highlights Density value.
  21289. * 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.
  21290. * Values less than zero provide a filter of opposite hue.
  21291. */
  21292. /**
  21293. * Sets the highlights Density value.
  21294. * 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.
  21295. * Values less than zero provide a filter of opposite hue.
  21296. */
  21297. highlightsDensity: number;
  21298. /**
  21299. * Gets the highlights Saturation value.
  21300. * 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.
  21301. */
  21302. /**
  21303. * Sets the highlights Saturation value.
  21304. * 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.
  21305. */
  21306. highlightsSaturation: number;
  21307. /**
  21308. * Gets the highlights Exposure value.
  21309. * 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.
  21310. */
  21311. /**
  21312. * Sets the highlights Exposure value.
  21313. * 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.
  21314. */
  21315. highlightsExposure: number;
  21316. private _midtonesHue;
  21317. private _midtonesDensity;
  21318. private _midtonesSaturation;
  21319. private _midtonesExposure;
  21320. /**
  21321. * Gets the midtones Hue value.
  21322. * 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).
  21323. */
  21324. /**
  21325. * Sets the midtones Hue value.
  21326. * 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).
  21327. */
  21328. midtonesHue: number;
  21329. /**
  21330. * Gets the midtones Density value.
  21331. * 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.
  21332. * Values less than zero provide a filter of opposite hue.
  21333. */
  21334. /**
  21335. * Sets the midtones Density value.
  21336. * 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.
  21337. * Values less than zero provide a filter of opposite hue.
  21338. */
  21339. midtonesDensity: number;
  21340. /**
  21341. * Gets the midtones Saturation value.
  21342. * 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.
  21343. */
  21344. /**
  21345. * Sets the midtones Saturation value.
  21346. * 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.
  21347. */
  21348. midtonesSaturation: number;
  21349. /**
  21350. * Gets the midtones Exposure value.
  21351. * 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.
  21352. */
  21353. /**
  21354. * Sets the midtones Exposure value.
  21355. * 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.
  21356. */
  21357. midtonesExposure: number;
  21358. private _shadowsHue;
  21359. private _shadowsDensity;
  21360. private _shadowsSaturation;
  21361. private _shadowsExposure;
  21362. /**
  21363. * Gets the shadows Hue value.
  21364. * 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).
  21365. */
  21366. /**
  21367. * Sets the shadows Hue value.
  21368. * 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).
  21369. */
  21370. shadowsHue: number;
  21371. /**
  21372. * Gets the shadows Density value.
  21373. * 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.
  21374. * Values less than zero provide a filter of opposite hue.
  21375. */
  21376. /**
  21377. * Sets the shadows Density value.
  21378. * 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.
  21379. * Values less than zero provide a filter of opposite hue.
  21380. */
  21381. shadowsDensity: number;
  21382. /**
  21383. * Gets the shadows Saturation value.
  21384. * 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.
  21385. */
  21386. /**
  21387. * Sets the shadows Saturation value.
  21388. * 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.
  21389. */
  21390. shadowsSaturation: number;
  21391. /**
  21392. * Gets the shadows Exposure value.
  21393. * 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.
  21394. */
  21395. /**
  21396. * Sets the shadows Exposure value.
  21397. * 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.
  21398. */
  21399. shadowsExposure: number;
  21400. /**
  21401. * Returns the class name
  21402. * @returns The class name
  21403. */
  21404. getClassName(): string;
  21405. /**
  21406. * Binds the color curves to the shader.
  21407. * @param colorCurves The color curve to bind
  21408. * @param effect The effect to bind to
  21409. * @param positiveUniform The positive uniform shader parameter
  21410. * @param neutralUniform The neutral uniform shader parameter
  21411. * @param negativeUniform The negative uniform shader parameter
  21412. */
  21413. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  21414. /**
  21415. * Prepare the list of uniforms associated with the ColorCurves effects.
  21416. * @param uniformsList The list of uniforms used in the effect
  21417. */
  21418. static PrepareUniforms(uniformsList: string[]): void;
  21419. /**
  21420. * Returns color grading data based on a hue, density, saturation and exposure value.
  21421. * @param filterHue The hue of the color filter.
  21422. * @param filterDensity The density of the color filter.
  21423. * @param saturation The saturation.
  21424. * @param exposure The exposure.
  21425. * @param result The result data container.
  21426. */
  21427. private getColorGradingDataToRef;
  21428. /**
  21429. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  21430. * @param value The input slider value in range [-100,100].
  21431. * @returns Adjusted value.
  21432. */
  21433. private static applyColorGradingSliderNonlinear;
  21434. /**
  21435. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  21436. * @param hue The hue (H) input.
  21437. * @param saturation The saturation (S) input.
  21438. * @param brightness The brightness (B) input.
  21439. * @result An RGBA color represented as Vector4.
  21440. */
  21441. private static fromHSBToRef;
  21442. /**
  21443. * Returns a value clamped between min and max
  21444. * @param value The value to clamp
  21445. * @param min The minimum of value
  21446. * @param max The maximum of value
  21447. * @returns The clamped value.
  21448. */
  21449. private static clamp;
  21450. /**
  21451. * Clones the current color curve instance.
  21452. * @return The cloned curves
  21453. */
  21454. clone(): ColorCurves;
  21455. /**
  21456. * Serializes the current color curve instance to a json representation.
  21457. * @return a JSON representation
  21458. */
  21459. serialize(): any;
  21460. /**
  21461. * Parses the color curve from a json representation.
  21462. * @param source the JSON source to parse
  21463. * @return The parsed curves
  21464. */
  21465. static Parse(source: any): ColorCurves;
  21466. }
  21467. }
  21468. declare module BABYLON {
  21469. /**
  21470. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  21471. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  21472. */
  21473. class EffectFallbacks {
  21474. private _defines;
  21475. private _currentRank;
  21476. private _maxRank;
  21477. private _mesh;
  21478. /**
  21479. * Removes the fallback from the bound mesh.
  21480. */
  21481. unBindMesh(): void;
  21482. /**
  21483. * Adds a fallback on the specified property.
  21484. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21485. * @param define The name of the define in the shader
  21486. */
  21487. addFallback(rank: number, define: string): void;
  21488. /**
  21489. * Sets the mesh to use CPU skinning when needing to fallback.
  21490. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21491. * @param mesh The mesh to use the fallbacks.
  21492. */
  21493. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  21494. /**
  21495. * Checks to see if more fallbacks are still availible.
  21496. */
  21497. readonly isMoreFallbacks: boolean;
  21498. /**
  21499. * Removes the defines that shoould be removed when falling back.
  21500. * @param currentDefines defines the current define statements for the shader.
  21501. * @param effect defines the current effect we try to compile
  21502. * @returns The resulting defines with defines of the current rank removed.
  21503. */
  21504. reduce(currentDefines: string, effect: Effect): string;
  21505. }
  21506. /**
  21507. * Options to be used when creating an effect.
  21508. */
  21509. class EffectCreationOptions {
  21510. /**
  21511. * Atrributes that will be used in the shader.
  21512. */
  21513. attributes: string[];
  21514. /**
  21515. * Uniform varible names that will be set in the shader.
  21516. */
  21517. uniformsNames: string[];
  21518. /**
  21519. * Uniform buffer varible names that will be set in the shader.
  21520. */
  21521. uniformBuffersNames: string[];
  21522. /**
  21523. * Sampler texture variable names that will be set in the shader.
  21524. */
  21525. samplers: string[];
  21526. /**
  21527. * Define statements that will be set in the shader.
  21528. */
  21529. defines: any;
  21530. /**
  21531. * Possible fallbacks for this effect to improve performance when needed.
  21532. */
  21533. fallbacks: Nullable<EffectFallbacks>;
  21534. /**
  21535. * Callback that will be called when the shader is compiled.
  21536. */
  21537. onCompiled: Nullable<(effect: Effect) => void>;
  21538. /**
  21539. * Callback that will be called if an error occurs during shader compilation.
  21540. */
  21541. onError: Nullable<(effect: Effect, errors: string) => void>;
  21542. /**
  21543. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21544. */
  21545. indexParameters: any;
  21546. /**
  21547. * Max number of lights that can be used in the shader.
  21548. */
  21549. maxSimultaneousLights: number;
  21550. /**
  21551. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  21552. */
  21553. transformFeedbackVaryings: Nullable<string[]>;
  21554. }
  21555. /**
  21556. * Effect containing vertex and fragment shader that can be executed on an object.
  21557. */
  21558. class Effect {
  21559. /**
  21560. * Name of the effect.
  21561. */
  21562. name: any;
  21563. /**
  21564. * String container all the define statements that should be set on the shader.
  21565. */
  21566. defines: string;
  21567. /**
  21568. * Callback that will be called when the shader is compiled.
  21569. */
  21570. onCompiled: Nullable<(effect: Effect) => void>;
  21571. /**
  21572. * Callback that will be called if an error occurs during shader compilation.
  21573. */
  21574. onError: Nullable<(effect: Effect, errors: string) => void>;
  21575. /**
  21576. * Callback that will be called when effect is bound.
  21577. */
  21578. onBind: Nullable<(effect: Effect) => void>;
  21579. /**
  21580. * Unique ID of the effect.
  21581. */
  21582. uniqueId: number;
  21583. /**
  21584. * Observable that will be called when the shader is compiled.
  21585. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  21586. */
  21587. onCompileObservable: Observable<Effect>;
  21588. /**
  21589. * Observable that will be called if an error occurs during shader compilation.
  21590. */
  21591. onErrorObservable: Observable<Effect>;
  21592. /** @hidden */
  21593. _onBindObservable: Nullable<Observable<Effect>>;
  21594. /**
  21595. * Observable that will be called when effect is bound.
  21596. */
  21597. readonly onBindObservable: Observable<Effect>;
  21598. /** @hidden */
  21599. _bonesComputationForcedToCPU: boolean;
  21600. private static _uniqueIdSeed;
  21601. private _engine;
  21602. private _uniformBuffersNames;
  21603. private _uniformsNames;
  21604. private _samplers;
  21605. private _isReady;
  21606. private _compilationError;
  21607. private _attributesNames;
  21608. private _attributes;
  21609. private _uniforms;
  21610. /**
  21611. * Key for the effect.
  21612. * @hidden
  21613. */
  21614. _key: string;
  21615. private _indexParameters;
  21616. private _fallbacks;
  21617. private _vertexSourceCode;
  21618. private _fragmentSourceCode;
  21619. private _vertexSourceCodeOverride;
  21620. private _fragmentSourceCodeOverride;
  21621. private _transformFeedbackVaryings;
  21622. /**
  21623. * Compiled shader to webGL program.
  21624. * @hidden
  21625. */
  21626. _program: WebGLProgram;
  21627. private _valueCache;
  21628. private static _baseCache;
  21629. /**
  21630. * Instantiates an effect.
  21631. * An effect can be used to create/manage/execute vertex and fragment shaders.
  21632. * @param baseName Name of the effect.
  21633. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  21634. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  21635. * @param samplers List of sampler variables that will be passed to the shader.
  21636. * @param engine Engine to be used to render the effect
  21637. * @param defines Define statements to be added to the shader.
  21638. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  21639. * @param onCompiled Callback that will be called when the shader is compiled.
  21640. * @param onError Callback that will be called if an error occurs during shader compilation.
  21641. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21642. */
  21643. 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);
  21644. /**
  21645. * Unique key for this effect
  21646. */
  21647. readonly key: string;
  21648. /**
  21649. * If the effect has been compiled and prepared.
  21650. * @returns if the effect is compiled and prepared.
  21651. */
  21652. isReady(): boolean;
  21653. /**
  21654. * The engine the effect was initialized with.
  21655. * @returns the engine.
  21656. */
  21657. getEngine(): Engine;
  21658. /**
  21659. * The compiled webGL program for the effect
  21660. * @returns the webGL program.
  21661. */
  21662. getProgram(): WebGLProgram;
  21663. /**
  21664. * The set of names of attribute variables for the shader.
  21665. * @returns An array of attribute names.
  21666. */
  21667. getAttributesNames(): string[];
  21668. /**
  21669. * Returns the attribute at the given index.
  21670. * @param index The index of the attribute.
  21671. * @returns The location of the attribute.
  21672. */
  21673. getAttributeLocation(index: number): number;
  21674. /**
  21675. * Returns the attribute based on the name of the variable.
  21676. * @param name of the attribute to look up.
  21677. * @returns the attribute location.
  21678. */
  21679. getAttributeLocationByName(name: string): number;
  21680. /**
  21681. * The number of attributes.
  21682. * @returns the numnber of attributes.
  21683. */
  21684. getAttributesCount(): number;
  21685. /**
  21686. * Gets the index of a uniform variable.
  21687. * @param uniformName of the uniform to look up.
  21688. * @returns the index.
  21689. */
  21690. getUniformIndex(uniformName: string): number;
  21691. /**
  21692. * Returns the attribute based on the name of the variable.
  21693. * @param uniformName of the uniform to look up.
  21694. * @returns the location of the uniform.
  21695. */
  21696. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  21697. /**
  21698. * Returns an array of sampler variable names
  21699. * @returns The array of sampler variable neames.
  21700. */
  21701. getSamplers(): string[];
  21702. /**
  21703. * The error from the last compilation.
  21704. * @returns the error string.
  21705. */
  21706. getCompilationError(): string;
  21707. /**
  21708. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  21709. * @param func The callback to be used.
  21710. */
  21711. executeWhenCompiled(func: (effect: Effect) => void): void;
  21712. private _checkIsReady;
  21713. /** @hidden */
  21714. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  21715. /** @hidden */
  21716. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  21717. /** @hidden */
  21718. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  21719. private _processShaderConversion;
  21720. private _processIncludes;
  21721. private _processPrecision;
  21722. /**
  21723. * Recompiles the webGL program
  21724. * @param vertexSourceCode The source code for the vertex shader.
  21725. * @param fragmentSourceCode The source code for the fragment shader.
  21726. * @param onCompiled Callback called when completed.
  21727. * @param onError Callback called on error.
  21728. * @hidden
  21729. */
  21730. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  21731. /**
  21732. * Gets the uniform locations of the the specified variable names
  21733. * @param names THe names of the variables to lookup.
  21734. * @returns Array of locations in the same order as variable names.
  21735. */
  21736. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  21737. /**
  21738. * Prepares the effect
  21739. * @hidden
  21740. */
  21741. _prepareEffect(): void;
  21742. /**
  21743. * Checks if the effect is supported. (Must be called after compilation)
  21744. */
  21745. readonly isSupported: boolean;
  21746. /**
  21747. * Binds a texture to the engine to be used as output of the shader.
  21748. * @param channel Name of the output variable.
  21749. * @param texture Texture to bind.
  21750. * @hidden
  21751. */
  21752. _bindTexture(channel: string, texture: InternalTexture): void;
  21753. /**
  21754. * Sets a texture on the engine to be used in the shader.
  21755. * @param channel Name of the sampler variable.
  21756. * @param texture Texture to set.
  21757. */
  21758. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  21759. /**
  21760. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  21761. * @param channel Name of the sampler variable.
  21762. * @param texture Texture to set.
  21763. */
  21764. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  21765. /**
  21766. * Sets an array of textures on the engine to be used in the shader.
  21767. * @param channel Name of the variable.
  21768. * @param textures Textures to set.
  21769. */
  21770. setTextureArray(channel: string, textures: BaseTexture[]): void;
  21771. /**
  21772. * 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)
  21773. * @param channel Name of the sampler variable.
  21774. * @param postProcess Post process to get the input texture from.
  21775. */
  21776. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  21777. /**
  21778. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  21779. * 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)
  21780. * @param channel Name of the sampler variable.
  21781. * @param postProcess Post process to get the output texture from.
  21782. */
  21783. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  21784. /** @hidden */
  21785. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  21786. /** @hidden */
  21787. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  21788. /** @hidden */
  21789. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  21790. /** @hidden */
  21791. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  21792. /**
  21793. * Binds a buffer to a uniform.
  21794. * @param buffer Buffer to bind.
  21795. * @param name Name of the uniform variable to bind to.
  21796. */
  21797. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  21798. /**
  21799. * Binds block to a uniform.
  21800. * @param blockName Name of the block to bind.
  21801. * @param index Index to bind.
  21802. */
  21803. bindUniformBlock(blockName: string, index: number): void;
  21804. /**
  21805. * Sets an interger value on a uniform variable.
  21806. * @param uniformName Name of the variable.
  21807. * @param value Value to be set.
  21808. * @returns this effect.
  21809. */
  21810. setInt(uniformName: string, value: number): Effect;
  21811. /**
  21812. * Sets an int array on a uniform variable.
  21813. * @param uniformName Name of the variable.
  21814. * @param array array to be set.
  21815. * @returns this effect.
  21816. */
  21817. setIntArray(uniformName: string, array: Int32Array): Effect;
  21818. /**
  21819. * 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)
  21820. * @param uniformName Name of the variable.
  21821. * @param array array to be set.
  21822. * @returns this effect.
  21823. */
  21824. setIntArray2(uniformName: string, array: Int32Array): Effect;
  21825. /**
  21826. * 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)
  21827. * @param uniformName Name of the variable.
  21828. * @param array array to be set.
  21829. * @returns this effect.
  21830. */
  21831. setIntArray3(uniformName: string, array: Int32Array): Effect;
  21832. /**
  21833. * 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)
  21834. * @param uniformName Name of the variable.
  21835. * @param array array to be set.
  21836. * @returns this effect.
  21837. */
  21838. setIntArray4(uniformName: string, array: Int32Array): Effect;
  21839. /**
  21840. * Sets an float array on a uniform variable.
  21841. * @param uniformName Name of the variable.
  21842. * @param array array to be set.
  21843. * @returns this effect.
  21844. */
  21845. setFloatArray(uniformName: string, array: Float32Array): Effect;
  21846. /**
  21847. * 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)
  21848. * @param uniformName Name of the variable.
  21849. * @param array array to be set.
  21850. * @returns this effect.
  21851. */
  21852. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  21853. /**
  21854. * 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)
  21855. * @param uniformName Name of the variable.
  21856. * @param array array to be set.
  21857. * @returns this effect.
  21858. */
  21859. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  21860. /**
  21861. * 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)
  21862. * @param uniformName Name of the variable.
  21863. * @param array array to be set.
  21864. * @returns this effect.
  21865. */
  21866. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  21867. /**
  21868. * Sets an array on a uniform variable.
  21869. * @param uniformName Name of the variable.
  21870. * @param array array to be set.
  21871. * @returns this effect.
  21872. */
  21873. setArray(uniformName: string, array: number[]): Effect;
  21874. /**
  21875. * 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)
  21876. * @param uniformName Name of the variable.
  21877. * @param array array to be set.
  21878. * @returns this effect.
  21879. */
  21880. setArray2(uniformName: string, array: number[]): Effect;
  21881. /**
  21882. * 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)
  21883. * @param uniformName Name of the variable.
  21884. * @param array array to be set.
  21885. * @returns this effect.
  21886. */
  21887. setArray3(uniformName: string, array: number[]): Effect;
  21888. /**
  21889. * 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)
  21890. * @param uniformName Name of the variable.
  21891. * @param array array to be set.
  21892. * @returns this effect.
  21893. */
  21894. setArray4(uniformName: string, array: number[]): Effect;
  21895. /**
  21896. * Sets matrices on a uniform variable.
  21897. * @param uniformName Name of the variable.
  21898. * @param matrices matrices to be set.
  21899. * @returns this effect.
  21900. */
  21901. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  21902. /**
  21903. * Sets matrix on a uniform variable.
  21904. * @param uniformName Name of the variable.
  21905. * @param matrix matrix to be set.
  21906. * @returns this effect.
  21907. */
  21908. setMatrix(uniformName: string, matrix: Matrix): Effect;
  21909. /**
  21910. * 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)
  21911. * @param uniformName Name of the variable.
  21912. * @param matrix matrix to be set.
  21913. * @returns this effect.
  21914. */
  21915. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  21916. /**
  21917. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  21918. * @param uniformName Name of the variable.
  21919. * @param matrix matrix to be set.
  21920. * @returns this effect.
  21921. */
  21922. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  21923. /**
  21924. * Sets a float on a uniform variable.
  21925. * @param uniformName Name of the variable.
  21926. * @param value value to be set.
  21927. * @returns this effect.
  21928. */
  21929. setFloat(uniformName: string, value: number): Effect;
  21930. /**
  21931. * Sets a boolean on a uniform variable.
  21932. * @param uniformName Name of the variable.
  21933. * @param bool value to be set.
  21934. * @returns this effect.
  21935. */
  21936. setBool(uniformName: string, bool: boolean): Effect;
  21937. /**
  21938. * Sets a Vector2 on a uniform variable.
  21939. * @param uniformName Name of the variable.
  21940. * @param vector2 vector2 to be set.
  21941. * @returns this effect.
  21942. */
  21943. setVector2(uniformName: string, vector2: Vector2): Effect;
  21944. /**
  21945. * Sets a float2 on a uniform variable.
  21946. * @param uniformName Name of the variable.
  21947. * @param x First float in float2.
  21948. * @param y Second float in float2.
  21949. * @returns this effect.
  21950. */
  21951. setFloat2(uniformName: string, x: number, y: number): Effect;
  21952. /**
  21953. * Sets a Vector3 on a uniform variable.
  21954. * @param uniformName Name of the variable.
  21955. * @param vector3 Value to be set.
  21956. * @returns this effect.
  21957. */
  21958. setVector3(uniformName: string, vector3: Vector3): Effect;
  21959. /**
  21960. * Sets a float3 on a uniform variable.
  21961. * @param uniformName Name of the variable.
  21962. * @param x First float in float3.
  21963. * @param y Second float in float3.
  21964. * @param z Third float in float3.
  21965. * @returns this effect.
  21966. */
  21967. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  21968. /**
  21969. * Sets a Vector4 on a uniform variable.
  21970. * @param uniformName Name of the variable.
  21971. * @param vector4 Value to be set.
  21972. * @returns this effect.
  21973. */
  21974. setVector4(uniformName: string, vector4: Vector4): Effect;
  21975. /**
  21976. * Sets a float4 on a uniform variable.
  21977. * @param uniformName Name of the variable.
  21978. * @param x First float in float4.
  21979. * @param y Second float in float4.
  21980. * @param z Third float in float4.
  21981. * @param w Fourth float in float4.
  21982. * @returns this effect.
  21983. */
  21984. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  21985. /**
  21986. * Sets a Color3 on a uniform variable.
  21987. * @param uniformName Name of the variable.
  21988. * @param color3 Value to be set.
  21989. * @returns this effect.
  21990. */
  21991. setColor3(uniformName: string, color3: Color3): Effect;
  21992. /**
  21993. * Sets a Color4 on a uniform variable.
  21994. * @param uniformName Name of the variable.
  21995. * @param color3 Value to be set.
  21996. * @param alpha Alpha value to be set.
  21997. * @returns this effect.
  21998. */
  21999. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  22000. /**
  22001. * Sets a Color4 on a uniform variable
  22002. * @param uniformName defines the name of the variable
  22003. * @param color4 defines the value to be set
  22004. * @returns this effect.
  22005. */
  22006. setDirectColor4(uniformName: string, color4: Color4): Effect;
  22007. /**
  22008. * This function will add a new shader to the shader store
  22009. * @param name the name of the shader
  22010. * @param pixelShader optional pixel shader content
  22011. * @param vertexShader optional vertex shader content
  22012. */
  22013. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  22014. /**
  22015. * Store of each shader (The can be looked up using effect.key)
  22016. */
  22017. static ShadersStore: {
  22018. [key: string]: string;
  22019. };
  22020. /**
  22021. * Store of each included file for a shader (The can be looked up using effect.key)
  22022. */
  22023. static IncludesShadersStore: {
  22024. [key: string]: string;
  22025. };
  22026. /**
  22027. * Resets the cache of effects.
  22028. */
  22029. static ResetCache(): void;
  22030. }
  22031. }
  22032. declare module BABYLON {
  22033. /**
  22034. * This represents all the required information to add a fresnel effect on a material:
  22035. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  22036. */
  22037. class FresnelParameters {
  22038. private _isEnabled;
  22039. /**
  22040. * Define if the fresnel effect is enable or not.
  22041. */
  22042. isEnabled: boolean;
  22043. /**
  22044. * Define the color used on edges (grazing angle)
  22045. */
  22046. leftColor: Color3;
  22047. /**
  22048. * Define the color used on center
  22049. */
  22050. rightColor: Color3;
  22051. /**
  22052. * Define bias applied to computed fresnel term
  22053. */
  22054. bias: number;
  22055. /**
  22056. * Defined the power exponent applied to fresnel term
  22057. */
  22058. power: number;
  22059. /**
  22060. * Clones the current fresnel and its valuues
  22061. * @returns a clone fresnel configuration
  22062. */
  22063. clone(): FresnelParameters;
  22064. /**
  22065. * Serializes the current fresnel parameters to a JSON representation.
  22066. * @return the JSON serialization
  22067. */
  22068. serialize(): any;
  22069. /**
  22070. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  22071. * @param parsedFresnelParameters Define the JSON representation
  22072. * @returns the parsed parameters
  22073. */
  22074. static Parse(parsedFresnelParameters: any): FresnelParameters;
  22075. }
  22076. }
  22077. declare module BABYLON {
  22078. /**
  22079. * Interface to follow in your material defines to integrate easily the
  22080. * Image proccessing functions.
  22081. * @hidden
  22082. */
  22083. interface IImageProcessingConfigurationDefines {
  22084. IMAGEPROCESSING: boolean;
  22085. VIGNETTE: boolean;
  22086. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22087. VIGNETTEBLENDMODEOPAQUE: boolean;
  22088. TONEMAPPING: boolean;
  22089. TONEMAPPING_ACES: boolean;
  22090. CONTRAST: boolean;
  22091. EXPOSURE: boolean;
  22092. COLORCURVES: boolean;
  22093. COLORGRADING: boolean;
  22094. COLORGRADING3D: boolean;
  22095. SAMPLER3DGREENDEPTH: boolean;
  22096. SAMPLER3DBGRMAP: boolean;
  22097. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22098. }
  22099. /**
  22100. * @hidden
  22101. */
  22102. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22103. IMAGEPROCESSING: boolean;
  22104. VIGNETTE: boolean;
  22105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22106. VIGNETTEBLENDMODEOPAQUE: boolean;
  22107. TONEMAPPING: boolean;
  22108. TONEMAPPING_ACES: boolean;
  22109. CONTRAST: boolean;
  22110. COLORCURVES: boolean;
  22111. COLORGRADING: boolean;
  22112. COLORGRADING3D: boolean;
  22113. SAMPLER3DGREENDEPTH: boolean;
  22114. SAMPLER3DBGRMAP: boolean;
  22115. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22116. EXPOSURE: boolean;
  22117. constructor();
  22118. }
  22119. /**
  22120. * This groups together the common properties used for image processing either in direct forward pass
  22121. * or through post processing effect depending on the use of the image processing pipeline in your scene
  22122. * or not.
  22123. */
  22124. class ImageProcessingConfiguration {
  22125. /**
  22126. * Default tone mapping applied in BabylonJS.
  22127. */
  22128. static readonly TONEMAPPING_STANDARD: number;
  22129. /**
  22130. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  22131. * to other engines rendering to increase portability.
  22132. */
  22133. static readonly TONEMAPPING_ACES: number;
  22134. /**
  22135. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  22136. */
  22137. colorCurves: Nullable<ColorCurves>;
  22138. private _colorCurvesEnabled;
  22139. /**
  22140. * Gets wether the color curves effect is enabled.
  22141. */
  22142. /**
  22143. * Sets wether the color curves effect is enabled.
  22144. */
  22145. colorCurvesEnabled: boolean;
  22146. private _colorGradingTexture;
  22147. /**
  22148. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  22149. */
  22150. /**
  22151. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  22152. */
  22153. colorGradingTexture: Nullable<BaseTexture>;
  22154. private _colorGradingEnabled;
  22155. /**
  22156. * Gets wether the color grading effect is enabled.
  22157. */
  22158. /**
  22159. * Sets wether the color grading effect is enabled.
  22160. */
  22161. colorGradingEnabled: boolean;
  22162. private _colorGradingWithGreenDepth;
  22163. /**
  22164. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  22165. */
  22166. /**
  22167. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  22168. */
  22169. colorGradingWithGreenDepth: boolean;
  22170. private _colorGradingBGR;
  22171. /**
  22172. * Gets wether the color grading texture contains BGR values.
  22173. */
  22174. /**
  22175. * Sets wether the color grading texture contains BGR values.
  22176. */
  22177. colorGradingBGR: boolean;
  22178. /** @hidden */
  22179. _exposure: number;
  22180. /**
  22181. * Gets the Exposure used in the effect.
  22182. */
  22183. /**
  22184. * Sets the Exposure used in the effect.
  22185. */
  22186. exposure: number;
  22187. private _toneMappingEnabled;
  22188. /**
  22189. * Gets wether the tone mapping effect is enabled.
  22190. */
  22191. /**
  22192. * Sets wether the tone mapping effect is enabled.
  22193. */
  22194. toneMappingEnabled: boolean;
  22195. private _toneMappingType;
  22196. /**
  22197. * Gets the type of tone mapping effect.
  22198. */
  22199. /**
  22200. * Sets the type of tone mapping effect used in BabylonJS.
  22201. */
  22202. toneMappingType: number;
  22203. protected _contrast: number;
  22204. /**
  22205. * Gets the contrast used in the effect.
  22206. */
  22207. /**
  22208. * Sets the contrast used in the effect.
  22209. */
  22210. contrast: number;
  22211. /**
  22212. * Vignette stretch size.
  22213. */
  22214. vignetteStretch: number;
  22215. /**
  22216. * Vignette centre X Offset.
  22217. */
  22218. vignetteCentreX: number;
  22219. /**
  22220. * Vignette centre Y Offset.
  22221. */
  22222. vignetteCentreY: number;
  22223. /**
  22224. * Vignette weight or intensity of the vignette effect.
  22225. */
  22226. vignetteWeight: number;
  22227. /**
  22228. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22229. * if vignetteEnabled is set to true.
  22230. */
  22231. vignetteColor: Color4;
  22232. /**
  22233. * Camera field of view used by the Vignette effect.
  22234. */
  22235. vignetteCameraFov: number;
  22236. private _vignetteBlendMode;
  22237. /**
  22238. * Gets the vignette blend mode allowing different kind of effect.
  22239. */
  22240. /**
  22241. * Sets the vignette blend mode allowing different kind of effect.
  22242. */
  22243. vignetteBlendMode: number;
  22244. private _vignetteEnabled;
  22245. /**
  22246. * Gets wether the vignette effect is enabled.
  22247. */
  22248. /**
  22249. * Sets wether the vignette effect is enabled.
  22250. */
  22251. vignetteEnabled: boolean;
  22252. private _applyByPostProcess;
  22253. /**
  22254. * Gets wether the image processing is applied through a post process or not.
  22255. */
  22256. /**
  22257. * Sets wether the image processing is applied through a post process or not.
  22258. */
  22259. applyByPostProcess: boolean;
  22260. private _isEnabled;
  22261. /**
  22262. * Gets wether the image processing is enabled or not.
  22263. */
  22264. /**
  22265. * Sets wether the image processing is enabled or not.
  22266. */
  22267. isEnabled: boolean;
  22268. /**
  22269. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  22270. */
  22271. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  22272. /**
  22273. * Method called each time the image processing information changes requires to recompile the effect.
  22274. */
  22275. protected _updateParameters(): void;
  22276. /**
  22277. * Gets the current class name.
  22278. * @return "ImageProcessingConfiguration"
  22279. */
  22280. getClassName(): string;
  22281. /**
  22282. * Prepare the list of uniforms associated with the Image Processing effects.
  22283. * @param uniforms The list of uniforms used in the effect
  22284. * @param defines the list of defines currently in use
  22285. */
  22286. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  22287. /**
  22288. * Prepare the list of samplers associated with the Image Processing effects.
  22289. * @param samplersList The list of uniforms used in the effect
  22290. * @param defines the list of defines currently in use
  22291. */
  22292. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  22293. /**
  22294. * Prepare the list of defines associated to the shader.
  22295. * @param defines the list of defines to complete
  22296. * @param forPostProcess Define if we are currently in post process mode or not
  22297. */
  22298. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  22299. /**
  22300. * Returns true if all the image processing information are ready.
  22301. * @returns True if ready, otherwise, false
  22302. */
  22303. isReady(): boolean;
  22304. /**
  22305. * Binds the image processing to the shader.
  22306. * @param effect The effect to bind to
  22307. * @param aspectRatio Define the current aspect ratio of the effect
  22308. */
  22309. bind(effect: Effect, aspectRatio?: number): void;
  22310. /**
  22311. * Clones the current image processing instance.
  22312. * @return The cloned image processing
  22313. */
  22314. clone(): ImageProcessingConfiguration;
  22315. /**
  22316. * Serializes the current image processing instance to a json representation.
  22317. * @return a JSON representation
  22318. */
  22319. serialize(): any;
  22320. /**
  22321. * Parses the image processing from a json representation.
  22322. * @param source the JSON source to parse
  22323. * @return The parsed image processing
  22324. */
  22325. static Parse(source: any): ImageProcessingConfiguration;
  22326. private static _VIGNETTEMODE_MULTIPLY;
  22327. private static _VIGNETTEMODE_OPAQUE;
  22328. /**
  22329. * Used to apply the vignette as a mix with the pixel color.
  22330. */
  22331. static readonly VIGNETTEMODE_MULTIPLY: number;
  22332. /**
  22333. * Used to apply the vignette as a replacement of the pixel color.
  22334. */
  22335. static readonly VIGNETTEMODE_OPAQUE: number;
  22336. }
  22337. }
  22338. declare module BABYLON {
  22339. /**
  22340. * Manages the defines for the Material
  22341. */
  22342. class MaterialDefines {
  22343. private _keys;
  22344. private _isDirty;
  22345. /** @hidden */
  22346. _renderId: number;
  22347. /** @hidden */
  22348. _areLightsDirty: boolean;
  22349. /** @hidden */
  22350. _areAttributesDirty: boolean;
  22351. /** @hidden */
  22352. _areTexturesDirty: boolean;
  22353. /** @hidden */
  22354. _areFresnelDirty: boolean;
  22355. /** @hidden */
  22356. _areMiscDirty: boolean;
  22357. /** @hidden */
  22358. _areImageProcessingDirty: boolean;
  22359. /** @hidden */
  22360. _normals: boolean;
  22361. /** @hidden */
  22362. _uvs: boolean;
  22363. /** @hidden */
  22364. _needNormals: boolean;
  22365. /** @hidden */
  22366. _needUVs: boolean;
  22367. /**
  22368. * Specifies if the material needs to be re-calculated
  22369. */
  22370. readonly isDirty: boolean;
  22371. /**
  22372. * Marks the material to indicate that it has been re-calculated
  22373. */
  22374. markAsProcessed(): void;
  22375. /**
  22376. * Marks the material to indicate that it needs to be re-calculated
  22377. */
  22378. markAsUnprocessed(): void;
  22379. /**
  22380. * Marks the material to indicate all of its defines need to be re-calculated
  22381. */
  22382. markAllAsDirty(): void;
  22383. /**
  22384. * Marks the material to indicate that image processing needs to be re-calculated
  22385. */
  22386. markAsImageProcessingDirty(): void;
  22387. /**
  22388. * Marks the material to indicate the lights need to be re-calculated
  22389. */
  22390. markAsLightDirty(): void;
  22391. /**
  22392. * Marks the attribute state as changed
  22393. */
  22394. markAsAttributesDirty(): void;
  22395. /**
  22396. * Marks the texture state as changed
  22397. */
  22398. markAsTexturesDirty(): void;
  22399. /**
  22400. * Marks the fresnel state as changed
  22401. */
  22402. markAsFresnelDirty(): void;
  22403. /**
  22404. * Marks the misc state as changed
  22405. */
  22406. markAsMiscDirty(): void;
  22407. /**
  22408. * Rebuilds the material defines
  22409. */
  22410. rebuild(): void;
  22411. /**
  22412. * Specifies if two material defines are equal
  22413. * @param other - A material define instance to compare to
  22414. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  22415. */
  22416. isEqual(other: MaterialDefines): boolean;
  22417. /**
  22418. * Clones this instance's defines to another instance
  22419. * @param other - material defines to clone values to
  22420. */
  22421. cloneTo(other: MaterialDefines): void;
  22422. /**
  22423. * Resets the material define values
  22424. */
  22425. reset(): void;
  22426. /**
  22427. * Converts the material define values to a string
  22428. * @returns - String of material define information
  22429. */
  22430. toString(): string;
  22431. }
  22432. /**
  22433. * Base class for the main features of a material in Babylon.js
  22434. */
  22435. class Material implements IAnimatable {
  22436. private static _TriangleFillMode;
  22437. private static _WireFrameFillMode;
  22438. private static _PointFillMode;
  22439. private static _PointListDrawMode;
  22440. private static _LineListDrawMode;
  22441. private static _LineLoopDrawMode;
  22442. private static _LineStripDrawMode;
  22443. private static _TriangleStripDrawMode;
  22444. private static _TriangleFanDrawMode;
  22445. /**
  22446. * Returns the triangle fill mode
  22447. */
  22448. static readonly TriangleFillMode: number;
  22449. /**
  22450. * Returns the wireframe mode
  22451. */
  22452. static readonly WireFrameFillMode: number;
  22453. /**
  22454. * Returns the point fill mode
  22455. */
  22456. static readonly PointFillMode: number;
  22457. /**
  22458. * Returns the point list draw mode
  22459. */
  22460. static readonly PointListDrawMode: number;
  22461. /**
  22462. * Returns the line list draw mode
  22463. */
  22464. static readonly LineListDrawMode: number;
  22465. /**
  22466. * Returns the line loop draw mode
  22467. */
  22468. static readonly LineLoopDrawMode: number;
  22469. /**
  22470. * Returns the line strip draw mode
  22471. */
  22472. static readonly LineStripDrawMode: number;
  22473. /**
  22474. * Returns the triangle strip draw mode
  22475. */
  22476. static readonly TriangleStripDrawMode: number;
  22477. /**
  22478. * Returns the triangle fan draw mode
  22479. */
  22480. static readonly TriangleFanDrawMode: number;
  22481. /**
  22482. * Stores the clock-wise side orientation
  22483. */
  22484. private static _ClockWiseSideOrientation;
  22485. /**
  22486. * Stores the counter clock-wise side orientation
  22487. */
  22488. private static _CounterClockWiseSideOrientation;
  22489. /**
  22490. * Returns the clock-wise side orientation
  22491. */
  22492. static readonly ClockWiseSideOrientation: number;
  22493. /**
  22494. * Returns the counter clock-wise side orientation
  22495. */
  22496. static readonly CounterClockWiseSideOrientation: number;
  22497. /**
  22498. * The dirty texture flag value
  22499. */
  22500. static readonly TextureDirtyFlag: number;
  22501. /**
  22502. * The dirty light flag value
  22503. */
  22504. static readonly LightDirtyFlag: number;
  22505. /**
  22506. * The dirty fresnel flag value
  22507. */
  22508. static readonly FresnelDirtyFlag: number;
  22509. /**
  22510. * The dirty attribute flag value
  22511. */
  22512. static readonly AttributesDirtyFlag: number;
  22513. /**
  22514. * The dirty misc flag value
  22515. */
  22516. static readonly MiscDirtyFlag: number;
  22517. /**
  22518. * The all dirty flag value
  22519. */
  22520. static readonly AllDirtyFlag: number;
  22521. /**
  22522. * The ID of the material
  22523. */
  22524. id: string;
  22525. /**
  22526. * Gets or sets the unique id of the material
  22527. */
  22528. uniqueId: number;
  22529. /**
  22530. * The name of the material
  22531. */
  22532. name: string;
  22533. /**
  22534. * Gets or sets user defined metadata
  22535. */
  22536. metadata: any;
  22537. /**
  22538. * For internal use only. Please do not use.
  22539. */
  22540. reservedDataStore: any;
  22541. /**
  22542. * Specifies if the ready state should be checked on each call
  22543. */
  22544. checkReadyOnEveryCall: boolean;
  22545. /**
  22546. * Specifies if the ready state should be checked once
  22547. */
  22548. checkReadyOnlyOnce: boolean;
  22549. /**
  22550. * The state of the material
  22551. */
  22552. state: string;
  22553. /**
  22554. * The alpha value of the material
  22555. */
  22556. protected _alpha: number;
  22557. /**
  22558. * Sets the alpha value of the material
  22559. */
  22560. /**
  22561. * Gets the alpha value of the material
  22562. */
  22563. alpha: number;
  22564. /**
  22565. * Specifies if back face culling is enabled
  22566. */
  22567. protected _backFaceCulling: boolean;
  22568. /**
  22569. * Sets the back-face culling state
  22570. */
  22571. /**
  22572. * Gets the back-face culling state
  22573. */
  22574. backFaceCulling: boolean;
  22575. /**
  22576. * Stores the value for side orientation
  22577. */
  22578. sideOrientation: number;
  22579. /**
  22580. * Callback triggered when the material is compiled
  22581. */
  22582. onCompiled: (effect: Effect) => void;
  22583. /**
  22584. * Callback triggered when an error occurs
  22585. */
  22586. onError: (effect: Effect, errors: string) => void;
  22587. /**
  22588. * Callback triggered to get the render target textures
  22589. */
  22590. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22591. /**
  22592. * Gets a boolean indicating that current material needs to register RTT
  22593. */
  22594. readonly hasRenderTargetTextures: boolean;
  22595. /**
  22596. * Specifies if the material should be serialized
  22597. */
  22598. doNotSerialize: boolean;
  22599. /**
  22600. * @hidden
  22601. */
  22602. _storeEffectOnSubMeshes: boolean;
  22603. /**
  22604. * Stores the animations for the material
  22605. */
  22606. animations: Array<Animation>;
  22607. /**
  22608. * An event triggered when the material is disposed
  22609. */
  22610. onDisposeObservable: Observable<Material>;
  22611. /**
  22612. * An observer which watches for dispose events
  22613. */
  22614. private _onDisposeObserver;
  22615. private _onUnBindObservable;
  22616. /**
  22617. * Called during a dispose event
  22618. */
  22619. onDispose: () => void;
  22620. private _onBindObservable;
  22621. /**
  22622. * An event triggered when the material is bound
  22623. */
  22624. readonly onBindObservable: Observable<AbstractMesh>;
  22625. /**
  22626. * An observer which watches for bind events
  22627. */
  22628. private _onBindObserver;
  22629. /**
  22630. * Called during a bind event
  22631. */
  22632. onBind: (Mesh: AbstractMesh) => void;
  22633. /**
  22634. * An event triggered when the material is unbound
  22635. */
  22636. readonly onUnBindObservable: Observable<Material>;
  22637. /**
  22638. * Stores the value of the alpha mode
  22639. */
  22640. private _alphaMode;
  22641. /**
  22642. * Sets the value of the alpha mode.
  22643. *
  22644. * | Value | Type | Description |
  22645. * | --- | --- | --- |
  22646. * | 0 | ALPHA_DISABLE | |
  22647. * | 1 | ALPHA_ADD | |
  22648. * | 2 | ALPHA_COMBINE | |
  22649. * | 3 | ALPHA_SUBTRACT | |
  22650. * | 4 | ALPHA_MULTIPLY | |
  22651. * | 5 | ALPHA_MAXIMIZED | |
  22652. * | 6 | ALPHA_ONEONE | |
  22653. * | 7 | ALPHA_PREMULTIPLIED | |
  22654. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22655. * | 9 | ALPHA_INTERPOLATE | |
  22656. * | 10 | ALPHA_SCREENMODE | |
  22657. *
  22658. */
  22659. /**
  22660. * Gets the value of the alpha mode
  22661. */
  22662. alphaMode: number;
  22663. /**
  22664. * Stores the state of the need depth pre-pass value
  22665. */
  22666. private _needDepthPrePass;
  22667. /**
  22668. * Sets the need depth pre-pass value
  22669. */
  22670. /**
  22671. * Gets the depth pre-pass value
  22672. */
  22673. needDepthPrePass: boolean;
  22674. /**
  22675. * Specifies if depth writing should be disabled
  22676. */
  22677. disableDepthWrite: boolean;
  22678. /**
  22679. * Specifies if depth writing should be forced
  22680. */
  22681. forceDepthWrite: boolean;
  22682. /**
  22683. * Specifies if there should be a separate pass for culling
  22684. */
  22685. separateCullingPass: boolean;
  22686. /**
  22687. * Stores the state specifing if fog should be enabled
  22688. */
  22689. private _fogEnabled;
  22690. /**
  22691. * Sets the state for enabling fog
  22692. */
  22693. /**
  22694. * Gets the value of the fog enabled state
  22695. */
  22696. fogEnabled: boolean;
  22697. /**
  22698. * Stores the size of points
  22699. */
  22700. pointSize: number;
  22701. /**
  22702. * Stores the z offset value
  22703. */
  22704. zOffset: number;
  22705. /**
  22706. * Gets a value specifying if wireframe mode is enabled
  22707. */
  22708. /**
  22709. * Sets the state of wireframe mode
  22710. */
  22711. wireframe: boolean;
  22712. /**
  22713. * Gets the value specifying if point clouds are enabled
  22714. */
  22715. /**
  22716. * Sets the state of point cloud mode
  22717. */
  22718. pointsCloud: boolean;
  22719. /**
  22720. * Gets the material fill mode
  22721. */
  22722. /**
  22723. * Sets the material fill mode
  22724. */
  22725. fillMode: number;
  22726. /**
  22727. * @hidden
  22728. * Stores the effects for the material
  22729. */
  22730. _effect: Nullable<Effect>;
  22731. /**
  22732. * @hidden
  22733. * Specifies if the material was previously ready
  22734. */
  22735. _wasPreviouslyReady: boolean;
  22736. /**
  22737. * Specifies if uniform buffers should be used
  22738. */
  22739. private _useUBO;
  22740. /**
  22741. * Stores a reference to the scene
  22742. */
  22743. private _scene;
  22744. /**
  22745. * Stores the fill mode state
  22746. */
  22747. private _fillMode;
  22748. /**
  22749. * Specifies if the depth write state should be cached
  22750. */
  22751. private _cachedDepthWriteState;
  22752. /**
  22753. * Stores the uniform buffer
  22754. */
  22755. protected _uniformBuffer: UniformBuffer;
  22756. /** @hidden */
  22757. _indexInSceneMaterialArray: number;
  22758. /** @hidden */
  22759. meshMap: Nullable<{
  22760. [id: string]: AbstractMesh | undefined;
  22761. }>;
  22762. /**
  22763. * Creates a material instance
  22764. * @param name defines the name of the material
  22765. * @param scene defines the scene to reference
  22766. * @param doNotAdd specifies if the material should be added to the scene
  22767. */
  22768. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22769. /**
  22770. * Returns a string representation of the current material
  22771. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22772. * @returns a string with material information
  22773. */
  22774. toString(fullDetails?: boolean): string;
  22775. /**
  22776. * Gets the class name of the material
  22777. * @returns a string with the class name of the material
  22778. */
  22779. getClassName(): string;
  22780. /**
  22781. * Specifies if updates for the material been locked
  22782. */
  22783. readonly isFrozen: boolean;
  22784. /**
  22785. * Locks updates for the material
  22786. */
  22787. freeze(): void;
  22788. /**
  22789. * Unlocks updates for the material
  22790. */
  22791. unfreeze(): void;
  22792. /**
  22793. * Specifies if the material is ready to be used
  22794. * @param mesh defines the mesh to check
  22795. * @param useInstances specifies if instances should be used
  22796. * @returns a boolean indicating if the material is ready to be used
  22797. */
  22798. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22799. /**
  22800. * Specifies that the submesh is ready to be used
  22801. * @param mesh defines the mesh to check
  22802. * @param subMesh defines which submesh to check
  22803. * @param useInstances specifies that instances should be used
  22804. * @returns a boolean indicating that the submesh is ready or not
  22805. */
  22806. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22807. /**
  22808. * Returns the material effect
  22809. * @returns the effect associated with the material
  22810. */
  22811. getEffect(): Nullable<Effect>;
  22812. /**
  22813. * Returns the current scene
  22814. * @returns a Scene
  22815. */
  22816. getScene(): Scene;
  22817. /**
  22818. * Specifies if the material will require alpha blending
  22819. * @returns a boolean specifying if alpha blending is needed
  22820. */
  22821. needAlphaBlending(): boolean;
  22822. /**
  22823. * Specifies if the mesh will require alpha blending
  22824. * @param mesh defines the mesh to check
  22825. * @returns a boolean specifying if alpha blending is needed for the mesh
  22826. */
  22827. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22828. /**
  22829. * Specifies if this material should be rendered in alpha test mode
  22830. * @returns a boolean specifying if an alpha test is needed.
  22831. */
  22832. needAlphaTesting(): boolean;
  22833. /**
  22834. * Gets the texture used for the alpha test
  22835. * @returns the texture to use for alpha testing
  22836. */
  22837. getAlphaTestTexture(): Nullable<BaseTexture>;
  22838. /**
  22839. * Marks the material to indicate that it needs to be re-calculated
  22840. */
  22841. markDirty(): void;
  22842. /** @hidden */
  22843. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22844. /**
  22845. * Binds the material to the mesh
  22846. * @param world defines the world transformation matrix
  22847. * @param mesh defines the mesh to bind the material to
  22848. */
  22849. bind(world: Matrix, mesh?: Mesh): void;
  22850. /**
  22851. * Binds the submesh to the material
  22852. * @param world defines the world transformation matrix
  22853. * @param mesh defines the mesh containing the submesh
  22854. * @param subMesh defines the submesh to bind the material to
  22855. */
  22856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22857. /**
  22858. * Binds the world matrix to the material
  22859. * @param world defines the world transformation matrix
  22860. */
  22861. bindOnlyWorldMatrix(world: Matrix): void;
  22862. /**
  22863. * Binds the scene's uniform buffer to the effect.
  22864. * @param effect defines the effect to bind to the scene uniform buffer
  22865. * @param sceneUbo defines the uniform buffer storing scene data
  22866. */
  22867. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22868. /**
  22869. * Binds the view matrix to the effect
  22870. * @param effect defines the effect to bind the view matrix to
  22871. */
  22872. bindView(effect: Effect): void;
  22873. /**
  22874. * Binds the view projection matrix to the effect
  22875. * @param effect defines the effect to bind the view projection matrix to
  22876. */
  22877. bindViewProjection(effect: Effect): void;
  22878. /**
  22879. * Specifies if material alpha testing should be turned on for the mesh
  22880. * @param mesh defines the mesh to check
  22881. */
  22882. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22883. /**
  22884. * Processes to execute after binding the material to a mesh
  22885. * @param mesh defines the rendered mesh
  22886. */
  22887. protected _afterBind(mesh?: Mesh): void;
  22888. /**
  22889. * Unbinds the material from the mesh
  22890. */
  22891. unbind(): void;
  22892. /**
  22893. * Gets the active textures from the material
  22894. * @returns an array of textures
  22895. */
  22896. getActiveTextures(): BaseTexture[];
  22897. /**
  22898. * Specifies if the material uses a texture
  22899. * @param texture defines the texture to check against the material
  22900. * @returns a boolean specifying if the material uses the texture
  22901. */
  22902. hasTexture(texture: BaseTexture): boolean;
  22903. /**
  22904. * Makes a duplicate of the material, and gives it a new name
  22905. * @param name defines the new name for the duplicated material
  22906. * @returns the cloned material
  22907. */
  22908. clone(name: string): Nullable<Material>;
  22909. /**
  22910. * Gets the meshes bound to the material
  22911. * @returns an array of meshes bound to the material
  22912. */
  22913. getBindedMeshes(): AbstractMesh[];
  22914. /**
  22915. * Force shader compilation
  22916. * @param mesh defines the mesh associated with this material
  22917. * @param onCompiled defines a function to execute once the material is compiled
  22918. * @param options defines the options to configure the compilation
  22919. */
  22920. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22921. clipPlane: boolean;
  22922. }>): void;
  22923. /**
  22924. * Force shader compilation
  22925. * @param mesh defines the mesh that will use this material
  22926. * @param options defines additional options for compiling the shaders
  22927. * @returns a promise that resolves when the compilation completes
  22928. */
  22929. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22930. clipPlane: boolean;
  22931. }>): Promise<void>;
  22932. private static readonly _ImageProcessingDirtyCallBack;
  22933. private static readonly _TextureDirtyCallBack;
  22934. private static readonly _FresnelDirtyCallBack;
  22935. private static readonly _MiscDirtyCallBack;
  22936. private static readonly _LightsDirtyCallBack;
  22937. private static readonly _AttributeDirtyCallBack;
  22938. private static _FresnelAndMiscDirtyCallBack;
  22939. private static _TextureAndMiscDirtyCallBack;
  22940. private static readonly _DirtyCallbackArray;
  22941. private static readonly _RunDirtyCallBacks;
  22942. /**
  22943. * Marks a define in the material to indicate that it needs to be re-computed
  22944. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22945. */
  22946. markAsDirty(flag: number): void;
  22947. /**
  22948. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22949. * @param func defines a function which checks material defines against the submeshes
  22950. */
  22951. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22952. /**
  22953. * Indicates that image processing needs to be re-calculated for all submeshes
  22954. */
  22955. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22956. /**
  22957. * Indicates that textures need to be re-calculated for all submeshes
  22958. */
  22959. protected _markAllSubMeshesAsTexturesDirty(): void;
  22960. /**
  22961. * Indicates that fresnel needs to be re-calculated for all submeshes
  22962. */
  22963. protected _markAllSubMeshesAsFresnelDirty(): void;
  22964. /**
  22965. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22966. */
  22967. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22968. /**
  22969. * Indicates that lights need to be re-calculated for all submeshes
  22970. */
  22971. protected _markAllSubMeshesAsLightsDirty(): void;
  22972. /**
  22973. * Indicates that attributes need to be re-calculated for all submeshes
  22974. */
  22975. protected _markAllSubMeshesAsAttributesDirty(): void;
  22976. /**
  22977. * Indicates that misc needs to be re-calculated for all submeshes
  22978. */
  22979. protected _markAllSubMeshesAsMiscDirty(): void;
  22980. /**
  22981. * Indicates that textures and misc need to be re-calculated for all submeshes
  22982. */
  22983. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22984. /**
  22985. * Disposes the material
  22986. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22987. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22988. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22989. */
  22990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22991. /** @hidden */
  22992. private releaseVertexArrayObject;
  22993. /**
  22994. * Serializes this material
  22995. * @returns the serialized material object
  22996. */
  22997. serialize(): any;
  22998. /**
  22999. * Creates a MultiMaterial from parsed MultiMaterial data.
  23000. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  23001. * @param scene defines the hosting scene
  23002. * @returns a new MultiMaterial
  23003. */
  23004. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  23005. /**
  23006. * Creates a material from parsed material data
  23007. * @param parsedMaterial defines parsed material data
  23008. * @param scene defines the hosting scene
  23009. * @param rootUrl defines the root URL to use to load textures
  23010. * @returns a new material
  23011. */
  23012. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  23013. }
  23014. }
  23015. declare module BABYLON {
  23016. /**
  23017. * "Static Class" containing the most commonly used helper while dealing with material for
  23018. * rendering purpose.
  23019. *
  23020. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  23021. *
  23022. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  23023. */
  23024. class MaterialHelper {
  23025. /**
  23026. * Bind the current view position to an effect.
  23027. * @param effect The effect to be bound
  23028. * @param scene The scene the eyes position is used from
  23029. */
  23030. static BindEyePosition(effect: Effect, scene: Scene): void;
  23031. /**
  23032. * Helps preparing the defines values about the UVs in used in the effect.
  23033. * UVs are shared as much as we can accross channels in the shaders.
  23034. * @param texture The texture we are preparing the UVs for
  23035. * @param defines The defines to update
  23036. * @param key The channel key "diffuse", "specular"... used in the shader
  23037. */
  23038. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  23039. /**
  23040. * Binds a texture matrix value to its corrsponding uniform
  23041. * @param texture The texture to bind the matrix for
  23042. * @param uniformBuffer The uniform buffer receivin the data
  23043. * @param key The channel key "diffuse", "specular"... used in the shader
  23044. */
  23045. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  23046. /**
  23047. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  23048. * @param mesh defines the current mesh
  23049. * @param scene defines the current scene
  23050. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  23051. * @param pointsCloud defines if point cloud rendering has to be turned on
  23052. * @param fogEnabled defines if fog has to be turned on
  23053. * @param alphaTest defines if alpha testing has to be turned on
  23054. * @param defines defines the current list of defines
  23055. */
  23056. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  23057. /**
  23058. * Helper used to prepare the list of defines associated with frame values for shader compilation
  23059. * @param scene defines the current scene
  23060. * @param engine defines the current engine
  23061. * @param defines specifies the list of active defines
  23062. * @param useInstances defines if instances have to be turned on
  23063. * @param useClipPlane defines if clip plane have to be turned on
  23064. */
  23065. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  23066. /**
  23067. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  23068. * @param mesh The mesh containing the geometry data we will draw
  23069. * @param defines The defines to update
  23070. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  23071. * @param useBones Precise whether bones should be used or not (override mesh info)
  23072. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  23073. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  23074. * @returns false if defines are considered not dirty and have not been checked
  23075. */
  23076. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  23077. /**
  23078. * Prepares the defines related to the light information passed in parameter
  23079. * @param scene The scene we are intending to draw
  23080. * @param mesh The mesh the effect is compiling for
  23081. * @param defines The defines to update
  23082. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  23083. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  23084. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  23085. * @returns true if normals will be required for the rest of the effect
  23086. */
  23087. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  23088. /**
  23089. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  23090. * that won t be acctive due to defines being turned off.
  23091. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  23092. * @param samplersList The samplers list
  23093. * @param defines The defines helping in the list generation
  23094. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  23095. */
  23096. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  23097. /**
  23098. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  23099. * @param defines The defines to update while falling back
  23100. * @param fallbacks The authorized effect fallbacks
  23101. * @param maxSimultaneousLights The maximum number of lights allowed
  23102. * @param rank the current rank of the Effect
  23103. * @returns The newly affected rank
  23104. */
  23105. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  23106. /**
  23107. * Prepares the list of attributes required for morph targets according to the effect defines.
  23108. * @param attribs The current list of supported attribs
  23109. * @param mesh The mesh to prepare the morph targets attributes for
  23110. * @param defines The current Defines of the effect
  23111. */
  23112. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  23113. /**
  23114. * Prepares the list of attributes required for bones according to the effect defines.
  23115. * @param attribs The current list of supported attribs
  23116. * @param mesh The mesh to prepare the bones attributes for
  23117. * @param defines The current Defines of the effect
  23118. * @param fallbacks The current efffect fallback strategy
  23119. */
  23120. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  23121. /**
  23122. * Prepares the list of attributes required for instances according to the effect defines.
  23123. * @param attribs The current list of supported attribs
  23124. * @param defines The current Defines of the effect
  23125. */
  23126. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  23127. /**
  23128. * Binds the light shadow information to the effect for the given mesh.
  23129. * @param light The light containing the generator
  23130. * @param scene The scene the lights belongs to
  23131. * @param mesh The mesh we are binding the information to render
  23132. * @param lightIndex The light index in the effect used to render the mesh
  23133. * @param effect The effect we are binding the data to
  23134. */
  23135. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  23136. /**
  23137. * Binds the light information to the effect.
  23138. * @param light The light containing the generator
  23139. * @param effect The effect we are binding the data to
  23140. * @param lightIndex The light index in the effect used to render
  23141. */
  23142. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  23143. /**
  23144. * Binds the lights information from the scene to the effect for the given mesh.
  23145. * @param scene The scene the lights belongs to
  23146. * @param mesh The mesh we are binding the information to render
  23147. * @param effect The effect we are binding the data to
  23148. * @param defines The generated defines for the effect
  23149. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  23150. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  23151. */
  23152. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  23153. private static _tempFogColor;
  23154. /**
  23155. * Binds the fog information from the scene to the effect for the given mesh.
  23156. * @param scene The scene the lights belongs to
  23157. * @param mesh The mesh we are binding the information to render
  23158. * @param effect The effect we are binding the data to
  23159. * @param linearSpace Defines if the fog effect is applied in linear space
  23160. */
  23161. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  23162. /**
  23163. * Binds the bones information from the mesh to the effect.
  23164. * @param mesh The mesh we are binding the information to render
  23165. * @param effect The effect we are binding the data to
  23166. */
  23167. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  23168. /**
  23169. * Binds the morph targets information from the mesh to the effect.
  23170. * @param abstractMesh The mesh we are binding the information to render
  23171. * @param effect The effect we are binding the data to
  23172. */
  23173. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  23174. /**
  23175. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  23176. * @param defines The generated defines used in the effect
  23177. * @param effect The effect we are binding the data to
  23178. * @param scene The scene we are willing to render with logarithmic scale for
  23179. */
  23180. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  23181. /**
  23182. * Binds the clip plane information from the scene to the effect.
  23183. * @param scene The scene the clip plane information are extracted from
  23184. * @param effect The effect we are binding the data to
  23185. */
  23186. static BindClipPlane(effect: Effect, scene: Scene): void;
  23187. }
  23188. }
  23189. declare module BABYLON {
  23190. /**
  23191. * A multi-material is used to apply different materials to different parts of the same object without the need of
  23192. * separate meshes. This can be use to improve performances.
  23193. * @see http://doc.babylonjs.com/how_to/multi_materials
  23194. */
  23195. class MultiMaterial extends Material {
  23196. private _subMaterials;
  23197. /**
  23198. * Gets or Sets the list of Materials used within the multi material.
  23199. * They need to be ordered according to the submeshes order in the associated mesh
  23200. */
  23201. subMaterials: Nullable<Material>[];
  23202. /**
  23203. * Function used to align with Node.getChildren()
  23204. * @returns the list of Materials used within the multi material
  23205. */
  23206. getChildren(): Nullable<Material>[];
  23207. /**
  23208. * Instantiates a new Multi Material
  23209. * A multi-material is used to apply different materials to different parts of the same object without the need of
  23210. * separate meshes. This can be use to improve performances.
  23211. * @see http://doc.babylonjs.com/how_to/multi_materials
  23212. * @param name Define the name in the scene
  23213. * @param scene Define the scene the material belongs to
  23214. */
  23215. constructor(name: string, scene: Scene);
  23216. private _hookArray;
  23217. /**
  23218. * Get one of the submaterial by its index in the submaterials array
  23219. * @param index The index to look the sub material at
  23220. * @returns The Material if the index has been defined
  23221. */
  23222. getSubMaterial(index: number): Nullable<Material>;
  23223. /**
  23224. * Get the list of active textures for the whole sub materials list.
  23225. * @returns All the textures that will be used during the rendering
  23226. */
  23227. getActiveTextures(): BaseTexture[];
  23228. /**
  23229. * Gets the current class name of the material e.g. "MultiMaterial"
  23230. * Mainly use in serialization.
  23231. * @returns the class name
  23232. */
  23233. getClassName(): string;
  23234. /**
  23235. * Checks if the material is ready to render the requested sub mesh
  23236. * @param mesh Define the mesh the submesh belongs to
  23237. * @param subMesh Define the sub mesh to look readyness for
  23238. * @param useInstances Define whether or not the material is used with instances
  23239. * @returns true if ready, otherwise false
  23240. */
  23241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23242. /**
  23243. * Clones the current material and its related sub materials
  23244. * @param name Define the name of the newly cloned material
  23245. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  23246. * @returns the cloned material
  23247. */
  23248. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  23249. /**
  23250. * Serializes the materials into a JSON representation.
  23251. * @returns the JSON representation
  23252. */
  23253. serialize(): any;
  23254. /**
  23255. * Dispose the material and release its associated resources
  23256. * @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)
  23257. * @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)
  23258. */
  23259. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23260. }
  23261. }
  23262. declare module BABYLON {
  23263. /**
  23264. * Base class of materials working in push mode in babylon JS
  23265. * @hidden
  23266. */
  23267. class PushMaterial extends Material {
  23268. protected _activeEffect: Effect;
  23269. protected _normalMatrix: Matrix;
  23270. /**
  23271. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  23272. * This means that the material can keep using a previous shader while a new one is being compiled.
  23273. * This is mostly used when shader parallel compilation is supported (true by default)
  23274. */
  23275. allowShaderHotSwapping: boolean;
  23276. constructor(name: string, scene: Scene);
  23277. getEffect(): Effect;
  23278. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23279. /**
  23280. * Binds the given world matrix to the active effect
  23281. *
  23282. * @param world the matrix to bind
  23283. */
  23284. bindOnlyWorldMatrix(world: Matrix): void;
  23285. /**
  23286. * Binds the given normal matrix to the active effect
  23287. *
  23288. * @param normalMatrix the matrix to bind
  23289. */
  23290. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  23291. bind(world: Matrix, mesh?: Mesh): void;
  23292. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  23293. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  23294. }
  23295. }
  23296. declare module BABYLON {
  23297. /**
  23298. * Defines the options associated with the creation of a shader material.
  23299. */
  23300. interface IShaderMaterialOptions {
  23301. /**
  23302. * Does the material work in alpha blend mode
  23303. */
  23304. needAlphaBlending: boolean;
  23305. /**
  23306. * Does the material work in alpha test mode
  23307. */
  23308. needAlphaTesting: boolean;
  23309. /**
  23310. * The list of attribute names used in the shader
  23311. */
  23312. attributes: string[];
  23313. /**
  23314. * The list of unifrom names used in the shader
  23315. */
  23316. uniforms: string[];
  23317. /**
  23318. * The list of UBO names used in the shader
  23319. */
  23320. uniformBuffers: string[];
  23321. /**
  23322. * The list of sampler names used in the shader
  23323. */
  23324. samplers: string[];
  23325. /**
  23326. * The list of defines used in the shader
  23327. */
  23328. defines: string[];
  23329. }
  23330. /**
  23331. * 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.
  23332. *
  23333. * This returned material effects how the mesh will look based on the code in the shaders.
  23334. *
  23335. * @see http://doc.babylonjs.com/how_to/shader_material
  23336. */
  23337. class ShaderMaterial extends Material {
  23338. private _shaderPath;
  23339. private _options;
  23340. private _textures;
  23341. private _textureArrays;
  23342. private _floats;
  23343. private _ints;
  23344. private _floatsArrays;
  23345. private _colors3;
  23346. private _colors3Arrays;
  23347. private _colors4;
  23348. private _vectors2;
  23349. private _vectors3;
  23350. private _vectors4;
  23351. private _matrices;
  23352. private _matrices3x3;
  23353. private _matrices2x2;
  23354. private _vectors2Arrays;
  23355. private _vectors3Arrays;
  23356. private _cachedWorldViewMatrix;
  23357. private _renderId;
  23358. /**
  23359. * Instantiate a new shader material.
  23360. * 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.
  23361. * This returned material effects how the mesh will look based on the code in the shaders.
  23362. * @see http://doc.babylonjs.com/how_to/shader_material
  23363. * @param name Define the name of the material in the scene
  23364. * @param scene Define the scene the material belongs to
  23365. * @param shaderPath Defines the route to the shader code in one of three ways:
  23366. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  23367. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  23368. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  23369. * @param options Define the options used to create the shader
  23370. */
  23371. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  23372. /**
  23373. * Gets the current class name of the material e.g. "ShaderMaterial"
  23374. * Mainly use in serialization.
  23375. * @returns the class name
  23376. */
  23377. getClassName(): string;
  23378. /**
  23379. * Specifies if the material will require alpha blending
  23380. * @returns a boolean specifying if alpha blending is needed
  23381. */
  23382. needAlphaBlending(): boolean;
  23383. /**
  23384. * Specifies if this material should be rendered in alpha test mode
  23385. * @returns a boolean specifying if an alpha test is needed.
  23386. */
  23387. needAlphaTesting(): boolean;
  23388. private _checkUniform;
  23389. /**
  23390. * Set a texture in the shader.
  23391. * @param name Define the name of the uniform samplers as defined in the shader
  23392. * @param texture Define the texture to bind to this sampler
  23393. * @return the material itself allowing "fluent" like uniform updates
  23394. */
  23395. setTexture(name: string, texture: Texture): ShaderMaterial;
  23396. /**
  23397. * Set a texture array in the shader.
  23398. * @param name Define the name of the uniform sampler array as defined in the shader
  23399. * @param textures Define the list of textures to bind to this sampler
  23400. * @return the material itself allowing "fluent" like uniform updates
  23401. */
  23402. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  23403. /**
  23404. * Set a float in the shader.
  23405. * @param name Define the name of the uniform as defined in the shader
  23406. * @param value Define the value to give to the uniform
  23407. * @return the material itself allowing "fluent" like uniform updates
  23408. */
  23409. setFloat(name: string, value: number): ShaderMaterial;
  23410. /**
  23411. * Set a int in the shader.
  23412. * @param name Define the name of the uniform as defined in the shader
  23413. * @param value Define the value to give to the uniform
  23414. * @return the material itself allowing "fluent" like uniform updates
  23415. */
  23416. setInt(name: string, value: number): ShaderMaterial;
  23417. /**
  23418. * Set an array of floats in the shader.
  23419. * @param name Define the name of the uniform as defined in the shader
  23420. * @param value Define the value to give to the uniform
  23421. * @return the material itself allowing "fluent" like uniform updates
  23422. */
  23423. setFloats(name: string, value: number[]): ShaderMaterial;
  23424. /**
  23425. * Set a vec3 in the shader from a Color3.
  23426. * @param name Define the name of the uniform as defined in the shader
  23427. * @param value Define the value to give to the uniform
  23428. * @return the material itself allowing "fluent" like uniform updates
  23429. */
  23430. setColor3(name: string, value: Color3): ShaderMaterial;
  23431. /**
  23432. * Set a vec3 array in the shader from a Color3 array.
  23433. * @param name Define the name of the uniform as defined in the shader
  23434. * @param value Define the value to give to the uniform
  23435. * @return the material itself allowing "fluent" like uniform updates
  23436. */
  23437. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  23438. /**
  23439. * Set a vec4 in the shader from a Color4.
  23440. * @param name Define the name of the uniform as defined in the shader
  23441. * @param value Define the value to give to the uniform
  23442. * @return the material itself allowing "fluent" like uniform updates
  23443. */
  23444. setColor4(name: string, value: Color4): ShaderMaterial;
  23445. /**
  23446. * Set a vec2 in the shader from a Vector2.
  23447. * @param name Define the name of the uniform as defined in the shader
  23448. * @param value Define the value to give to the uniform
  23449. * @return the material itself allowing "fluent" like uniform updates
  23450. */
  23451. setVector2(name: string, value: Vector2): ShaderMaterial;
  23452. /**
  23453. * Set a vec3 in the shader from a Vector3.
  23454. * @param name Define the name of the uniform as defined in the shader
  23455. * @param value Define the value to give to the uniform
  23456. * @return the material itself allowing "fluent" like uniform updates
  23457. */
  23458. setVector3(name: string, value: Vector3): ShaderMaterial;
  23459. /**
  23460. * Set a vec4 in the shader from a Vector4.
  23461. * @param name Define the name of the uniform as defined in the shader
  23462. * @param value Define the value to give to the uniform
  23463. * @return the material itself allowing "fluent" like uniform updates
  23464. */
  23465. setVector4(name: string, value: Vector4): ShaderMaterial;
  23466. /**
  23467. * Set a mat4 in the shader from a Matrix.
  23468. * @param name Define the name of the uniform as defined in the shader
  23469. * @param value Define the value to give to the uniform
  23470. * @return the material itself allowing "fluent" like uniform updates
  23471. */
  23472. setMatrix(name: string, value: Matrix): ShaderMaterial;
  23473. /**
  23474. * Set a mat3 in the shader from a Float32Array.
  23475. * @param name Define the name of the uniform as defined in the shader
  23476. * @param value Define the value to give to the uniform
  23477. * @return the material itself allowing "fluent" like uniform updates
  23478. */
  23479. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  23480. /**
  23481. * Set a mat2 in the shader from a Float32Array.
  23482. * @param name Define the name of the uniform as defined in the shader
  23483. * @param value Define the value to give to the uniform
  23484. * @return the material itself allowing "fluent" like uniform updates
  23485. */
  23486. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  23487. /**
  23488. * Set a vec2 array in the shader from a number array.
  23489. * @param name Define the name of the uniform as defined in the shader
  23490. * @param value Define the value to give to the uniform
  23491. * @return the material itself allowing "fluent" like uniform updates
  23492. */
  23493. setArray2(name: string, value: number[]): ShaderMaterial;
  23494. /**
  23495. * Set a vec3 array in the shader from a number array.
  23496. * @param name Define the name of the uniform as defined in the shader
  23497. * @param value Define the value to give to the uniform
  23498. * @return the material itself allowing "fluent" like uniform updates
  23499. */
  23500. setArray3(name: string, value: number[]): ShaderMaterial;
  23501. private _checkCache;
  23502. /**
  23503. * Checks if the material is ready to render the requested mesh
  23504. * @param mesh Define the mesh to render
  23505. * @param useInstances Define whether or not the material is used with instances
  23506. * @returns true if ready, otherwise false
  23507. */
  23508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23509. /**
  23510. * Binds the world matrix to the material
  23511. * @param world defines the world transformation matrix
  23512. */
  23513. bindOnlyWorldMatrix(world: Matrix): void;
  23514. /**
  23515. * Binds the material to the mesh
  23516. * @param world defines the world transformation matrix
  23517. * @param mesh defines the mesh to bind the material to
  23518. */
  23519. bind(world: Matrix, mesh?: Mesh): void;
  23520. /**
  23521. * Gets the active textures from the material
  23522. * @returns an array of textures
  23523. */
  23524. getActiveTextures(): BaseTexture[];
  23525. /**
  23526. * Specifies if the material uses a texture
  23527. * @param texture defines the texture to check against the material
  23528. * @returns a boolean specifying if the material uses the texture
  23529. */
  23530. hasTexture(texture: BaseTexture): boolean;
  23531. /**
  23532. * Makes a duplicate of the material, and gives it a new name
  23533. * @param name defines the new name for the duplicated material
  23534. * @returns the cloned material
  23535. */
  23536. clone(name: string): ShaderMaterial;
  23537. /**
  23538. * Disposes the material
  23539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23540. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23541. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23542. */
  23543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23544. /**
  23545. * Serializes this material in a JSON representation
  23546. * @returns the serialized material object
  23547. */
  23548. serialize(): any;
  23549. /**
  23550. * Creates a shader material from parsed shader material data
  23551. * @param source defines the JSON represnetation of the material
  23552. * @param scene defines the hosting scene
  23553. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23554. * @returns a new material
  23555. */
  23556. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  23557. }
  23558. }
  23559. declare module BABYLON {
  23560. /** @hidden */
  23561. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23562. MAINUV1: boolean;
  23563. MAINUV2: boolean;
  23564. DIFFUSE: boolean;
  23565. DIFFUSEDIRECTUV: number;
  23566. AMBIENT: boolean;
  23567. AMBIENTDIRECTUV: number;
  23568. OPACITY: boolean;
  23569. OPACITYDIRECTUV: number;
  23570. OPACITYRGB: boolean;
  23571. REFLECTION: boolean;
  23572. EMISSIVE: boolean;
  23573. EMISSIVEDIRECTUV: number;
  23574. SPECULAR: boolean;
  23575. SPECULARDIRECTUV: number;
  23576. BUMP: boolean;
  23577. BUMPDIRECTUV: number;
  23578. PARALLAX: boolean;
  23579. PARALLAXOCCLUSION: boolean;
  23580. SPECULAROVERALPHA: boolean;
  23581. CLIPPLANE: boolean;
  23582. CLIPPLANE2: boolean;
  23583. CLIPPLANE3: boolean;
  23584. CLIPPLANE4: boolean;
  23585. ALPHATEST: boolean;
  23586. DEPTHPREPASS: boolean;
  23587. ALPHAFROMDIFFUSE: boolean;
  23588. POINTSIZE: boolean;
  23589. FOG: boolean;
  23590. SPECULARTERM: boolean;
  23591. DIFFUSEFRESNEL: boolean;
  23592. OPACITYFRESNEL: boolean;
  23593. REFLECTIONFRESNEL: boolean;
  23594. REFRACTIONFRESNEL: boolean;
  23595. EMISSIVEFRESNEL: boolean;
  23596. FRESNEL: boolean;
  23597. NORMAL: boolean;
  23598. UV1: boolean;
  23599. UV2: boolean;
  23600. VERTEXCOLOR: boolean;
  23601. VERTEXALPHA: boolean;
  23602. NUM_BONE_INFLUENCERS: number;
  23603. BonesPerMesh: number;
  23604. BONETEXTURE: boolean;
  23605. INSTANCES: boolean;
  23606. GLOSSINESS: boolean;
  23607. ROUGHNESS: boolean;
  23608. EMISSIVEASILLUMINATION: boolean;
  23609. LINKEMISSIVEWITHDIFFUSE: boolean;
  23610. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23611. LIGHTMAP: boolean;
  23612. LIGHTMAPDIRECTUV: number;
  23613. OBJECTSPACE_NORMALMAP: boolean;
  23614. USELIGHTMAPASSHADOWMAP: boolean;
  23615. REFLECTIONMAP_3D: boolean;
  23616. REFLECTIONMAP_SPHERICAL: boolean;
  23617. REFLECTIONMAP_PLANAR: boolean;
  23618. REFLECTIONMAP_CUBIC: boolean;
  23619. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23620. REFLECTIONMAP_PROJECTION: boolean;
  23621. REFLECTIONMAP_SKYBOX: boolean;
  23622. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  23623. REFLECTIONMAP_EXPLICIT: boolean;
  23624. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23625. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23626. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23627. INVERTCUBICMAP: boolean;
  23628. LOGARITHMICDEPTH: boolean;
  23629. REFRACTION: boolean;
  23630. REFRACTIONMAP_3D: boolean;
  23631. REFLECTIONOVERALPHA: boolean;
  23632. TWOSIDEDLIGHTING: boolean;
  23633. SHADOWFLOAT: boolean;
  23634. MORPHTARGETS: boolean;
  23635. MORPHTARGETS_NORMAL: boolean;
  23636. MORPHTARGETS_TANGENT: boolean;
  23637. NUM_MORPH_INFLUENCERS: number;
  23638. NONUNIFORMSCALING: boolean;
  23639. PREMULTIPLYALPHA: boolean;
  23640. IMAGEPROCESSING: boolean;
  23641. VIGNETTE: boolean;
  23642. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23643. VIGNETTEBLENDMODEOPAQUE: boolean;
  23644. TONEMAPPING: boolean;
  23645. TONEMAPPING_ACES: boolean;
  23646. CONTRAST: boolean;
  23647. COLORCURVES: boolean;
  23648. COLORGRADING: boolean;
  23649. COLORGRADING3D: boolean;
  23650. SAMPLER3DGREENDEPTH: boolean;
  23651. SAMPLER3DBGRMAP: boolean;
  23652. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23653. /**
  23654. * If the reflection texture on this material is in linear color space
  23655. * @hidden
  23656. */
  23657. IS_REFLECTION_LINEAR: boolean;
  23658. /**
  23659. * If the refraction texture on this material is in linear color space
  23660. * @hidden
  23661. */
  23662. IS_REFRACTION_LINEAR: boolean;
  23663. EXPOSURE: boolean;
  23664. constructor();
  23665. setReflectionMode(modeToEnable: string): void;
  23666. }
  23667. /**
  23668. * This is the default material used in Babylon. It is the best trade off between quality
  23669. * and performances.
  23670. * @see http://doc.babylonjs.com/babylon101/materials
  23671. */
  23672. class StandardMaterial extends PushMaterial {
  23673. private _diffuseTexture;
  23674. /**
  23675. * The basic texture of the material as viewed under a light.
  23676. */
  23677. diffuseTexture: Nullable<BaseTexture>;
  23678. private _ambientTexture;
  23679. /**
  23680. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23681. */
  23682. ambientTexture: Nullable<BaseTexture>;
  23683. private _opacityTexture;
  23684. /**
  23685. * Define the transparency of the material from a texture.
  23686. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23687. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23688. */
  23689. opacityTexture: Nullable<BaseTexture>;
  23690. private _reflectionTexture;
  23691. /**
  23692. * Define the texture used to display the reflection.
  23693. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23694. */
  23695. reflectionTexture: Nullable<BaseTexture>;
  23696. private _emissiveTexture;
  23697. /**
  23698. * Define texture of the material as if self lit.
  23699. * This will be mixed in the final result even in the absence of light.
  23700. */
  23701. emissiveTexture: Nullable<BaseTexture>;
  23702. private _specularTexture;
  23703. /**
  23704. * Define how the color and intensity of the highlight given by the light in the material.
  23705. */
  23706. specularTexture: Nullable<BaseTexture>;
  23707. private _bumpTexture;
  23708. /**
  23709. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23710. * 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.
  23711. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  23712. */
  23713. bumpTexture: Nullable<BaseTexture>;
  23714. private _lightmapTexture;
  23715. /**
  23716. * Complex lighting can be computationally expensive to compute at runtime.
  23717. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23718. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  23719. */
  23720. lightmapTexture: Nullable<BaseTexture>;
  23721. private _refractionTexture;
  23722. /**
  23723. * Define the texture used to display the refraction.
  23724. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23725. */
  23726. refractionTexture: Nullable<BaseTexture>;
  23727. /**
  23728. * The color of the material lit by the environmental background lighting.
  23729. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23730. */
  23731. ambientColor: Color3;
  23732. /**
  23733. * The basic color of the material as viewed under a light.
  23734. */
  23735. diffuseColor: Color3;
  23736. /**
  23737. * Define how the color and intensity of the highlight given by the light in the material.
  23738. */
  23739. specularColor: Color3;
  23740. /**
  23741. * Define the color of the material as if self lit.
  23742. * This will be mixed in the final result even in the absence of light.
  23743. */
  23744. emissiveColor: Color3;
  23745. /**
  23746. * Defines how sharp are the highlights in the material.
  23747. * The bigger the value the sharper giving a more glossy feeling to the result.
  23748. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  23749. */
  23750. specularPower: number;
  23751. private _useAlphaFromDiffuseTexture;
  23752. /**
  23753. * Does the transparency come from the diffuse texture alpha channel.
  23754. */
  23755. useAlphaFromDiffuseTexture: boolean;
  23756. private _useEmissiveAsIllumination;
  23757. /**
  23758. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  23759. */
  23760. useEmissiveAsIllumination: boolean;
  23761. private _linkEmissiveWithDiffuse;
  23762. /**
  23763. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  23764. * the emissive level when the final color is close to one.
  23765. */
  23766. linkEmissiveWithDiffuse: boolean;
  23767. private _useSpecularOverAlpha;
  23768. /**
  23769. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23770. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23771. */
  23772. useSpecularOverAlpha: boolean;
  23773. private _useReflectionOverAlpha;
  23774. /**
  23775. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23776. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23777. */
  23778. useReflectionOverAlpha: boolean;
  23779. private _disableLighting;
  23780. /**
  23781. * Does lights from the scene impacts this material.
  23782. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  23783. */
  23784. disableLighting: boolean;
  23785. private _useObjectSpaceNormalMap;
  23786. /**
  23787. * Allows using an object space normal map (instead of tangent space).
  23788. */
  23789. useObjectSpaceNormalMap: boolean;
  23790. private _useParallax;
  23791. /**
  23792. * Is parallax enabled or not.
  23793. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23794. */
  23795. useParallax: boolean;
  23796. private _useParallaxOcclusion;
  23797. /**
  23798. * Is parallax occlusion enabled or not.
  23799. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  23800. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23801. */
  23802. useParallaxOcclusion: boolean;
  23803. /**
  23804. * 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.
  23805. */
  23806. parallaxScaleBias: number;
  23807. private _roughness;
  23808. /**
  23809. * Helps to define how blurry the reflections should appears in the material.
  23810. */
  23811. roughness: number;
  23812. /**
  23813. * In case of refraction, define the value of the indice of refraction.
  23814. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23815. */
  23816. indexOfRefraction: number;
  23817. /**
  23818. * Invert the refraction texture alongside the y axis.
  23819. * It can be useful with procedural textures or probe for instance.
  23820. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23821. */
  23822. invertRefractionY: boolean;
  23823. /**
  23824. * Defines the alpha limits in alpha test mode.
  23825. */
  23826. alphaCutOff: number;
  23827. private _useLightmapAsShadowmap;
  23828. /**
  23829. * In case of light mapping, define whether the map contains light or shadow informations.
  23830. */
  23831. useLightmapAsShadowmap: boolean;
  23832. private _diffuseFresnelParameters;
  23833. /**
  23834. * Define the diffuse fresnel parameters of the material.
  23835. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23836. */
  23837. diffuseFresnelParameters: FresnelParameters;
  23838. private _opacityFresnelParameters;
  23839. /**
  23840. * Define the opacity fresnel parameters of the material.
  23841. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23842. */
  23843. opacityFresnelParameters: FresnelParameters;
  23844. private _reflectionFresnelParameters;
  23845. /**
  23846. * Define the reflection fresnel parameters of the material.
  23847. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23848. */
  23849. reflectionFresnelParameters: FresnelParameters;
  23850. private _refractionFresnelParameters;
  23851. /**
  23852. * Define the refraction fresnel parameters of the material.
  23853. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23854. */
  23855. refractionFresnelParameters: FresnelParameters;
  23856. private _emissiveFresnelParameters;
  23857. /**
  23858. * Define the emissive fresnel parameters of the material.
  23859. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23860. */
  23861. emissiveFresnelParameters: FresnelParameters;
  23862. private _useReflectionFresnelFromSpecular;
  23863. /**
  23864. * If true automatically deducts the fresnels values from the material specularity.
  23865. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23866. */
  23867. useReflectionFresnelFromSpecular: boolean;
  23868. private _useGlossinessFromSpecularMapAlpha;
  23869. /**
  23870. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  23871. */
  23872. useGlossinessFromSpecularMapAlpha: boolean;
  23873. private _maxSimultaneousLights;
  23874. /**
  23875. * Defines the maximum number of lights that can be used in the material
  23876. */
  23877. maxSimultaneousLights: number;
  23878. private _invertNormalMapX;
  23879. /**
  23880. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23881. */
  23882. invertNormalMapX: boolean;
  23883. private _invertNormalMapY;
  23884. /**
  23885. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23886. */
  23887. invertNormalMapY: boolean;
  23888. private _twoSidedLighting;
  23889. /**
  23890. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23891. */
  23892. twoSidedLighting: boolean;
  23893. /**
  23894. * Default configuration related to image processing available in the standard Material.
  23895. */
  23896. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23897. /**
  23898. * Gets the image processing configuration used either in this material.
  23899. */
  23900. /**
  23901. * Sets the Default image processing configuration used either in the this material.
  23902. *
  23903. * If sets to null, the scene one is in use.
  23904. */
  23905. imageProcessingConfiguration: ImageProcessingConfiguration;
  23906. /**
  23907. * Keep track of the image processing observer to allow dispose and replace.
  23908. */
  23909. private _imageProcessingObserver;
  23910. /**
  23911. * Attaches a new image processing configuration to the Standard Material.
  23912. * @param configuration
  23913. */
  23914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23915. /**
  23916. * Gets wether the color curves effect is enabled.
  23917. */
  23918. /**
  23919. * Sets wether the color curves effect is enabled.
  23920. */
  23921. cameraColorCurvesEnabled: boolean;
  23922. /**
  23923. * Gets wether the color grading effect is enabled.
  23924. */
  23925. /**
  23926. * Gets wether the color grading effect is enabled.
  23927. */
  23928. cameraColorGradingEnabled: boolean;
  23929. /**
  23930. * Gets wether tonemapping is enabled or not.
  23931. */
  23932. /**
  23933. * Sets wether tonemapping is enabled or not
  23934. */
  23935. cameraToneMappingEnabled: boolean;
  23936. /**
  23937. * The camera exposure used on this material.
  23938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23939. * This corresponds to a photographic exposure.
  23940. */
  23941. /**
  23942. * The camera exposure used on this material.
  23943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23944. * This corresponds to a photographic exposure.
  23945. */
  23946. cameraExposure: number;
  23947. /**
  23948. * Gets The camera contrast used on this material.
  23949. */
  23950. /**
  23951. * Sets The camera contrast used on this material.
  23952. */
  23953. cameraContrast: number;
  23954. /**
  23955. * Gets the Color Grading 2D Lookup Texture.
  23956. */
  23957. /**
  23958. * Sets the Color Grading 2D Lookup Texture.
  23959. */
  23960. cameraColorGradingTexture: Nullable<BaseTexture>;
  23961. /**
  23962. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23963. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23964. * 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;
  23965. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23966. */
  23967. /**
  23968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23970. * 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;
  23971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23972. */
  23973. cameraColorCurves: Nullable<ColorCurves>;
  23974. /**
  23975. * Custom callback helping to override the default shader used in the material.
  23976. */
  23977. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  23978. protected _renderTargets: SmartArray<RenderTargetTexture>;
  23979. protected _worldViewProjectionMatrix: Matrix;
  23980. protected _globalAmbientColor: Color3;
  23981. protected _useLogarithmicDepth: boolean;
  23982. /**
  23983. * Instantiates a new standard material.
  23984. * This is the default material used in Babylon. It is the best trade off between quality
  23985. * and performances.
  23986. * @see http://doc.babylonjs.com/babylon101/materials
  23987. * @param name Define the name of the material in the scene
  23988. * @param scene Define the scene the material belong to
  23989. */
  23990. constructor(name: string, scene: Scene);
  23991. /**
  23992. * Gets a boolean indicating that current material needs to register RTT
  23993. */
  23994. readonly hasRenderTargetTextures: boolean;
  23995. /**
  23996. * Gets the current class name of the material e.g. "StandardMaterial"
  23997. * Mainly use in serialization.
  23998. * @returns the class name
  23999. */
  24000. getClassName(): string;
  24001. /**
  24002. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24003. * You can try switching to logarithmic depth.
  24004. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24005. */
  24006. useLogarithmicDepth: boolean;
  24007. /**
  24008. * Specifies if the material will require alpha blending
  24009. * @returns a boolean specifying if alpha blending is needed
  24010. */
  24011. needAlphaBlending(): boolean;
  24012. /**
  24013. * Specifies if this material should be rendered in alpha test mode
  24014. * @returns a boolean specifying if an alpha test is needed.
  24015. */
  24016. needAlphaTesting(): boolean;
  24017. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24018. /**
  24019. * Get the texture used for alpha test purpose.
  24020. * @returns the diffuse texture in case of the standard material.
  24021. */
  24022. getAlphaTestTexture(): Nullable<BaseTexture>;
  24023. /**
  24024. * Get if the submesh is ready to be used and all its information available.
  24025. * Child classes can use it to update shaders
  24026. * @param mesh defines the mesh to check
  24027. * @param subMesh defines which submesh to check
  24028. * @param useInstances specifies that instances should be used
  24029. * @returns a boolean indicating that the submesh is ready or not
  24030. */
  24031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24032. /**
  24033. * Builds the material UBO layouts.
  24034. * Used internally during the effect preparation.
  24035. */
  24036. buildUniformLayout(): void;
  24037. /**
  24038. * Unbinds the material from the mesh
  24039. */
  24040. unbind(): void;
  24041. /**
  24042. * Binds the submesh to this material by preparing the effect and shader to draw
  24043. * @param world defines the world transformation matrix
  24044. * @param mesh defines the mesh containing the submesh
  24045. * @param subMesh defines the submesh to bind the material to
  24046. */
  24047. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24048. /**
  24049. * Get the list of animatables in the material.
  24050. * @returns the list of animatables object used in the material
  24051. */
  24052. getAnimatables(): IAnimatable[];
  24053. /**
  24054. * Gets the active textures from the material
  24055. * @returns an array of textures
  24056. */
  24057. getActiveTextures(): BaseTexture[];
  24058. /**
  24059. * Specifies if the material uses a texture
  24060. * @param texture defines the texture to check against the material
  24061. * @returns a boolean specifying if the material uses the texture
  24062. */
  24063. hasTexture(texture: BaseTexture): boolean;
  24064. /**
  24065. * Disposes the material
  24066. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24067. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24068. */
  24069. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24070. /**
  24071. * Makes a duplicate of the material, and gives it a new name
  24072. * @param name defines the new name for the duplicated material
  24073. * @returns the cloned material
  24074. */
  24075. clone(name: string): StandardMaterial;
  24076. /**
  24077. * Serializes this material in a JSON representation
  24078. * @returns the serialized material object
  24079. */
  24080. serialize(): any;
  24081. /**
  24082. * Creates a standard material from parsed material data
  24083. * @param source defines the JSON representation of the material
  24084. * @param scene defines the hosting scene
  24085. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24086. * @returns a new standard material
  24087. */
  24088. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24089. private static _DiffuseTextureEnabled;
  24090. /**
  24091. * Are diffuse textures enabled in the application.
  24092. */
  24093. static DiffuseTextureEnabled: boolean;
  24094. private static _AmbientTextureEnabled;
  24095. /**
  24096. * Are ambient textures enabled in the application.
  24097. */
  24098. static AmbientTextureEnabled: boolean;
  24099. private static _OpacityTextureEnabled;
  24100. /**
  24101. * Are opacity textures enabled in the application.
  24102. */
  24103. static OpacityTextureEnabled: boolean;
  24104. private static _ReflectionTextureEnabled;
  24105. /**
  24106. * Are reflection textures enabled in the application.
  24107. */
  24108. static ReflectionTextureEnabled: boolean;
  24109. private static _EmissiveTextureEnabled;
  24110. /**
  24111. * Are emissive textures enabled in the application.
  24112. */
  24113. static EmissiveTextureEnabled: boolean;
  24114. private static _SpecularTextureEnabled;
  24115. /**
  24116. * Are specular textures enabled in the application.
  24117. */
  24118. static SpecularTextureEnabled: boolean;
  24119. private static _BumpTextureEnabled;
  24120. /**
  24121. * Are bump textures enabled in the application.
  24122. */
  24123. static BumpTextureEnabled: boolean;
  24124. private static _LightmapTextureEnabled;
  24125. /**
  24126. * Are lightmap textures enabled in the application.
  24127. */
  24128. static LightmapTextureEnabled: boolean;
  24129. private static _RefractionTextureEnabled;
  24130. /**
  24131. * Are refraction textures enabled in the application.
  24132. */
  24133. static RefractionTextureEnabled: boolean;
  24134. private static _ColorGradingTextureEnabled;
  24135. /**
  24136. * Are color grading textures enabled in the application.
  24137. */
  24138. static ColorGradingTextureEnabled: boolean;
  24139. private static _FresnelEnabled;
  24140. /**
  24141. * Are fresnels enabled in the application.
  24142. */
  24143. static FresnelEnabled: boolean;
  24144. }
  24145. }
  24146. declare module BABYLON {
  24147. /**
  24148. * Uniform buffer objects.
  24149. *
  24150. * Handles blocks of uniform on the GPU.
  24151. *
  24152. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24153. *
  24154. * For more information, please refer to :
  24155. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24156. */
  24157. class UniformBuffer {
  24158. private _engine;
  24159. private _buffer;
  24160. private _data;
  24161. private _bufferData;
  24162. private _dynamic?;
  24163. private _uniformLocations;
  24164. private _uniformSizes;
  24165. private _uniformLocationPointer;
  24166. private _needSync;
  24167. private _noUBO;
  24168. private _currentEffect;
  24169. private static _MAX_UNIFORM_SIZE;
  24170. private static _tempBuffer;
  24171. /**
  24172. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  24173. * This is dynamic to allow compat with webgl 1 and 2.
  24174. * You will need to pass the name of the uniform as well as the value.
  24175. */
  24176. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  24177. /**
  24178. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  24179. * This is dynamic to allow compat with webgl 1 and 2.
  24180. * You will need to pass the name of the uniform as well as the value.
  24181. */
  24182. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  24183. /**
  24184. * Lambda to Update a single float in a uniform buffer.
  24185. * This is dynamic to allow compat with webgl 1 and 2.
  24186. * You will need to pass the name of the uniform as well as the value.
  24187. */
  24188. updateFloat: (name: string, x: number) => void;
  24189. /**
  24190. * Lambda to Update a vec2 of float in a uniform buffer.
  24191. * This is dynamic to allow compat with webgl 1 and 2.
  24192. * You will need to pass the name of the uniform as well as the value.
  24193. */
  24194. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  24195. /**
  24196. * Lambda to Update a vec3 of float in a uniform buffer.
  24197. * This is dynamic to allow compat with webgl 1 and 2.
  24198. * You will need to pass the name of the uniform as well as the value.
  24199. */
  24200. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  24201. /**
  24202. * Lambda to Update a vec4 of float in a uniform buffer.
  24203. * This is dynamic to allow compat with webgl 1 and 2.
  24204. * You will need to pass the name of the uniform as well as the value.
  24205. */
  24206. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  24207. /**
  24208. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  24209. * This is dynamic to allow compat with webgl 1 and 2.
  24210. * You will need to pass the name of the uniform as well as the value.
  24211. */
  24212. updateMatrix: (name: string, mat: Matrix) => void;
  24213. /**
  24214. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  24215. * This is dynamic to allow compat with webgl 1 and 2.
  24216. * You will need to pass the name of the uniform as well as the value.
  24217. */
  24218. updateVector3: (name: string, vector: Vector3) => void;
  24219. /**
  24220. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  24221. * This is dynamic to allow compat with webgl 1 and 2.
  24222. * You will need to pass the name of the uniform as well as the value.
  24223. */
  24224. updateVector4: (name: string, vector: Vector4) => void;
  24225. /**
  24226. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  24227. * This is dynamic to allow compat with webgl 1 and 2.
  24228. * You will need to pass the name of the uniform as well as the value.
  24229. */
  24230. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  24231. /**
  24232. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  24233. * This is dynamic to allow compat with webgl 1 and 2.
  24234. * You will need to pass the name of the uniform as well as the value.
  24235. */
  24236. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  24237. /**
  24238. * Instantiates a new Uniform buffer objects.
  24239. *
  24240. * Handles blocks of uniform on the GPU.
  24241. *
  24242. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24243. *
  24244. * For more information, please refer to :
  24245. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24246. * @param engine Define the engine the buffer is associated with
  24247. * @param data Define the data contained in the buffer
  24248. * @param dynamic Define if the buffer is updatable
  24249. */
  24250. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  24251. /**
  24252. * Indicates if the buffer is using the WebGL2 UBO implementation,
  24253. * or just falling back on setUniformXXX calls.
  24254. */
  24255. readonly useUbo: boolean;
  24256. /**
  24257. * Indicates if the WebGL underlying uniform buffer is in sync
  24258. * with the javascript cache data.
  24259. */
  24260. readonly isSync: boolean;
  24261. /**
  24262. * Indicates if the WebGL underlying uniform buffer is dynamic.
  24263. * Also, a dynamic UniformBuffer will disable cache verification and always
  24264. * update the underlying WebGL uniform buffer to the GPU.
  24265. * @returns if Dynamic, otherwise false
  24266. */
  24267. isDynamic(): boolean;
  24268. /**
  24269. * The data cache on JS side.
  24270. * @returns the underlying data as a float array
  24271. */
  24272. getData(): Float32Array;
  24273. /**
  24274. * The underlying WebGL Uniform buffer.
  24275. * @returns the webgl buffer
  24276. */
  24277. getBuffer(): Nullable<WebGLBuffer>;
  24278. /**
  24279. * std140 layout specifies how to align data within an UBO structure.
  24280. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  24281. * for specs.
  24282. */
  24283. private _fillAlignment;
  24284. /**
  24285. * Adds an uniform in the buffer.
  24286. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  24287. * for the layout to be correct !
  24288. * @param name Name of the uniform, as used in the uniform block in the shader.
  24289. * @param size Data size, or data directly.
  24290. */
  24291. addUniform(name: string, size: number | number[]): void;
  24292. /**
  24293. * Adds a Matrix 4x4 to the uniform buffer.
  24294. * @param name Name of the uniform, as used in the uniform block in the shader.
  24295. * @param mat A 4x4 matrix.
  24296. */
  24297. addMatrix(name: string, mat: Matrix): void;
  24298. /**
  24299. * Adds a vec2 to the uniform buffer.
  24300. * @param name Name of the uniform, as used in the uniform block in the shader.
  24301. * @param x Define the x component value of the vec2
  24302. * @param y Define the y component value of the vec2
  24303. */
  24304. addFloat2(name: string, x: number, y: number): void;
  24305. /**
  24306. * Adds a vec3 to the uniform buffer.
  24307. * @param name Name of the uniform, as used in the uniform block in the shader.
  24308. * @param x Define the x component value of the vec3
  24309. * @param y Define the y component value of the vec3
  24310. * @param z Define the z component value of the vec3
  24311. */
  24312. addFloat3(name: string, x: number, y: number, z: number): void;
  24313. /**
  24314. * Adds a vec3 to the uniform buffer.
  24315. * @param name Name of the uniform, as used in the uniform block in the shader.
  24316. * @param color Define the vec3 from a Color
  24317. */
  24318. addColor3(name: string, color: Color3): void;
  24319. /**
  24320. * Adds a vec4 to the uniform buffer.
  24321. * @param name Name of the uniform, as used in the uniform block in the shader.
  24322. * @param color Define the rgb components from a Color
  24323. * @param alpha Define the a component of the vec4
  24324. */
  24325. addColor4(name: string, color: Color3, alpha: number): void;
  24326. /**
  24327. * Adds a vec3 to the uniform buffer.
  24328. * @param name Name of the uniform, as used in the uniform block in the shader.
  24329. * @param vector Define the vec3 components from a Vector
  24330. */
  24331. addVector3(name: string, vector: Vector3): void;
  24332. /**
  24333. * Adds a Matrix 3x3 to the uniform buffer.
  24334. * @param name Name of the uniform, as used in the uniform block in the shader.
  24335. */
  24336. addMatrix3x3(name: string): void;
  24337. /**
  24338. * Adds a Matrix 2x2 to the uniform buffer.
  24339. * @param name Name of the uniform, as used in the uniform block in the shader.
  24340. */
  24341. addMatrix2x2(name: string): void;
  24342. /**
  24343. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  24344. */
  24345. create(): void;
  24346. /** @hidden */
  24347. _rebuild(): void;
  24348. /**
  24349. * Updates the WebGL Uniform Buffer on the GPU.
  24350. * If the `dynamic` flag is set to true, no cache comparison is done.
  24351. * Otherwise, the buffer will be updated only if the cache differs.
  24352. */
  24353. update(): void;
  24354. /**
  24355. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  24356. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24357. * @param data Define the flattened data
  24358. * @param size Define the size of the data.
  24359. */
  24360. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  24361. private _updateMatrix3x3ForUniform;
  24362. private _updateMatrix3x3ForEffect;
  24363. private _updateMatrix2x2ForEffect;
  24364. private _updateMatrix2x2ForUniform;
  24365. private _updateFloatForEffect;
  24366. private _updateFloatForUniform;
  24367. private _updateFloat2ForEffect;
  24368. private _updateFloat2ForUniform;
  24369. private _updateFloat3ForEffect;
  24370. private _updateFloat3ForUniform;
  24371. private _updateFloat4ForEffect;
  24372. private _updateFloat4ForUniform;
  24373. private _updateMatrixForEffect;
  24374. private _updateMatrixForUniform;
  24375. private _updateVector3ForEffect;
  24376. private _updateVector3ForUniform;
  24377. private _updateVector4ForEffect;
  24378. private _updateVector4ForUniform;
  24379. private _updateColor3ForEffect;
  24380. private _updateColor3ForUniform;
  24381. private _updateColor4ForEffect;
  24382. private _updateColor4ForUniform;
  24383. /**
  24384. * Sets a sampler uniform on the effect.
  24385. * @param name Define the name of the sampler.
  24386. * @param texture Define the texture to set in the sampler
  24387. */
  24388. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  24389. /**
  24390. * Directly updates the value of the uniform in the cache AND on the GPU.
  24391. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24392. * @param data Define the flattened data
  24393. */
  24394. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  24395. /**
  24396. * Binds this uniform buffer to an effect.
  24397. * @param effect Define the effect to bind the buffer to
  24398. * @param name Name of the uniform block in the shader.
  24399. */
  24400. bindToEffect(effect: Effect, name: string): void;
  24401. /**
  24402. * Disposes the uniform buffer.
  24403. */
  24404. dispose(): void;
  24405. }
  24406. }
  24407. declare module BABYLON {
  24408. /**
  24409. * Defines a target to use with MorphTargetManager
  24410. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24411. */
  24412. class MorphTarget implements IAnimatable {
  24413. /** defines the name of the target */
  24414. name: string;
  24415. /**
  24416. * Gets or sets the list of animations
  24417. */
  24418. animations: Animation[];
  24419. private _scene;
  24420. private _positions;
  24421. private _normals;
  24422. private _tangents;
  24423. private _influence;
  24424. /**
  24425. * Observable raised when the influence changes
  24426. */
  24427. onInfluenceChanged: Observable<boolean>;
  24428. /** @hidden */
  24429. _onDataLayoutChanged: Observable<void>;
  24430. /**
  24431. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24432. */
  24433. influence: number;
  24434. /**
  24435. * Gets or sets the id of the morph Target
  24436. */
  24437. id: string;
  24438. private _animationPropertiesOverride;
  24439. /**
  24440. * Gets or sets the animation properties override
  24441. */
  24442. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24443. /**
  24444. * Creates a new MorphTarget
  24445. * @param name defines the name of the target
  24446. * @param influence defines the influence to use
  24447. */
  24448. constructor(
  24449. /** defines the name of the target */
  24450. name: string, influence?: number, scene?: Nullable<Scene>);
  24451. /**
  24452. * Gets a boolean defining if the target contains position data
  24453. */
  24454. readonly hasPositions: boolean;
  24455. /**
  24456. * Gets a boolean defining if the target contains normal data
  24457. */
  24458. readonly hasNormals: boolean;
  24459. /**
  24460. * Gets a boolean defining if the target contains tangent data
  24461. */
  24462. readonly hasTangents: boolean;
  24463. /**
  24464. * Affects position data to this target
  24465. * @param data defines the position data to use
  24466. */
  24467. setPositions(data: Nullable<FloatArray>): void;
  24468. /**
  24469. * Gets the position data stored in this target
  24470. * @returns a FloatArray containing the position data (or null if not present)
  24471. */
  24472. getPositions(): Nullable<FloatArray>;
  24473. /**
  24474. * Affects normal data to this target
  24475. * @param data defines the normal data to use
  24476. */
  24477. setNormals(data: Nullable<FloatArray>): void;
  24478. /**
  24479. * Gets the normal data stored in this target
  24480. * @returns a FloatArray containing the normal data (or null if not present)
  24481. */
  24482. getNormals(): Nullable<FloatArray>;
  24483. /**
  24484. * Affects tangent data to this target
  24485. * @param data defines the tangent data to use
  24486. */
  24487. setTangents(data: Nullable<FloatArray>): void;
  24488. /**
  24489. * Gets the tangent data stored in this target
  24490. * @returns a FloatArray containing the tangent data (or null if not present)
  24491. */
  24492. getTangents(): Nullable<FloatArray>;
  24493. /**
  24494. * Serializes the current target into a Serialization object
  24495. * @returns the serialized object
  24496. */
  24497. serialize(): any;
  24498. /**
  24499. * Returns the string "MorphTarget"
  24500. * @returns "MorphTarget"
  24501. */
  24502. getClassName(): string;
  24503. /**
  24504. * Creates a new target from serialized data
  24505. * @param serializationObject defines the serialized data to use
  24506. * @returns a new MorphTarget
  24507. */
  24508. static Parse(serializationObject: any): MorphTarget;
  24509. /**
  24510. * Creates a MorphTarget from mesh data
  24511. * @param mesh defines the source mesh
  24512. * @param name defines the name to use for the new target
  24513. * @param influence defines the influence to attach to the target
  24514. * @returns a new MorphTarget
  24515. */
  24516. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24517. }
  24518. }
  24519. declare module BABYLON {
  24520. /**
  24521. * This class is used to deform meshes using morphing between different targets
  24522. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24523. */
  24524. class MorphTargetManager {
  24525. private _targets;
  24526. private _targetInfluenceChangedObservers;
  24527. private _targetDataLayoutChangedObservers;
  24528. private _activeTargets;
  24529. private _scene;
  24530. private _influences;
  24531. private _supportsNormals;
  24532. private _supportsTangents;
  24533. private _vertexCount;
  24534. private _uniqueId;
  24535. private _tempInfluences;
  24536. /**
  24537. * Creates a new MorphTargetManager
  24538. * @param scene defines the current scene
  24539. */
  24540. constructor(scene?: Nullable<Scene>);
  24541. /**
  24542. * Gets the unique ID of this manager
  24543. */
  24544. readonly uniqueId: number;
  24545. /**
  24546. * Gets the number of vertices handled by this manager
  24547. */
  24548. readonly vertexCount: number;
  24549. /**
  24550. * Gets a boolean indicating if this manager supports morphing of normals
  24551. */
  24552. readonly supportsNormals: boolean;
  24553. /**
  24554. * Gets a boolean indicating if this manager supports morphing of tangents
  24555. */
  24556. readonly supportsTangents: boolean;
  24557. /**
  24558. * Gets the number of targets stored in this manager
  24559. */
  24560. readonly numTargets: number;
  24561. /**
  24562. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24563. */
  24564. readonly numInfluencers: number;
  24565. /**
  24566. * Gets the list of influences (one per target)
  24567. */
  24568. readonly influences: Float32Array;
  24569. /**
  24570. * Gets the active target at specified index. An active target is a target with an influence > 0
  24571. * @param index defines the index to check
  24572. * @returns the requested target
  24573. */
  24574. getActiveTarget(index: number): MorphTarget;
  24575. /**
  24576. * Gets the target at specified index
  24577. * @param index defines the index to check
  24578. * @returns the requested target
  24579. */
  24580. getTarget(index: number): MorphTarget;
  24581. /**
  24582. * Add a new target to this manager
  24583. * @param target defines the target to add
  24584. */
  24585. addTarget(target: MorphTarget): void;
  24586. /**
  24587. * Removes a target from the manager
  24588. * @param target defines the target to remove
  24589. */
  24590. removeTarget(target: MorphTarget): void;
  24591. /**
  24592. * Serializes the current manager into a Serialization object
  24593. * @returns the serialized object
  24594. */
  24595. serialize(): any;
  24596. private _syncActiveTargets;
  24597. /**
  24598. * Syncrhonize the targets with all the meshes using this morph target manager
  24599. */
  24600. synchronize(): void;
  24601. /**
  24602. * Creates a new MorphTargetManager from serialized data
  24603. * @param serializationObject defines the serialized data
  24604. * @param scene defines the hosting scene
  24605. * @returns the new MorphTargetManager
  24606. */
  24607. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24608. }
  24609. }
  24610. declare module BABYLON {
  24611. /**
  24612. * Class used to store all common mesh properties
  24613. */
  24614. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24615. /** No occlusion */
  24616. static OCCLUSION_TYPE_NONE: number;
  24617. /** Occlusion set to optimisitic */
  24618. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24619. /** Occlusion set to strict */
  24620. static OCCLUSION_TYPE_STRICT: number;
  24621. /** Use an accurante occlusion algorithm */
  24622. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24623. /** Use a conservative occlusion algorithm */
  24624. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24625. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24626. * Test order :
  24627. * Is the bounding sphere outside the frustum ?
  24628. * If not, are the bounding box vertices outside the frustum ?
  24629. * It not, then the cullable object is in the frustum.
  24630. */
  24631. static readonly CULLINGSTRATEGY_STANDARD: number;
  24632. /** Culling strategy : Bounding Sphere Only.
  24633. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24634. * It's also less accurate than the standard because some not visible objects can still be selected.
  24635. * Test : is the bounding sphere outside the frustum ?
  24636. * If not, then the cullable object is in the frustum.
  24637. */
  24638. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24639. /** Culling strategy : Optimistic Inclusion.
  24640. * This in an inclusion test first, then the standard exclusion test.
  24641. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24642. * 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.
  24643. * Anyway, it's as accurate as the standard strategy.
  24644. * Test :
  24645. * Is the cullable object bounding sphere center in the frustum ?
  24646. * If not, apply the default culling strategy.
  24647. */
  24648. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24649. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24650. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24651. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24652. * 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.
  24653. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24654. * Test :
  24655. * Is the cullable object bounding sphere center in the frustum ?
  24656. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24657. */
  24658. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24659. /**
  24660. * No billboard
  24661. */
  24662. static readonly BILLBOARDMODE_NONE: number;
  24663. /** Billboard on X axis */
  24664. static readonly BILLBOARDMODE_X: number;
  24665. /** Billboard on Y axis */
  24666. static readonly BILLBOARDMODE_Y: number;
  24667. /** Billboard on Z axis */
  24668. static readonly BILLBOARDMODE_Z: number;
  24669. /** Billboard on all axes */
  24670. static readonly BILLBOARDMODE_ALL: number;
  24671. private _facetData;
  24672. /**
  24673. * The culling strategy to use to check whether the mesh must be rendered or not.
  24674. * This value can be changed at any time and will be used on the next render mesh selection.
  24675. * The possible values are :
  24676. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24677. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24678. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24679. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24680. * Please read each static variable documentation to get details about the culling process.
  24681. * */
  24682. cullingStrategy: number;
  24683. /**
  24684. * Gets the number of facets in the mesh
  24685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24686. */
  24687. readonly facetNb: number;
  24688. /**
  24689. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24691. */
  24692. partitioningSubdivisions: number;
  24693. /**
  24694. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24695. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24697. */
  24698. partitioningBBoxRatio: number;
  24699. /**
  24700. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24701. * Works only for updatable meshes.
  24702. * Doesn't work with multi-materials
  24703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24704. */
  24705. mustDepthSortFacets: boolean;
  24706. /**
  24707. * The location (Vector3) where the facet depth sort must be computed from.
  24708. * By default, the active camera position.
  24709. * Used only when facet depth sort is enabled
  24710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24711. */
  24712. facetDepthSortFrom: Vector3;
  24713. /**
  24714. * gets a boolean indicating if facetData is enabled
  24715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24716. */
  24717. readonly isFacetDataEnabled: boolean;
  24718. /** @hidden */
  24719. _updateNonUniformScalingState(value: boolean): boolean;
  24720. /**
  24721. * An event triggered when this mesh collides with another one
  24722. */
  24723. onCollideObservable: Observable<AbstractMesh>;
  24724. private _onCollideObserver;
  24725. /** Set a function to call when this mesh collides with another one */
  24726. onCollide: () => void;
  24727. /**
  24728. * An event triggered when the collision's position changes
  24729. */
  24730. onCollisionPositionChangeObservable: Observable<Vector3>;
  24731. private _onCollisionPositionChangeObserver;
  24732. /** Set a function to call when the collision's position changes */
  24733. onCollisionPositionChange: () => void;
  24734. /**
  24735. * An event triggered when material is changed
  24736. */
  24737. onMaterialChangedObservable: Observable<AbstractMesh>;
  24738. /**
  24739. * Gets or sets the orientation for POV movement & rotation
  24740. */
  24741. definedFacingForward: boolean;
  24742. /** @hidden */
  24743. _occlusionQuery: Nullable<WebGLQuery>;
  24744. private _visibility;
  24745. /**
  24746. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24747. */
  24748. /**
  24749. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24750. */
  24751. visibility: number;
  24752. /** Gets or sets the alpha index used to sort transparent meshes
  24753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24754. */
  24755. alphaIndex: number;
  24756. /**
  24757. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24758. */
  24759. isVisible: boolean;
  24760. /**
  24761. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24762. */
  24763. isPickable: boolean;
  24764. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24765. showSubMeshesBoundingBox: boolean;
  24766. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24767. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24768. */
  24769. isBlocker: boolean;
  24770. /**
  24771. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24772. */
  24773. enablePointerMoveEvents: boolean;
  24774. /**
  24775. * Specifies the rendering group id for this mesh (0 by default)
  24776. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24777. */
  24778. renderingGroupId: number;
  24779. private _material;
  24780. /** Gets or sets current material */
  24781. material: Nullable<Material>;
  24782. private _receiveShadows;
  24783. /**
  24784. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24785. * @see http://doc.babylonjs.com/babylon101/shadows
  24786. */
  24787. receiveShadows: boolean;
  24788. /** Defines color to use when rendering outline */
  24789. outlineColor: Color3;
  24790. /** Define width to use when rendering outline */
  24791. outlineWidth: number;
  24792. /** Defines color to use when rendering overlay */
  24793. overlayColor: Color3;
  24794. /** Defines alpha to use when rendering overlay */
  24795. overlayAlpha: number;
  24796. private _hasVertexAlpha;
  24797. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24798. hasVertexAlpha: boolean;
  24799. private _useVertexColors;
  24800. /** 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) */
  24801. useVertexColors: boolean;
  24802. private _computeBonesUsingShaders;
  24803. /**
  24804. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24805. */
  24806. computeBonesUsingShaders: boolean;
  24807. private _numBoneInfluencers;
  24808. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24809. numBoneInfluencers: number;
  24810. private _applyFog;
  24811. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24812. applyFog: boolean;
  24813. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24814. useOctreeForRenderingSelection: boolean;
  24815. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24816. useOctreeForPicking: boolean;
  24817. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24818. useOctreeForCollisions: boolean;
  24819. private _layerMask;
  24820. /**
  24821. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24822. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24823. */
  24824. layerMask: number;
  24825. /**
  24826. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24827. */
  24828. alwaysSelectAsActiveMesh: boolean;
  24829. /**
  24830. * Gets or sets the current action manager
  24831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24832. */
  24833. actionManager: Nullable<ActionManager>;
  24834. private _checkCollisions;
  24835. private _collisionMask;
  24836. private _collisionGroup;
  24837. /**
  24838. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24840. */
  24841. ellipsoid: Vector3;
  24842. /**
  24843. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24845. */
  24846. ellipsoidOffset: Vector3;
  24847. private _collider;
  24848. private _oldPositionForCollisions;
  24849. private _diffPositionForCollisions;
  24850. /**
  24851. * Gets or sets a collision mask used to mask collisions (default is -1).
  24852. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24853. */
  24854. collisionMask: number;
  24855. /**
  24856. * Gets or sets the current collision group mask (-1 by default).
  24857. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24858. */
  24859. collisionGroup: number;
  24860. /**
  24861. * Defines edge width used when edgesRenderer is enabled
  24862. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24863. */
  24864. edgesWidth: number;
  24865. /**
  24866. * Defines edge color used when edgesRenderer is enabled
  24867. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24868. */
  24869. edgesColor: Color4;
  24870. /** @hidden */
  24871. _edgesRenderer: Nullable<IEdgesRenderer>;
  24872. /** @hidden */
  24873. _masterMesh: Nullable<AbstractMesh>;
  24874. /** @hidden */
  24875. _boundingInfo: Nullable<BoundingInfo>;
  24876. /** @hidden */
  24877. _renderId: number;
  24878. /**
  24879. * Gets or sets the list of subMeshes
  24880. * @see http://doc.babylonjs.com/how_to/multi_materials
  24881. */
  24882. subMeshes: SubMesh[];
  24883. /** @hidden */
  24884. _intersectionsInProgress: AbstractMesh[];
  24885. /** @hidden */
  24886. _unIndexed: boolean;
  24887. /** @hidden */
  24888. _lightSources: Light[];
  24889. /** @hidden */
  24890. readonly _positions: Nullable<Vector3[]>;
  24891. /** @hidden */
  24892. _waitingActions: any;
  24893. /** @hidden */
  24894. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24895. private _skeleton;
  24896. /** @hidden */
  24897. _bonesTransformMatrices: Nullable<Float32Array>;
  24898. /**
  24899. * Gets or sets a skeleton to apply skining transformations
  24900. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24901. */
  24902. skeleton: Nullable<Skeleton>;
  24903. /**
  24904. * An event triggered when the mesh is rebuilt.
  24905. */
  24906. onRebuildObservable: Observable<AbstractMesh>;
  24907. /**
  24908. * Creates a new AbstractMesh
  24909. * @param name defines the name of the mesh
  24910. * @param scene defines the hosting scene
  24911. */
  24912. constructor(name: string, scene?: Nullable<Scene>);
  24913. /**
  24914. * Returns the string "AbstractMesh"
  24915. * @returns "AbstractMesh"
  24916. */
  24917. getClassName(): string;
  24918. /**
  24919. * Gets a string representation of the current mesh
  24920. * @param fullDetails defines a boolean indicating if full details must be included
  24921. * @returns a string representation of the current mesh
  24922. */
  24923. toString(fullDetails?: boolean): string;
  24924. /** @hidden */
  24925. _rebuild(): void;
  24926. /** @hidden */
  24927. _resyncLightSources(): void;
  24928. /** @hidden */
  24929. _resyncLighSource(light: Light): void;
  24930. /** @hidden */
  24931. _unBindEffect(): void;
  24932. /** @hidden */
  24933. _removeLightSource(light: Light): void;
  24934. private _markSubMeshesAsDirty;
  24935. /** @hidden */
  24936. _markSubMeshesAsLightDirty(): void;
  24937. /** @hidden */
  24938. _markSubMeshesAsAttributesDirty(): void;
  24939. /** @hidden */
  24940. _markSubMeshesAsMiscDirty(): void;
  24941. /**
  24942. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24943. */
  24944. scaling: Vector3;
  24945. /**
  24946. * Returns true if the mesh is blocked. Implemented by child classes
  24947. */
  24948. readonly isBlocked: boolean;
  24949. /**
  24950. * Returns the mesh itself by default. Implemented by child classes
  24951. * @param camera defines the camera to use to pick the right LOD level
  24952. * @returns the currentAbstractMesh
  24953. */
  24954. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24955. /**
  24956. * Returns 0 by default. Implemented by child classes
  24957. * @returns an integer
  24958. */
  24959. getTotalVertices(): number;
  24960. /**
  24961. * Returns a positive integer : the total number of indices in this mesh geometry.
  24962. * @returns the numner of indices or zero if the mesh has no geometry.
  24963. */
  24964. getTotalIndices(): number;
  24965. /**
  24966. * Returns null by default. Implemented by child classes
  24967. * @returns null
  24968. */
  24969. getIndices(): Nullable<IndicesArray>;
  24970. /**
  24971. * Returns the array of the requested vertex data kind. Implemented by child classes
  24972. * @param kind defines the vertex data kind to use
  24973. * @returns null
  24974. */
  24975. getVerticesData(kind: string): Nullable<FloatArray>;
  24976. /**
  24977. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24978. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24979. * Note that a new underlying VertexBuffer object is created each call.
  24980. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24981. * @param kind defines vertex data kind:
  24982. * * BABYLON.VertexBuffer.PositionKind
  24983. * * BABYLON.VertexBuffer.UVKind
  24984. * * BABYLON.VertexBuffer.UV2Kind
  24985. * * BABYLON.VertexBuffer.UV3Kind
  24986. * * BABYLON.VertexBuffer.UV4Kind
  24987. * * BABYLON.VertexBuffer.UV5Kind
  24988. * * BABYLON.VertexBuffer.UV6Kind
  24989. * * BABYLON.VertexBuffer.ColorKind
  24990. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24991. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24992. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24993. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24994. * @param data defines the data source
  24995. * @param updatable defines if the data must be flagged as updatable (or static)
  24996. * @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
  24997. * @returns the current mesh
  24998. */
  24999. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25000. /**
  25001. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25002. * If the mesh has no geometry, it is simply returned as it is.
  25003. * @param kind defines vertex data kind:
  25004. * * BABYLON.VertexBuffer.PositionKind
  25005. * * BABYLON.VertexBuffer.UVKind
  25006. * * BABYLON.VertexBuffer.UV2Kind
  25007. * * BABYLON.VertexBuffer.UV3Kind
  25008. * * BABYLON.VertexBuffer.UV4Kind
  25009. * * BABYLON.VertexBuffer.UV5Kind
  25010. * * BABYLON.VertexBuffer.UV6Kind
  25011. * * BABYLON.VertexBuffer.ColorKind
  25012. * * BABYLON.VertexBuffer.MatricesIndicesKind
  25013. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25014. * * BABYLON.VertexBuffer.MatricesWeightsKind
  25015. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25016. * @param data defines the data source
  25017. * @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
  25018. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25019. * @returns the current mesh
  25020. */
  25021. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25022. /**
  25023. * Sets the mesh indices,
  25024. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25025. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25026. * @param totalVertices Defines the total number of vertices
  25027. * @returns the current mesh
  25028. */
  25029. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25030. /**
  25031. * Gets a boolean indicating if specific vertex data is present
  25032. * @param kind defines the vertex data kind to use
  25033. * @returns true is data kind is present
  25034. */
  25035. isVerticesDataPresent(kind: string): boolean;
  25036. /**
  25037. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25038. * @returns a BoundingInfo
  25039. */
  25040. getBoundingInfo(): BoundingInfo;
  25041. /**
  25042. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25043. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25044. * @returns the current mesh
  25045. */
  25046. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25047. /**
  25048. * Overwrite the current bounding info
  25049. * @param boundingInfo defines the new bounding info
  25050. * @returns the current mesh
  25051. */
  25052. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25053. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25054. readonly useBones: boolean;
  25055. /** @hidden */
  25056. _preActivate(): void;
  25057. /** @hidden */
  25058. _preActivateForIntermediateRendering(renderId: number): void;
  25059. /** @hidden */
  25060. _activate(renderId: number): void;
  25061. /**
  25062. * Gets the current world matrix
  25063. * @returns a Matrix
  25064. */
  25065. getWorldMatrix(): Matrix;
  25066. /** @hidden */
  25067. _getWorldMatrixDeterminant(): number;
  25068. /**
  25069. * Perform relative position change from the point of view of behind the front of the mesh.
  25070. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25071. * Supports definition of mesh facing forward or backward
  25072. * @param amountRight defines the distance on the right axis
  25073. * @param amountUp defines the distance on the up axis
  25074. * @param amountForward defines the distance on the forward axis
  25075. * @returns the current mesh
  25076. */
  25077. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25078. /**
  25079. * Calculate relative position change from the point of view of behind the front of the mesh.
  25080. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25081. * Supports definition of mesh facing forward or backward
  25082. * @param amountRight defines the distance on the right axis
  25083. * @param amountUp defines the distance on the up axis
  25084. * @param amountForward defines the distance on the forward axis
  25085. * @returns the new displacement vector
  25086. */
  25087. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25088. /**
  25089. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25090. * Supports definition of mesh facing forward or backward
  25091. * @param flipBack defines the flip
  25092. * @param twirlClockwise defines the twirl
  25093. * @param tiltRight defines the tilt
  25094. * @returns the current mesh
  25095. */
  25096. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25097. /**
  25098. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25099. * Supports definition of mesh facing forward or backward.
  25100. * @param flipBack defines the flip
  25101. * @param twirlClockwise defines the twirl
  25102. * @param tiltRight defines the tilt
  25103. * @returns the new rotation vector
  25104. */
  25105. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25106. /**
  25107. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25108. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25109. * @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
  25110. * @returns the new bounding vectors
  25111. */
  25112. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25113. min: Vector3;
  25114. max: Vector3;
  25115. };
  25116. /**
  25117. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25118. * This means the mesh underlying bounding box and sphere are recomputed.
  25119. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25120. * @returns the current mesh
  25121. */
  25122. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25123. /** @hidden */
  25124. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25125. /** @hidden */
  25126. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25127. /** @hidden */
  25128. _updateBoundingInfo(): AbstractMesh;
  25129. /** @hidden */
  25130. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25131. /** @hidden */
  25132. protected _afterComputeWorldMatrix(): void;
  25133. /**
  25134. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25135. * A mesh is in the frustum if its bounding box intersects the frustum
  25136. * @param frustumPlanes defines the frustum to test
  25137. * @returns true if the mesh is in the frustum planes
  25138. */
  25139. isInFrustum(frustumPlanes: Plane[]): boolean;
  25140. /**
  25141. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25142. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25143. * @param frustumPlanes defines the frustum to test
  25144. * @returns true if the mesh is completely in the frustum planes
  25145. */
  25146. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25147. /**
  25148. * True if the mesh intersects another mesh or a SolidParticle object
  25149. * @param mesh defines a target mesh or SolidParticle to test
  25150. * @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)
  25151. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25152. * @returns true if there is an intersection
  25153. */
  25154. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25155. /**
  25156. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25157. * @param point defines the point to test
  25158. * @returns true if there is an intersection
  25159. */
  25160. intersectsPoint(point: Vector3): boolean;
  25161. /**
  25162. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25164. */
  25165. checkCollisions: boolean;
  25166. /**
  25167. * Gets Collider object used to compute collisions (not physics)
  25168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25169. */
  25170. readonly collider: Collider;
  25171. /**
  25172. * Move the mesh using collision engine
  25173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25174. * @param displacement defines the requested displacement vector
  25175. * @returns the current mesh
  25176. */
  25177. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25178. private _onCollisionPositionChange;
  25179. /** @hidden */
  25180. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25181. /** @hidden */
  25182. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25183. /** @hidden */
  25184. _checkCollision(collider: Collider): AbstractMesh;
  25185. /** @hidden */
  25186. _generatePointsArray(): boolean;
  25187. /**
  25188. * Checks if the passed Ray intersects with the mesh
  25189. * @param ray defines the ray to use
  25190. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25191. * @returns the picking info
  25192. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25193. */
  25194. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25195. /**
  25196. * Clones the current mesh
  25197. * @param name defines the mesh name
  25198. * @param newParent defines the new mesh parent
  25199. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25200. * @returns the new mesh
  25201. */
  25202. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25203. /**
  25204. * Disposes all the submeshes of the current meshnp
  25205. * @returns the current mesh
  25206. */
  25207. releaseSubMeshes(): AbstractMesh;
  25208. /**
  25209. * Releases resources associated with this abstract mesh.
  25210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25212. */
  25213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25214. /**
  25215. * Adds the passed mesh as a child to the current mesh
  25216. * @param mesh defines the child mesh
  25217. * @returns the current mesh
  25218. */
  25219. addChild(mesh: AbstractMesh): AbstractMesh;
  25220. /**
  25221. * Removes the passed mesh from the current mesh children list
  25222. * @param mesh defines the child mesh
  25223. * @returns the current mesh
  25224. */
  25225. removeChild(mesh: AbstractMesh): AbstractMesh;
  25226. /** @hidden */
  25227. private _initFacetData;
  25228. /**
  25229. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25230. * This method can be called within the render loop.
  25231. * 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
  25232. * @returns the current mesh
  25233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25234. */
  25235. updateFacetData(): AbstractMesh;
  25236. /**
  25237. * Returns the facetLocalNormals array.
  25238. * The normals are expressed in the mesh local spac
  25239. * @returns an array of Vector3
  25240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25241. */
  25242. getFacetLocalNormals(): Vector3[];
  25243. /**
  25244. * Returns the facetLocalPositions array.
  25245. * The facet positions are expressed in the mesh local space
  25246. * @returns an array of Vector3
  25247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25248. */
  25249. getFacetLocalPositions(): Vector3[];
  25250. /**
  25251. * Returns the facetLocalPartioning array
  25252. * @returns an array of array of numbers
  25253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25254. */
  25255. getFacetLocalPartitioning(): number[][];
  25256. /**
  25257. * Returns the i-th facet position in the world system.
  25258. * This method allocates a new Vector3 per call
  25259. * @param i defines the facet index
  25260. * @returns a new Vector3
  25261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25262. */
  25263. getFacetPosition(i: number): Vector3;
  25264. /**
  25265. * Sets the reference Vector3 with the i-th facet position in the world system
  25266. * @param i defines the facet index
  25267. * @param ref defines the target vector
  25268. * @returns the current mesh
  25269. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25270. */
  25271. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25272. /**
  25273. * Returns the i-th facet normal in the world system.
  25274. * This method allocates a new Vector3 per call
  25275. * @param i defines the facet index
  25276. * @returns a new Vector3
  25277. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25278. */
  25279. getFacetNormal(i: number): Vector3;
  25280. /**
  25281. * Sets the reference Vector3 with the i-th facet normal in the world system
  25282. * @param i defines the facet index
  25283. * @param ref defines the target vector
  25284. * @returns the current mesh
  25285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25286. */
  25287. getFacetNormalToRef(i: number, ref: Vector3): this;
  25288. /**
  25289. * 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)
  25290. * @param x defines x coordinate
  25291. * @param y defines y coordinate
  25292. * @param z defines z coordinate
  25293. * @returns the array of facet indexes
  25294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25295. */
  25296. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25297. /**
  25298. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25299. * @param projected sets as the (x,y,z) world projection on the facet
  25300. * @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
  25301. * @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
  25302. * @param x defines x coordinate
  25303. * @param y defines y coordinate
  25304. * @param z defines z coordinate
  25305. * @returns the face index if found (or null instead)
  25306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25307. */
  25308. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25309. /**
  25310. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25311. * @param projected sets as the (x,y,z) local projection on the facet
  25312. * @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
  25313. * @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
  25314. * @param x defines x coordinate
  25315. * @param y defines y coordinate
  25316. * @param z defines z coordinate
  25317. * @returns the face index if found (or null instead)
  25318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25319. */
  25320. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25321. /**
  25322. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25323. * @returns the parameters
  25324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25325. */
  25326. getFacetDataParameters(): any;
  25327. /**
  25328. * Disables the feature FacetData and frees the related memory
  25329. * @returns the current mesh
  25330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25331. */
  25332. disableFacetData(): AbstractMesh;
  25333. /**
  25334. * Updates the AbstractMesh indices array
  25335. * @param indices defines the data source
  25336. * @returns the current mesh
  25337. */
  25338. updateIndices(indices: IndicesArray): AbstractMesh;
  25339. /**
  25340. * Creates new normals data for the mesh
  25341. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25342. * @returns the current mesh
  25343. */
  25344. createNormals(updatable: boolean): AbstractMesh;
  25345. /**
  25346. * Align the mesh with a normal
  25347. * @param normal defines the normal to use
  25348. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25349. * @returns the current mesh
  25350. */
  25351. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25352. /** @hidden */
  25353. _checkOcclusionQuery(): boolean;
  25354. }
  25355. }
  25356. declare module BABYLON {
  25357. /**
  25358. * Class used to store data that will be store in GPU memory
  25359. */
  25360. class Buffer {
  25361. private _engine;
  25362. private _buffer;
  25363. /** @hidden */
  25364. _data: Nullable<DataArray>;
  25365. private _updatable;
  25366. private _instanced;
  25367. /**
  25368. * Gets the byte stride.
  25369. */
  25370. readonly byteStride: number;
  25371. /**
  25372. * Constructor
  25373. * @param engine the engine
  25374. * @param data the data to use for this buffer
  25375. * @param updatable whether the data is updatable
  25376. * @param stride the stride (optional)
  25377. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25378. * @param instanced whether the buffer is instanced (optional)
  25379. * @param useBytes set to true if the stride in in bytes (optional)
  25380. */
  25381. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25382. /**
  25383. * Create a new VertexBuffer based on the current buffer
  25384. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25385. * @param offset defines offset in the buffer (0 by default)
  25386. * @param size defines the size in floats of attributes (position is 3 for instance)
  25387. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25388. * @param instanced defines if the vertex buffer contains indexed data
  25389. * @param useBytes defines if the offset and stride are in bytes
  25390. * @returns the new vertex buffer
  25391. */
  25392. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25393. /**
  25394. * Gets a boolean indicating if the Buffer is updatable?
  25395. * @returns true if the buffer is updatable
  25396. */
  25397. isUpdatable(): boolean;
  25398. /**
  25399. * Gets current buffer's data
  25400. * @returns a DataArray or null
  25401. */
  25402. getData(): Nullable<DataArray>;
  25403. /**
  25404. * Gets underlying native buffer
  25405. * @returns underlying native buffer
  25406. */
  25407. getBuffer(): Nullable<WebGLBuffer>;
  25408. /**
  25409. * Gets the stride in float32 units (i.e. byte stride / 4).
  25410. * May not be an integer if the byte stride is not divisible by 4.
  25411. * DEPRECATED. Use byteStride instead.
  25412. * @returns the stride in float32 units
  25413. */
  25414. getStrideSize(): number;
  25415. /**
  25416. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25417. * @param data defines the data to store
  25418. */
  25419. create(data?: Nullable<DataArray>): void;
  25420. /** @hidden */
  25421. _rebuild(): void;
  25422. /**
  25423. * Update current buffer data
  25424. * @param data defines the data to store
  25425. */
  25426. update(data: DataArray): void;
  25427. /**
  25428. * Updates the data directly.
  25429. * @param data the new data
  25430. * @param offset the new offset
  25431. * @param vertexCount the vertex count (optional)
  25432. * @param useBytes set to true if the offset is in bytes
  25433. */
  25434. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25435. /**
  25436. * Release all resources
  25437. */
  25438. dispose(): void;
  25439. }
  25440. }
  25441. declare module BABYLON {
  25442. /**
  25443. * Class for building Constructive Solid Geometry
  25444. */
  25445. class CSG {
  25446. private polygons;
  25447. /**
  25448. * The world matrix
  25449. */
  25450. matrix: Matrix;
  25451. /**
  25452. * Stores the position
  25453. */
  25454. position: Vector3;
  25455. /**
  25456. * Stores the rotation
  25457. */
  25458. rotation: Vector3;
  25459. /**
  25460. * Stores the rotation quaternion
  25461. */
  25462. rotationQuaternion: Nullable<Quaternion>;
  25463. /**
  25464. * Stores the scaling vector
  25465. */
  25466. scaling: Vector3;
  25467. /**
  25468. * Convert the BABYLON.Mesh to BABYLON.CSG
  25469. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25470. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25471. */
  25472. static FromMesh(mesh: Mesh): CSG;
  25473. /**
  25474. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25475. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25476. */
  25477. private static FromPolygons;
  25478. /**
  25479. * Clones, or makes a deep copy, of the BABYLON.CSG
  25480. * @returns A new BABYLON.CSG
  25481. */
  25482. clone(): CSG;
  25483. /**
  25484. * Unions this CSG with another CSG
  25485. * @param csg The CSG to union against this CSG
  25486. * @returns The unioned CSG
  25487. */
  25488. union(csg: CSG): CSG;
  25489. /**
  25490. * Unions this CSG with another CSG in place
  25491. * @param csg The CSG to union against this CSG
  25492. */
  25493. unionInPlace(csg: CSG): void;
  25494. /**
  25495. * Subtracts this CSG with another CSG
  25496. * @param csg The CSG to subtract against this CSG
  25497. * @returns A new BABYLON.CSG
  25498. */
  25499. subtract(csg: CSG): CSG;
  25500. /**
  25501. * Subtracts this CSG with another CSG in place
  25502. * @param csg The CSG to subtact against this CSG
  25503. */
  25504. subtractInPlace(csg: CSG): void;
  25505. /**
  25506. * Intersect this CSG with another CSG
  25507. * @param csg The CSG to intersect against this CSG
  25508. * @returns A new BABYLON.CSG
  25509. */
  25510. intersect(csg: CSG): CSG;
  25511. /**
  25512. * Intersects this CSG with another CSG in place
  25513. * @param csg The CSG to intersect against this CSG
  25514. */
  25515. intersectInPlace(csg: CSG): void;
  25516. /**
  25517. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25518. * not modified.
  25519. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25520. */
  25521. inverse(): CSG;
  25522. /**
  25523. * Inverses the BABYLON.CSG in place
  25524. */
  25525. inverseInPlace(): void;
  25526. /**
  25527. * This is used to keep meshes transformations so they can be restored
  25528. * when we build back a Babylon Mesh
  25529. * NB : All CSG operations are performed in world coordinates
  25530. * @param csg The BABYLON.CSG to copy the transform attributes from
  25531. * @returns This BABYLON.CSG
  25532. */
  25533. copyTransformAttributes(csg: CSG): CSG;
  25534. /**
  25535. * Build Raw mesh from CSG
  25536. * Coordinates here are in world space
  25537. * @param name The name of the mesh geometry
  25538. * @param scene The BABYLON.Scene
  25539. * @param keepSubMeshes Specifies if the submeshes should be kept
  25540. * @returns A new BABYLON.Mesh
  25541. */
  25542. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25543. /**
  25544. * Build Mesh from CSG taking material and transforms into account
  25545. * @param name The name of the BABYLON.Mesh
  25546. * @param material The material of the BABYLON.Mesh
  25547. * @param scene The BABYLON.Scene
  25548. * @param keepSubMeshes Specifies if submeshes should be kept
  25549. * @returns The new BABYLON.Mesh
  25550. */
  25551. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25552. }
  25553. }
  25554. declare module BABYLON {
  25555. /**
  25556. * Class used to store geometry data (vertex buffers + index buffer)
  25557. */
  25558. class Geometry implements IGetSetVerticesData {
  25559. /**
  25560. * Gets or sets the ID of the geometry
  25561. */
  25562. id: string;
  25563. /**
  25564. * Gets or sets the unique ID of the geometry
  25565. */
  25566. uniqueId: number;
  25567. /**
  25568. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25569. */
  25570. delayLoadState: number;
  25571. /**
  25572. * Gets the file containing the data to load when running in delay load state
  25573. */
  25574. delayLoadingFile: Nullable<string>;
  25575. /**
  25576. * Callback called when the geometry is updated
  25577. */
  25578. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25579. private _scene;
  25580. private _engine;
  25581. private _meshes;
  25582. private _totalVertices;
  25583. /** @hidden */
  25584. _indices: IndicesArray;
  25585. /** @hidden */
  25586. _vertexBuffers: {
  25587. [key: string]: VertexBuffer;
  25588. };
  25589. private _isDisposed;
  25590. private _extend;
  25591. private _boundingBias;
  25592. /** @hidden */
  25593. _delayInfo: Array<string>;
  25594. private _indexBuffer;
  25595. private _indexBufferIsUpdatable;
  25596. /** @hidden */
  25597. _boundingInfo: Nullable<BoundingInfo>;
  25598. /** @hidden */
  25599. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25600. /** @hidden */
  25601. _softwareSkinningFrameId: number;
  25602. private _vertexArrayObjects;
  25603. private _updatable;
  25604. /** @hidden */
  25605. _positions: Nullable<Vector3[]>;
  25606. /**
  25607. * 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
  25608. */
  25609. /**
  25610. * 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
  25611. */
  25612. boundingBias: Vector2;
  25613. /**
  25614. * Static function used to attach a new empty geometry to a mesh
  25615. * @param mesh defines the mesh to attach the geometry to
  25616. * @returns the new Geometry
  25617. */
  25618. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25619. /**
  25620. * Creates a new geometry
  25621. * @param id defines the unique ID
  25622. * @param scene defines the hosting scene
  25623. * @param vertexData defines the VertexData used to get geometry data
  25624. * @param updatable defines if geometry must be updatable (false by default)
  25625. * @param mesh defines the mesh that will be associated with the geometry
  25626. */
  25627. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25628. /**
  25629. * Gets the current extend of the geometry
  25630. */
  25631. readonly extend: {
  25632. minimum: Vector3;
  25633. maximum: Vector3;
  25634. };
  25635. /**
  25636. * Gets the hosting scene
  25637. * @returns the hosting Scene
  25638. */
  25639. getScene(): Scene;
  25640. /**
  25641. * Gets the hosting engine
  25642. * @returns the hosting Engine
  25643. */
  25644. getEngine(): Engine;
  25645. /**
  25646. * Defines if the geometry is ready to use
  25647. * @returns true if the geometry is ready to be used
  25648. */
  25649. isReady(): boolean;
  25650. /**
  25651. * Gets a value indicating that the geometry should not be serialized
  25652. */
  25653. readonly doNotSerialize: boolean;
  25654. /** @hidden */
  25655. _rebuild(): void;
  25656. /**
  25657. * Affects all geometry data in one call
  25658. * @param vertexData defines the geometry data
  25659. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25660. */
  25661. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25662. /**
  25663. * Set specific vertex data
  25664. * @param kind defines the data kind (Position, normal, etc...)
  25665. * @param data defines the vertex data to use
  25666. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25667. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25668. */
  25669. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25670. /**
  25671. * Removes a specific vertex data
  25672. * @param kind defines the data kind (Position, normal, etc...)
  25673. */
  25674. removeVerticesData(kind: string): void;
  25675. /**
  25676. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25677. * @param buffer defines the vertex buffer to use
  25678. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25679. */
  25680. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25681. /**
  25682. * Update a specific vertex buffer
  25683. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25684. * It will do nothing if the buffer is not updatable
  25685. * @param kind defines the data kind (Position, normal, etc...)
  25686. * @param data defines the data to use
  25687. * @param offset defines the offset in the target buffer where to store the data
  25688. * @param useBytes set to true if the offset is in bytes
  25689. */
  25690. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25691. /**
  25692. * Update a specific vertex buffer
  25693. * This function will create a new buffer if the current one is not updatable
  25694. * @param kind defines the data kind (Position, normal, etc...)
  25695. * @param data defines the data to use
  25696. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25697. */
  25698. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25699. private _updateBoundingInfo;
  25700. /** @hidden */
  25701. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25702. /**
  25703. * Gets total number of vertices
  25704. * @returns the total number of vertices
  25705. */
  25706. getTotalVertices(): number;
  25707. /**
  25708. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25709. * @param kind defines the data kind (Position, normal, etc...)
  25710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25712. * @returns a float array containing vertex data
  25713. */
  25714. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25715. /**
  25716. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25717. * @param kind defines the data kind (Position, normal, etc...)
  25718. * @returns true if the vertex buffer with the specified kind is updatable
  25719. */
  25720. isVertexBufferUpdatable(kind: string): boolean;
  25721. /**
  25722. * Gets a specific vertex buffer
  25723. * @param kind defines the data kind (Position, normal, etc...)
  25724. * @returns a VertexBuffer
  25725. */
  25726. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25727. /**
  25728. * Returns all vertex buffers
  25729. * @return an object holding all vertex buffers indexed by kind
  25730. */
  25731. getVertexBuffers(): Nullable<{
  25732. [key: string]: VertexBuffer;
  25733. }>;
  25734. /**
  25735. * Gets a boolean indicating if specific vertex buffer is present
  25736. * @param kind defines the data kind (Position, normal, etc...)
  25737. * @returns true if data is present
  25738. */
  25739. isVerticesDataPresent(kind: string): boolean;
  25740. /**
  25741. * Gets a list of all attached data kinds (Position, normal, etc...)
  25742. * @returns a list of string containing all kinds
  25743. */
  25744. getVerticesDataKinds(): string[];
  25745. /**
  25746. * Update index buffer
  25747. * @param indices defines the indices to store in the index buffer
  25748. * @param offset defines the offset in the target buffer where to store the data
  25749. */
  25750. updateIndices(indices: IndicesArray, offset?: number): void;
  25751. /**
  25752. * Creates a new index buffer
  25753. * @param indices defines the indices to store in the index buffer
  25754. * @param totalVertices defines the total number of vertices (could be null)
  25755. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25756. */
  25757. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25758. /**
  25759. * Return the total number of indices
  25760. * @returns the total number of indices
  25761. */
  25762. getTotalIndices(): number;
  25763. /**
  25764. * Gets the index buffer array
  25765. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25767. * @returns the index buffer array
  25768. */
  25769. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25770. /**
  25771. * Gets the index buffer
  25772. * @return the index buffer
  25773. */
  25774. getIndexBuffer(): Nullable<WebGLBuffer>;
  25775. /** @hidden */
  25776. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25777. /**
  25778. * Release the associated resources for a specific mesh
  25779. * @param mesh defines the source mesh
  25780. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25781. */
  25782. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25783. /**
  25784. * Apply current geometry to a given mesh
  25785. * @param mesh defines the mesh to apply geometry to
  25786. */
  25787. applyToMesh(mesh: Mesh): void;
  25788. private _updateExtend;
  25789. private _applyToMesh;
  25790. private notifyUpdate;
  25791. /**
  25792. * Load the geometry if it was flagged as delay loaded
  25793. * @param scene defines the hosting scene
  25794. * @param onLoaded defines a callback called when the geometry is loaded
  25795. */
  25796. load(scene: Scene, onLoaded?: () => void): void;
  25797. private _queueLoad;
  25798. /**
  25799. * Invert the geometry to move from a right handed system to a left handed one.
  25800. */
  25801. toLeftHanded(): void;
  25802. /** @hidden */
  25803. _resetPointsArrayCache(): void;
  25804. /** @hidden */
  25805. _generatePointsArray(): boolean;
  25806. /**
  25807. * Gets a value indicating if the geometry is disposed
  25808. * @returns true if the geometry was disposed
  25809. */
  25810. isDisposed(): boolean;
  25811. private _disposeVertexArrayObjects;
  25812. /**
  25813. * Free all associated resources
  25814. */
  25815. dispose(): void;
  25816. /**
  25817. * Clone the current geometry into a new geometry
  25818. * @param id defines the unique ID of the new geometry
  25819. * @returns a new geometry object
  25820. */
  25821. copy(id: string): Geometry;
  25822. /**
  25823. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25824. * @return a JSON representation of the current geometry data (without the vertices data)
  25825. */
  25826. serialize(): any;
  25827. private toNumberArray;
  25828. /**
  25829. * Serialize all vertices data into a JSON oject
  25830. * @returns a JSON representation of the current geometry data
  25831. */
  25832. serializeVerticeData(): any;
  25833. /**
  25834. * Extracts a clone of a mesh geometry
  25835. * @param mesh defines the source mesh
  25836. * @param id defines the unique ID of the new geometry object
  25837. * @returns the new geometry object
  25838. */
  25839. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25840. /**
  25841. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25842. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25843. * Be aware Math.random() could cause collisions, but:
  25844. * "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"
  25845. * @returns a string containing a new GUID
  25846. */
  25847. static RandomId(): string;
  25848. /** @hidden */
  25849. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25850. private static _CleanMatricesWeights;
  25851. /**
  25852. * Create a new geometry from persisted data (Using .babylon file format)
  25853. * @param parsedVertexData defines the persisted data
  25854. * @param scene defines the hosting scene
  25855. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25856. * @returns the new geometry object
  25857. */
  25858. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25859. }
  25860. /**
  25861. * Abstract class used to provide common services for all typed geometries
  25862. * @hidden
  25863. */
  25864. class _PrimitiveGeometry extends Geometry {
  25865. private _canBeRegenerated;
  25866. private _beingRegenerated;
  25867. /**
  25868. * Creates a new typed geometry
  25869. * @param id defines the unique ID of the geometry
  25870. * @param scene defines the hosting scene
  25871. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25872. * @param mesh defines the hosting mesh (can be null)
  25873. */
  25874. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25875. /**
  25876. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25877. * @returns true if the geometry can be regenerated
  25878. */
  25879. canBeRegenerated(): boolean;
  25880. /**
  25881. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25882. */
  25883. regenerate(): void;
  25884. /**
  25885. * Clone the geometry
  25886. * @param id defines the unique ID of the new geometry
  25887. * @returns the new geometry
  25888. */
  25889. asNewGeometry(id: string): Geometry;
  25890. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25891. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25892. /** @hidden */
  25893. _regenerateVertexData(): VertexData;
  25894. copy(id: string): Geometry;
  25895. serialize(): any;
  25896. }
  25897. /**
  25898. * Creates a ribbon geometry
  25899. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25900. */
  25901. class RibbonGeometry extends _PrimitiveGeometry {
  25902. /**
  25903. * Defines the array of paths to use
  25904. */
  25905. pathArray: Vector3[][];
  25906. /**
  25907. * Defines if the last and first points of each path in your pathArray must be joined
  25908. */
  25909. closeArray: boolean;
  25910. /**
  25911. * Defines if the last and first points of each path in your pathArray must be joined
  25912. */
  25913. closePath: boolean;
  25914. /**
  25915. * Defines the offset between points
  25916. */
  25917. offset: number;
  25918. /**
  25919. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25920. */
  25921. side: number;
  25922. /**
  25923. * Creates a ribbon geometry
  25924. * @param id defines the unique ID of the geometry
  25925. * @param scene defines the hosting scene
  25926. * @param pathArray defines the array of paths to use
  25927. * @param closeArray defines if the last path and the first path must be joined
  25928. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25929. * @param offset defines the offset between points
  25930. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25931. * @param mesh defines the hosting mesh (can be null)
  25932. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25933. */
  25934. constructor(id: string, scene: Scene,
  25935. /**
  25936. * Defines the array of paths to use
  25937. */
  25938. pathArray: Vector3[][],
  25939. /**
  25940. * Defines if the last and first points of each path in your pathArray must be joined
  25941. */
  25942. closeArray: boolean,
  25943. /**
  25944. * Defines if the last and first points of each path in your pathArray must be joined
  25945. */
  25946. closePath: boolean,
  25947. /**
  25948. * Defines the offset between points
  25949. */
  25950. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25951. /**
  25952. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25953. */
  25954. side?: number);
  25955. /** @hidden */
  25956. _regenerateVertexData(): VertexData;
  25957. copy(id: string): Geometry;
  25958. }
  25959. /**
  25960. * Creates a box geometry
  25961. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25962. */
  25963. class BoxGeometry extends _PrimitiveGeometry {
  25964. /**
  25965. * Defines the zise of the box (width, height and depth are the same)
  25966. */
  25967. size: number;
  25968. /**
  25969. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25970. */
  25971. side: number;
  25972. /**
  25973. * Creates a box geometry
  25974. * @param id defines the unique ID of the geometry
  25975. * @param scene defines the hosting scene
  25976. * @param size defines the zise of the box (width, height and depth are the same)
  25977. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25978. * @param mesh defines the hosting mesh (can be null)
  25979. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25980. */
  25981. constructor(id: string, scene: Scene,
  25982. /**
  25983. * Defines the zise of the box (width, height and depth are the same)
  25984. */
  25985. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25986. /**
  25987. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25988. */
  25989. side?: number);
  25990. /** @hidden */
  25991. _regenerateVertexData(): VertexData;
  25992. copy(id: string): Geometry;
  25993. serialize(): any;
  25994. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25995. }
  25996. /**
  25997. * Creates a sphere geometry
  25998. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25999. */
  26000. class SphereGeometry extends _PrimitiveGeometry {
  26001. /**
  26002. * Defines the number of segments to use to create the sphere
  26003. */
  26004. segments: number;
  26005. /**
  26006. * Defines the diameter of the sphere
  26007. */
  26008. diameter: number;
  26009. /**
  26010. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26011. */
  26012. side: number;
  26013. /**
  26014. * Create a new sphere geometry
  26015. * @param id defines the unique ID of the geometry
  26016. * @param scene defines the hosting scene
  26017. * @param segments defines the number of segments to use to create the sphere
  26018. * @param diameter defines the diameter of the sphere
  26019. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26020. * @param mesh defines the hosting mesh (can be null)
  26021. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26022. */
  26023. constructor(id: string, scene: Scene,
  26024. /**
  26025. * Defines the number of segments to use to create the sphere
  26026. */
  26027. segments: number,
  26028. /**
  26029. * Defines the diameter of the sphere
  26030. */
  26031. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26032. /**
  26033. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26034. */
  26035. side?: number);
  26036. /** @hidden */
  26037. _regenerateVertexData(): VertexData;
  26038. copy(id: string): Geometry;
  26039. serialize(): any;
  26040. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  26041. }
  26042. /**
  26043. * Creates a disc geometry
  26044. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26045. */
  26046. class DiscGeometry extends _PrimitiveGeometry {
  26047. /**
  26048. * Defines the radius of the disc
  26049. */
  26050. radius: number;
  26051. /**
  26052. * Defines the tesselation factor to apply to the disc
  26053. */
  26054. tessellation: number;
  26055. /**
  26056. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26057. */
  26058. side: number;
  26059. /**
  26060. * Creates a new disc geometry
  26061. * @param id defines the unique ID of the geometry
  26062. * @param scene defines the hosting scene
  26063. * @param radius defines the radius of the disc
  26064. * @param tessellation defines the tesselation factor to apply to the disc
  26065. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26066. * @param mesh defines the hosting mesh (can be null)
  26067. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26068. */
  26069. constructor(id: string, scene: Scene,
  26070. /**
  26071. * Defines the radius of the disc
  26072. */
  26073. radius: number,
  26074. /**
  26075. * Defines the tesselation factor to apply to the disc
  26076. */
  26077. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26078. /**
  26079. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26080. */
  26081. side?: number);
  26082. /** @hidden */
  26083. _regenerateVertexData(): VertexData;
  26084. copy(id: string): Geometry;
  26085. }
  26086. /**
  26087. * Creates a new cylinder geometry
  26088. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  26089. */
  26090. class CylinderGeometry extends _PrimitiveGeometry {
  26091. /**
  26092. * Defines the height of the cylinder
  26093. */
  26094. height: number;
  26095. /**
  26096. * Defines the diameter of the cylinder's top cap
  26097. */
  26098. diameterTop: number;
  26099. /**
  26100. * Defines the diameter of the cylinder's bottom cap
  26101. */
  26102. diameterBottom: number;
  26103. /**
  26104. * Defines the tessellation factor to apply to the cylinder
  26105. */
  26106. tessellation: number;
  26107. /**
  26108. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26109. */
  26110. subdivisions: number;
  26111. /**
  26112. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26113. */
  26114. side: number;
  26115. /**
  26116. * Creates a new cylinder geometry
  26117. * @param id defines the unique ID of the geometry
  26118. * @param scene defines the hosting scene
  26119. * @param height defines the height of the cylinder
  26120. * @param diameterTop defines the diameter of the cylinder's top cap
  26121. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  26122. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  26123. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  26124. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26125. * @param mesh defines the hosting mesh (can be null)
  26126. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26127. */
  26128. constructor(id: string, scene: Scene,
  26129. /**
  26130. * Defines the height of the cylinder
  26131. */
  26132. height: number,
  26133. /**
  26134. * Defines the diameter of the cylinder's top cap
  26135. */
  26136. diameterTop: number,
  26137. /**
  26138. * Defines the diameter of the cylinder's bottom cap
  26139. */
  26140. diameterBottom: number,
  26141. /**
  26142. * Defines the tessellation factor to apply to the cylinder
  26143. */
  26144. tessellation: number,
  26145. /**
  26146. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26147. */
  26148. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26149. /**
  26150. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26151. */
  26152. side?: number);
  26153. /** @hidden */
  26154. _regenerateVertexData(): VertexData;
  26155. copy(id: string): Geometry;
  26156. serialize(): any;
  26157. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  26158. }
  26159. /**
  26160. * Creates a new torus geometry
  26161. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  26162. */
  26163. class TorusGeometry extends _PrimitiveGeometry {
  26164. /**
  26165. * Defines the diameter of the torus
  26166. */
  26167. diameter: number;
  26168. /**
  26169. * Defines the thickness of the torus (ie. internal diameter)
  26170. */
  26171. thickness: number;
  26172. /**
  26173. * Defines the tesselation factor to apply to the torus
  26174. */
  26175. tessellation: number;
  26176. /**
  26177. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26178. */
  26179. side: number;
  26180. /**
  26181. * Creates a new torus geometry
  26182. * @param id defines the unique ID of the geometry
  26183. * @param scene defines the hosting scene
  26184. * @param diameter defines the diameter of the torus
  26185. * @param thickness defines the thickness of the torus (ie. internal diameter)
  26186. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  26187. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26188. * @param mesh defines the hosting mesh (can be null)
  26189. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26190. */
  26191. constructor(id: string, scene: Scene,
  26192. /**
  26193. * Defines the diameter of the torus
  26194. */
  26195. diameter: number,
  26196. /**
  26197. * Defines the thickness of the torus (ie. internal diameter)
  26198. */
  26199. thickness: number,
  26200. /**
  26201. * Defines the tesselation factor to apply to the torus
  26202. */
  26203. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26204. /**
  26205. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26206. */
  26207. side?: number);
  26208. /** @hidden */
  26209. _regenerateVertexData(): VertexData;
  26210. copy(id: string): Geometry;
  26211. serialize(): any;
  26212. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  26213. }
  26214. /**
  26215. * Creates a new ground geometry
  26216. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  26217. */
  26218. class GroundGeometry extends _PrimitiveGeometry {
  26219. /**
  26220. * Defines the width of the ground
  26221. */
  26222. width: number;
  26223. /**
  26224. * Defines the height of the ground
  26225. */
  26226. height: number;
  26227. /**
  26228. * Defines the subdivisions to apply to the ground
  26229. */
  26230. subdivisions: number;
  26231. /**
  26232. * Creates a new ground geometry
  26233. * @param id defines the unique ID of the geometry
  26234. * @param scene defines the hosting scene
  26235. * @param width defines the width of the ground
  26236. * @param height defines the height of the ground
  26237. * @param subdivisions defines the subdivisions to apply to the ground
  26238. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26239. * @param mesh defines the hosting mesh (can be null)
  26240. */
  26241. constructor(id: string, scene: Scene,
  26242. /**
  26243. * Defines the width of the ground
  26244. */
  26245. width: number,
  26246. /**
  26247. * Defines the height of the ground
  26248. */
  26249. height: number,
  26250. /**
  26251. * Defines the subdivisions to apply to the ground
  26252. */
  26253. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26254. /** @hidden */
  26255. _regenerateVertexData(): VertexData;
  26256. copy(id: string): Geometry;
  26257. serialize(): any;
  26258. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  26259. }
  26260. /**
  26261. * Creates a tiled ground geometry
  26262. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  26263. */
  26264. class TiledGroundGeometry extends _PrimitiveGeometry {
  26265. /**
  26266. * Defines the minimum value on X axis
  26267. */
  26268. xmin: number;
  26269. /**
  26270. * Defines the minimum value on Z axis
  26271. */
  26272. zmin: number;
  26273. /**
  26274. * Defines the maximum value on X axis
  26275. */
  26276. xmax: number;
  26277. /**
  26278. * Defines the maximum value on Z axis
  26279. */
  26280. zmax: number;
  26281. /**
  26282. * Defines the subdivisions to apply to the ground
  26283. */
  26284. subdivisions: {
  26285. w: number;
  26286. h: number;
  26287. };
  26288. /**
  26289. * Defines the precision to use when computing the tiles
  26290. */
  26291. precision: {
  26292. w: number;
  26293. h: number;
  26294. };
  26295. /**
  26296. * Creates a tiled ground geometry
  26297. * @param id defines the unique ID of the geometry
  26298. * @param scene defines the hosting scene
  26299. * @param xmin defines the minimum value on X axis
  26300. * @param zmin defines the minimum value on Z axis
  26301. * @param xmax defines the maximum value on X axis
  26302. * @param zmax defines the maximum value on Z axis
  26303. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26304. * @param precision defines the precision to use when computing the tiles
  26305. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26306. * @param mesh defines the hosting mesh (can be null)
  26307. */
  26308. constructor(id: string, scene: Scene,
  26309. /**
  26310. * Defines the minimum value on X axis
  26311. */
  26312. xmin: number,
  26313. /**
  26314. * Defines the minimum value on Z axis
  26315. */
  26316. zmin: number,
  26317. /**
  26318. * Defines the maximum value on X axis
  26319. */
  26320. xmax: number,
  26321. /**
  26322. * Defines the maximum value on Z axis
  26323. */
  26324. zmax: number,
  26325. /**
  26326. * Defines the subdivisions to apply to the ground
  26327. */
  26328. subdivisions: {
  26329. w: number;
  26330. h: number;
  26331. },
  26332. /**
  26333. * Defines the precision to use when computing the tiles
  26334. */
  26335. precision: {
  26336. w: number;
  26337. h: number;
  26338. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26339. /** @hidden */
  26340. _regenerateVertexData(): VertexData;
  26341. copy(id: string): Geometry;
  26342. }
  26343. /**
  26344. * Creates a plane geometry
  26345. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26346. */
  26347. class PlaneGeometry extends _PrimitiveGeometry {
  26348. /**
  26349. * Defines the size of the plane (width === height)
  26350. */
  26351. size: number;
  26352. /**
  26353. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26354. */
  26355. side: number;
  26356. /**
  26357. * Creates a plane geometry
  26358. * @param id defines the unique ID of the geometry
  26359. * @param scene defines the hosting scene
  26360. * @param size defines the size of the plane (width === height)
  26361. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26362. * @param mesh defines the hosting mesh (can be null)
  26363. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26364. */
  26365. constructor(id: string, scene: Scene,
  26366. /**
  26367. * Defines the size of the plane (width === height)
  26368. */
  26369. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26370. /**
  26371. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26372. */
  26373. side?: number);
  26374. /** @hidden */
  26375. _regenerateVertexData(): VertexData;
  26376. copy(id: string): Geometry;
  26377. serialize(): any;
  26378. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26379. }
  26380. /**
  26381. * Creates a torus knot geometry
  26382. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26383. */
  26384. class TorusKnotGeometry extends _PrimitiveGeometry {
  26385. /**
  26386. * Defines the radius of the torus knot
  26387. */
  26388. radius: number;
  26389. /**
  26390. * Defines the thickness of the torus knot tube
  26391. */
  26392. tube: number;
  26393. /**
  26394. * Defines the number of radial segments
  26395. */
  26396. radialSegments: number;
  26397. /**
  26398. * Defines the number of tubular segments
  26399. */
  26400. tubularSegments: number;
  26401. /**
  26402. * Defines the first number of windings
  26403. */
  26404. p: number;
  26405. /**
  26406. * Defines the second number of windings
  26407. */
  26408. q: number;
  26409. /**
  26410. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26411. */
  26412. side: number;
  26413. /**
  26414. * Creates a torus knot geometry
  26415. * @param id defines the unique ID of the geometry
  26416. * @param scene defines the hosting scene
  26417. * @param radius defines the radius of the torus knot
  26418. * @param tube defines the thickness of the torus knot tube
  26419. * @param radialSegments defines the number of radial segments
  26420. * @param tubularSegments defines the number of tubular segments
  26421. * @param p defines the first number of windings
  26422. * @param q defines the second number of windings
  26423. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26424. * @param mesh defines the hosting mesh (can be null)
  26425. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26426. */
  26427. constructor(id: string, scene: Scene,
  26428. /**
  26429. * Defines the radius of the torus knot
  26430. */
  26431. radius: number,
  26432. /**
  26433. * Defines the thickness of the torus knot tube
  26434. */
  26435. tube: number,
  26436. /**
  26437. * Defines the number of radial segments
  26438. */
  26439. radialSegments: number,
  26440. /**
  26441. * Defines the number of tubular segments
  26442. */
  26443. tubularSegments: number,
  26444. /**
  26445. * Defines the first number of windings
  26446. */
  26447. p: number,
  26448. /**
  26449. * Defines the second number of windings
  26450. */
  26451. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26452. /**
  26453. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26454. */
  26455. side?: number);
  26456. /** @hidden */
  26457. _regenerateVertexData(): VertexData;
  26458. copy(id: string): Geometry;
  26459. serialize(): any;
  26460. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26461. }
  26462. }
  26463. declare module BABYLON {
  26464. /**
  26465. * Mesh representing the gorund
  26466. */
  26467. class GroundMesh extends Mesh {
  26468. /** If octree should be generated */
  26469. generateOctree: boolean;
  26470. private _heightQuads;
  26471. /** @hidden */
  26472. _subdivisionsX: number;
  26473. /** @hidden */
  26474. _subdivisionsY: number;
  26475. /** @hidden */
  26476. _width: number;
  26477. /** @hidden */
  26478. _height: number;
  26479. /** @hidden */
  26480. _minX: number;
  26481. /** @hidden */
  26482. _maxX: number;
  26483. /** @hidden */
  26484. _minZ: number;
  26485. /** @hidden */
  26486. _maxZ: number;
  26487. constructor(name: string, scene: Scene);
  26488. /**
  26489. * "GroundMesh"
  26490. * @returns "GroundMesh"
  26491. */
  26492. getClassName(): string;
  26493. /**
  26494. * The minimum of x and y subdivisions
  26495. */
  26496. readonly subdivisions: number;
  26497. /**
  26498. * X subdivisions
  26499. */
  26500. readonly subdivisionsX: number;
  26501. /**
  26502. * Y subdivisions
  26503. */
  26504. readonly subdivisionsY: number;
  26505. /**
  26506. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26507. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26508. * @param chunksCount the number of subdivisions for x and y
  26509. * @param octreeBlocksSize (Default: 32)
  26510. */
  26511. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26512. /**
  26513. * Returns a height (y) value in the Worl system :
  26514. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26515. * @param x x coordinate
  26516. * @param z z coordinate
  26517. * @returns the ground y position if (x, z) are outside the ground surface.
  26518. */
  26519. getHeightAtCoordinates(x: number, z: number): number;
  26520. /**
  26521. * Returns a normalized vector (Vector3) orthogonal to the ground
  26522. * at the ground coordinates (x, z) expressed in the World system.
  26523. * @param x x coordinate
  26524. * @param z z coordinate
  26525. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26526. */
  26527. getNormalAtCoordinates(x: number, z: number): Vector3;
  26528. /**
  26529. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26530. * at the ground coordinates (x, z) expressed in the World system.
  26531. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26532. * @param x x coordinate
  26533. * @param z z coordinate
  26534. * @param ref vector to store the result
  26535. * @returns the GroundMesh.
  26536. */
  26537. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26538. /**
  26539. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26540. * if the ground has been updated.
  26541. * This can be used in the render loop.
  26542. * @returns the GroundMesh.
  26543. */
  26544. updateCoordinateHeights(): GroundMesh;
  26545. private _getFacetAt;
  26546. private _initHeightQuads;
  26547. private _computeHeightQuads;
  26548. /**
  26549. * Serializes this ground mesh
  26550. * @param serializationObject object to write serialization to
  26551. */
  26552. serialize(serializationObject: any): void;
  26553. /**
  26554. * Parses a serialized ground mesh
  26555. * @param parsedMesh the serialized mesh
  26556. * @param scene the scene to create the ground mesh in
  26557. * @returns the created ground mesh
  26558. */
  26559. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26560. }
  26561. }
  26562. declare module BABYLON {
  26563. /**
  26564. * Creates an instance based on a source mesh.
  26565. */
  26566. class InstancedMesh extends AbstractMesh {
  26567. private _sourceMesh;
  26568. private _currentLOD;
  26569. /** @hidden */
  26570. _indexInSourceMeshInstanceArray: number;
  26571. constructor(name: string, source: Mesh);
  26572. /**
  26573. * Returns the string "InstancedMesh".
  26574. */
  26575. getClassName(): string;
  26576. /**
  26577. * If the source mesh receives shadows
  26578. */
  26579. readonly receiveShadows: boolean;
  26580. /**
  26581. * The material of the source mesh
  26582. */
  26583. readonly material: Nullable<Material>;
  26584. /**
  26585. * Visibility of the source mesh
  26586. */
  26587. readonly visibility: number;
  26588. /**
  26589. * Skeleton of the source mesh
  26590. */
  26591. readonly skeleton: Nullable<Skeleton>;
  26592. /**
  26593. * Rendering ground id of the source mesh
  26594. */
  26595. renderingGroupId: number;
  26596. /**
  26597. * Returns the total number of vertices (integer).
  26598. */
  26599. getTotalVertices(): number;
  26600. /**
  26601. * Returns a positive integer : the total number of indices in this mesh geometry.
  26602. * @returns the numner of indices or zero if the mesh has no geometry.
  26603. */
  26604. getTotalIndices(): number;
  26605. /**
  26606. * The source mesh of the instance
  26607. */
  26608. readonly sourceMesh: Mesh;
  26609. /**
  26610. * Is this node ready to be used/rendered
  26611. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26612. * @return {boolean} is it ready
  26613. */
  26614. isReady(completeCheck?: boolean): boolean;
  26615. /**
  26616. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26617. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26618. * @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.
  26619. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26620. */
  26621. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26622. /**
  26623. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26624. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26625. * The `data` are either a numeric array either a Float32Array.
  26626. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26627. * 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).
  26628. * Note that a new underlying VertexBuffer object is created each call.
  26629. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26630. *
  26631. * Possible `kind` values :
  26632. * - BABYLON.VertexBuffer.PositionKind
  26633. * - BABYLON.VertexBuffer.UVKind
  26634. * - BABYLON.VertexBuffer.UV2Kind
  26635. * - BABYLON.VertexBuffer.UV3Kind
  26636. * - BABYLON.VertexBuffer.UV4Kind
  26637. * - BABYLON.VertexBuffer.UV5Kind
  26638. * - BABYLON.VertexBuffer.UV6Kind
  26639. * - BABYLON.VertexBuffer.ColorKind
  26640. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26641. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26642. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26643. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26644. *
  26645. * Returns the Mesh.
  26646. */
  26647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26648. /**
  26649. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26650. * If the mesh has no geometry, it is simply returned as it is.
  26651. * The `data` are either a numeric array either a Float32Array.
  26652. * No new underlying VertexBuffer object is created.
  26653. * 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.
  26654. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26655. *
  26656. * Possible `kind` values :
  26657. * - BABYLON.VertexBuffer.PositionKind
  26658. * - BABYLON.VertexBuffer.UVKind
  26659. * - BABYLON.VertexBuffer.UV2Kind
  26660. * - BABYLON.VertexBuffer.UV3Kind
  26661. * - BABYLON.VertexBuffer.UV4Kind
  26662. * - BABYLON.VertexBuffer.UV5Kind
  26663. * - BABYLON.VertexBuffer.UV6Kind
  26664. * - BABYLON.VertexBuffer.ColorKind
  26665. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26666. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26667. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26668. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26669. *
  26670. * Returns the Mesh.
  26671. */
  26672. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26673. /**
  26674. * Sets the mesh indices.
  26675. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26677. * This method creates a new index buffer each call.
  26678. * Returns the Mesh.
  26679. */
  26680. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26681. /**
  26682. * Boolean : True if the mesh owns the requested kind of data.
  26683. */
  26684. isVerticesDataPresent(kind: string): boolean;
  26685. /**
  26686. * Returns an array of indices (IndicesArray).
  26687. */
  26688. getIndices(): Nullable<IndicesArray>;
  26689. readonly _positions: Nullable<Vector3[]>;
  26690. /**
  26691. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26692. * This means the mesh underlying bounding box and sphere are recomputed.
  26693. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26694. * @returns the current mesh
  26695. */
  26696. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26697. /** @hidden */
  26698. _preActivate(): InstancedMesh;
  26699. /** @hidden */
  26700. _activate(renderId: number): InstancedMesh;
  26701. /**
  26702. * Returns the current associated LOD AbstractMesh.
  26703. */
  26704. getLOD(camera: Camera): AbstractMesh;
  26705. /** @hidden */
  26706. _syncSubMeshes(): InstancedMesh;
  26707. /** @hidden */
  26708. _generatePointsArray(): boolean;
  26709. /**
  26710. * Creates a new InstancedMesh from the current mesh.
  26711. * - name (string) : the cloned mesh name
  26712. * - newParent (optional Node) : the optional Node to parent the clone to.
  26713. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26714. *
  26715. * Returns the clone.
  26716. */
  26717. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26718. /**
  26719. * Disposes the InstancedMesh.
  26720. * Returns nothing.
  26721. */
  26722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26723. }
  26724. }
  26725. declare module BABYLON {
  26726. /**
  26727. * Line mesh
  26728. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26729. */
  26730. class LinesMesh extends Mesh {
  26731. /**
  26732. * If vertex color should be applied to the mesh
  26733. */
  26734. useVertexColor?: boolean | undefined;
  26735. /**
  26736. * If vertex alpha should be applied to the mesh
  26737. */
  26738. useVertexAlpha?: boolean | undefined;
  26739. /**
  26740. * Color of the line (Default: White)
  26741. */
  26742. color: Color3;
  26743. /**
  26744. * Alpha of the line (Default: 1)
  26745. */
  26746. alpha: number;
  26747. /**
  26748. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26749. * This margin is expressed in world space coordinates, so its value may vary.
  26750. * Default value is 0.1
  26751. */
  26752. intersectionThreshold: number;
  26753. private _colorShader;
  26754. /**
  26755. * Creates a new LinesMesh
  26756. * @param name defines the name
  26757. * @param scene defines the hosting scene
  26758. * @param parent defines the parent mesh if any
  26759. * @param source defines the optional source LinesMesh used to clone data from
  26760. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26761. * When false, achieved by calling a clone(), also passing False.
  26762. * This will make creation of children, recursive.
  26763. * @param useVertexColor defines if this LinesMesh supports vertex color
  26764. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26765. */
  26766. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26767. /**
  26768. * If vertex color should be applied to the mesh
  26769. */
  26770. useVertexColor?: boolean | undefined,
  26771. /**
  26772. * If vertex alpha should be applied to the mesh
  26773. */
  26774. useVertexAlpha?: boolean | undefined);
  26775. /**
  26776. * Returns the string "LineMesh"
  26777. */
  26778. getClassName(): string;
  26779. /**
  26780. * @hidden
  26781. */
  26782. /**
  26783. * @hidden
  26784. */
  26785. material: Material;
  26786. /**
  26787. * @hidden
  26788. */
  26789. readonly checkCollisions: boolean;
  26790. /** @hidden */
  26791. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26792. /** @hidden */
  26793. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26794. /**
  26795. * Disposes of the line mesh
  26796. * @param doNotRecurse If children should be disposed
  26797. */
  26798. dispose(doNotRecurse?: boolean): void;
  26799. /**
  26800. * Returns a new LineMesh object cloned from the current one.
  26801. */
  26802. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26803. /**
  26804. * Creates a new InstancedLinesMesh object from the mesh model.
  26805. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26806. * @param name defines the name of the new instance
  26807. * @returns a new InstancedLinesMesh
  26808. */
  26809. createInstance(name: string): InstancedLinesMesh;
  26810. }
  26811. /**
  26812. * Creates an instance based on a source LinesMesh
  26813. */
  26814. class InstancedLinesMesh extends InstancedMesh {
  26815. /**
  26816. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26817. * This margin is expressed in world space coordinates, so its value may vary.
  26818. * Initilized with the intersectionThreshold value of the source LinesMesh
  26819. */
  26820. intersectionThreshold: number;
  26821. constructor(name: string, source: LinesMesh);
  26822. /**
  26823. * Returns the string "InstancedLinesMesh".
  26824. */
  26825. getClassName(): string;
  26826. }
  26827. }
  26828. declare module BABYLON {
  26829. /**
  26830. * @hidden
  26831. **/
  26832. class _CreationDataStorage {
  26833. closePath?: boolean;
  26834. closeArray?: boolean;
  26835. idx: number[];
  26836. dashSize: number;
  26837. gapSize: number;
  26838. path3D: Path3D;
  26839. pathArray: Vector3[][];
  26840. arc: number;
  26841. radius: number;
  26842. cap: number;
  26843. tessellation: number;
  26844. }
  26845. /**
  26846. * @hidden
  26847. **/
  26848. class _InstanceDataStorage {
  26849. visibleInstances: any;
  26850. renderIdForInstances: number[];
  26851. batchCache: _InstancesBatch;
  26852. instancesBufferSize: number;
  26853. instancesBuffer: Nullable<Buffer>;
  26854. instancesData: Float32Array;
  26855. overridenInstanceCount: number;
  26856. }
  26857. /**
  26858. * @hidden
  26859. **/
  26860. class _InstancesBatch {
  26861. mustReturn: boolean;
  26862. visibleInstances: Nullable<InstancedMesh[]>[];
  26863. renderSelf: boolean[];
  26864. }
  26865. /**
  26866. * Class used to represent renderable models
  26867. */
  26868. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26869. /**
  26870. * Mesh side orientation : usually the external or front surface
  26871. */
  26872. static readonly FRONTSIDE: number;
  26873. /**
  26874. * Mesh side orientation : usually the internal or back surface
  26875. */
  26876. static readonly BACKSIDE: number;
  26877. /**
  26878. * Mesh side orientation : both internal and external or front and back surfaces
  26879. */
  26880. static readonly DOUBLESIDE: number;
  26881. /**
  26882. * Mesh side orientation : by default, `FRONTSIDE`
  26883. */
  26884. static readonly DEFAULTSIDE: number;
  26885. /**
  26886. * Mesh cap setting : no cap
  26887. */
  26888. static readonly NO_CAP: number;
  26889. /**
  26890. * Mesh cap setting : one cap at the beginning of the mesh
  26891. */
  26892. static readonly CAP_START: number;
  26893. /**
  26894. * Mesh cap setting : one cap at the end of the mesh
  26895. */
  26896. static readonly CAP_END: number;
  26897. /**
  26898. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26899. */
  26900. static readonly CAP_ALL: number;
  26901. private _onBeforeRenderObservable;
  26902. private _onAfterRenderObservable;
  26903. private _onBeforeDrawObservable;
  26904. /**
  26905. * An event triggered before rendering the mesh
  26906. */
  26907. readonly onBeforeRenderObservable: Observable<Mesh>;
  26908. /**
  26909. * An event triggered after rendering the mesh
  26910. */
  26911. readonly onAfterRenderObservable: Observable<Mesh>;
  26912. /**
  26913. * An event triggered before drawing the mesh
  26914. */
  26915. readonly onBeforeDrawObservable: Observable<Mesh>;
  26916. private _onBeforeDrawObserver;
  26917. /**
  26918. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26919. */
  26920. onBeforeDraw: () => void;
  26921. /**
  26922. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26923. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26924. */
  26925. delayLoadState: number;
  26926. /**
  26927. * Gets the list of instances created from this mesh
  26928. * it is not supposed to be modified manually.
  26929. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26930. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26931. */
  26932. instances: InstancedMesh[];
  26933. /**
  26934. * Gets the file containing delay loading data for this mesh
  26935. */
  26936. delayLoadingFile: string;
  26937. /** @hidden */
  26938. _binaryInfo: any;
  26939. private _LODLevels;
  26940. /**
  26941. * User defined function used to change how LOD level selection is done
  26942. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26943. */
  26944. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26945. private _morphTargetManager;
  26946. /**
  26947. * Gets or sets the morph target manager
  26948. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26949. */
  26950. morphTargetManager: Nullable<MorphTargetManager>;
  26951. /** @hidden */
  26952. _creationDataStorage: Nullable<_CreationDataStorage>;
  26953. /** @hidden */
  26954. _geometry: Nullable<Geometry>;
  26955. /** @hidden */
  26956. _delayInfo: Array<string>;
  26957. /** @hidden */
  26958. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26959. /** @hidden */
  26960. _instanceDataStorage: _InstanceDataStorage;
  26961. private _effectiveMaterial;
  26962. /** @hidden */
  26963. _shouldGenerateFlatShading: boolean;
  26964. private _preActivateId;
  26965. /** @hidden */
  26966. _originalBuilderSideOrientation: number;
  26967. /**
  26968. * Use this property to change the original side orientation defined at construction time
  26969. */
  26970. overrideMaterialSideOrientation: Nullable<number>;
  26971. private _areNormalsFrozen;
  26972. private _sourcePositions;
  26973. private _sourceNormals;
  26974. private _source;
  26975. private meshMap;
  26976. /**
  26977. * Gets the source mesh (the one used to clone this one from)
  26978. */
  26979. readonly source: Nullable<Mesh>;
  26980. /**
  26981. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26982. */
  26983. isUnIndexed: boolean;
  26984. /**
  26985. * @constructor
  26986. * @param name The value used by scene.getMeshByName() to do a lookup.
  26987. * @param scene The scene to add this mesh to.
  26988. * @param parent The parent of this mesh, if it has one
  26989. * @param source An optional Mesh from which geometry is shared, cloned.
  26990. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26991. * When false, achieved by calling a clone(), also passing False.
  26992. * This will make creation of children, recursive.
  26993. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26994. */
  26995. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26996. /**
  26997. * Gets the class name
  26998. * @returns the string "Mesh".
  26999. */
  27000. getClassName(): string;
  27001. /**
  27002. * Returns a description of this mesh
  27003. * @param fullDetails define if full details about this mesh must be used
  27004. * @returns a descriptive string representing this mesh
  27005. */
  27006. toString(fullDetails?: boolean): string;
  27007. /** @hidden */
  27008. _unBindEffect(): void;
  27009. /**
  27010. * Gets a boolean indicating if this mesh has LOD
  27011. */
  27012. readonly hasLODLevels: boolean;
  27013. /**
  27014. * Gets the list of MeshLODLevel associated with the current mesh
  27015. * @returns an array of MeshLODLevel
  27016. */
  27017. getLODLevels(): MeshLODLevel[];
  27018. private _sortLODLevels;
  27019. /**
  27020. * Add a mesh as LOD level triggered at the given distance.
  27021. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27022. * @param distance The distance from the center of the object to show this level
  27023. * @param mesh The mesh to be added as LOD level (can be null)
  27024. * @return This mesh (for chaining)
  27025. */
  27026. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27027. /**
  27028. * Returns the LOD level mesh at the passed distance or null if not found.
  27029. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27030. * @param distance The distance from the center of the object to show this level
  27031. * @returns a Mesh or `null`
  27032. */
  27033. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27034. /**
  27035. * Remove a mesh from the LOD array
  27036. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27037. * @param mesh defines the mesh to be removed
  27038. * @return This mesh (for chaining)
  27039. */
  27040. removeLODLevel(mesh: Mesh): Mesh;
  27041. /**
  27042. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27043. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27044. * @param camera defines the camera to use to compute distance
  27045. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27046. * @return This mesh (for chaining)
  27047. */
  27048. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27049. /**
  27050. * Gets the mesh internal Geometry object
  27051. */
  27052. readonly geometry: Nullable<Geometry>;
  27053. /**
  27054. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27055. * @returns the total number of vertices
  27056. */
  27057. getTotalVertices(): number;
  27058. /**
  27059. * Returns the content of an associated vertex buffer
  27060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27061. * - BABYLON.VertexBuffer.PositionKind
  27062. * - BABYLON.VertexBuffer.UVKind
  27063. * - BABYLON.VertexBuffer.UV2Kind
  27064. * - BABYLON.VertexBuffer.UV3Kind
  27065. * - BABYLON.VertexBuffer.UV4Kind
  27066. * - BABYLON.VertexBuffer.UV5Kind
  27067. * - BABYLON.VertexBuffer.UV6Kind
  27068. * - BABYLON.VertexBuffer.ColorKind
  27069. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27070. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27071. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27072. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27073. * @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
  27074. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27075. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27076. */
  27077. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27078. /**
  27079. * Returns the mesh VertexBuffer object from the requested `kind`
  27080. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27081. * - BABYLON.VertexBuffer.PositionKind
  27082. * - BABYLON.VertexBuffer.UVKind
  27083. * - BABYLON.VertexBuffer.UV2Kind
  27084. * - BABYLON.VertexBuffer.UV3Kind
  27085. * - BABYLON.VertexBuffer.UV4Kind
  27086. * - BABYLON.VertexBuffer.UV5Kind
  27087. * - BABYLON.VertexBuffer.UV6Kind
  27088. * - BABYLON.VertexBuffer.ColorKind
  27089. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27090. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27091. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27092. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27093. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27094. */
  27095. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27096. /**
  27097. * Tests if a specific vertex buffer is associated with this mesh
  27098. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27099. * - BABYLON.VertexBuffer.PositionKind
  27100. * - BABYLON.VertexBuffer.UVKind
  27101. * - BABYLON.VertexBuffer.UV2Kind
  27102. * - BABYLON.VertexBuffer.UV3Kind
  27103. * - BABYLON.VertexBuffer.UV4Kind
  27104. * - BABYLON.VertexBuffer.UV5Kind
  27105. * - BABYLON.VertexBuffer.UV6Kind
  27106. * - BABYLON.VertexBuffer.ColorKind
  27107. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27108. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27109. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27110. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27111. * @returns a boolean
  27112. */
  27113. isVerticesDataPresent(kind: string): boolean;
  27114. /**
  27115. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27116. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27117. * - BABYLON.VertexBuffer.PositionKind
  27118. * - BABYLON.VertexBuffer.UVKind
  27119. * - BABYLON.VertexBuffer.UV2Kind
  27120. * - BABYLON.VertexBuffer.UV3Kind
  27121. * - BABYLON.VertexBuffer.UV4Kind
  27122. * - BABYLON.VertexBuffer.UV5Kind
  27123. * - BABYLON.VertexBuffer.UV6Kind
  27124. * - BABYLON.VertexBuffer.ColorKind
  27125. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27126. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27127. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27128. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27129. * @returns a boolean
  27130. */
  27131. isVertexBufferUpdatable(kind: string): boolean;
  27132. /**
  27133. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27134. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27135. * - BABYLON.VertexBuffer.PositionKind
  27136. * - BABYLON.VertexBuffer.UVKind
  27137. * - BABYLON.VertexBuffer.UV2Kind
  27138. * - BABYLON.VertexBuffer.UV3Kind
  27139. * - BABYLON.VertexBuffer.UV4Kind
  27140. * - BABYLON.VertexBuffer.UV5Kind
  27141. * - BABYLON.VertexBuffer.UV6Kind
  27142. * - BABYLON.VertexBuffer.ColorKind
  27143. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27144. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27145. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27146. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27147. * @returns an array of strings
  27148. */
  27149. getVerticesDataKinds(): string[];
  27150. /**
  27151. * Returns a positive integer : the total number of indices in this mesh geometry.
  27152. * @returns the numner of indices or zero if the mesh has no geometry.
  27153. */
  27154. getTotalIndices(): number;
  27155. /**
  27156. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27157. * @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.
  27158. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27159. * @returns the indices array or an empty array if the mesh has no geometry
  27160. */
  27161. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27162. readonly isBlocked: boolean;
  27163. /**
  27164. * Determine if the current mesh is ready to be rendered
  27165. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27166. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27167. * @returns true if all associated assets are ready (material, textures, shaders)
  27168. */
  27169. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27170. /**
  27171. * 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.
  27172. */
  27173. readonly areNormalsFrozen: boolean;
  27174. /**
  27175. * 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.
  27176. * @returns the current mesh
  27177. */
  27178. freezeNormals(): Mesh;
  27179. /**
  27180. * 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
  27181. * @returns the current mesh
  27182. */
  27183. unfreezeNormals(): Mesh;
  27184. /**
  27185. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27186. */
  27187. overridenInstanceCount: number;
  27188. /** @hidden */
  27189. _preActivate(): Mesh;
  27190. /** @hidden */
  27191. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27192. /** @hidden */
  27193. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27194. /**
  27195. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27196. * This means the mesh underlying bounding box and sphere are recomputed.
  27197. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27198. * @returns the current mesh
  27199. */
  27200. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27201. /** @hidden */
  27202. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27203. /**
  27204. * This function will subdivide the mesh into multiple submeshes
  27205. * @param count defines the expected number of submeshes
  27206. */
  27207. subdivide(count: number): void;
  27208. /**
  27209. * Copy a FloatArray into a specific associated vertex buffer
  27210. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27211. * - BABYLON.VertexBuffer.PositionKind
  27212. * - BABYLON.VertexBuffer.UVKind
  27213. * - BABYLON.VertexBuffer.UV2Kind
  27214. * - BABYLON.VertexBuffer.UV3Kind
  27215. * - BABYLON.VertexBuffer.UV4Kind
  27216. * - BABYLON.VertexBuffer.UV5Kind
  27217. * - BABYLON.VertexBuffer.UV6Kind
  27218. * - BABYLON.VertexBuffer.ColorKind
  27219. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27220. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27221. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27222. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27223. * @param data defines the data source
  27224. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27225. * @param stride defines the data stride size (can be null)
  27226. * @returns the current mesh
  27227. */
  27228. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  27229. /**
  27230. * Flags an associated vertex buffer as updatable
  27231. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27232. * - BABYLON.VertexBuffer.PositionKind
  27233. * - BABYLON.VertexBuffer.UVKind
  27234. * - BABYLON.VertexBuffer.UV2Kind
  27235. * - BABYLON.VertexBuffer.UV3Kind
  27236. * - BABYLON.VertexBuffer.UV4Kind
  27237. * - BABYLON.VertexBuffer.UV5Kind
  27238. * - BABYLON.VertexBuffer.UV6Kind
  27239. * - BABYLON.VertexBuffer.ColorKind
  27240. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27241. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27242. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27243. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27244. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27245. */
  27246. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27247. /**
  27248. * Sets the mesh global Vertex Buffer
  27249. * @param buffer defines the buffer to use
  27250. * @returns the current mesh
  27251. */
  27252. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27253. /**
  27254. * Update a specific associated vertex buffer
  27255. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27256. * - BABYLON.VertexBuffer.PositionKind
  27257. * - BABYLON.VertexBuffer.UVKind
  27258. * - BABYLON.VertexBuffer.UV2Kind
  27259. * - BABYLON.VertexBuffer.UV3Kind
  27260. * - BABYLON.VertexBuffer.UV4Kind
  27261. * - BABYLON.VertexBuffer.UV5Kind
  27262. * - BABYLON.VertexBuffer.UV6Kind
  27263. * - BABYLON.VertexBuffer.ColorKind
  27264. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27265. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27266. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27267. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27268. * @param data defines the data source
  27269. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27270. * @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)
  27271. * @returns the current mesh
  27272. */
  27273. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27274. /**
  27275. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27276. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27277. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27278. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27279. * @returns the current mesh
  27280. */
  27281. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27282. /**
  27283. * Creates a un-shared specific occurence of the geometry for the mesh.
  27284. * @returns the current mesh
  27285. */
  27286. makeGeometryUnique(): Mesh;
  27287. /**
  27288. * Set the index buffer of this mesh
  27289. * @param indices defines the source data
  27290. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27291. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27292. * @returns the current mesh
  27293. */
  27294. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27295. /**
  27296. * Update the current index buffer
  27297. * @param indices defines the source data
  27298. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27299. * @returns the current mesh
  27300. */
  27301. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27302. /**
  27303. * Invert the geometry to move from a right handed system to a left handed one.
  27304. * @returns the current mesh
  27305. */
  27306. toLeftHanded(): Mesh;
  27307. /** @hidden */
  27308. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27309. /** @hidden */
  27310. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27311. /**
  27312. * Registers for this mesh a javascript function called just before the rendering process
  27313. * @param func defines the function to call before rendering this mesh
  27314. * @returns the current mesh
  27315. */
  27316. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27317. /**
  27318. * Disposes a previously registered javascript function called before the rendering
  27319. * @param func defines the function to remove
  27320. * @returns the current mesh
  27321. */
  27322. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27323. /**
  27324. * Registers for this mesh a javascript function called just after the rendering is complete
  27325. * @param func defines the function to call after rendering this mesh
  27326. * @returns the current mesh
  27327. */
  27328. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27329. /**
  27330. * Disposes a previously registered javascript function called after the rendering.
  27331. * @param func defines the function to remove
  27332. * @returns the current mesh
  27333. */
  27334. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27335. /** @hidden */
  27336. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27337. /** @hidden */
  27338. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27339. /** @hidden */
  27340. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27341. /**
  27342. * 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
  27343. * @param subMesh defines the subMesh to render
  27344. * @param enableAlphaMode defines if alpha mode can be changed
  27345. * @returns the current mesh
  27346. */
  27347. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27348. private _onBeforeDraw;
  27349. /**
  27350. * Renormalize the mesh and patch it up if there are no weights
  27351. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27352. * However in the case of zero weights then we set just a single influence to 1.
  27353. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27354. */
  27355. cleanMatrixWeights(): void;
  27356. private normalizeSkinFourWeights;
  27357. private normalizeSkinWeightsAndExtra;
  27358. /**
  27359. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27360. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27361. * the user know there was an issue with importing the mesh
  27362. * @returns a validation object with skinned, valid and report string
  27363. */
  27364. validateSkinning(): {
  27365. skinned: boolean;
  27366. valid: boolean;
  27367. report: string;
  27368. };
  27369. /** @hidden */
  27370. _checkDelayState(): Mesh;
  27371. private _queueLoad;
  27372. /**
  27373. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27374. * A mesh is in the frustum if its bounding box intersects the frustum
  27375. * @param frustumPlanes defines the frustum to test
  27376. * @returns true if the mesh is in the frustum planes
  27377. */
  27378. isInFrustum(frustumPlanes: Plane[]): boolean;
  27379. /**
  27380. * Sets the mesh material by the material or multiMaterial `id` property
  27381. * @param id is a string identifying the material or the multiMaterial
  27382. * @returns the current mesh
  27383. */
  27384. setMaterialByID(id: string): Mesh;
  27385. /**
  27386. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27387. * @returns an array of IAnimatable
  27388. */
  27389. getAnimatables(): IAnimatable[];
  27390. /**
  27391. * Modifies the mesh geometry according to the passed transformation matrix.
  27392. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27393. * The mesh normals are modified using the same transformation.
  27394. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27395. * @param transform defines the transform matrix to use
  27396. * @see http://doc.babylonjs.com/resources/baking_transformations
  27397. * @returns the current mesh
  27398. */
  27399. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27400. /**
  27401. * Modifies the mesh geometry according to its own current World Matrix.
  27402. * The mesh World Matrix is then reset.
  27403. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27404. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27405. * @see http://doc.babylonjs.com/resources/baking_transformations
  27406. * @returns the current mesh
  27407. */
  27408. bakeCurrentTransformIntoVertices(): Mesh;
  27409. /** @hidden */
  27410. readonly _positions: Nullable<Vector3[]>;
  27411. /** @hidden */
  27412. _resetPointsArrayCache(): Mesh;
  27413. /** @hidden */
  27414. _generatePointsArray(): boolean;
  27415. /**
  27416. * Returns a new Mesh object generated from the current mesh properties.
  27417. * This method must not get confused with createInstance()
  27418. * @param name is a string, the name given to the new mesh
  27419. * @param newParent can be any Node object (default `null`)
  27420. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27421. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27422. * @returns a new mesh
  27423. */
  27424. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27425. /**
  27426. * Releases resources associated with this mesh.
  27427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27429. */
  27430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27431. /**
  27432. * Modifies the mesh geometry according to a displacement map.
  27433. * 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.
  27434. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27435. * @param url is a string, the URL from the image file is to be downloaded.
  27436. * @param minHeight is the lower limit of the displacement.
  27437. * @param maxHeight is the upper limit of the displacement.
  27438. * @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.
  27439. * @param uvOffset is an optional vector2 used to offset UV.
  27440. * @param uvScale is an optional vector2 used to scale UV.
  27441. * @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.
  27442. * @returns the Mesh.
  27443. */
  27444. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27445. /**
  27446. * Modifies the mesh geometry according to a displacementMap buffer.
  27447. * 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.
  27448. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27449. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27450. * @param heightMapWidth is the width of the buffer image.
  27451. * @param heightMapHeight is the height of the buffer image.
  27452. * @param minHeight is the lower limit of the displacement.
  27453. * @param maxHeight is the upper limit of the displacement.
  27454. * @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.
  27455. * @param uvOffset is an optional vector2 used to offset UV.
  27456. * @param uvScale is an optional vector2 used to scale UV.
  27457. * @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.
  27458. * @returns the Mesh.
  27459. */
  27460. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27461. /**
  27462. * Modify the mesh to get a flat shading rendering.
  27463. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27464. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27465. * @returns current mesh
  27466. */
  27467. convertToFlatShadedMesh(): Mesh;
  27468. /**
  27469. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27470. * In other words, more vertices, no more indices and a single bigger VBO.
  27471. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27472. * @returns current mesh
  27473. */
  27474. convertToUnIndexedMesh(): Mesh;
  27475. /**
  27476. * Inverses facet orientations.
  27477. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27478. * @param flipNormals will also inverts the normals
  27479. * @returns current mesh
  27480. */
  27481. flipFaces(flipNormals?: boolean): Mesh;
  27482. /**
  27483. * Creates a new InstancedMesh object from the mesh model.
  27484. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27485. * @param name defines the name of the new instance
  27486. * @returns a new InstancedMesh
  27487. */
  27488. createInstance(name: string): InstancedMesh;
  27489. /**
  27490. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27491. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27492. * @returns the current mesh
  27493. */
  27494. synchronizeInstances(): Mesh;
  27495. /**
  27496. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27497. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27498. * This should be used together with the simplification to avoid disappearing triangles.
  27499. * @param successCallback an optional success callback to be called after the optimization finished.
  27500. * @returns the current mesh
  27501. */
  27502. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27503. /**
  27504. * Serialize current mesh
  27505. * @param serializationObject defines the object which will receive the serialization data
  27506. */
  27507. serialize(serializationObject: any): void;
  27508. /** @hidden */
  27509. _syncGeometryWithMorphTargetManager(): void;
  27510. /**
  27511. * Returns a new Mesh object parsed from the source provided.
  27512. * @param parsedMesh is the source
  27513. * @param scene defines the hosting scene
  27514. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27515. * @returns a new Mesh
  27516. */
  27517. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27518. /**
  27519. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27520. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27521. * @param name defines the name of the mesh to create
  27522. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27523. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27524. * @param closePath creates a seam between the first and the last points of each path of the path array
  27525. * @param offset is taken in account only if the `pathArray` is containing a single path
  27526. * @param scene defines the hosting scene
  27527. * @param updatable defines if the mesh must be flagged as updatable
  27528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27529. * @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)
  27530. * @returns a new Mesh
  27531. */
  27532. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27533. /**
  27534. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27535. * @param name defines the name of the mesh to create
  27536. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27537. * @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
  27538. * @param scene defines the hosting scene
  27539. * @param updatable defines if the mesh must be flagged as updatable
  27540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27541. * @returns a new Mesh
  27542. */
  27543. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27544. /**
  27545. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27546. * @param name defines the name of the mesh to create
  27547. * @param size sets the size (float) of each box side (default 1)
  27548. * @param scene defines the hosting scene
  27549. * @param updatable defines if the mesh must be flagged as updatable
  27550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27551. * @returns a new Mesh
  27552. */
  27553. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27554. /**
  27555. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27556. * @param name defines the name of the mesh to create
  27557. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27558. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27559. * @param scene defines the hosting scene
  27560. * @param updatable defines if the mesh must be flagged as updatable
  27561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27562. * @returns a new Mesh
  27563. */
  27564. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27565. /**
  27566. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27567. * @param name defines the name of the mesh to create
  27568. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27569. * @param diameterTop set the top cap diameter (floats, default 1)
  27570. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27571. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27572. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27573. * @param scene defines the hosting scene
  27574. * @param updatable defines if the mesh must be flagged as updatable
  27575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27576. * @returns a new Mesh
  27577. */
  27578. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27579. /**
  27580. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27581. * @param name defines the name of the mesh to create
  27582. * @param diameter sets the diameter size (float) of the torus (default 1)
  27583. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27584. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27585. * @param scene defines the hosting scene
  27586. * @param updatable defines if the mesh must be flagged as updatable
  27587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27588. * @returns a new Mesh
  27589. */
  27590. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27591. /**
  27592. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27593. * @param name defines the name of the mesh to create
  27594. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27595. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27596. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27597. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27598. * @param p the number of windings on X axis (positive integers, default 2)
  27599. * @param q the number of windings on Y axis (positive integers, default 3)
  27600. * @param scene defines the hosting scene
  27601. * @param updatable defines if the mesh must be flagged as updatable
  27602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27603. * @returns a new Mesh
  27604. */
  27605. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27606. /**
  27607. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27608. * @param name defines the name of the mesh to create
  27609. * @param points is an array successive Vector3
  27610. * @param scene defines the hosting scene
  27611. * @param updatable defines if the mesh must be flagged as updatable
  27612. * @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).
  27613. * @returns a new Mesh
  27614. */
  27615. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27616. /**
  27617. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27618. * @param name defines the name of the mesh to create
  27619. * @param points is an array successive Vector3
  27620. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27621. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27622. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27623. * @param scene defines the hosting scene
  27624. * @param updatable defines if the mesh must be flagged as updatable
  27625. * @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)
  27626. * @returns a new Mesh
  27627. */
  27628. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27629. /**
  27630. * Creates a polygon mesh.
  27631. * Please consider using the same method from the MeshBuilder class instead.
  27632. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27633. * 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.
  27634. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27635. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27636. * Remember you can only change the shape positions, not their number when updating a polygon.
  27637. */
  27638. /**
  27639. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27640. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27641. * @param name defines the name of the mesh to create
  27642. * @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
  27643. * @param scene defines the hosting scene
  27644. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27645. * @param updatable defines if the mesh must be flagged as updatable
  27646. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27647. * @returns a new Mesh
  27648. */
  27649. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27650. /**
  27651. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27652. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27653. * @param name defines the name of the mesh to create
  27654. * @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
  27655. * @param depth defines the height of extrusion
  27656. * @param scene defines the hosting scene
  27657. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27658. * @param updatable defines if the mesh must be flagged as updatable
  27659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27660. * @returns a new Mesh
  27661. */
  27662. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27663. /**
  27664. * Creates an extruded shape mesh.
  27665. * 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
  27666. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27667. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27668. * @param name defines the name of the mesh to create
  27669. * @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
  27670. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27671. * @param scale is the value to scale the shape
  27672. * @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
  27673. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27674. * @param scene defines the hosting scene
  27675. * @param updatable defines if the mesh must be flagged as updatable
  27676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27677. * @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)
  27678. * @returns a new Mesh
  27679. */
  27680. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27681. /**
  27682. * Creates an custom extruded shape mesh.
  27683. * The custom extrusion is a parametric shape.
  27684. * It has no predefined shape. Its final shape will depend on the input parameters.
  27685. * Please consider using the same method from the MeshBuilder class instead
  27686. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27687. * @param name defines the name of the mesh to create
  27688. * @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
  27689. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27690. * @param scaleFunction is a custom Javascript function called on each path point
  27691. * @param rotationFunction is a custom Javascript function called on each path point
  27692. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27693. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27694. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27695. * @param scene defines the hosting scene
  27696. * @param updatable defines if the mesh must be flagged as updatable
  27697. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27698. * @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)
  27699. * @returns a new Mesh
  27700. */
  27701. 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;
  27702. /**
  27703. * Creates lathe mesh.
  27704. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27705. * Please consider using the same method from the MeshBuilder class instead
  27706. * @param name defines the name of the mesh to create
  27707. * @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
  27708. * @param radius is the radius value of the lathe
  27709. * @param tessellation is the side number of the lathe.
  27710. * @param scene defines the hosting scene
  27711. * @param updatable defines if the mesh must be flagged as updatable
  27712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27713. * @returns a new Mesh
  27714. */
  27715. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27716. /**
  27717. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27718. * @param name defines the name of the mesh to create
  27719. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27720. * @param scene defines the hosting scene
  27721. * @param updatable defines if the mesh must be flagged as updatable
  27722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27723. * @returns a new Mesh
  27724. */
  27725. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27726. /**
  27727. * Creates a ground mesh.
  27728. * Please consider using the same method from the MeshBuilder class instead
  27729. * @param name defines the name of the mesh to create
  27730. * @param width set the width of the ground
  27731. * @param height set the height of the ground
  27732. * @param subdivisions sets the number of subdivisions per side
  27733. * @param scene defines the hosting scene
  27734. * @param updatable defines if the mesh must be flagged as updatable
  27735. * @returns a new Mesh
  27736. */
  27737. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27738. /**
  27739. * Creates a tiled ground mesh.
  27740. * Please consider using the same method from the MeshBuilder class instead
  27741. * @param name defines the name of the mesh to create
  27742. * @param xmin set the ground minimum X coordinate
  27743. * @param zmin set the ground minimum Y coordinate
  27744. * @param xmax set the ground maximum X coordinate
  27745. * @param zmax set the ground maximum Z coordinate
  27746. * @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
  27747. * @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
  27748. * @param scene defines the hosting scene
  27749. * @param updatable defines if the mesh must be flagged as updatable
  27750. * @returns a new Mesh
  27751. */
  27752. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27753. w: number;
  27754. h: number;
  27755. }, precision: {
  27756. w: number;
  27757. h: number;
  27758. }, scene: Scene, updatable?: boolean): Mesh;
  27759. /**
  27760. * Creates a ground mesh from a height map.
  27761. * Please consider using the same method from the MeshBuilder class instead
  27762. * @see http://doc.babylonjs.com/babylon101/height_map
  27763. * @param name defines the name of the mesh to create
  27764. * @param url sets the URL of the height map image resource
  27765. * @param width set the ground width size
  27766. * @param height set the ground height size
  27767. * @param subdivisions sets the number of subdivision per side
  27768. * @param minHeight is the minimum altitude on the ground
  27769. * @param maxHeight is the maximum altitude on the ground
  27770. * @param scene defines the hosting scene
  27771. * @param updatable defines if the mesh must be flagged as updatable
  27772. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27773. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27774. * @returns a new Mesh
  27775. */
  27776. 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;
  27777. /**
  27778. * Creates a tube mesh.
  27779. * The tube is a parametric shape.
  27780. * It has no predefined shape. Its final shape will depend on the input parameters.
  27781. * Please consider using the same method from the MeshBuilder class instead
  27782. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27783. * @param name defines the name of the mesh to create
  27784. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27785. * @param radius sets the tube radius size
  27786. * @param tessellation is the number of sides on the tubular surface
  27787. * @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
  27788. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27789. * @param scene defines the hosting scene
  27790. * @param updatable defines if the mesh must be flagged as updatable
  27791. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27792. * @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)
  27793. * @returns a new Mesh
  27794. */
  27795. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27796. (i: number, distance: number): number;
  27797. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27798. /**
  27799. * Creates a polyhedron mesh.
  27800. * Please consider using the same method from the MeshBuilder class instead.
  27801. * * 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
  27802. * * The parameter `size` (positive float, default 1) sets the polygon size
  27803. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27804. * * 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`
  27805. * * 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
  27806. * * 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)`)
  27807. * * 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
  27808. * * 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
  27809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27810. * * 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
  27811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27812. * @param name defines the name of the mesh to create
  27813. * @param options defines the options used to create the mesh
  27814. * @param scene defines the hosting scene
  27815. * @returns a new Mesh
  27816. */
  27817. static CreatePolyhedron(name: string, options: {
  27818. type?: number;
  27819. size?: number;
  27820. sizeX?: number;
  27821. sizeY?: number;
  27822. sizeZ?: number;
  27823. custom?: any;
  27824. faceUV?: Vector4[];
  27825. faceColors?: Color4[];
  27826. updatable?: boolean;
  27827. sideOrientation?: number;
  27828. }, scene: Scene): Mesh;
  27829. /**
  27830. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27831. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27832. * * 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`)
  27833. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27834. * * 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
  27835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27836. * * 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
  27837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27838. * @param name defines the name of the mesh
  27839. * @param options defines the options used to create the mesh
  27840. * @param scene defines the hosting scene
  27841. * @returns a new Mesh
  27842. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27843. */
  27844. static CreateIcoSphere(name: string, options: {
  27845. radius?: number;
  27846. flat?: boolean;
  27847. subdivisions?: number;
  27848. sideOrientation?: number;
  27849. updatable?: boolean;
  27850. }, scene: Scene): Mesh;
  27851. /**
  27852. * Creates a decal mesh.
  27853. * Please consider using the same method from the MeshBuilder class instead.
  27854. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27855. * @param name defines the name of the mesh
  27856. * @param sourceMesh defines the mesh receiving the decal
  27857. * @param position sets the position of the decal in world coordinates
  27858. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27859. * @param size sets the decal scaling
  27860. * @param angle sets the angle to rotate the decal
  27861. * @returns a new Mesh
  27862. */
  27863. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27864. /**
  27865. * Prepare internal position array for software CPU skinning
  27866. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27867. */
  27868. setPositionsForCPUSkinning(): Float32Array;
  27869. /**
  27870. * Prepare internal normal array for software CPU skinning
  27871. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27872. */
  27873. setNormalsForCPUSkinning(): Float32Array;
  27874. /**
  27875. * Updates the vertex buffer by applying transformation from the bones
  27876. * @param skeleton defines the skeleton to apply to current mesh
  27877. * @returns the current mesh
  27878. */
  27879. applySkeleton(skeleton: Skeleton): Mesh;
  27880. /**
  27881. * 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
  27882. * @param meshes defines the list of meshes to scan
  27883. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27884. */
  27885. static MinMax(meshes: AbstractMesh[]): {
  27886. min: Vector3;
  27887. max: Vector3;
  27888. };
  27889. /**
  27890. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27891. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27892. * @returns a vector3
  27893. */
  27894. static Center(meshesOrMinMaxVector: {
  27895. min: Vector3;
  27896. max: Vector3;
  27897. } | AbstractMesh[]): Vector3;
  27898. /**
  27899. * Merge the array of meshes into a single mesh for performance reasons.
  27900. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27901. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27902. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27903. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27904. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27905. * @returns a new mesh
  27906. */
  27907. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27908. /** @hidden */
  27909. addInstance(instance: InstancedMesh): void;
  27910. /** @hidden */
  27911. removeInstance(instance: InstancedMesh): void;
  27912. }
  27913. }
  27914. declare module BABYLON {
  27915. /**
  27916. * Define an interface for all classes that will get and set the data on vertices
  27917. */
  27918. interface IGetSetVerticesData {
  27919. /**
  27920. * Gets a boolean indicating if specific vertex data is present
  27921. * @param kind defines the vertex data kind to use
  27922. * @returns true is data kind is present
  27923. */
  27924. isVerticesDataPresent(kind: string): boolean;
  27925. /**
  27926. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27927. * @param kind defines the data kind (Position, normal, etc...)
  27928. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27929. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27930. * @returns a float array containing vertex data
  27931. */
  27932. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27933. /**
  27934. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27935. * @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.
  27936. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27937. * @returns the indices array or an empty array if the mesh has no geometry
  27938. */
  27939. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27940. /**
  27941. * Set specific vertex data
  27942. * @param kind defines the data kind (Position, normal, etc...)
  27943. * @param data defines the vertex data to use
  27944. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27945. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27946. */
  27947. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27948. /**
  27949. * Update a specific associated vertex buffer
  27950. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27951. * - BABYLON.VertexBuffer.PositionKind
  27952. * - BABYLON.VertexBuffer.UVKind
  27953. * - BABYLON.VertexBuffer.UV2Kind
  27954. * - BABYLON.VertexBuffer.UV3Kind
  27955. * - BABYLON.VertexBuffer.UV4Kind
  27956. * - BABYLON.VertexBuffer.UV5Kind
  27957. * - BABYLON.VertexBuffer.UV6Kind
  27958. * - BABYLON.VertexBuffer.ColorKind
  27959. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27960. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27961. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27962. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27963. * @param data defines the data source
  27964. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27965. * @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)
  27966. */
  27967. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27968. /**
  27969. * Creates a new index buffer
  27970. * @param indices defines the indices to store in the index buffer
  27971. * @param totalVertices defines the total number of vertices (could be null)
  27972. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27973. */
  27974. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27975. }
  27976. /**
  27977. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27978. */
  27979. class VertexData {
  27980. /**
  27981. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27982. */
  27983. positions: Nullable<FloatArray>;
  27984. /**
  27985. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27986. */
  27987. normals: Nullable<FloatArray>;
  27988. /**
  27989. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27990. */
  27991. tangents: Nullable<FloatArray>;
  27992. /**
  27993. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27994. */
  27995. uvs: Nullable<FloatArray>;
  27996. /**
  27997. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27998. */
  27999. uvs2: Nullable<FloatArray>;
  28000. /**
  28001. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  28002. */
  28003. uvs3: Nullable<FloatArray>;
  28004. /**
  28005. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  28006. */
  28007. uvs4: Nullable<FloatArray>;
  28008. /**
  28009. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  28010. */
  28011. uvs5: Nullable<FloatArray>;
  28012. /**
  28013. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  28014. */
  28015. uvs6: Nullable<FloatArray>;
  28016. /**
  28017. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  28018. */
  28019. colors: Nullable<FloatArray>;
  28020. /**
  28021. * 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).
  28022. */
  28023. matricesIndices: Nullable<FloatArray>;
  28024. /**
  28025. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  28026. */
  28027. matricesWeights: Nullable<FloatArray>;
  28028. /**
  28029. * An array extending the number of possible indices
  28030. */
  28031. matricesIndicesExtra: Nullable<FloatArray>;
  28032. /**
  28033. * An array extending the number of possible weights when the number of indices is extended
  28034. */
  28035. matricesWeightsExtra: Nullable<FloatArray>;
  28036. /**
  28037. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  28038. */
  28039. indices: Nullable<IndicesArray>;
  28040. /**
  28041. * Uses the passed data array to set the set the values for the specified kind of data
  28042. * @param data a linear array of floating numbers
  28043. * @param kind the type of data that is being set, eg positions, colors etc
  28044. */
  28045. set(data: FloatArray, kind: string): void;
  28046. /**
  28047. * Associates the vertexData to the passed Mesh.
  28048. * Sets it as updatable or not (default `false`)
  28049. * @param mesh the mesh the vertexData is applied to
  28050. * @param updatable when used and having the value true allows new data to update the vertexData
  28051. * @returns the VertexData
  28052. */
  28053. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  28054. /**
  28055. * Associates the vertexData to the passed Geometry.
  28056. * Sets it as updatable or not (default `false`)
  28057. * @param geometry the geometry the vertexData is applied to
  28058. * @param updatable when used and having the value true allows new data to update the vertexData
  28059. * @returns VertexData
  28060. */
  28061. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  28062. /**
  28063. * Updates the associated mesh
  28064. * @param mesh the mesh to be updated
  28065. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28066. * @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
  28067. * @returns VertexData
  28068. */
  28069. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28070. /**
  28071. * Updates the associated geometry
  28072. * @param geometry the geometry to be updated
  28073. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28074. * @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
  28075. * @returns VertexData.
  28076. */
  28077. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28078. private _applyTo;
  28079. private _update;
  28080. /**
  28081. * Transforms each position and each normal of the vertexData according to the passed Matrix
  28082. * @param matrix the transforming matrix
  28083. * @returns the VertexData
  28084. */
  28085. transform(matrix: Matrix): VertexData;
  28086. /**
  28087. * Merges the passed VertexData into the current one
  28088. * @param other the VertexData to be merged into the current one
  28089. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  28090. * @returns the modified VertexData
  28091. */
  28092. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  28093. private _mergeElement;
  28094. private _validate;
  28095. /**
  28096. * Serializes the VertexData
  28097. * @returns a serialized object
  28098. */
  28099. serialize(): any;
  28100. /**
  28101. * Extracts the vertexData from a mesh
  28102. * @param mesh the mesh from which to extract the VertexData
  28103. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  28104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28105. * @returns the object VertexData associated to the passed mesh
  28106. */
  28107. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28108. /**
  28109. * Extracts the vertexData from the geometry
  28110. * @param geometry the geometry from which to extract the VertexData
  28111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  28112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28113. * @returns the object VertexData associated to the passed mesh
  28114. */
  28115. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28116. private static _ExtractFrom;
  28117. /**
  28118. * Creates the VertexData for a Ribbon
  28119. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  28120. * * pathArray array of paths, each of which an array of successive Vector3
  28121. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  28122. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  28123. * * 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
  28124. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28125. * * 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)
  28126. * * 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)
  28127. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  28128. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  28129. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  28130. * @returns the VertexData of the ribbon
  28131. */
  28132. static CreateRibbon(options: {
  28133. pathArray: Vector3[][];
  28134. closeArray?: boolean;
  28135. closePath?: boolean;
  28136. offset?: number;
  28137. sideOrientation?: number;
  28138. frontUVs?: Vector4;
  28139. backUVs?: Vector4;
  28140. invertUV?: boolean;
  28141. uvs?: Vector2[];
  28142. colors?: Color4[];
  28143. }): VertexData;
  28144. /**
  28145. * Creates the VertexData for a box
  28146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28147. * * size sets the width, height and depth of the box to the value of size, optional default 1
  28148. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  28149. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  28150. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  28151. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  28152. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  28153. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28154. * * 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)
  28155. * * 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)
  28156. * @returns the VertexData of the box
  28157. */
  28158. static CreateBox(options: {
  28159. size?: number;
  28160. width?: number;
  28161. height?: number;
  28162. depth?: number;
  28163. faceUV?: Vector4[];
  28164. faceColors?: Color4[];
  28165. sideOrientation?: number;
  28166. frontUVs?: Vector4;
  28167. backUVs?: Vector4;
  28168. }): VertexData;
  28169. /**
  28170. * Creates the VertexData for an ellipsoid, defaults to a sphere
  28171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28172. * * segments sets the number of horizontal strips optional, default 32
  28173. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  28174. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  28175. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  28176. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  28177. * * 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
  28178. * * 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
  28179. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28180. * * 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)
  28181. * * 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)
  28182. * @returns the VertexData of the ellipsoid
  28183. */
  28184. static CreateSphere(options: {
  28185. segments?: number;
  28186. diameter?: number;
  28187. diameterX?: number;
  28188. diameterY?: number;
  28189. diameterZ?: number;
  28190. arc?: number;
  28191. slice?: number;
  28192. sideOrientation?: number;
  28193. frontUVs?: Vector4;
  28194. backUVs?: Vector4;
  28195. }): VertexData;
  28196. /**
  28197. * Creates the VertexData for a cylinder, cone or prism
  28198. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28199. * * height sets the height (y direction) of the cylinder, optional, default 2
  28200. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  28201. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  28202. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  28203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28204. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  28205. * * 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
  28206. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28207. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28208. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  28209. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  28210. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28211. * * 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)
  28212. * * 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)
  28213. * @returns the VertexData of the cylinder, cone or prism
  28214. */
  28215. static CreateCylinder(options: {
  28216. height?: number;
  28217. diameterTop?: number;
  28218. diameterBottom?: number;
  28219. diameter?: number;
  28220. tessellation?: number;
  28221. subdivisions?: number;
  28222. arc?: number;
  28223. faceColors?: Color4[];
  28224. faceUV?: Vector4[];
  28225. hasRings?: boolean;
  28226. enclose?: boolean;
  28227. sideOrientation?: number;
  28228. frontUVs?: Vector4;
  28229. backUVs?: Vector4;
  28230. }): VertexData;
  28231. /**
  28232. * Creates the VertexData for a torus
  28233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28234. * * diameter the diameter of the torus, optional default 1
  28235. * * thickness the diameter of the tube forming the torus, optional default 0.5
  28236. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28237. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28238. * * 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)
  28239. * * 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)
  28240. * @returns the VertexData of the torus
  28241. */
  28242. static CreateTorus(options: {
  28243. diameter?: number;
  28244. thickness?: number;
  28245. tessellation?: number;
  28246. sideOrientation?: number;
  28247. frontUVs?: Vector4;
  28248. backUVs?: Vector4;
  28249. }): VertexData;
  28250. /**
  28251. * Creates the VertexData of the LineSystem
  28252. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  28253. * - lines an array of lines, each line being an array of successive Vector3
  28254. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  28255. * @returns the VertexData of the LineSystem
  28256. */
  28257. static CreateLineSystem(options: {
  28258. lines: Vector3[][];
  28259. colors?: Nullable<Color4[][]>;
  28260. }): VertexData;
  28261. /**
  28262. * Create the VertexData for a DashedLines
  28263. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  28264. * - points an array successive Vector3
  28265. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  28266. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  28267. * - dashNb the intended total number of dashes, optional, default 200
  28268. * @returns the VertexData for the DashedLines
  28269. */
  28270. static CreateDashedLines(options: {
  28271. points: Vector3[];
  28272. dashSize?: number;
  28273. gapSize?: number;
  28274. dashNb?: number;
  28275. }): VertexData;
  28276. /**
  28277. * Creates the VertexData for a Ground
  28278. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28279. * - width the width (x direction) of the ground, optional, default 1
  28280. * - height the height (z direction) of the ground, optional, default 1
  28281. * - subdivisions the number of subdivisions per side, optional, default 1
  28282. * @returns the VertexData of the Ground
  28283. */
  28284. static CreateGround(options: {
  28285. width?: number;
  28286. height?: number;
  28287. subdivisions?: number;
  28288. subdivisionsX?: number;
  28289. subdivisionsY?: number;
  28290. }): VertexData;
  28291. /**
  28292. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28293. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28294. * * xmin the ground minimum X coordinate, optional, default -1
  28295. * * zmin the ground minimum Z coordinate, optional, default -1
  28296. * * xmax the ground maximum X coordinate, optional, default 1
  28297. * * zmax the ground maximum Z coordinate, optional, default 1
  28298. * * 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}
  28299. * * 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}
  28300. * @returns the VertexData of the TiledGround
  28301. */
  28302. static CreateTiledGround(options: {
  28303. xmin: number;
  28304. zmin: number;
  28305. xmax: number;
  28306. zmax: number;
  28307. subdivisions?: {
  28308. w: number;
  28309. h: number;
  28310. };
  28311. precision?: {
  28312. w: number;
  28313. h: number;
  28314. };
  28315. }): VertexData;
  28316. /**
  28317. * Creates the VertexData of the Ground designed from a heightmap
  28318. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28319. * * width the width (x direction) of the ground
  28320. * * height the height (z direction) of the ground
  28321. * * subdivisions the number of subdivisions per side
  28322. * * minHeight the minimum altitude on the ground, optional, default 0
  28323. * * maxHeight the maximum altitude on the ground, optional default 1
  28324. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28325. * * buffer the array holding the image color data
  28326. * * bufferWidth the width of image
  28327. * * bufferHeight the height of image
  28328. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28329. * @returns the VertexData of the Ground designed from a heightmap
  28330. */
  28331. static CreateGroundFromHeightMap(options: {
  28332. width: number;
  28333. height: number;
  28334. subdivisions: number;
  28335. minHeight: number;
  28336. maxHeight: number;
  28337. colorFilter: Color3;
  28338. buffer: Uint8Array;
  28339. bufferWidth: number;
  28340. bufferHeight: number;
  28341. alphaFilter: number;
  28342. }): VertexData;
  28343. /**
  28344. * Creates the VertexData for a Plane
  28345. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28346. * * size sets the width and height of the plane to the value of size, optional default 1
  28347. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28348. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28349. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28350. * * 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)
  28351. * * 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)
  28352. * @returns the VertexData of the box
  28353. */
  28354. static CreatePlane(options: {
  28355. size?: number;
  28356. width?: number;
  28357. height?: number;
  28358. sideOrientation?: number;
  28359. frontUVs?: Vector4;
  28360. backUVs?: Vector4;
  28361. }): VertexData;
  28362. /**
  28363. * Creates the VertexData of the Disc or regular Polygon
  28364. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28365. * * radius the radius of the disc, optional default 0.5
  28366. * * tessellation the number of polygon sides, optional, default 64
  28367. * * 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
  28368. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28369. * * 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)
  28370. * * 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)
  28371. * @returns the VertexData of the box
  28372. */
  28373. static CreateDisc(options: {
  28374. radius?: number;
  28375. tessellation?: number;
  28376. arc?: number;
  28377. sideOrientation?: number;
  28378. frontUVs?: Vector4;
  28379. backUVs?: Vector4;
  28380. }): VertexData;
  28381. /**
  28382. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28383. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28384. * @param polygon a mesh built from polygonTriangulation.build()
  28385. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28386. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28387. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28388. * @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)
  28389. * @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)
  28390. * @returns the VertexData of the Polygon
  28391. */
  28392. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28393. /**
  28394. * Creates the VertexData of the IcoSphere
  28395. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28396. * * radius the radius of the IcoSphere, optional default 1
  28397. * * radiusX allows stretching in the x direction, optional, default radius
  28398. * * radiusY allows stretching in the y direction, optional, default radius
  28399. * * radiusZ allows stretching in the z direction, optional, default radius
  28400. * * flat when true creates a flat shaded mesh, optional, default true
  28401. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28402. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28403. * * 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)
  28404. * * 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)
  28405. * @returns the VertexData of the IcoSphere
  28406. */
  28407. static CreateIcoSphere(options: {
  28408. radius?: number;
  28409. radiusX?: number;
  28410. radiusY?: number;
  28411. radiusZ?: number;
  28412. flat?: boolean;
  28413. subdivisions?: number;
  28414. sideOrientation?: number;
  28415. frontUVs?: Vector4;
  28416. backUVs?: Vector4;
  28417. }): VertexData;
  28418. /**
  28419. * Creates the VertexData for a Polyhedron
  28420. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28421. * * type provided types are:
  28422. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28423. * * 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)
  28424. * * size the size of the IcoSphere, optional default 1
  28425. * * sizeX allows stretching in the x direction, optional, default size
  28426. * * sizeY allows stretching in the y direction, optional, default size
  28427. * * sizeZ allows stretching in the z direction, optional, default size
  28428. * * 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
  28429. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28430. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28431. * * flat when true creates a flat shaded mesh, optional, default true
  28432. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28433. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28434. * * 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)
  28435. * * 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)
  28436. * @returns the VertexData of the Polyhedron
  28437. */
  28438. static CreatePolyhedron(options: {
  28439. type?: number;
  28440. size?: number;
  28441. sizeX?: number;
  28442. sizeY?: number;
  28443. sizeZ?: number;
  28444. custom?: any;
  28445. faceUV?: Vector4[];
  28446. faceColors?: Color4[];
  28447. flat?: boolean;
  28448. sideOrientation?: number;
  28449. frontUVs?: Vector4;
  28450. backUVs?: Vector4;
  28451. }): VertexData;
  28452. /**
  28453. * Creates the VertexData for a TorusKnot
  28454. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28455. * * radius the radius of the torus knot, optional, default 2
  28456. * * tube the thickness of the tube, optional, default 0.5
  28457. * * radialSegments the number of sides on each tube segments, optional, default 32
  28458. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28459. * * p the number of windings around the z axis, optional, default 2
  28460. * * q the number of windings around the x axis, optional, default 3
  28461. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28462. * * 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)
  28463. * * 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)
  28464. * @returns the VertexData of the Torus Knot
  28465. */
  28466. static CreateTorusKnot(options: {
  28467. radius?: number;
  28468. tube?: number;
  28469. radialSegments?: number;
  28470. tubularSegments?: number;
  28471. p?: number;
  28472. q?: number;
  28473. sideOrientation?: number;
  28474. frontUVs?: Vector4;
  28475. backUVs?: Vector4;
  28476. }): VertexData;
  28477. /**
  28478. * Compute normals for given positions and indices
  28479. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28480. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28481. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28482. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28483. * * facetNormals : optional array of facet normals (vector3)
  28484. * * facetPositions : optional array of facet positions (vector3)
  28485. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28486. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28487. * * bInfo : optional bounding info, required for facetPartitioning computation
  28488. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28489. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28490. * * useRightHandedSystem: optional boolean to for right handed system computation
  28491. * * depthSort : optional boolean to enable the facet depth sort computation
  28492. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28493. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28494. */
  28495. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28496. facetNormals?: any;
  28497. facetPositions?: any;
  28498. facetPartitioning?: any;
  28499. ratio?: number;
  28500. bInfo?: any;
  28501. bbSize?: Vector3;
  28502. subDiv?: any;
  28503. useRightHandedSystem?: boolean;
  28504. depthSort?: boolean;
  28505. distanceTo?: Vector3;
  28506. depthSortedFacets?: any;
  28507. }): void;
  28508. private static _ComputeSides;
  28509. /**
  28510. * Applies VertexData created from the imported parameters to the geometry
  28511. * @param parsedVertexData the parsed data from an imported file
  28512. * @param geometry the geometry to apply the VertexData to
  28513. */
  28514. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28515. }
  28516. }
  28517. declare module BABYLON {
  28518. /**
  28519. * Class containing static functions to help procedurally build meshes
  28520. */
  28521. class MeshBuilder {
  28522. private static _UpdateSideOrientation;
  28523. /**
  28524. * Creates a box mesh
  28525. * * The parameter `size` sets the size (float) of each box side (default 1)
  28526. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28527. * * 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)
  28528. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28530. * * 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
  28531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28532. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28533. * @param name defines the name of the mesh
  28534. * @param options defines the options used to create the mesh
  28535. * @param scene defines the hosting scene
  28536. * @returns the box mesh
  28537. */
  28538. static CreateBox(name: string, options: {
  28539. size?: number;
  28540. width?: number;
  28541. height?: number;
  28542. depth?: number;
  28543. faceUV?: Vector4[];
  28544. faceColors?: Color4[];
  28545. sideOrientation?: number;
  28546. frontUVs?: Vector4;
  28547. backUVs?: Vector4;
  28548. updatable?: boolean;
  28549. }, scene?: Nullable<Scene>): Mesh;
  28550. /**
  28551. * Creates a sphere mesh
  28552. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28553. * * 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`)
  28554. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28555. * * 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
  28556. * * 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)
  28557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28558. * * 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
  28559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28560. * @param name defines the name of the mesh
  28561. * @param options defines the options used to create the mesh
  28562. * @param scene defines the hosting scene
  28563. * @returns the sphere mesh
  28564. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28565. */
  28566. static CreateSphere(name: string, options: {
  28567. segments?: number;
  28568. diameter?: number;
  28569. diameterX?: number;
  28570. diameterY?: number;
  28571. diameterZ?: number;
  28572. arc?: number;
  28573. slice?: number;
  28574. sideOrientation?: number;
  28575. frontUVs?: Vector4;
  28576. backUVs?: Vector4;
  28577. updatable?: boolean;
  28578. }, scene: any): Mesh;
  28579. /**
  28580. * Creates a plane polygonal mesh. By default, this is a disc
  28581. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28582. * * 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
  28583. * * 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
  28584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28585. * * 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
  28586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28587. * @param name defines the name of the mesh
  28588. * @param options defines the options used to create the mesh
  28589. * @param scene defines the hosting scene
  28590. * @returns the plane polygonal mesh
  28591. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28592. */
  28593. static CreateDisc(name: string, options: {
  28594. radius?: number;
  28595. tessellation?: number;
  28596. arc?: number;
  28597. updatable?: boolean;
  28598. sideOrientation?: number;
  28599. frontUVs?: Vector4;
  28600. backUVs?: Vector4;
  28601. }, scene?: Nullable<Scene>): Mesh;
  28602. /**
  28603. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28604. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28605. * * 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`)
  28606. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28607. * * 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
  28608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28609. * * 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
  28610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28611. * @param name defines the name of the mesh
  28612. * @param options defines the options used to create the mesh
  28613. * @param scene defines the hosting scene
  28614. * @returns the icosahedron mesh
  28615. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28616. */
  28617. static CreateIcoSphere(name: string, options: {
  28618. radius?: number;
  28619. radiusX?: number;
  28620. radiusY?: number;
  28621. radiusZ?: number;
  28622. flat?: boolean;
  28623. subdivisions?: number;
  28624. sideOrientation?: number;
  28625. frontUVs?: Vector4;
  28626. backUVs?: Vector4;
  28627. updatable?: boolean;
  28628. }, scene: Scene): Mesh;
  28629. /**
  28630. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28631. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28632. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28633. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28634. * * 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
  28635. * * 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
  28636. * * 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
  28637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28638. * * 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
  28639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28640. * * 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
  28641. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28642. * * 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
  28643. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28645. * @param name defines the name of the mesh
  28646. * @param options defines the options used to create the mesh
  28647. * @param scene defines the hosting scene
  28648. * @returns the ribbon mesh
  28649. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28651. */
  28652. static CreateRibbon(name: string, options: {
  28653. pathArray: Vector3[][];
  28654. closeArray?: boolean;
  28655. closePath?: boolean;
  28656. offset?: number;
  28657. updatable?: boolean;
  28658. sideOrientation?: number;
  28659. frontUVs?: Vector4;
  28660. backUVs?: Vector4;
  28661. instance?: Mesh;
  28662. invertUV?: boolean;
  28663. uvs?: Vector2[];
  28664. colors?: Color4[];
  28665. }, scene?: Nullable<Scene>): Mesh;
  28666. /**
  28667. * Creates a cylinder or a cone mesh
  28668. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28669. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28670. * * 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.
  28671. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28672. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28673. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28674. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28675. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28676. * * 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).
  28677. * * 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
  28678. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28679. * * 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
  28680. * * 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.
  28681. * * If `enclose` is false, a ring surface is one element.
  28682. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28683. * * 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
  28684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28685. * * 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
  28686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28687. * @param name defines the name of the mesh
  28688. * @param options defines the options used to create the mesh
  28689. * @param scene defines the hosting scene
  28690. * @returns the cylinder mesh
  28691. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28692. */
  28693. static CreateCylinder(name: string, options: {
  28694. height?: number;
  28695. diameterTop?: number;
  28696. diameterBottom?: number;
  28697. diameter?: number;
  28698. tessellation?: number;
  28699. subdivisions?: number;
  28700. arc?: number;
  28701. faceColors?: Color4[];
  28702. faceUV?: Vector4[];
  28703. updatable?: boolean;
  28704. hasRings?: boolean;
  28705. enclose?: boolean;
  28706. sideOrientation?: number;
  28707. frontUVs?: Vector4;
  28708. backUVs?: Vector4;
  28709. }, scene: any): Mesh;
  28710. /**
  28711. * Creates a torus mesh
  28712. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28713. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28714. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28716. * * 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
  28717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28718. * @param name defines the name of the mesh
  28719. * @param options defines the options used to create the mesh
  28720. * @param scene defines the hosting scene
  28721. * @returns the torus mesh
  28722. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28723. */
  28724. static CreateTorus(name: string, options: {
  28725. diameter?: number;
  28726. thickness?: number;
  28727. tessellation?: number;
  28728. updatable?: boolean;
  28729. sideOrientation?: number;
  28730. frontUVs?: Vector4;
  28731. backUVs?: Vector4;
  28732. }, scene: any): Mesh;
  28733. /**
  28734. * Creates a torus knot mesh
  28735. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28736. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28737. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28738. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28740. * * 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
  28741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28742. * @param name defines the name of the mesh
  28743. * @param options defines the options used to create the mesh
  28744. * @param scene defines the hosting scene
  28745. * @returns the torus knot mesh
  28746. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28747. */
  28748. static CreateTorusKnot(name: string, options: {
  28749. radius?: number;
  28750. tube?: number;
  28751. radialSegments?: number;
  28752. tubularSegments?: number;
  28753. p?: number;
  28754. q?: number;
  28755. updatable?: boolean;
  28756. sideOrientation?: number;
  28757. frontUVs?: Vector4;
  28758. backUVs?: Vector4;
  28759. }, scene: any): Mesh;
  28760. /**
  28761. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28762. * * 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
  28763. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28764. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28765. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28766. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28767. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28768. * * 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
  28769. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28772. * @param name defines the name of the new line system
  28773. * @param options defines the options used to create the line system
  28774. * @param scene defines the hosting scene
  28775. * @returns a new line system mesh
  28776. */
  28777. static CreateLineSystem(name: string, options: {
  28778. lines: Vector3[][];
  28779. updatable?: boolean;
  28780. instance?: Nullable<LinesMesh>;
  28781. colors?: Nullable<Color4[][]>;
  28782. useVertexAlpha?: boolean;
  28783. }, scene: Nullable<Scene>): LinesMesh;
  28784. /**
  28785. * Creates a line mesh
  28786. * 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
  28787. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28788. * * The parameter `points` is an array successive Vector3
  28789. * * 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
  28790. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28791. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28792. * * When updating an instance, remember that only point positions can change, not the number of points
  28793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28795. * @param name defines the name of the new line system
  28796. * @param options defines the options used to create the line system
  28797. * @param scene defines the hosting scene
  28798. * @returns a new line mesh
  28799. */
  28800. static CreateLines(name: string, options: {
  28801. points: Vector3[];
  28802. updatable?: boolean;
  28803. instance?: Nullable<LinesMesh>;
  28804. colors?: Color4[];
  28805. useVertexAlpha?: boolean;
  28806. }, scene?: Nullable<Scene>): LinesMesh;
  28807. /**
  28808. * Creates a dashed line mesh
  28809. * * 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
  28810. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28811. * * The parameter `points` is an array successive Vector3
  28812. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28813. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28814. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28815. * * 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
  28816. * * When updating an instance, remember that only point positions can change, not the number of points
  28817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28818. * @param name defines the name of the mesh
  28819. * @param options defines the options used to create the mesh
  28820. * @param scene defines the hosting scene
  28821. * @returns the dashed line mesh
  28822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28823. */
  28824. static CreateDashedLines(name: string, options: {
  28825. points: Vector3[];
  28826. dashSize?: number;
  28827. gapSize?: number;
  28828. dashNb?: number;
  28829. updatable?: boolean;
  28830. instance?: LinesMesh;
  28831. }, scene?: Nullable<Scene>): LinesMesh;
  28832. /**
  28833. * 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.
  28834. * * 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.
  28835. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28836. * * 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.
  28837. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28838. * * 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
  28839. * * 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
  28840. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28842. * * 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
  28843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28845. * @param name defines the name of the mesh
  28846. * @param options defines the options used to create the mesh
  28847. * @param scene defines the hosting scene
  28848. * @returns the extruded shape mesh
  28849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28851. */
  28852. static ExtrudeShape(name: string, options: {
  28853. shape: Vector3[];
  28854. path: Vector3[];
  28855. scale?: number;
  28856. rotation?: number;
  28857. cap?: number;
  28858. updatable?: boolean;
  28859. sideOrientation?: number;
  28860. frontUVs?: Vector4;
  28861. backUVs?: Vector4;
  28862. instance?: Mesh;
  28863. invertUV?: boolean;
  28864. }, scene?: Nullable<Scene>): Mesh;
  28865. /**
  28866. * Creates an custom extruded shape mesh.
  28867. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28868. * * 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.
  28869. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28870. * * 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
  28871. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28872. * * 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
  28873. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28874. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28875. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28876. * * 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
  28877. * * 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
  28878. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28880. * * 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
  28881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28883. * @param name defines the name of the mesh
  28884. * @param options defines the options used to create the mesh
  28885. * @param scene defines the hosting scene
  28886. * @returns the custom extruded shape mesh
  28887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28890. */
  28891. static ExtrudeShapeCustom(name: string, options: {
  28892. shape: Vector3[];
  28893. path: Vector3[];
  28894. scaleFunction?: any;
  28895. rotationFunction?: any;
  28896. ribbonCloseArray?: boolean;
  28897. ribbonClosePath?: boolean;
  28898. cap?: number;
  28899. updatable?: boolean;
  28900. sideOrientation?: number;
  28901. frontUVs?: Vector4;
  28902. backUVs?: Vector4;
  28903. instance?: Mesh;
  28904. invertUV?: boolean;
  28905. }, scene: Scene): Mesh;
  28906. /**
  28907. * Creates lathe mesh.
  28908. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28909. * * 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
  28910. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28911. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28912. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28913. * * 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
  28914. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28915. * * 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
  28916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28917. * * 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
  28918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28920. * @param name defines the name of the mesh
  28921. * @param options defines the options used to create the mesh
  28922. * @param scene defines the hosting scene
  28923. * @returns the lathe mesh
  28924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28925. */
  28926. static CreateLathe(name: string, options: {
  28927. shape: Vector3[];
  28928. radius?: number;
  28929. tessellation?: number;
  28930. clip?: number;
  28931. arc?: number;
  28932. closed?: boolean;
  28933. updatable?: boolean;
  28934. sideOrientation?: number;
  28935. frontUVs?: Vector4;
  28936. backUVs?: Vector4;
  28937. cap?: number;
  28938. invertUV?: boolean;
  28939. }, scene: Scene): Mesh;
  28940. /**
  28941. * Creates a plane mesh
  28942. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28943. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28944. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28946. * * 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
  28947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28948. * @param name defines the name of the mesh
  28949. * @param options defines the options used to create the mesh
  28950. * @param scene defines the hosting scene
  28951. * @returns the plane mesh
  28952. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28953. */
  28954. static CreatePlane(name: string, options: {
  28955. size?: number;
  28956. width?: number;
  28957. height?: number;
  28958. sideOrientation?: number;
  28959. frontUVs?: Vector4;
  28960. backUVs?: Vector4;
  28961. updatable?: boolean;
  28962. sourcePlane?: Plane;
  28963. }, scene: Scene): Mesh;
  28964. /**
  28965. * Creates a ground mesh
  28966. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28967. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28969. * @param name defines the name of the mesh
  28970. * @param options defines the options used to create the mesh
  28971. * @param scene defines the hosting scene
  28972. * @returns the ground mesh
  28973. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28974. */
  28975. static CreateGround(name: string, options: {
  28976. width?: number;
  28977. height?: number;
  28978. subdivisions?: number;
  28979. subdivisionsX?: number;
  28980. subdivisionsY?: number;
  28981. updatable?: boolean;
  28982. }, scene: any): Mesh;
  28983. /**
  28984. * Creates a tiled ground mesh
  28985. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28986. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28987. * * 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
  28988. * * 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
  28989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28990. * @param name defines the name of the mesh
  28991. * @param options defines the options used to create the mesh
  28992. * @param scene defines the hosting scene
  28993. * @returns the tiled ground mesh
  28994. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28995. */
  28996. static CreateTiledGround(name: string, options: {
  28997. xmin: number;
  28998. zmin: number;
  28999. xmax: number;
  29000. zmax: number;
  29001. subdivisions?: {
  29002. w: number;
  29003. h: number;
  29004. };
  29005. precision?: {
  29006. w: number;
  29007. h: number;
  29008. };
  29009. updatable?: boolean;
  29010. }, scene: Scene): Mesh;
  29011. /**
  29012. * Creates a ground mesh from a height map
  29013. * * The parameter `url` sets the URL of the height map image resource.
  29014. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  29015. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  29016. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  29017. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  29018. * * 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.
  29019. * * 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).
  29020. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29022. * @param name defines the name of the mesh
  29023. * @param url defines the url to the height map
  29024. * @param options defines the options used to create the mesh
  29025. * @param scene defines the hosting scene
  29026. * @returns the ground mesh
  29027. * @see https://doc.babylonjs.com/babylon101/height_map
  29028. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  29029. */
  29030. static CreateGroundFromHeightMap(name: string, url: string, options: {
  29031. width?: number;
  29032. height?: number;
  29033. subdivisions?: number;
  29034. minHeight?: number;
  29035. maxHeight?: number;
  29036. colorFilter?: Color3;
  29037. alphaFilter?: number;
  29038. updatable?: boolean;
  29039. onReady?: (mesh: GroundMesh) => void;
  29040. }, scene: Scene): GroundMesh;
  29041. /**
  29042. * Creates a polygon mesh
  29043. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  29044. * * 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
  29045. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29047. * * 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)
  29048. * * Remember you can only change the shape positions, not their number when updating a polygon
  29049. * @param name defines the name of the mesh
  29050. * @param options defines the options used to create the mesh
  29051. * @param scene defines the hosting scene
  29052. * @returns the polygon mesh
  29053. */
  29054. static CreatePolygon(name: string, options: {
  29055. shape: Vector3[];
  29056. holes?: Vector3[][];
  29057. depth?: number;
  29058. faceUV?: Vector4[];
  29059. faceColors?: Color4[];
  29060. updatable?: boolean;
  29061. sideOrientation?: number;
  29062. frontUVs?: Vector4;
  29063. backUVs?: Vector4;
  29064. }, scene: Scene): Mesh;
  29065. /**
  29066. * Creates an extruded polygon mesh, with depth in the Y direction.
  29067. * * 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)
  29068. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  29069. * @param name defines the name of the mesh
  29070. * @param options defines the options used to create the mesh
  29071. * @param scene defines the hosting scene
  29072. * @returns the polygon mesh
  29073. */
  29074. static ExtrudePolygon(name: string, options: {
  29075. shape: Vector3[];
  29076. holes?: Vector3[][];
  29077. depth?: number;
  29078. faceUV?: Vector4[];
  29079. faceColors?: Color4[];
  29080. updatable?: boolean;
  29081. sideOrientation?: number;
  29082. frontUVs?: Vector4;
  29083. backUVs?: Vector4;
  29084. }, scene: Scene): Mesh;
  29085. /**
  29086. * Creates a tube mesh.
  29087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  29088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  29089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  29090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  29091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  29092. * * 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)
  29093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  29094. * * 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
  29095. * * 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
  29096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29097. * * 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
  29098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  29099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29100. * @param name defines the name of the mesh
  29101. * @param options defines the options used to create the mesh
  29102. * @param scene defines the hosting scene
  29103. * @returns the tube mesh
  29104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  29106. */
  29107. static CreateTube(name: string, options: {
  29108. path: Vector3[];
  29109. radius?: number;
  29110. tessellation?: number;
  29111. radiusFunction?: {
  29112. (i: number, distance: number): number;
  29113. };
  29114. cap?: number;
  29115. arc?: number;
  29116. updatable?: boolean;
  29117. sideOrientation?: number;
  29118. frontUVs?: Vector4;
  29119. backUVs?: Vector4;
  29120. instance?: Mesh;
  29121. invertUV?: boolean;
  29122. }, scene: Scene): Mesh;
  29123. /**
  29124. * Creates a polyhedron mesh
  29125. * * 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
  29126. * * The parameter `size` (positive float, default 1) sets the polygon size
  29127. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29128. * * 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`
  29129. * * 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
  29130. * * 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)`)
  29131. * * 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
  29132. * * 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
  29133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29134. * * 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
  29135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29136. * @param name defines the name of the mesh
  29137. * @param options defines the options used to create the mesh
  29138. * @param scene defines the hosting scene
  29139. * @returns the polyhedron mesh
  29140. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  29141. */
  29142. static CreatePolyhedron(name: string, options: {
  29143. type?: number;
  29144. size?: number;
  29145. sizeX?: number;
  29146. sizeY?: number;
  29147. sizeZ?: number;
  29148. custom?: any;
  29149. faceUV?: Vector4[];
  29150. faceColors?: Color4[];
  29151. flat?: boolean;
  29152. updatable?: boolean;
  29153. sideOrientation?: number;
  29154. frontUVs?: Vector4;
  29155. backUVs?: Vector4;
  29156. }, scene: Scene): Mesh;
  29157. /**
  29158. * Creates a decal mesh.
  29159. * 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
  29160. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  29161. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  29162. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  29163. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  29164. * @param name defines the name of the mesh
  29165. * @param sourceMesh defines the mesh where the decal must be applied
  29166. * @param options defines the options used to create the mesh
  29167. * @param scene defines the hosting scene
  29168. * @returns the decal mesh
  29169. * @see https://doc.babylonjs.com/how_to/decals
  29170. */
  29171. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  29172. position?: Vector3;
  29173. normal?: Vector3;
  29174. size?: Vector3;
  29175. angle?: number;
  29176. }): Mesh;
  29177. private static _ExtrudeShapeGeneric;
  29178. }
  29179. }
  29180. declare module BABYLON {
  29181. /**
  29182. * Class used to represent a specific level of detail of a mesh
  29183. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  29184. */
  29185. class MeshLODLevel {
  29186. /** Defines the distance where this level should star being displayed */
  29187. distance: number;
  29188. /** Defines the mesh to use to render this level */
  29189. mesh: Nullable<Mesh>;
  29190. /**
  29191. * Creates a new LOD level
  29192. * @param distance defines the distance where this level should star being displayed
  29193. * @param mesh defines the mesh to use to render this level
  29194. */
  29195. constructor(
  29196. /** Defines the distance where this level should star being displayed */
  29197. distance: number,
  29198. /** Defines the mesh to use to render this level */
  29199. mesh: Nullable<Mesh>);
  29200. }
  29201. }
  29202. declare module BABYLON {
  29203. /**
  29204. * A simplifier interface for future simplification implementations
  29205. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29206. */
  29207. interface ISimplifier {
  29208. /**
  29209. * Simplification of a given mesh according to the given settings.
  29210. * Since this requires computation, it is assumed that the function runs async.
  29211. * @param settings The settings of the simplification, including quality and distance
  29212. * @param successCallback A callback that will be called after the mesh was simplified.
  29213. * @param errorCallback in case of an error, this callback will be called. optional.
  29214. */
  29215. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  29216. }
  29217. /**
  29218. * Expected simplification settings.
  29219. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  29220. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29221. */
  29222. interface ISimplificationSettings {
  29223. /**
  29224. * Gets or sets the expected quality
  29225. */
  29226. quality: number;
  29227. /**
  29228. * Gets or sets the distance when this optimized version should be used
  29229. */
  29230. distance: number;
  29231. /**
  29232. * Gets an already optimized mesh
  29233. */
  29234. optimizeMesh?: boolean;
  29235. }
  29236. /**
  29237. * Class used to specify simplification options
  29238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29239. */
  29240. class SimplificationSettings implements ISimplificationSettings {
  29241. /** expected quality */
  29242. quality: number;
  29243. /** distance when this optimized version should be used */
  29244. distance: number;
  29245. /** already optimized mesh */
  29246. optimizeMesh?: boolean | undefined;
  29247. /**
  29248. * Creates a SimplificationSettings
  29249. * @param quality expected quality
  29250. * @param distance distance when this optimized version should be used
  29251. * @param optimizeMesh already optimized mesh
  29252. */
  29253. constructor(
  29254. /** expected quality */
  29255. quality: number,
  29256. /** distance when this optimized version should be used */
  29257. distance: number,
  29258. /** already optimized mesh */
  29259. optimizeMesh?: boolean | undefined);
  29260. }
  29261. /**
  29262. * Interface used to define a simplification task
  29263. */
  29264. interface ISimplificationTask {
  29265. /**
  29266. * Array of settings
  29267. */
  29268. settings: Array<ISimplificationSettings>;
  29269. /**
  29270. * Simplification type
  29271. */
  29272. simplificationType: SimplificationType;
  29273. /**
  29274. * Mesh to simplify
  29275. */
  29276. mesh: Mesh;
  29277. /**
  29278. * Callback called on success
  29279. */
  29280. successCallback?: () => void;
  29281. /**
  29282. * Defines if parallel processing can be used
  29283. */
  29284. parallelProcessing: boolean;
  29285. }
  29286. /**
  29287. * Queue used to order the simplification tasks
  29288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29289. */
  29290. class SimplificationQueue {
  29291. private _simplificationArray;
  29292. /**
  29293. * Gets a boolean indicating that the process is still running
  29294. */
  29295. running: boolean;
  29296. /**
  29297. * Creates a new queue
  29298. */
  29299. constructor();
  29300. /**
  29301. * Adds a new simplification task
  29302. * @param task defines a task to add
  29303. */
  29304. addTask(task: ISimplificationTask): void;
  29305. /**
  29306. * Execute next task
  29307. */
  29308. executeNext(): void;
  29309. /**
  29310. * Execute a simplification task
  29311. * @param task defines the task to run
  29312. */
  29313. runSimplification(task: ISimplificationTask): void;
  29314. private getSimplifier;
  29315. }
  29316. /**
  29317. * The implemented types of simplification
  29318. * At the moment only Quadratic Error Decimation is implemented
  29319. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29320. */
  29321. enum SimplificationType {
  29322. /** Quadratic error decimation */
  29323. QUADRATIC = 0
  29324. }
  29325. }
  29326. declare module BABYLON {
  29327. interface Scene {
  29328. /** @hidden (Backing field) */
  29329. _simplificationQueue: SimplificationQueue;
  29330. /**
  29331. * Gets or sets the simplification queue attached to the scene
  29332. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29333. */
  29334. simplificationQueue: SimplificationQueue;
  29335. }
  29336. interface Mesh {
  29337. /**
  29338. * Simplify the mesh according to the given array of settings.
  29339. * Function will return immediately and will simplify async
  29340. * @param settings a collection of simplification settings
  29341. * @param parallelProcessing should all levels calculate parallel or one after the other
  29342. * @param simplificationType the type of simplification to run
  29343. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29344. * @returns the current mesh
  29345. */
  29346. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29347. }
  29348. /**
  29349. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29350. * created in a scene
  29351. */
  29352. class SimplicationQueueSceneComponent implements ISceneComponent {
  29353. /**
  29354. * The component name helpfull to identify the component in the list of scene components.
  29355. */
  29356. readonly name: string;
  29357. /**
  29358. * The scene the component belongs to.
  29359. */
  29360. scene: Scene;
  29361. /**
  29362. * Creates a new instance of the component for the given scene
  29363. * @param scene Defines the scene to register the component in
  29364. */
  29365. constructor(scene: Scene);
  29366. /**
  29367. * Registers the component in a given scene
  29368. */
  29369. register(): void;
  29370. /**
  29371. * Rebuilds the elements related to this component in case of
  29372. * context lost for instance.
  29373. */
  29374. rebuild(): void;
  29375. /**
  29376. * Disposes the component and the associated ressources
  29377. */
  29378. dispose(): void;
  29379. private _beforeCameraUpdate;
  29380. }
  29381. }
  29382. declare module BABYLON {
  29383. /**
  29384. * Polygon
  29385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29386. */
  29387. class Polygon {
  29388. /**
  29389. * Creates a rectangle
  29390. * @param xmin bottom X coord
  29391. * @param ymin bottom Y coord
  29392. * @param xmax top X coord
  29393. * @param ymax top Y coord
  29394. * @returns points that make the resulting rectation
  29395. */
  29396. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29397. /**
  29398. * Creates a circle
  29399. * @param radius radius of circle
  29400. * @param cx scale in x
  29401. * @param cy scale in y
  29402. * @param numberOfSides number of sides that make up the circle
  29403. * @returns points that make the resulting circle
  29404. */
  29405. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29406. /**
  29407. * Creates a polygon from input string
  29408. * @param input Input polygon data
  29409. * @returns the parsed points
  29410. */
  29411. static Parse(input: string): Vector2[];
  29412. /**
  29413. * Starts building a polygon from x and y coordinates
  29414. * @param x x coordinate
  29415. * @param y y coordinate
  29416. * @returns the started path2
  29417. */
  29418. static StartingAt(x: number, y: number): Path2;
  29419. }
  29420. /**
  29421. * Builds a polygon
  29422. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29423. */
  29424. class PolygonMeshBuilder {
  29425. private _points;
  29426. private _outlinepoints;
  29427. private _holes;
  29428. private _name;
  29429. private _scene;
  29430. private _epoints;
  29431. private _eholes;
  29432. private _addToepoint;
  29433. /**
  29434. * Creates a PolygonMeshBuilder
  29435. * @param name name of the builder
  29436. * @param contours Path of the polygon
  29437. * @param scene scene to add to
  29438. */
  29439. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29440. /**
  29441. * Adds a whole within the polygon
  29442. * @param hole Array of points defining the hole
  29443. * @returns this
  29444. */
  29445. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29446. /**
  29447. * Creates the polygon
  29448. * @param updatable If the mesh should be updatable
  29449. * @param depth The depth of the mesh created
  29450. * @returns the created mesh
  29451. */
  29452. build(updatable?: boolean, depth?: number): Mesh;
  29453. /**
  29454. * Adds a side to the polygon
  29455. * @param positions points that make the polygon
  29456. * @param normals normals of the polygon
  29457. * @param uvs uvs of the polygon
  29458. * @param indices indices of the polygon
  29459. * @param bounds bounds of the polygon
  29460. * @param points points of the polygon
  29461. * @param depth depth of the polygon
  29462. * @param flip flip of the polygon
  29463. */
  29464. private addSide;
  29465. }
  29466. }
  29467. declare module BABYLON {
  29468. /**
  29469. * Base class for submeshes
  29470. */
  29471. class BaseSubMesh {
  29472. /** @hidden */
  29473. _materialDefines: Nullable<MaterialDefines>;
  29474. /** @hidden */
  29475. _materialEffect: Nullable<Effect>;
  29476. /**
  29477. * Gets associated effect
  29478. */
  29479. readonly effect: Nullable<Effect>;
  29480. /**
  29481. * Sets associated effect (effect used to render this submesh)
  29482. * @param effect defines the effect to associate with
  29483. * @param defines defines the set of defines used to compile this effect
  29484. */
  29485. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29486. }
  29487. /**
  29488. * Defines a subdivision inside a mesh
  29489. */
  29490. class SubMesh extends BaseSubMesh implements ICullable {
  29491. /** the material index to use */
  29492. materialIndex: number;
  29493. /** vertex index start */
  29494. verticesStart: number;
  29495. /** vertices count */
  29496. verticesCount: number;
  29497. /** index start */
  29498. indexStart: number;
  29499. /** indices count */
  29500. indexCount: number;
  29501. /** @hidden */
  29502. _linesIndexCount: number;
  29503. private _mesh;
  29504. private _renderingMesh;
  29505. private _boundingInfo;
  29506. private _linesIndexBuffer;
  29507. /** @hidden */
  29508. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29509. /** @hidden */
  29510. _trianglePlanes: Plane[];
  29511. /** @hidden */
  29512. _lastColliderTransformMatrix: Matrix;
  29513. /** @hidden */
  29514. _renderId: number;
  29515. /** @hidden */
  29516. _alphaIndex: number;
  29517. /** @hidden */
  29518. _distanceToCamera: number;
  29519. /** @hidden */
  29520. _id: number;
  29521. private _currentMaterial;
  29522. /**
  29523. * Add a new submesh to a mesh
  29524. * @param materialIndex defines the material index to use
  29525. * @param verticesStart defines vertex index start
  29526. * @param verticesCount defines vertices count
  29527. * @param indexStart defines index start
  29528. * @param indexCount defines indices count
  29529. * @param mesh defines the parent mesh
  29530. * @param renderingMesh defines an optional rendering mesh
  29531. * @param createBoundingBox defines if bounding box should be created for this submesh
  29532. * @returns the new submesh
  29533. */
  29534. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29535. /**
  29536. * Creates a new submesh
  29537. * @param materialIndex defines the material index to use
  29538. * @param verticesStart defines vertex index start
  29539. * @param verticesCount defines vertices count
  29540. * @param indexStart defines index start
  29541. * @param indexCount defines indices count
  29542. * @param mesh defines the parent mesh
  29543. * @param renderingMesh defines an optional rendering mesh
  29544. * @param createBoundingBox defines if bounding box should be created for this submesh
  29545. */
  29546. constructor(
  29547. /** the material index to use */
  29548. materialIndex: number,
  29549. /** vertex index start */
  29550. verticesStart: number,
  29551. /** vertices count */
  29552. verticesCount: number,
  29553. /** index start */
  29554. indexStart: number,
  29555. /** indices count */
  29556. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29557. /**
  29558. * Returns true if this submesh covers the entire parent mesh
  29559. * @ignorenaming
  29560. */
  29561. readonly IsGlobal: boolean;
  29562. /**
  29563. * Returns the submesh BoudingInfo object
  29564. * @returns current bounding info (or mesh's one if the submesh is global)
  29565. */
  29566. getBoundingInfo(): BoundingInfo;
  29567. /**
  29568. * Sets the submesh BoundingInfo
  29569. * @param boundingInfo defines the new bounding info to use
  29570. * @returns the SubMesh
  29571. */
  29572. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29573. /**
  29574. * Returns the mesh of the current submesh
  29575. * @return the parent mesh
  29576. */
  29577. getMesh(): AbstractMesh;
  29578. /**
  29579. * Returns the rendering mesh of the submesh
  29580. * @returns the rendering mesh (could be different from parent mesh)
  29581. */
  29582. getRenderingMesh(): Mesh;
  29583. /**
  29584. * Returns the submesh material
  29585. * @returns null or the current material
  29586. */
  29587. getMaterial(): Nullable<Material>;
  29588. /**
  29589. * Sets a new updated BoundingInfo object to the submesh
  29590. * @returns the SubMesh
  29591. */
  29592. refreshBoundingInfo(): SubMesh;
  29593. /** @hidden */
  29594. _checkCollision(collider: Collider): boolean;
  29595. /**
  29596. * Updates the submesh BoundingInfo
  29597. * @param world defines the world matrix to use to update the bounding info
  29598. * @returns the submesh
  29599. */
  29600. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29601. /**
  29602. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29603. * @param frustumPlanes defines the frustum planes
  29604. * @returns true if the submesh is intersecting with the frustum
  29605. */
  29606. isInFrustum(frustumPlanes: Plane[]): boolean;
  29607. /**
  29608. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29609. * @param frustumPlanes defines the frustum planes
  29610. * @returns true if the submesh is inside the frustum
  29611. */
  29612. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29613. /**
  29614. * Renders the submesh
  29615. * @param enableAlphaMode defines if alpha needs to be used
  29616. * @returns the submesh
  29617. */
  29618. render(enableAlphaMode: boolean): SubMesh;
  29619. /**
  29620. * @hidden
  29621. */
  29622. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29623. /**
  29624. * Checks if the submesh intersects with a ray
  29625. * @param ray defines the ray to test
  29626. * @returns true is the passed ray intersects the submesh bounding box
  29627. */
  29628. canIntersects(ray: Ray): boolean;
  29629. /**
  29630. * Intersects current submesh with a ray
  29631. * @param ray defines the ray to test
  29632. * @param positions defines mesh's positions array
  29633. * @param indices defines mesh's indices array
  29634. * @param fastCheck defines if only bounding info should be used
  29635. * @returns intersection info or null if no intersection
  29636. */
  29637. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29638. /** @hidden */
  29639. private _intersectLines;
  29640. /** @hidden */
  29641. private _intersectTriangles;
  29642. /** @hidden */
  29643. _rebuild(): void;
  29644. /**
  29645. * Creates a new submesh from the passed mesh
  29646. * @param newMesh defines the new hosting mesh
  29647. * @param newRenderingMesh defines an optional rendering mesh
  29648. * @returns the new submesh
  29649. */
  29650. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29651. /**
  29652. * Release associated resources
  29653. */
  29654. dispose(): void;
  29655. /**
  29656. * Creates a new submesh from indices data
  29657. * @param materialIndex the index of the main mesh material
  29658. * @param startIndex the index where to start the copy in the mesh indices array
  29659. * @param indexCount the number of indices to copy then from the startIndex
  29660. * @param mesh the main mesh to create the submesh from
  29661. * @param renderingMesh the optional rendering mesh
  29662. * @returns a new submesh
  29663. */
  29664. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29665. }
  29666. }
  29667. declare module BABYLON {
  29668. /**
  29669. * 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.
  29670. * @see https://doc.babylonjs.com/how_to/transformnode
  29671. */
  29672. class TransformNode extends Node {
  29673. /**
  29674. * Object will not rotate to face the camera
  29675. */
  29676. static BILLBOARDMODE_NONE: number;
  29677. /**
  29678. * Object will rotate to face the camera but only on the x axis
  29679. */
  29680. static BILLBOARDMODE_X: number;
  29681. /**
  29682. * Object will rotate to face the camera but only on the y axis
  29683. */
  29684. static BILLBOARDMODE_Y: number;
  29685. /**
  29686. * Object will rotate to face the camera but only on the z axis
  29687. */
  29688. static BILLBOARDMODE_Z: number;
  29689. /**
  29690. * Object will rotate to face the camera
  29691. */
  29692. static BILLBOARDMODE_ALL: number;
  29693. private _forward;
  29694. private _forwardInverted;
  29695. private _up;
  29696. private _right;
  29697. private _rightInverted;
  29698. private _position;
  29699. private _rotation;
  29700. private _rotationQuaternion;
  29701. protected _scaling: Vector3;
  29702. protected _isDirty: boolean;
  29703. private _transformToBoneReferal;
  29704. /**
  29705. * Set the billboard mode. Default is 0.
  29706. *
  29707. * | Value | Type | Description |
  29708. * | --- | --- | --- |
  29709. * | 0 | BILLBOARDMODE_NONE | |
  29710. * | 1 | BILLBOARDMODE_X | |
  29711. * | 2 | BILLBOARDMODE_Y | |
  29712. * | 4 | BILLBOARDMODE_Z | |
  29713. * | 7 | BILLBOARDMODE_ALL | |
  29714. *
  29715. */
  29716. billboardMode: number;
  29717. /**
  29718. * 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
  29719. */
  29720. scalingDeterminant: number;
  29721. /**
  29722. * Sets the distance of the object to max, often used by skybox
  29723. */
  29724. infiniteDistance: boolean;
  29725. /**
  29726. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29727. * By default the system will update normals to compensate
  29728. */
  29729. ignoreNonUniformScaling: boolean;
  29730. /** @hidden */
  29731. _poseMatrix: Matrix;
  29732. /** @hidden */
  29733. _localMatrix: Matrix;
  29734. private _absolutePosition;
  29735. private _pivotMatrix;
  29736. private _pivotMatrixInverse;
  29737. protected _postMultiplyPivotMatrix: boolean;
  29738. protected _isWorldMatrixFrozen: boolean;
  29739. /** @hidden */
  29740. _indexInSceneTransformNodesArray: number;
  29741. /**
  29742. * An event triggered after the world matrix is updated
  29743. */
  29744. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29745. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29746. /**
  29747. * Gets a string identifying the name of the class
  29748. * @returns "TransformNode" string
  29749. */
  29750. getClassName(): string;
  29751. /**
  29752. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29753. */
  29754. position: Vector3;
  29755. /**
  29756. * 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)).
  29757. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29758. */
  29759. rotation: Vector3;
  29760. /**
  29761. * 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)).
  29762. */
  29763. scaling: Vector3;
  29764. /**
  29765. * 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).
  29766. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29767. */
  29768. rotationQuaternion: Nullable<Quaternion>;
  29769. /**
  29770. * The forward direction of that transform in world space.
  29771. */
  29772. readonly forward: Vector3;
  29773. /**
  29774. * The up direction of that transform in world space.
  29775. */
  29776. readonly up: Vector3;
  29777. /**
  29778. * The right direction of that transform in world space.
  29779. */
  29780. readonly right: Vector3;
  29781. /**
  29782. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29783. * @param matrix the matrix to copy the pose from
  29784. * @returns this TransformNode.
  29785. */
  29786. updatePoseMatrix(matrix: Matrix): TransformNode;
  29787. /**
  29788. * Returns the mesh Pose matrix.
  29789. * @returns the pose matrix
  29790. */
  29791. getPoseMatrix(): Matrix;
  29792. /** @hidden */
  29793. _isSynchronized(): boolean;
  29794. /** @hidden */
  29795. _initCache(): void;
  29796. /**
  29797. * Flag the transform node as dirty (Forcing it to update everything)
  29798. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29799. * @returns this transform node
  29800. */
  29801. markAsDirty(property: string): TransformNode;
  29802. /**
  29803. * Returns the current mesh absolute position.
  29804. * Returns a Vector3.
  29805. */
  29806. readonly absolutePosition: Vector3;
  29807. /**
  29808. * Sets a new matrix to apply before all other transformation
  29809. * @param matrix defines the transform matrix
  29810. * @returns the current TransformNode
  29811. */
  29812. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29813. /**
  29814. * Sets a new pivot matrix to the current node
  29815. * @param matrix defines the new pivot matrix to use
  29816. * @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
  29817. * @returns the current TransformNode
  29818. */
  29819. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29820. /**
  29821. * Returns the mesh pivot matrix.
  29822. * Default : Identity.
  29823. * @returns the matrix
  29824. */
  29825. getPivotMatrix(): Matrix;
  29826. /**
  29827. * Prevents the World matrix to be computed any longer.
  29828. * @returns the TransformNode.
  29829. */
  29830. freezeWorldMatrix(): TransformNode;
  29831. /**
  29832. * Allows back the World matrix computation.
  29833. * @returns the TransformNode.
  29834. */
  29835. unfreezeWorldMatrix(): this;
  29836. /**
  29837. * True if the World matrix has been frozen.
  29838. */
  29839. readonly isWorldMatrixFrozen: boolean;
  29840. /**
  29841. * Retuns the mesh absolute position in the World.
  29842. * @returns a Vector3.
  29843. */
  29844. getAbsolutePosition(): Vector3;
  29845. /**
  29846. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29847. * @param absolutePosition the absolute position to set
  29848. * @returns the TransformNode.
  29849. */
  29850. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29851. /**
  29852. * Sets the mesh position in its local space.
  29853. * @param vector3 the position to set in localspace
  29854. * @returns the TransformNode.
  29855. */
  29856. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29857. /**
  29858. * Returns the mesh position in the local space from the current World matrix values.
  29859. * @returns a new Vector3.
  29860. */
  29861. getPositionExpressedInLocalSpace(): Vector3;
  29862. /**
  29863. * Translates the mesh along the passed Vector3 in its local space.
  29864. * @param vector3 the distance to translate in localspace
  29865. * @returns the TransformNode.
  29866. */
  29867. locallyTranslate(vector3: Vector3): TransformNode;
  29868. private static _lookAtVectorCache;
  29869. /**
  29870. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29871. * @param targetPoint the position (must be in same space as current mesh) to look at
  29872. * @param yawCor optional yaw (y-axis) correction in radians
  29873. * @param pitchCor optional pitch (x-axis) correction in radians
  29874. * @param rollCor optional roll (z-axis) correction in radians
  29875. * @param space the choosen space of the target
  29876. * @returns the TransformNode.
  29877. */
  29878. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29879. /**
  29880. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29881. * This Vector3 is expressed in the World space.
  29882. * @param localAxis axis to rotate
  29883. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29884. */
  29885. getDirection(localAxis: Vector3): Vector3;
  29886. /**
  29887. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29888. * localAxis is expressed in the mesh local space.
  29889. * result is computed in the Wordl space from the mesh World matrix.
  29890. * @param localAxis axis to rotate
  29891. * @param result the resulting transformnode
  29892. * @returns this TransformNode.
  29893. */
  29894. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29895. /**
  29896. * Sets this transform node rotation to the given local axis.
  29897. * @param localAxis the axis in local space
  29898. * @param yawCor optional yaw (y-axis) correction in radians
  29899. * @param pitchCor optional pitch (x-axis) correction in radians
  29900. * @param rollCor optional roll (z-axis) correction in radians
  29901. * @returns this TransformNode
  29902. */
  29903. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29904. /**
  29905. * Sets a new pivot point to the current node
  29906. * @param point defines the new pivot point to use
  29907. * @param space defines if the point is in world or local space (local by default)
  29908. * @returns the current TransformNode
  29909. */
  29910. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29911. /**
  29912. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29913. * @returns the pivot point
  29914. */
  29915. getPivotPoint(): Vector3;
  29916. /**
  29917. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29918. * @param result the vector3 to store the result
  29919. * @returns this TransformNode.
  29920. */
  29921. getPivotPointToRef(result: Vector3): TransformNode;
  29922. /**
  29923. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29924. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29925. */
  29926. getAbsolutePivotPoint(): Vector3;
  29927. /**
  29928. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29929. * @param result vector3 to store the result
  29930. * @returns this TransformNode.
  29931. */
  29932. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29933. /**
  29934. * Defines the passed node as the parent of the current node.
  29935. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29936. * @param node the node ot set as the parent
  29937. * @returns this TransformNode.
  29938. */
  29939. setParent(node: Nullable<Node>): TransformNode;
  29940. private _nonUniformScaling;
  29941. /**
  29942. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29943. */
  29944. readonly nonUniformScaling: boolean;
  29945. /** @hidden */
  29946. _updateNonUniformScalingState(value: boolean): boolean;
  29947. /**
  29948. * Attach the current TransformNode to another TransformNode associated with a bone
  29949. * @param bone Bone affecting the TransformNode
  29950. * @param affectedTransformNode TransformNode associated with the bone
  29951. * @returns this object
  29952. */
  29953. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29954. /**
  29955. * Detach the transform node if its associated with a bone
  29956. * @returns this object
  29957. */
  29958. detachFromBone(): TransformNode;
  29959. private static _rotationAxisCache;
  29960. /**
  29961. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29962. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29963. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29964. * The passed axis is also normalized.
  29965. * @param axis the axis to rotate around
  29966. * @param amount the amount to rotate in radians
  29967. * @param space Space to rotate in (Default: local)
  29968. * @returns the TransformNode.
  29969. */
  29970. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29971. /**
  29972. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29973. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29974. * The passed axis is also normalized. .
  29975. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29976. * @param point the point to rotate around
  29977. * @param axis the axis to rotate around
  29978. * @param amount the amount to rotate in radians
  29979. * @returns the TransformNode
  29980. */
  29981. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29982. /**
  29983. * Translates the mesh along the axis vector for the passed distance in the given space.
  29984. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29985. * @param axis the axis to translate in
  29986. * @param distance the distance to translate
  29987. * @param space Space to rotate in (Default: local)
  29988. * @returns the TransformNode.
  29989. */
  29990. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29991. /**
  29992. * Adds a rotation step to the mesh current rotation.
  29993. * x, y, z are Euler angles expressed in radians.
  29994. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29995. * This means this rotation is made in the mesh local space only.
  29996. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29997. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29998. * ```javascript
  29999. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  30000. * ```
  30001. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  30002. * 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.
  30003. * @param x Rotation to add
  30004. * @param y Rotation to add
  30005. * @param z Rotation to add
  30006. * @returns the TransformNode.
  30007. */
  30008. addRotation(x: number, y: number, z: number): TransformNode;
  30009. /**
  30010. * Computes the world matrix of the node
  30011. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30012. * @returns the world matrix
  30013. */
  30014. computeWorldMatrix(force?: boolean): Matrix;
  30015. protected _afterComputeWorldMatrix(): void;
  30016. /**
  30017. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  30018. * @param func callback function to add
  30019. *
  30020. * @returns the TransformNode.
  30021. */
  30022. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  30023. /**
  30024. * Removes a registered callback function.
  30025. * @param func callback function to remove
  30026. * @returns the TransformNode.
  30027. */
  30028. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  30029. /**
  30030. * Gets the position of the current mesh in camera space
  30031. * @param camera defines the camera to use
  30032. * @returns a position
  30033. */
  30034. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  30035. /**
  30036. * Returns the distance from the mesh to the active camera
  30037. * @param camera defines the camera to use
  30038. * @returns the distance
  30039. */
  30040. getDistanceToCamera(camera?: Nullable<Camera>): number;
  30041. /**
  30042. * Clone the current transform node
  30043. * @param name Name of the new clone
  30044. * @param newParent New parent for the clone
  30045. * @param doNotCloneChildren Do not clone children hierarchy
  30046. * @returns the new transform node
  30047. */
  30048. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  30049. /**
  30050. * Serializes the objects information.
  30051. * @param currentSerializationObject defines the object to serialize in
  30052. * @returns the serialized object
  30053. */
  30054. serialize(currentSerializationObject?: any): any;
  30055. /**
  30056. * Returns a new TransformNode object parsed from the source provided.
  30057. * @param parsedTransformNode is the source.
  30058. * @param scene the scne the object belongs to
  30059. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  30060. * @returns a new TransformNode object parsed from the source provided.
  30061. */
  30062. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  30063. /**
  30064. * Releases resources associated with this transform node.
  30065. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30066. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30067. */
  30068. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30069. }
  30070. }
  30071. declare module BABYLON {
  30072. /**
  30073. * Specialized buffer used to store vertex data
  30074. */
  30075. class VertexBuffer {
  30076. /** @hidden */
  30077. _buffer: Buffer;
  30078. private _kind;
  30079. private _size;
  30080. private _ownsBuffer;
  30081. private _instanced;
  30082. private _instanceDivisor;
  30083. /**
  30084. * The byte type.
  30085. */
  30086. static readonly BYTE: number;
  30087. /**
  30088. * The unsigned byte type.
  30089. */
  30090. static readonly UNSIGNED_BYTE: number;
  30091. /**
  30092. * The short type.
  30093. */
  30094. static readonly SHORT: number;
  30095. /**
  30096. * The unsigned short type.
  30097. */
  30098. static readonly UNSIGNED_SHORT: number;
  30099. /**
  30100. * The integer type.
  30101. */
  30102. static readonly INT: number;
  30103. /**
  30104. * The unsigned integer type.
  30105. */
  30106. static readonly UNSIGNED_INT: number;
  30107. /**
  30108. * The float type.
  30109. */
  30110. static readonly FLOAT: number;
  30111. /**
  30112. * Gets or sets the instance divisor when in instanced mode
  30113. */
  30114. instanceDivisor: number;
  30115. /**
  30116. * Gets the byte stride.
  30117. */
  30118. readonly byteStride: number;
  30119. /**
  30120. * Gets the byte offset.
  30121. */
  30122. readonly byteOffset: number;
  30123. /**
  30124. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  30125. */
  30126. readonly normalized: boolean;
  30127. /**
  30128. * Gets the data type of each component in the array.
  30129. */
  30130. readonly type: number;
  30131. /**
  30132. * Constructor
  30133. * @param engine the engine
  30134. * @param data the data to use for this vertex buffer
  30135. * @param kind the vertex buffer kind
  30136. * @param updatable whether the data is updatable
  30137. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  30138. * @param stride the stride (optional)
  30139. * @param instanced whether the buffer is instanced (optional)
  30140. * @param offset the offset of the data (optional)
  30141. * @param size the number of components (optional)
  30142. * @param type the type of the component (optional)
  30143. * @param normalized whether the data contains normalized data (optional)
  30144. * @param useBytes set to true if stride and offset are in bytes (optional)
  30145. */
  30146. 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);
  30147. /** @hidden */
  30148. _rebuild(): void;
  30149. /**
  30150. * Returns the kind of the VertexBuffer (string)
  30151. * @returns a string
  30152. */
  30153. getKind(): string;
  30154. /**
  30155. * Gets a boolean indicating if the VertexBuffer is updatable?
  30156. * @returns true if the buffer is updatable
  30157. */
  30158. isUpdatable(): boolean;
  30159. /**
  30160. * Gets current buffer's data
  30161. * @returns a DataArray or null
  30162. */
  30163. getData(): Nullable<DataArray>;
  30164. /**
  30165. * Gets underlying native buffer
  30166. * @returns underlying native buffer
  30167. */
  30168. getBuffer(): Nullable<WebGLBuffer>;
  30169. /**
  30170. * Gets the stride in float32 units (i.e. byte stride / 4).
  30171. * May not be an integer if the byte stride is not divisible by 4.
  30172. * DEPRECATED. Use byteStride instead.
  30173. * @returns the stride in float32 units
  30174. */
  30175. getStrideSize(): number;
  30176. /**
  30177. * Returns the offset as a multiple of the type byte length.
  30178. * DEPRECATED. Use byteOffset instead.
  30179. * @returns the offset in bytes
  30180. */
  30181. getOffset(): number;
  30182. /**
  30183. * Returns the number of components per vertex attribute (integer)
  30184. * @returns the size in float
  30185. */
  30186. getSize(): number;
  30187. /**
  30188. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  30189. * @returns true if this buffer is instanced
  30190. */
  30191. getIsInstanced(): boolean;
  30192. /**
  30193. * Returns the instancing divisor, zero for non-instanced (integer).
  30194. * @returns a number
  30195. */
  30196. getInstanceDivisor(): number;
  30197. /**
  30198. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  30199. * @param data defines the data to store
  30200. */
  30201. create(data?: DataArray): void;
  30202. /**
  30203. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  30204. * This function will create a new buffer if the current one is not updatable
  30205. * @param data defines the data to store
  30206. */
  30207. update(data: DataArray): void;
  30208. /**
  30209. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  30210. * Returns the directly updated WebGLBuffer.
  30211. * @param data the new data
  30212. * @param offset the new offset
  30213. * @param useBytes set to true if the offset is in bytes
  30214. */
  30215. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  30216. /**
  30217. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  30218. */
  30219. dispose(): void;
  30220. /**
  30221. * Enumerates each value of this vertex buffer as numbers.
  30222. * @param count the number of values to enumerate
  30223. * @param callback the callback function called for each value
  30224. */
  30225. forEach(count: number, callback: (value: number, index: number) => void): void;
  30226. /**
  30227. * Positions
  30228. */
  30229. static readonly PositionKind: string;
  30230. /**
  30231. * Normals
  30232. */
  30233. static readonly NormalKind: string;
  30234. /**
  30235. * Tangents
  30236. */
  30237. static readonly TangentKind: string;
  30238. /**
  30239. * Texture coordinates
  30240. */
  30241. static readonly UVKind: string;
  30242. /**
  30243. * Texture coordinates 2
  30244. */
  30245. static readonly UV2Kind: string;
  30246. /**
  30247. * Texture coordinates 3
  30248. */
  30249. static readonly UV3Kind: string;
  30250. /**
  30251. * Texture coordinates 4
  30252. */
  30253. static readonly UV4Kind: string;
  30254. /**
  30255. * Texture coordinates 5
  30256. */
  30257. static readonly UV5Kind: string;
  30258. /**
  30259. * Texture coordinates 6
  30260. */
  30261. static readonly UV6Kind: string;
  30262. /**
  30263. * Colors
  30264. */
  30265. static readonly ColorKind: string;
  30266. /**
  30267. * Matrix indices (for bones)
  30268. */
  30269. static readonly MatricesIndicesKind: string;
  30270. /**
  30271. * Matrix weights (for bones)
  30272. */
  30273. static readonly MatricesWeightsKind: string;
  30274. /**
  30275. * Additional matrix indices (for bones)
  30276. */
  30277. static readonly MatricesIndicesExtraKind: string;
  30278. /**
  30279. * Additional matrix weights (for bones)
  30280. */
  30281. static readonly MatricesWeightsExtraKind: string;
  30282. /**
  30283. * Deduces the stride given a kind.
  30284. * @param kind The kind string to deduce
  30285. * @returns The deduced stride
  30286. */
  30287. static DeduceStride(kind: string): number;
  30288. /**
  30289. * Gets the byte length of the given type.
  30290. * @param type the type
  30291. * @returns the number of bytes
  30292. */
  30293. static GetTypeByteLength(type: number): number;
  30294. /**
  30295. * Enumerates each value of the given parameters as numbers.
  30296. * @param data the data to enumerate
  30297. * @param byteOffset the byte offset of the data
  30298. * @param byteStride the byte stride of the data
  30299. * @param componentCount the number of components per element
  30300. * @param componentType the type of the component
  30301. * @param count the total number of components
  30302. * @param normalized whether the data is normalized
  30303. * @param callback the callback function called for each value
  30304. */
  30305. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30306. private static _GetFloatValue;
  30307. }
  30308. }
  30309. declare module BABYLON {
  30310. /**
  30311. * Class used to enable access to IndexedDB
  30312. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30313. */
  30314. class Database implements IOfflineProvider {
  30315. private _callbackManifestChecked;
  30316. private _currentSceneUrl;
  30317. private _db;
  30318. private _enableSceneOffline;
  30319. private _enableTexturesOffline;
  30320. private _manifestVersionFound;
  30321. private _mustUpdateRessources;
  30322. private _hasReachedQuota;
  30323. private _isSupported;
  30324. private _idbFactory;
  30325. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30326. private static IsUASupportingBlobStorage;
  30327. /**
  30328. * Gets a boolean indicating if Database storate is enabled (off by default)
  30329. */
  30330. static IDBStorageEnabled: boolean;
  30331. /**
  30332. * Gets a boolean indicating if scene must be saved in the database
  30333. */
  30334. readonly enableSceneOffline: boolean;
  30335. /**
  30336. * Gets a boolean indicating if textures must be saved in the database
  30337. */
  30338. readonly enableTexturesOffline: boolean;
  30339. /**
  30340. * Creates a new Database
  30341. * @param urlToScene defines the url to load the scene
  30342. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30343. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30344. */
  30345. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30346. private static _ParseURL;
  30347. private static _ReturnFullUrlLocation;
  30348. private _checkManifestFile;
  30349. /**
  30350. * Open the database and make it available
  30351. * @param successCallback defines the callback to call on success
  30352. * @param errorCallback defines the callback to call on error
  30353. */
  30354. open(successCallback: () => void, errorCallback: () => void): void;
  30355. /**
  30356. * Loads an image from the database
  30357. * @param url defines the url to load from
  30358. * @param image defines the target DOM image
  30359. */
  30360. loadImage(url: string, image: HTMLImageElement): void;
  30361. private _loadImageFromDBAsync;
  30362. private _saveImageIntoDBAsync;
  30363. private _checkVersionFromDB;
  30364. private _loadVersionFromDBAsync;
  30365. private _saveVersionIntoDBAsync;
  30366. /**
  30367. * Loads a file from database
  30368. * @param url defines the URL to load from
  30369. * @param sceneLoaded defines a callback to call on success
  30370. * @param progressCallBack defines a callback to call when progress changed
  30371. * @param errorCallback defines a callback to call on error
  30372. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30373. */
  30374. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30375. private _loadFileAsync;
  30376. private _saveFileAsync;
  30377. }
  30378. }
  30379. declare module BABYLON {
  30380. /**
  30381. * Class used to enable access to offline support
  30382. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30383. */
  30384. interface IOfflineProvider {
  30385. /**
  30386. * Gets a boolean indicating if scene must be saved in the database
  30387. */
  30388. enableSceneOffline: boolean;
  30389. /**
  30390. * Gets a boolean indicating if textures must be saved in the database
  30391. */
  30392. enableTexturesOffline: boolean;
  30393. /**
  30394. * Open the offline support and make it available
  30395. * @param successCallback defines the callback to call on success
  30396. * @param errorCallback defines the callback to call on error
  30397. */
  30398. open(successCallback: () => void, errorCallback: () => void): void;
  30399. /**
  30400. * Loads an image from the offline support
  30401. * @param url defines the url to load from
  30402. * @param image defines the target DOM image
  30403. */
  30404. loadImage(url: string, image: HTMLImageElement): void;
  30405. /**
  30406. * Loads a file from offline support
  30407. * @param url defines the URL to load from
  30408. * @param sceneLoaded defines a callback to call on success
  30409. * @param progressCallBack defines a callback to call when progress changed
  30410. * @param errorCallback defines a callback to call on error
  30411. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30412. */
  30413. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30414. }
  30415. }
  30416. declare module BABYLON {
  30417. /**
  30418. * This represents the base class for particle system in Babylon.
  30419. * 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.
  30420. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30421. * @example https://doc.babylonjs.com/babylon101/particles
  30422. */
  30423. class BaseParticleSystem {
  30424. /**
  30425. * Source color is added to the destination color without alpha affecting the result
  30426. */
  30427. static BLENDMODE_ONEONE: number;
  30428. /**
  30429. * Blend current color and particle color using particle’s alpha
  30430. */
  30431. static BLENDMODE_STANDARD: number;
  30432. /**
  30433. * Add current color and particle color multiplied by particle’s alpha
  30434. */
  30435. static BLENDMODE_ADD: number;
  30436. /**
  30437. * Multiply current color with particle color
  30438. */
  30439. static BLENDMODE_MULTIPLY: number;
  30440. /**
  30441. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30442. */
  30443. static BLENDMODE_MULTIPLYADD: number;
  30444. /**
  30445. * List of animations used by the particle system.
  30446. */
  30447. animations: Animation[];
  30448. /**
  30449. * The id of the Particle system.
  30450. */
  30451. id: string;
  30452. /**
  30453. * The friendly name of the Particle system.
  30454. */
  30455. name: string;
  30456. /**
  30457. * The rendering group used by the Particle system to chose when to render.
  30458. */
  30459. renderingGroupId: number;
  30460. /**
  30461. * The emitter represents the Mesh or position we are attaching the particle system to.
  30462. */
  30463. emitter: Nullable<AbstractMesh | Vector3>;
  30464. /**
  30465. * The maximum number of particles to emit per frame
  30466. */
  30467. emitRate: number;
  30468. /**
  30469. * If you want to launch only a few particles at once, that can be done, as well.
  30470. */
  30471. manualEmitCount: number;
  30472. /**
  30473. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30474. */
  30475. updateSpeed: number;
  30476. /**
  30477. * The amount of time the particle system is running (depends of the overall update speed).
  30478. */
  30479. targetStopDuration: number;
  30480. /**
  30481. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30482. */
  30483. disposeOnStop: boolean;
  30484. /**
  30485. * Minimum power of emitting particles.
  30486. */
  30487. minEmitPower: number;
  30488. /**
  30489. * Maximum power of emitting particles.
  30490. */
  30491. maxEmitPower: number;
  30492. /**
  30493. * Minimum life time of emitting particles.
  30494. */
  30495. minLifeTime: number;
  30496. /**
  30497. * Maximum life time of emitting particles.
  30498. */
  30499. maxLifeTime: number;
  30500. /**
  30501. * Minimum Size of emitting particles.
  30502. */
  30503. minSize: number;
  30504. /**
  30505. * Maximum Size of emitting particles.
  30506. */
  30507. maxSize: number;
  30508. /**
  30509. * Minimum scale of emitting particles on X axis.
  30510. */
  30511. minScaleX: number;
  30512. /**
  30513. * Maximum scale of emitting particles on X axis.
  30514. */
  30515. maxScaleX: number;
  30516. /**
  30517. * Minimum scale of emitting particles on Y axis.
  30518. */
  30519. minScaleY: number;
  30520. /**
  30521. * Maximum scale of emitting particles on Y axis.
  30522. */
  30523. maxScaleY: number;
  30524. /**
  30525. * Gets or sets the minimal initial rotation in radians.
  30526. */
  30527. minInitialRotation: number;
  30528. /**
  30529. * Gets or sets the maximal initial rotation in radians.
  30530. */
  30531. maxInitialRotation: number;
  30532. /**
  30533. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30534. */
  30535. minAngularSpeed: number;
  30536. /**
  30537. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30538. */
  30539. maxAngularSpeed: number;
  30540. /**
  30541. * The texture used to render each particle. (this can be a spritesheet)
  30542. */
  30543. particleTexture: Nullable<Texture>;
  30544. /**
  30545. * The layer mask we are rendering the particles through.
  30546. */
  30547. layerMask: number;
  30548. /**
  30549. * This can help using your own shader to render the particle system.
  30550. * The according effect will be created
  30551. */
  30552. customShader: any;
  30553. /**
  30554. * By default particle system starts as soon as they are created. This prevents the
  30555. * automatic start to happen and let you decide when to start emitting particles.
  30556. */
  30557. preventAutoStart: boolean;
  30558. private _noiseTexture;
  30559. /**
  30560. * Gets or sets a texture used to add random noise to particle positions
  30561. */
  30562. noiseTexture: Nullable<ProceduralTexture>;
  30563. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30564. noiseStrength: Vector3;
  30565. /**
  30566. * Callback triggered when the particle animation is ending.
  30567. */
  30568. onAnimationEnd: Nullable<() => void>;
  30569. /**
  30570. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30571. */
  30572. blendMode: number;
  30573. /**
  30574. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30575. * to override the particles.
  30576. */
  30577. forceDepthWrite: boolean;
  30578. /** 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 */
  30579. preWarmCycles: number;
  30580. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30581. preWarmStepOffset: number;
  30582. /**
  30583. * 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)
  30584. */
  30585. spriteCellChangeSpeed: number;
  30586. /**
  30587. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30588. */
  30589. startSpriteCellID: number;
  30590. /**
  30591. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30592. */
  30593. endSpriteCellID: number;
  30594. /**
  30595. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30596. */
  30597. spriteCellWidth: number;
  30598. /**
  30599. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30600. */
  30601. spriteCellHeight: number;
  30602. /**
  30603. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30604. */
  30605. spriteRandomStartCell: boolean;
  30606. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30607. translationPivot: Vector2;
  30608. /** @hidden */
  30609. protected _isAnimationSheetEnabled: boolean;
  30610. /**
  30611. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30612. */
  30613. beginAnimationOnStart: boolean;
  30614. /**
  30615. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30616. */
  30617. beginAnimationFrom: number;
  30618. /**
  30619. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30620. */
  30621. beginAnimationTo: number;
  30622. /**
  30623. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30624. */
  30625. beginAnimationLoop: boolean;
  30626. /**
  30627. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30628. */
  30629. isAnimationSheetEnabled: boolean;
  30630. /**
  30631. * Get hosting scene
  30632. * @returns the scene
  30633. */
  30634. getScene(): Scene;
  30635. /**
  30636. * You can use gravity if you want to give an orientation to your particles.
  30637. */
  30638. gravity: Vector3;
  30639. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30640. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30641. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30642. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30643. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30644. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30645. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30646. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30647. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30648. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30649. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30650. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30651. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30652. /**
  30653. * Defines the delay in milliseconds before starting the system (0 by default)
  30654. */
  30655. startDelay: number;
  30656. /**
  30657. * Gets the current list of drag gradients.
  30658. * You must use addDragGradient and removeDragGradient to udpate this list
  30659. * @returns the list of drag gradients
  30660. */
  30661. getDragGradients(): Nullable<Array<FactorGradient>>;
  30662. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30663. limitVelocityDamping: number;
  30664. /**
  30665. * Gets the current list of limit velocity gradients.
  30666. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30667. * @returns the list of limit velocity gradients
  30668. */
  30669. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30670. /**
  30671. * Gets the current list of color gradients.
  30672. * You must use addColorGradient and removeColorGradient to udpate this list
  30673. * @returns the list of color gradients
  30674. */
  30675. getColorGradients(): Nullable<Array<ColorGradient>>;
  30676. /**
  30677. * Gets the current list of size gradients.
  30678. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30679. * @returns the list of size gradients
  30680. */
  30681. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30682. /**
  30683. * Gets the current list of color remap gradients.
  30684. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30685. * @returns the list of color remap gradients
  30686. */
  30687. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30688. /**
  30689. * Gets the current list of alpha remap gradients.
  30690. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30691. * @returns the list of alpha remap gradients
  30692. */
  30693. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30694. /**
  30695. * Gets the current list of life time gradients.
  30696. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30697. * @returns the list of life time gradients
  30698. */
  30699. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30700. /**
  30701. * Gets the current list of angular speed gradients.
  30702. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30703. * @returns the list of angular speed gradients
  30704. */
  30705. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30706. /**
  30707. * Gets the current list of velocity gradients.
  30708. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30709. * @returns the list of velocity gradients
  30710. */
  30711. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30712. /**
  30713. * Gets the current list of start size gradients.
  30714. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30715. * @returns the list of start size gradients
  30716. */
  30717. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30718. /**
  30719. * Gets the current list of emit rate gradients.
  30720. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30721. * @returns the list of emit rate gradients
  30722. */
  30723. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30724. /**
  30725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30726. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30727. */
  30728. direction1: Vector3;
  30729. /**
  30730. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30731. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30732. */
  30733. direction2: Vector3;
  30734. /**
  30735. * 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.
  30736. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30737. */
  30738. minEmitBox: Vector3;
  30739. /**
  30740. * 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.
  30741. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30742. */
  30743. maxEmitBox: Vector3;
  30744. /**
  30745. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30746. */
  30747. color1: Color4;
  30748. /**
  30749. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30750. */
  30751. color2: Color4;
  30752. /**
  30753. * Color the particle will have at the end of its lifetime
  30754. */
  30755. colorDead: Color4;
  30756. /**
  30757. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30758. */
  30759. textureMask: Color4;
  30760. /**
  30761. * The particle emitter type defines the emitter used by the particle system.
  30762. * It can be for example box, sphere, or cone...
  30763. */
  30764. particleEmitterType: IParticleEmitterType;
  30765. /** @hidden */
  30766. _isSubEmitter: boolean;
  30767. /**
  30768. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30769. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30770. */
  30771. billboardMode: number;
  30772. protected _isBillboardBased: boolean;
  30773. /**
  30774. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30775. */
  30776. isBillboardBased: boolean;
  30777. /**
  30778. * The scene the particle system belongs to.
  30779. */
  30780. protected _scene: Scene;
  30781. /**
  30782. * Local cache of defines for image processing.
  30783. */
  30784. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30785. /**
  30786. * Default configuration related to image processing available in the standard Material.
  30787. */
  30788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30789. /**
  30790. * Gets the image processing configuration used either in this material.
  30791. */
  30792. /**
  30793. * Sets the Default image processing configuration used either in the this material.
  30794. *
  30795. * If sets to null, the scene one is in use.
  30796. */
  30797. imageProcessingConfiguration: ImageProcessingConfiguration;
  30798. /**
  30799. * Attaches a new image processing configuration to the Standard Material.
  30800. * @param configuration
  30801. */
  30802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30803. /** @hidden */
  30804. protected _reset(): void;
  30805. /** @hidden */
  30806. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30807. /**
  30808. * Instantiates a particle system.
  30809. * 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.
  30810. * @param name The name of the particle system
  30811. */
  30812. constructor(name: string);
  30813. /**
  30814. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30817. * @returns the emitter
  30818. */
  30819. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30820. /**
  30821. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30822. * @param radius The radius of the hemisphere to emit from
  30823. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30824. * @returns the emitter
  30825. */
  30826. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30827. /**
  30828. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30829. * @param radius The radius of the sphere to emit from
  30830. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30831. * @returns the emitter
  30832. */
  30833. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30834. /**
  30835. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30836. * @param radius The radius of the sphere to emit from
  30837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30839. * @returns the emitter
  30840. */
  30841. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30842. /**
  30843. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30844. * @param radius The radius of the emission cylinder
  30845. * @param height The height of the emission cylinder
  30846. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30847. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30848. * @returns the emitter
  30849. */
  30850. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30851. /**
  30852. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30853. * @param radius The radius of the cylinder to emit from
  30854. * @param height The height of the emission cylinder
  30855. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30858. * @returns the emitter
  30859. */
  30860. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30861. /**
  30862. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30863. * @param radius The radius of the cone to emit from
  30864. * @param angle The base angle of the cone
  30865. * @returns the emitter
  30866. */
  30867. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30868. /**
  30869. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30872. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30873. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30874. * @returns the emitter
  30875. */
  30876. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30877. }
  30878. }
  30879. declare module BABYLON {
  30880. /**
  30881. * This represents a GPU particle system in Babylon
  30882. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30883. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30884. */
  30885. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30886. /**
  30887. * The layer mask we are rendering the particles through.
  30888. */
  30889. layerMask: number;
  30890. private _capacity;
  30891. private _activeCount;
  30892. private _currentActiveCount;
  30893. private _accumulatedCount;
  30894. private _renderEffect;
  30895. private _updateEffect;
  30896. private _buffer0;
  30897. private _buffer1;
  30898. private _spriteBuffer;
  30899. private _updateVAO;
  30900. private _renderVAO;
  30901. private _targetIndex;
  30902. private _sourceBuffer;
  30903. private _targetBuffer;
  30904. private _engine;
  30905. private _currentRenderId;
  30906. private _started;
  30907. private _stopped;
  30908. private _timeDelta;
  30909. private _randomTexture;
  30910. private _randomTexture2;
  30911. private _attributesStrideSize;
  30912. private _updateEffectOptions;
  30913. private _randomTextureSize;
  30914. private _actualFrame;
  30915. private readonly _rawTextureWidth;
  30916. /**
  30917. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30918. */
  30919. static readonly IsSupported: boolean;
  30920. /**
  30921. * An event triggered when the system is disposed.
  30922. */
  30923. onDisposeObservable: Observable<GPUParticleSystem>;
  30924. /**
  30925. * Gets the maximum number of particles active at the same time.
  30926. * @returns The max number of active particles.
  30927. */
  30928. getCapacity(): number;
  30929. /**
  30930. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30931. * to override the particles.
  30932. */
  30933. forceDepthWrite: boolean;
  30934. /**
  30935. * Gets or set the number of active particles
  30936. */
  30937. activeParticleCount: number;
  30938. private _preWarmDone;
  30939. /**
  30940. * Is this system ready to be used/rendered
  30941. * @return true if the system is ready
  30942. */
  30943. isReady(): boolean;
  30944. /**
  30945. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30946. * @returns True if it has been started, otherwise false.
  30947. */
  30948. isStarted(): boolean;
  30949. /**
  30950. * Starts the particle system and begins to emit
  30951. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30952. */
  30953. start(delay?: number): void;
  30954. /**
  30955. * Stops the particle system.
  30956. */
  30957. stop(): void;
  30958. /**
  30959. * Remove all active particles
  30960. */
  30961. reset(): void;
  30962. /**
  30963. * Returns the string "GPUParticleSystem"
  30964. * @returns a string containing the class name
  30965. */
  30966. getClassName(): string;
  30967. private _colorGradientsTexture;
  30968. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30969. /**
  30970. * Adds a new color gradient
  30971. * @param gradient defines the gradient to use (between 0 and 1)
  30972. * @param color1 defines the color to affect to the specified gradient
  30973. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30974. * @returns the current particle system
  30975. */
  30976. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30977. /**
  30978. * Remove a specific color gradient
  30979. * @param gradient defines the gradient to remove
  30980. * @returns the current particle system
  30981. */
  30982. removeColorGradient(gradient: number): GPUParticleSystem;
  30983. private _angularSpeedGradientsTexture;
  30984. private _sizeGradientsTexture;
  30985. private _velocityGradientsTexture;
  30986. private _limitVelocityGradientsTexture;
  30987. private _dragGradientsTexture;
  30988. private _addFactorGradient;
  30989. /**
  30990. * Adds a new size gradient
  30991. * @param gradient defines the gradient to use (between 0 and 1)
  30992. * @param factor defines the size factor to affect to the specified gradient
  30993. * @returns the current particle system
  30994. */
  30995. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30996. /**
  30997. * Remove a specific size gradient
  30998. * @param gradient defines the gradient to remove
  30999. * @returns the current particle system
  31000. */
  31001. removeSizeGradient(gradient: number): GPUParticleSystem;
  31002. /**
  31003. * Adds a new angular speed gradient
  31004. * @param gradient defines the gradient to use (between 0 and 1)
  31005. * @param factor defines the angular speed to affect to the specified gradient
  31006. * @returns the current particle system
  31007. */
  31008. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  31009. /**
  31010. * Remove a specific angular speed gradient
  31011. * @param gradient defines the gradient to remove
  31012. * @returns the current particle system
  31013. */
  31014. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  31015. /**
  31016. * Adds a new velocity gradient
  31017. * @param gradient defines the gradient to use (between 0 and 1)
  31018. * @param factor defines the velocity to affect to the specified gradient
  31019. * @returns the current particle system
  31020. */
  31021. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31022. /**
  31023. * Remove a specific velocity gradient
  31024. * @param gradient defines the gradient to remove
  31025. * @returns the current particle system
  31026. */
  31027. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31028. /**
  31029. * Adds a new limit velocity gradient
  31030. * @param gradient defines the gradient to use (between 0 and 1)
  31031. * @param factor defines the limit velocity value to affect to the specified gradient
  31032. * @returns the current particle system
  31033. */
  31034. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31035. /**
  31036. * Remove a specific limit velocity gradient
  31037. * @param gradient defines the gradient to remove
  31038. * @returns the current particle system
  31039. */
  31040. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31041. /**
  31042. * Adds a new drag gradient
  31043. * @param gradient defines the gradient to use (between 0 and 1)
  31044. * @param factor defines the drag value to affect to the specified gradient
  31045. * @returns the current particle system
  31046. */
  31047. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31048. /**
  31049. * Remove a specific drag gradient
  31050. * @param gradient defines the gradient to remove
  31051. * @returns the current particle system
  31052. */
  31053. removeDragGradient(gradient: number): GPUParticleSystem;
  31054. /**
  31055. * Not supported by GPUParticleSystem
  31056. * @param gradient defines the gradient to use (between 0 and 1)
  31057. * @param factor defines the emit rate value to affect to the specified gradient
  31058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31059. * @returns the current particle system
  31060. */
  31061. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31062. /**
  31063. * Not supported by GPUParticleSystem
  31064. * @param gradient defines the gradient to remove
  31065. * @returns the current particle system
  31066. */
  31067. removeEmitRateGradient(gradient: number): IParticleSystem;
  31068. /**
  31069. * Not supported by GPUParticleSystem
  31070. * @param gradient defines the gradient to use (between 0 and 1)
  31071. * @param factor defines the start size value to affect to the specified gradient
  31072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31073. * @returns the current particle system
  31074. */
  31075. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31076. /**
  31077. * Not supported by GPUParticleSystem
  31078. * @param gradient defines the gradient to remove
  31079. * @returns the current particle system
  31080. */
  31081. removeStartSizeGradient(gradient: number): IParticleSystem;
  31082. /**
  31083. * Not supported by GPUParticleSystem
  31084. * @param gradient defines the gradient to use (between 0 and 1)
  31085. * @param min defines the color remap minimal range
  31086. * @param max defines the color remap maximal range
  31087. * @returns the current particle system
  31088. */
  31089. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31090. /**
  31091. * Not supported by GPUParticleSystem
  31092. * @param gradient defines the gradient to remove
  31093. * @returns the current particle system
  31094. */
  31095. removeColorRemapGradient(gradient: number): IParticleSystem;
  31096. /**
  31097. * Not supported by GPUParticleSystem
  31098. * @param gradient defines the gradient to use (between 0 and 1)
  31099. * @param min defines the alpha remap minimal range
  31100. * @param max defines the alpha remap maximal range
  31101. * @returns the current particle system
  31102. */
  31103. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31104. /**
  31105. * Not supported by GPUParticleSystem
  31106. * @param gradient defines the gradient to remove
  31107. * @returns the current particle system
  31108. */
  31109. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31110. /**
  31111. * Not supported by GPUParticleSystem
  31112. * @param gradient defines the gradient to use (between 0 and 1)
  31113. * @param color defines the color to affect to the specified gradient
  31114. * @returns the current particle system
  31115. */
  31116. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31117. /**
  31118. * Not supported by GPUParticleSystem
  31119. * @param gradient defines the gradient to remove
  31120. * @returns the current particle system
  31121. */
  31122. removeRampGradient(gradient: number): IParticleSystem;
  31123. /**
  31124. * Not supported by GPUParticleSystem
  31125. * @returns the list of ramp gradients
  31126. */
  31127. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31128. /**
  31129. * Not supported by GPUParticleSystem
  31130. * Gets or sets a boolean indicating that ramp gradients must be used
  31131. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31132. */
  31133. useRampGradients: boolean;
  31134. /**
  31135. * Not supported by GPUParticleSystem
  31136. * @param gradient defines the gradient to use (between 0 and 1)
  31137. * @param factor defines the life time factor to affect to the specified gradient
  31138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31139. * @returns the current particle system
  31140. */
  31141. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31142. /**
  31143. * Not supported by GPUParticleSystem
  31144. * @param gradient defines the gradient to remove
  31145. * @returns the current particle system
  31146. */
  31147. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31148. /**
  31149. * Instantiates a GPU particle system.
  31150. * 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.
  31151. * @param name The name of the particle system
  31152. * @param options The options used to create the system
  31153. * @param scene The scene the particle system belongs to
  31154. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31155. */
  31156. constructor(name: string, options: Partial<{
  31157. capacity: number;
  31158. randomTextureSize: number;
  31159. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31160. protected _reset(): void;
  31161. private _createUpdateVAO;
  31162. private _createRenderVAO;
  31163. private _initialize;
  31164. /** @hidden */
  31165. _recreateUpdateEffect(): void;
  31166. /** @hidden */
  31167. _recreateRenderEffect(): void;
  31168. /**
  31169. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31170. * @param preWarm defines if we are in the pre-warmimg phase
  31171. */
  31172. animate(preWarm?: boolean): void;
  31173. private _createFactorGradientTexture;
  31174. private _createSizeGradientTexture;
  31175. private _createAngularSpeedGradientTexture;
  31176. private _createVelocityGradientTexture;
  31177. private _createLimitVelocityGradientTexture;
  31178. private _createDragGradientTexture;
  31179. private _createColorGradientTexture;
  31180. /**
  31181. * Renders the particle system in its current state
  31182. * @param preWarm defines if the system should only update the particles but not render them
  31183. * @returns the current number of particles
  31184. */
  31185. render(preWarm?: boolean): number;
  31186. /**
  31187. * Rebuilds the particle system
  31188. */
  31189. rebuild(): void;
  31190. private _releaseBuffers;
  31191. private _releaseVAOs;
  31192. /**
  31193. * Disposes the particle system and free the associated resources
  31194. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31195. */
  31196. dispose(disposeTexture?: boolean): void;
  31197. /**
  31198. * Clones the particle system.
  31199. * @param name The name of the cloned object
  31200. * @param newEmitter The new emitter to use
  31201. * @returns the cloned particle system
  31202. */
  31203. clone(name: string, newEmitter: any): GPUParticleSystem;
  31204. /**
  31205. * Serializes the particle system to a JSON object.
  31206. * @returns the JSON object
  31207. */
  31208. serialize(): any;
  31209. /**
  31210. * Parses a JSON object to create a GPU particle system.
  31211. * @param parsedParticleSystem The JSON object to parse
  31212. * @param scene The scene to create the particle system in
  31213. * @param rootUrl The root url to use to load external dependencies like texture
  31214. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31215. * @returns the parsed GPU particle system
  31216. */
  31217. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31218. }
  31219. }
  31220. declare module BABYLON {
  31221. /**
  31222. * Interface representing a particle system in Babylon.js.
  31223. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31224. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31225. */
  31226. interface IParticleSystem {
  31227. /**
  31228. * List of animations used by the particle system.
  31229. */
  31230. animations: Animation[];
  31231. /**
  31232. * The id of the Particle system.
  31233. */
  31234. id: string;
  31235. /**
  31236. * The name of the Particle system.
  31237. */
  31238. name: string;
  31239. /**
  31240. * The emitter represents the Mesh or position we are attaching the particle system to.
  31241. */
  31242. emitter: Nullable<AbstractMesh | Vector3>;
  31243. /**
  31244. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31245. */
  31246. isBillboardBased: boolean;
  31247. /**
  31248. * The rendering group used by the Particle system to chose when to render.
  31249. */
  31250. renderingGroupId: number;
  31251. /**
  31252. * The layer mask we are rendering the particles through.
  31253. */
  31254. layerMask: number;
  31255. /**
  31256. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31257. */
  31258. updateSpeed: number;
  31259. /**
  31260. * The amount of time the particle system is running (depends of the overall update speed).
  31261. */
  31262. targetStopDuration: number;
  31263. /**
  31264. * The texture used to render each particle. (this can be a spritesheet)
  31265. */
  31266. particleTexture: Nullable<Texture>;
  31267. /**
  31268. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31269. */
  31270. blendMode: number;
  31271. /**
  31272. * Minimum life time of emitting particles.
  31273. */
  31274. minLifeTime: number;
  31275. /**
  31276. * Maximum life time of emitting particles.
  31277. */
  31278. maxLifeTime: number;
  31279. /**
  31280. * Minimum Size of emitting particles.
  31281. */
  31282. minSize: number;
  31283. /**
  31284. * Maximum Size of emitting particles.
  31285. */
  31286. maxSize: number;
  31287. /**
  31288. * Minimum scale of emitting particles on X axis.
  31289. */
  31290. minScaleX: number;
  31291. /**
  31292. * Maximum scale of emitting particles on X axis.
  31293. */
  31294. maxScaleX: number;
  31295. /**
  31296. * Minimum scale of emitting particles on Y axis.
  31297. */
  31298. minScaleY: number;
  31299. /**
  31300. * Maximum scale of emitting particles on Y axis.
  31301. */
  31302. maxScaleY: number;
  31303. /**
  31304. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31305. */
  31306. color1: Color4;
  31307. /**
  31308. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31309. */
  31310. color2: Color4;
  31311. /**
  31312. * Color the particle will have at the end of its lifetime.
  31313. */
  31314. colorDead: Color4;
  31315. /**
  31316. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31317. */
  31318. emitRate: number;
  31319. /**
  31320. * You can use gravity if you want to give an orientation to your particles.
  31321. */
  31322. gravity: Vector3;
  31323. /**
  31324. * Minimum power of emitting particles.
  31325. */
  31326. minEmitPower: number;
  31327. /**
  31328. * Maximum power of emitting particles.
  31329. */
  31330. maxEmitPower: number;
  31331. /**
  31332. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31333. */
  31334. minAngularSpeed: number;
  31335. /**
  31336. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31337. */
  31338. maxAngularSpeed: number;
  31339. /**
  31340. * Gets or sets the minimal initial rotation in radians.
  31341. */
  31342. minInitialRotation: number;
  31343. /**
  31344. * Gets or sets the maximal initial rotation in radians.
  31345. */
  31346. maxInitialRotation: number;
  31347. /**
  31348. * The particle emitter type defines the emitter used by the particle system.
  31349. * It can be for example box, sphere, or cone...
  31350. */
  31351. particleEmitterType: Nullable<IParticleEmitterType>;
  31352. /**
  31353. * Defines the delay in milliseconds before starting the system (0 by default)
  31354. */
  31355. startDelay: number;
  31356. /**
  31357. * 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
  31358. */
  31359. preWarmCycles: number;
  31360. /**
  31361. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31362. */
  31363. preWarmStepOffset: number;
  31364. /**
  31365. * 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)
  31366. */
  31367. spriteCellChangeSpeed: number;
  31368. /**
  31369. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31370. */
  31371. startSpriteCellID: number;
  31372. /**
  31373. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31374. */
  31375. endSpriteCellID: number;
  31376. /**
  31377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31378. */
  31379. spriteCellWidth: number;
  31380. /**
  31381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31382. */
  31383. spriteCellHeight: number;
  31384. /**
  31385. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31386. */
  31387. spriteRandomStartCell: boolean;
  31388. /**
  31389. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31390. */
  31391. isAnimationSheetEnabled: boolean;
  31392. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31393. translationPivot: Vector2;
  31394. /**
  31395. * Gets or sets a texture used to add random noise to particle positions
  31396. */
  31397. noiseTexture: Nullable<BaseTexture>;
  31398. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31399. noiseStrength: Vector3;
  31400. /**
  31401. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31402. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31403. */
  31404. billboardMode: number;
  31405. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31406. limitVelocityDamping: number;
  31407. /**
  31408. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31409. */
  31410. beginAnimationOnStart: boolean;
  31411. /**
  31412. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31413. */
  31414. beginAnimationFrom: number;
  31415. /**
  31416. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31417. */
  31418. beginAnimationTo: number;
  31419. /**
  31420. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31421. */
  31422. beginAnimationLoop: boolean;
  31423. /**
  31424. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31425. */
  31426. disposeOnStop: boolean;
  31427. /**
  31428. * Gets the maximum number of particles active at the same time.
  31429. * @returns The max number of active particles.
  31430. */
  31431. getCapacity(): number;
  31432. /**
  31433. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31434. * @returns True if it has been started, otherwise false.
  31435. */
  31436. isStarted(): boolean;
  31437. /**
  31438. * Animates the particle system for this frame.
  31439. */
  31440. animate(): void;
  31441. /**
  31442. * Renders the particle system in its current state.
  31443. * @returns the current number of particles
  31444. */
  31445. render(): number;
  31446. /**
  31447. * Dispose the particle system and frees its associated resources.
  31448. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31449. */
  31450. dispose(disposeTexture?: boolean): void;
  31451. /**
  31452. * Clones the particle system.
  31453. * @param name The name of the cloned object
  31454. * @param newEmitter The new emitter to use
  31455. * @returns the cloned particle system
  31456. */
  31457. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31458. /**
  31459. * Serializes the particle system to a JSON object.
  31460. * @returns the JSON object
  31461. */
  31462. serialize(): any;
  31463. /**
  31464. * Rebuild the particle system
  31465. */
  31466. rebuild(): void;
  31467. /**
  31468. * Starts the particle system and begins to emit
  31469. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31470. */
  31471. start(delay?: number): void;
  31472. /**
  31473. * Stops the particle system.
  31474. */
  31475. stop(): void;
  31476. /**
  31477. * Remove all active particles
  31478. */
  31479. reset(): void;
  31480. /**
  31481. * Is this system ready to be used/rendered
  31482. * @return true if the system is ready
  31483. */
  31484. isReady(): boolean;
  31485. /**
  31486. * Adds a new color gradient
  31487. * @param gradient defines the gradient to use (between 0 and 1)
  31488. * @param color1 defines the color to affect to the specified gradient
  31489. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31490. * @returns the current particle system
  31491. */
  31492. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31493. /**
  31494. * Remove a specific color gradient
  31495. * @param gradient defines the gradient to remove
  31496. * @returns the current particle system
  31497. */
  31498. removeColorGradient(gradient: number): IParticleSystem;
  31499. /**
  31500. * Adds a new size gradient
  31501. * @param gradient defines the gradient to use (between 0 and 1)
  31502. * @param factor defines the size factor to affect to the specified gradient
  31503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31504. * @returns the current particle system
  31505. */
  31506. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31507. /**
  31508. * Remove a specific size gradient
  31509. * @param gradient defines the gradient to remove
  31510. * @returns the current particle system
  31511. */
  31512. removeSizeGradient(gradient: number): IParticleSystem;
  31513. /**
  31514. * Gets the current list of color gradients.
  31515. * You must use addColorGradient and removeColorGradient to udpate this list
  31516. * @returns the list of color gradients
  31517. */
  31518. getColorGradients(): Nullable<Array<ColorGradient>>;
  31519. /**
  31520. * Gets the current list of size gradients.
  31521. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31522. * @returns the list of size gradients
  31523. */
  31524. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31525. /**
  31526. * Gets the current list of angular speed gradients.
  31527. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31528. * @returns the list of angular speed gradients
  31529. */
  31530. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31531. /**
  31532. * Adds a new angular speed gradient
  31533. * @param gradient defines the gradient to use (between 0 and 1)
  31534. * @param factor defines the angular speed to affect to the specified gradient
  31535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31536. * @returns the current particle system
  31537. */
  31538. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31539. /**
  31540. * Remove a specific angular speed gradient
  31541. * @param gradient defines the gradient to remove
  31542. * @returns the current particle system
  31543. */
  31544. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31545. /**
  31546. * Gets the current list of velocity gradients.
  31547. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31548. * @returns the list of velocity gradients
  31549. */
  31550. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31551. /**
  31552. * Adds a new velocity gradient
  31553. * @param gradient defines the gradient to use (between 0 and 1)
  31554. * @param factor defines the velocity to affect to the specified gradient
  31555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31556. * @returns the current particle system
  31557. */
  31558. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31559. /**
  31560. * Remove a specific velocity gradient
  31561. * @param gradient defines the gradient to remove
  31562. * @returns the current particle system
  31563. */
  31564. removeVelocityGradient(gradient: number): IParticleSystem;
  31565. /**
  31566. * Gets the current list of limit velocity gradients.
  31567. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31568. * @returns the list of limit velocity gradients
  31569. */
  31570. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31571. /**
  31572. * Adds a new limit velocity gradient
  31573. * @param gradient defines the gradient to use (between 0 and 1)
  31574. * @param factor defines the limit velocity to affect to the specified gradient
  31575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31576. * @returns the current particle system
  31577. */
  31578. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31579. /**
  31580. * Remove a specific limit velocity gradient
  31581. * @param gradient defines the gradient to remove
  31582. * @returns the current particle system
  31583. */
  31584. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31585. /**
  31586. * Adds a new drag gradient
  31587. * @param gradient defines the gradient to use (between 0 and 1)
  31588. * @param factor defines the drag to affect to the specified gradient
  31589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31590. * @returns the current particle system
  31591. */
  31592. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31593. /**
  31594. * Remove a specific drag gradient
  31595. * @param gradient defines the gradient to remove
  31596. * @returns the current particle system
  31597. */
  31598. removeDragGradient(gradient: number): IParticleSystem;
  31599. /**
  31600. * Gets the current list of drag gradients.
  31601. * You must use addDragGradient and removeDragGradient to udpate this list
  31602. * @returns the list of drag gradients
  31603. */
  31604. getDragGradients(): Nullable<Array<FactorGradient>>;
  31605. /**
  31606. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31607. * @param gradient defines the gradient to use (between 0 and 1)
  31608. * @param factor defines the emit rate to affect to the specified gradient
  31609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31610. * @returns the current particle system
  31611. */
  31612. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31613. /**
  31614. * Remove a specific emit rate gradient
  31615. * @param gradient defines the gradient to remove
  31616. * @returns the current particle system
  31617. */
  31618. removeEmitRateGradient(gradient: number): IParticleSystem;
  31619. /**
  31620. * Gets the current list of emit rate gradients.
  31621. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31622. * @returns the list of emit rate gradients
  31623. */
  31624. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31625. /**
  31626. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31627. * @param gradient defines the gradient to use (between 0 and 1)
  31628. * @param factor defines the start size to affect to the specified gradient
  31629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31630. * @returns the current particle system
  31631. */
  31632. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31633. /**
  31634. * Remove a specific start size gradient
  31635. * @param gradient defines the gradient to remove
  31636. * @returns the current particle system
  31637. */
  31638. removeStartSizeGradient(gradient: number): IParticleSystem;
  31639. /**
  31640. * Gets the current list of start size gradients.
  31641. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31642. * @returns the list of start size gradients
  31643. */
  31644. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31645. /**
  31646. * Adds a new life time gradient
  31647. * @param gradient defines the gradient to use (between 0 and 1)
  31648. * @param factor defines the life time factor to affect to the specified gradient
  31649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31650. * @returns the current particle system
  31651. */
  31652. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31653. /**
  31654. * Remove a specific life time gradient
  31655. * @param gradient defines the gradient to remove
  31656. * @returns the current particle system
  31657. */
  31658. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31659. /**
  31660. * Gets the current list of life time gradients.
  31661. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31662. * @returns the list of life time gradients
  31663. */
  31664. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31665. /**
  31666. * Gets the current list of color gradients.
  31667. * You must use addColorGradient and removeColorGradient to udpate this list
  31668. * @returns the list of color gradients
  31669. */
  31670. getColorGradients(): Nullable<Array<ColorGradient>>;
  31671. /**
  31672. * Adds a new ramp gradient used to remap particle colors
  31673. * @param gradient defines the gradient to use (between 0 and 1)
  31674. * @param color defines the color to affect to the specified gradient
  31675. * @returns the current particle system
  31676. */
  31677. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31678. /**
  31679. * Gets the current list of ramp gradients.
  31680. * You must use addRampGradient and removeRampGradient to udpate this list
  31681. * @returns the list of ramp gradients
  31682. */
  31683. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31684. /** Gets or sets a boolean indicating that ramp gradients must be used
  31685. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31686. */
  31687. useRampGradients: boolean;
  31688. /**
  31689. * Adds a new color remap gradient
  31690. * @param gradient defines the gradient to use (between 0 and 1)
  31691. * @param min defines the color remap minimal range
  31692. * @param max defines the color remap maximal range
  31693. * @returns the current particle system
  31694. */
  31695. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31696. /**
  31697. * Gets the current list of color remap gradients.
  31698. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31699. * @returns the list of color remap gradients
  31700. */
  31701. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31702. /**
  31703. * Adds a new alpha remap gradient
  31704. * @param gradient defines the gradient to use (between 0 and 1)
  31705. * @param min defines the alpha remap minimal range
  31706. * @param max defines the alpha remap maximal range
  31707. * @returns the current particle system
  31708. */
  31709. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31710. /**
  31711. * Gets the current list of alpha remap gradients.
  31712. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31713. * @returns the list of alpha remap gradients
  31714. */
  31715. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31716. /**
  31717. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31720. * @returns the emitter
  31721. */
  31722. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31723. /**
  31724. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31725. * @param radius The radius of the hemisphere to emit from
  31726. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31727. * @returns the emitter
  31728. */
  31729. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31730. /**
  31731. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31732. * @param radius The radius of the sphere to emit from
  31733. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31734. * @returns the emitter
  31735. */
  31736. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31737. /**
  31738. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31739. * @param radius The radius of the sphere to emit from
  31740. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31741. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31742. * @returns the emitter
  31743. */
  31744. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31745. /**
  31746. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31747. * @param radius The radius of the emission cylinder
  31748. * @param height The height of the emission cylinder
  31749. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31750. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31751. * @returns the emitter
  31752. */
  31753. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31754. /**
  31755. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31756. * @param radius The radius of the cylinder to emit from
  31757. * @param height The height of the emission cylinder
  31758. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31759. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31760. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31761. * @returns the emitter
  31762. */
  31763. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31764. /**
  31765. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31766. * @param radius The radius of the cone to emit from
  31767. * @param angle The base angle of the cone
  31768. * @returns the emitter
  31769. */
  31770. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31771. /**
  31772. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31773. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31774. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31775. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31776. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31777. * @returns the emitter
  31778. */
  31779. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31780. /**
  31781. * Get hosting scene
  31782. * @returns the scene
  31783. */
  31784. getScene(): Scene;
  31785. }
  31786. }
  31787. declare module BABYLON {
  31788. /**
  31789. * A particle represents one of the element emitted by a particle system.
  31790. * This is mainly define by its coordinates, direction, velocity and age.
  31791. */
  31792. class Particle {
  31793. /**
  31794. * The particle system the particle belongs to.
  31795. */
  31796. particleSystem: ParticleSystem;
  31797. private static _Count;
  31798. /**
  31799. * Unique ID of the particle
  31800. */
  31801. id: number;
  31802. /**
  31803. * The world position of the particle in the scene.
  31804. */
  31805. position: Vector3;
  31806. /**
  31807. * The world direction of the particle in the scene.
  31808. */
  31809. direction: Vector3;
  31810. /**
  31811. * The color of the particle.
  31812. */
  31813. color: Color4;
  31814. /**
  31815. * The color change of the particle per step.
  31816. */
  31817. colorStep: Color4;
  31818. /**
  31819. * Defines how long will the life of the particle be.
  31820. */
  31821. lifeTime: number;
  31822. /**
  31823. * The current age of the particle.
  31824. */
  31825. age: number;
  31826. /**
  31827. * The current size of the particle.
  31828. */
  31829. size: number;
  31830. /**
  31831. * The current scale of the particle.
  31832. */
  31833. scale: Vector2;
  31834. /**
  31835. * The current angle of the particle.
  31836. */
  31837. angle: number;
  31838. /**
  31839. * Defines how fast is the angle changing.
  31840. */
  31841. angularSpeed: number;
  31842. /**
  31843. * Defines the cell index used by the particle to be rendered from a sprite.
  31844. */
  31845. cellIndex: number;
  31846. /**
  31847. * The information required to support color remapping
  31848. */
  31849. remapData: Vector4;
  31850. /** @hidden */
  31851. _randomCellOffset?: number;
  31852. /** @hidden */
  31853. _initialDirection: Nullable<Vector3>;
  31854. /** @hidden */
  31855. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31856. /** @hidden */
  31857. _initialStartSpriteCellID: number;
  31858. /** @hidden */
  31859. _initialEndSpriteCellID: number;
  31860. /** @hidden */
  31861. _currentColorGradient: Nullable<ColorGradient>;
  31862. /** @hidden */
  31863. _currentColor1: Color4;
  31864. /** @hidden */
  31865. _currentColor2: Color4;
  31866. /** @hidden */
  31867. _currentSizeGradient: Nullable<FactorGradient>;
  31868. /** @hidden */
  31869. _currentSize1: number;
  31870. /** @hidden */
  31871. _currentSize2: number;
  31872. /** @hidden */
  31873. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31874. /** @hidden */
  31875. _currentAngularSpeed1: number;
  31876. /** @hidden */
  31877. _currentAngularSpeed2: number;
  31878. /** @hidden */
  31879. _currentVelocityGradient: Nullable<FactorGradient>;
  31880. /** @hidden */
  31881. _currentVelocity1: number;
  31882. /** @hidden */
  31883. _currentVelocity2: number;
  31884. /** @hidden */
  31885. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31886. /** @hidden */
  31887. _currentLimitVelocity1: number;
  31888. /** @hidden */
  31889. _currentLimitVelocity2: number;
  31890. /** @hidden */
  31891. _currentDragGradient: Nullable<FactorGradient>;
  31892. /** @hidden */
  31893. _currentDrag1: number;
  31894. /** @hidden */
  31895. _currentDrag2: number;
  31896. /** @hidden */
  31897. _randomNoiseCoordinates1: Vector3;
  31898. /** @hidden */
  31899. _randomNoiseCoordinates2: Vector3;
  31900. /**
  31901. * Creates a new instance Particle
  31902. * @param particleSystem the particle system the particle belongs to
  31903. */
  31904. constructor(
  31905. /**
  31906. * The particle system the particle belongs to.
  31907. */
  31908. particleSystem: ParticleSystem);
  31909. private updateCellInfoFromSystem;
  31910. /**
  31911. * Defines how the sprite cell index is updated for the particle
  31912. */
  31913. updateCellIndex(): void;
  31914. /** @hidden */
  31915. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31916. /** @hidden */
  31917. _inheritParticleInfoToSubEmitters(): void;
  31918. /** @hidden */
  31919. _reset(): void;
  31920. /**
  31921. * Copy the properties of particle to another one.
  31922. * @param other the particle to copy the information to.
  31923. */
  31924. copyTo(other: Particle): void;
  31925. }
  31926. }
  31927. declare module BABYLON {
  31928. /**
  31929. * This class is made for on one-liner static method to help creating particle system set.
  31930. */
  31931. class ParticleHelper {
  31932. /**
  31933. * Gets or sets base Assets URL
  31934. */
  31935. static BaseAssetsUrl: string;
  31936. /**
  31937. * Create a default particle system that you can tweak
  31938. * @param emitter defines the emitter to use
  31939. * @param capacity defines the system capacity (default is 500 particles)
  31940. * @param scene defines the hosting scene
  31941. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31942. * @returns the new Particle system
  31943. */
  31944. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31945. /**
  31946. * This is the main static method (one-liner) of this helper to create different particle systems
  31947. * @param type This string represents the type to the particle system to create
  31948. * @param scene The scene where the particle system should live
  31949. * @param gpu If the system will use gpu
  31950. * @returns the ParticleSystemSet created
  31951. */
  31952. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31953. /**
  31954. * Static function used to export a particle system to a ParticleSystemSet variable.
  31955. * Please note that the emitter shape is not exported
  31956. * @param systems defines the particle systems to export
  31957. * @returns the created particle system set
  31958. */
  31959. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31960. }
  31961. }
  31962. declare module BABYLON {
  31963. /**
  31964. * This represents a particle system in Babylon.
  31965. * 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.
  31966. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31967. * @example https://doc.babylonjs.com/babylon101/particles
  31968. */
  31969. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31970. /**
  31971. * Billboard mode will only apply to Y axis
  31972. */
  31973. static readonly BILLBOARDMODE_Y: number;
  31974. /**
  31975. * Billboard mode will apply to all axes
  31976. */
  31977. static readonly BILLBOARDMODE_ALL: number;
  31978. /**
  31979. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31980. */
  31981. static readonly BILLBOARDMODE_STRETCHED: number;
  31982. /**
  31983. * This function can be defined to provide custom update for active particles.
  31984. * This function will be called instead of regular update (age, position, color, etc.).
  31985. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31986. */
  31987. updateFunction: (particles: Particle[]) => void;
  31988. private _emitterWorldMatrix;
  31989. /**
  31990. * This function can be defined to specify initial direction for every new particle.
  31991. * It by default use the emitterType defined function
  31992. */
  31993. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31994. /**
  31995. * This function can be defined to specify initial position for every new particle.
  31996. * It by default use the emitterType defined function
  31997. */
  31998. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31999. /**
  32000. * @hidden
  32001. */
  32002. _inheritedVelocityOffset: Vector3;
  32003. /**
  32004. * An event triggered when the system is disposed
  32005. */
  32006. onDisposeObservable: Observable<ParticleSystem>;
  32007. private _onDisposeObserver;
  32008. /**
  32009. * Sets a callback that will be triggered when the system is disposed
  32010. */
  32011. onDispose: () => void;
  32012. private _particles;
  32013. private _epsilon;
  32014. private _capacity;
  32015. private _stockParticles;
  32016. private _newPartsExcess;
  32017. private _vertexData;
  32018. private _vertexBuffer;
  32019. private _vertexBuffers;
  32020. private _spriteBuffer;
  32021. private _indexBuffer;
  32022. private _effect;
  32023. private _customEffect;
  32024. private _cachedDefines;
  32025. private _scaledColorStep;
  32026. private _colorDiff;
  32027. private _scaledDirection;
  32028. private _scaledGravity;
  32029. private _currentRenderId;
  32030. private _alive;
  32031. private _useInstancing;
  32032. private _started;
  32033. private _stopped;
  32034. private _actualFrame;
  32035. private _scaledUpdateSpeed;
  32036. private _vertexBufferSize;
  32037. /** @hidden */
  32038. _currentEmitRateGradient: Nullable<FactorGradient>;
  32039. /** @hidden */
  32040. _currentEmitRate1: number;
  32041. /** @hidden */
  32042. _currentEmitRate2: number;
  32043. /** @hidden */
  32044. _currentStartSizeGradient: Nullable<FactorGradient>;
  32045. /** @hidden */
  32046. _currentStartSize1: number;
  32047. /** @hidden */
  32048. _currentStartSize2: number;
  32049. private readonly _rawTextureWidth;
  32050. private _rampGradientsTexture;
  32051. private _useRampGradients;
  32052. /** Gets or sets a boolean indicating that ramp gradients must be used
  32053. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32054. */
  32055. useRampGradients: boolean;
  32056. /**
  32057. * 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.
  32058. * 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: [])
  32059. */
  32060. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32061. private _subEmitters;
  32062. /**
  32063. * @hidden
  32064. * If the particle systems emitter should be disposed when the particle system is disposed
  32065. */
  32066. _disposeEmitterOnDispose: boolean;
  32067. /**
  32068. * The current active Sub-systems, this property is used by the root particle system only.
  32069. */
  32070. activeSubSystems: Array<ParticleSystem>;
  32071. private _rootParticleSystem;
  32072. /**
  32073. * Gets the current list of active particles
  32074. */
  32075. readonly particles: Particle[];
  32076. /**
  32077. * Returns the string "ParticleSystem"
  32078. * @returns a string containing the class name
  32079. */
  32080. getClassName(): string;
  32081. /**
  32082. * Instantiates a particle system.
  32083. * 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.
  32084. * @param name The name of the particle system
  32085. * @param capacity The max number of particles alive at the same time
  32086. * @param scene The scene the particle system belongs to
  32087. * @param customEffect a custom effect used to change the way particles are rendered by default
  32088. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32089. * @param epsilon Offset used to render the particles
  32090. */
  32091. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32092. private _addFactorGradient;
  32093. private _removeFactorGradient;
  32094. /**
  32095. * Adds a new life time gradient
  32096. * @param gradient defines the gradient to use (between 0 and 1)
  32097. * @param factor defines the life time factor to affect to the specified gradient
  32098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32099. * @returns the current particle system
  32100. */
  32101. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32102. /**
  32103. * Remove a specific life time gradient
  32104. * @param gradient defines the gradient to remove
  32105. * @returns the current particle system
  32106. */
  32107. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32108. /**
  32109. * Adds a new size gradient
  32110. * @param gradient defines the gradient to use (between 0 and 1)
  32111. * @param factor defines the size factor to affect to the specified gradient
  32112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32113. * @returns the current particle system
  32114. */
  32115. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32116. /**
  32117. * Remove a specific size gradient
  32118. * @param gradient defines the gradient to remove
  32119. * @returns the current particle system
  32120. */
  32121. removeSizeGradient(gradient: number): IParticleSystem;
  32122. /**
  32123. * Adds a new color remap gradient
  32124. * @param gradient defines the gradient to use (between 0 and 1)
  32125. * @param min defines the color remap minimal range
  32126. * @param max defines the color remap maximal range
  32127. * @returns the current particle system
  32128. */
  32129. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32130. /**
  32131. * Remove a specific color remap gradient
  32132. * @param gradient defines the gradient to remove
  32133. * @returns the current particle system
  32134. */
  32135. removeColorRemapGradient(gradient: number): IParticleSystem;
  32136. /**
  32137. * Adds a new alpha remap gradient
  32138. * @param gradient defines the gradient to use (between 0 and 1)
  32139. * @param min defines the alpha remap minimal range
  32140. * @param max defines the alpha remap maximal range
  32141. * @returns the current particle system
  32142. */
  32143. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32144. /**
  32145. * Remove a specific alpha remap gradient
  32146. * @param gradient defines the gradient to remove
  32147. * @returns the current particle system
  32148. */
  32149. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32150. /**
  32151. * Adds a new angular speed gradient
  32152. * @param gradient defines the gradient to use (between 0 and 1)
  32153. * @param factor defines the angular speed to affect to the specified gradient
  32154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32155. * @returns the current particle system
  32156. */
  32157. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32158. /**
  32159. * Remove a specific angular speed gradient
  32160. * @param gradient defines the gradient to remove
  32161. * @returns the current particle system
  32162. */
  32163. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32164. /**
  32165. * Adds a new velocity gradient
  32166. * @param gradient defines the gradient to use (between 0 and 1)
  32167. * @param factor defines the velocity to affect to the specified gradient
  32168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32169. * @returns the current particle system
  32170. */
  32171. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32172. /**
  32173. * Remove a specific velocity gradient
  32174. * @param gradient defines the gradient to remove
  32175. * @returns the current particle system
  32176. */
  32177. removeVelocityGradient(gradient: number): IParticleSystem;
  32178. /**
  32179. * Adds a new limit velocity gradient
  32180. * @param gradient defines the gradient to use (between 0 and 1)
  32181. * @param factor defines the limit velocity value to affect to the specified gradient
  32182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32183. * @returns the current particle system
  32184. */
  32185. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32186. /**
  32187. * Remove a specific limit velocity gradient
  32188. * @param gradient defines the gradient to remove
  32189. * @returns the current particle system
  32190. */
  32191. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32192. /**
  32193. * Adds a new drag gradient
  32194. * @param gradient defines the gradient to use (between 0 and 1)
  32195. * @param factor defines the drag value to affect to the specified gradient
  32196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32197. * @returns the current particle system
  32198. */
  32199. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32200. /**
  32201. * Remove a specific drag gradient
  32202. * @param gradient defines the gradient to remove
  32203. * @returns the current particle system
  32204. */
  32205. removeDragGradient(gradient: number): IParticleSystem;
  32206. /**
  32207. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32208. * @param gradient defines the gradient to use (between 0 and 1)
  32209. * @param factor defines the emit rate value to affect to the specified gradient
  32210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32211. * @returns the current particle system
  32212. */
  32213. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32214. /**
  32215. * Remove a specific emit rate gradient
  32216. * @param gradient defines the gradient to remove
  32217. * @returns the current particle system
  32218. */
  32219. removeEmitRateGradient(gradient: number): IParticleSystem;
  32220. /**
  32221. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32222. * @param gradient defines the gradient to use (between 0 and 1)
  32223. * @param factor defines the start size value to affect to the specified gradient
  32224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32225. * @returns the current particle system
  32226. */
  32227. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32228. /**
  32229. * Remove a specific start size gradient
  32230. * @param gradient defines the gradient to remove
  32231. * @returns the current particle system
  32232. */
  32233. removeStartSizeGradient(gradient: number): IParticleSystem;
  32234. private _createRampGradientTexture;
  32235. /**
  32236. * Gets the current list of ramp gradients.
  32237. * You must use addRampGradient and removeRampGradient to udpate this list
  32238. * @returns the list of ramp gradients
  32239. */
  32240. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32241. /**
  32242. * Adds a new ramp gradient used to remap particle colors
  32243. * @param gradient defines the gradient to use (between 0 and 1)
  32244. * @param color defines the color to affect to the specified gradient
  32245. * @returns the current particle system
  32246. */
  32247. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32248. /**
  32249. * Remove a specific ramp gradient
  32250. * @param gradient defines the gradient to remove
  32251. * @returns the current particle system
  32252. */
  32253. removeRampGradient(gradient: number): ParticleSystem;
  32254. /**
  32255. * Adds a new color gradient
  32256. * @param gradient defines the gradient to use (between 0 and 1)
  32257. * @param color1 defines the color to affect to the specified gradient
  32258. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32259. * @returns this particle system
  32260. */
  32261. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32262. /**
  32263. * Remove a specific color gradient
  32264. * @param gradient defines the gradient to remove
  32265. * @returns this particle system
  32266. */
  32267. removeColorGradient(gradient: number): IParticleSystem;
  32268. private _fetchR;
  32269. protected _reset(): void;
  32270. private _resetEffect;
  32271. private _createVertexBuffers;
  32272. private _createIndexBuffer;
  32273. /**
  32274. * Gets the maximum number of particles active at the same time.
  32275. * @returns The max number of active particles.
  32276. */
  32277. getCapacity(): number;
  32278. /**
  32279. * Gets whether there are still active particles in the system.
  32280. * @returns True if it is alive, otherwise false.
  32281. */
  32282. isAlive(): boolean;
  32283. /**
  32284. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32285. * @returns True if it has been started, otherwise false.
  32286. */
  32287. isStarted(): boolean;
  32288. private _prepareSubEmitterInternalArray;
  32289. /**
  32290. * Starts the particle system and begins to emit
  32291. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32292. */
  32293. start(delay?: number): void;
  32294. /**
  32295. * Stops the particle system.
  32296. * @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.
  32297. */
  32298. stop(stopSubEmitters?: boolean): void;
  32299. /**
  32300. * Remove all active particles
  32301. */
  32302. reset(): void;
  32303. /**
  32304. * @hidden (for internal use only)
  32305. */
  32306. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32307. /**
  32308. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32309. * Its lifetime will start back at 0.
  32310. */
  32311. recycleParticle: (particle: Particle) => void;
  32312. private _stopSubEmitters;
  32313. private _createParticle;
  32314. private _removeFromRoot;
  32315. private _emitFromParticle;
  32316. private _update;
  32317. /** @hidden */
  32318. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32319. /** @hidden */
  32320. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32321. /** @hidden */
  32322. private _getEffect;
  32323. /**
  32324. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32325. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32326. */
  32327. animate(preWarmOnly?: boolean): void;
  32328. private _appendParticleVertices;
  32329. /**
  32330. * Rebuilds the particle system.
  32331. */
  32332. rebuild(): void;
  32333. /**
  32334. * Is this system ready to be used/rendered
  32335. * @return true if the system is ready
  32336. */
  32337. isReady(): boolean;
  32338. private _render;
  32339. /**
  32340. * Renders the particle system in its current state.
  32341. * @returns the current number of particles
  32342. */
  32343. render(): number;
  32344. /**
  32345. * Disposes the particle system and free the associated resources
  32346. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32347. */
  32348. dispose(disposeTexture?: boolean): void;
  32349. /**
  32350. * Clones the particle system.
  32351. * @param name The name of the cloned object
  32352. * @param newEmitter The new emitter to use
  32353. * @returns the cloned particle system
  32354. */
  32355. clone(name: string, newEmitter: any): ParticleSystem;
  32356. /**
  32357. * Serializes the particle system to a JSON object.
  32358. * @returns the JSON object
  32359. */
  32360. serialize(): any;
  32361. /** @hidden */
  32362. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32363. /** @hidden */
  32364. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32365. /**
  32366. * Parses a JSON object to create a particle system.
  32367. * @param parsedParticleSystem The JSON object to parse
  32368. * @param scene The scene to create the particle system in
  32369. * @param rootUrl The root url to use to load external dependencies like texture
  32370. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32371. * @returns the Parsed particle system
  32372. */
  32373. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32374. }
  32375. }
  32376. declare module BABYLON {
  32377. interface Engine {
  32378. /**
  32379. * Create an effect to use with particle systems.
  32380. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32381. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32382. * @param uniformsNames defines a list of attribute names
  32383. * @param samplers defines an array of string used to represent textures
  32384. * @param defines defines the string containing the defines to use to compile the shaders
  32385. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32386. * @param onCompiled defines a function to call when the effect creation is successful
  32387. * @param onError defines a function to call when the effect creation has failed
  32388. * @returns the new Effect
  32389. */
  32390. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32391. }
  32392. interface Mesh {
  32393. /**
  32394. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32395. * @returns an array of IParticleSystem
  32396. */
  32397. getEmittedParticleSystems(): IParticleSystem[];
  32398. /**
  32399. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32400. * @returns an array of IParticleSystem
  32401. */
  32402. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32403. }
  32404. }
  32405. declare module BABYLON {
  32406. /**
  32407. * Represents a set of particle systems working together to create a specific effect
  32408. */
  32409. class ParticleSystemSet implements IDisposable {
  32410. private _emitterCreationOptions;
  32411. private _emitterNode;
  32412. /**
  32413. * Gets the particle system list
  32414. */
  32415. systems: IParticleSystem[];
  32416. /**
  32417. * Gets the emitter node used with this set
  32418. */
  32419. readonly emitterNode: Nullable<TransformNode>;
  32420. /**
  32421. * Creates a new emitter mesh as a sphere
  32422. * @param options defines the options used to create the sphere
  32423. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32424. * @param scene defines the hosting scene
  32425. */
  32426. setEmitterAsSphere(options: {
  32427. diameter: number;
  32428. segments: number;
  32429. color: Color3;
  32430. }, renderingGroupId: number, scene: Scene): void;
  32431. /**
  32432. * Starts all particle systems of the set
  32433. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32434. */
  32435. start(emitter?: AbstractMesh): void;
  32436. /**
  32437. * Release all associated resources
  32438. */
  32439. dispose(): void;
  32440. /**
  32441. * Serialize the set into a JSON compatible object
  32442. * @returns a JSON compatible representation of the set
  32443. */
  32444. serialize(): any;
  32445. /**
  32446. * Parse a new ParticleSystemSet from a serialized source
  32447. * @param data defines a JSON compatible representation of the set
  32448. * @param scene defines the hosting scene
  32449. * @param gpu defines if we want GPU particles or CPU particles
  32450. * @returns a new ParticleSystemSet
  32451. */
  32452. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32453. }
  32454. }
  32455. declare module BABYLON {
  32456. /**
  32457. * Represents one particle of a solid particle system.
  32458. */
  32459. class SolidParticle {
  32460. /**
  32461. * particle global index
  32462. */
  32463. idx: number;
  32464. /**
  32465. * The color of the particle
  32466. */
  32467. color: Nullable<Color4>;
  32468. /**
  32469. * The world space position of the particle.
  32470. */
  32471. position: Vector3;
  32472. /**
  32473. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32474. */
  32475. rotation: Vector3;
  32476. /**
  32477. * The world space rotation quaternion of the particle.
  32478. */
  32479. rotationQuaternion: Nullable<Quaternion>;
  32480. /**
  32481. * The scaling of the particle.
  32482. */
  32483. scaling: Vector3;
  32484. /**
  32485. * The uvs of the particle.
  32486. */
  32487. uvs: Vector4;
  32488. /**
  32489. * The current speed of the particle.
  32490. */
  32491. velocity: Vector3;
  32492. /**
  32493. * The pivot point in the particle local space.
  32494. */
  32495. pivot: Vector3;
  32496. /**
  32497. * Must the particle be translated from its pivot point in its local space ?
  32498. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32499. * Default : false
  32500. */
  32501. translateFromPivot: boolean;
  32502. /**
  32503. * Is the particle active or not ?
  32504. */
  32505. alive: boolean;
  32506. /**
  32507. * Is the particle visible or not ?
  32508. */
  32509. isVisible: boolean;
  32510. /**
  32511. * Index of this particle in the global "positions" array (Internal use)
  32512. * @hidden
  32513. */
  32514. _pos: number;
  32515. /**
  32516. * @hidden Index of this particle in the global "indices" array (Internal use)
  32517. */
  32518. _ind: number;
  32519. /**
  32520. * @hidden ModelShape of this particle (Internal use)
  32521. */
  32522. _model: ModelShape;
  32523. /**
  32524. * ModelShape id of this particle
  32525. */
  32526. shapeId: number;
  32527. /**
  32528. * Index of the particle in its shape id (Internal use)
  32529. */
  32530. idxInShape: number;
  32531. /**
  32532. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32533. */
  32534. _modelBoundingInfo: BoundingInfo;
  32535. /**
  32536. * @hidden Particle BoundingInfo object (Internal use)
  32537. */
  32538. _boundingInfo: BoundingInfo;
  32539. /**
  32540. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32541. */
  32542. _sps: SolidParticleSystem;
  32543. /**
  32544. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32545. */
  32546. _stillInvisible: boolean;
  32547. /**
  32548. * @hidden Last computed particle rotation matrix
  32549. */
  32550. _rotationMatrix: number[];
  32551. /**
  32552. * Parent particle Id, if any.
  32553. * Default null.
  32554. */
  32555. parentId: Nullable<number>;
  32556. /**
  32557. * @hidden Internal global position in the SPS.
  32558. */
  32559. _globalPosition: Vector3;
  32560. /**
  32561. * Creates a Solid Particle object.
  32562. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32563. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32564. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32565. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32566. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32567. * @param shapeId (integer) is the model shape identifier in the SPS.
  32568. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32569. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32570. */
  32571. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32572. /**
  32573. * Legacy support, changed scale to scaling
  32574. */
  32575. /**
  32576. * Legacy support, changed scale to scaling
  32577. */
  32578. scale: Vector3;
  32579. /**
  32580. * Legacy support, changed quaternion to rotationQuaternion
  32581. */
  32582. /**
  32583. * Legacy support, changed quaternion to rotationQuaternion
  32584. */
  32585. quaternion: Nullable<Quaternion>;
  32586. /**
  32587. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32588. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32589. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32590. * @returns true if it intersects
  32591. */
  32592. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32593. /**
  32594. * get the rotation matrix of the particle
  32595. * @hidden
  32596. */
  32597. getRotationMatrix(m: Matrix): void;
  32598. }
  32599. /**
  32600. * Represents the shape of the model used by one particle of a solid particle system.
  32601. * SPS internal tool, don't use it manually.
  32602. */
  32603. class ModelShape {
  32604. /**
  32605. * The shape id
  32606. * @hidden
  32607. */
  32608. shapeID: number;
  32609. /**
  32610. * flat array of model positions (internal use)
  32611. * @hidden
  32612. */
  32613. _shape: Vector3[];
  32614. /**
  32615. * flat array of model UVs (internal use)
  32616. * @hidden
  32617. */
  32618. _shapeUV: number[];
  32619. /**
  32620. * length of the shape in the model indices array (internal use)
  32621. * @hidden
  32622. */
  32623. _indicesLength: number;
  32624. /**
  32625. * Custom position function (internal use)
  32626. * @hidden
  32627. */
  32628. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32629. /**
  32630. * Custom vertex function (internal use)
  32631. * @hidden
  32632. */
  32633. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32634. /**
  32635. * 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.
  32636. * SPS internal tool, don't use it manually.
  32637. * @hidden
  32638. */
  32639. 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>);
  32640. }
  32641. /**
  32642. * Represents a Depth Sorted Particle in the solid particle system.
  32643. */
  32644. class DepthSortedParticle {
  32645. /**
  32646. * Index of the particle in the "indices" array
  32647. */
  32648. ind: number;
  32649. /**
  32650. * Length of the particle shape in the "indices" array
  32651. */
  32652. indicesLength: number;
  32653. /**
  32654. * Squared distance from the particle to the camera
  32655. */
  32656. sqDistance: number;
  32657. }
  32658. }
  32659. declare module BABYLON {
  32660. /**
  32661. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32662. *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.
  32663. * The SPS is also a particle system. It provides some methods to manage the particles.
  32664. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32665. *
  32666. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32667. */
  32668. class SolidParticleSystem implements IDisposable {
  32669. /**
  32670. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32671. * Example : var p = SPS.particles[i];
  32672. */
  32673. particles: SolidParticle[];
  32674. /**
  32675. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32676. */
  32677. nbParticles: number;
  32678. /**
  32679. * If the particles must ever face the camera (default false). Useful for planar particles.
  32680. */
  32681. billboard: boolean;
  32682. /**
  32683. * Recompute normals when adding a shape
  32684. */
  32685. recomputeNormals: boolean;
  32686. /**
  32687. * This a counter ofr your own usage. It's not set by any SPS functions.
  32688. */
  32689. counter: number;
  32690. /**
  32691. * The SPS name. This name is also given to the underlying mesh.
  32692. */
  32693. name: string;
  32694. /**
  32695. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32696. */
  32697. mesh: Mesh;
  32698. /**
  32699. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32700. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32701. */
  32702. vars: any;
  32703. /**
  32704. * This array is populated when the SPS is set as 'pickable'.
  32705. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32706. * Each element of this array is an object `{idx: int, faceId: int}`.
  32707. * `idx` is the picked particle index in the `SPS.particles` array
  32708. * `faceId` is the picked face index counted within this particle.
  32709. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32710. */
  32711. pickedParticles: {
  32712. idx: number;
  32713. faceId: number;
  32714. }[];
  32715. /**
  32716. * This array is populated when `enableDepthSort` is set to true.
  32717. * Each element of this array is an instance of the class DepthSortedParticle.
  32718. */
  32719. depthSortedParticles: DepthSortedParticle[];
  32720. /**
  32721. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32722. * @hidden
  32723. */
  32724. _bSphereOnly: boolean;
  32725. /**
  32726. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32727. * @hidden
  32728. */
  32729. _bSphereRadiusFactor: number;
  32730. private _scene;
  32731. private _positions;
  32732. private _indices;
  32733. private _normals;
  32734. private _colors;
  32735. private _uvs;
  32736. private _indices32;
  32737. private _positions32;
  32738. private _normals32;
  32739. private _fixedNormal32;
  32740. private _colors32;
  32741. private _uvs32;
  32742. private _index;
  32743. private _updatable;
  32744. private _pickable;
  32745. private _isVisibilityBoxLocked;
  32746. private _alwaysVisible;
  32747. private _depthSort;
  32748. private _shapeCounter;
  32749. private _copy;
  32750. private _color;
  32751. private _computeParticleColor;
  32752. private _computeParticleTexture;
  32753. private _computeParticleRotation;
  32754. private _computeParticleVertex;
  32755. private _computeBoundingBox;
  32756. private _depthSortParticles;
  32757. private _camera;
  32758. private _mustUnrotateFixedNormals;
  32759. private _particlesIntersect;
  32760. private _needs32Bits;
  32761. /**
  32762. * Creates a SPS (Solid Particle System) object.
  32763. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32764. * @param scene (Scene) is the scene in which the SPS is added.
  32765. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32766. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32767. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32768. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32769. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32770. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32771. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32772. */
  32773. constructor(name: string, scene: Scene, options?: {
  32774. updatable?: boolean;
  32775. isPickable?: boolean;
  32776. enableDepthSort?: boolean;
  32777. particleIntersection?: boolean;
  32778. boundingSphereOnly?: boolean;
  32779. bSphereRadiusFactor?: number;
  32780. });
  32781. /**
  32782. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32783. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32784. * @returns the created mesh
  32785. */
  32786. buildMesh(): Mesh;
  32787. /**
  32788. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32789. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32790. * Thus the particles generated from `digest()` have their property `position` set yet.
  32791. * @param mesh ( Mesh ) is the mesh to be digested
  32792. * @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
  32793. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32794. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32795. * @returns the current SPS
  32796. */
  32797. digest(mesh: Mesh, options?: {
  32798. facetNb?: number;
  32799. number?: number;
  32800. delta?: number;
  32801. }): SolidParticleSystem;
  32802. private _unrotateFixedNormals;
  32803. private _resetCopy;
  32804. private _meshBuilder;
  32805. private _posToShape;
  32806. private _uvsToShapeUV;
  32807. private _addParticle;
  32808. /**
  32809. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32810. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32811. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32812. * @param nb (positive integer) the number of particles to be created from this model
  32813. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32814. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32815. * @returns the number of shapes in the system
  32816. */
  32817. addShape(mesh: Mesh, nb: number, options?: {
  32818. positionFunction?: any;
  32819. vertexFunction?: any;
  32820. }): number;
  32821. private _rebuildParticle;
  32822. /**
  32823. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32824. * @returns the SPS.
  32825. */
  32826. rebuildMesh(): SolidParticleSystem;
  32827. /**
  32828. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32829. * This method calls `updateParticle()` for each particle of the SPS.
  32830. * For an animated SPS, it is usually called within the render loop.
  32831. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32832. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32833. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32834. * @returns the SPS.
  32835. */
  32836. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32837. /**
  32838. * Disposes the SPS.
  32839. */
  32840. dispose(): void;
  32841. /**
  32842. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32843. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32844. * @returns the SPS.
  32845. */
  32846. refreshVisibleSize(): SolidParticleSystem;
  32847. /**
  32848. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32849. * @param size the size (float) of the visibility box
  32850. * note : this doesn't lock the SPS mesh bounding box.
  32851. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32852. */
  32853. setVisibilityBox(size: number): void;
  32854. /**
  32855. * Gets whether the SPS as always visible or not
  32856. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32857. */
  32858. /**
  32859. * Sets the SPS as always visible or not
  32860. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32861. */
  32862. isAlwaysVisible: boolean;
  32863. /**
  32864. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32865. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32866. */
  32867. /**
  32868. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32869. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32870. */
  32871. isVisibilityBoxLocked: boolean;
  32872. /**
  32873. * Tells to `setParticles()` to compute the particle rotations or not.
  32874. * Default value : true. The SPS is faster when it's set to false.
  32875. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32876. */
  32877. /**
  32878. * Gets if `setParticles()` computes the particle rotations or not.
  32879. * Default value : true. The SPS is faster when it's set to false.
  32880. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32881. */
  32882. computeParticleRotation: boolean;
  32883. /**
  32884. * Tells to `setParticles()` to compute the particle colors or not.
  32885. * Default value : true. The SPS is faster when it's set to false.
  32886. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32887. */
  32888. /**
  32889. * Gets if `setParticles()` computes the particle colors or not.
  32890. * Default value : true. The SPS is faster when it's set to false.
  32891. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32892. */
  32893. computeParticleColor: boolean;
  32894. /**
  32895. * Gets if `setParticles()` computes the particle textures or not.
  32896. * Default value : true. The SPS is faster when it's set to false.
  32897. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32898. */
  32899. computeParticleTexture: boolean;
  32900. /**
  32901. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32902. * Default value : false. The SPS is faster when it's set to false.
  32903. * Note : the particle custom vertex positions aren't stored values.
  32904. */
  32905. /**
  32906. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32907. * Default value : false. The SPS is faster when it's set to false.
  32908. * Note : the particle custom vertex positions aren't stored values.
  32909. */
  32910. computeParticleVertex: boolean;
  32911. /**
  32912. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32913. */
  32914. /**
  32915. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32916. */
  32917. computeBoundingBox: boolean;
  32918. /**
  32919. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32920. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32921. * Default : `true`
  32922. */
  32923. /**
  32924. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32925. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32926. * Default : `true`
  32927. */
  32928. depthSortParticles: boolean;
  32929. /**
  32930. * This function does nothing. It may be overwritten to set all the particle first values.
  32931. * The SPS doesn't call this function, you may have to call it by your own.
  32932. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32933. */
  32934. initParticles(): void;
  32935. /**
  32936. * This function does nothing. It may be overwritten to recycle a particle.
  32937. * The SPS doesn't call this function, you may have to call it by your own.
  32938. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32939. * @param particle The particle to recycle
  32940. * @returns the recycled particle
  32941. */
  32942. recycleParticle(particle: SolidParticle): SolidParticle;
  32943. /**
  32944. * Updates a particle : this function should be overwritten by the user.
  32945. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32946. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32947. * @example : just set a particle position or velocity and recycle conditions
  32948. * @param particle The particle to update
  32949. * @returns the updated particle
  32950. */
  32951. updateParticle(particle: SolidParticle): SolidParticle;
  32952. /**
  32953. * Updates a vertex of a particle : it can be overwritten by the user.
  32954. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32955. * @param particle the current particle
  32956. * @param vertex the current index of the current particle
  32957. * @param pt the index of the current vertex in the particle shape
  32958. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32959. * @example : just set a vertex particle position
  32960. * @returns the updated vertex
  32961. */
  32962. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32963. /**
  32964. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32965. * This does nothing and may be overwritten by the user.
  32966. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32968. * @param update the boolean update value actually passed to setParticles()
  32969. */
  32970. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32971. /**
  32972. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32973. * This will be passed three parameters.
  32974. * This does nothing and may be overwritten by the user.
  32975. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32977. * @param update the boolean update value actually passed to setParticles()
  32978. */
  32979. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32980. }
  32981. }
  32982. declare module BABYLON {
  32983. /**
  32984. * Type of sub emitter
  32985. */
  32986. enum SubEmitterType {
  32987. /**
  32988. * Attached to the particle over it's lifetime
  32989. */
  32990. ATTACHED = 0,
  32991. /**
  32992. * Created when the particle dies
  32993. */
  32994. END = 1
  32995. }
  32996. /**
  32997. * Sub emitter class used to emit particles from an existing particle
  32998. */
  32999. class SubEmitter {
  33000. /**
  33001. * the particle system to be used by the sub emitter
  33002. */
  33003. particleSystem: ParticleSystem;
  33004. /**
  33005. * Type of the submitter (Default: END)
  33006. */
  33007. type: SubEmitterType;
  33008. /**
  33009. * 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)
  33010. * Note: This only is supported when using an emitter of type Mesh
  33011. */
  33012. inheritDirection: boolean;
  33013. /**
  33014. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  33015. */
  33016. inheritedVelocityAmount: number;
  33017. /**
  33018. * Creates a sub emitter
  33019. * @param particleSystem the particle system to be used by the sub emitter
  33020. */
  33021. constructor(
  33022. /**
  33023. * the particle system to be used by the sub emitter
  33024. */
  33025. particleSystem: ParticleSystem);
  33026. /**
  33027. * Clones the sub emitter
  33028. * @returns the cloned sub emitter
  33029. */
  33030. clone(): SubEmitter;
  33031. /**
  33032. * Serialize current object to a JSON object
  33033. * @returns the serialized object
  33034. */
  33035. serialize(): any;
  33036. /**
  33037. * Creates a new SubEmitter from a serialized JSON version
  33038. * @param serializationObject defines the JSON object to read from
  33039. * @param scene defines the hosting scene
  33040. * @param rootUrl defines the rootUrl for data loading
  33041. * @returns a new SubEmitter
  33042. */
  33043. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33044. /** Release associated resources */
  33045. dispose(): void;
  33046. }
  33047. }
  33048. declare module BABYLON {
  33049. /**
  33050. * Interface used to describe a physics joint
  33051. */
  33052. interface PhysicsImpostorJoint {
  33053. /** Defines the main impostor to which the joint is linked */
  33054. mainImpostor: PhysicsImpostor;
  33055. /** Defines the impostor that is connected to the main impostor using this joint */
  33056. connectedImpostor: PhysicsImpostor;
  33057. /** Defines the joint itself */
  33058. joint: PhysicsJoint;
  33059. }
  33060. /** @hidden */
  33061. interface IPhysicsEnginePlugin {
  33062. world: any;
  33063. name: string;
  33064. setGravity(gravity: Vector3): void;
  33065. setTimeStep(timeStep: number): void;
  33066. getTimeStep(): number;
  33067. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33068. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33069. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33070. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33071. removePhysicsBody(impostor: PhysicsImpostor): void;
  33072. generateJoint(joint: PhysicsImpostorJoint): void;
  33073. removeJoint(joint: PhysicsImpostorJoint): void;
  33074. isSupported(): boolean;
  33075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33077. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33078. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33079. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33080. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33081. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33082. getBodyMass(impostor: PhysicsImpostor): number;
  33083. getBodyFriction(impostor: PhysicsImpostor): number;
  33084. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33085. getBodyRestitution(impostor: PhysicsImpostor): number;
  33086. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33087. sleepBody(impostor: PhysicsImpostor): void;
  33088. wakeUpBody(impostor: PhysicsImpostor): void;
  33089. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33090. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33091. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33092. getRadius(impostor: PhysicsImpostor): number;
  33093. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33094. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33095. dispose(): void;
  33096. }
  33097. /**
  33098. * Interface used to define a physics engine
  33099. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33100. */
  33101. interface IPhysicsEngine {
  33102. /**
  33103. * Gets the gravity vector used by the simulation
  33104. */
  33105. gravity: Vector3;
  33106. /**
  33107. * Sets the gravity vector used by the simulation
  33108. * @param gravity defines the gravity vector to use
  33109. */
  33110. setGravity(gravity: Vector3): void;
  33111. /**
  33112. * Set the time step of the physics engine.
  33113. * Default is 1/60.
  33114. * To slow it down, enter 1/600 for example.
  33115. * To speed it up, 1/30
  33116. * @param newTimeStep the new timestep to apply to this world.
  33117. */
  33118. setTimeStep(newTimeStep: number): void;
  33119. /**
  33120. * Get the time step of the physics engine.
  33121. * @returns the current time step
  33122. */
  33123. getTimeStep(): number;
  33124. /**
  33125. * Release all resources
  33126. */
  33127. dispose(): void;
  33128. /**
  33129. * Gets the name of the current physics plugin
  33130. * @returns the name of the plugin
  33131. */
  33132. getPhysicsPluginName(): string;
  33133. /**
  33134. * Adding a new impostor for the impostor tracking.
  33135. * This will be done by the impostor itself.
  33136. * @param impostor the impostor to add
  33137. */
  33138. addImpostor(impostor: PhysicsImpostor): void;
  33139. /**
  33140. * Remove an impostor from the engine.
  33141. * This impostor and its mesh will not longer be updated by the physics engine.
  33142. * @param impostor the impostor to remove
  33143. */
  33144. removeImpostor(impostor: PhysicsImpostor): void;
  33145. /**
  33146. * Add a joint to the physics engine
  33147. * @param mainImpostor defines the main impostor to which the joint is added.
  33148. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33149. * @param joint defines the joint that will connect both impostors.
  33150. */
  33151. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33152. /**
  33153. * Removes a joint from the simulation
  33154. * @param mainImpostor defines the impostor used with the joint
  33155. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33156. * @param joint defines the joint to remove
  33157. */
  33158. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33159. /**
  33160. * Gets the current plugin used to run the simulation
  33161. * @returns current plugin
  33162. */
  33163. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33164. /**
  33165. * Gets the list of physic impostors
  33166. * @returns an array of PhysicsImpostor
  33167. */
  33168. getImpostors(): Array<PhysicsImpostor>;
  33169. /**
  33170. * Gets the impostor for a physics enabled object
  33171. * @param object defines the object impersonated by the impostor
  33172. * @returns the PhysicsImpostor or null if not found
  33173. */
  33174. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33175. /**
  33176. * Gets the impostor for a physics body object
  33177. * @param body defines physics body used by the impostor
  33178. * @returns the PhysicsImpostor or null if not found
  33179. */
  33180. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33181. /**
  33182. * Called by the scene. No need to call it.
  33183. * @param delta defines the timespam between frames
  33184. */
  33185. _step(delta: number): void;
  33186. }
  33187. }
  33188. declare module BABYLON {
  33189. /**
  33190. * Class used to control physics engine
  33191. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33192. */
  33193. class PhysicsEngine implements IPhysicsEngine {
  33194. private _physicsPlugin;
  33195. /**
  33196. * Global value used to control the smallest number supported by the simulation
  33197. */
  33198. static Epsilon: number;
  33199. private _impostors;
  33200. private _joints;
  33201. /**
  33202. * Gets the gravity vector used by the simulation
  33203. */
  33204. gravity: Vector3;
  33205. /**
  33206. * Creates a new Physics Engine
  33207. * @param gravity defines the gravity vector used by the simulation
  33208. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33209. */
  33210. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33211. /**
  33212. * Sets the gravity vector used by the simulation
  33213. * @param gravity defines the gravity vector to use
  33214. */
  33215. setGravity(gravity: Vector3): void;
  33216. /**
  33217. * Set the time step of the physics engine.
  33218. * Default is 1/60.
  33219. * To slow it down, enter 1/600 for example.
  33220. * To speed it up, 1/30
  33221. * @param newTimeStep defines the new timestep to apply to this world.
  33222. */
  33223. setTimeStep(newTimeStep?: number): void;
  33224. /**
  33225. * Get the time step of the physics engine.
  33226. * @returns the current time step
  33227. */
  33228. getTimeStep(): number;
  33229. /**
  33230. * Release all resources
  33231. */
  33232. dispose(): void;
  33233. /**
  33234. * Gets the name of the current physics plugin
  33235. * @returns the name of the plugin
  33236. */
  33237. getPhysicsPluginName(): string;
  33238. /**
  33239. * Adding a new impostor for the impostor tracking.
  33240. * This will be done by the impostor itself.
  33241. * @param impostor the impostor to add
  33242. */
  33243. addImpostor(impostor: PhysicsImpostor): void;
  33244. /**
  33245. * Remove an impostor from the engine.
  33246. * This impostor and its mesh will not longer be updated by the physics engine.
  33247. * @param impostor the impostor to remove
  33248. */
  33249. removeImpostor(impostor: PhysicsImpostor): void;
  33250. /**
  33251. * Add a joint to the physics engine
  33252. * @param mainImpostor defines the main impostor to which the joint is added.
  33253. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33254. * @param joint defines the joint that will connect both impostors.
  33255. */
  33256. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33257. /**
  33258. * Removes a joint from the simulation
  33259. * @param mainImpostor defines the impostor used with the joint
  33260. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33261. * @param joint defines the joint to remove
  33262. */
  33263. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33264. /**
  33265. * Called by the scene. No need to call it.
  33266. * @param delta defines the timespam between frames
  33267. */
  33268. _step(delta: number): void;
  33269. /**
  33270. * Gets the current plugin used to run the simulation
  33271. * @returns current plugin
  33272. */
  33273. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33274. /**
  33275. * Gets the list of physic impostors
  33276. * @returns an array of PhysicsImpostor
  33277. */
  33278. getImpostors(): Array<PhysicsImpostor>;
  33279. /**
  33280. * Gets the impostor for a physics enabled object
  33281. * @param object defines the object impersonated by the impostor
  33282. * @returns the PhysicsImpostor or null if not found
  33283. */
  33284. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33285. /**
  33286. * Gets the impostor for a physics body object
  33287. * @param body defines physics body used by the impostor
  33288. * @returns the PhysicsImpostor or null if not found
  33289. */
  33290. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33291. }
  33292. }
  33293. declare module BABYLON {
  33294. interface Scene {
  33295. /** @hidden (Backing field) */
  33296. _physicsEngine: Nullable<IPhysicsEngine>;
  33297. /**
  33298. * Gets the current physics engine
  33299. * @returns a IPhysicsEngine or null if none attached
  33300. */
  33301. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33302. /**
  33303. * Enables physics to the current scene
  33304. * @param gravity defines the scene's gravity for the physics engine
  33305. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33306. * @return a boolean indicating if the physics engine was initialized
  33307. */
  33308. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33309. /**
  33310. * Disables and disposes the physics engine associated with the scene
  33311. */
  33312. disablePhysicsEngine(): void;
  33313. /**
  33314. * Gets a boolean indicating if there is an active physics engine
  33315. * @returns a boolean indicating if there is an active physics engine
  33316. */
  33317. isPhysicsEnabled(): boolean;
  33318. /**
  33319. * Deletes a physics compound impostor
  33320. * @param compound defines the compound to delete
  33321. */
  33322. deleteCompoundImpostor(compound: any): void;
  33323. /**
  33324. * An event triggered when physic simulation is about to be run
  33325. */
  33326. onBeforePhysicsObservable: Observable<Scene>;
  33327. /**
  33328. * An event triggered when physic simulation has been done
  33329. */
  33330. onAfterPhysicsObservable: Observable<Scene>;
  33331. }
  33332. interface AbstractMesh {
  33333. /** @hidden */
  33334. _physicsImpostor: Nullable<PhysicsImpostor>;
  33335. /**
  33336. * Gets or sets impostor used for physic simulation
  33337. * @see http://doc.babylonjs.com/features/physics_engine
  33338. */
  33339. physicsImpostor: Nullable<PhysicsImpostor>;
  33340. /**
  33341. * Gets the current physics impostor
  33342. * @see http://doc.babylonjs.com/features/physics_engine
  33343. * @returns a physics impostor or null
  33344. */
  33345. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33346. /** Apply a physic impulse to the mesh
  33347. * @param force defines the force to apply
  33348. * @param contactPoint defines where to apply the force
  33349. * @returns the current mesh
  33350. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33351. */
  33352. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33353. /**
  33354. * Creates a physic joint between two meshes
  33355. * @param otherMesh defines the other mesh to use
  33356. * @param pivot1 defines the pivot to use on this mesh
  33357. * @param pivot2 defines the pivot to use on the other mesh
  33358. * @param options defines additional options (can be plugin dependent)
  33359. * @returns the current mesh
  33360. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33361. */
  33362. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33363. /** @hidden */
  33364. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33365. }
  33366. /**
  33367. * Defines the physics engine scene component responsible to manage a physics engine
  33368. */
  33369. class PhysicsEngineSceneComponent implements ISceneComponent {
  33370. /**
  33371. * The component name helpful to identify the component in the list of scene components.
  33372. */
  33373. readonly name: string;
  33374. /**
  33375. * The scene the component belongs to.
  33376. */
  33377. scene: Scene;
  33378. /**
  33379. * Creates a new instance of the component for the given scene
  33380. * @param scene Defines the scene to register the component in
  33381. */
  33382. constructor(scene: Scene);
  33383. /**
  33384. * Registers the component in a given scene
  33385. */
  33386. register(): void;
  33387. /**
  33388. * Rebuilds the elements related to this component in case of
  33389. * context lost for instance.
  33390. */
  33391. rebuild(): void;
  33392. /**
  33393. * Disposes the component and the associated ressources
  33394. */
  33395. dispose(): void;
  33396. }
  33397. }
  33398. declare module BABYLON {
  33399. /**
  33400. * A helper for physics simulations
  33401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33402. */
  33403. class PhysicsHelper {
  33404. private _scene;
  33405. private _physicsEngine;
  33406. /**
  33407. * Initializes the Physics helper
  33408. * @param scene Babylon.js scene
  33409. */
  33410. constructor(scene: Scene);
  33411. /**
  33412. * Applies a radial explosion impulse
  33413. * @param origin the origin of the explosion
  33414. * @param radius the explosion radius
  33415. * @param strength the explosion strength
  33416. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33417. * @returns A physics radial explosion event, or null
  33418. */
  33419. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33420. /**
  33421. * Applies a radial explosion force
  33422. * @param origin the origin of the explosion
  33423. * @param radius the explosion radius
  33424. * @param strength the explosion strength
  33425. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33426. * @returns A physics radial explosion event, or null
  33427. */
  33428. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33429. /**
  33430. * Creates a gravitational field
  33431. * @param origin the origin of the explosion
  33432. * @param radius the explosion radius
  33433. * @param strength the explosion strength
  33434. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33435. * @returns A physics gravitational field event, or null
  33436. */
  33437. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33438. /**
  33439. * Creates a physics updraft event
  33440. * @param origin the origin of the updraft
  33441. * @param radius the radius of the updraft
  33442. * @param strength the strength of the updraft
  33443. * @param height the height of the updraft
  33444. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33445. * @returns A physics updraft event, or null
  33446. */
  33447. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33448. /**
  33449. * Creates a physics vortex event
  33450. * @param origin the of the vortex
  33451. * @param radius the radius of the vortex
  33452. * @param strength the strength of the vortex
  33453. * @param height the height of the vortex
  33454. * @returns a Physics vortex event, or null
  33455. * A physics vortex event or null
  33456. */
  33457. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33458. }
  33459. /**
  33460. * Represents a physics radial explosion event
  33461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33462. */
  33463. class PhysicsRadialExplosionEvent {
  33464. private _scene;
  33465. private _sphere;
  33466. private _sphereOptions;
  33467. private _rays;
  33468. private _dataFetched;
  33469. /**
  33470. * Initializes a radial explosioin event
  33471. * @param scene BabylonJS scene
  33472. */
  33473. constructor(scene: Scene);
  33474. /**
  33475. * Returns the data related to the radial explosion event (sphere & rays).
  33476. * @returns The radial explosion event data
  33477. */
  33478. getData(): PhysicsRadialExplosionEventData;
  33479. /**
  33480. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33481. * @param impostor A physics imposter
  33482. * @param origin the origin of the explosion
  33483. * @param radius the explosion radius
  33484. * @param strength the explosion strength
  33485. * @param falloff possible options: Constant & Linear
  33486. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33487. */
  33488. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33489. /**
  33490. * Disposes the sphere.
  33491. * @param force Specifies if the sphere should be disposed by force
  33492. */
  33493. dispose(force?: boolean): void;
  33494. /*** Helpers ***/
  33495. private _prepareSphere;
  33496. private _intersectsWithSphere;
  33497. }
  33498. /**
  33499. * Represents a gravitational field event
  33500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33501. */
  33502. class PhysicsGravitationalFieldEvent {
  33503. private _physicsHelper;
  33504. private _scene;
  33505. private _origin;
  33506. private _radius;
  33507. private _strength;
  33508. private _falloff;
  33509. private _tickCallback;
  33510. private _sphere;
  33511. private _dataFetched;
  33512. /**
  33513. * Initializes the physics gravitational field event
  33514. * @param physicsHelper A physics helper
  33515. * @param scene BabylonJS scene
  33516. * @param origin The origin position of the gravitational field event
  33517. * @param radius The radius of the gravitational field event
  33518. * @param strength The strength of the gravitational field event
  33519. * @param falloff The falloff for the gravitational field event
  33520. */
  33521. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33522. /**
  33523. * Returns the data related to the gravitational field event (sphere).
  33524. * @returns A gravitational field event
  33525. */
  33526. getData(): PhysicsGravitationalFieldEventData;
  33527. /**
  33528. * Enables the gravitational field.
  33529. */
  33530. enable(): void;
  33531. /**
  33532. * Disables the gravitational field.
  33533. */
  33534. disable(): void;
  33535. /**
  33536. * Disposes the sphere.
  33537. * @param force The force to dispose from the gravitational field event
  33538. */
  33539. dispose(force?: boolean): void;
  33540. private _tick;
  33541. }
  33542. /**
  33543. * Represents a physics updraft event
  33544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33545. */
  33546. class PhysicsUpdraftEvent {
  33547. private _scene;
  33548. private _origin;
  33549. private _radius;
  33550. private _strength;
  33551. private _height;
  33552. private _updraftMode;
  33553. private _physicsEngine;
  33554. private _originTop;
  33555. private _originDirection;
  33556. private _tickCallback;
  33557. private _cylinder;
  33558. private _cylinderPosition;
  33559. private _dataFetched;
  33560. /**
  33561. * Initializes the physics updraft event
  33562. * @param _scene BabylonJS scene
  33563. * @param _origin The origin position of the updraft
  33564. * @param _radius The radius of the updraft
  33565. * @param _strength The strength of the updraft
  33566. * @param _height The height of the updraft
  33567. * @param _updraftMode The mode of the updraft
  33568. */
  33569. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33570. /**
  33571. * Returns the data related to the updraft event (cylinder).
  33572. * @returns A physics updraft event
  33573. */
  33574. getData(): PhysicsUpdraftEventData;
  33575. /**
  33576. * Enables the updraft.
  33577. */
  33578. enable(): void;
  33579. /**
  33580. * Disables the cortex.
  33581. */
  33582. disable(): void;
  33583. /**
  33584. * Disposes the sphere.
  33585. * @param force Specifies if the updraft should be disposed by force
  33586. */
  33587. dispose(force?: boolean): void;
  33588. private getImpostorForceAndContactPoint;
  33589. private _tick;
  33590. /*** Helpers ***/
  33591. private _prepareCylinder;
  33592. private _intersectsWithCylinder;
  33593. }
  33594. /**
  33595. * Represents a physics vortex event
  33596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33597. */
  33598. class PhysicsVortexEvent {
  33599. private _scene;
  33600. private _origin;
  33601. private _radius;
  33602. private _strength;
  33603. private _height;
  33604. private _physicsEngine;
  33605. private _originTop;
  33606. private _centripetalForceThreshold;
  33607. private _updraftMultiplier;
  33608. private _tickCallback;
  33609. private _cylinder;
  33610. private _cylinderPosition;
  33611. private _dataFetched;
  33612. /**
  33613. * Initializes the physics vortex event
  33614. * @param _scene The BabylonJS scene
  33615. * @param _origin The origin position of the vortex
  33616. * @param _radius The radius of the vortex
  33617. * @param _strength The strength of the vortex
  33618. * @param _height The height of the vortex
  33619. */
  33620. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33621. /**
  33622. * Returns the data related to the vortex event (cylinder).
  33623. * @returns The physics vortex event data
  33624. */
  33625. getData(): PhysicsVortexEventData;
  33626. /**
  33627. * Enables the vortex.
  33628. */
  33629. enable(): void;
  33630. /**
  33631. * Disables the cortex.
  33632. */
  33633. disable(): void;
  33634. /**
  33635. * Disposes the sphere.
  33636. * @param force
  33637. */
  33638. dispose(force?: boolean): void;
  33639. private getImpostorForceAndContactPoint;
  33640. private _tick;
  33641. /*** Helpers ***/
  33642. private _prepareCylinder;
  33643. private _intersectsWithCylinder;
  33644. }
  33645. /**
  33646. * The strenght of the force in correspondence to the distance of the affected object
  33647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33648. */
  33649. enum PhysicsRadialImpulseFalloff {
  33650. /** Defines that impulse is constant in strength across it's whole radius */
  33651. Constant = 0,
  33652. /** DEfines that impulse gets weaker if it's further from the origin */
  33653. Linear = 1
  33654. }
  33655. /**
  33656. * The strength of the force in correspondence to the distance of the affected object
  33657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33658. */
  33659. enum PhysicsUpdraftMode {
  33660. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33661. Center = 0,
  33662. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33663. Perpendicular = 1
  33664. }
  33665. /**
  33666. * Interface for a physics force and contact point
  33667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33668. */
  33669. interface PhysicsForceAndContactPoint {
  33670. /**
  33671. * The force applied at the contact point
  33672. */
  33673. force: Vector3;
  33674. /**
  33675. * The contact point
  33676. */
  33677. contactPoint: Vector3;
  33678. }
  33679. /**
  33680. * Interface for radial explosion event data
  33681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33682. */
  33683. interface PhysicsRadialExplosionEventData {
  33684. /**
  33685. * A sphere used for the radial explosion event
  33686. */
  33687. sphere: Mesh;
  33688. /**
  33689. * An array of rays for the radial explosion event
  33690. */
  33691. rays: Array<Ray>;
  33692. }
  33693. /**
  33694. * Interface for gravitational field event data
  33695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33696. */
  33697. interface PhysicsGravitationalFieldEventData {
  33698. /**
  33699. * A sphere mesh used for the gravitational field event
  33700. */
  33701. sphere: Mesh;
  33702. }
  33703. /**
  33704. * Interface for updraft event data
  33705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33706. */
  33707. interface PhysicsUpdraftEventData {
  33708. /**
  33709. * A cylinder used for the updraft event
  33710. */
  33711. cylinder: Mesh;
  33712. }
  33713. /**
  33714. * Interface for vortex event data
  33715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33716. */
  33717. interface PhysicsVortexEventData {
  33718. /**
  33719. * A cylinder used for the vortex event
  33720. */
  33721. cylinder: Mesh;
  33722. }
  33723. }
  33724. declare module BABYLON {
  33725. /**
  33726. * The interface for the physics imposter parameters
  33727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33728. */
  33729. interface PhysicsImpostorParameters {
  33730. /**
  33731. * The mass of the physics imposter
  33732. */
  33733. mass: number;
  33734. /**
  33735. * The friction of the physics imposter
  33736. */
  33737. friction?: number;
  33738. /**
  33739. * The coefficient of restitution of the physics imposter
  33740. */
  33741. restitution?: number;
  33742. /**
  33743. * The native options of the physics imposter
  33744. */
  33745. nativeOptions?: any;
  33746. /**
  33747. * Specifies if the parent should be ignored
  33748. */
  33749. ignoreParent?: boolean;
  33750. /**
  33751. * Specifies if bi-directional transformations should be disabled
  33752. */
  33753. disableBidirectionalTransformation?: boolean;
  33754. }
  33755. /**
  33756. * Interface for a physics-enabled object
  33757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33758. */
  33759. interface IPhysicsEnabledObject {
  33760. /**
  33761. * The position of the physics-enabled object
  33762. */
  33763. position: Vector3;
  33764. /**
  33765. * The rotation of the physics-enabled object
  33766. */
  33767. rotationQuaternion: Nullable<Quaternion>;
  33768. /**
  33769. * The scale of the physics-enabled object
  33770. */
  33771. scaling: Vector3;
  33772. /**
  33773. * The rotation of the physics-enabled object
  33774. */
  33775. rotation?: Vector3;
  33776. /**
  33777. * The parent of the physics-enabled object
  33778. */
  33779. parent?: any;
  33780. /**
  33781. * The bounding info of the physics-enabled object
  33782. * @returns The bounding info of the physics-enabled object
  33783. */
  33784. getBoundingInfo(): BoundingInfo;
  33785. /**
  33786. * Computes the world matrix
  33787. * @param force Specifies if the world matrix should be computed by force
  33788. * @returns A world matrix
  33789. */
  33790. computeWorldMatrix(force: boolean): Matrix;
  33791. /**
  33792. * Gets the world matrix
  33793. * @returns A world matrix
  33794. */
  33795. getWorldMatrix?(): Matrix;
  33796. /**
  33797. * Gets the child meshes
  33798. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33799. * @returns An array of abstract meshes
  33800. */
  33801. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33802. /**
  33803. * Gets the vertex data
  33804. * @param kind The type of vertex data
  33805. * @returns A nullable array of numbers, or a float32 array
  33806. */
  33807. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33808. /**
  33809. * Gets the indices from the mesh
  33810. * @returns A nullable array of index arrays
  33811. */
  33812. getIndices?(): Nullable<IndicesArray>;
  33813. /**
  33814. * Gets the scene from the mesh
  33815. * @returns the indices array or null
  33816. */
  33817. getScene?(): Scene;
  33818. /**
  33819. * Gets the absolute position from the mesh
  33820. * @returns the absolute position
  33821. */
  33822. getAbsolutePosition(): Vector3;
  33823. /**
  33824. * Gets the absolute pivot point from the mesh
  33825. * @returns the absolute pivot point
  33826. */
  33827. getAbsolutePivotPoint(): Vector3;
  33828. /**
  33829. * Rotates the mesh
  33830. * @param axis The axis of rotation
  33831. * @param amount The amount of rotation
  33832. * @param space The space of the rotation
  33833. * @returns The rotation transform node
  33834. */
  33835. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33836. /**
  33837. * Translates the mesh
  33838. * @param axis The axis of translation
  33839. * @param distance The distance of translation
  33840. * @param space The space of the translation
  33841. * @returns The transform node
  33842. */
  33843. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33844. /**
  33845. * Sets the absolute position of the mesh
  33846. * @param absolutePosition The absolute position of the mesh
  33847. * @returns The transform node
  33848. */
  33849. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33850. /**
  33851. * Gets the class name of the mesh
  33852. * @returns The class name
  33853. */
  33854. getClassName(): string;
  33855. }
  33856. /**
  33857. * Represents a physics imposter
  33858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33859. */
  33860. class PhysicsImpostor {
  33861. /**
  33862. * The physics-enabled object used as the physics imposter
  33863. */
  33864. object: IPhysicsEnabledObject;
  33865. /**
  33866. * The type of the physics imposter
  33867. */
  33868. type: number;
  33869. private _options;
  33870. private _scene?;
  33871. /**
  33872. * The default object size of the imposter
  33873. */
  33874. static DEFAULT_OBJECT_SIZE: Vector3;
  33875. /**
  33876. * The identity quaternion of the imposter
  33877. */
  33878. static IDENTITY_QUATERNION: Quaternion;
  33879. /** @hidden */
  33880. _pluginData: any;
  33881. private _physicsEngine;
  33882. private _physicsBody;
  33883. private _bodyUpdateRequired;
  33884. private _onBeforePhysicsStepCallbacks;
  33885. private _onAfterPhysicsStepCallbacks;
  33886. /** @hidden */
  33887. _onPhysicsCollideCallbacks: Array<{
  33888. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33889. otherImpostors: Array<PhysicsImpostor>;
  33890. }>;
  33891. private _deltaPosition;
  33892. private _deltaRotation;
  33893. private _deltaRotationConjugated;
  33894. private _parent;
  33895. private _isDisposed;
  33896. private static _tmpVecs;
  33897. private static _tmpQuat;
  33898. /**
  33899. * Specifies if the physics imposter is disposed
  33900. */
  33901. readonly isDisposed: boolean;
  33902. /**
  33903. * Gets the mass of the physics imposter
  33904. */
  33905. mass: number;
  33906. /**
  33907. * Gets the coefficient of friction
  33908. */
  33909. /**
  33910. * Sets the coefficient of friction
  33911. */
  33912. friction: number;
  33913. /**
  33914. * Gets the coefficient of restitution
  33915. */
  33916. /**
  33917. * Sets the coefficient of restitution
  33918. */
  33919. restitution: number;
  33920. /**
  33921. * The unique id of the physics imposter
  33922. * set by the physics engine when adding this impostor to the array
  33923. */
  33924. uniqueId: number;
  33925. private _joints;
  33926. /**
  33927. * Initializes the physics imposter
  33928. * @param object The physics-enabled object used as the physics imposter
  33929. * @param type The type of the physics imposter
  33930. * @param _options The options for the physics imposter
  33931. * @param _scene The Babylon scene
  33932. */
  33933. constructor(
  33934. /**
  33935. * The physics-enabled object used as the physics imposter
  33936. */
  33937. object: IPhysicsEnabledObject,
  33938. /**
  33939. * The type of the physics imposter
  33940. */
  33941. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33942. /**
  33943. * This function will completly initialize this impostor.
  33944. * It will create a new body - but only if this mesh has no parent.
  33945. * If it has, this impostor will not be used other than to define the impostor
  33946. * of the child mesh.
  33947. * @hidden
  33948. */
  33949. _init(): void;
  33950. private _getPhysicsParent;
  33951. /**
  33952. * Should a new body be generated.
  33953. * @returns boolean specifying if body initialization is required
  33954. */
  33955. isBodyInitRequired(): boolean;
  33956. /**
  33957. * Sets the updated scaling
  33958. * @param updated Specifies if the scaling is updated
  33959. */
  33960. setScalingUpdated(updated: boolean): void;
  33961. /**
  33962. * Force a regeneration of this or the parent's impostor's body.
  33963. * Use under cautious - This will remove all joints already implemented.
  33964. */
  33965. forceUpdate(): void;
  33966. /**
  33967. * Gets the body that holds this impostor. Either its own, or its parent.
  33968. */
  33969. /**
  33970. * Set the physics body. Used mainly by the physics engine/plugin
  33971. */
  33972. physicsBody: any;
  33973. /**
  33974. * Get the parent of the physics imposter
  33975. * @returns Physics imposter or null
  33976. */
  33977. /**
  33978. * Sets the parent of the physics imposter
  33979. */
  33980. parent: Nullable<PhysicsImpostor>;
  33981. /**
  33982. * Resets the update flags
  33983. */
  33984. resetUpdateFlags(): void;
  33985. /**
  33986. * Gets the object extend size
  33987. * @returns the object extend size
  33988. */
  33989. getObjectExtendSize(): Vector3;
  33990. /**
  33991. * Gets the object center
  33992. * @returns The object center
  33993. */
  33994. getObjectCenter(): Vector3;
  33995. /**
  33996. * Get a specific parametes from the options parameter
  33997. * @param paramName The object parameter name
  33998. * @returns The object parameter
  33999. */
  34000. getParam(paramName: string): any;
  34001. /**
  34002. * Sets a specific parameter in the options given to the physics plugin
  34003. * @param paramName The parameter name
  34004. * @param value The value of the parameter
  34005. */
  34006. setParam(paramName: string, value: number): void;
  34007. /**
  34008. * Specifically change the body's mass option. Won't recreate the physics body object
  34009. * @param mass The mass of the physics imposter
  34010. */
  34011. setMass(mass: number): void;
  34012. /**
  34013. * Gets the linear velocity
  34014. * @returns linear velocity or null
  34015. */
  34016. getLinearVelocity(): Nullable<Vector3>;
  34017. /**
  34018. * Sets the linear velocity
  34019. * @param velocity linear velocity or null
  34020. */
  34021. setLinearVelocity(velocity: Nullable<Vector3>): void;
  34022. /**
  34023. * Gets the angular velocity
  34024. * @returns angular velocity or null
  34025. */
  34026. getAngularVelocity(): Nullable<Vector3>;
  34027. /**
  34028. * Sets the angular velocity
  34029. * @param velocity The velocity or null
  34030. */
  34031. setAngularVelocity(velocity: Nullable<Vector3>): void;
  34032. /**
  34033. * Execute a function with the physics plugin native code
  34034. * Provide a function the will have two variables - the world object and the physics body object
  34035. * @param func The function to execute with the physics plugin native code
  34036. */
  34037. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  34038. /**
  34039. * Register a function that will be executed before the physics world is stepping forward
  34040. * @param func The function to execute before the physics world is stepped forward
  34041. */
  34042. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34043. /**
  34044. * Unregister a function that will be executed before the physics world is stepping forward
  34045. * @param func The function to execute before the physics world is stepped forward
  34046. */
  34047. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34048. /**
  34049. * Register a function that will be executed after the physics step
  34050. * @param func The function to execute after physics step
  34051. */
  34052. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34053. /**
  34054. * Unregisters a function that will be executed after the physics step
  34055. * @param func The function to execute after physics step
  34056. */
  34057. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34058. /**
  34059. * register a function that will be executed when this impostor collides against a different body
  34060. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34061. * @param func Callback that is executed on collision
  34062. */
  34063. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34064. /**
  34065. * Unregisters the physics imposter on contact
  34066. * @param collideAgainst The physics object to collide against
  34067. * @param func Callback to execute on collision
  34068. */
  34069. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34070. private _tmpQuat;
  34071. private _tmpQuat2;
  34072. /**
  34073. * Get the parent rotation
  34074. * @returns The parent rotation
  34075. */
  34076. getParentsRotation(): Quaternion;
  34077. /**
  34078. * this function is executed by the physics engine.
  34079. */
  34080. beforeStep: () => void;
  34081. /**
  34082. * this function is executed by the physics engine
  34083. */
  34084. afterStep: () => void;
  34085. /**
  34086. * Legacy collision detection event support
  34087. */
  34088. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34089. /**
  34090. * event and body object due to cannon's event-based architecture.
  34091. */
  34092. onCollide: (e: {
  34093. body: any;
  34094. }) => void;
  34095. /**
  34096. * Apply a force
  34097. * @param force The force to apply
  34098. * @param contactPoint The contact point for the force
  34099. * @returns The physics imposter
  34100. */
  34101. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34102. /**
  34103. * Apply an impulse
  34104. * @param force The impulse force
  34105. * @param contactPoint The contact point for the impulse force
  34106. * @returns The physics imposter
  34107. */
  34108. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34109. /**
  34110. * A help function to create a joint
  34111. * @param otherImpostor A physics imposter used to create a joint
  34112. * @param jointType The type of joint
  34113. * @param jointData The data for the joint
  34114. * @returns The physics imposter
  34115. */
  34116. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34117. /**
  34118. * Add a joint to this impostor with a different impostor
  34119. * @param otherImpostor A physics imposter used to add a joint
  34120. * @param joint The joint to add
  34121. * @returns The physics imposter
  34122. */
  34123. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34124. /**
  34125. * Will keep this body still, in a sleep mode.
  34126. * @returns the physics imposter
  34127. */
  34128. sleep(): PhysicsImpostor;
  34129. /**
  34130. * Wake the body up.
  34131. * @returns The physics imposter
  34132. */
  34133. wakeUp(): PhysicsImpostor;
  34134. /**
  34135. * Clones the physics imposter
  34136. * @param newObject The physics imposter clones to this physics-enabled object
  34137. * @returns A nullable physics imposter
  34138. */
  34139. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34140. /**
  34141. * Disposes the physics imposter
  34142. */
  34143. dispose(): void;
  34144. /**
  34145. * Sets the delta position
  34146. * @param position The delta position amount
  34147. */
  34148. setDeltaPosition(position: Vector3): void;
  34149. /**
  34150. * Sets the delta rotation
  34151. * @param rotation The delta rotation amount
  34152. */
  34153. setDeltaRotation(rotation: Quaternion): void;
  34154. /**
  34155. * Gets the box size of the physics imposter and stores the result in the input parameter
  34156. * @param result Stores the box size
  34157. * @returns The physics imposter
  34158. */
  34159. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34160. /**
  34161. * Gets the radius of the physics imposter
  34162. * @returns Radius of the physics imposter
  34163. */
  34164. getRadius(): number;
  34165. /**
  34166. * Sync a bone with this impostor
  34167. * @param bone The bone to sync to the impostor.
  34168. * @param boneMesh The mesh that the bone is influencing.
  34169. * @param jointPivot The pivot of the joint / bone in local space.
  34170. * @param distToJoint Optional distance from the impostor to the joint.
  34171. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34172. */
  34173. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34174. /**
  34175. * Sync impostor to a bone
  34176. * @param bone The bone that the impostor will be synced to.
  34177. * @param boneMesh The mesh that the bone is influencing.
  34178. * @param jointPivot The pivot of the joint / bone in local space.
  34179. * @param distToJoint Optional distance from the impostor to the joint.
  34180. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34181. * @param boneAxis Optional vector3 axis the bone is aligned with
  34182. */
  34183. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34184. /**
  34185. * No-Imposter type
  34186. */
  34187. static NoImpostor: number;
  34188. /**
  34189. * Sphere-Imposter type
  34190. */
  34191. static SphereImpostor: number;
  34192. /**
  34193. * Box-Imposter type
  34194. */
  34195. static BoxImpostor: number;
  34196. /**
  34197. * Plane-Imposter type
  34198. */
  34199. static PlaneImpostor: number;
  34200. /**
  34201. * Mesh-imposter type
  34202. */
  34203. static MeshImpostor: number;
  34204. /**
  34205. * Cylinder-Imposter type
  34206. */
  34207. static CylinderImpostor: number;
  34208. /**
  34209. * Particle-Imposter type
  34210. */
  34211. static ParticleImpostor: number;
  34212. /**
  34213. * Heightmap-Imposter type
  34214. */
  34215. static HeightmapImpostor: number;
  34216. }
  34217. }
  34218. declare module BABYLON {
  34219. /**
  34220. * Interface for Physics-Joint data
  34221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34222. */
  34223. interface PhysicsJointData {
  34224. /**
  34225. * The main pivot of the joint
  34226. */
  34227. mainPivot?: Vector3;
  34228. /**
  34229. * The connected pivot of the joint
  34230. */
  34231. connectedPivot?: Vector3;
  34232. /**
  34233. * The main axis of the joint
  34234. */
  34235. mainAxis?: Vector3;
  34236. /**
  34237. * The connected axis of the joint
  34238. */
  34239. connectedAxis?: Vector3;
  34240. /**
  34241. * The collision of the joint
  34242. */
  34243. collision?: boolean;
  34244. /**
  34245. * Native Oimo/Cannon/Energy data
  34246. */
  34247. nativeParams?: any;
  34248. }
  34249. /**
  34250. * This is a holder class for the physics joint created by the physics plugin
  34251. * It holds a set of functions to control the underlying joint
  34252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34253. */
  34254. class PhysicsJoint {
  34255. /**
  34256. * The type of the physics joint
  34257. */
  34258. type: number;
  34259. /**
  34260. * The data for the physics joint
  34261. */
  34262. jointData: PhysicsJointData;
  34263. private _physicsJoint;
  34264. protected _physicsPlugin: IPhysicsEnginePlugin;
  34265. /**
  34266. * Initializes the physics joint
  34267. * @param type The type of the physics joint
  34268. * @param jointData The data for the physics joint
  34269. */
  34270. constructor(
  34271. /**
  34272. * The type of the physics joint
  34273. */
  34274. type: number,
  34275. /**
  34276. * The data for the physics joint
  34277. */
  34278. jointData: PhysicsJointData);
  34279. /**
  34280. * Gets the physics joint
  34281. */
  34282. /**
  34283. * Sets the physics joint
  34284. */
  34285. physicsJoint: any;
  34286. /**
  34287. * Sets the physics plugin
  34288. */
  34289. physicsPlugin: IPhysicsEnginePlugin;
  34290. /**
  34291. * Execute a function that is physics-plugin specific.
  34292. * @param {Function} func the function that will be executed.
  34293. * It accepts two parameters: the physics world and the physics joint
  34294. */
  34295. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34296. /**
  34297. * Distance-Joint type
  34298. */
  34299. static DistanceJoint: number;
  34300. /**
  34301. * Hinge-Joint type
  34302. */
  34303. static HingeJoint: number;
  34304. /**
  34305. * Ball-and-Socket joint type
  34306. */
  34307. static BallAndSocketJoint: number;
  34308. /**
  34309. * Wheel-Joint type
  34310. */
  34311. static WheelJoint: number;
  34312. /**
  34313. * Slider-Joint type
  34314. */
  34315. static SliderJoint: number;
  34316. /**
  34317. * Prismatic-Joint type
  34318. */
  34319. static PrismaticJoint: number;
  34320. /**
  34321. * Universal-Joint type
  34322. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34323. */
  34324. static UniversalJoint: number;
  34325. /**
  34326. * Hinge-Joint 2 type
  34327. */
  34328. static Hinge2Joint: number;
  34329. /**
  34330. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34331. */
  34332. static PointToPointJoint: number;
  34333. /**
  34334. * Spring-Joint type
  34335. */
  34336. static SpringJoint: number;
  34337. /**
  34338. * Lock-Joint type
  34339. */
  34340. static LockJoint: number;
  34341. }
  34342. /**
  34343. * A class representing a physics distance joint
  34344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34345. */
  34346. class DistanceJoint extends PhysicsJoint {
  34347. /**
  34348. *
  34349. * @param jointData The data for the Distance-Joint
  34350. */
  34351. constructor(jointData: DistanceJointData);
  34352. /**
  34353. * Update the predefined distance.
  34354. * @param maxDistance The maximum preferred distance
  34355. * @param minDistance The minimum preferred distance
  34356. */
  34357. updateDistance(maxDistance: number, minDistance?: number): void;
  34358. }
  34359. /**
  34360. * Represents a Motor-Enabled Joint
  34361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34362. */
  34363. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34364. /**
  34365. * Initializes the Motor-Enabled Joint
  34366. * @param type The type of the joint
  34367. * @param jointData The physica joint data for the joint
  34368. */
  34369. constructor(type: number, jointData: PhysicsJointData);
  34370. /**
  34371. * Set the motor values.
  34372. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34373. * @param force the force to apply
  34374. * @param maxForce max force for this motor.
  34375. */
  34376. setMotor(force?: number, maxForce?: number): void;
  34377. /**
  34378. * Set the motor's limits.
  34379. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34380. * @param upperLimit The upper limit of the motor
  34381. * @param lowerLimit The lower limit of the motor
  34382. */
  34383. setLimit(upperLimit: number, lowerLimit?: number): void;
  34384. }
  34385. /**
  34386. * This class represents a single physics Hinge-Joint
  34387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34388. */
  34389. class HingeJoint extends MotorEnabledJoint {
  34390. /**
  34391. * Initializes the Hinge-Joint
  34392. * @param jointData The joint data for the Hinge-Joint
  34393. */
  34394. constructor(jointData: PhysicsJointData);
  34395. /**
  34396. * Set the motor values.
  34397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34398. * @param {number} force the force to apply
  34399. * @param {number} maxForce max force for this motor.
  34400. */
  34401. setMotor(force?: number, maxForce?: number): void;
  34402. /**
  34403. * Set the motor's limits.
  34404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34405. * @param upperLimit The upper limit of the motor
  34406. * @param lowerLimit The lower limit of the motor
  34407. */
  34408. setLimit(upperLimit: number, lowerLimit?: number): void;
  34409. }
  34410. /**
  34411. * This class represents a dual hinge physics joint (same as wheel joint)
  34412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34413. */
  34414. class Hinge2Joint extends MotorEnabledJoint {
  34415. /**
  34416. * Initializes the Hinge2-Joint
  34417. * @param jointData The joint data for the Hinge2-Joint
  34418. */
  34419. constructor(jointData: PhysicsJointData);
  34420. /**
  34421. * Set the motor values.
  34422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34423. * @param {number} force the force to apply
  34424. * @param {number} maxForce max force for this motor.
  34425. * @param {motorIndex} the motor's index, 0 or 1.
  34426. */
  34427. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34428. /**
  34429. * Set the motor limits.
  34430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34431. * @param {number} upperLimit the upper limit
  34432. * @param {number} lowerLimit lower limit
  34433. * @param {motorIndex} the motor's index, 0 or 1.
  34434. */
  34435. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34436. }
  34437. /**
  34438. * Interface for a motor enabled joint
  34439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34440. */
  34441. interface IMotorEnabledJoint {
  34442. /**
  34443. * Physics joint
  34444. */
  34445. physicsJoint: any;
  34446. /**
  34447. * Sets the motor of the motor-enabled joint
  34448. * @param force The force of the motor
  34449. * @param maxForce The maximum force of the motor
  34450. * @param motorIndex The index of the motor
  34451. */
  34452. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34453. /**
  34454. * Sets the limit of the motor
  34455. * @param upperLimit The upper limit of the motor
  34456. * @param lowerLimit The lower limit of the motor
  34457. * @param motorIndex The index of the motor
  34458. */
  34459. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34460. }
  34461. /**
  34462. * Joint data for a Distance-Joint
  34463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34464. */
  34465. interface DistanceJointData extends PhysicsJointData {
  34466. /**
  34467. * Max distance the 2 joint objects can be apart
  34468. */
  34469. maxDistance: number;
  34470. }
  34471. /**
  34472. * Joint data from a spring joint
  34473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34474. */
  34475. interface SpringJointData extends PhysicsJointData {
  34476. /**
  34477. * Length of the spring
  34478. */
  34479. length: number;
  34480. /**
  34481. * Stiffness of the spring
  34482. */
  34483. stiffness: number;
  34484. /**
  34485. * Damping of the spring
  34486. */
  34487. damping: number;
  34488. /** this callback will be called when applying the force to the impostors. */
  34489. forceApplicationCallback: () => void;
  34490. }
  34491. }
  34492. declare module BABYLON {
  34493. interface AbstractScene {
  34494. /**
  34495. * The list of reflection probes added to the scene
  34496. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34497. */
  34498. reflectionProbes: Array<ReflectionProbe>;
  34499. /**
  34500. * Removes the given reflection probe from this scene.
  34501. * @param toRemove The reflection probe to remove
  34502. * @returns The index of the removed reflection probe
  34503. */
  34504. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34505. /**
  34506. * Adds the given reflection probe to this scene.
  34507. * @param newReflectionProbe The reflection probe to add
  34508. */
  34509. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34510. }
  34511. /**
  34512. * Class used to generate realtime reflection / refraction cube textures
  34513. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34514. */
  34515. class ReflectionProbe {
  34516. /** defines the name of the probe */
  34517. name: string;
  34518. private _scene;
  34519. private _renderTargetTexture;
  34520. private _projectionMatrix;
  34521. private _viewMatrix;
  34522. private _target;
  34523. private _add;
  34524. private _attachedMesh;
  34525. private _invertYAxis;
  34526. /** Gets or sets probe position (center of the cube map) */
  34527. position: Vector3;
  34528. /**
  34529. * Creates a new reflection probe
  34530. * @param name defines the name of the probe
  34531. * @param size defines the texture resolution (for each face)
  34532. * @param scene defines the hosting scene
  34533. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34534. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34535. */
  34536. constructor(
  34537. /** defines the name of the probe */
  34538. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34539. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34540. samples: number;
  34541. /** Gets or sets the refresh rate to use (on every frame by default) */
  34542. refreshRate: number;
  34543. /**
  34544. * Gets the hosting scene
  34545. * @returns a Scene
  34546. */
  34547. getScene(): Scene;
  34548. /** Gets the internal CubeTexture used to render to */
  34549. readonly cubeTexture: RenderTargetTexture;
  34550. /** Gets the list of meshes to render */
  34551. readonly renderList: Nullable<AbstractMesh[]>;
  34552. /**
  34553. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34554. * @param mesh defines the mesh to attach to
  34555. */
  34556. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34557. /**
  34558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34559. * @param renderingGroupId The rendering group id corresponding to its index
  34560. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34561. */
  34562. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34563. /**
  34564. * Clean all associated resources
  34565. */
  34566. dispose(): void;
  34567. /**
  34568. * Converts the reflection probe information to a readable string for debug purpose.
  34569. * @param fullDetails Supports for multiple levels of logging within scene loading
  34570. * @returns the human readable reflection probe info
  34571. */
  34572. toString(fullDetails?: boolean): string;
  34573. /**
  34574. * Get the class name of the relfection probe.
  34575. * @returns "ReflectionProbe"
  34576. */
  34577. getClassName(): string;
  34578. /**
  34579. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34580. * @returns The JSON representation of the texture
  34581. */
  34582. serialize(): any;
  34583. /**
  34584. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34585. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34586. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34587. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34588. * @returns The parsed reflection probe if successful
  34589. */
  34590. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34591. }
  34592. }
  34593. declare module BABYLON {
  34594. /**
  34595. * Postprocess used to generate anaglyphic rendering
  34596. */
  34597. class AnaglyphPostProcess extends PostProcess {
  34598. private _passedProcess;
  34599. /**
  34600. * Creates a new AnaglyphPostProcess
  34601. * @param name defines postprocess name
  34602. * @param options defines creation options or target ratio scale
  34603. * @param rigCameras defines cameras using this postprocess
  34604. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34605. * @param engine defines hosting engine
  34606. * @param reusable defines if the postprocess will be reused multiple times per frame
  34607. */
  34608. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34609. }
  34610. }
  34611. declare module BABYLON {
  34612. /**
  34613. * Post process used to render in black and white
  34614. */
  34615. class BlackAndWhitePostProcess extends PostProcess {
  34616. /**
  34617. * Linear about to convert he result to black and white (default: 1)
  34618. */
  34619. degree: number;
  34620. /**
  34621. * Creates a black and white post process
  34622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34623. * @param name The name of the effect.
  34624. * @param options The required width/height ratio to downsize to before computing the render pass.
  34625. * @param camera The camera to apply the render pass to.
  34626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34627. * @param engine The engine which the post process will be applied. (default: current engine)
  34628. * @param reusable If the post process can be reused on the same frame. (default: false)
  34629. */
  34630. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34631. }
  34632. }
  34633. declare module BABYLON {
  34634. /**
  34635. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34636. */
  34637. class BloomEffect extends PostProcessRenderEffect {
  34638. private bloomScale;
  34639. /**
  34640. * @hidden Internal
  34641. */
  34642. _effects: Array<PostProcess>;
  34643. /**
  34644. * @hidden Internal
  34645. */
  34646. _downscale: ExtractHighlightsPostProcess;
  34647. private _blurX;
  34648. private _blurY;
  34649. private _merge;
  34650. /**
  34651. * The luminance threshold to find bright areas of the image to bloom.
  34652. */
  34653. threshold: number;
  34654. /**
  34655. * The strength of the bloom.
  34656. */
  34657. weight: number;
  34658. /**
  34659. * Specifies the size of the bloom blur kernel, relative to the final output size
  34660. */
  34661. kernel: number;
  34662. /**
  34663. * Creates a new instance of @see BloomEffect
  34664. * @param scene The scene the effect belongs to.
  34665. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34666. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34667. * @param bloomWeight The the strength of bloom.
  34668. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34669. * @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)
  34670. */
  34671. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34672. /**
  34673. * Disposes each of the internal effects for a given camera.
  34674. * @param camera The camera to dispose the effect on.
  34675. */
  34676. disposeEffects(camera: Camera): void;
  34677. /**
  34678. * @hidden Internal
  34679. */
  34680. _updateEffects(): void;
  34681. /**
  34682. * Internal
  34683. * @returns if all the contained post processes are ready.
  34684. * @hidden
  34685. */
  34686. _isReady(): boolean;
  34687. }
  34688. }
  34689. declare module BABYLON {
  34690. /**
  34691. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34692. */
  34693. class BloomMergePostProcess extends PostProcess {
  34694. /** Weight of the bloom to be added to the original input. */
  34695. weight: number;
  34696. /**
  34697. * Creates a new instance of @see BloomMergePostProcess
  34698. * @param name The name of the effect.
  34699. * @param originalFromInput Post process which's input will be used for the merge.
  34700. * @param blurred Blurred highlights post process which's output will be used.
  34701. * @param weight Weight of the bloom to be added to the original input.
  34702. * @param options The required width/height ratio to downsize to before computing the render pass.
  34703. * @param camera The camera to apply the render pass to.
  34704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34705. * @param engine The engine which the post process will be applied. (default: current engine)
  34706. * @param reusable If the post process can be reused on the same frame. (default: false)
  34707. * @param textureType Type of textures used when performing the post process. (default: 0)
  34708. * @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)
  34709. */
  34710. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34711. /** Weight of the bloom to be added to the original input. */
  34712. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34713. }
  34714. }
  34715. declare module BABYLON {
  34716. /**
  34717. * The Blur Post Process which blurs an image based on a kernel and direction.
  34718. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34719. */
  34720. class BlurPostProcess extends PostProcess {
  34721. /** The direction in which to blur the image. */
  34722. direction: Vector2;
  34723. private blockCompilation;
  34724. protected _kernel: number;
  34725. protected _idealKernel: number;
  34726. protected _packedFloat: boolean;
  34727. private _staticDefines;
  34728. /**
  34729. * Sets the length in pixels of the blur sample region
  34730. */
  34731. /**
  34732. * Gets the length in pixels of the blur sample region
  34733. */
  34734. kernel: number;
  34735. /**
  34736. * Sets wether or not the blur needs to unpack/repack floats
  34737. */
  34738. /**
  34739. * Gets wether or not the blur is unpacking/repacking floats
  34740. */
  34741. packedFloat: boolean;
  34742. /**
  34743. * Creates a new instance BlurPostProcess
  34744. * @param name The name of the effect.
  34745. * @param direction The direction in which to blur the image.
  34746. * @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.
  34747. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34748. * @param camera The camera to apply the render pass to.
  34749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34750. * @param engine The engine which the post process will be applied. (default: current engine)
  34751. * @param reusable If the post process can be reused on the same frame. (default: false)
  34752. * @param textureType Type of textures used when performing the post process. (default: 0)
  34753. * @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)
  34754. */
  34755. constructor(name: string,
  34756. /** The direction in which to blur the image. */
  34757. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34758. /**
  34759. * Updates the effect with the current post process compile time values and recompiles the shader.
  34760. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34761. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34762. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34763. * @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
  34764. * @param onCompiled Called when the shader has been compiled.
  34765. * @param onError Called if there is an error when compiling a shader.
  34766. */
  34767. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34768. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34769. /**
  34770. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34771. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34772. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34773. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34774. * The gaps between physical kernels are compensated for in the weighting of the samples
  34775. * @param idealKernel Ideal blur kernel.
  34776. * @return Nearest best kernel.
  34777. */
  34778. protected _nearestBestKernel(idealKernel: number): number;
  34779. /**
  34780. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34781. * @param x The point on the Gaussian distribution to sample.
  34782. * @return the value of the Gaussian function at x.
  34783. */
  34784. protected _gaussianWeight(x: number): number;
  34785. /**
  34786. * Generates a string that can be used as a floating point number in GLSL.
  34787. * @param x Value to print.
  34788. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34789. * @return GLSL float string.
  34790. */
  34791. protected _glslFloat(x: number, decimalFigures?: number): string;
  34792. }
  34793. }
  34794. declare module BABYLON {
  34795. /**
  34796. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34797. */
  34798. class ChromaticAberrationPostProcess extends PostProcess {
  34799. /**
  34800. * The amount of seperation of rgb channels (default: 30)
  34801. */
  34802. aberrationAmount: number;
  34803. /**
  34804. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34805. */
  34806. radialIntensity: number;
  34807. /**
  34808. * 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))
  34809. */
  34810. direction: Vector2;
  34811. /**
  34812. * 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))
  34813. */
  34814. centerPosition: Vector2;
  34815. /**
  34816. * Creates a new instance ChromaticAberrationPostProcess
  34817. * @param name The name of the effect.
  34818. * @param screenWidth The width of the screen to apply the effect on.
  34819. * @param screenHeight The height of the screen to apply the effect on.
  34820. * @param options The required width/height ratio to downsize to before computing the render pass.
  34821. * @param camera The camera to apply the render pass to.
  34822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34823. * @param engine The engine which the post process will be applied. (default: current engine)
  34824. * @param reusable If the post process can be reused on the same frame. (default: false)
  34825. * @param textureType Type of textures used when performing the post process. (default: 0)
  34826. * @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)
  34827. */
  34828. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34829. }
  34830. }
  34831. declare module BABYLON {
  34832. /**
  34833. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34834. */
  34835. class CircleOfConfusionPostProcess extends PostProcess {
  34836. /**
  34837. * 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.
  34838. */
  34839. lensSize: number;
  34840. /**
  34841. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34842. */
  34843. fStop: number;
  34844. /**
  34845. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34846. */
  34847. focusDistance: number;
  34848. /**
  34849. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34850. */
  34851. focalLength: number;
  34852. private _depthTexture;
  34853. /**
  34854. * Creates a new instance CircleOfConfusionPostProcess
  34855. * @param name The name of the effect.
  34856. * @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.
  34857. * @param options The required width/height ratio to downsize to before computing the render pass.
  34858. * @param camera The camera to apply the render pass to.
  34859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34860. * @param engine The engine which the post process will be applied. (default: current engine)
  34861. * @param reusable If the post process can be reused on the same frame. (default: false)
  34862. * @param textureType Type of textures used when performing the post process. (default: 0)
  34863. * @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)
  34864. */
  34865. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34866. /**
  34867. * 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.
  34868. */
  34869. depthTexture: RenderTargetTexture;
  34870. }
  34871. }
  34872. declare module BABYLON {
  34873. /**
  34874. *
  34875. * This post-process allows the modification of rendered colors by using
  34876. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34877. *
  34878. * The object needs to be provided an url to a texture containing the color
  34879. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34880. * Use an image editing software to tweak the LUT to match your needs.
  34881. *
  34882. * For an example of a color LUT, see here:
  34883. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34884. * For explanations on color grading, see here:
  34885. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34886. *
  34887. */
  34888. class ColorCorrectionPostProcess extends PostProcess {
  34889. private _colorTableTexture;
  34890. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34891. }
  34892. }
  34893. declare module BABYLON {
  34894. /**
  34895. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34896. * input texture to perform effects such as edge detection or sharpening
  34897. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34898. */
  34899. class ConvolutionPostProcess extends PostProcess {
  34900. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34901. kernel: number[];
  34902. /**
  34903. * Creates a new instance ConvolutionPostProcess
  34904. * @param name The name of the effect.
  34905. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34906. * @param options The required width/height ratio to downsize to before computing the render pass.
  34907. * @param camera The camera to apply the render pass to.
  34908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34909. * @param engine The engine which the post process will be applied. (default: current engine)
  34910. * @param reusable If the post process can be reused on the same frame. (default: false)
  34911. * @param textureType Type of textures used when performing the post process. (default: 0)
  34912. */
  34913. constructor(name: string,
  34914. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34915. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34916. /**
  34917. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34918. */
  34919. static EdgeDetect0Kernel: number[];
  34920. /**
  34921. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34922. */
  34923. static EdgeDetect1Kernel: number[];
  34924. /**
  34925. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34926. */
  34927. static EdgeDetect2Kernel: number[];
  34928. /**
  34929. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34930. */
  34931. static SharpenKernel: number[];
  34932. /**
  34933. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34934. */
  34935. static EmbossKernel: number[];
  34936. /**
  34937. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34938. */
  34939. static GaussianKernel: number[];
  34940. }
  34941. }
  34942. declare module BABYLON {
  34943. /**
  34944. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34945. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34946. * based on samples that have a large difference in distance than the center pixel.
  34947. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34948. */
  34949. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34950. direction: Vector2;
  34951. /**
  34952. * Creates a new instance CircleOfConfusionPostProcess
  34953. * @param name The name of the effect.
  34954. * @param scene The scene the effect belongs to.
  34955. * @param direction The direction the blur should be applied.
  34956. * @param kernel The size of the kernel used to blur.
  34957. * @param options The required width/height ratio to downsize to before computing the render pass.
  34958. * @param camera The camera to apply the render pass to.
  34959. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34960. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34962. * @param engine The engine which the post process will be applied. (default: current engine)
  34963. * @param reusable If the post process can be reused on the same frame. (default: false)
  34964. * @param textureType Type of textures used when performing the post process. (default: 0)
  34965. * @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)
  34966. */
  34967. 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);
  34968. }
  34969. }
  34970. declare module BABYLON {
  34971. /**
  34972. * Specifies the level of max blur that should be applied when using the depth of field effect
  34973. */
  34974. enum DepthOfFieldEffectBlurLevel {
  34975. /**
  34976. * Subtle blur
  34977. */
  34978. Low = 0,
  34979. /**
  34980. * Medium blur
  34981. */
  34982. Medium = 1,
  34983. /**
  34984. * Large blur
  34985. */
  34986. High = 2
  34987. }
  34988. /**
  34989. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34990. */
  34991. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34992. private _circleOfConfusion;
  34993. /**
  34994. * @hidden Internal, blurs from high to low
  34995. */
  34996. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34997. private _depthOfFieldBlurY;
  34998. private _dofMerge;
  34999. /**
  35000. * @hidden Internal post processes in depth of field effect
  35001. */
  35002. _effects: Array<PostProcess>;
  35003. /**
  35004. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  35005. */
  35006. focalLength: number;
  35007. /**
  35008. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35009. */
  35010. fStop: number;
  35011. /**
  35012. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35013. */
  35014. focusDistance: number;
  35015. /**
  35016. * 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.
  35017. */
  35018. lensSize: number;
  35019. /**
  35020. * Creates a new instance DepthOfFieldEffect
  35021. * @param scene The scene the effect belongs to.
  35022. * @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.
  35023. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35024. * @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)
  35025. */
  35026. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35027. /**
  35028. * 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.
  35029. */
  35030. depthTexture: RenderTargetTexture;
  35031. /**
  35032. * Disposes each of the internal effects for a given camera.
  35033. * @param camera The camera to dispose the effect on.
  35034. */
  35035. disposeEffects(camera: Camera): void;
  35036. /**
  35037. * @hidden Internal
  35038. */
  35039. _updateEffects(): void;
  35040. /**
  35041. * Internal
  35042. * @returns if all the contained post processes are ready.
  35043. * @hidden
  35044. */
  35045. _isReady(): boolean;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * Options to be set when merging outputs from the default pipeline.
  35051. */
  35052. class DepthOfFieldMergePostProcessOptions {
  35053. /**
  35054. * The original image to merge on top of
  35055. */
  35056. originalFromInput: PostProcess;
  35057. /**
  35058. * Parameters to perform the merge of the depth of field effect
  35059. */
  35060. depthOfField?: {
  35061. circleOfConfusion: PostProcess;
  35062. blurSteps: Array<PostProcess>;
  35063. };
  35064. /**
  35065. * Parameters to perform the merge of bloom effect
  35066. */
  35067. bloom?: {
  35068. blurred: PostProcess;
  35069. weight: number;
  35070. };
  35071. }
  35072. /**
  35073. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35074. */
  35075. class DepthOfFieldMergePostProcess extends PostProcess {
  35076. private blurSteps;
  35077. /**
  35078. * Creates a new instance of DepthOfFieldMergePostProcess
  35079. * @param name The name of the effect.
  35080. * @param originalFromInput Post process which's input will be used for the merge.
  35081. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35082. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35083. * @param options The required width/height ratio to downsize to before computing the render pass.
  35084. * @param camera The camera to apply the render pass to.
  35085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35086. * @param engine The engine which the post process will be applied. (default: current engine)
  35087. * @param reusable If the post process can be reused on the same frame. (default: false)
  35088. * @param textureType Type of textures used when performing the post process. (default: 0)
  35089. * @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)
  35090. */
  35091. 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);
  35092. /**
  35093. * Updates the effect with the current post process compile time values and recompiles the shader.
  35094. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35095. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35096. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35097. * @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
  35098. * @param onCompiled Called when the shader has been compiled.
  35099. * @param onError Called if there is an error when compiling a shader.
  35100. */
  35101. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35102. }
  35103. }
  35104. declare module BABYLON {
  35105. /**
  35106. * DisplayPassPostProcess which produces an output the same as it's input
  35107. */
  35108. class DisplayPassPostProcess extends PostProcess {
  35109. /**
  35110. * Creates the DisplayPassPostProcess
  35111. * @param name The name of the effect.
  35112. * @param options The required width/height ratio to downsize to before computing the render pass.
  35113. * @param camera The camera to apply the render pass to.
  35114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35115. * @param engine The engine which the post process will be applied. (default: current engine)
  35116. * @param reusable If the post process can be reused on the same frame. (default: false)
  35117. */
  35118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35119. }
  35120. }
  35121. declare module BABYLON {
  35122. /**
  35123. * 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.
  35124. */
  35125. class ExtractHighlightsPostProcess extends PostProcess {
  35126. /**
  35127. * The luminance threshold, pixels below this value will be set to black.
  35128. */
  35129. threshold: number;
  35130. /** @hidden */
  35131. _exposure: number;
  35132. /**
  35133. * Post process which has the input texture to be used when performing highlight extraction
  35134. * @hidden
  35135. */
  35136. _inputPostProcess: Nullable<PostProcess>;
  35137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35138. }
  35139. }
  35140. declare module BABYLON {
  35141. /**
  35142. * Applies a kernel filter to the image
  35143. */
  35144. class FilterPostProcess extends PostProcess {
  35145. /** The matrix to be applied to the image */
  35146. kernelMatrix: Matrix;
  35147. /**
  35148. *
  35149. * @param name The name of the effect.
  35150. * @param kernelMatrix The matrix to be applied to the image
  35151. * @param options The required width/height ratio to downsize to before computing the render pass.
  35152. * @param camera The camera to apply the render pass to.
  35153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35154. * @param engine The engine which the post process will be applied. (default: current engine)
  35155. * @param reusable If the post process can be reused on the same frame. (default: false)
  35156. */
  35157. constructor(name: string,
  35158. /** The matrix to be applied to the image */
  35159. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35160. }
  35161. }
  35162. declare module BABYLON {
  35163. /**
  35164. * Fxaa post process
  35165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35166. */
  35167. class FxaaPostProcess extends PostProcess {
  35168. /** @hidden */
  35169. texelWidth: number;
  35170. /** @hidden */
  35171. texelHeight: number;
  35172. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35173. private _getDefines;
  35174. }
  35175. }
  35176. declare module BABYLON {
  35177. /**
  35178. * The GrainPostProcess adds noise to the image at mid luminance levels
  35179. */
  35180. class GrainPostProcess extends PostProcess {
  35181. /**
  35182. * The intensity of the grain added (default: 30)
  35183. */
  35184. intensity: number;
  35185. /**
  35186. * If the grain should be randomized on every frame
  35187. */
  35188. animated: boolean;
  35189. /**
  35190. * Creates a new instance of @see GrainPostProcess
  35191. * @param name The name of the effect.
  35192. * @param options The required width/height ratio to downsize to before computing the render pass.
  35193. * @param camera The camera to apply the render pass to.
  35194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35195. * @param engine The engine which the post process will be applied. (default: current engine)
  35196. * @param reusable If the post process can be reused on the same frame. (default: false)
  35197. * @param textureType Type of textures used when performing the post process. (default: 0)
  35198. * @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)
  35199. */
  35200. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35201. }
  35202. }
  35203. declare module BABYLON {
  35204. /**
  35205. * Extracts highlights from the image
  35206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35207. */
  35208. class HighlightsPostProcess extends PostProcess {
  35209. /**
  35210. * Extracts highlights from the image
  35211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35212. * @param name The name of the effect.
  35213. * @param options The required width/height ratio to downsize to before computing the render pass.
  35214. * @param camera The camera to apply the render pass to.
  35215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35216. * @param engine The engine which the post process will be applied. (default: current engine)
  35217. * @param reusable If the post process can be reused on the same frame. (default: false)
  35218. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35219. */
  35220. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35221. }
  35222. }
  35223. declare module BABYLON {
  35224. /**
  35225. * ImageProcessingPostProcess
  35226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35227. */
  35228. class ImageProcessingPostProcess extends PostProcess {
  35229. /**
  35230. * Default configuration related to image processing available in the PBR Material.
  35231. */
  35232. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35233. /**
  35234. * Gets the image processing configuration used either in this material.
  35235. */
  35236. /**
  35237. * Sets the Default image processing configuration used either in the this material.
  35238. *
  35239. * If sets to null, the scene one is in use.
  35240. */
  35241. imageProcessingConfiguration: ImageProcessingConfiguration;
  35242. /**
  35243. * Keep track of the image processing observer to allow dispose and replace.
  35244. */
  35245. private _imageProcessingObserver;
  35246. /**
  35247. * Attaches a new image processing configuration to the PBR Material.
  35248. * @param configuration
  35249. */
  35250. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35251. /**
  35252. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35253. */
  35254. /**
  35255. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35256. */
  35257. colorCurves: Nullable<ColorCurves>;
  35258. /**
  35259. * Gets wether the color curves effect is enabled.
  35260. */
  35261. /**
  35262. * Sets wether the color curves effect is enabled.
  35263. */
  35264. colorCurvesEnabled: boolean;
  35265. /**
  35266. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35267. */
  35268. /**
  35269. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35270. */
  35271. colorGradingTexture: Nullable<BaseTexture>;
  35272. /**
  35273. * Gets wether the color grading effect is enabled.
  35274. */
  35275. /**
  35276. * Gets wether the color grading effect is enabled.
  35277. */
  35278. colorGradingEnabled: boolean;
  35279. /**
  35280. * Gets exposure used in the effect.
  35281. */
  35282. /**
  35283. * Sets exposure used in the effect.
  35284. */
  35285. exposure: number;
  35286. /**
  35287. * Gets wether tonemapping is enabled or not.
  35288. */
  35289. /**
  35290. * Sets wether tonemapping is enabled or not
  35291. */
  35292. toneMappingEnabled: boolean;
  35293. /**
  35294. * Gets contrast used in the effect.
  35295. */
  35296. /**
  35297. * Sets contrast used in the effect.
  35298. */
  35299. contrast: number;
  35300. /**
  35301. * Gets Vignette stretch size.
  35302. */
  35303. /**
  35304. * Sets Vignette stretch size.
  35305. */
  35306. vignetteStretch: number;
  35307. /**
  35308. * Gets Vignette centre X Offset.
  35309. */
  35310. /**
  35311. * Sets Vignette centre X Offset.
  35312. */
  35313. vignetteCentreX: number;
  35314. /**
  35315. * Gets Vignette centre Y Offset.
  35316. */
  35317. /**
  35318. * Sets Vignette centre Y Offset.
  35319. */
  35320. vignetteCentreY: number;
  35321. /**
  35322. * Gets Vignette weight or intensity of the vignette effect.
  35323. */
  35324. /**
  35325. * Sets Vignette weight or intensity of the vignette effect.
  35326. */
  35327. vignetteWeight: number;
  35328. /**
  35329. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35330. * if vignetteEnabled is set to true.
  35331. */
  35332. /**
  35333. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35334. * if vignetteEnabled is set to true.
  35335. */
  35336. vignetteColor: Color4;
  35337. /**
  35338. * Gets Camera field of view used by the Vignette effect.
  35339. */
  35340. /**
  35341. * Sets Camera field of view used by the Vignette effect.
  35342. */
  35343. vignetteCameraFov: number;
  35344. /**
  35345. * Gets the vignette blend mode allowing different kind of effect.
  35346. */
  35347. /**
  35348. * Sets the vignette blend mode allowing different kind of effect.
  35349. */
  35350. vignetteBlendMode: number;
  35351. /**
  35352. * Gets wether the vignette effect is enabled.
  35353. */
  35354. /**
  35355. * Sets wether the vignette effect is enabled.
  35356. */
  35357. vignetteEnabled: boolean;
  35358. private _fromLinearSpace;
  35359. /**
  35360. * Gets wether the input of the processing is in Gamma or Linear Space.
  35361. */
  35362. /**
  35363. * Sets wether the input of the processing is in Gamma or Linear Space.
  35364. */
  35365. fromLinearSpace: boolean;
  35366. /**
  35367. * Defines cache preventing GC.
  35368. */
  35369. private _defines;
  35370. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35371. /**
  35372. * "ImageProcessingPostProcess"
  35373. * @returns "ImageProcessingPostProcess"
  35374. */
  35375. getClassName(): string;
  35376. protected _updateParameters(): void;
  35377. dispose(camera?: Camera): void;
  35378. }
  35379. }
  35380. declare module BABYLON {
  35381. /**
  35382. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35383. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35384. * As an example, all you have to do is to create the post-process:
  35385. * var mb = new BABYLON.MotionBlurPostProcess(
  35386. * 'mb', // The name of the effect.
  35387. * scene, // The scene containing the objects to blur according to their velocity.
  35388. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35389. * camera // The camera to apply the render pass to.
  35390. * );
  35391. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35392. */
  35393. class MotionBlurPostProcess extends PostProcess {
  35394. /**
  35395. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35396. */
  35397. motionStrength: number;
  35398. /**
  35399. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35400. */
  35401. /**
  35402. * Sets the number of iterations to be used for motion blur quality
  35403. */
  35404. motionBlurSamples: number;
  35405. private _motionBlurSamples;
  35406. private _geometryBufferRenderer;
  35407. /**
  35408. * Creates a new instance MotionBlurPostProcess
  35409. * @param name The name of the effect.
  35410. * @param scene The scene containing the objects to blur according to their velocity.
  35411. * @param options The required width/height ratio to downsize to before computing the render pass.
  35412. * @param camera The camera to apply the render pass to.
  35413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35414. * @param engine The engine which the post process will be applied. (default: current engine)
  35415. * @param reusable If the post process can be reused on the same frame. (default: false)
  35416. * @param textureType Type of textures used when performing the post process. (default: 0)
  35417. * @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)
  35418. */
  35419. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35420. /**
  35421. * Disposes the post process.
  35422. * @param camera The camera to dispose the post process on.
  35423. */
  35424. dispose(camera?: Camera): void;
  35425. }
  35426. }
  35427. declare module BABYLON {
  35428. /**
  35429. * PassPostProcess which produces an output the same as it's input
  35430. */
  35431. class PassPostProcess extends PostProcess {
  35432. /**
  35433. * Creates the PassPostProcess
  35434. * @param name The name of the effect.
  35435. * @param options The required width/height ratio to downsize to before computing the render pass.
  35436. * @param camera The camera to apply the render pass to.
  35437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35438. * @param engine The engine which the post process will be applied. (default: current engine)
  35439. * @param reusable If the post process can be reused on the same frame. (default: false)
  35440. * @param textureType The type of texture to be used when performing the post processing.
  35441. * @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)
  35442. */
  35443. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35444. }
  35445. /**
  35446. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35447. */
  35448. class PassCubePostProcess extends PostProcess {
  35449. private _face;
  35450. /**
  35451. * Gets or sets the cube face to display.
  35452. * * 0 is +X
  35453. * * 1 is -X
  35454. * * 2 is +Y
  35455. * * 3 is -Y
  35456. * * 4 is +Z
  35457. * * 5 is -Z
  35458. */
  35459. face: number;
  35460. /**
  35461. * Creates the PassCubePostProcess
  35462. * @param name The name of the effect.
  35463. * @param options The required width/height ratio to downsize to before computing the render pass.
  35464. * @param camera The camera to apply the render pass to.
  35465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35466. * @param engine The engine which the post process will be applied. (default: current engine)
  35467. * @param reusable If the post process can be reused on the same frame. (default: false)
  35468. * @param textureType The type of texture to be used when performing the post processing.
  35469. * @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)
  35470. */
  35471. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35472. }
  35473. }
  35474. declare module BABYLON {
  35475. /**
  35476. * Size options for a post process
  35477. */
  35478. type PostProcessOptions = {
  35479. width: number;
  35480. height: number;
  35481. };
  35482. /**
  35483. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35484. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35485. */
  35486. class PostProcess {
  35487. /** Name of the PostProcess. */
  35488. name: string;
  35489. /**
  35490. * Width of the texture to apply the post process on
  35491. */
  35492. width: number;
  35493. /**
  35494. * Height of the texture to apply the post process on
  35495. */
  35496. height: number;
  35497. /**
  35498. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35499. * @hidden
  35500. */
  35501. _outputTexture: Nullable<InternalTexture>;
  35502. /**
  35503. * Sampling mode used by the shader
  35504. * See https://doc.babylonjs.com/classes/3.1/texture
  35505. */
  35506. renderTargetSamplingMode: number;
  35507. /**
  35508. * Clear color to use when screen clearing
  35509. */
  35510. clearColor: Color4;
  35511. /**
  35512. * If the buffer needs to be cleared before applying the post process. (default: true)
  35513. * Should be set to false if shader will overwrite all previous pixels.
  35514. */
  35515. autoClear: boolean;
  35516. /**
  35517. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35518. */
  35519. alphaMode: number;
  35520. /**
  35521. * Sets the setAlphaBlendConstants of the babylon engine
  35522. */
  35523. alphaConstants: Color4;
  35524. /**
  35525. * Animations to be used for the post processing
  35526. */
  35527. animations: Animation[];
  35528. /**
  35529. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35530. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35531. */
  35532. enablePixelPerfectMode: boolean;
  35533. /**
  35534. * Force the postprocess to be applied without taking in account viewport
  35535. */
  35536. forceFullscreenViewport: boolean;
  35537. /**
  35538. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35539. *
  35540. * | Value | Type | Description |
  35541. * | ----- | ----------------------------------- | ----------- |
  35542. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35543. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35544. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35545. *
  35546. */
  35547. scaleMode: number;
  35548. /**
  35549. * Force textures to be a power of two (default: false)
  35550. */
  35551. alwaysForcePOT: boolean;
  35552. private _samples;
  35553. /**
  35554. * Number of sample textures (default: 1)
  35555. */
  35556. samples: number;
  35557. /**
  35558. * Modify the scale of the post process to be the same as the viewport (default: false)
  35559. */
  35560. adaptScaleToCurrentViewport: boolean;
  35561. private _camera;
  35562. private _scene;
  35563. private _engine;
  35564. private _options;
  35565. private _reusable;
  35566. private _textureType;
  35567. /**
  35568. * Smart array of input and output textures for the post process.
  35569. * @hidden
  35570. */
  35571. _textures: SmartArray<InternalTexture>;
  35572. /**
  35573. * The index in _textures that corresponds to the output texture.
  35574. * @hidden
  35575. */
  35576. _currentRenderTextureInd: number;
  35577. private _effect;
  35578. private _samplers;
  35579. private _fragmentUrl;
  35580. private _vertexUrl;
  35581. private _parameters;
  35582. private _scaleRatio;
  35583. protected _indexParameters: any;
  35584. private _shareOutputWithPostProcess;
  35585. private _texelSize;
  35586. private _forcedOutputTexture;
  35587. /**
  35588. * An event triggered when the postprocess is activated.
  35589. */
  35590. onActivateObservable: Observable<Camera>;
  35591. private _onActivateObserver;
  35592. /**
  35593. * A function that is added to the onActivateObservable
  35594. */
  35595. onActivate: Nullable<(camera: Camera) => void>;
  35596. /**
  35597. * An event triggered when the postprocess changes its size.
  35598. */
  35599. onSizeChangedObservable: Observable<PostProcess>;
  35600. private _onSizeChangedObserver;
  35601. /**
  35602. * A function that is added to the onSizeChangedObservable
  35603. */
  35604. onSizeChanged: (postProcess: PostProcess) => void;
  35605. /**
  35606. * An event triggered when the postprocess applies its effect.
  35607. */
  35608. onApplyObservable: Observable<Effect>;
  35609. private _onApplyObserver;
  35610. /**
  35611. * A function that is added to the onApplyObservable
  35612. */
  35613. onApply: (effect: Effect) => void;
  35614. /**
  35615. * An event triggered before rendering the postprocess
  35616. */
  35617. onBeforeRenderObservable: Observable<Effect>;
  35618. private _onBeforeRenderObserver;
  35619. /**
  35620. * A function that is added to the onBeforeRenderObservable
  35621. */
  35622. onBeforeRender: (effect: Effect) => void;
  35623. /**
  35624. * An event triggered after rendering the postprocess
  35625. */
  35626. onAfterRenderObservable: Observable<Effect>;
  35627. private _onAfterRenderObserver;
  35628. /**
  35629. * A function that is added to the onAfterRenderObservable
  35630. */
  35631. onAfterRender: (efect: Effect) => void;
  35632. /**
  35633. * 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
  35634. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35635. */
  35636. inputTexture: InternalTexture;
  35637. /**
  35638. * Gets the camera which post process is applied to.
  35639. * @returns The camera the post process is applied to.
  35640. */
  35641. getCamera(): Camera;
  35642. /**
  35643. * Gets the texel size of the postprocess.
  35644. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35645. */
  35646. readonly texelSize: Vector2;
  35647. /**
  35648. * Creates a new instance PostProcess
  35649. * @param name The name of the PostProcess.
  35650. * @param fragmentUrl The url of the fragment shader to be used.
  35651. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35652. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35653. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35654. * @param camera The camera to apply the render pass to.
  35655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35656. * @param engine The engine which the post process will be applied. (default: current engine)
  35657. * @param reusable If the post process can be reused on the same frame. (default: false)
  35658. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35659. * @param textureType Type of textures used when performing the post process. (default: 0)
  35660. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35661. * @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
  35662. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35663. */
  35664. constructor(
  35665. /** Name of the PostProcess. */
  35666. 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);
  35667. /**
  35668. * Gets the engine which this post process belongs to.
  35669. * @returns The engine the post process was enabled with.
  35670. */
  35671. getEngine(): Engine;
  35672. /**
  35673. * The effect that is created when initializing the post process.
  35674. * @returns The created effect corrisponding the the postprocess.
  35675. */
  35676. getEffect(): Effect;
  35677. /**
  35678. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35679. * @param postProcess The post process to share the output with.
  35680. * @returns This post process.
  35681. */
  35682. shareOutputWith(postProcess: PostProcess): PostProcess;
  35683. /**
  35684. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35685. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35686. */
  35687. useOwnOutput(): void;
  35688. /**
  35689. * Updates the effect with the current post process compile time values and recompiles the shader.
  35690. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35691. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35692. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35693. * @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
  35694. * @param onCompiled Called when the shader has been compiled.
  35695. * @param onError Called if there is an error when compiling a shader.
  35696. */
  35697. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35698. /**
  35699. * The post process is reusable if it can be used multiple times within one frame.
  35700. * @returns If the post process is reusable
  35701. */
  35702. isReusable(): boolean;
  35703. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35704. markTextureDirty(): void;
  35705. /**
  35706. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35707. * 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.
  35708. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35709. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35710. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35711. * @returns The target texture that was bound to be written to.
  35712. */
  35713. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35714. /**
  35715. * If the post process is supported.
  35716. */
  35717. readonly isSupported: boolean;
  35718. /**
  35719. * The aspect ratio of the output texture.
  35720. */
  35721. readonly aspectRatio: number;
  35722. /**
  35723. * Get a value indicating if the post-process is ready to be used
  35724. * @returns true if the post-process is ready (shader is compiled)
  35725. */
  35726. isReady(): boolean;
  35727. /**
  35728. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35729. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35730. */
  35731. apply(): Nullable<Effect>;
  35732. private _disposeTextures;
  35733. /**
  35734. * Disposes the post process.
  35735. * @param camera The camera to dispose the post process on.
  35736. */
  35737. dispose(camera?: Camera): void;
  35738. }
  35739. }
  35740. declare module BABYLON {
  35741. /**
  35742. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35743. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35744. */
  35745. class PostProcessManager {
  35746. private _scene;
  35747. private _indexBuffer;
  35748. private _vertexBuffers;
  35749. /**
  35750. * Creates a new instance PostProcess
  35751. * @param scene The scene that the post process is associated with.
  35752. */
  35753. constructor(scene: Scene);
  35754. private _prepareBuffers;
  35755. private _buildIndexBuffer;
  35756. /**
  35757. * Rebuilds the vertex buffers of the manager.
  35758. * @hidden
  35759. */
  35760. _rebuild(): void;
  35761. /**
  35762. * Prepares a frame to be run through a post process.
  35763. * @param sourceTexture The input texture to the post procesess. (default: null)
  35764. * @param postProcesses An array of post processes to be run. (default: null)
  35765. * @returns True if the post processes were able to be run.
  35766. * @hidden
  35767. */
  35768. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35769. /**
  35770. * Manually render a set of post processes to a texture.
  35771. * @param postProcesses An array of post processes to be run.
  35772. * @param targetTexture The target texture to render to.
  35773. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35774. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35775. * @param lodLevel defines which lod of the texture to render to
  35776. */
  35777. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35778. /**
  35779. * Finalize the result of the output of the postprocesses.
  35780. * @param doNotPresent If true the result will not be displayed to the screen.
  35781. * @param targetTexture The target texture to render to.
  35782. * @param faceIndex The index of the face to bind the target texture to.
  35783. * @param postProcesses The array of post processes to render.
  35784. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35785. * @hidden
  35786. */
  35787. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35788. /**
  35789. * Disposes of the post process manager.
  35790. */
  35791. dispose(): void;
  35792. }
  35793. }
  35794. declare module BABYLON {
  35795. /**
  35796. * Post process which applies a refractin texture
  35797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35798. */
  35799. class RefractionPostProcess extends PostProcess {
  35800. /** the base color of the refraction (used to taint the rendering) */
  35801. color: Color3;
  35802. /** simulated refraction depth */
  35803. depth: number;
  35804. /** the coefficient of the base color (0 to remove base color tainting) */
  35805. colorLevel: number;
  35806. private _refTexture;
  35807. private _ownRefractionTexture;
  35808. /**
  35809. * Gets or sets the refraction texture
  35810. * Please note that you are responsible for disposing the texture if you set it manually
  35811. */
  35812. refractionTexture: Texture;
  35813. /**
  35814. * Initializes the RefractionPostProcess
  35815. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35816. * @param name The name of the effect.
  35817. * @param refractionTextureUrl Url of the refraction texture to use
  35818. * @param color the base color of the refraction (used to taint the rendering)
  35819. * @param depth simulated refraction depth
  35820. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35821. * @param camera The camera to apply the render pass to.
  35822. * @param options The required width/height ratio to downsize to before computing the render pass.
  35823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35824. * @param engine The engine which the post process will be applied. (default: current engine)
  35825. * @param reusable If the post process can be reused on the same frame. (default: false)
  35826. */
  35827. constructor(name: string, refractionTextureUrl: string,
  35828. /** the base color of the refraction (used to taint the rendering) */
  35829. color: Color3,
  35830. /** simulated refraction depth */
  35831. depth: number,
  35832. /** the coefficient of the base color (0 to remove base color tainting) */
  35833. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35834. /**
  35835. * Disposes of the post process
  35836. * @param camera Camera to dispose post process on
  35837. */
  35838. dispose(camera: Camera): void;
  35839. }
  35840. }
  35841. declare module BABYLON {
  35842. /**
  35843. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35844. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35845. */
  35846. class SharpenPostProcess extends PostProcess {
  35847. /**
  35848. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35849. */
  35850. colorAmount: number;
  35851. /**
  35852. * How much sharpness should be applied (default: 0.3)
  35853. */
  35854. edgeAmount: number;
  35855. /**
  35856. * Creates a new instance ConvolutionPostProcess
  35857. * @param name The name of the effect.
  35858. * @param options The required width/height ratio to downsize to before computing the render pass.
  35859. * @param camera The camera to apply the render pass to.
  35860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35861. * @param engine The engine which the post process will be applied. (default: current engine)
  35862. * @param reusable If the post process can be reused on the same frame. (default: false)
  35863. * @param textureType Type of textures used when performing the post process. (default: 0)
  35864. * @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)
  35865. */
  35866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35867. }
  35868. }
  35869. declare module BABYLON {
  35870. /**
  35871. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35872. */
  35873. class StereoscopicInterlacePostProcess extends PostProcess {
  35874. private _stepSize;
  35875. private _passedProcess;
  35876. /**
  35877. * Initializes a StereoscopicInterlacePostProcess
  35878. * @param name The name of the effect.
  35879. * @param rigCameras The rig cameras to be appled to the post process
  35880. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35882. * @param engine The engine which the post process will be applied. (default: current engine)
  35883. * @param reusable If the post process can be reused on the same frame. (default: false)
  35884. */
  35885. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35886. }
  35887. }
  35888. declare module BABYLON {
  35889. /** Defines operator used for tonemapping */
  35890. enum TonemappingOperator {
  35891. /** Hable */
  35892. Hable = 0,
  35893. /** Reinhard */
  35894. Reinhard = 1,
  35895. /** HejiDawson */
  35896. HejiDawson = 2,
  35897. /** Photographic */
  35898. Photographic = 3
  35899. }
  35900. /**
  35901. * Defines a post process to apply tone mapping
  35902. */
  35903. class TonemapPostProcess extends PostProcess {
  35904. private _operator;
  35905. /** Defines the required exposure adjustement */
  35906. exposureAdjustment: number;
  35907. /**
  35908. * Creates a new TonemapPostProcess
  35909. * @param name defines the name of the postprocess
  35910. * @param _operator defines the operator to use
  35911. * @param exposureAdjustment defines the required exposure adjustement
  35912. * @param camera defines the camera to use (can be null)
  35913. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35914. * @param engine defines the hosting engine (can be ignore if camera is set)
  35915. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35916. */
  35917. constructor(name: string, _operator: TonemappingOperator,
  35918. /** Defines the required exposure adjustement */
  35919. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35920. }
  35921. }
  35922. declare module BABYLON {
  35923. /**
  35924. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35925. */
  35926. class VolumetricLightScatteringPostProcess extends PostProcess {
  35927. private _volumetricLightScatteringPass;
  35928. private _volumetricLightScatteringRTT;
  35929. private _viewPort;
  35930. private _screenCoordinates;
  35931. private _cachedDefines;
  35932. /**
  35933. * If not undefined, the mesh position is computed from the attached node position
  35934. */
  35935. attachedNode: {
  35936. position: Vector3;
  35937. };
  35938. /**
  35939. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35940. */
  35941. customMeshPosition: Vector3;
  35942. /**
  35943. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35944. */
  35945. useCustomMeshPosition: boolean;
  35946. /**
  35947. * If the post-process should inverse the light scattering direction
  35948. */
  35949. invert: boolean;
  35950. /**
  35951. * The internal mesh used by the post-process
  35952. */
  35953. mesh: Mesh;
  35954. /**
  35955. * @hidden
  35956. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35957. */
  35958. useDiffuseColor: boolean;
  35959. /**
  35960. * Array containing the excluded meshes not rendered in the internal pass
  35961. */
  35962. excludedMeshes: AbstractMesh[];
  35963. /**
  35964. * Controls the overall intensity of the post-process
  35965. */
  35966. exposure: number;
  35967. /**
  35968. * Dissipates each sample's contribution in range [0, 1]
  35969. */
  35970. decay: number;
  35971. /**
  35972. * Controls the overall intensity of each sample
  35973. */
  35974. weight: number;
  35975. /**
  35976. * Controls the density of each sample
  35977. */
  35978. density: number;
  35979. /**
  35980. * @constructor
  35981. * @param name The post-process name
  35982. * @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)
  35983. * @param camera The camera that the post-process will be attached to
  35984. * @param mesh The mesh used to create the light scattering
  35985. * @param samples The post-process quality, default 100
  35986. * @param samplingModeThe post-process filtering mode
  35987. * @param engine The babylon engine
  35988. * @param reusable If the post-process is reusable
  35989. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35990. */
  35991. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35992. /**
  35993. * Returns the string "VolumetricLightScatteringPostProcess"
  35994. * @returns "VolumetricLightScatteringPostProcess"
  35995. */
  35996. getClassName(): string;
  35997. private _isReady;
  35998. /**
  35999. * Sets the new light position for light scattering effect
  36000. * @param position The new custom light position
  36001. */
  36002. setCustomMeshPosition(position: Vector3): void;
  36003. /**
  36004. * Returns the light position for light scattering effect
  36005. * @return Vector3 The custom light position
  36006. */
  36007. getCustomMeshPosition(): Vector3;
  36008. /**
  36009. * Disposes the internal assets and detaches the post-process from the camera
  36010. */
  36011. dispose(camera: Camera): void;
  36012. /**
  36013. * Returns the render target texture used by the post-process
  36014. * @return the render target texture used by the post-process
  36015. */
  36016. getPass(): RenderTargetTexture;
  36017. private _meshExcluded;
  36018. private _createPass;
  36019. private _updateMeshScreenCoordinates;
  36020. /**
  36021. * Creates a default mesh for the Volumeric Light Scattering post-process
  36022. * @param name The mesh name
  36023. * @param scene The scene where to create the mesh
  36024. * @return the default mesh
  36025. */
  36026. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36027. }
  36028. }
  36029. declare module BABYLON {
  36030. /**
  36031. * VRDistortionCorrectionPostProcess used for mobile VR
  36032. */
  36033. class VRDistortionCorrectionPostProcess extends PostProcess {
  36034. private _isRightEye;
  36035. private _distortionFactors;
  36036. private _postProcessScaleFactor;
  36037. private _lensCenterOffset;
  36038. private _scaleIn;
  36039. private _scaleFactor;
  36040. private _lensCenter;
  36041. /**
  36042. * Initializes the VRDistortionCorrectionPostProcess
  36043. * @param name The name of the effect.
  36044. * @param camera The camera to apply the render pass to.
  36045. * @param isRightEye If this is for the right eye distortion
  36046. * @param vrMetrics All the required metrics for the VR camera
  36047. */
  36048. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36049. }
  36050. }
  36051. declare module BABYLON {
  36052. interface Scene {
  36053. /** @hidden (Backing field) */
  36054. _boundingBoxRenderer: BoundingBoxRenderer;
  36055. /** @hidden (Backing field) */
  36056. _forceShowBoundingBoxes: boolean;
  36057. /**
  36058. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  36059. */
  36060. forceShowBoundingBoxes: boolean;
  36061. /**
  36062. * Gets the bounding box renderer associated with the scene
  36063. * @returns a BoundingBoxRenderer
  36064. */
  36065. getBoundingBoxRenderer(): BoundingBoxRenderer;
  36066. }
  36067. interface AbstractMesh {
  36068. /** @hidden (Backing field) */
  36069. _showBoundingBox: boolean;
  36070. /**
  36071. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  36072. */
  36073. showBoundingBox: boolean;
  36074. }
  36075. /**
  36076. * Component responsible of rendering the bounding box of the meshes in a scene.
  36077. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  36078. */
  36079. class BoundingBoxRenderer implements ISceneComponent {
  36080. /**
  36081. * The component name helpfull to identify the component in the list of scene components.
  36082. */
  36083. readonly name: string;
  36084. /**
  36085. * The scene the component belongs to.
  36086. */
  36087. scene: Scene;
  36088. /**
  36089. * Color of the bounding box lines placed in front of an object
  36090. */
  36091. frontColor: Color3;
  36092. /**
  36093. * Color of the bounding box lines placed behind an object
  36094. */
  36095. backColor: Color3;
  36096. /**
  36097. * Defines if the renderer should show the back lines or not
  36098. */
  36099. showBackLines: boolean;
  36100. /**
  36101. * @hidden
  36102. */
  36103. renderList: SmartArray<BoundingBox>;
  36104. private _colorShader;
  36105. private _vertexBuffers;
  36106. private _indexBuffer;
  36107. /**
  36108. * Instantiates a new bounding box renderer in a scene.
  36109. * @param scene the scene the renderer renders in
  36110. */
  36111. constructor(scene: Scene);
  36112. /**
  36113. * Registers the component in a given scene
  36114. */
  36115. register(): void;
  36116. private _evaluateSubMesh;
  36117. private _activeMesh;
  36118. private _prepareRessources;
  36119. private _createIndexBuffer;
  36120. /**
  36121. * Rebuilds the elements related to this component in case of
  36122. * context lost for instance.
  36123. */
  36124. rebuild(): void;
  36125. /**
  36126. * @hidden
  36127. */
  36128. reset(): void;
  36129. /**
  36130. * Render the bounding boxes of a specific rendering group
  36131. * @param renderingGroupId defines the rendering group to render
  36132. */
  36133. render(renderingGroupId: number): void;
  36134. /**
  36135. * In case of occlusion queries, we can render the occlusion bounding box through this method
  36136. * @param mesh Define the mesh to render the occlusion bounding box for
  36137. */
  36138. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  36139. /**
  36140. * Dispose and release the resources attached to this renderer.
  36141. */
  36142. dispose(): void;
  36143. }
  36144. }
  36145. declare module BABYLON {
  36146. /**
  36147. * This represents a depth renderer in Babylon.
  36148. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  36149. */
  36150. class DepthRenderer {
  36151. private _scene;
  36152. private _depthMap;
  36153. private _effect;
  36154. private _cachedDefines;
  36155. private _camera;
  36156. /**
  36157. * Specifiess that the depth renderer will only be used within
  36158. * the camera it is created for.
  36159. * This can help forcing its rendering during the camera processing.
  36160. */
  36161. useOnlyInActiveCamera: boolean;
  36162. /**
  36163. * Instantiates a depth renderer
  36164. * @param scene The scene the renderer belongs to
  36165. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  36166. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  36167. */
  36168. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  36169. /**
  36170. * Creates the depth rendering effect and checks if the effect is ready.
  36171. * @param subMesh The submesh to be used to render the depth map of
  36172. * @param useInstances If multiple world instances should be used
  36173. * @returns if the depth renderer is ready to render the depth map
  36174. */
  36175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36176. /**
  36177. * Gets the texture which the depth map will be written to.
  36178. * @returns The depth map texture
  36179. */
  36180. getDepthMap(): RenderTargetTexture;
  36181. /**
  36182. * Disposes of the depth renderer.
  36183. */
  36184. dispose(): void;
  36185. }
  36186. }
  36187. declare module BABYLON {
  36188. interface Scene {
  36189. /** @hidden (Backing field) */
  36190. _depthRenderer: {
  36191. [id: string]: DepthRenderer;
  36192. };
  36193. /**
  36194. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  36195. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  36196. * @returns the created depth renderer
  36197. */
  36198. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  36199. /**
  36200. * Disables a depth renderer for a given camera
  36201. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  36202. */
  36203. disableDepthRenderer(camera?: Nullable<Camera>): void;
  36204. }
  36205. /**
  36206. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  36207. * in several rendering techniques.
  36208. */
  36209. class DepthRendererSceneComponent implements ISceneComponent {
  36210. /**
  36211. * The component name helpfull to identify the component in the list of scene components.
  36212. */
  36213. readonly name: string;
  36214. /**
  36215. * The scene the component belongs to.
  36216. */
  36217. scene: Scene;
  36218. /**
  36219. * Creates a new instance of the component for the given scene
  36220. * @param scene Defines the scene to register the component in
  36221. */
  36222. constructor(scene: Scene);
  36223. /**
  36224. * Registers the component in a given scene
  36225. */
  36226. register(): void;
  36227. /**
  36228. * Rebuilds the elements related to this component in case of
  36229. * context lost for instance.
  36230. */
  36231. rebuild(): void;
  36232. /**
  36233. * Disposes the component and the associated ressources
  36234. */
  36235. dispose(): void;
  36236. private _gatherRenderTargets;
  36237. private _gatherActiveCameraRenderTargets;
  36238. }
  36239. }
  36240. declare module BABYLON {
  36241. interface AbstractMesh {
  36242. /**
  36243. * Disables the mesh edge rendering mode
  36244. * @returns the currentAbstractMesh
  36245. */
  36246. disableEdgesRendering(): AbstractMesh;
  36247. /**
  36248. * Enables the edge rendering mode on the mesh.
  36249. * This mode makes the mesh edges visible
  36250. * @param epsilon defines the maximal distance between two angles to detect a face
  36251. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36252. * @returns the currentAbstractMesh
  36253. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36254. */
  36255. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36256. /**
  36257. * Gets the edgesRenderer associated with the mesh
  36258. */
  36259. edgesRenderer: Nullable<EdgesRenderer>;
  36260. }
  36261. interface LinesMesh {
  36262. /**
  36263. * Enables the edge rendering mode on the mesh.
  36264. * This mode makes the mesh edges visible
  36265. * @param epsilon defines the maximal distance between two angles to detect a face
  36266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36267. * @returns the currentAbstractMesh
  36268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36269. */
  36270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36271. }
  36272. interface InstancedLinesMesh {
  36273. /**
  36274. * Enables the edge rendering mode on the mesh.
  36275. * This mode makes the mesh edges visible
  36276. * @param epsilon defines the maximal distance between two angles to detect a face
  36277. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36278. * @returns the current InstancedLinesMesh
  36279. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36280. */
  36281. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  36282. }
  36283. /**
  36284. * Defines the minimum contract an Edges renderer should follow.
  36285. */
  36286. interface IEdgesRenderer extends IDisposable {
  36287. /**
  36288. * Gets or sets a boolean indicating if the edgesRenderer is active
  36289. */
  36290. isEnabled: boolean;
  36291. /**
  36292. * Renders the edges of the attached mesh,
  36293. */
  36294. render(): void;
  36295. /**
  36296. * Checks wether or not the edges renderer is ready to render.
  36297. * @return true if ready, otherwise false.
  36298. */
  36299. isReady(): boolean;
  36300. }
  36301. /**
  36302. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  36303. */
  36304. class EdgesRenderer implements IEdgesRenderer {
  36305. /**
  36306. * Define the size of the edges with an orthographic camera
  36307. */
  36308. edgesWidthScalerForOrthographic: number;
  36309. /**
  36310. * Define the size of the edges with a perspective camera
  36311. */
  36312. edgesWidthScalerForPerspective: number;
  36313. protected _source: AbstractMesh;
  36314. protected _linesPositions: number[];
  36315. protected _linesNormals: number[];
  36316. protected _linesIndices: number[];
  36317. protected _epsilon: number;
  36318. protected _indicesCount: number;
  36319. protected _lineShader: ShaderMaterial;
  36320. protected _ib: WebGLBuffer;
  36321. protected _buffers: {
  36322. [key: string]: Nullable<VertexBuffer>;
  36323. };
  36324. protected _checkVerticesInsteadOfIndices: boolean;
  36325. private _meshRebuildObserver;
  36326. private _meshDisposeObserver;
  36327. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  36328. isEnabled: boolean;
  36329. /**
  36330. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36331. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36332. * @param source Mesh used to create edges
  36333. * @param epsilon sum of angles in adjacency to check for edge
  36334. * @param checkVerticesInsteadOfIndices
  36335. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36336. */
  36337. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36338. protected _prepareRessources(): void;
  36339. /** @hidden */
  36340. _rebuild(): void;
  36341. /**
  36342. * Releases the required resources for the edges renderer
  36343. */
  36344. dispose(): void;
  36345. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36346. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36347. /**
  36348. * Checks if the pair of p0 and p1 is en edge
  36349. * @param faceIndex
  36350. * @param edge
  36351. * @param faceNormals
  36352. * @param p0
  36353. * @param p1
  36354. * @private
  36355. */
  36356. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36357. /**
  36358. * push line into the position, normal and index buffer
  36359. * @protected
  36360. */
  36361. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36362. /**
  36363. * Generates lines edges from adjacencjes
  36364. * @private
  36365. */
  36366. _generateEdgesLines(): void;
  36367. /**
  36368. * Checks wether or not the edges renderer is ready to render.
  36369. * @return true if ready, otherwise false.
  36370. */
  36371. isReady(): boolean;
  36372. /**
  36373. * Renders the edges of the attached mesh,
  36374. */
  36375. render(): void;
  36376. }
  36377. }
  36378. declare module BABYLON {
  36379. /**
  36380. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36381. */
  36382. class GeometryBufferRenderer {
  36383. /**
  36384. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36385. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36386. */
  36387. static readonly POSITION_TEXTURE_TYPE: number;
  36388. /**
  36389. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36390. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36391. */
  36392. static readonly VELOCITY_TEXTURE_TYPE: number;
  36393. /**
  36394. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36395. * in order to compute objects velocities when enableVelocity is set to "true"
  36396. * @hidden
  36397. */
  36398. _previousTransformationMatrices: {
  36399. [index: number]: Matrix;
  36400. };
  36401. private _scene;
  36402. private _multiRenderTarget;
  36403. private _ratio;
  36404. private _enablePosition;
  36405. private _enableVelocity;
  36406. private _positionIndex;
  36407. private _velocityIndex;
  36408. protected _effect: Effect;
  36409. protected _cachedDefines: string;
  36410. /**
  36411. * Set the render list (meshes to be rendered) used in the G buffer.
  36412. */
  36413. renderList: Mesh[];
  36414. /**
  36415. * Gets wether or not G buffer are supported by the running hardware.
  36416. * This requires draw buffer supports
  36417. */
  36418. readonly isSupported: boolean;
  36419. /**
  36420. * Returns the index of the given texture type in the G-Buffer textures array
  36421. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36422. * @returns the index of the given texture type in the G-Buffer textures array
  36423. */
  36424. getTextureIndex(textureType: number): number;
  36425. /**
  36426. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36427. */
  36428. /**
  36429. * Sets whether or not objects positions are enabled for the G buffer.
  36430. */
  36431. enablePosition: boolean;
  36432. /**
  36433. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36434. */
  36435. /**
  36436. * Sets wether or not objects velocities are enabled for the G buffer.
  36437. */
  36438. enableVelocity: boolean;
  36439. /**
  36440. * Gets the scene associated with the buffer.
  36441. */
  36442. readonly scene: Scene;
  36443. /**
  36444. * Gets the ratio used by the buffer during its creation.
  36445. * How big is the buffer related to the main canvas.
  36446. */
  36447. readonly ratio: number;
  36448. /**
  36449. * Creates a new G Buffer for the scene
  36450. * @param scene The scene the buffer belongs to
  36451. * @param ratio How big is the buffer related to the main canvas.
  36452. */
  36453. constructor(scene: Scene, ratio?: number);
  36454. /**
  36455. * Checks wether everything is ready to render a submesh to the G buffer.
  36456. * @param subMesh the submesh to check readiness for
  36457. * @param useInstances is the mesh drawn using instance or not
  36458. * @returns true if ready otherwise false
  36459. */
  36460. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36461. /**
  36462. * Gets the current underlying G Buffer.
  36463. * @returns the buffer
  36464. */
  36465. getGBuffer(): MultiRenderTarget;
  36466. /**
  36467. * Gets the number of samples used to render the buffer (anti aliasing).
  36468. */
  36469. /**
  36470. * Sets the number of samples used to render the buffer (anti aliasing).
  36471. */
  36472. samples: number;
  36473. /**
  36474. * Disposes the renderer and frees up associated resources.
  36475. */
  36476. dispose(): void;
  36477. protected _createRenderTargets(): void;
  36478. }
  36479. }
  36480. declare module BABYLON {
  36481. interface Scene {
  36482. /** @hidden (Backing field) */
  36483. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36484. /**
  36485. * Gets or Sets the current geometry buffer associated to the scene.
  36486. */
  36487. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36488. /**
  36489. * Enables a GeometryBufferRender and associates it with the scene
  36490. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36491. * @returns the GeometryBufferRenderer
  36492. */
  36493. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36494. /**
  36495. * Disables the GeometryBufferRender associated with the scene
  36496. */
  36497. disableGeometryBufferRenderer(): void;
  36498. }
  36499. /**
  36500. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36501. * in several rendering techniques.
  36502. */
  36503. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36504. /**
  36505. * The component name helpful to identify the component in the list of scene components.
  36506. */
  36507. readonly name: string;
  36508. /**
  36509. * The scene the component belongs to.
  36510. */
  36511. scene: Scene;
  36512. /**
  36513. * Creates a new instance of the component for the given scene
  36514. * @param scene Defines the scene to register the component in
  36515. */
  36516. constructor(scene: Scene);
  36517. /**
  36518. * Registers the component in a given scene
  36519. */
  36520. register(): void;
  36521. /**
  36522. * Rebuilds the elements related to this component in case of
  36523. * context lost for instance.
  36524. */
  36525. rebuild(): void;
  36526. /**
  36527. * Disposes the component and the associated ressources
  36528. */
  36529. dispose(): void;
  36530. private _gatherRenderTargets;
  36531. }
  36532. }
  36533. declare module BABYLON {
  36534. /**
  36535. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36536. */
  36537. class LineEdgesRenderer extends EdgesRenderer {
  36538. /**
  36539. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36540. * @param source LineMesh used to generate edges
  36541. * @param epsilon not important (specified angle for edge detection)
  36542. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36543. */
  36544. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36545. /**
  36546. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36547. */
  36548. _generateEdgesLines(): void;
  36549. }
  36550. }
  36551. declare module BABYLON {
  36552. interface Scene {
  36553. /** @hidden */
  36554. _outlineRenderer: OutlineRenderer;
  36555. /**
  36556. * Gets the outline renderer associated with the scene
  36557. * @returns a OutlineRenderer
  36558. */
  36559. getOutlineRenderer(): OutlineRenderer;
  36560. }
  36561. interface AbstractMesh {
  36562. /** @hidden (Backing field) */
  36563. _renderOutline: boolean;
  36564. /**
  36565. * Gets or sets a boolean indicating if the outline must be rendered as well
  36566. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36567. */
  36568. renderOutline: boolean;
  36569. /** @hidden (Backing field) */
  36570. _renderOverlay: boolean;
  36571. /**
  36572. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36573. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36574. */
  36575. renderOverlay: boolean;
  36576. }
  36577. /**
  36578. * This class is responsible to draw bothe outline/overlay of meshes.
  36579. * It should not be used directly but through the available method on mesh.
  36580. */
  36581. class OutlineRenderer implements ISceneComponent {
  36582. /**
  36583. * The name of the component. Each component must have a unique name.
  36584. */
  36585. name: string;
  36586. /**
  36587. * The scene the component belongs to.
  36588. */
  36589. scene: Scene;
  36590. /**
  36591. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36592. */
  36593. zOffset: number;
  36594. private _engine;
  36595. private _effect;
  36596. private _cachedDefines;
  36597. private _savedDepthWrite;
  36598. /**
  36599. * Instantiates a new outline renderer. (There could be only one per scene).
  36600. * @param scene Defines the scene it belongs to
  36601. */
  36602. constructor(scene: Scene);
  36603. /**
  36604. * Register the component to one instance of a scene.
  36605. */
  36606. register(): void;
  36607. /**
  36608. * Rebuilds the elements related to this component in case of
  36609. * context lost for instance.
  36610. */
  36611. rebuild(): void;
  36612. /**
  36613. * Disposes the component and the associated ressources.
  36614. */
  36615. dispose(): void;
  36616. /**
  36617. * Renders the outline in the canvas.
  36618. * @param subMesh Defines the sumesh to render
  36619. * @param batch Defines the batch of meshes in case of instances
  36620. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36621. */
  36622. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36623. /**
  36624. * Returns whether or not the outline renderer is ready for a given submesh.
  36625. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36626. * @param subMesh Defines the submesh to check readyness for
  36627. * @param useInstances Defines wheter wee are trying to render instances or not
  36628. * @returns true if ready otherwise false
  36629. */
  36630. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36631. private _beforeRenderingMesh;
  36632. private _afterRenderingMesh;
  36633. }
  36634. }
  36635. declare module BABYLON {
  36636. /**
  36637. * This represents the object necessary to create a rendering group.
  36638. * This is exclusively used and created by the rendering manager.
  36639. * To modify the behavior, you use the available helpers in your scene or meshes.
  36640. * @hidden
  36641. */
  36642. class RenderingGroup {
  36643. index: number;
  36644. private _scene;
  36645. private _opaqueSubMeshes;
  36646. private _transparentSubMeshes;
  36647. private _alphaTestSubMeshes;
  36648. private _depthOnlySubMeshes;
  36649. private _particleSystems;
  36650. private _spriteManagers;
  36651. private _opaqueSortCompareFn;
  36652. private _alphaTestSortCompareFn;
  36653. private _transparentSortCompareFn;
  36654. private _renderOpaque;
  36655. private _renderAlphaTest;
  36656. private _renderTransparent;
  36657. private _edgesRenderers;
  36658. onBeforeTransparentRendering: () => void;
  36659. /**
  36660. * Set the opaque sort comparison function.
  36661. * If null the sub meshes will be render in the order they were created
  36662. */
  36663. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36664. /**
  36665. * Set the alpha test sort comparison function.
  36666. * If null the sub meshes will be render in the order they were created
  36667. */
  36668. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36669. /**
  36670. * Set the transparent sort comparison function.
  36671. * If null the sub meshes will be render in the order they were created
  36672. */
  36673. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36674. /**
  36675. * Creates a new rendering group.
  36676. * @param index The rendering group index
  36677. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36678. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36679. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36680. */
  36681. 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>);
  36682. /**
  36683. * Render all the sub meshes contained in the group.
  36684. * @param customRenderFunction Used to override the default render behaviour of the group.
  36685. * @returns true if rendered some submeshes.
  36686. */
  36687. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36688. /**
  36689. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36690. * @param subMeshes The submeshes to render
  36691. */
  36692. private renderOpaqueSorted;
  36693. /**
  36694. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36695. * @param subMeshes The submeshes to render
  36696. */
  36697. private renderAlphaTestSorted;
  36698. /**
  36699. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36700. * @param subMeshes The submeshes to render
  36701. */
  36702. private renderTransparentSorted;
  36703. /**
  36704. * Renders the submeshes in a specified order.
  36705. * @param subMeshes The submeshes to sort before render
  36706. * @param sortCompareFn The comparison function use to sort
  36707. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36708. * @param transparent Specifies to activate blending if true
  36709. */
  36710. private static renderSorted;
  36711. /**
  36712. * Renders the submeshes in the order they were dispatched (no sort applied).
  36713. * @param subMeshes The submeshes to render
  36714. */
  36715. private static renderUnsorted;
  36716. /**
  36717. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36718. * are rendered back to front if in the same alpha index.
  36719. *
  36720. * @param a The first submesh
  36721. * @param b The second submesh
  36722. * @returns The result of the comparison
  36723. */
  36724. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36725. /**
  36726. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36727. * are rendered back to front.
  36728. *
  36729. * @param a The first submesh
  36730. * @param b The second submesh
  36731. * @returns The result of the comparison
  36732. */
  36733. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36734. /**
  36735. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36736. * are rendered front to back (prevent overdraw).
  36737. *
  36738. * @param a The first submesh
  36739. * @param b The second submesh
  36740. * @returns The result of the comparison
  36741. */
  36742. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36743. /**
  36744. * Resets the different lists of submeshes to prepare a new frame.
  36745. */
  36746. prepare(): void;
  36747. dispose(): void;
  36748. /**
  36749. * Inserts the submesh in its correct queue depending on its material.
  36750. * @param subMesh The submesh to dispatch
  36751. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36752. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36753. */
  36754. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36755. dispatchSprites(spriteManager: ISpriteManager): void;
  36756. dispatchParticles(particleSystem: IParticleSystem): void;
  36757. private _renderParticles;
  36758. private _renderSprites;
  36759. }
  36760. }
  36761. declare module BABYLON {
  36762. /**
  36763. * Interface describing the different options available in the rendering manager
  36764. * regarding Auto Clear between groups.
  36765. */
  36766. interface IRenderingManagerAutoClearSetup {
  36767. /**
  36768. * Defines whether or not autoclear is enable.
  36769. */
  36770. autoClear: boolean;
  36771. /**
  36772. * Defines whether or not to autoclear the depth buffer.
  36773. */
  36774. depth: boolean;
  36775. /**
  36776. * Defines whether or not to autoclear the stencil buffer.
  36777. */
  36778. stencil: boolean;
  36779. }
  36780. /**
  36781. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36782. * It is enable to manage the different groups as well as the different necessary sort functions.
  36783. * This should not be used directly aside of the few static configurations
  36784. */
  36785. class RenderingManager {
  36786. /**
  36787. * The max id used for rendering groups (not included)
  36788. */
  36789. static MAX_RENDERINGGROUPS: number;
  36790. /**
  36791. * The min id used for rendering groups (included)
  36792. */
  36793. static MIN_RENDERINGGROUPS: number;
  36794. /**
  36795. * Used to globally prevent autoclearing scenes.
  36796. */
  36797. static AUTOCLEAR: boolean;
  36798. /**
  36799. * @hidden
  36800. */
  36801. _useSceneAutoClearSetup: boolean;
  36802. private _scene;
  36803. private _renderingGroups;
  36804. private _depthStencilBufferAlreadyCleaned;
  36805. private _autoClearDepthStencil;
  36806. private _customOpaqueSortCompareFn;
  36807. private _customAlphaTestSortCompareFn;
  36808. private _customTransparentSortCompareFn;
  36809. private _renderingGroupInfo;
  36810. /**
  36811. * Instantiates a new rendering group for a particular scene
  36812. * @param scene Defines the scene the groups belongs to
  36813. */
  36814. constructor(scene: Scene);
  36815. private _clearDepthStencilBuffer;
  36816. /**
  36817. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36818. * @hidden
  36819. */
  36820. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36821. /**
  36822. * Resets the different information of the group to prepare a new frame
  36823. * @hidden
  36824. */
  36825. reset(): void;
  36826. /**
  36827. * Dispose and release the group and its associated resources.
  36828. * @hidden
  36829. */
  36830. dispose(): void;
  36831. /**
  36832. * Clear the info related to rendering groups preventing retention points during dispose.
  36833. */
  36834. freeRenderingGroups(): void;
  36835. private _prepareRenderingGroup;
  36836. /**
  36837. * Add a sprite manager to the rendering manager in order to render it this frame.
  36838. * @param spriteManager Define the sprite manager to render
  36839. */
  36840. dispatchSprites(spriteManager: ISpriteManager): void;
  36841. /**
  36842. * Add a particle system to the rendering manager in order to render it this frame.
  36843. * @param particleSystem Define the particle system to render
  36844. */
  36845. dispatchParticles(particleSystem: IParticleSystem): void;
  36846. /**
  36847. * Add a submesh to the manager in order to render it this frame
  36848. * @param subMesh The submesh to dispatch
  36849. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36850. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36851. */
  36852. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36853. /**
  36854. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36855. * This allowed control for front to back rendering or reversly depending of the special needs.
  36856. *
  36857. * @param renderingGroupId The rendering group id corresponding to its index
  36858. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36859. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36860. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36861. */
  36862. 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;
  36863. /**
  36864. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36865. *
  36866. * @param renderingGroupId The rendering group id corresponding to its index
  36867. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36868. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36869. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36870. */
  36871. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36872. /**
  36873. * Gets the current auto clear configuration for one rendering group of the rendering
  36874. * manager.
  36875. * @param index the rendering group index to get the information for
  36876. * @returns The auto clear setup for the requested rendering group
  36877. */
  36878. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36879. }
  36880. }
  36881. declare module BABYLON {
  36882. /**
  36883. * Renders a layer on top of an existing scene
  36884. */
  36885. class UtilityLayerRenderer implements IDisposable {
  36886. /** the original scene that will be rendered on top of */
  36887. originalScene: Scene;
  36888. private _pointerCaptures;
  36889. private _lastPointerEvents;
  36890. private static _DefaultUtilityLayer;
  36891. private static _DefaultKeepDepthUtilityLayer;
  36892. /**
  36893. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  36894. */
  36895. pickUtilitySceneFirst: boolean;
  36896. /**
  36897. * 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)
  36898. */
  36899. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36900. /**
  36901. * 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)
  36902. */
  36903. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36904. /**
  36905. * The scene that is rendered on top of the original scene
  36906. */
  36907. utilityLayerScene: Scene;
  36908. /**
  36909. * If the utility layer should automatically be rendered on top of existing scene
  36910. */
  36911. shouldRender: boolean;
  36912. /**
  36913. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36914. */
  36915. onlyCheckPointerDownEvents: boolean;
  36916. /**
  36917. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36918. */
  36919. processAllEvents: boolean;
  36920. /**
  36921. * Observable raised when the pointer move from the utility layer scene to the main scene
  36922. */
  36923. onPointerOutObservable: Observable<number>;
  36924. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36925. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36926. private _afterRenderObserver;
  36927. private _sceneDisposeObserver;
  36928. private _originalPointerObserver;
  36929. /**
  36930. * Instantiates a UtilityLayerRenderer
  36931. * @param originalScene the original scene that will be rendered on top of
  36932. * @param handleEvents boolean indicating if the utility layer should handle events
  36933. */
  36934. constructor(
  36935. /** the original scene that will be rendered on top of */
  36936. originalScene: Scene, handleEvents?: boolean);
  36937. private _notifyObservers;
  36938. /**
  36939. * Renders the utility layers scene on top of the original scene
  36940. */
  36941. render(): void;
  36942. /**
  36943. * Disposes of the renderer
  36944. */
  36945. dispose(): void;
  36946. private _updateCamera;
  36947. }
  36948. }
  36949. declare module BABYLON {
  36950. /**
  36951. * Class used to represent a sprite
  36952. * @see http://doc.babylonjs.com/babylon101/sprites
  36953. */
  36954. class Sprite {
  36955. /** defines the name */
  36956. name: string;
  36957. /** Gets or sets the current world position */
  36958. position: Vector3;
  36959. /** Gets or sets the main color */
  36960. color: Color4;
  36961. /** Gets or sets the width */
  36962. width: number;
  36963. /** Gets or sets the height */
  36964. height: number;
  36965. /** Gets or sets rotation angle */
  36966. angle: number;
  36967. /** Gets or sets the cell index in the sprite sheet */
  36968. cellIndex: number;
  36969. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36970. invertU: number;
  36971. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36972. invertV: number;
  36973. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36974. disposeWhenFinishedAnimating: boolean;
  36975. /** Gets the list of attached animations */
  36976. animations: Animation[];
  36977. /** Gets or sets a boolean indicating if the sprite can be picked */
  36978. isPickable: boolean;
  36979. /**
  36980. * Gets or sets the associated action manager
  36981. */
  36982. actionManager: Nullable<ActionManager>;
  36983. private _animationStarted;
  36984. private _loopAnimation;
  36985. private _fromIndex;
  36986. private _toIndex;
  36987. private _delay;
  36988. private _direction;
  36989. private _manager;
  36990. private _time;
  36991. private _onAnimationEnd;
  36992. /**
  36993. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36994. */
  36995. isVisible: boolean;
  36996. /**
  36997. * Gets or sets the sprite size
  36998. */
  36999. size: number;
  37000. /**
  37001. * Creates a new Sprite
  37002. * @param name defines the name
  37003. * @param manager defines the manager
  37004. */
  37005. constructor(
  37006. /** defines the name */
  37007. name: string, manager: ISpriteManager);
  37008. /**
  37009. * Starts an animation
  37010. * @param from defines the initial key
  37011. * @param to defines the end key
  37012. * @param loop defines if the animation must loop
  37013. * @param delay defines the start delay (in ms)
  37014. * @param onAnimationEnd defines a callback to call when animation ends
  37015. */
  37016. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  37017. /** Stops current animation (if any) */
  37018. stopAnimation(): void;
  37019. /** @hidden */
  37020. _animate(deltaTime: number): void;
  37021. /** Release associated resources */
  37022. dispose(): void;
  37023. }
  37024. }
  37025. declare module BABYLON {
  37026. /**
  37027. * Defines the minimum interface to fullfil in order to be a sprite manager.
  37028. */
  37029. interface ISpriteManager extends IDisposable {
  37030. /**
  37031. * Restricts the camera to viewing objects with the same layerMask.
  37032. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  37033. */
  37034. layerMask: number;
  37035. /**
  37036. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37037. */
  37038. isPickable: boolean;
  37039. /**
  37040. * Specifies the rendering group id for this mesh (0 by default)
  37041. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37042. */
  37043. renderingGroupId: number;
  37044. /**
  37045. * Defines the list of sprites managed by the manager.
  37046. */
  37047. sprites: Array<Sprite>;
  37048. /**
  37049. * Tests the intersection of a sprite with a specific ray.
  37050. * @param ray The ray we are sending to test the collision
  37051. * @param camera The camera space we are sending rays in
  37052. * @param predicate A predicate allowing excluding sprites from the list of object to test
  37053. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  37054. * @returns picking info or null.
  37055. */
  37056. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37057. /**
  37058. * Renders the list of sprites on screen.
  37059. */
  37060. render(): void;
  37061. }
  37062. /**
  37063. * Class used to manage multiple sprites on the same spritesheet
  37064. * @see http://doc.babylonjs.com/babylon101/sprites
  37065. */
  37066. class SpriteManager implements ISpriteManager {
  37067. /** defines the manager's name */
  37068. name: string;
  37069. /** Gets the list of sprites */
  37070. sprites: Sprite[];
  37071. /** Gets or sets the rendering group id (0 by default) */
  37072. renderingGroupId: number;
  37073. /** Gets or sets camera layer mask */
  37074. layerMask: number;
  37075. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  37076. fogEnabled: boolean;
  37077. /** Gets or sets a boolean indicating if the sprites are pickable */
  37078. isPickable: boolean;
  37079. /** Defines the default width of a cell in the spritesheet */
  37080. cellWidth: number;
  37081. /** Defines the default height of a cell in the spritesheet */
  37082. cellHeight: number;
  37083. /**
  37084. * An event triggered when the manager is disposed.
  37085. */
  37086. onDisposeObservable: Observable<SpriteManager>;
  37087. private _onDisposeObserver;
  37088. /**
  37089. * Callback called when the manager is disposed
  37090. */
  37091. onDispose: () => void;
  37092. private _capacity;
  37093. private _spriteTexture;
  37094. private _epsilon;
  37095. private _scene;
  37096. private _vertexData;
  37097. private _buffer;
  37098. private _vertexBuffers;
  37099. private _indexBuffer;
  37100. private _effectBase;
  37101. private _effectFog;
  37102. /**
  37103. * Gets or sets the spritesheet texture
  37104. */
  37105. texture: Texture;
  37106. /**
  37107. * Creates a new sprite manager
  37108. * @param name defines the manager's name
  37109. * @param imgUrl defines the sprite sheet url
  37110. * @param capacity defines the maximum allowed number of sprites
  37111. * @param cellSize defines the size of a sprite cell
  37112. * @param scene defines the hosting scene
  37113. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  37114. * @param samplingMode defines the smapling mode to use with spritesheet
  37115. */
  37116. constructor(
  37117. /** defines the manager's name */
  37118. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  37119. private _appendSpriteVertex;
  37120. /**
  37121. * Intersects the sprites with a ray
  37122. * @param ray defines the ray to intersect with
  37123. * @param camera defines the current active camera
  37124. * @param predicate defines a predicate used to select candidate sprites
  37125. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  37126. * @returns null if no hit or a PickingInfo
  37127. */
  37128. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37129. /**
  37130. * Render all child sprites
  37131. */
  37132. render(): void;
  37133. /**
  37134. * Release associated resources
  37135. */
  37136. dispose(): void;
  37137. }
  37138. }
  37139. declare module BABYLON {
  37140. interface Scene {
  37141. /** @hidden */
  37142. _pointerOverSprite: Nullable<Sprite>;
  37143. /** @hidden */
  37144. _pickedDownSprite: Nullable<Sprite>;
  37145. /** @hidden */
  37146. _tempSpritePickingRay: Nullable<Ray>;
  37147. /**
  37148. * All of the sprite managers added to this scene
  37149. * @see http://doc.babylonjs.com/babylon101/sprites
  37150. */
  37151. spriteManagers: Array<ISpriteManager>;
  37152. /**
  37153. * An event triggered when sprites rendering is about to start
  37154. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37155. */
  37156. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37157. /**
  37158. * An event triggered when sprites rendering is done
  37159. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37160. */
  37161. onAfterSpritesRenderingObservable: Observable<Scene>;
  37162. /** @hidden */
  37163. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37164. /** Launch a ray to try to pick a sprite in the scene
  37165. * @param x position on screen
  37166. * @param y position on screen
  37167. * @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
  37168. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37169. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37170. * @returns a PickingInfo
  37171. */
  37172. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37173. /** Use the given ray to pick a sprite in the scene
  37174. * @param ray The ray (in world space) to use to pick meshes
  37175. * @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
  37176. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37177. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37178. * @returns a PickingInfo
  37179. */
  37180. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37181. /**
  37182. * Force the sprite under the pointer
  37183. * @param sprite defines the sprite to use
  37184. */
  37185. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37186. /**
  37187. * Gets the sprite under the pointer
  37188. * @returns a Sprite or null if no sprite is under the pointer
  37189. */
  37190. getPointerOverSprite(): Nullable<Sprite>;
  37191. }
  37192. /**
  37193. * Defines the sprite scene component responsible to manage sprites
  37194. * in a given scene.
  37195. */
  37196. class SpriteSceneComponent implements ISceneComponent {
  37197. /**
  37198. * The component name helpfull to identify the component in the list of scene components.
  37199. */
  37200. readonly name: string;
  37201. /**
  37202. * The scene the component belongs to.
  37203. */
  37204. scene: Scene;
  37205. /** @hidden */
  37206. private _spritePredicate;
  37207. /**
  37208. * Creates a new instance of the component for the given scene
  37209. * @param scene Defines the scene to register the component in
  37210. */
  37211. constructor(scene: Scene);
  37212. /**
  37213. * Registers the component in a given scene
  37214. */
  37215. register(): void;
  37216. /**
  37217. * Rebuilds the elements related to this component in case of
  37218. * context lost for instance.
  37219. */
  37220. rebuild(): void;
  37221. /**
  37222. * Disposes the component and the associated ressources.
  37223. */
  37224. dispose(): void;
  37225. private _pickSpriteButKeepRay;
  37226. private _pointerMove;
  37227. private _pointerDown;
  37228. private _pointerUp;
  37229. }
  37230. }
  37231. declare module BABYLON {
  37232. /**
  37233. * @hidden
  37234. **/
  37235. class _AlphaState {
  37236. private _isAlphaBlendDirty;
  37237. private _isBlendFunctionParametersDirty;
  37238. private _isBlendEquationParametersDirty;
  37239. private _isBlendConstantsDirty;
  37240. private _alphaBlend;
  37241. private _blendFunctionParameters;
  37242. private _blendEquationParameters;
  37243. private _blendConstants;
  37244. /**
  37245. * Initializes the state.
  37246. */
  37247. constructor();
  37248. readonly isDirty: boolean;
  37249. alphaBlend: boolean;
  37250. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37251. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37252. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37253. reset(): void;
  37254. apply(gl: WebGLRenderingContext): void;
  37255. }
  37256. }
  37257. declare module BABYLON {
  37258. /**
  37259. * @hidden
  37260. **/
  37261. class _DepthCullingState {
  37262. private _isDepthTestDirty;
  37263. private _isDepthMaskDirty;
  37264. private _isDepthFuncDirty;
  37265. private _isCullFaceDirty;
  37266. private _isCullDirty;
  37267. private _isZOffsetDirty;
  37268. private _isFrontFaceDirty;
  37269. private _depthTest;
  37270. private _depthMask;
  37271. private _depthFunc;
  37272. private _cull;
  37273. private _cullFace;
  37274. private _zOffset;
  37275. private _frontFace;
  37276. /**
  37277. * Initializes the state.
  37278. */
  37279. constructor();
  37280. readonly isDirty: boolean;
  37281. zOffset: number;
  37282. cullFace: Nullable<number>;
  37283. cull: Nullable<boolean>;
  37284. depthFunc: Nullable<number>;
  37285. depthMask: boolean;
  37286. depthTest: boolean;
  37287. frontFace: Nullable<number>;
  37288. reset(): void;
  37289. apply(gl: WebGLRenderingContext): void;
  37290. }
  37291. }
  37292. declare module BABYLON {
  37293. /**
  37294. * @hidden
  37295. **/
  37296. class _StencilState {
  37297. private _isStencilTestDirty;
  37298. private _isStencilMaskDirty;
  37299. private _isStencilFuncDirty;
  37300. private _isStencilOpDirty;
  37301. private _stencilTest;
  37302. private _stencilMask;
  37303. private _stencilFunc;
  37304. private _stencilFuncRef;
  37305. private _stencilFuncMask;
  37306. private _stencilOpStencilFail;
  37307. private _stencilOpDepthFail;
  37308. private _stencilOpStencilDepthPass;
  37309. readonly isDirty: boolean;
  37310. stencilFunc: number;
  37311. stencilFuncRef: number;
  37312. stencilFuncMask: number;
  37313. stencilOpStencilFail: number;
  37314. stencilOpDepthFail: number;
  37315. stencilOpStencilDepthPass: number;
  37316. stencilMask: number;
  37317. stencilTest: boolean;
  37318. constructor();
  37319. reset(): void;
  37320. apply(gl: WebGLRenderingContext): void;
  37321. }
  37322. }
  37323. declare module BABYLON {
  37324. /**
  37325. * Class used to evalaute queries containing `and` and `or` operators
  37326. */
  37327. class AndOrNotEvaluator {
  37328. /**
  37329. * Evaluate a query
  37330. * @param query defines the query to evaluate
  37331. * @param evaluateCallback defines the callback used to filter result
  37332. * @returns true if the query matches
  37333. */
  37334. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37335. private static _HandleParenthesisContent;
  37336. private static _SimplifyNegation;
  37337. }
  37338. }
  37339. declare module BABYLON {
  37340. /**
  37341. * Defines the list of states available for a task inside a AssetsManager
  37342. */
  37343. enum AssetTaskState {
  37344. /**
  37345. * Initialization
  37346. */
  37347. INIT = 0,
  37348. /**
  37349. * Running
  37350. */
  37351. RUNNING = 1,
  37352. /**
  37353. * Done
  37354. */
  37355. DONE = 2,
  37356. /**
  37357. * Error
  37358. */
  37359. ERROR = 3
  37360. }
  37361. /**
  37362. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37363. */
  37364. abstract class AbstractAssetTask {
  37365. /**
  37366. * Task name
  37367. */ name: string;
  37368. /**
  37369. * Callback called when the task is successful
  37370. */
  37371. onSuccess: (task: any) => void;
  37372. /**
  37373. * Callback called when the task is not successful
  37374. */
  37375. onError: (task: any, message?: string, exception?: any) => void;
  37376. /**
  37377. * Creates a new AssetsManager
  37378. * @param name defines the name of the task
  37379. */
  37380. constructor(
  37381. /**
  37382. * Task name
  37383. */ name: string);
  37384. private _isCompleted;
  37385. private _taskState;
  37386. private _errorObject;
  37387. /**
  37388. * Get if the task is completed
  37389. */
  37390. readonly isCompleted: boolean;
  37391. /**
  37392. * Gets the current state of the task
  37393. */
  37394. readonly taskState: AssetTaskState;
  37395. /**
  37396. * Gets the current error object (if task is in error)
  37397. */
  37398. readonly errorObject: {
  37399. message?: string;
  37400. exception?: any;
  37401. };
  37402. /**
  37403. * Internal only
  37404. * @hidden
  37405. */
  37406. _setErrorObject(message?: string, exception?: any): void;
  37407. /**
  37408. * Execute the current task
  37409. * @param scene defines the scene where you want your assets to be loaded
  37410. * @param onSuccess is a callback called when the task is successfully executed
  37411. * @param onError is a callback called if an error occurs
  37412. */
  37413. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37414. /**
  37415. * Execute the current task
  37416. * @param scene defines the scene where you want your assets to be loaded
  37417. * @param onSuccess is a callback called when the task is successfully executed
  37418. * @param onError is a callback called if an error occurs
  37419. */
  37420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37421. /**
  37422. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37423. * This can be used with failed tasks that have the reason for failure fixed.
  37424. */
  37425. reset(): void;
  37426. private onErrorCallback;
  37427. private onDoneCallback;
  37428. }
  37429. /**
  37430. * Define the interface used by progress events raised during assets loading
  37431. */
  37432. interface IAssetsProgressEvent {
  37433. /**
  37434. * Defines the number of remaining tasks to process
  37435. */
  37436. remainingCount: number;
  37437. /**
  37438. * Defines the total number of tasks
  37439. */
  37440. totalCount: number;
  37441. /**
  37442. * Defines the task that was just processed
  37443. */
  37444. task: AbstractAssetTask;
  37445. }
  37446. /**
  37447. * Class used to share progress information about assets loading
  37448. */
  37449. class AssetsProgressEvent implements IAssetsProgressEvent {
  37450. /**
  37451. * Defines the number of remaining tasks to process
  37452. */
  37453. remainingCount: number;
  37454. /**
  37455. * Defines the total number of tasks
  37456. */
  37457. totalCount: number;
  37458. /**
  37459. * Defines the task that was just processed
  37460. */
  37461. task: AbstractAssetTask;
  37462. /**
  37463. * Creates a AssetsProgressEvent
  37464. * @param remainingCount defines the number of remaining tasks to process
  37465. * @param totalCount defines the total number of tasks
  37466. * @param task defines the task that was just processed
  37467. */
  37468. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37469. }
  37470. /**
  37471. * Define a task used by AssetsManager to load meshes
  37472. */
  37473. class MeshAssetTask extends AbstractAssetTask {
  37474. /**
  37475. * Defines the name of the task
  37476. */
  37477. name: string;
  37478. /**
  37479. * Defines the list of mesh's names you want to load
  37480. */
  37481. meshesNames: any;
  37482. /**
  37483. * Defines the root url to use as a base to load your meshes and associated resources
  37484. */
  37485. rootUrl: string;
  37486. /**
  37487. * Defines the filename of the scene to load from
  37488. */
  37489. sceneFilename: string;
  37490. /**
  37491. * Gets the list of loaded meshes
  37492. */
  37493. loadedMeshes: Array<AbstractMesh>;
  37494. /**
  37495. * Gets the list of loaded particle systems
  37496. */
  37497. loadedParticleSystems: Array<IParticleSystem>;
  37498. /**
  37499. * Gets the list of loaded skeletons
  37500. */
  37501. loadedSkeletons: Array<Skeleton>;
  37502. /**
  37503. * Gets the list of loaded animation groups
  37504. */
  37505. loadedAnimationGroups: Array<AnimationGroup>;
  37506. /**
  37507. * Callback called when the task is successful
  37508. */
  37509. onSuccess: (task: MeshAssetTask) => void;
  37510. /**
  37511. * Callback called when the task is successful
  37512. */
  37513. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37514. /**
  37515. * Creates a new MeshAssetTask
  37516. * @param name defines the name of the task
  37517. * @param meshesNames defines the list of mesh's names you want to load
  37518. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37519. * @param sceneFilename defines the filename of the scene to load from
  37520. */
  37521. constructor(
  37522. /**
  37523. * Defines the name of the task
  37524. */
  37525. name: string,
  37526. /**
  37527. * Defines the list of mesh's names you want to load
  37528. */
  37529. meshesNames: any,
  37530. /**
  37531. * Defines the root url to use as a base to load your meshes and associated resources
  37532. */
  37533. rootUrl: string,
  37534. /**
  37535. * Defines the filename of the scene to load from
  37536. */
  37537. sceneFilename: string);
  37538. /**
  37539. * Execute the current task
  37540. * @param scene defines the scene where you want your assets to be loaded
  37541. * @param onSuccess is a callback called when the task is successfully executed
  37542. * @param onError is a callback called if an error occurs
  37543. */
  37544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37545. }
  37546. /**
  37547. * Define a task used by AssetsManager to load text content
  37548. */
  37549. class TextFileAssetTask extends AbstractAssetTask {
  37550. /**
  37551. * Defines the name of the task
  37552. */
  37553. name: string;
  37554. /**
  37555. * Defines the location of the file to load
  37556. */
  37557. url: string;
  37558. /**
  37559. * Gets the loaded text string
  37560. */
  37561. text: string;
  37562. /**
  37563. * Callback called when the task is successful
  37564. */
  37565. onSuccess: (task: TextFileAssetTask) => void;
  37566. /**
  37567. * Callback called when the task is successful
  37568. */
  37569. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37570. /**
  37571. * Creates a new TextFileAssetTask object
  37572. * @param name defines the name of the task
  37573. * @param url defines the location of the file to load
  37574. */
  37575. constructor(
  37576. /**
  37577. * Defines the name of the task
  37578. */
  37579. name: string,
  37580. /**
  37581. * Defines the location of the file to load
  37582. */
  37583. url: string);
  37584. /**
  37585. * Execute the current task
  37586. * @param scene defines the scene where you want your assets to be loaded
  37587. * @param onSuccess is a callback called when the task is successfully executed
  37588. * @param onError is a callback called if an error occurs
  37589. */
  37590. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37591. }
  37592. /**
  37593. * Define a task used by AssetsManager to load binary data
  37594. */
  37595. class BinaryFileAssetTask extends AbstractAssetTask {
  37596. /**
  37597. * Defines the name of the task
  37598. */
  37599. name: string;
  37600. /**
  37601. * Defines the location of the file to load
  37602. */
  37603. url: string;
  37604. /**
  37605. * Gets the lodaded data (as an array buffer)
  37606. */
  37607. data: ArrayBuffer;
  37608. /**
  37609. * Callback called when the task is successful
  37610. */
  37611. onSuccess: (task: BinaryFileAssetTask) => void;
  37612. /**
  37613. * Callback called when the task is successful
  37614. */
  37615. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37616. /**
  37617. * Creates a new BinaryFileAssetTask object
  37618. * @param name defines the name of the new task
  37619. * @param url defines the location of the file to load
  37620. */
  37621. constructor(
  37622. /**
  37623. * Defines the name of the task
  37624. */
  37625. name: string,
  37626. /**
  37627. * Defines the location of the file to load
  37628. */
  37629. url: string);
  37630. /**
  37631. * Execute the current task
  37632. * @param scene defines the scene where you want your assets to be loaded
  37633. * @param onSuccess is a callback called when the task is successfully executed
  37634. * @param onError is a callback called if an error occurs
  37635. */
  37636. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37637. }
  37638. /**
  37639. * Define a task used by AssetsManager to load images
  37640. */
  37641. class ImageAssetTask extends AbstractAssetTask {
  37642. /**
  37643. * Defines the name of the task
  37644. */
  37645. name: string;
  37646. /**
  37647. * Defines the location of the image to load
  37648. */
  37649. url: string;
  37650. /**
  37651. * Gets the loaded images
  37652. */
  37653. image: HTMLImageElement;
  37654. /**
  37655. * Callback called when the task is successful
  37656. */
  37657. onSuccess: (task: ImageAssetTask) => void;
  37658. /**
  37659. * Callback called when the task is successful
  37660. */
  37661. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37662. /**
  37663. * Creates a new ImageAssetTask
  37664. * @param name defines the name of the task
  37665. * @param url defines the location of the image to load
  37666. */
  37667. constructor(
  37668. /**
  37669. * Defines the name of the task
  37670. */
  37671. name: string,
  37672. /**
  37673. * Defines the location of the image to load
  37674. */
  37675. url: string);
  37676. /**
  37677. * Execute the current task
  37678. * @param scene defines the scene where you want your assets to be loaded
  37679. * @param onSuccess is a callback called when the task is successfully executed
  37680. * @param onError is a callback called if an error occurs
  37681. */
  37682. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37683. }
  37684. /**
  37685. * Defines the interface used by texture loading tasks
  37686. */
  37687. interface ITextureAssetTask<TEX extends BaseTexture> {
  37688. /**
  37689. * Gets the loaded texture
  37690. */
  37691. texture: TEX;
  37692. }
  37693. /**
  37694. * Define a task used by AssetsManager to load 2D textures
  37695. */
  37696. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37697. /**
  37698. * Defines the name of the task
  37699. */
  37700. name: string;
  37701. /**
  37702. * Defines the location of the file to load
  37703. */
  37704. url: string;
  37705. /**
  37706. * Defines if mipmap should not be generated (default is false)
  37707. */
  37708. noMipmap?: boolean | undefined;
  37709. /**
  37710. * Defines if texture must be inverted on Y axis (default is false)
  37711. */
  37712. invertY?: boolean | undefined;
  37713. /**
  37714. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37715. */
  37716. samplingMode: number;
  37717. /**
  37718. * Gets the loaded texture
  37719. */
  37720. texture: Texture;
  37721. /**
  37722. * Callback called when the task is successful
  37723. */
  37724. onSuccess: (task: TextureAssetTask) => void;
  37725. /**
  37726. * Callback called when the task is successful
  37727. */
  37728. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37729. /**
  37730. * Creates a new TextureAssetTask object
  37731. * @param name defines the name of the task
  37732. * @param url defines the location of the file to load
  37733. * @param noMipmap defines if mipmap should not be generated (default is false)
  37734. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37735. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37736. */
  37737. constructor(
  37738. /**
  37739. * Defines the name of the task
  37740. */
  37741. name: string,
  37742. /**
  37743. * Defines the location of the file to load
  37744. */
  37745. url: string,
  37746. /**
  37747. * Defines if mipmap should not be generated (default is false)
  37748. */
  37749. noMipmap?: boolean | undefined,
  37750. /**
  37751. * Defines if texture must be inverted on Y axis (default is false)
  37752. */
  37753. invertY?: boolean | undefined,
  37754. /**
  37755. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37756. */
  37757. samplingMode?: number);
  37758. /**
  37759. * Execute the current task
  37760. * @param scene defines the scene where you want your assets to be loaded
  37761. * @param onSuccess is a callback called when the task is successfully executed
  37762. * @param onError is a callback called if an error occurs
  37763. */
  37764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37765. }
  37766. /**
  37767. * Define a task used by AssetsManager to load cube textures
  37768. */
  37769. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37770. /**
  37771. * Defines the name of the task
  37772. */
  37773. name: string;
  37774. /**
  37775. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37776. */
  37777. url: string;
  37778. /**
  37779. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37780. */
  37781. extensions?: string[] | undefined;
  37782. /**
  37783. * Defines if mipmaps should not be generated (default is false)
  37784. */
  37785. noMipmap?: boolean | undefined;
  37786. /**
  37787. * Defines the explicit list of files (undefined by default)
  37788. */
  37789. files?: string[] | undefined;
  37790. /**
  37791. * Gets the loaded texture
  37792. */
  37793. texture: CubeTexture;
  37794. /**
  37795. * Callback called when the task is successful
  37796. */
  37797. onSuccess: (task: CubeTextureAssetTask) => void;
  37798. /**
  37799. * Callback called when the task is successful
  37800. */
  37801. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37802. /**
  37803. * Creates a new CubeTextureAssetTask
  37804. * @param name defines the name of the task
  37805. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37806. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37807. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37808. * @param files defines the explicit list of files (undefined by default)
  37809. */
  37810. constructor(
  37811. /**
  37812. * Defines the name of the task
  37813. */
  37814. name: string,
  37815. /**
  37816. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37817. */
  37818. url: string,
  37819. /**
  37820. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37821. */
  37822. extensions?: string[] | undefined,
  37823. /**
  37824. * Defines if mipmaps should not be generated (default is false)
  37825. */
  37826. noMipmap?: boolean | undefined,
  37827. /**
  37828. * Defines the explicit list of files (undefined by default)
  37829. */
  37830. files?: string[] | undefined);
  37831. /**
  37832. * Execute the current task
  37833. * @param scene defines the scene where you want your assets to be loaded
  37834. * @param onSuccess is a callback called when the task is successfully executed
  37835. * @param onError is a callback called if an error occurs
  37836. */
  37837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37838. }
  37839. /**
  37840. * Define a task used by AssetsManager to load HDR cube textures
  37841. */
  37842. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37843. /**
  37844. * Defines the name of the task
  37845. */
  37846. name: string;
  37847. /**
  37848. * Defines the location of the file to load
  37849. */
  37850. url: string;
  37851. /**
  37852. * Defines the desired size (the more it increases the longer the generation will be)
  37853. */
  37854. size: number;
  37855. /**
  37856. * Defines if mipmaps should not be generated (default is false)
  37857. */
  37858. noMipmap: boolean;
  37859. /**
  37860. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37861. */
  37862. generateHarmonics: boolean;
  37863. /**
  37864. * 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)
  37865. */
  37866. gammaSpace: boolean;
  37867. /**
  37868. * Internal Use Only
  37869. */
  37870. reserved: boolean;
  37871. /**
  37872. * Gets the loaded texture
  37873. */
  37874. texture: HDRCubeTexture;
  37875. /**
  37876. * Callback called when the task is successful
  37877. */
  37878. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37879. /**
  37880. * Callback called when the task is successful
  37881. */
  37882. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37883. /**
  37884. * Creates a new HDRCubeTextureAssetTask object
  37885. * @param name defines the name of the task
  37886. * @param url defines the location of the file to load
  37887. * @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.
  37888. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37889. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37890. * @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)
  37891. * @param reserved Internal use only
  37892. */
  37893. constructor(
  37894. /**
  37895. * Defines the name of the task
  37896. */
  37897. name: string,
  37898. /**
  37899. * Defines the location of the file to load
  37900. */
  37901. url: string,
  37902. /**
  37903. * Defines the desired size (the more it increases the longer the generation will be)
  37904. */
  37905. size: number,
  37906. /**
  37907. * Defines if mipmaps should not be generated (default is false)
  37908. */
  37909. noMipmap?: boolean,
  37910. /**
  37911. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37912. */
  37913. generateHarmonics?: boolean,
  37914. /**
  37915. * 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)
  37916. */
  37917. gammaSpace?: boolean,
  37918. /**
  37919. * Internal Use Only
  37920. */
  37921. reserved?: boolean);
  37922. /**
  37923. * Execute the current task
  37924. * @param scene defines the scene where you want your assets to be loaded
  37925. * @param onSuccess is a callback called when the task is successfully executed
  37926. * @param onError is a callback called if an error occurs
  37927. */
  37928. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37929. }
  37930. /**
  37931. * This class can be used to easily import assets into a scene
  37932. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37933. */
  37934. class AssetsManager {
  37935. private _scene;
  37936. private _isLoading;
  37937. protected _tasks: AbstractAssetTask[];
  37938. protected _waitingTasksCount: number;
  37939. protected _totalTasksCount: number;
  37940. /**
  37941. * Callback called when all tasks are processed
  37942. */
  37943. onFinish: (tasks: AbstractAssetTask[]) => void;
  37944. /**
  37945. * Callback called when a task is successful
  37946. */
  37947. onTaskSuccess: (task: AbstractAssetTask) => void;
  37948. /**
  37949. * Callback called when a task had an error
  37950. */
  37951. onTaskError: (task: AbstractAssetTask) => void;
  37952. /**
  37953. * Callback called when a task is done (whatever the result is)
  37954. */
  37955. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37956. /**
  37957. * Observable called when all tasks are processed
  37958. */
  37959. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37960. /**
  37961. * Observable called when a task had an error
  37962. */
  37963. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37964. /**
  37965. * Observable called when a task is successful
  37966. */
  37967. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37968. /**
  37969. * Observable called when a task is done (whatever the result is)
  37970. */
  37971. onProgressObservable: Observable<IAssetsProgressEvent>;
  37972. /**
  37973. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37974. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37975. */
  37976. useDefaultLoadingScreen: boolean;
  37977. /**
  37978. * Creates a new AssetsManager
  37979. * @param scene defines the scene to work on
  37980. */
  37981. constructor(scene: Scene);
  37982. /**
  37983. * Add a MeshAssetTask to the list of active tasks
  37984. * @param taskName defines the name of the new task
  37985. * @param meshesNames defines the name of meshes to load
  37986. * @param rootUrl defines the root url to use to locate files
  37987. * @param sceneFilename defines the filename of the scene file
  37988. * @returns a new MeshAssetTask object
  37989. */
  37990. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37991. /**
  37992. * Add a TextFileAssetTask to the list of active tasks
  37993. * @param taskName defines the name of the new task
  37994. * @param url defines the url of the file to load
  37995. * @returns a new TextFileAssetTask object
  37996. */
  37997. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37998. /**
  37999. * Add a BinaryFileAssetTask to the list of active tasks
  38000. * @param taskName defines the name of the new task
  38001. * @param url defines the url of the file to load
  38002. * @returns a new BinaryFileAssetTask object
  38003. */
  38004. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  38005. /**
  38006. * Add a ImageAssetTask to the list of active tasks
  38007. * @param taskName defines the name of the new task
  38008. * @param url defines the url of the file to load
  38009. * @returns a new ImageAssetTask object
  38010. */
  38011. addImageTask(taskName: string, url: string): ImageAssetTask;
  38012. /**
  38013. * Add a TextureAssetTask to the list of active tasks
  38014. * @param taskName defines the name of the new task
  38015. * @param url defines the url of the file to load
  38016. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38017. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  38018. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  38019. * @returns a new TextureAssetTask object
  38020. */
  38021. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  38022. /**
  38023. * Add a CubeTextureAssetTask to the list of active tasks
  38024. * @param taskName defines the name of the new task
  38025. * @param url defines the url of the file to load
  38026. * @param extensions defines the extension to use to load the cube map (can be null)
  38027. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38028. * @param files defines the list of files to load (can be null)
  38029. * @returns a new CubeTextureAssetTask object
  38030. */
  38031. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  38032. /**
  38033. *
  38034. * Add a HDRCubeTextureAssetTask to the list of active tasks
  38035. * @param taskName defines the name of the new task
  38036. * @param url defines the url of the file to load
  38037. * @param size defines the size you want for the cubemap (can be null)
  38038. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38039. * @param generateHarmonics defines if you want to automatically generate (true by default)
  38040. * @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)
  38041. * @param reserved Internal use only
  38042. * @returns a new HDRCubeTextureAssetTask object
  38043. */
  38044. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  38045. /**
  38046. * Remove a task from the assets manager.
  38047. * @param task the task to remove
  38048. */
  38049. removeTask(task: AbstractAssetTask): void;
  38050. private _decreaseWaitingTasksCount;
  38051. private _runTask;
  38052. /**
  38053. * Reset the AssetsManager and remove all tasks
  38054. * @return the current instance of the AssetsManager
  38055. */
  38056. reset(): AssetsManager;
  38057. /**
  38058. * Start the loading process
  38059. * @return the current instance of the AssetsManager
  38060. */
  38061. load(): AssetsManager;
  38062. }
  38063. }
  38064. declare module BABYLON {
  38065. /**
  38066. * Direct draw surface info
  38067. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  38068. */
  38069. interface DDSInfo {
  38070. /**
  38071. * Width of the texture
  38072. */
  38073. width: number;
  38074. /**
  38075. * Width of the texture
  38076. */
  38077. height: number;
  38078. /**
  38079. * Number of Mipmaps for the texture
  38080. * @see https://en.wikipedia.org/wiki/Mipmap
  38081. */
  38082. mipmapCount: number;
  38083. /**
  38084. * If the textures format is a known fourCC format
  38085. * @see https://www.fourcc.org/
  38086. */
  38087. isFourCC: boolean;
  38088. /**
  38089. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  38090. */
  38091. isRGB: boolean;
  38092. /**
  38093. * If the texture is a lumincance format
  38094. */
  38095. isLuminance: boolean;
  38096. /**
  38097. * If this is a cube texture
  38098. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  38099. */
  38100. isCube: boolean;
  38101. /**
  38102. * If the texture is a compressed format eg. FOURCC_DXT1
  38103. */
  38104. isCompressed: boolean;
  38105. /**
  38106. * The dxgiFormat of the texture
  38107. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38108. */
  38109. dxgiFormat: number;
  38110. /**
  38111. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38112. */
  38113. textureType: number;
  38114. /**
  38115. * Sphericle polynomial created for the dds texture
  38116. */
  38117. sphericalPolynomial?: SphericalPolynomial;
  38118. }
  38119. /**
  38120. * Class used to provide DDS decompression tools
  38121. */
  38122. class DDSTools {
  38123. /**
  38124. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38125. */
  38126. static StoreLODInAlphaChannel: boolean;
  38127. /**
  38128. * Gets DDS information from an array buffer
  38129. * @param arrayBuffer defines the array buffer to read data from
  38130. * @returns the DDS information
  38131. */
  38132. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38133. private static _FloatView;
  38134. private static _Int32View;
  38135. private static _ToHalfFloat;
  38136. private static _FromHalfFloat;
  38137. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38138. private static _GetHalfFloatRGBAArrayBuffer;
  38139. private static _GetFloatRGBAArrayBuffer;
  38140. private static _GetFloatAsUIntRGBAArrayBuffer;
  38141. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38142. private static _GetRGBAArrayBuffer;
  38143. private static _ExtractLongWordOrder;
  38144. private static _GetRGBArrayBuffer;
  38145. private static _GetLuminanceArrayBuffer;
  38146. /**
  38147. * Uploads DDS Levels to a Babylon Texture
  38148. * @hidden
  38149. */
  38150. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38151. }
  38152. }
  38153. declare module BABYLON {
  38154. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38155. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38156. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38157. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38158. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38159. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38160. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38161. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38162. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38163. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38164. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38165. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38166. /**
  38167. * Decorator used to define property that can be serialized as reference to a camera
  38168. * @param sourceName defines the name of the property to decorate
  38169. */
  38170. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38171. /**
  38172. * Class used to help serialization objects
  38173. */
  38174. class SerializationHelper {
  38175. /**
  38176. * Static function used to serialized a specific entity
  38177. * @param entity defines the entity to serialize
  38178. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38179. * @returns a JSON compatible object representing the serialization of the entity
  38180. */
  38181. static Serialize<T>(entity: T, serializationObject?: any): any;
  38182. /**
  38183. * Creates a new entity from a serialization data object
  38184. * @param creationFunction defines a function used to instanciated the new entity
  38185. * @param source defines the source serialization data
  38186. * @param scene defines the hosting scene
  38187. * @param rootUrl defines the root url for resources
  38188. * @returns a new entity
  38189. */
  38190. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38191. /**
  38192. * Clones an object
  38193. * @param creationFunction defines the function used to instanciate the new object
  38194. * @param source defines the source object
  38195. * @returns the cloned object
  38196. */
  38197. static Clone<T>(creationFunction: () => T, source: T): T;
  38198. /**
  38199. * Instanciates a new object based on a source one (some data will be shared between both object)
  38200. * @param creationFunction defines the function used to instanciate the new object
  38201. * @param source defines the source object
  38202. * @returns the new object
  38203. */
  38204. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38205. }
  38206. }
  38207. declare module BABYLON {
  38208. /**
  38209. * Wrapper class for promise with external resolve and reject.
  38210. */
  38211. class Deferred<T> {
  38212. /**
  38213. * The promise associated with this deferred object.
  38214. */
  38215. readonly promise: Promise<T>;
  38216. private _resolve;
  38217. private _reject;
  38218. /**
  38219. * The resolve method of the promise associated with this deferred object.
  38220. */
  38221. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38222. /**
  38223. * The reject method of the promise associated with this deferred object.
  38224. */
  38225. readonly reject: (reason?: any) => void;
  38226. /**
  38227. * Constructor for this deferred object.
  38228. */
  38229. constructor();
  38230. }
  38231. }
  38232. declare module BABYLON {
  38233. /**
  38234. * Raw texture data and descriptor sufficient for WebGL texture upload
  38235. */
  38236. interface EnvironmentTextureInfo {
  38237. /**
  38238. * Version of the environment map
  38239. */
  38240. version: number;
  38241. /**
  38242. * Width of image
  38243. */
  38244. width: number;
  38245. /**
  38246. * Irradiance information stored in the file.
  38247. */
  38248. irradiance: any;
  38249. /**
  38250. * Specular information stored in the file.
  38251. */
  38252. specular: any;
  38253. }
  38254. /**
  38255. * Sets of helpers addressing the serialization and deserialization of environment texture
  38256. * stored in a BabylonJS env file.
  38257. * Those files are usually stored as .env files.
  38258. */
  38259. class EnvironmentTextureTools {
  38260. /**
  38261. * Magic number identifying the env file.
  38262. */
  38263. private static _MagicBytes;
  38264. /**
  38265. * Gets the environment info from an env file.
  38266. * @param data The array buffer containing the .env bytes.
  38267. * @returns the environment file info (the json header) if successfully parsed.
  38268. */
  38269. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38270. /**
  38271. * Creates an environment texture from a loaded cube texture.
  38272. * @param texture defines the cube texture to convert in env file
  38273. * @return a promise containing the environment data if succesfull.
  38274. */
  38275. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38276. /**
  38277. * Creates a JSON representation of the spherical data.
  38278. * @param texture defines the texture containing the polynomials
  38279. * @return the JSON representation of the spherical info
  38280. */
  38281. private static _CreateEnvTextureIrradiance;
  38282. /**
  38283. * Uploads the texture info contained in the env file to the GPU.
  38284. * @param texture defines the internal texture to upload to
  38285. * @param arrayBuffer defines the buffer cotaining the data to load
  38286. * @param info defines the texture info retrieved through the GetEnvInfo method
  38287. * @returns a promise
  38288. */
  38289. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38290. /**
  38291. * Uploads the levels of image data to the GPU.
  38292. * @param texture defines the internal texture to upload to
  38293. * @param imageData defines the array buffer views of image data [mipmap][face]
  38294. * @returns a promise
  38295. */
  38296. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38297. /**
  38298. * Uploads spherical polynomials information to the texture.
  38299. * @param texture defines the texture we are trying to upload the information to
  38300. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38301. */
  38302. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38303. }
  38304. }
  38305. declare module BABYLON {
  38306. /**
  38307. * Class used to help managing file picking and drag'n'drop
  38308. */
  38309. class FilesInput {
  38310. /**
  38311. * List of files ready to be loaded
  38312. */
  38313. static FilesToLoad: {
  38314. [key: string]: File;
  38315. };
  38316. /**
  38317. * Callback called when a file is processed
  38318. */
  38319. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38320. private _engine;
  38321. private _currentScene;
  38322. private _sceneLoadedCallback;
  38323. private _progressCallback;
  38324. private _additionalRenderLoopLogicCallback;
  38325. private _textureLoadingCallback;
  38326. private _startingProcessingFilesCallback;
  38327. private _onReloadCallback;
  38328. private _errorCallback;
  38329. private _elementToMonitor;
  38330. private _sceneFileToLoad;
  38331. private _filesToLoad;
  38332. /**
  38333. * Creates a new FilesInput
  38334. * @param engine defines the rendering engine
  38335. * @param scene defines the hosting scene
  38336. * @param sceneLoadedCallback callback called when scene is loaded
  38337. * @param progressCallback callback called to track progress
  38338. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38339. * @param textureLoadingCallback callback called when a texture is loading
  38340. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38341. * @param onReloadCallback callback called when a reload is requested
  38342. * @param errorCallback callback call if an error occurs
  38343. */
  38344. 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);
  38345. private _dragEnterHandler;
  38346. private _dragOverHandler;
  38347. private _dropHandler;
  38348. /**
  38349. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38350. * @param elementToMonitor defines the DOM element to track
  38351. */
  38352. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38353. /**
  38354. * Release all associated resources
  38355. */
  38356. dispose(): void;
  38357. private renderFunction;
  38358. private drag;
  38359. private drop;
  38360. private _traverseFolder;
  38361. private _processFiles;
  38362. /**
  38363. * Load files from a drop event
  38364. * @param event defines the drop event to use as source
  38365. */
  38366. loadFiles(event: any): void;
  38367. private _processReload;
  38368. /**
  38369. * Reload the current scene from the loaded files
  38370. */
  38371. reload(): void;
  38372. }
  38373. }
  38374. declare module BABYLON {
  38375. /**
  38376. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38377. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38378. */
  38379. class KhronosTextureContainer {
  38380. /** contents of the KTX container file */
  38381. arrayBuffer: any;
  38382. private static HEADER_LEN;
  38383. private static COMPRESSED_2D;
  38384. private static COMPRESSED_3D;
  38385. private static TEX_2D;
  38386. private static TEX_3D;
  38387. /**
  38388. * Gets the openGL type
  38389. */
  38390. glType: number;
  38391. /**
  38392. * Gets the openGL type size
  38393. */
  38394. glTypeSize: number;
  38395. /**
  38396. * Gets the openGL format
  38397. */
  38398. glFormat: number;
  38399. /**
  38400. * Gets the openGL internal format
  38401. */
  38402. glInternalFormat: number;
  38403. /**
  38404. * Gets the base internal format
  38405. */
  38406. glBaseInternalFormat: number;
  38407. /**
  38408. * Gets image width in pixel
  38409. */
  38410. pixelWidth: number;
  38411. /**
  38412. * Gets image height in pixel
  38413. */
  38414. pixelHeight: number;
  38415. /**
  38416. * Gets image depth in pixels
  38417. */
  38418. pixelDepth: number;
  38419. /**
  38420. * Gets the number of array elements
  38421. */
  38422. numberOfArrayElements: number;
  38423. /**
  38424. * Gets the number of faces
  38425. */
  38426. numberOfFaces: number;
  38427. /**
  38428. * Gets the number of mipmap levels
  38429. */
  38430. numberOfMipmapLevels: number;
  38431. /**
  38432. * Gets the bytes of key value data
  38433. */
  38434. bytesOfKeyValueData: number;
  38435. /**
  38436. * Gets the load type
  38437. */
  38438. loadType: number;
  38439. /**
  38440. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38441. */
  38442. isInvalid: boolean;
  38443. /**
  38444. * Creates a new KhronosTextureContainer
  38445. * @param arrayBuffer contents of the KTX container file
  38446. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38447. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38448. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38449. */
  38450. constructor(
  38451. /** contents of the KTX container file */
  38452. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38453. /**
  38454. * Uploads KTX content to a Babylon Texture.
  38455. * It is assumed that the texture has already been created & is currently bound
  38456. * @hidden
  38457. */
  38458. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38459. private _upload2DCompressedLevels;
  38460. }
  38461. }
  38462. declare module BABYLON {
  38463. /**
  38464. * A class serves as a medium between the observable and its observers
  38465. */
  38466. class EventState {
  38467. /**
  38468. * Create a new EventState
  38469. * @param mask defines the mask associated with this state
  38470. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38471. * @param target defines the original target of the state
  38472. * @param currentTarget defines the current target of the state
  38473. */
  38474. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38475. /**
  38476. * Initialize the current event state
  38477. * @param mask defines the mask associated with this state
  38478. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38479. * @param target defines the original target of the state
  38480. * @param currentTarget defines the current target of the state
  38481. * @returns the current event state
  38482. */
  38483. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38484. /**
  38485. * An Observer can set this property to true to prevent subsequent observers of being notified
  38486. */
  38487. skipNextObservers: boolean;
  38488. /**
  38489. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38490. */
  38491. mask: number;
  38492. /**
  38493. * The object that originally notified the event
  38494. */
  38495. target?: any;
  38496. /**
  38497. * The current object in the bubbling phase
  38498. */
  38499. currentTarget?: any;
  38500. /**
  38501. * This will be populated with the return value of the last function that was executed.
  38502. * If it is the first function in the callback chain it will be the event data.
  38503. */
  38504. lastReturnValue?: any;
  38505. }
  38506. /**
  38507. * Represent an Observer registered to a given Observable object.
  38508. */
  38509. class Observer<T> {
  38510. /**
  38511. * Defines the callback to call when the observer is notified
  38512. */
  38513. callback: (eventData: T, eventState: EventState) => void;
  38514. /**
  38515. * Defines the mask of the observer (used to filter notifications)
  38516. */
  38517. mask: number;
  38518. /**
  38519. * Defines the current scope used to restore the JS context
  38520. */
  38521. scope: any;
  38522. /** @hidden */
  38523. _willBeUnregistered: boolean;
  38524. /**
  38525. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38526. */
  38527. unregisterOnNextCall: boolean;
  38528. /**
  38529. * Creates a new observer
  38530. * @param callback defines the callback to call when the observer is notified
  38531. * @param mask defines the mask of the observer (used to filter notifications)
  38532. * @param scope defines the current scope used to restore the JS context
  38533. */
  38534. constructor(
  38535. /**
  38536. * Defines the callback to call when the observer is notified
  38537. */
  38538. callback: (eventData: T, eventState: EventState) => void,
  38539. /**
  38540. * Defines the mask of the observer (used to filter notifications)
  38541. */
  38542. mask: number,
  38543. /**
  38544. * Defines the current scope used to restore the JS context
  38545. */
  38546. scope?: any);
  38547. }
  38548. /**
  38549. * Represent a list of observers registered to multiple Observables object.
  38550. */
  38551. class MultiObserver<T> {
  38552. private _observers;
  38553. private _observables;
  38554. /**
  38555. * Release associated resources
  38556. */
  38557. dispose(): void;
  38558. /**
  38559. * Raise a callback when one of the observable will notify
  38560. * @param observables defines a list of observables to watch
  38561. * @param callback defines the callback to call on notification
  38562. * @param mask defines the mask used to filter notifications
  38563. * @param scope defines the current scope used to restore the JS context
  38564. * @returns the new MultiObserver
  38565. */
  38566. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38567. }
  38568. /**
  38569. * The Observable class is a simple implementation of the Observable pattern.
  38570. *
  38571. * 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.
  38572. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38573. * 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).
  38574. * 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.
  38575. */
  38576. class Observable<T> {
  38577. private _observers;
  38578. private _eventState;
  38579. private _onObserverAdded;
  38580. /**
  38581. * Creates a new observable
  38582. * @param onObserverAdded defines a callback to call when a new observer is added
  38583. */
  38584. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38585. /**
  38586. * Create a new Observer with the specified callback
  38587. * @param callback the callback that will be executed for that Observer
  38588. * @param mask the mask used to filter observers
  38589. * @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.
  38590. * @param scope optional scope for the callback to be called from
  38591. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38592. * @returns the new observer created for the callback
  38593. */
  38594. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38595. /**
  38596. * Create a new Observer with the specified callback and unregisters after the next notification
  38597. * @param callback the callback that will be executed for that Observer
  38598. * @returns the new observer created for the callback
  38599. */
  38600. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38601. /**
  38602. * Remove an Observer from the Observable object
  38603. * @param observer the instance of the Observer to remove
  38604. * @returns false if it doesn't belong to this Observable
  38605. */
  38606. remove(observer: Nullable<Observer<T>>): boolean;
  38607. /**
  38608. * Remove a callback from the Observable object
  38609. * @param callback the callback to remove
  38610. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38611. * @returns false if it doesn't belong to this Observable
  38612. */
  38613. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38614. private _deferUnregister;
  38615. private _remove;
  38616. /**
  38617. * Notify all Observers by calling their respective callback with the given data
  38618. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38619. * @param eventData defines the data to send to all observers
  38620. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38621. * @param target defines the original target of the state
  38622. * @param currentTarget defines the current target of the state
  38623. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38624. */
  38625. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38626. /**
  38627. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38628. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38629. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38630. * and it is crucial that all callbacks will be executed.
  38631. * The order of the callbacks is kept, callbacks are not executed parallel.
  38632. *
  38633. * @param eventData The data to be sent to each callback
  38634. * @param mask is used to filter observers defaults to -1
  38635. * @param target defines the callback target (see EventState)
  38636. * @param currentTarget defines he current object in the bubbling phase
  38637. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38638. */
  38639. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38640. /**
  38641. * Notify a specific observer
  38642. * @param observer defines the observer to notify
  38643. * @param eventData defines the data to be sent to each callback
  38644. * @param mask is used to filter observers defaults to -1
  38645. */
  38646. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38647. /**
  38648. * Gets a boolean indicating if the observable has at least one observer
  38649. * @returns true is the Observable has at least one Observer registered
  38650. */
  38651. hasObservers(): boolean;
  38652. /**
  38653. * Clear the list of observers
  38654. */
  38655. clear(): void;
  38656. /**
  38657. * Clone the current observable
  38658. * @returns a new observable
  38659. */
  38660. clone(): Observable<T>;
  38661. /**
  38662. * Does this observable handles observer registered with a given mask
  38663. * @param mask defines the mask to be tested
  38664. * @return whether or not one observer registered with the given mask is handeled
  38665. **/
  38666. hasSpecificMask(mask?: number): boolean;
  38667. }
  38668. }
  38669. declare module BABYLON {
  38670. /**
  38671. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38672. */
  38673. class PerformanceMonitor {
  38674. private _enabled;
  38675. private _rollingFrameTime;
  38676. private _lastFrameTimeMs;
  38677. /**
  38678. * constructor
  38679. * @param frameSampleSize The number of samples required to saturate the sliding window
  38680. */
  38681. constructor(frameSampleSize?: number);
  38682. /**
  38683. * Samples current frame
  38684. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38685. */
  38686. sampleFrame(timeMs?: number): void;
  38687. /**
  38688. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38689. */
  38690. readonly averageFrameTime: number;
  38691. /**
  38692. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38693. */
  38694. readonly averageFrameTimeVariance: number;
  38695. /**
  38696. * Returns the frame time of the most recent frame
  38697. */
  38698. readonly instantaneousFrameTime: number;
  38699. /**
  38700. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38701. */
  38702. readonly averageFPS: number;
  38703. /**
  38704. * Returns the average framerate in frames per second using the most recent frame time
  38705. */
  38706. readonly instantaneousFPS: number;
  38707. /**
  38708. * Returns true if enough samples have been taken to completely fill the sliding window
  38709. */
  38710. readonly isSaturated: boolean;
  38711. /**
  38712. * Enables contributions to the sliding window sample set
  38713. */
  38714. enable(): void;
  38715. /**
  38716. * Disables contributions to the sliding window sample set
  38717. * Samples will not be interpolated over the disabled period
  38718. */
  38719. disable(): void;
  38720. /**
  38721. * Returns true if sampling is enabled
  38722. */
  38723. readonly isEnabled: boolean;
  38724. /**
  38725. * Resets performance monitor
  38726. */
  38727. reset(): void;
  38728. }
  38729. /**
  38730. * RollingAverage
  38731. *
  38732. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38733. */
  38734. class RollingAverage {
  38735. /**
  38736. * Current average
  38737. */
  38738. average: number;
  38739. /**
  38740. * Current variance
  38741. */
  38742. variance: number;
  38743. protected _samples: Array<number>;
  38744. protected _sampleCount: number;
  38745. protected _pos: number;
  38746. protected _m2: number;
  38747. /**
  38748. * constructor
  38749. * @param length The number of samples required to saturate the sliding window
  38750. */
  38751. constructor(length: number);
  38752. /**
  38753. * Adds a sample to the sample set
  38754. * @param v The sample value
  38755. */
  38756. add(v: number): void;
  38757. /**
  38758. * Returns previously added values or null if outside of history or outside the sliding window domain
  38759. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38760. * @return Value previously recorded with add() or null if outside of range
  38761. */
  38762. history(i: number): number;
  38763. /**
  38764. * Returns true if enough samples have been taken to completely fill the sliding window
  38765. * @return true if sample-set saturated
  38766. */
  38767. isSaturated(): boolean;
  38768. /**
  38769. * Resets the rolling average (equivalent to 0 samples taken so far)
  38770. */
  38771. reset(): void;
  38772. /**
  38773. * Wraps a value around the sample range boundaries
  38774. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38775. * @return Wrapped position in sample range
  38776. */
  38777. protected _wrapPosition(i: number): number;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Helper class that provides a small promise polyfill
  38783. */
  38784. class PromisePolyfill {
  38785. /**
  38786. * Static function used to check if the polyfill is required
  38787. * If this is the case then the function will inject the polyfill to window.Promise
  38788. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38789. */
  38790. static Apply(force?: boolean): void;
  38791. }
  38792. }
  38793. declare module BABYLON {
  38794. /**
  38795. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38797. */
  38798. class SceneOptimization {
  38799. /**
  38800. * Defines the priority of this optimization (0 by default which means first in the list)
  38801. */
  38802. priority: number;
  38803. /**
  38804. * Gets a string describing the action executed by the current optimization
  38805. * @returns description string
  38806. */
  38807. getDescription(): string;
  38808. /**
  38809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38810. * @param scene defines the current scene where to apply this optimization
  38811. * @param optimizer defines the current optimizer
  38812. * @returns true if everything that can be done was applied
  38813. */
  38814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38815. /**
  38816. * Creates the SceneOptimization object
  38817. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38818. * @param desc defines the description associated with the optimization
  38819. */
  38820. constructor(
  38821. /**
  38822. * Defines the priority of this optimization (0 by default which means first in the list)
  38823. */
  38824. priority?: number);
  38825. }
  38826. /**
  38827. * Defines an optimization used to reduce the size of render target textures
  38828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38829. */
  38830. class TextureOptimization extends SceneOptimization {
  38831. /**
  38832. * Defines the priority of this optimization (0 by default which means first in the list)
  38833. */
  38834. priority: number;
  38835. /**
  38836. * 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
  38837. */
  38838. maximumSize: number;
  38839. /**
  38840. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38841. */
  38842. step: number;
  38843. /**
  38844. * Gets a string describing the action executed by the current optimization
  38845. * @returns description string
  38846. */
  38847. getDescription(): string;
  38848. /**
  38849. * Creates the TextureOptimization object
  38850. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38851. * @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
  38852. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38853. */
  38854. constructor(
  38855. /**
  38856. * Defines the priority of this optimization (0 by default which means first in the list)
  38857. */
  38858. priority?: number,
  38859. /**
  38860. * 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
  38861. */
  38862. maximumSize?: number,
  38863. /**
  38864. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38865. */
  38866. step?: number);
  38867. /**
  38868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38869. * @param scene defines the current scene where to apply this optimization
  38870. * @param optimizer defines the current optimizer
  38871. * @returns true if everything that can be done was applied
  38872. */
  38873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38874. }
  38875. /**
  38876. * Defines an optimization used to increase or decrease the rendering resolution
  38877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38878. */
  38879. class HardwareScalingOptimization extends SceneOptimization {
  38880. /**
  38881. * Defines the priority of this optimization (0 by default which means first in the list)
  38882. */
  38883. priority: number;
  38884. /**
  38885. * Defines the maximum scale to use (2 by default)
  38886. */
  38887. maximumScale: number;
  38888. /**
  38889. * Defines the step to use between two passes (0.5 by default)
  38890. */
  38891. step: number;
  38892. private _currentScale;
  38893. private _directionOffset;
  38894. /**
  38895. * Gets a string describing the action executed by the current optimization
  38896. * @return description string
  38897. */
  38898. getDescription(): string;
  38899. /**
  38900. * Creates the HardwareScalingOptimization object
  38901. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38902. * @param maximumScale defines the maximum scale to use (2 by default)
  38903. * @param step defines the step to use between two passes (0.5 by default)
  38904. */
  38905. constructor(
  38906. /**
  38907. * Defines the priority of this optimization (0 by default which means first in the list)
  38908. */
  38909. priority?: number,
  38910. /**
  38911. * Defines the maximum scale to use (2 by default)
  38912. */
  38913. maximumScale?: number,
  38914. /**
  38915. * Defines the step to use between two passes (0.5 by default)
  38916. */
  38917. step?: number);
  38918. /**
  38919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38920. * @param scene defines the current scene where to apply this optimization
  38921. * @param optimizer defines the current optimizer
  38922. * @returns true if everything that can be done was applied
  38923. */
  38924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38925. }
  38926. /**
  38927. * Defines an optimization used to remove shadows
  38928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38929. */
  38930. class ShadowsOptimization extends SceneOptimization {
  38931. /**
  38932. * Gets a string describing the action executed by the current optimization
  38933. * @return description string
  38934. */
  38935. getDescription(): string;
  38936. /**
  38937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38938. * @param scene defines the current scene where to apply this optimization
  38939. * @param optimizer defines the current optimizer
  38940. * @returns true if everything that can be done was applied
  38941. */
  38942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38943. }
  38944. /**
  38945. * Defines an optimization used to turn post-processes off
  38946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38947. */
  38948. class PostProcessesOptimization extends SceneOptimization {
  38949. /**
  38950. * Gets a string describing the action executed by the current optimization
  38951. * @return description string
  38952. */
  38953. getDescription(): string;
  38954. /**
  38955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38956. * @param scene defines the current scene where to apply this optimization
  38957. * @param optimizer defines the current optimizer
  38958. * @returns true if everything that can be done was applied
  38959. */
  38960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38961. }
  38962. /**
  38963. * Defines an optimization used to turn lens flares off
  38964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38965. */
  38966. class LensFlaresOptimization extends SceneOptimization {
  38967. /**
  38968. * Gets a string describing the action executed by the current optimization
  38969. * @return description string
  38970. */
  38971. getDescription(): string;
  38972. /**
  38973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38974. * @param scene defines the current scene where to apply this optimization
  38975. * @param optimizer defines the current optimizer
  38976. * @returns true if everything that can be done was applied
  38977. */
  38978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38979. }
  38980. /**
  38981. * Defines an optimization based on user defined callback.
  38982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38983. */
  38984. class CustomOptimization extends SceneOptimization {
  38985. /**
  38986. * Callback called to apply the custom optimization.
  38987. */
  38988. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38989. /**
  38990. * Callback called to get custom description
  38991. */
  38992. onGetDescription: () => string;
  38993. /**
  38994. * Gets a string describing the action executed by the current optimization
  38995. * @returns description string
  38996. */
  38997. getDescription(): string;
  38998. /**
  38999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39000. * @param scene defines the current scene where to apply this optimization
  39001. * @param optimizer defines the current optimizer
  39002. * @returns true if everything that can be done was applied
  39003. */
  39004. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39005. }
  39006. /**
  39007. * Defines an optimization used to turn particles off
  39008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39009. */
  39010. class ParticlesOptimization extends SceneOptimization {
  39011. /**
  39012. * Gets a string describing the action executed by the current optimization
  39013. * @return description string
  39014. */
  39015. getDescription(): string;
  39016. /**
  39017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39018. * @param scene defines the current scene where to apply this optimization
  39019. * @param optimizer defines the current optimizer
  39020. * @returns true if everything that can be done was applied
  39021. */
  39022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39023. }
  39024. /**
  39025. * Defines an optimization used to turn render targets off
  39026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39027. */
  39028. class RenderTargetsOptimization extends SceneOptimization {
  39029. /**
  39030. * Gets a string describing the action executed by the current optimization
  39031. * @return description string
  39032. */
  39033. getDescription(): string;
  39034. /**
  39035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39036. * @param scene defines the current scene where to apply this optimization
  39037. * @param optimizer defines the current optimizer
  39038. * @returns true if everything that can be done was applied
  39039. */
  39040. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39041. }
  39042. /**
  39043. * Defines an optimization used to merge meshes with compatible materials
  39044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39045. */
  39046. class MergeMeshesOptimization extends SceneOptimization {
  39047. private static _UpdateSelectionTree;
  39048. /**
  39049. * Gets or sets a boolean which defines if optimization octree has to be updated
  39050. */
  39051. /**
  39052. * Gets or sets a boolean which defines if optimization octree has to be updated
  39053. */
  39054. static UpdateSelectionTree: boolean;
  39055. /**
  39056. * Gets a string describing the action executed by the current optimization
  39057. * @return description string
  39058. */
  39059. getDescription(): string;
  39060. private _canBeMerged;
  39061. /**
  39062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39063. * @param scene defines the current scene where to apply this optimization
  39064. * @param optimizer defines the current optimizer
  39065. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  39066. * @returns true if everything that can be done was applied
  39067. */
  39068. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  39069. }
  39070. /**
  39071. * Defines a list of options used by SceneOptimizer
  39072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39073. */
  39074. class SceneOptimizerOptions {
  39075. /**
  39076. * Defines the target frame rate to reach (60 by default)
  39077. */
  39078. targetFrameRate: number;
  39079. /**
  39080. * Defines the interval between two checkes (2000ms by default)
  39081. */
  39082. trackerDuration: number;
  39083. /**
  39084. * Gets the list of optimizations to apply
  39085. */
  39086. optimizations: SceneOptimization[];
  39087. /**
  39088. * Creates a new list of options used by SceneOptimizer
  39089. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  39090. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  39091. */
  39092. constructor(
  39093. /**
  39094. * Defines the target frame rate to reach (60 by default)
  39095. */
  39096. targetFrameRate?: number,
  39097. /**
  39098. * Defines the interval between two checkes (2000ms by default)
  39099. */
  39100. trackerDuration?: number);
  39101. /**
  39102. * Add a new optimization
  39103. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39104. * @returns the current SceneOptimizerOptions
  39105. */
  39106. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39107. /**
  39108. * Add a new custom optimization
  39109. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39110. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39111. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39112. * @returns the current SceneOptimizerOptions
  39113. */
  39114. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39115. /**
  39116. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39117. * @param targetFrameRate defines the target frame rate (60 by default)
  39118. * @returns a SceneOptimizerOptions object
  39119. */
  39120. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39121. /**
  39122. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39123. * @param targetFrameRate defines the target frame rate (60 by default)
  39124. * @returns a SceneOptimizerOptions object
  39125. */
  39126. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39127. /**
  39128. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39129. * @param targetFrameRate defines the target frame rate (60 by default)
  39130. * @returns a SceneOptimizerOptions object
  39131. */
  39132. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39133. }
  39134. /**
  39135. * Class used to run optimizations in order to reach a target frame rate
  39136. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39137. */
  39138. class SceneOptimizer implements IDisposable {
  39139. private _isRunning;
  39140. private _options;
  39141. private _scene;
  39142. private _currentPriorityLevel;
  39143. private _targetFrameRate;
  39144. private _trackerDuration;
  39145. private _currentFrameRate;
  39146. private _sceneDisposeObserver;
  39147. private _improvementMode;
  39148. /**
  39149. * Defines an observable called when the optimizer reaches the target frame rate
  39150. */
  39151. onSuccessObservable: Observable<SceneOptimizer>;
  39152. /**
  39153. * Defines an observable called when the optimizer enables an optimization
  39154. */
  39155. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39156. /**
  39157. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39158. */
  39159. onFailureObservable: Observable<SceneOptimizer>;
  39160. /**
  39161. * Gets a boolean indicating if the optimizer is in improvement mode
  39162. */
  39163. readonly isInImprovementMode: boolean;
  39164. /**
  39165. * Gets the current priority level (0 at start)
  39166. */
  39167. readonly currentPriorityLevel: number;
  39168. /**
  39169. * Gets the current frame rate checked by the SceneOptimizer
  39170. */
  39171. readonly currentFrameRate: number;
  39172. /**
  39173. * Gets or sets the current target frame rate (60 by default)
  39174. */
  39175. /**
  39176. * Gets or sets the current target frame rate (60 by default)
  39177. */
  39178. targetFrameRate: number;
  39179. /**
  39180. * Gets or sets the current interval between two checks (every 2000ms by default)
  39181. */
  39182. /**
  39183. * Gets or sets the current interval between two checks (every 2000ms by default)
  39184. */
  39185. trackerDuration: number;
  39186. /**
  39187. * Gets the list of active optimizations
  39188. */
  39189. readonly optimizations: SceneOptimization[];
  39190. /**
  39191. * Creates a new SceneOptimizer
  39192. * @param scene defines the scene to work on
  39193. * @param options defines the options to use with the SceneOptimizer
  39194. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39195. * @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)
  39196. */
  39197. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39198. /**
  39199. * Stops the current optimizer
  39200. */
  39201. stop(): void;
  39202. /**
  39203. * Reset the optimizer to initial step (current priority level = 0)
  39204. */
  39205. reset(): void;
  39206. /**
  39207. * Start the optimizer. By default it will try to reach a specific framerate
  39208. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39209. */
  39210. start(): void;
  39211. private _checkCurrentState;
  39212. /**
  39213. * Release all resources
  39214. */
  39215. dispose(): void;
  39216. /**
  39217. * Helper function to create a SceneOptimizer with one single line of code
  39218. * @param scene defines the scene to work on
  39219. * @param options defines the options to use with the SceneOptimizer
  39220. * @param onSuccess defines a callback to call on success
  39221. * @param onFailure defines a callback to call on failure
  39222. * @returns the new SceneOptimizer object
  39223. */
  39224. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39225. }
  39226. }
  39227. declare module BABYLON {
  39228. /**
  39229. * Class used to serialize a scene into a string
  39230. */
  39231. class SceneSerializer {
  39232. /**
  39233. * Clear cache used by a previous serialization
  39234. */
  39235. static ClearCache(): void;
  39236. /**
  39237. * Serialize a scene into a JSON compatible object
  39238. * @param scene defines the scene to serialize
  39239. * @returns a JSON compatible object
  39240. */
  39241. static Serialize(scene: Scene): any;
  39242. /**
  39243. * Serialize a mesh into a JSON compatible object
  39244. * @param toSerialize defines the mesh to serialize
  39245. * @param withParents defines if parents must be serialized as well
  39246. * @param withChildren defines if children must be serialized as well
  39247. * @returns a JSON compatible object
  39248. */
  39249. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39250. }
  39251. }
  39252. declare module BABYLON {
  39253. /**
  39254. * Defines an array and its length.
  39255. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39256. */
  39257. interface ISmartArrayLike<T> {
  39258. /**
  39259. * The data of the array.
  39260. */
  39261. data: Array<T>;
  39262. /**
  39263. * The active length of the array.
  39264. */
  39265. length: number;
  39266. }
  39267. /**
  39268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39269. */
  39270. class SmartArray<T> implements ISmartArrayLike<T> {
  39271. /**
  39272. * The full set of data from the array.
  39273. */
  39274. data: Array<T>;
  39275. /**
  39276. * The active length of the array.
  39277. */
  39278. length: number;
  39279. protected _id: number;
  39280. /**
  39281. * Instantiates a Smart Array.
  39282. * @param capacity defines the default capacity of the array.
  39283. */
  39284. constructor(capacity: number);
  39285. /**
  39286. * Pushes a value at the end of the active data.
  39287. * @param value defines the object to push in the array.
  39288. */
  39289. push(value: T): void;
  39290. /**
  39291. * Iterates over the active data and apply the lambda to them.
  39292. * @param func defines the action to apply on each value.
  39293. */
  39294. forEach(func: (content: T) => void): void;
  39295. /**
  39296. * Sorts the full sets of data.
  39297. * @param compareFn defines the comparison function to apply.
  39298. */
  39299. sort(compareFn: (a: T, b: T) => number): void;
  39300. /**
  39301. * Resets the active data to an empty array.
  39302. */
  39303. reset(): void;
  39304. /**
  39305. * Releases all the data from the array as well as the array.
  39306. */
  39307. dispose(): void;
  39308. /**
  39309. * Concats the active data with a given array.
  39310. * @param array defines the data to concatenate with.
  39311. */
  39312. concat(array: any): void;
  39313. /**
  39314. * Returns the position of a value in the active data.
  39315. * @param value defines the value to find the index for
  39316. * @returns the index if found in the active data otherwise -1
  39317. */
  39318. indexOf(value: T): number;
  39319. /**
  39320. * Returns whether an element is part of the active data.
  39321. * @param value defines the value to look for
  39322. * @returns true if found in the active data otherwise false
  39323. */
  39324. contains(value: T): boolean;
  39325. private static _GlobalId;
  39326. }
  39327. /**
  39328. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39329. * The data in this array can only be present once
  39330. */
  39331. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39332. private _duplicateId;
  39333. /**
  39334. * Pushes a value at the end of the active data.
  39335. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39336. * @param value defines the object to push in the array.
  39337. */
  39338. push(value: T): void;
  39339. /**
  39340. * Pushes a value at the end of the active data.
  39341. * If the data is already present, it won t be added again
  39342. * @param value defines the object to push in the array.
  39343. * @returns true if added false if it was already present
  39344. */
  39345. pushNoDuplicate(value: T): boolean;
  39346. /**
  39347. * Resets the active data to an empty array.
  39348. */
  39349. reset(): void;
  39350. /**
  39351. * Concats the active data with a given array.
  39352. * This ensures no dupplicate will be present in the result.
  39353. * @param array defines the data to concatenate with.
  39354. */
  39355. concatWithNoDuplicate(array: any): void;
  39356. }
  39357. }
  39358. declare module BABYLON {
  39359. /**
  39360. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39361. * The underlying implementation relies on an associative array to ensure the best performances.
  39362. * The value can be anything including 'null' but except 'undefined'
  39363. */
  39364. class StringDictionary<T> {
  39365. /**
  39366. * This will clear this dictionary and copy the content from the 'source' one.
  39367. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39368. * @param source the dictionary to take the content from and copy to this dictionary
  39369. */
  39370. copyFrom(source: StringDictionary<T>): void;
  39371. /**
  39372. * Get a value based from its key
  39373. * @param key the given key to get the matching value from
  39374. * @return the value if found, otherwise undefined is returned
  39375. */
  39376. get(key: string): T | undefined;
  39377. /**
  39378. * Get a value from its key or add it if it doesn't exist.
  39379. * This method will ensure you that a given key/data will be present in the dictionary.
  39380. * @param key the given key to get the matching value from
  39381. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39382. * The factory will only be invoked if there's no data for the given key.
  39383. * @return the value corresponding to the key.
  39384. */
  39385. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39386. /**
  39387. * Get a value from its key if present in the dictionary otherwise add it
  39388. * @param key the key to get the value from
  39389. * @param val if there's no such key/value pair in the dictionary add it with this value
  39390. * @return the value corresponding to the key
  39391. */
  39392. getOrAdd(key: string, val: T): T;
  39393. /**
  39394. * Check if there's a given key in the dictionary
  39395. * @param key the key to check for
  39396. * @return true if the key is present, false otherwise
  39397. */
  39398. contains(key: string): boolean;
  39399. /**
  39400. * Add a new key and its corresponding value
  39401. * @param key the key to add
  39402. * @param value the value corresponding to the key
  39403. * @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
  39404. */
  39405. add(key: string, value: T): boolean;
  39406. /**
  39407. * Update a specific value associated to a key
  39408. * @param key defines the key to use
  39409. * @param value defines the value to store
  39410. * @returns true if the value was updated (or false if the key was not found)
  39411. */
  39412. set(key: string, value: T): boolean;
  39413. /**
  39414. * Get the element of the given key and remove it from the dictionary
  39415. * @param key defines the key to search
  39416. * @returns the value associated with the key or null if not found
  39417. */
  39418. getAndRemove(key: string): Nullable<T>;
  39419. /**
  39420. * Remove a key/value from the dictionary.
  39421. * @param key the key to remove
  39422. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39423. */
  39424. remove(key: string): boolean;
  39425. /**
  39426. * Clear the whole content of the dictionary
  39427. */
  39428. clear(): void;
  39429. /**
  39430. * Gets the current count
  39431. */
  39432. readonly count: number;
  39433. /**
  39434. * Execute a callback on each key/val of the dictionary.
  39435. * Note that you can remove any element in this dictionary in the callback implementation
  39436. * @param callback the callback to execute on a given key/value pair
  39437. */
  39438. forEach(callback: (key: string, val: T) => void): void;
  39439. /**
  39440. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39441. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39442. * Note that you can remove any element in this dictionary in the callback implementation
  39443. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39444. * @returns the first item
  39445. */
  39446. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39447. private _count;
  39448. private _data;
  39449. }
  39450. }
  39451. declare module BABYLON {
  39452. /**
  39453. * Class used to store custom tags
  39454. */
  39455. class Tags {
  39456. /**
  39457. * Adds support for tags on the given object
  39458. * @param obj defines the object to use
  39459. */
  39460. static EnableFor(obj: any): void;
  39461. /**
  39462. * Removes tags support
  39463. * @param obj defines the object to use
  39464. */
  39465. static DisableFor(obj: any): void;
  39466. /**
  39467. * Gets a boolean indicating if the given object has tags
  39468. * @param obj defines the object to use
  39469. * @returns a boolean
  39470. */
  39471. static HasTags(obj: any): boolean;
  39472. /**
  39473. * Gets the tags available on a given object
  39474. * @param obj defines the object to use
  39475. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39476. * @returns the tags
  39477. */
  39478. static GetTags(obj: any, asString?: boolean): any;
  39479. /**
  39480. * Adds tags to an object
  39481. * @param obj defines the object to use
  39482. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39483. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39484. */
  39485. static AddTagsTo(obj: any, tagsString: string): void;
  39486. /**
  39487. * @hidden
  39488. */
  39489. static _AddTagTo(obj: any, tag: string): void;
  39490. /**
  39491. * Removes specific tags from a specific object
  39492. * @param obj defines the object to use
  39493. * @param tagsString defines the tags to remove
  39494. */
  39495. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39496. /**
  39497. * @hidden
  39498. */
  39499. static _RemoveTagFrom(obj: any, tag: string): void;
  39500. /**
  39501. * Defines if tags hosted on an object match a given query
  39502. * @param obj defines the object to use
  39503. * @param tagsQuery defines the tag query
  39504. * @returns a boolean
  39505. */
  39506. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39507. }
  39508. }
  39509. declare module BABYLON {
  39510. /**
  39511. * Class used to host texture specific utilities
  39512. */
  39513. class TextureTools {
  39514. /**
  39515. * Uses the GPU to create a copy texture rescaled at a given size
  39516. * @param texture Texture to copy from
  39517. * @param width defines the desired width
  39518. * @param height defines the desired height
  39519. * @param useBilinearMode defines if bilinear mode has to be used
  39520. * @return the generated texture
  39521. */
  39522. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39523. /**
  39524. * Gets an environment BRDF texture for a given scene
  39525. * @param scene defines the hosting scene
  39526. * @returns the environment BRDF texture
  39527. */
  39528. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39529. private static _environmentBRDFBase64Texture;
  39530. }
  39531. }
  39532. declare module BABYLON {
  39533. /**
  39534. * Based on jsTGALoader - Javascript loader for TGA file
  39535. * By Vincent Thibault
  39536. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39537. */
  39538. class TGATools {
  39539. private static _TYPE_INDEXED;
  39540. private static _TYPE_RGB;
  39541. private static _TYPE_GREY;
  39542. private static _TYPE_RLE_INDEXED;
  39543. private static _TYPE_RLE_RGB;
  39544. private static _TYPE_RLE_GREY;
  39545. private static _ORIGIN_MASK;
  39546. private static _ORIGIN_SHIFT;
  39547. private static _ORIGIN_BL;
  39548. private static _ORIGIN_BR;
  39549. private static _ORIGIN_UL;
  39550. private static _ORIGIN_UR;
  39551. /**
  39552. * Gets the header of a TGA file
  39553. * @param data defines the TGA data
  39554. * @returns the header
  39555. */
  39556. static GetTGAHeader(data: Uint8Array): any;
  39557. /**
  39558. * Uploads TGA content to a Babylon Texture
  39559. * @hidden
  39560. */
  39561. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39562. /** @hidden */
  39563. 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;
  39564. /** @hidden */
  39565. 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;
  39566. /** @hidden */
  39567. 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;
  39568. /** @hidden */
  39569. 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;
  39570. /** @hidden */
  39571. 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;
  39572. /** @hidden */
  39573. 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;
  39574. }
  39575. }
  39576. declare module BABYLON {
  39577. /**
  39578. * Interface for any object that can request an animation frame
  39579. */
  39580. interface ICustomAnimationFrameRequester {
  39581. /**
  39582. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39583. */
  39584. renderFunction?: Function;
  39585. /**
  39586. * Called to request the next frame to render to
  39587. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39588. */
  39589. requestAnimationFrame: Function;
  39590. /**
  39591. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39592. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39593. */
  39594. requestID?: number;
  39595. }
  39596. /**
  39597. * Interface containing an array of animations
  39598. */
  39599. interface IAnimatable {
  39600. /**
  39601. * Array of animations
  39602. */
  39603. animations: Array<Animation>;
  39604. }
  39605. /** Interface used by value gradients (color, factor, ...) */
  39606. interface IValueGradient {
  39607. /**
  39608. * Gets or sets the gradient value (between 0 and 1)
  39609. */
  39610. gradient: number;
  39611. }
  39612. /** Class used to store color4 gradient */
  39613. class ColorGradient implements IValueGradient {
  39614. /**
  39615. * Gets or sets the gradient value (between 0 and 1)
  39616. */
  39617. gradient: number;
  39618. /**
  39619. * Gets or sets first associated color
  39620. */
  39621. color1: Color4;
  39622. /**
  39623. * Gets or sets second associated color
  39624. */
  39625. color2?: Color4;
  39626. /**
  39627. * Will get a color picked randomly between color1 and color2.
  39628. * If color2 is undefined then color1 will be used
  39629. * @param result defines the target Color4 to store the result in
  39630. */
  39631. getColorToRef(result: Color4): void;
  39632. }
  39633. /** Class used to store color 3 gradient */
  39634. class Color3Gradient implements IValueGradient {
  39635. /**
  39636. * Gets or sets the gradient value (between 0 and 1)
  39637. */
  39638. gradient: number;
  39639. /**
  39640. * Gets or sets the associated color
  39641. */
  39642. color: Color3;
  39643. }
  39644. /** Class used to store factor gradient */
  39645. class FactorGradient implements IValueGradient {
  39646. /**
  39647. * Gets or sets the gradient value (between 0 and 1)
  39648. */
  39649. gradient: number;
  39650. /**
  39651. * Gets or sets first associated factor
  39652. */
  39653. factor1: number;
  39654. /**
  39655. * Gets or sets second associated factor
  39656. */
  39657. factor2?: number;
  39658. /**
  39659. * Will get a number picked randomly between factor1 and factor2.
  39660. * If factor2 is undefined then factor1 will be used
  39661. * @returns the picked number
  39662. */
  39663. getFactor(): number;
  39664. }
  39665. /**
  39666. * @ignore
  39667. * Application error to support additional information when loading a file
  39668. */
  39669. class LoadFileError extends Error {
  39670. /** defines the optional XHR request */
  39671. request?: XMLHttpRequest | undefined;
  39672. private static _setPrototypeOf;
  39673. /**
  39674. * Creates a new LoadFileError
  39675. * @param message defines the message of the error
  39676. * @param request defines the optional XHR request
  39677. */
  39678. constructor(message: string,
  39679. /** defines the optional XHR request */
  39680. request?: XMLHttpRequest | undefined);
  39681. }
  39682. /**
  39683. * Class used to define a retry strategy when error happens while loading assets
  39684. */
  39685. class RetryStrategy {
  39686. /**
  39687. * Function used to defines an exponential back off strategy
  39688. * @param maxRetries defines the maximum number of retries (3 by default)
  39689. * @param baseInterval defines the interval between retries
  39690. * @returns the strategy function to use
  39691. */
  39692. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39693. }
  39694. /**
  39695. * File request interface
  39696. */
  39697. interface IFileRequest {
  39698. /**
  39699. * Raised when the request is complete (success or error).
  39700. */
  39701. onCompleteObservable: Observable<IFileRequest>;
  39702. /**
  39703. * Aborts the request for a file.
  39704. */
  39705. abort: () => void;
  39706. }
  39707. /**
  39708. * Class containing a set of static utilities functions
  39709. */
  39710. class Tools {
  39711. /**
  39712. * Gets or sets the base URL to use to load assets
  39713. */
  39714. static BaseUrl: string;
  39715. /**
  39716. * Enable/Disable Custom HTTP Request Headers globally.
  39717. * default = false
  39718. * @see CustomRequestHeaders
  39719. */
  39720. static UseCustomRequestHeaders: boolean;
  39721. /**
  39722. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39723. * i.e. when loading files, where the server/service expects an Authorization header.
  39724. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39725. */
  39726. static CustomRequestHeaders: {
  39727. [key: string]: string;
  39728. };
  39729. /**
  39730. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39731. */
  39732. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39733. /**
  39734. * Default behaviour for cors in the application.
  39735. * It can be a string if the expected behavior is identical in the entire app.
  39736. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39737. */
  39738. static CorsBehavior: string | ((url: string | string[]) => string);
  39739. /**
  39740. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39741. * @ignorenaming
  39742. */
  39743. static UseFallbackTexture: boolean;
  39744. /**
  39745. * Use this object to register external classes like custom textures or material
  39746. * to allow the laoders to instantiate them
  39747. */
  39748. static RegisteredExternalClasses: {
  39749. [key: string]: Object;
  39750. };
  39751. /**
  39752. * Texture content used if a texture cannot loaded
  39753. * @ignorenaming
  39754. */
  39755. static fallbackTexture: string;
  39756. /**
  39757. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39758. * @param u defines the coordinate on X axis
  39759. * @param v defines the coordinate on Y axis
  39760. * @param width defines the width of the source data
  39761. * @param height defines the height of the source data
  39762. * @param pixels defines the source byte array
  39763. * @param color defines the output color
  39764. */
  39765. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39766. /**
  39767. * Interpolates between a and b via alpha
  39768. * @param a The lower value (returned when alpha = 0)
  39769. * @param b The upper value (returned when alpha = 1)
  39770. * @param alpha The interpolation-factor
  39771. * @return The mixed value
  39772. */
  39773. static Mix(a: number, b: number, alpha: number): number;
  39774. /**
  39775. * Tries to instantiate a new object from a given class name
  39776. * @param className defines the class name to instantiate
  39777. * @returns the new object or null if the system was not able to do the instantiation
  39778. */
  39779. static Instantiate(className: string): any;
  39780. /**
  39781. * Provides a slice function that will work even on IE
  39782. * @param data defines the array to slice
  39783. * @param start defines the start of the data (optional)
  39784. * @param end defines the end of the data (optional)
  39785. * @returns the new sliced array
  39786. */
  39787. static Slice<T>(data: T, start?: number, end?: number): T;
  39788. /**
  39789. * Polyfill for setImmediate
  39790. * @param action defines the action to execute after the current execution block
  39791. */
  39792. static SetImmediate(action: () => void): void;
  39793. /**
  39794. * Function indicating if a number is an exponent of 2
  39795. * @param value defines the value to test
  39796. * @returns true if the value is an exponent of 2
  39797. */
  39798. static IsExponentOfTwo(value: number): boolean;
  39799. private static _tmpFloatArray;
  39800. /**
  39801. * Returns the nearest 32-bit single precision float representation of a Number
  39802. * @param value A Number. If the parameter is of a different type, it will get converted
  39803. * to a number or to NaN if it cannot be converted
  39804. * @returns number
  39805. */
  39806. static FloatRound(value: number): number;
  39807. /**
  39808. * Find the next highest power of two.
  39809. * @param x Number to start search from.
  39810. * @return Next highest power of two.
  39811. */
  39812. static CeilingPOT(x: number): number;
  39813. /**
  39814. * Find the next lowest power of two.
  39815. * @param x Number to start search from.
  39816. * @return Next lowest power of two.
  39817. */
  39818. static FloorPOT(x: number): number;
  39819. /**
  39820. * Find the nearest power of two.
  39821. * @param x Number to start search from.
  39822. * @return Next nearest power of two.
  39823. */
  39824. static NearestPOT(x: number): number;
  39825. /**
  39826. * Get the closest exponent of two
  39827. * @param value defines the value to approximate
  39828. * @param max defines the maximum value to return
  39829. * @param mode defines how to define the closest value
  39830. * @returns closest exponent of two of the given value
  39831. */
  39832. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39833. /**
  39834. * Extracts the filename from a path
  39835. * @param path defines the path to use
  39836. * @returns the filename
  39837. */
  39838. static GetFilename(path: string): string;
  39839. /**
  39840. * Extracts the "folder" part of a path (everything before the filename).
  39841. * @param uri The URI to extract the info from
  39842. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39843. * @returns The "folder" part of the path
  39844. */
  39845. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39846. /**
  39847. * Extracts text content from a DOM element hierarchy
  39848. * @param element defines the root element
  39849. * @returns a string
  39850. */
  39851. static GetDOMTextContent(element: HTMLElement): string;
  39852. /**
  39853. * Convert an angle in radians to degrees
  39854. * @param angle defines the angle to convert
  39855. * @returns the angle in degrees
  39856. */
  39857. static ToDegrees(angle: number): number;
  39858. /**
  39859. * Convert an angle in degrees to radians
  39860. * @param angle defines the angle to convert
  39861. * @returns the angle in radians
  39862. */
  39863. static ToRadians(angle: number): number;
  39864. /**
  39865. * Encode a buffer to a base64 string
  39866. * @param buffer defines the buffer to encode
  39867. * @returns the encoded string
  39868. */
  39869. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39870. /**
  39871. * Extracts minimum and maximum values from a list of indexed positions
  39872. * @param positions defines the positions to use
  39873. * @param indices defines the indices to the positions
  39874. * @param indexStart defines the start index
  39875. * @param indexCount defines the end index
  39876. * @param bias defines bias value to add to the result
  39877. * @return minimum and maximum values
  39878. */
  39879. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39880. minimum: Vector3;
  39881. maximum: Vector3;
  39882. };
  39883. /**
  39884. * Extracts minimum and maximum values from a list of positions
  39885. * @param positions defines the positions to use
  39886. * @param start defines the start index in the positions array
  39887. * @param count defines the number of positions to handle
  39888. * @param bias defines bias value to add to the result
  39889. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39890. * @return minimum and maximum values
  39891. */
  39892. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39893. minimum: Vector3;
  39894. maximum: Vector3;
  39895. };
  39896. /**
  39897. * Returns an array if obj is not an array
  39898. * @param obj defines the object to evaluate as an array
  39899. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39900. * @returns either obj directly if obj is an array or a new array containing obj
  39901. */
  39902. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39903. /**
  39904. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39905. * @param size the number of element to construct and put in the array
  39906. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39907. * @returns a new array filled with new objects
  39908. */
  39909. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39910. /**
  39911. * Gets the pointer prefix to use
  39912. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39913. */
  39914. static GetPointerPrefix(): string;
  39915. /**
  39916. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39917. * @param func - the function to be called
  39918. * @param requester - the object that will request the next frame. Falls back to window.
  39919. * @returns frame number
  39920. */
  39921. static QueueNewFrame(func: () => void, requester?: any): number;
  39922. /**
  39923. * Ask the browser to promote the current element to fullscreen rendering mode
  39924. * @param element defines the DOM element to promote
  39925. */
  39926. static RequestFullscreen(element: HTMLElement): void;
  39927. /**
  39928. * Asks the browser to exit fullscreen mode
  39929. */
  39930. static ExitFullscreen(): void;
  39931. /**
  39932. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39933. * @param url define the url we are trying
  39934. * @param element define the dom element where to configure the cors policy
  39935. */
  39936. static SetCorsBehavior(url: string | string[], element: {
  39937. crossOrigin: string | null;
  39938. }): void;
  39939. /**
  39940. * Removes unwanted characters from an url
  39941. * @param url defines the url to clean
  39942. * @returns the cleaned url
  39943. */
  39944. static CleanUrl(url: string): string;
  39945. /**
  39946. * Gets or sets a function used to pre-process url before using them to load assets
  39947. */
  39948. static PreprocessUrl: (url: string) => string;
  39949. /**
  39950. * Loads an image as an HTMLImageElement.
  39951. * @param input url string, ArrayBuffer, or Blob to load
  39952. * @param onLoad callback called when the image successfully loads
  39953. * @param onError callback called when the image fails to load
  39954. * @param offlineProvider offline provider for caching
  39955. * @returns the HTMLImageElement of the loaded image
  39956. */
  39957. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39958. /**
  39959. * Loads a file
  39960. * @param url url string, ArrayBuffer, or Blob to load
  39961. * @param onSuccess callback called when the file successfully loads
  39962. * @param onProgress callback called while file is loading (if the server supports this mode)
  39963. * @param offlineProvider defines the offline provider for caching
  39964. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39965. * @param onError callback called when the file fails to load
  39966. * @returns a file request object
  39967. */
  39968. 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;
  39969. /**
  39970. * Load a script (identified by an url). When the url returns, the
  39971. * content of this file is added into a new script element, attached to the DOM (body element)
  39972. * @param scriptUrl defines the url of the script to laod
  39973. * @param onSuccess defines the callback called when the script is loaded
  39974. * @param onError defines the callback to call if an error occurs
  39975. */
  39976. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39977. /**
  39978. * Loads a file from a blob
  39979. * @param fileToLoad defines the blob to use
  39980. * @param callback defines the callback to call when data is loaded
  39981. * @param progressCallback defines the callback to call during loading process
  39982. * @returns a file request object
  39983. */
  39984. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39985. /**
  39986. * Loads a file
  39987. * @param fileToLoad defines the file to load
  39988. * @param callback defines the callback to call when data is loaded
  39989. * @param progressCallBack defines the callback to call during loading process
  39990. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39991. * @returns a file request object
  39992. */
  39993. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39994. /**
  39995. * Creates a data url from a given string content
  39996. * @param content defines the content to convert
  39997. * @returns the new data url link
  39998. */
  39999. static FileAsURL(content: string): string;
  40000. /**
  40001. * Format the given number to a specific decimal format
  40002. * @param value defines the number to format
  40003. * @param decimals defines the number of decimals to use
  40004. * @returns the formatted string
  40005. */
  40006. static Format(value: number, decimals?: number): string;
  40007. /**
  40008. * Checks if a given vector is inside a specific range
  40009. * @param v defines the vector to test
  40010. * @param min defines the minimum range
  40011. * @param max defines the maximum range
  40012. */
  40013. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  40014. /**
  40015. * Tries to copy an object by duplicating every property
  40016. * @param source defines the source object
  40017. * @param destination defines the target object
  40018. * @param doNotCopyList defines a list of properties to avoid
  40019. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  40020. */
  40021. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  40022. /**
  40023. * Gets a boolean indicating if the given object has no own property
  40024. * @param obj defines the object to test
  40025. * @returns true if object has no own property
  40026. */
  40027. static IsEmpty(obj: any): boolean;
  40028. /**
  40029. * Function used to register events at window level
  40030. * @param events defines the events to register
  40031. */
  40032. static RegisterTopRootEvents(events: {
  40033. name: string;
  40034. handler: Nullable<(e: FocusEvent) => any>;
  40035. }[]): void;
  40036. /**
  40037. * Function used to unregister events from window level
  40038. * @param events defines the events to unregister
  40039. */
  40040. static UnregisterTopRootEvents(events: {
  40041. name: string;
  40042. handler: Nullable<(e: FocusEvent) => any>;
  40043. }[]): void;
  40044. /**
  40045. * Dumps the current bound framebuffer
  40046. * @param width defines the rendering width
  40047. * @param height defines the rendering height
  40048. * @param engine defines the hosting engine
  40049. * @param successCallback defines the callback triggered once the data are available
  40050. * @param mimeType defines the mime type of the result
  40051. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40052. */
  40053. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40054. /**
  40055. * Converts the canvas data to blob.
  40056. * This acts as a polyfill for browsers not supporting the to blob function.
  40057. * @param canvas Defines the canvas to extract the data from
  40058. * @param successCallback Defines the callback triggered once the data are available
  40059. * @param mimeType Defines the mime type of the result
  40060. */
  40061. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40062. /**
  40063. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40064. * @param successCallback defines the callback triggered once the data are available
  40065. * @param mimeType defines the mime type of the result
  40066. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40067. */
  40068. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40069. /**
  40070. * Downloads a blob in the browser
  40071. * @param blob defines the blob to download
  40072. * @param fileName defines the name of the downloaded file
  40073. */
  40074. static Download(blob: Blob, fileName: string): void;
  40075. /**
  40076. * Captures a screenshot of the current rendering
  40077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40078. * @param engine defines the rendering engine
  40079. * @param camera defines the source camera
  40080. * @param size This parameter can be set to a single number or to an object with the
  40081. * following (optional) properties: precision, width, height. If a single number is passed,
  40082. * it will be used for both width and height. If an object is passed, the screenshot size
  40083. * will be derived from the parameters. The precision property is a multiplier allowing
  40084. * rendering at a higher or lower resolution
  40085. * @param successCallback defines the callback receives a single parameter which contains the
  40086. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40087. * src parameter of an <img> to display it
  40088. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40089. * Check your browser for supported MIME types
  40090. */
  40091. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  40092. /**
  40093. * Generates an image screenshot from the specified camera.
  40094. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40095. * @param engine The engine to use for rendering
  40096. * @param camera The camera to use for rendering
  40097. * @param size This parameter can be set to a single number or to an object with the
  40098. * following (optional) properties: precision, width, height. If a single number is passed,
  40099. * it will be used for both width and height. If an object is passed, the screenshot size
  40100. * will be derived from the parameters. The precision property is a multiplier allowing
  40101. * rendering at a higher or lower resolution
  40102. * @param successCallback The callback receives a single parameter which contains the
  40103. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40104. * src parameter of an <img> to display it
  40105. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40106. * Check your browser for supported MIME types
  40107. * @param samples Texture samples (default: 1)
  40108. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40109. * @param fileName A name for for the downloaded file.
  40110. */
  40111. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40112. /**
  40113. * Validates if xhr data is correct
  40114. * @param xhr defines the request to validate
  40115. * @param dataType defines the expected data type
  40116. * @returns true if data is correct
  40117. */
  40118. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40119. /**
  40120. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40121. * Be aware Math.random() could cause collisions, but:
  40122. * "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"
  40123. * @returns a pseudo random id
  40124. */
  40125. static RandomId(): string;
  40126. /**
  40127. * Test if the given uri is a base64 string
  40128. * @param uri The uri to test
  40129. * @return True if the uri is a base64 string or false otherwise
  40130. */
  40131. static IsBase64(uri: string): boolean;
  40132. /**
  40133. * Decode the given base64 uri.
  40134. * @param uri The uri to decode
  40135. * @return The decoded base64 data.
  40136. */
  40137. static DecodeBase64(uri: string): ArrayBuffer;
  40138. /**
  40139. * No log
  40140. */
  40141. static readonly NoneLogLevel: number;
  40142. /**
  40143. * Only message logs
  40144. */
  40145. static readonly MessageLogLevel: number;
  40146. /**
  40147. * Only warning logs
  40148. */
  40149. static readonly WarningLogLevel: number;
  40150. /**
  40151. * Only error logs
  40152. */
  40153. static readonly ErrorLogLevel: number;
  40154. /**
  40155. * All logs
  40156. */
  40157. static readonly AllLogLevel: number;
  40158. private static _LogCache;
  40159. /**
  40160. * Gets a value indicating the number of loading errors
  40161. * @ignorenaming
  40162. */
  40163. static errorsCount: number;
  40164. /**
  40165. * Callback called when a new log is added
  40166. */
  40167. static OnNewCacheEntry: (entry: string) => void;
  40168. private static _AddLogEntry;
  40169. private static _FormatMessage;
  40170. private static _LogDisabled;
  40171. private static _LogEnabled;
  40172. private static _WarnDisabled;
  40173. private static _WarnEnabled;
  40174. private static _ErrorDisabled;
  40175. private static _ErrorEnabled;
  40176. /**
  40177. * Log a message to the console
  40178. */
  40179. static Log: (message: string) => void;
  40180. /**
  40181. * Write a warning message to the console
  40182. */
  40183. static Warn: (message: string) => void;
  40184. /**
  40185. * Write an error message to the console
  40186. */
  40187. static Error: (message: string) => void;
  40188. /**
  40189. * Gets current log cache (list of logs)
  40190. */
  40191. static readonly LogCache: string;
  40192. /**
  40193. * Clears the log cache
  40194. */
  40195. static ClearLogCache(): void;
  40196. /**
  40197. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40198. */
  40199. static LogLevels: number;
  40200. /**
  40201. * Checks if the loaded document was accessed via `file:`-Protocol.
  40202. * @returns boolean
  40203. */
  40204. static IsFileURL(): boolean;
  40205. /**
  40206. * Checks if the window object exists
  40207. * @returns true if the window object exists
  40208. */
  40209. static IsWindowObjectExist(): boolean;
  40210. /**
  40211. * No performance log
  40212. */
  40213. static readonly PerformanceNoneLogLevel: number;
  40214. /**
  40215. * Use user marks to log performance
  40216. */
  40217. static readonly PerformanceUserMarkLogLevel: number;
  40218. /**
  40219. * Log performance to the console
  40220. */
  40221. static readonly PerformanceConsoleLogLevel: number;
  40222. private static _performance;
  40223. /**
  40224. * Sets the current performance log level
  40225. */
  40226. static PerformanceLogLevel: number;
  40227. private static _StartPerformanceCounterDisabled;
  40228. private static _EndPerformanceCounterDisabled;
  40229. private static _StartUserMark;
  40230. private static _EndUserMark;
  40231. private static _StartPerformanceConsole;
  40232. private static _EndPerformanceConsole;
  40233. /**
  40234. * Injects the @see CustomRequestHeaders into the given request
  40235. * @param request the request that should be used for injection
  40236. */
  40237. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40238. /**
  40239. * Starts a performance counter
  40240. */
  40241. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40242. /**
  40243. * Ends a specific performance coutner
  40244. */
  40245. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40246. /**
  40247. * Gets either window.performance.now() if supported or Date.now() else
  40248. */
  40249. static readonly Now: number;
  40250. /**
  40251. * This method will return the name of the class used to create the instance of the given object.
  40252. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40253. * @param object the object to get the class name from
  40254. * @param isType defines if the object is actually a type
  40255. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40256. */
  40257. static GetClassName(object: any, isType?: boolean): string;
  40258. /**
  40259. * Gets the first element of an array satisfying a given predicate
  40260. * @param array defines the array to browse
  40261. * @param predicate defines the predicate to use
  40262. * @returns null if not found or the element
  40263. */
  40264. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40265. /**
  40266. * This method will return the name of the full name of the class, including its owning module (if any).
  40267. * 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).
  40268. * @param object the object to get the class name from
  40269. * @param isType defines if the object is actually a type
  40270. * @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.
  40271. * @ignorenaming
  40272. */
  40273. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40274. /**
  40275. * Returns a promise that resolves after the given amount of time.
  40276. * @param delay Number of milliseconds to delay
  40277. * @returns Promise that resolves after the given amount of time
  40278. */
  40279. static DelayAsync(delay: number): Promise<void>;
  40280. /**
  40281. * Gets the current gradient from an array of IValueGradient
  40282. * @param ratio defines the current ratio to get
  40283. * @param gradients defines the array of IValueGradient
  40284. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40285. */
  40286. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40287. }
  40288. /**
  40289. * This class is used to track a performance counter which is number based.
  40290. * The user has access to many properties which give statistics of different nature.
  40291. *
  40292. * The implementer can track two kinds of Performance Counter: time and count.
  40293. * 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.
  40294. * 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.
  40295. */
  40296. class PerfCounter {
  40297. /**
  40298. * Gets or sets a global boolean to turn on and off all the counters
  40299. */
  40300. static Enabled: boolean;
  40301. /**
  40302. * Returns the smallest value ever
  40303. */
  40304. readonly min: number;
  40305. /**
  40306. * Returns the biggest value ever
  40307. */
  40308. readonly max: number;
  40309. /**
  40310. * Returns the average value since the performance counter is running
  40311. */
  40312. readonly average: number;
  40313. /**
  40314. * Returns the average value of the last second the counter was monitored
  40315. */
  40316. readonly lastSecAverage: number;
  40317. /**
  40318. * Returns the current value
  40319. */
  40320. readonly current: number;
  40321. /**
  40322. * Gets the accumulated total
  40323. */
  40324. readonly total: number;
  40325. /**
  40326. * Gets the total value count
  40327. */
  40328. readonly count: number;
  40329. /**
  40330. * Creates a new counter
  40331. */
  40332. constructor();
  40333. /**
  40334. * Call this method to start monitoring a new frame.
  40335. * 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.
  40336. */
  40337. fetchNewFrame(): void;
  40338. /**
  40339. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40340. * @param newCount the count value to add to the monitored count
  40341. * @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.
  40342. */
  40343. addCount(newCount: number, fetchResult: boolean): void;
  40344. /**
  40345. * Start monitoring this performance counter
  40346. */
  40347. beginMonitoring(): void;
  40348. /**
  40349. * Compute the time lapsed since the previous beginMonitoring() call.
  40350. * @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
  40351. */
  40352. endMonitoring(newFrame?: boolean): void;
  40353. private _fetchResult;
  40354. private _startMonitoringTime;
  40355. private _min;
  40356. private _max;
  40357. private _average;
  40358. private _current;
  40359. private _totalValueCount;
  40360. private _totalAccumulated;
  40361. private _lastSecAverage;
  40362. private _lastSecAccumulated;
  40363. private _lastSecTime;
  40364. private _lastSecValueCount;
  40365. }
  40366. /**
  40367. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40368. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40369. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40370. * @param name The name of the class, case should be preserved
  40371. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40372. */
  40373. function className(name: string, module?: string): (target: Object) => void;
  40374. /**
  40375. * An implementation of a loop for asynchronous functions.
  40376. */
  40377. class AsyncLoop {
  40378. /**
  40379. * Defines the number of iterations for the loop
  40380. */
  40381. iterations: number;
  40382. /**
  40383. * Defines the current index of the loop.
  40384. */
  40385. index: number;
  40386. private _done;
  40387. private _fn;
  40388. private _successCallback;
  40389. /**
  40390. * Constructor.
  40391. * @param iterations the number of iterations.
  40392. * @param func the function to run each iteration
  40393. * @param successCallback the callback that will be called upon succesful execution
  40394. * @param offset starting offset.
  40395. */
  40396. constructor(
  40397. /**
  40398. * Defines the number of iterations for the loop
  40399. */
  40400. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40401. /**
  40402. * Execute the next iteration. Must be called after the last iteration was finished.
  40403. */
  40404. executeNext(): void;
  40405. /**
  40406. * Break the loop and run the success callback.
  40407. */
  40408. breakLoop(): void;
  40409. /**
  40410. * Create and run an async loop.
  40411. * @param iterations the number of iterations.
  40412. * @param fn the function to run each iteration
  40413. * @param successCallback the callback that will be called upon succesful execution
  40414. * @param offset starting offset.
  40415. * @returns the created async loop object
  40416. */
  40417. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40418. /**
  40419. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40420. * @param iterations total number of iterations
  40421. * @param syncedIterations number of synchronous iterations in each async iteration.
  40422. * @param fn the function to call each iteration.
  40423. * @param callback a success call back that will be called when iterating stops.
  40424. * @param breakFunction a break condition (optional)
  40425. * @param timeout timeout settings for the setTimeout function. default - 0.
  40426. * @returns the created async loop object
  40427. */
  40428. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40429. }
  40430. }
  40431. interface HTMLCanvasElement {
  40432. /** Track wether a record is in progress */
  40433. isRecording: boolean;
  40434. /** Capture Stream method defined by some browsers */
  40435. captureStream(fps?: number): MediaStream;
  40436. }
  40437. interface MediaRecorder {
  40438. /** Starts recording */
  40439. start(timeSlice: number): void;
  40440. /** Stops recording */
  40441. stop(): void;
  40442. /** Event raised when an error arised. */
  40443. onerror: (event: ErrorEvent) => void;
  40444. /** Event raised when the recording stops. */
  40445. onstop: (event: Event) => void;
  40446. /** Event raised when a new chunk of data is available and should be tracked. */
  40447. ondataavailable: (event: Event) => void;
  40448. }
  40449. interface MediaRecorderOptions {
  40450. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40451. mimeType?: string;
  40452. /** The chosen bitrate for the audio component of the media. */
  40453. audioBitsPerSecond?: number;
  40454. /** The chosen bitrate for the video component of the media. */
  40455. videoBitsPerSecond?: number;
  40456. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  40457. bitsPerSecond?: number;
  40458. }
  40459. interface MediaRecorderConstructor {
  40460. /**
  40461. * A reference to the prototype.
  40462. */
  40463. readonly prototype: MediaRecorder;
  40464. /**
  40465. * Creates a new MediaRecorder.
  40466. * @param stream Defines the stream to record.
  40467. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40468. */
  40469. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40470. }
  40471. /**
  40472. * MediaRecoreder object available in some browsers.
  40473. */
  40474. declare var MediaRecorder: MediaRecorderConstructor;
  40475. declare module BABYLON {
  40476. /**
  40477. * This represents the different options avilable for the video capture.
  40478. */
  40479. interface VideoRecorderOptions {
  40480. /** Defines the mime type of the video */
  40481. mimeType: string;
  40482. /** Defines the video the video should be recorded at */
  40483. fps: number;
  40484. /** Defines the chunk size for the recording data */
  40485. recordChunckSize: number;
  40486. }
  40487. /**
  40488. * This can helps recording videos from BabylonJS.
  40489. * This is based on the available WebRTC functionalities of the browser.
  40490. *
  40491. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40492. */
  40493. class VideoRecorder {
  40494. private static readonly _defaultOptions;
  40495. /**
  40496. * Returns wehther or not the VideoRecorder is available in your browser.
  40497. * @param engine Defines the Babylon Engine to check the support for
  40498. * @returns true if supported otherwise false
  40499. */
  40500. static IsSupported(engine: Engine): boolean;
  40501. private readonly _options;
  40502. private _canvas;
  40503. private _mediaRecorder;
  40504. private _recordedChunks;
  40505. private _fileName;
  40506. private _resolve;
  40507. private _reject;
  40508. /**
  40509. * True wether a recording is already in progress.
  40510. */
  40511. readonly isRecording: boolean;
  40512. /**
  40513. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40514. * a video file.
  40515. * @param engine Defines the BabylonJS Engine you wish to record
  40516. * @param options Defines options that can be used to customized the capture
  40517. */
  40518. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40519. /**
  40520. * Stops the current recording before the default capture timeout passed in the startRecording
  40521. * functions.
  40522. */
  40523. stopRecording(): void;
  40524. /**
  40525. * Starts recording the canvas for a max duration specified in parameters.
  40526. * @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.
  40527. * @param maxDuration Defines the maximum recording time in seconds.
  40528. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40529. * @return a promise callback at the end of the recording with the video data in Blob.
  40530. */
  40531. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40532. /**
  40533. * Releases internal resources used during the recording.
  40534. */
  40535. dispose(): void;
  40536. private _handleDataAvailable;
  40537. private _handleError;
  40538. private _handleStop;
  40539. }
  40540. }
  40541. declare module BABYLON {
  40542. /**
  40543. * Defines the potential axis of a Joystick
  40544. */
  40545. enum JoystickAxis {
  40546. /** X axis */
  40547. X = 0,
  40548. /** Y axis */
  40549. Y = 1,
  40550. /** Z axis */
  40551. Z = 2
  40552. }
  40553. /**
  40554. * Class used to define virtual joystick (used in touch mode)
  40555. */
  40556. class VirtualJoystick {
  40557. /**
  40558. * Gets or sets a boolean indicating that left and right values must be inverted
  40559. */
  40560. reverseLeftRight: boolean;
  40561. /**
  40562. * Gets or sets a boolean indicating that up and down values must be inverted
  40563. */
  40564. reverseUpDown: boolean;
  40565. /**
  40566. * Gets the offset value for the position (ie. the change of the position value)
  40567. */
  40568. deltaPosition: Vector3;
  40569. /**
  40570. * Gets a boolean indicating if the virtual joystick was pressed
  40571. */
  40572. pressed: boolean;
  40573. /**
  40574. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40575. */
  40576. static Canvas: Nullable<HTMLCanvasElement>;
  40577. private static _globalJoystickIndex;
  40578. private static vjCanvasContext;
  40579. private static vjCanvasWidth;
  40580. private static vjCanvasHeight;
  40581. private static halfWidth;
  40582. private _action;
  40583. private _axisTargetedByLeftAndRight;
  40584. private _axisTargetedByUpAndDown;
  40585. private _joystickSensibility;
  40586. private _inversedSensibility;
  40587. private _joystickPointerID;
  40588. private _joystickColor;
  40589. private _joystickPointerPos;
  40590. private _joystickPreviousPointerPos;
  40591. private _joystickPointerStartPos;
  40592. private _deltaJoystickVector;
  40593. private _leftJoystick;
  40594. private _touches;
  40595. private _onPointerDownHandlerRef;
  40596. private _onPointerMoveHandlerRef;
  40597. private _onPointerUpHandlerRef;
  40598. private _onResize;
  40599. /**
  40600. * Creates a new virtual joystick
  40601. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40602. */
  40603. constructor(leftJoystick?: boolean);
  40604. /**
  40605. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40606. * @param newJoystickSensibility defines the new sensibility
  40607. */
  40608. setJoystickSensibility(newJoystickSensibility: number): void;
  40609. private _onPointerDown;
  40610. private _onPointerMove;
  40611. private _onPointerUp;
  40612. /**
  40613. * Change the color of the virtual joystick
  40614. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40615. */
  40616. setJoystickColor(newColor: string): void;
  40617. /**
  40618. * Defines a callback to call when the joystick is touched
  40619. * @param action defines the callback
  40620. */
  40621. setActionOnTouch(action: () => any): void;
  40622. /**
  40623. * Defines which axis you'd like to control for left & right
  40624. * @param axis defines the axis to use
  40625. */
  40626. setAxisForLeftRight(axis: JoystickAxis): void;
  40627. /**
  40628. * Defines which axis you'd like to control for up & down
  40629. * @param axis defines the axis to use
  40630. */
  40631. setAxisForUpDown(axis: JoystickAxis): void;
  40632. private _drawVirtualJoystick;
  40633. /**
  40634. * Release internal HTML canvas
  40635. */
  40636. releaseCanvas(): void;
  40637. }
  40638. }
  40639. declare module BABYLON {
  40640. /**
  40641. * Helper class to push actions to a pool of workers.
  40642. */
  40643. class WorkerPool implements IDisposable {
  40644. private _workerInfos;
  40645. private _pendingActions;
  40646. /**
  40647. * Constructor
  40648. * @param workers Array of workers to use for actions
  40649. */
  40650. constructor(workers: Array<Worker>);
  40651. /**
  40652. * Terminates all workers and clears any pending actions.
  40653. */
  40654. dispose(): void;
  40655. /**
  40656. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40657. * pended until a worker has completed its action.
  40658. * @param action The action to perform. Call onComplete when the action is complete.
  40659. */
  40660. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40661. private _execute;
  40662. }
  40663. }
  40664. declare module BABYLON {
  40665. /**
  40666. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40667. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40668. */
  40669. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40670. /**
  40671. * Gets the name of the behavior.
  40672. */
  40673. readonly name: string;
  40674. private _zoomStopsAnimation;
  40675. private _idleRotationSpeed;
  40676. private _idleRotationWaitTime;
  40677. private _idleRotationSpinupTime;
  40678. /**
  40679. * Sets the flag that indicates if user zooming should stop animation.
  40680. */
  40681. /**
  40682. * Gets the flag that indicates if user zooming should stop animation.
  40683. */
  40684. zoomStopsAnimation: boolean;
  40685. /**
  40686. * Sets the default speed at which the camera rotates around the model.
  40687. */
  40688. /**
  40689. * Gets the default speed at which the camera rotates around the model.
  40690. */
  40691. idleRotationSpeed: number;
  40692. /**
  40693. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40694. */
  40695. /**
  40696. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40697. */
  40698. idleRotationWaitTime: number;
  40699. /**
  40700. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40701. */
  40702. /**
  40703. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40704. */
  40705. idleRotationSpinupTime: number;
  40706. /**
  40707. * Gets a value indicating if the camera is currently rotating because of this behavior
  40708. */
  40709. readonly rotationInProgress: boolean;
  40710. private _onPrePointerObservableObserver;
  40711. private _onAfterCheckInputsObserver;
  40712. private _attachedCamera;
  40713. private _isPointerDown;
  40714. private _lastFrameTime;
  40715. private _lastInteractionTime;
  40716. private _cameraRotationSpeed;
  40717. /**
  40718. * Initializes the behavior.
  40719. */
  40720. init(): void;
  40721. /**
  40722. * Attaches the behavior to its arc rotate camera.
  40723. * @param camera Defines the camera to attach the behavior to
  40724. */
  40725. attach(camera: ArcRotateCamera): void;
  40726. /**
  40727. * Detaches the behavior from its current arc rotate camera.
  40728. */
  40729. detach(): void;
  40730. /**
  40731. * Returns true if user is scrolling.
  40732. * @return true if user is scrolling.
  40733. */
  40734. private _userIsZooming;
  40735. private _lastFrameRadius;
  40736. private _shouldAnimationStopForInteraction;
  40737. /**
  40738. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40739. */
  40740. private _applyUserInteraction;
  40741. private _userIsMoving;
  40742. }
  40743. }
  40744. declare module BABYLON {
  40745. /**
  40746. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40748. */
  40749. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40750. /**
  40751. * Gets the name of the behavior.
  40752. */
  40753. readonly name: string;
  40754. /**
  40755. * The easing function used by animations
  40756. */
  40757. static EasingFunction: BackEase;
  40758. /**
  40759. * The easing mode used by animations
  40760. */
  40761. static EasingMode: number;
  40762. /**
  40763. * The duration of the animation, in milliseconds
  40764. */
  40765. transitionDuration: number;
  40766. /**
  40767. * Length of the distance animated by the transition when lower radius is reached
  40768. */
  40769. lowerRadiusTransitionRange: number;
  40770. /**
  40771. * Length of the distance animated by the transition when upper radius is reached
  40772. */
  40773. upperRadiusTransitionRange: number;
  40774. private _autoTransitionRange;
  40775. /**
  40776. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40777. */
  40778. /**
  40779. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40780. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40781. */
  40782. autoTransitionRange: boolean;
  40783. private _attachedCamera;
  40784. private _onAfterCheckInputsObserver;
  40785. private _onMeshTargetChangedObserver;
  40786. /**
  40787. * Initializes the behavior.
  40788. */
  40789. init(): void;
  40790. /**
  40791. * Attaches the behavior to its arc rotate camera.
  40792. * @param camera Defines the camera to attach the behavior to
  40793. */
  40794. attach(camera: ArcRotateCamera): void;
  40795. /**
  40796. * Detaches the behavior from its current arc rotate camera.
  40797. */
  40798. detach(): void;
  40799. private _radiusIsAnimating;
  40800. private _radiusBounceTransition;
  40801. private _animatables;
  40802. private _cachedWheelPrecision;
  40803. /**
  40804. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40805. * @param radiusLimit The limit to check against.
  40806. * @return Bool to indicate if at limit.
  40807. */
  40808. private _isRadiusAtLimit;
  40809. /**
  40810. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40811. * @param radiusDelta The delta by which to animate to. Can be negative.
  40812. */
  40813. private _applyBoundRadiusAnimation;
  40814. /**
  40815. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40816. */
  40817. protected _clearAnimationLocks(): void;
  40818. /**
  40819. * Stops and removes all animations that have been applied to the camera
  40820. */
  40821. stopAllAnimations(): void;
  40822. }
  40823. }
  40824. declare module BABYLON {
  40825. /**
  40826. * The framing behavior (BABYLON.FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  40827. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40828. */
  40829. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40830. /**
  40831. * Gets the name of the behavior.
  40832. */
  40833. readonly name: string;
  40834. private _mode;
  40835. private _radiusScale;
  40836. private _positionScale;
  40837. private _defaultElevation;
  40838. private _elevationReturnTime;
  40839. private _elevationReturnWaitTime;
  40840. private _zoomStopsAnimation;
  40841. private _framingTime;
  40842. /**
  40843. * The easing function used by animations
  40844. */
  40845. static EasingFunction: ExponentialEase;
  40846. /**
  40847. * The easing mode used by animations
  40848. */
  40849. static EasingMode: number;
  40850. /**
  40851. * Sets the current mode used by the behavior
  40852. */
  40853. /**
  40854. * Gets current mode used by the behavior.
  40855. */
  40856. mode: number;
  40857. /**
  40858. * Sets the scale applied to the radius (1 by default)
  40859. */
  40860. /**
  40861. * Gets the scale applied to the radius
  40862. */
  40863. radiusScale: number;
  40864. /**
  40865. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40866. */
  40867. /**
  40868. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40869. */
  40870. positionScale: number;
  40871. /**
  40872. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40873. * behaviour is triggered, in radians.
  40874. */
  40875. /**
  40876. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40877. * behaviour is triggered, in radians.
  40878. */
  40879. defaultElevation: number;
  40880. /**
  40881. * Sets the time (in milliseconds) taken to return to the default beta position.
  40882. * Negative value indicates camera should not return to default.
  40883. */
  40884. /**
  40885. * Gets the time (in milliseconds) taken to return to the default beta position.
  40886. * Negative value indicates camera should not return to default.
  40887. */
  40888. elevationReturnTime: number;
  40889. /**
  40890. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40891. */
  40892. /**
  40893. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40894. */
  40895. elevationReturnWaitTime: number;
  40896. /**
  40897. * Sets the flag that indicates if user zooming should stop animation.
  40898. */
  40899. /**
  40900. * Gets the flag that indicates if user zooming should stop animation.
  40901. */
  40902. zoomStopsAnimation: boolean;
  40903. /**
  40904. * Sets the transition time when framing the mesh, in milliseconds
  40905. */
  40906. /**
  40907. * Gets the transition time when framing the mesh, in milliseconds
  40908. */
  40909. framingTime: number;
  40910. /**
  40911. * Define if the behavior should automatically change the configured
  40912. * camera limits and sensibilities.
  40913. */
  40914. autoCorrectCameraLimitsAndSensibility: boolean;
  40915. private _onPrePointerObservableObserver;
  40916. private _onAfterCheckInputsObserver;
  40917. private _onMeshTargetChangedObserver;
  40918. private _attachedCamera;
  40919. private _isPointerDown;
  40920. private _lastInteractionTime;
  40921. /**
  40922. * Initializes the behavior.
  40923. */
  40924. init(): void;
  40925. /**
  40926. * Attaches the behavior to its arc rotate camera.
  40927. * @param camera Defines the camera to attach the behavior to
  40928. */
  40929. attach(camera: ArcRotateCamera): void;
  40930. /**
  40931. * Detaches the behavior from its current arc rotate camera.
  40932. */
  40933. detach(): void;
  40934. private _animatables;
  40935. private _betaIsAnimating;
  40936. private _betaTransition;
  40937. private _radiusTransition;
  40938. private _vectorTransition;
  40939. /**
  40940. * Targets the given mesh and updates zoom level accordingly.
  40941. * @param mesh The mesh to target.
  40942. * @param radius Optional. If a cached radius position already exists, overrides default.
  40943. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40944. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40945. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40946. */
  40947. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40948. /**
  40949. * Targets the given mesh with its children and updates zoom level accordingly.
  40950. * @param mesh The mesh to target.
  40951. * @param radius Optional. If a cached radius position already exists, overrides default.
  40952. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40953. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40954. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40955. */
  40956. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40957. /**
  40958. * Targets the given meshes with their children and updates zoom level accordingly.
  40959. * @param meshes The mesh to target.
  40960. * @param radius Optional. If a cached radius position already exists, overrides default.
  40961. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40962. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40963. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40964. */
  40965. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40966. /**
  40967. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40968. * @param minimumWorld Determines the smaller position of the bounding box extend
  40969. * @param maximumWorld Determines the bigger position of the bounding box extend
  40970. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40971. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40972. */
  40973. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40974. /**
  40975. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40976. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40977. * frustum width.
  40978. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40979. * to fully enclose the mesh in the viewing frustum.
  40980. */
  40981. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40982. /**
  40983. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40984. * is automatically returned to its default position (expected to be above ground plane).
  40985. */
  40986. private _maintainCameraAboveGround;
  40987. /**
  40988. * Returns the frustum slope based on the canvas ratio and camera FOV
  40989. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40990. */
  40991. private _getFrustumSlope;
  40992. /**
  40993. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40994. */
  40995. private _clearAnimationLocks;
  40996. /**
  40997. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40998. */
  40999. private _applyUserInteraction;
  41000. /**
  41001. * Stops and removes all animations that have been applied to the camera
  41002. */
  41003. stopAllAnimations(): void;
  41004. /**
  41005. * Gets a value indicating if the user is moving the camera
  41006. */
  41007. readonly isUserIsMoving: boolean;
  41008. /**
  41009. * The camera can move all the way towards the mesh.
  41010. */
  41011. static IgnoreBoundsSizeMode: number;
  41012. /**
  41013. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41014. */
  41015. static FitFrustumSidesMode: number;
  41016. }
  41017. }
  41018. declare module BABYLON {
  41019. /**
  41020. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  41021. */
  41022. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  41023. private ui;
  41024. /**
  41025. * The name of the behavior
  41026. */
  41027. name: string;
  41028. /**
  41029. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  41030. */
  41031. distanceAwayFromFace: number;
  41032. /**
  41033. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  41034. */
  41035. distanceAwayFromBottomOfFace: number;
  41036. private _faceVectors;
  41037. private _target;
  41038. private _scene;
  41039. private _onRenderObserver;
  41040. private _tmpMatrix;
  41041. private _tmpVector;
  41042. /**
  41043. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  41044. * @param ui The transform node that should be attched to the mesh
  41045. */
  41046. constructor(ui: BABYLON.TransformNode);
  41047. /**
  41048. * Initializes the behavior
  41049. */
  41050. init(): void;
  41051. private _closestFace;
  41052. private _zeroVector;
  41053. private _lookAtTmpMatrix;
  41054. private _lookAtToRef;
  41055. /**
  41056. * Attaches the AttachToBoxBehavior to the passed in mesh
  41057. * @param target The mesh that the specified node will be attached to
  41058. */
  41059. attach(target: BABYLON.Mesh): void;
  41060. /**
  41061. * Detaches the behavior from the mesh
  41062. */
  41063. detach(): void;
  41064. }
  41065. }
  41066. declare module BABYLON {
  41067. /**
  41068. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  41069. */
  41070. class FadeInOutBehavior implements Behavior<Mesh> {
  41071. /**
  41072. * Time in milliseconds to delay before fading in (Default: 0)
  41073. */
  41074. delay: number;
  41075. /**
  41076. * Time in milliseconds for the mesh to fade in (Default: 300)
  41077. */
  41078. fadeInTime: number;
  41079. private _millisecondsPerFrame;
  41080. private _hovered;
  41081. private _hoverValue;
  41082. private _ownerNode;
  41083. /**
  41084. * Instatiates the FadeInOutBehavior
  41085. */
  41086. constructor();
  41087. /**
  41088. * The name of the behavior
  41089. */
  41090. readonly name: string;
  41091. /**
  41092. * Initializes the behavior
  41093. */
  41094. init(): void;
  41095. /**
  41096. * Attaches the fade behavior on the passed in mesh
  41097. * @param ownerNode The mesh that will be faded in/out once attached
  41098. */
  41099. attach(ownerNode: Mesh): void;
  41100. /**
  41101. * Detaches the behavior from the mesh
  41102. */
  41103. detach(): void;
  41104. /**
  41105. * Triggers the mesh to begin fading in or out
  41106. * @param value if the object should fade in or out (true to fade in)
  41107. */
  41108. fadeIn(value: boolean): void;
  41109. private _update;
  41110. private _setAllVisibility;
  41111. }
  41112. }
  41113. declare module BABYLON {
  41114. /**
  41115. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41116. */
  41117. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41118. private _dragBehaviorA;
  41119. private _dragBehaviorB;
  41120. private _startDistance;
  41121. private _initialScale;
  41122. private _targetScale;
  41123. private _ownerNode;
  41124. private _sceneRenderObserver;
  41125. /**
  41126. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41127. */
  41128. constructor();
  41129. /**
  41130. * The name of the behavior
  41131. */
  41132. readonly name: string;
  41133. /**
  41134. * Initializes the behavior
  41135. */
  41136. init(): void;
  41137. private _getCurrentDistance;
  41138. /**
  41139. * Attaches the scale behavior the passed in mesh
  41140. * @param ownerNode The mesh that will be scaled around once attached
  41141. */
  41142. attach(ownerNode: Mesh): void;
  41143. /**
  41144. * Detaches the behavior from the mesh
  41145. */
  41146. detach(): void;
  41147. }
  41148. }
  41149. declare module BABYLON {
  41150. /**
  41151. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41152. */
  41153. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41154. private static _AnyMouseID;
  41155. private _attachedNode;
  41156. private _dragPlane;
  41157. private _scene;
  41158. private _pointerObserver;
  41159. private _beforeRenderObserver;
  41160. private static _planeScene;
  41161. /**
  41162. * 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)
  41163. */
  41164. maxDragAngle: number;
  41165. /**
  41166. * @hidden
  41167. */
  41168. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41169. /**
  41170. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41171. */
  41172. currentDraggingPointerID: number;
  41173. /**
  41174. * The last position where the pointer hit the drag plane in world space
  41175. */
  41176. lastDragPosition: Vector3;
  41177. /**
  41178. * If the behavior is currently in a dragging state
  41179. */
  41180. dragging: boolean;
  41181. /**
  41182. * 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)
  41183. */
  41184. dragDeltaRatio: number;
  41185. /**
  41186. * If the drag plane orientation should be updated during the dragging (Default: true)
  41187. */
  41188. updateDragPlane: boolean;
  41189. private _debugMode;
  41190. private _moving;
  41191. /**
  41192. * Fires each time the attached mesh is dragged with the pointer
  41193. * * delta between last drag position and current drag position in world space
  41194. * * dragDistance along the drag axis
  41195. * * dragPlaneNormal normal of the current drag plane used during the drag
  41196. * * dragPlanePoint in world space where the drag intersects the drag plane
  41197. */
  41198. onDragObservable: Observable<{
  41199. delta: Vector3;
  41200. dragPlanePoint: Vector3;
  41201. dragPlaneNormal: Vector3;
  41202. dragDistance: number;
  41203. pointerId: number;
  41204. }>;
  41205. /**
  41206. * Fires each time a drag begins (eg. mouse down on mesh)
  41207. */
  41208. onDragStartObservable: Observable<{
  41209. dragPlanePoint: Vector3;
  41210. pointerId: number;
  41211. }>;
  41212. /**
  41213. * Fires each time a drag ends (eg. mouse release after drag)
  41214. */
  41215. onDragEndObservable: Observable<{
  41216. dragPlanePoint: Vector3;
  41217. pointerId: number;
  41218. }>;
  41219. /**
  41220. * If the attached mesh should be moved when dragged
  41221. */
  41222. moveAttached: boolean;
  41223. /**
  41224. * If the drag behavior will react to drag events (Default: true)
  41225. */
  41226. enabled: boolean;
  41227. /**
  41228. * If camera controls should be detached during the drag
  41229. */
  41230. detachCameraControls: boolean;
  41231. /**
  41232. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41233. */
  41234. useObjectOrienationForDragging: boolean;
  41235. private _options;
  41236. /**
  41237. * Creates a pointer drag behavior that can be attached to a mesh
  41238. * @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)
  41239. */
  41240. constructor(options?: {
  41241. dragAxis?: Vector3;
  41242. dragPlaneNormal?: Vector3;
  41243. });
  41244. /**
  41245. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41246. */
  41247. validateDrag: (targetPosition: Vector3) => boolean;
  41248. /**
  41249. * The name of the behavior
  41250. */
  41251. readonly name: string;
  41252. /**
  41253. * Initializes the behavior
  41254. */
  41255. init(): void;
  41256. private _tmpVector;
  41257. private _alternatePickedPoint;
  41258. private _worldDragAxis;
  41259. private _targetPosition;
  41260. private _attachedElement;
  41261. /**
  41262. * Attaches the drag behavior the passed in mesh
  41263. * @param ownerNode The mesh that will be dragged around once attached
  41264. */
  41265. attach(ownerNode: AbstractMesh): void;
  41266. /**
  41267. * Force relase the drag action by code.
  41268. */
  41269. releaseDrag(): void;
  41270. private _startDragRay;
  41271. private _lastPointerRay;
  41272. /**
  41273. * Simulates the start of a pointer drag event on the behavior
  41274. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41275. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41276. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41277. */
  41278. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41279. private _startDrag;
  41280. private _dragDelta;
  41281. private _moveDrag;
  41282. private _pickWithRayOnDragPlane;
  41283. private _pointA;
  41284. private _pointB;
  41285. private _pointC;
  41286. private _lineA;
  41287. private _lineB;
  41288. private _localAxis;
  41289. private _lookAt;
  41290. private _updateDragPlanePosition;
  41291. /**
  41292. * Detaches the behavior from the mesh
  41293. */
  41294. detach(): void;
  41295. }
  41296. }
  41297. declare module BABYLON {
  41298. /**
  41299. * 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
  41300. */
  41301. class SixDofDragBehavior implements Behavior<Mesh> {
  41302. private static _virtualScene;
  41303. private _ownerNode;
  41304. private _sceneRenderObserver;
  41305. private _scene;
  41306. private _targetPosition;
  41307. private _virtualOriginMesh;
  41308. private _virtualDragMesh;
  41309. private _pointerObserver;
  41310. private _moving;
  41311. private _startingOrientation;
  41312. /**
  41313. * 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)
  41314. */
  41315. private zDragFactor;
  41316. /**
  41317. * If the object should rotate to face the drag origin
  41318. */
  41319. rotateDraggedObject: boolean;
  41320. /**
  41321. * If the behavior is currently in a dragging state
  41322. */
  41323. dragging: boolean;
  41324. /**
  41325. * 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)
  41326. */
  41327. dragDeltaRatio: number;
  41328. /**
  41329. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41330. */
  41331. currentDraggingPointerID: number;
  41332. /**
  41333. * If camera controls should be detached during the drag
  41334. */
  41335. detachCameraControls: boolean;
  41336. /**
  41337. * Fires each time a drag starts
  41338. */
  41339. onDragStartObservable: Observable<{}>;
  41340. /**
  41341. * Fires each time a drag ends (eg. mouse release after drag)
  41342. */
  41343. onDragEndObservable: Observable<{}>;
  41344. /**
  41345. * 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
  41346. */
  41347. constructor();
  41348. /**
  41349. * The name of the behavior
  41350. */
  41351. readonly name: string;
  41352. /**
  41353. * Initializes the behavior
  41354. */
  41355. init(): void;
  41356. /**
  41357. * Attaches the scale behavior the passed in mesh
  41358. * @param ownerNode The mesh that will be scaled around once attached
  41359. */
  41360. attach(ownerNode: Mesh): void;
  41361. /**
  41362. * Detaches the behavior from the mesh
  41363. */
  41364. detach(): void;
  41365. }
  41366. }
  41367. declare module BABYLON {
  41368. /**
  41369. * Contains an array of blocks representing the octree
  41370. */
  41371. interface IOctreeContainer<T> {
  41372. /**
  41373. * Blocks within the octree
  41374. */
  41375. blocks: Array<OctreeBlock<T>>;
  41376. }
  41377. /**
  41378. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41379. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41380. */
  41381. class Octree<T> {
  41382. /** 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.) */
  41383. maxDepth: number;
  41384. /**
  41385. * Blocks within the octree containing objects
  41386. */
  41387. blocks: Array<OctreeBlock<T>>;
  41388. /**
  41389. * Content stored in the octree
  41390. */
  41391. dynamicContent: T[];
  41392. private _maxBlockCapacity;
  41393. private _selectionContent;
  41394. private _creationFunc;
  41395. /**
  41396. * Creates a octree
  41397. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41398. * @param creationFunc function to be used to instatiate the octree
  41399. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41400. * @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.)
  41401. */
  41402. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41403. /** 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.) */
  41404. maxDepth?: number);
  41405. /**
  41406. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41407. * @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);
  41408. * @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);
  41409. * @param entries meshes to be added to the octree blocks
  41410. */
  41411. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41412. /**
  41413. * Adds a mesh to the octree
  41414. * @param entry Mesh to add to the octree
  41415. */
  41416. addMesh(entry: T): void;
  41417. /**
  41418. * Remove an element from the octree
  41419. * @param entry defines the element to remove
  41420. */
  41421. removeMesh(entry: T): void;
  41422. /**
  41423. * Selects an array of meshes within the frustum
  41424. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41425. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41426. * @returns array of meshes within the frustum
  41427. */
  41428. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41429. /**
  41430. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41431. * @param sphereCenter defines the bounding sphere center
  41432. * @param sphereRadius defines the bounding sphere radius
  41433. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41434. * @returns an array of objects that intersect the sphere
  41435. */
  41436. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41437. /**
  41438. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41439. * @param ray defines the ray to test with
  41440. * @returns array of intersected objects
  41441. */
  41442. intersectsRay(ray: Ray): SmartArray<T>;
  41443. /**
  41444. * @hidden
  41445. */
  41446. 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;
  41447. /**
  41448. * Adds a mesh into the octree block if it intersects the block
  41449. */
  41450. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41451. /**
  41452. * Adds a submesh into the octree block if it intersects the block
  41453. */
  41454. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41455. }
  41456. }
  41457. declare module BABYLON {
  41458. /**
  41459. * Class used to store a cell in an octree
  41460. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41461. */
  41462. class OctreeBlock<T> {
  41463. /**
  41464. * Gets the content of the current block
  41465. */
  41466. entries: T[];
  41467. /**
  41468. * Gets the list of block children
  41469. */
  41470. blocks: Array<OctreeBlock<T>>;
  41471. private _depth;
  41472. private _maxDepth;
  41473. private _capacity;
  41474. private _minPoint;
  41475. private _maxPoint;
  41476. private _boundingVectors;
  41477. private _creationFunc;
  41478. /**
  41479. * Creates a new block
  41480. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41481. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41482. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41483. * @param depth defines the current depth of this block in the octree
  41484. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41485. * @param creationFunc defines a callback to call when an element is added to the block
  41486. */
  41487. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41488. /**
  41489. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41490. */
  41491. readonly capacity: number;
  41492. /**
  41493. * Gets the minimum vector (in world space) of the block's bounding box
  41494. */
  41495. readonly minPoint: Vector3;
  41496. /**
  41497. * Gets the maximum vector (in world space) of the block's bounding box
  41498. */
  41499. readonly maxPoint: Vector3;
  41500. /**
  41501. * Add a new element to this block
  41502. * @param entry defines the element to add
  41503. */
  41504. addEntry(entry: T): void;
  41505. /**
  41506. * Remove an element from this block
  41507. * @param entry defines the element to remove
  41508. */
  41509. removeEntry(entry: T): void;
  41510. /**
  41511. * Add an array of elements to this block
  41512. * @param entries defines the array of elements to add
  41513. */
  41514. addEntries(entries: T[]): void;
  41515. /**
  41516. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41517. * @param frustumPlanes defines the frustum planes to test
  41518. * @param selection defines the array to store current content if selection is positive
  41519. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41520. */
  41521. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41522. /**
  41523. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41524. * @param sphereCenter defines the bounding sphere center
  41525. * @param sphereRadius defines the bounding sphere radius
  41526. * @param selection defines the array to store current content if selection is positive
  41527. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41528. */
  41529. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41530. /**
  41531. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41532. * @param ray defines the ray to test with
  41533. * @param selection defines the array to store current content if selection is positive
  41534. */
  41535. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41536. /**
  41537. * Subdivide the content into child blocks (this block will then be empty)
  41538. */
  41539. createInnerBlocks(): void;
  41540. }
  41541. }
  41542. declare module BABYLON {
  41543. interface Scene {
  41544. /**
  41545. * @hidden
  41546. * Backing Filed
  41547. */
  41548. _selectionOctree: Octree<AbstractMesh>;
  41549. /**
  41550. * Gets the octree used to boost mesh selection (picking)
  41551. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41552. */
  41553. selectionOctree: Octree<AbstractMesh>;
  41554. /**
  41555. * Creates or updates the octree used to boost selection (picking)
  41556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41557. * @param maxCapacity defines the maximum capacity per leaf
  41558. * @param maxDepth defines the maximum depth of the octree
  41559. * @returns an octree of AbstractMesh
  41560. */
  41561. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41562. }
  41563. interface AbstractMesh {
  41564. /**
  41565. * @hidden
  41566. * Backing Field
  41567. */
  41568. _submeshesOctree: Octree<SubMesh>;
  41569. /**
  41570. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41571. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41572. * @param maxCapacity defines the maximum size of each block (64 by default)
  41573. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41574. * @returns the new octree
  41575. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41576. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41577. */
  41578. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41579. }
  41580. /**
  41581. * Defines the octree scene component responsible to manage any octrees
  41582. * in a given scene.
  41583. */
  41584. class OctreeSceneComponent {
  41585. /**
  41586. * The component name helpfull to identify the component in the list of scene components.
  41587. */
  41588. readonly name: string;
  41589. /**
  41590. * The scene the component belongs to.
  41591. */
  41592. scene: Scene;
  41593. /**
  41594. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41595. */
  41596. readonly checksIsEnabled: boolean;
  41597. /**
  41598. * Creates a new instance of the component for the given scene
  41599. * @param scene Defines the scene to register the component in
  41600. */
  41601. constructor(scene: Scene);
  41602. /**
  41603. * Registers the component in a given scene
  41604. */
  41605. register(): void;
  41606. /**
  41607. * Return the list of active meshes
  41608. * @returns the list of active meshes
  41609. */
  41610. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41611. /**
  41612. * Return the list of active sub meshes
  41613. * @param mesh The mesh to get the candidates sub meshes from
  41614. * @returns the list of active sub meshes
  41615. */
  41616. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41617. private _tempRay;
  41618. /**
  41619. * Return the list of sub meshes intersecting with a given local ray
  41620. * @param mesh defines the mesh to find the submesh for
  41621. * @param localRay defines the ray in local space
  41622. * @returns the list of intersecting sub meshes
  41623. */
  41624. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41625. /**
  41626. * Return the list of sub meshes colliding with a collider
  41627. * @param mesh defines the mesh to find the submesh for
  41628. * @param collider defines the collider to evaluate the collision against
  41629. * @returns the list of colliding sub meshes
  41630. */
  41631. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41632. /**
  41633. * Rebuilds the elements related to this component in case of
  41634. * context lost for instance.
  41635. */
  41636. rebuild(): void;
  41637. /**
  41638. * Disposes the component and the associated ressources.
  41639. */
  41640. dispose(): void;
  41641. }
  41642. }
  41643. declare module BABYLON {
  41644. /**
  41645. * Manage the gamepad inputs to control an arc rotate camera.
  41646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41647. */
  41648. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41649. /**
  41650. * Defines the camera the input is attached to.
  41651. */
  41652. camera: ArcRotateCamera;
  41653. /**
  41654. * Defines the gamepad the input is gathering event from.
  41655. */
  41656. gamepad: Nullable<Gamepad>;
  41657. /**
  41658. * Defines the gamepad rotation sensiblity.
  41659. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41660. */
  41661. gamepadRotationSensibility: number;
  41662. /**
  41663. * Defines the gamepad move sensiblity.
  41664. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41665. */
  41666. gamepadMoveSensibility: number;
  41667. private _onGamepadConnectedObserver;
  41668. private _onGamepadDisconnectedObserver;
  41669. /**
  41670. * Attach the input controls to a specific dom element to get the input from.
  41671. * @param element Defines the element the controls should be listened from
  41672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41673. */
  41674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41675. /**
  41676. * Detach the current controls from the specified dom element.
  41677. * @param element Defines the element to stop listening the inputs from
  41678. */
  41679. detachControl(element: Nullable<HTMLElement>): void;
  41680. /**
  41681. * Update the current camera state depending on the inputs that have been used this frame.
  41682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41683. */
  41684. checkInputs(): void;
  41685. /**
  41686. * Gets the class name of the current intput.
  41687. * @returns the class name
  41688. */
  41689. getClassName(): string;
  41690. /**
  41691. * Get the friendly name associated with the input class.
  41692. * @returns the input friendly name
  41693. */
  41694. getSimpleName(): string;
  41695. }
  41696. }
  41697. declare module BABYLON {
  41698. /**
  41699. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41701. */
  41702. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41703. /**
  41704. * Defines the camera the input is attached to.
  41705. */
  41706. camera: ArcRotateCamera;
  41707. /**
  41708. * Defines the list of key codes associated with the up action (increase alpha)
  41709. */
  41710. keysUp: number[];
  41711. /**
  41712. * Defines the list of key codes associated with the down action (decrease alpha)
  41713. */
  41714. keysDown: number[];
  41715. /**
  41716. * Defines the list of key codes associated with the left action (increase beta)
  41717. */
  41718. keysLeft: number[];
  41719. /**
  41720. * Defines the list of key codes associated with the right action (decrease beta)
  41721. */
  41722. keysRight: number[];
  41723. /**
  41724. * Defines the list of key codes associated with the reset action.
  41725. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41726. */
  41727. keysReset: number[];
  41728. /**
  41729. * Defines the panning sensibility of the inputs.
  41730. * (How fast is the camera paning)
  41731. */
  41732. panningSensibility: number;
  41733. /**
  41734. * Defines the zooming sensibility of the inputs.
  41735. * (How fast is the camera zooming)
  41736. */
  41737. zoomingSensibility: number;
  41738. /**
  41739. * Defines wether maintaining the alt key down switch the movement mode from
  41740. * orientation to zoom.
  41741. */
  41742. useAltToZoom: boolean;
  41743. /**
  41744. * Rotation speed of the camera
  41745. */
  41746. angularSpeed: number;
  41747. private _keys;
  41748. private _ctrlPressed;
  41749. private _altPressed;
  41750. private _onCanvasBlurObserver;
  41751. private _onKeyboardObserver;
  41752. private _engine;
  41753. private _scene;
  41754. /**
  41755. * Attach the input controls to a specific dom element to get the input from.
  41756. * @param element Defines the element the controls should be listened from
  41757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41758. */
  41759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41760. /**
  41761. * Detach the current controls from the specified dom element.
  41762. * @param element Defines the element to stop listening the inputs from
  41763. */
  41764. detachControl(element: Nullable<HTMLElement>): void;
  41765. /**
  41766. * Update the current camera state depending on the inputs that have been used this frame.
  41767. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41768. */
  41769. checkInputs(): void;
  41770. /**
  41771. * Gets the class name of the current intput.
  41772. * @returns the class name
  41773. */
  41774. getClassName(): string;
  41775. /**
  41776. * Get the friendly name associated with the input class.
  41777. * @returns the input friendly name
  41778. */
  41779. getSimpleName(): string;
  41780. }
  41781. }
  41782. declare module BABYLON {
  41783. /**
  41784. * Manage the mouse wheel inputs to control an arc rotate camera.
  41785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41786. */
  41787. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41788. /**
  41789. * Defines the camera the input is attached to.
  41790. */
  41791. camera: ArcRotateCamera;
  41792. /**
  41793. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41794. */
  41795. wheelPrecision: number;
  41796. /**
  41797. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41798. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41799. */
  41800. wheelDeltaPercentage: number;
  41801. private _wheel;
  41802. private _observer;
  41803. /**
  41804. * Attach the input controls to a specific dom element to get the input from.
  41805. * @param element Defines the element the controls should be listened from
  41806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41807. */
  41808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41809. /**
  41810. * Detach the current controls from the specified dom element.
  41811. * @param element Defines the element to stop listening the inputs from
  41812. */
  41813. detachControl(element: Nullable<HTMLElement>): void;
  41814. /**
  41815. * Gets the class name of the current intput.
  41816. * @returns the class name
  41817. */
  41818. getClassName(): string;
  41819. /**
  41820. * Get the friendly name associated with the input class.
  41821. * @returns the input friendly name
  41822. */
  41823. getSimpleName(): string;
  41824. }
  41825. }
  41826. declare module BABYLON {
  41827. /**
  41828. * Manage the pointers inputs to control an arc rotate camera.
  41829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41830. */
  41831. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41832. /**
  41833. * Defines the camera the input is attached to.
  41834. */
  41835. camera: ArcRotateCamera;
  41836. /**
  41837. * Defines the buttons associated with the input to handle camera move.
  41838. */
  41839. buttons: number[];
  41840. /**
  41841. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41842. */
  41843. angularSensibilityX: number;
  41844. /**
  41845. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41846. */
  41847. angularSensibilityY: number;
  41848. /**
  41849. * Defines the pointer pinch precision or how fast is the camera zooming.
  41850. */
  41851. pinchPrecision: number;
  41852. /**
  41853. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41854. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41855. */
  41856. pinchDeltaPercentage: number;
  41857. /**
  41858. * Defines the pointer panning sensibility or how fast is the camera moving.
  41859. */
  41860. panningSensibility: number;
  41861. /**
  41862. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41863. */
  41864. multiTouchPanning: boolean;
  41865. /**
  41866. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41867. */
  41868. multiTouchPanAndZoom: boolean;
  41869. /**
  41870. * Revers pinch action direction.
  41871. */
  41872. pinchInwards: boolean;
  41873. private _isPanClick;
  41874. private _pointerInput;
  41875. private _observer;
  41876. private _onMouseMove;
  41877. private _onGestureStart;
  41878. private _onGesture;
  41879. private _MSGestureHandler;
  41880. private _onLostFocus;
  41881. private _onContextMenu;
  41882. /**
  41883. * Attach the input controls to a specific dom element to get the input from.
  41884. * @param element Defines the element the controls should be listened from
  41885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41886. */
  41887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41888. /**
  41889. * Detach the current controls from the specified dom element.
  41890. * @param element Defines the element to stop listening the inputs from
  41891. */
  41892. detachControl(element: Nullable<HTMLElement>): void;
  41893. /**
  41894. * Gets the class name of the current intput.
  41895. * @returns the class name
  41896. */
  41897. getClassName(): string;
  41898. /**
  41899. * Get the friendly name associated with the input class.
  41900. * @returns the input friendly name
  41901. */
  41902. getSimpleName(): string;
  41903. }
  41904. }
  41905. declare module BABYLON {
  41906. /**
  41907. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41909. */
  41910. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41911. /**
  41912. * Defines the camera the input is attached to.
  41913. */
  41914. camera: ArcRotateCamera;
  41915. /**
  41916. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41917. */
  41918. alphaCorrection: number;
  41919. /**
  41920. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41921. */
  41922. gammaCorrection: number;
  41923. private _alpha;
  41924. private _gamma;
  41925. private _dirty;
  41926. private _deviceOrientationHandler;
  41927. /**
  41928. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41929. */
  41930. constructor();
  41931. /**
  41932. * Attach the input controls to a specific dom element to get the input from.
  41933. * @param element Defines the element the controls should be listened from
  41934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41935. */
  41936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41937. /** @hidden */
  41938. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41939. /**
  41940. * Update the current camera state depending on the inputs that have been used this frame.
  41941. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41942. */
  41943. checkInputs(): void;
  41944. /**
  41945. * Detach the current controls from the specified dom element.
  41946. * @param element Defines the element to stop listening the inputs from
  41947. */
  41948. detachControl(element: Nullable<HTMLElement>): void;
  41949. /**
  41950. * Gets the class name of the current intput.
  41951. * @returns the class name
  41952. */
  41953. getClassName(): string;
  41954. /**
  41955. * Get the friendly name associated with the input class.
  41956. * @returns the input friendly name
  41957. */
  41958. getSimpleName(): string;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * Listen to keyboard events to control the camera.
  41964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41965. */
  41966. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41967. /**
  41968. * Defines the camera the input is attached to.
  41969. */
  41970. camera: FlyCamera;
  41971. /**
  41972. * The list of keyboard keys used to control the forward move of the camera.
  41973. */
  41974. keysForward: number[];
  41975. /**
  41976. * The list of keyboard keys used to control the backward move of the camera.
  41977. */
  41978. keysBackward: number[];
  41979. /**
  41980. * The list of keyboard keys used to control the forward move of the camera.
  41981. */
  41982. keysUp: number[];
  41983. /**
  41984. * The list of keyboard keys used to control the backward move of the camera.
  41985. */
  41986. keysDown: number[];
  41987. /**
  41988. * The list of keyboard keys used to control the right strafe move of the camera.
  41989. */
  41990. keysRight: number[];
  41991. /**
  41992. * The list of keyboard keys used to control the left strafe move of the camera.
  41993. */
  41994. keysLeft: number[];
  41995. private _keys;
  41996. private _onCanvasBlurObserver;
  41997. private _onKeyboardObserver;
  41998. private _engine;
  41999. private _scene;
  42000. /**
  42001. * Attach the input controls to a specific dom element to get the input from.
  42002. * @param element Defines the element the controls should be listened from
  42003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42004. */
  42005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42006. /**
  42007. * Detach the current controls from the specified dom element.
  42008. * @param element Defines the element to stop listening the inputs from
  42009. */
  42010. detachControl(element: Nullable<HTMLElement>): void;
  42011. /**
  42012. * Gets the class name of the current intput.
  42013. * @returns the class name
  42014. */
  42015. getClassName(): string;
  42016. /** @hidden */
  42017. _onLostFocus(e: FocusEvent): void;
  42018. /**
  42019. * Get the friendly name associated with the input class.
  42020. * @returns the input friendly name
  42021. */
  42022. getSimpleName(): string;
  42023. /**
  42024. * Update the current camera state depending on the inputs that have been used this frame.
  42025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42026. */
  42027. checkInputs(): void;
  42028. }
  42029. }
  42030. declare module BABYLON {
  42031. /**
  42032. * Listen to mouse events to control the camera.
  42033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42034. */
  42035. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42036. /**
  42037. * Defines the camera the input is attached to.
  42038. */
  42039. camera: FlyCamera;
  42040. /**
  42041. * Defines if touch is enabled. (Default is true.)
  42042. */
  42043. touchEnabled: boolean;
  42044. /**
  42045. * Defines the buttons associated with the input to handle camera rotation.
  42046. */
  42047. buttons: number[];
  42048. /**
  42049. * Assign buttons for Yaw control.
  42050. */
  42051. buttonsYaw: number[];
  42052. /**
  42053. * Assign buttons for Pitch control.
  42054. */
  42055. buttonsPitch: number[];
  42056. /**
  42057. * Assign buttons for Roll control.
  42058. */
  42059. buttonsRoll: number[];
  42060. /**
  42061. * Detect if any button is being pressed while mouse is moved.
  42062. * -1 = Mouse locked.
  42063. * 0 = Left button.
  42064. * 1 = Middle Button.
  42065. * 2 = Right Button.
  42066. */
  42067. activeButton: number;
  42068. /**
  42069. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42070. * Higher values reduce its sensitivity.
  42071. */
  42072. angularSensibility: number;
  42073. private _mousemoveCallback;
  42074. private _observer;
  42075. private _rollObserver;
  42076. private previousPosition;
  42077. private noPreventDefault;
  42078. private element;
  42079. /**
  42080. * Listen to mouse events to control the camera.
  42081. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42083. */
  42084. constructor(touchEnabled?: boolean);
  42085. /**
  42086. * Attach the mouse control to the HTML DOM element.
  42087. * @param element Defines the element that listens to the input events.
  42088. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42089. */
  42090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42091. /**
  42092. * Detach the current controls from the specified dom element.
  42093. * @param element Defines the element to stop listening the inputs from
  42094. */
  42095. detachControl(element: Nullable<HTMLElement>): void;
  42096. /**
  42097. * Gets the class name of the current input.
  42098. * @returns the class name.
  42099. */
  42100. getClassName(): string;
  42101. /**
  42102. * Get the friendly name associated with the input class.
  42103. * @returns the input's friendly name.
  42104. */
  42105. getSimpleName(): string;
  42106. private _pointerInput;
  42107. private _onMouseMove;
  42108. /**
  42109. * Rotate camera by mouse offset.
  42110. */
  42111. private rotateCamera;
  42112. }
  42113. }
  42114. declare module BABYLON {
  42115. /**
  42116. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42117. * Screen rotation is taken into account.
  42118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42119. */
  42120. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42121. private _camera;
  42122. private _screenOrientationAngle;
  42123. private _constantTranform;
  42124. private _screenQuaternion;
  42125. private _alpha;
  42126. private _beta;
  42127. private _gamma;
  42128. /**
  42129. * Instantiates a new input
  42130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42131. */
  42132. constructor();
  42133. /**
  42134. * Define the camera controlled by the input.
  42135. */
  42136. camera: FreeCamera;
  42137. /**
  42138. * Attach the input controls to a specific dom element to get the input from.
  42139. * @param element Defines the element the controls should be listened from
  42140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42141. */
  42142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42143. private _orientationChanged;
  42144. private _deviceOrientation;
  42145. /**
  42146. * Detach the current controls from the specified dom element.
  42147. * @param element Defines the element to stop listening the inputs from
  42148. */
  42149. detachControl(element: Nullable<HTMLElement>): void;
  42150. /**
  42151. * Update the current camera state depending on the inputs that have been used this frame.
  42152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42153. */
  42154. checkInputs(): void;
  42155. /**
  42156. * Gets the class name of the current intput.
  42157. * @returns the class name
  42158. */
  42159. getClassName(): string;
  42160. /**
  42161. * Get the friendly name associated with the input class.
  42162. * @returns the input friendly name
  42163. */
  42164. getSimpleName(): string;
  42165. }
  42166. }
  42167. declare module BABYLON {
  42168. /**
  42169. * Manage the gamepad inputs to control a free camera.
  42170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42171. */
  42172. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42173. /**
  42174. * Define the camera the input is attached to.
  42175. */
  42176. camera: FreeCamera;
  42177. /**
  42178. * Define the Gamepad controlling the input
  42179. */
  42180. gamepad: Nullable<Gamepad>;
  42181. /**
  42182. * Defines the gamepad rotation sensiblity.
  42183. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42184. */
  42185. gamepadAngularSensibility: number;
  42186. /**
  42187. * Defines the gamepad move sensiblity.
  42188. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42189. */
  42190. gamepadMoveSensibility: number;
  42191. private _onGamepadConnectedObserver;
  42192. private _onGamepadDisconnectedObserver;
  42193. private _cameraTransform;
  42194. private _deltaTransform;
  42195. private _vector3;
  42196. private _vector2;
  42197. /**
  42198. * Attach the input controls to a specific dom element to get the input from.
  42199. * @param element Defines the element the controls should be listened from
  42200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42201. */
  42202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42203. /**
  42204. * Detach the current controls from the specified dom element.
  42205. * @param element Defines the element to stop listening the inputs from
  42206. */
  42207. detachControl(element: Nullable<HTMLElement>): void;
  42208. /**
  42209. * Update the current camera state depending on the inputs that have been used this frame.
  42210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42211. */
  42212. checkInputs(): void;
  42213. /**
  42214. * Gets the class name of the current intput.
  42215. * @returns the class name
  42216. */
  42217. getClassName(): string;
  42218. /**
  42219. * Get the friendly name associated with the input class.
  42220. * @returns the input friendly name
  42221. */
  42222. getSimpleName(): string;
  42223. }
  42224. }
  42225. declare module BABYLON {
  42226. /**
  42227. * Manage the keyboard inputs to control the movement of a free camera.
  42228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42229. */
  42230. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42231. /**
  42232. * Defines the camera the input is attached to.
  42233. */
  42234. camera: FreeCamera;
  42235. /**
  42236. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42237. */
  42238. keysUp: number[];
  42239. /**
  42240. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42241. */
  42242. keysDown: number[];
  42243. /**
  42244. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42245. */
  42246. keysLeft: number[];
  42247. /**
  42248. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42249. */
  42250. keysRight: number[];
  42251. private _keys;
  42252. private _onCanvasBlurObserver;
  42253. private _onKeyboardObserver;
  42254. private _engine;
  42255. private _scene;
  42256. /**
  42257. * Attach the input controls to a specific dom element to get the input from.
  42258. * @param element Defines the element the controls should be listened from
  42259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42260. */
  42261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42262. /**
  42263. * Detach the current controls from the specified dom element.
  42264. * @param element Defines the element to stop listening the inputs from
  42265. */
  42266. detachControl(element: Nullable<HTMLElement>): void;
  42267. /**
  42268. * Update the current camera state depending on the inputs that have been used this frame.
  42269. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42270. */
  42271. checkInputs(): void;
  42272. /**
  42273. * Gets the class name of the current intput.
  42274. * @returns the class name
  42275. */
  42276. getClassName(): string;
  42277. /** @hidden */
  42278. _onLostFocus(e: FocusEvent): void;
  42279. /**
  42280. * Get the friendly name associated with the input class.
  42281. * @returns the input friendly name
  42282. */
  42283. getSimpleName(): string;
  42284. }
  42285. }
  42286. declare module BABYLON {
  42287. /**
  42288. * Manage the mouse inputs to control the movement of a free camera.
  42289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42290. */
  42291. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42292. /**
  42293. * Define if touch is enabled in the mouse input
  42294. */
  42295. touchEnabled: boolean;
  42296. /**
  42297. * Defines the camera the input is attached to.
  42298. */
  42299. camera: FreeCamera;
  42300. /**
  42301. * Defines the buttons associated with the input to handle camera move.
  42302. */
  42303. buttons: number[];
  42304. /**
  42305. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42306. */
  42307. angularSensibility: number;
  42308. private _pointerInput;
  42309. private _onMouseMove;
  42310. private _observer;
  42311. private previousPosition;
  42312. /**
  42313. * Manage the mouse inputs to control the movement of a free camera.
  42314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42315. * @param touchEnabled Defines if touch is enabled or not
  42316. */
  42317. constructor(
  42318. /**
  42319. * Define if touch is enabled in the mouse input
  42320. */
  42321. touchEnabled?: boolean);
  42322. /**
  42323. * Attach the input controls to a specific dom element to get the input from.
  42324. * @param element Defines the element the controls should be listened from
  42325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42326. */
  42327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42328. /**
  42329. * Detach the current controls from the specified dom element.
  42330. * @param element Defines the element to stop listening the inputs from
  42331. */
  42332. detachControl(element: Nullable<HTMLElement>): void;
  42333. /**
  42334. * Gets the class name of the current intput.
  42335. * @returns the class name
  42336. */
  42337. getClassName(): string;
  42338. /**
  42339. * Get the friendly name associated with the input class.
  42340. * @returns the input friendly name
  42341. */
  42342. getSimpleName(): string;
  42343. }
  42344. }
  42345. declare module BABYLON {
  42346. /**
  42347. * Manage the touch inputs to control the movement of a free camera.
  42348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42349. */
  42350. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42351. /**
  42352. * Defines the camera the input is attached to.
  42353. */
  42354. camera: FreeCamera;
  42355. /**
  42356. * Defines the touch sensibility for rotation.
  42357. * The higher the faster.
  42358. */
  42359. touchAngularSensibility: number;
  42360. /**
  42361. * Defines the touch sensibility for move.
  42362. * The higher the faster.
  42363. */
  42364. touchMoveSensibility: number;
  42365. private _offsetX;
  42366. private _offsetY;
  42367. private _pointerPressed;
  42368. private _pointerInput;
  42369. private _observer;
  42370. private _onLostFocus;
  42371. /**
  42372. * Attach the input controls to a specific dom element to get the input from.
  42373. * @param element Defines the element the controls should be listened from
  42374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42375. */
  42376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42377. /**
  42378. * Detach the current controls from the specified dom element.
  42379. * @param element Defines the element to stop listening the inputs from
  42380. */
  42381. detachControl(element: Nullable<HTMLElement>): void;
  42382. /**
  42383. * Update the current camera state depending on the inputs that have been used this frame.
  42384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42385. */
  42386. checkInputs(): void;
  42387. /**
  42388. * Gets the class name of the current intput.
  42389. * @returns the class name
  42390. */
  42391. getClassName(): string;
  42392. /**
  42393. * Get the friendly name associated with the input class.
  42394. * @returns the input friendly name
  42395. */
  42396. getSimpleName(): string;
  42397. }
  42398. }
  42399. declare module BABYLON {
  42400. /**
  42401. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42403. */
  42404. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42405. /**
  42406. * Defines the camera the input is attached to.
  42407. */
  42408. camera: FreeCamera;
  42409. private _leftjoystick;
  42410. private _rightjoystick;
  42411. /**
  42412. * Gets the left stick of the virtual joystick.
  42413. * @returns The virtual Joystick
  42414. */
  42415. getLeftJoystick(): VirtualJoystick;
  42416. /**
  42417. * Gets the right stick of the virtual joystick.
  42418. * @returns The virtual Joystick
  42419. */
  42420. getRightJoystick(): VirtualJoystick;
  42421. /**
  42422. * Update the current camera state depending on the inputs that have been used this frame.
  42423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42424. */
  42425. checkInputs(): void;
  42426. /**
  42427. * Attach the input controls to a specific dom element to get the input from.
  42428. * @param element Defines the element the controls should be listened from
  42429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42430. */
  42431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42432. /**
  42433. * Detach the current controls from the specified dom element.
  42434. * @param element Defines the element to stop listening the inputs from
  42435. */
  42436. detachControl(element: Nullable<HTMLElement>): void;
  42437. /**
  42438. * Gets the class name of the current intput.
  42439. * @returns the class name
  42440. */
  42441. getClassName(): string;
  42442. /**
  42443. * Get the friendly name associated with the input class.
  42444. * @returns the input friendly name
  42445. */
  42446. getSimpleName(): string;
  42447. }
  42448. }
  42449. declare module BABYLON {
  42450. /**
  42451. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42452. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42453. */
  42454. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42455. /**
  42456. * Creates a new AnaglyphArcRotateCamera
  42457. * @param name defines camera name
  42458. * @param alpha defines alpha angle (in radians)
  42459. * @param beta defines beta angle (in radians)
  42460. * @param radius defines radius
  42461. * @param target defines camera target
  42462. * @param interaxialDistance defines distance between each color axis
  42463. * @param scene defines the hosting scene
  42464. */
  42465. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42466. /**
  42467. * Gets camera class name
  42468. * @returns AnaglyphArcRotateCamera
  42469. */
  42470. getClassName(): string;
  42471. }
  42472. }
  42473. declare module BABYLON {
  42474. /**
  42475. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42476. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42477. */
  42478. class AnaglyphFreeCamera extends FreeCamera {
  42479. /**
  42480. * Creates a new AnaglyphFreeCamera
  42481. * @param name defines camera name
  42482. * @param position defines initial position
  42483. * @param interaxialDistance defines distance between each color axis
  42484. * @param scene defines the hosting scene
  42485. */
  42486. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42487. /**
  42488. * Gets camera class name
  42489. * @returns AnaglyphFreeCamera
  42490. */
  42491. getClassName(): string;
  42492. }
  42493. }
  42494. declare module BABYLON {
  42495. /**
  42496. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42497. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42498. */
  42499. class AnaglyphGamepadCamera extends GamepadCamera {
  42500. /**
  42501. * Creates a new AnaglyphGamepadCamera
  42502. * @param name defines camera name
  42503. * @param position defines initial position
  42504. * @param interaxialDistance defines distance between each color axis
  42505. * @param scene defines the hosting scene
  42506. */
  42507. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42508. /**
  42509. * Gets camera class name
  42510. * @returns AnaglyphGamepadCamera
  42511. */
  42512. getClassName(): string;
  42513. }
  42514. }
  42515. declare module BABYLON {
  42516. /**
  42517. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42518. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42519. */
  42520. class AnaglyphUniversalCamera extends UniversalCamera {
  42521. /**
  42522. * Creates a new AnaglyphUniversalCamera
  42523. * @param name defines camera name
  42524. * @param position defines initial position
  42525. * @param interaxialDistance defines distance between each color axis
  42526. * @param scene defines the hosting scene
  42527. */
  42528. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42529. /**
  42530. * Gets camera class name
  42531. * @returns AnaglyphUniversalCamera
  42532. */
  42533. getClassName(): string;
  42534. }
  42535. }
  42536. declare module BABYLON {
  42537. /**
  42538. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42539. * @see http://doc.babylonjs.com/features/cameras
  42540. */
  42541. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42542. /**
  42543. * Creates a new StereoscopicArcRotateCamera
  42544. * @param name defines camera name
  42545. * @param alpha defines alpha angle (in radians)
  42546. * @param beta defines beta angle (in radians)
  42547. * @param radius defines radius
  42548. * @param target defines camera target
  42549. * @param interaxialDistance defines distance between each color axis
  42550. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42551. * @param scene defines the hosting scene
  42552. */
  42553. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42554. /**
  42555. * Gets camera class name
  42556. * @returns StereoscopicArcRotateCamera
  42557. */
  42558. getClassName(): string;
  42559. }
  42560. }
  42561. declare module BABYLON {
  42562. /**
  42563. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42564. * @see http://doc.babylonjs.com/features/cameras
  42565. */
  42566. class StereoscopicFreeCamera extends FreeCamera {
  42567. /**
  42568. * Creates a new StereoscopicFreeCamera
  42569. * @param name defines camera name
  42570. * @param position defines initial position
  42571. * @param interaxialDistance defines distance between each color axis
  42572. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42573. * @param scene defines the hosting scene
  42574. */
  42575. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42576. /**
  42577. * Gets camera class name
  42578. * @returns StereoscopicFreeCamera
  42579. */
  42580. getClassName(): string;
  42581. }
  42582. }
  42583. declare module BABYLON {
  42584. /**
  42585. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42586. * @see http://doc.babylonjs.com/features/cameras
  42587. */
  42588. class StereoscopicGamepadCamera extends GamepadCamera {
  42589. /**
  42590. * Creates a new StereoscopicGamepadCamera
  42591. * @param name defines camera name
  42592. * @param position defines initial position
  42593. * @param interaxialDistance defines distance between each color axis
  42594. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42595. * @param scene defines the hosting scene
  42596. */
  42597. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42598. /**
  42599. * Gets camera class name
  42600. * @returns StereoscopicGamepadCamera
  42601. */
  42602. getClassName(): string;
  42603. }
  42604. }
  42605. declare module BABYLON {
  42606. /**
  42607. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42608. * @see http://doc.babylonjs.com/features/cameras
  42609. */
  42610. class StereoscopicUniversalCamera extends UniversalCamera {
  42611. /**
  42612. * Creates a new StereoscopicUniversalCamera
  42613. * @param name defines camera name
  42614. * @param position defines initial position
  42615. * @param interaxialDistance defines distance between each color axis
  42616. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42617. * @param scene defines the hosting scene
  42618. */
  42619. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42620. /**
  42621. * Gets camera class name
  42622. * @returns StereoscopicUniversalCamera
  42623. */
  42624. getClassName(): string;
  42625. }
  42626. }
  42627. declare module BABYLON {
  42628. /**
  42629. * This represents all the required metrics to create a VR camera.
  42630. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42631. */
  42632. class VRCameraMetrics {
  42633. /**
  42634. * Define the horizontal resolution off the screen.
  42635. */
  42636. hResolution: number;
  42637. /**
  42638. * Define the vertical resolution off the screen.
  42639. */
  42640. vResolution: number;
  42641. /**
  42642. * Define the horizontal screen size.
  42643. */
  42644. hScreenSize: number;
  42645. /**
  42646. * Define the vertical screen size.
  42647. */
  42648. vScreenSize: number;
  42649. /**
  42650. * Define the vertical screen center position.
  42651. */
  42652. vScreenCenter: number;
  42653. /**
  42654. * Define the distance of the eyes to the screen.
  42655. */
  42656. eyeToScreenDistance: number;
  42657. /**
  42658. * Define the distance between both lenses
  42659. */
  42660. lensSeparationDistance: number;
  42661. /**
  42662. * Define the distance between both viewer's eyes.
  42663. */
  42664. interpupillaryDistance: number;
  42665. /**
  42666. * Define the distortion factor of the VR postprocess.
  42667. * Please, touch with care.
  42668. */
  42669. distortionK: number[];
  42670. /**
  42671. * Define the chromatic aberration correction factors for the VR post process.
  42672. */
  42673. chromaAbCorrection: number[];
  42674. /**
  42675. * Define the scale factor of the post process.
  42676. * The smaller the better but the slower.
  42677. */
  42678. postProcessScaleFactor: number;
  42679. /**
  42680. * Define an offset for the lens center.
  42681. */
  42682. lensCenterOffset: number;
  42683. /**
  42684. * Define if the current vr camera should compensate the distortion of the lense or not.
  42685. */
  42686. compensateDistortion: boolean;
  42687. /**
  42688. * Gets the rendering aspect ratio based on the provided resolutions.
  42689. */
  42690. readonly aspectRatio: number;
  42691. /**
  42692. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42693. */
  42694. readonly aspectRatioFov: number;
  42695. /**
  42696. * @hidden
  42697. */
  42698. readonly leftHMatrix: Matrix;
  42699. /**
  42700. * @hidden
  42701. */
  42702. readonly rightHMatrix: Matrix;
  42703. /**
  42704. * @hidden
  42705. */
  42706. readonly leftPreViewMatrix: Matrix;
  42707. /**
  42708. * @hidden
  42709. */
  42710. readonly rightPreViewMatrix: Matrix;
  42711. /**
  42712. * Get the default VRMetrics based on the most generic setup.
  42713. * @returns the default vr metrics
  42714. */
  42715. static GetDefault(): VRCameraMetrics;
  42716. }
  42717. }
  42718. declare module BABYLON {
  42719. /**
  42720. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42721. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42722. */
  42723. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42724. /**
  42725. * Creates a new VRDeviceOrientationArcRotateCamera
  42726. * @param name defines camera name
  42727. * @param alpha defines the camera rotation along the logitudinal axis
  42728. * @param beta defines the camera rotation along the latitudinal axis
  42729. * @param radius defines the camera distance from its target
  42730. * @param target defines the camera target
  42731. * @param scene defines the scene the camera belongs to
  42732. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42733. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42734. */
  42735. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42736. /**
  42737. * Gets camera class name
  42738. * @returns VRDeviceOrientationArcRotateCamera
  42739. */
  42740. getClassName(): string;
  42741. }
  42742. }
  42743. declare module BABYLON {
  42744. /**
  42745. * Camera used to simulate VR rendering (based on FreeCamera)
  42746. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42747. */
  42748. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42749. /**
  42750. * Creates a new VRDeviceOrientationFreeCamera
  42751. * @param name defines camera name
  42752. * @param position defines the start position of the camera
  42753. * @param scene defines the scene the camera belongs to
  42754. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42755. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42756. */
  42757. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42758. /**
  42759. * Gets camera class name
  42760. * @returns VRDeviceOrientationFreeCamera
  42761. */
  42762. getClassName(): string;
  42763. }
  42764. }
  42765. declare module BABYLON {
  42766. /**
  42767. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42768. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42769. */
  42770. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42771. /**
  42772. * Creates a new VRDeviceOrientationGamepadCamera
  42773. * @param name defines camera name
  42774. * @param position defines the start position of the camera
  42775. * @param scene defines the scene the camera belongs to
  42776. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42777. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42778. */
  42779. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42780. /**
  42781. * Gets camera class name
  42782. * @returns VRDeviceOrientationGamepadCamera
  42783. */
  42784. getClassName(): string;
  42785. }
  42786. }
  42787. declare module BABYLON {
  42788. /**
  42789. * Options to modify the vr teleportation behavior.
  42790. */
  42791. interface VRTeleportationOptions {
  42792. /**
  42793. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42794. */
  42795. floorMeshName?: string;
  42796. /**
  42797. * A list of meshes to be used as the teleportation floor. (default: empty)
  42798. */
  42799. floorMeshes?: Mesh[];
  42800. }
  42801. /**
  42802. * Options to modify the vr experience helper's behavior.
  42803. */
  42804. interface VRExperienceHelperOptions extends WebVROptions {
  42805. /**
  42806. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42807. */
  42808. createDeviceOrientationCamera?: boolean;
  42809. /**
  42810. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42811. */
  42812. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42813. /**
  42814. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42815. */
  42816. laserToggle?: boolean;
  42817. /**
  42818. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42819. */
  42820. floorMeshes?: Mesh[];
  42821. }
  42822. /**
  42823. * Helps to quickly add VR support to an existing scene.
  42824. * See http://doc.babylonjs.com/how_to/webvr_helper
  42825. */
  42826. class VRExperienceHelper {
  42827. /** Options to modify the vr experience helper's behavior. */
  42828. webVROptions: VRExperienceHelperOptions;
  42829. private _scene;
  42830. private _position;
  42831. private _btnVR;
  42832. private _btnVRDisplayed;
  42833. private _webVRsupported;
  42834. private _webVRready;
  42835. private _webVRrequesting;
  42836. private _webVRpresenting;
  42837. private _hasEnteredVR;
  42838. private _fullscreenVRpresenting;
  42839. private _canvas;
  42840. private _webVRCamera;
  42841. private _vrDeviceOrientationCamera;
  42842. private _deviceOrientationCamera;
  42843. private _existingCamera;
  42844. private _onKeyDown;
  42845. private _onVrDisplayPresentChange;
  42846. private _onVRDisplayChanged;
  42847. private _onVRRequestPresentStart;
  42848. private _onVRRequestPresentComplete;
  42849. /**
  42850. * Observable raised when entering VR.
  42851. */
  42852. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42853. /**
  42854. * Observable raised when exiting VR.
  42855. */
  42856. onExitingVRObservable: Observable<VRExperienceHelper>;
  42857. /**
  42858. * Observable raised when controller mesh is loaded.
  42859. */
  42860. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42861. /** Return this.onEnteringVRObservable
  42862. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42863. */
  42864. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42865. /** Return this.onExitingVRObservable
  42866. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42867. */
  42868. readonly onExitingVR: Observable<VRExperienceHelper>;
  42869. /** Return this.onControllerMeshLoadedObservable
  42870. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42871. */
  42872. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42873. private _rayLength;
  42874. private _useCustomVRButton;
  42875. private _teleportationRequested;
  42876. private _teleportActive;
  42877. private _floorMeshName;
  42878. private _floorMeshesCollection;
  42879. private _rotationAllowed;
  42880. private _teleportBackwardsVector;
  42881. private _teleportationTarget;
  42882. private _isDefaultTeleportationTarget;
  42883. private _postProcessMove;
  42884. private _teleportationFillColor;
  42885. private _teleportationBorderColor;
  42886. private _rotationAngle;
  42887. private _haloCenter;
  42888. private _cameraGazer;
  42889. private _padSensibilityUp;
  42890. private _padSensibilityDown;
  42891. private _leftController;
  42892. private _rightController;
  42893. /**
  42894. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42895. */
  42896. onNewMeshSelected: Observable<AbstractMesh>;
  42897. /**
  42898. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42899. */
  42900. onNewMeshPicked: Observable<PickingInfo>;
  42901. private _circleEase;
  42902. /**
  42903. * Observable raised before camera teleportation
  42904. */
  42905. onBeforeCameraTeleport: Observable<Vector3>;
  42906. /**
  42907. * Observable raised after camera teleportation
  42908. */
  42909. onAfterCameraTeleport: Observable<Vector3>;
  42910. /**
  42911. * Observable raised when current selected mesh gets unselected
  42912. */
  42913. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42914. private _raySelectionPredicate;
  42915. /**
  42916. * To be optionaly changed by user to define custom ray selection
  42917. */
  42918. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42919. /**
  42920. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42921. */
  42922. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42923. /**
  42924. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42925. */
  42926. teleportationEnabled: boolean;
  42927. private _defaultHeight;
  42928. private _teleportationInitialized;
  42929. private _interactionsEnabled;
  42930. private _interactionsRequested;
  42931. private _displayGaze;
  42932. private _displayLaserPointer;
  42933. /**
  42934. * The mesh used to display where the user is going to teleport.
  42935. */
  42936. /**
  42937. * Sets the mesh to be used to display where the user is going to teleport.
  42938. */
  42939. teleportationTarget: Mesh;
  42940. /**
  42941. * 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
  42942. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42943. * See http://doc.babylonjs.com/resources/baking_transformations
  42944. */
  42945. gazeTrackerMesh: Mesh;
  42946. /**
  42947. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42948. */
  42949. updateGazeTrackerScale: boolean;
  42950. /**
  42951. * If the gaze trackers color should be updated when selecting meshes
  42952. */
  42953. updateGazeTrackerColor: boolean;
  42954. /**
  42955. * The gaze tracking mesh corresponding to the left controller
  42956. */
  42957. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42958. /**
  42959. * The gaze tracking mesh corresponding to the right controller
  42960. */
  42961. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42962. /**
  42963. * If the ray of the gaze should be displayed.
  42964. */
  42965. /**
  42966. * Sets if the ray of the gaze should be displayed.
  42967. */
  42968. displayGaze: boolean;
  42969. /**
  42970. * If the ray of the LaserPointer should be displayed.
  42971. */
  42972. /**
  42973. * Sets if the ray of the LaserPointer should be displayed.
  42974. */
  42975. displayLaserPointer: boolean;
  42976. /**
  42977. * The deviceOrientationCamera used as the camera when not in VR.
  42978. */
  42979. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42980. /**
  42981. * Based on the current WebVR support, returns the current VR camera used.
  42982. */
  42983. readonly currentVRCamera: Nullable<Camera>;
  42984. /**
  42985. * The webVRCamera which is used when in VR.
  42986. */
  42987. readonly webVRCamera: WebVRFreeCamera;
  42988. /**
  42989. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42990. */
  42991. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42992. private readonly _teleportationRequestInitiated;
  42993. /**
  42994. * Instantiates a VRExperienceHelper.
  42995. * Helps to quickly add VR support to an existing scene.
  42996. * @param scene The scene the VRExperienceHelper belongs to.
  42997. * @param webVROptions Options to modify the vr experience helper's behavior.
  42998. */
  42999. constructor(scene: Scene,
  43000. /** Options to modify the vr experience helper's behavior. */
  43001. webVROptions?: VRExperienceHelperOptions);
  43002. private _onDefaultMeshLoaded;
  43003. private _onResize;
  43004. private _onFullscreenChange;
  43005. /**
  43006. * Gets a value indicating if we are currently in VR mode.
  43007. */
  43008. readonly isInVRMode: boolean;
  43009. private onVrDisplayPresentChange;
  43010. private onVRDisplayChanged;
  43011. private moveButtonToBottomRight;
  43012. private displayVRButton;
  43013. private updateButtonVisibility;
  43014. private _cachedAngularSensibility;
  43015. /**
  43016. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43017. * Otherwise, will use the fullscreen API.
  43018. */
  43019. enterVR(): void;
  43020. /**
  43021. * Attempt to exit VR, or fullscreen.
  43022. */
  43023. exitVR(): void;
  43024. /**
  43025. * The position of the vr experience helper.
  43026. */
  43027. /**
  43028. * Sets the position of the vr experience helper.
  43029. */
  43030. position: Vector3;
  43031. /**
  43032. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43033. */
  43034. enableInteractions(): void;
  43035. private readonly _noControllerIsActive;
  43036. private beforeRender;
  43037. private _isTeleportationFloor;
  43038. /**
  43039. * Adds a floor mesh to be used for teleportation.
  43040. * @param floorMesh the mesh to be used for teleportation.
  43041. */
  43042. addFloorMesh(floorMesh: Mesh): void;
  43043. /**
  43044. * Removes a floor mesh from being used for teleportation.
  43045. * @param floorMesh the mesh to be removed.
  43046. */
  43047. removeFloorMesh(floorMesh: Mesh): void;
  43048. /**
  43049. * Enables interactions and teleportation using the VR controllers and gaze.
  43050. * @param vrTeleportationOptions options to modify teleportation behavior.
  43051. */
  43052. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43053. private _onNewGamepadConnected;
  43054. private _tryEnableInteractionOnController;
  43055. private _onNewGamepadDisconnected;
  43056. private _enableInteractionOnController;
  43057. private _checkTeleportWithRay;
  43058. private _checkRotate;
  43059. private _checkTeleportBackwards;
  43060. private _enableTeleportationOnController;
  43061. private _createTeleportationCircles;
  43062. private _displayTeleportationTarget;
  43063. private _hideTeleportationTarget;
  43064. private _rotateCamera;
  43065. private _moveTeleportationSelectorTo;
  43066. private _workingVector;
  43067. private _workingQuaternion;
  43068. private _workingMatrix;
  43069. /**
  43070. * Teleports the users feet to the desired location
  43071. * @param location The location where the user's feet should be placed
  43072. */
  43073. teleportCamera(location: Vector3): void;
  43074. private _convertNormalToDirectionOfRay;
  43075. private _castRayAndSelectObject;
  43076. private _notifySelectedMeshUnselected;
  43077. /**
  43078. * Sets the color of the laser ray from the vr controllers.
  43079. * @param color new color for the ray.
  43080. */
  43081. changeLaserColor(color: Color3): void;
  43082. /**
  43083. * Sets the color of the ray from the vr headsets gaze.
  43084. * @param color new color for the ray.
  43085. */
  43086. changeGazeColor(color: Color3): void;
  43087. /**
  43088. * Exits VR and disposes of the vr experience helper
  43089. */
  43090. dispose(): void;
  43091. /**
  43092. * Gets the name of the VRExperienceHelper class
  43093. * @returns "VRExperienceHelper"
  43094. */
  43095. getClassName(): string;
  43096. }
  43097. }
  43098. declare module BABYLON {
  43099. /**
  43100. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  43101. * IMPORTANT!! The data is right-hand data.
  43102. * @export
  43103. * @interface DevicePose
  43104. */
  43105. interface DevicePose {
  43106. /**
  43107. * The position of the device, values in array are [x,y,z].
  43108. */
  43109. readonly position: Nullable<Float32Array>;
  43110. /**
  43111. * The linearVelocity of the device, values in array are [x,y,z].
  43112. */
  43113. readonly linearVelocity: Nullable<Float32Array>;
  43114. /**
  43115. * The linearAcceleration of the device, values in array are [x,y,z].
  43116. */
  43117. readonly linearAcceleration: Nullable<Float32Array>;
  43118. /**
  43119. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  43120. */
  43121. readonly orientation: Nullable<Float32Array>;
  43122. /**
  43123. * The angularVelocity of the device, values in array are [x,y,z].
  43124. */
  43125. readonly angularVelocity: Nullable<Float32Array>;
  43126. /**
  43127. * The angularAcceleration of the device, values in array are [x,y,z].
  43128. */
  43129. readonly angularAcceleration: Nullable<Float32Array>;
  43130. }
  43131. /**
  43132. * Interface representing a pose controlled object in Babylon.
  43133. * A pose controlled object has both regular pose values as well as pose values
  43134. * from an external device such as a VR head mounted display
  43135. */
  43136. interface PoseControlled {
  43137. /**
  43138. * The position of the object in babylon space.
  43139. */
  43140. position: Vector3;
  43141. /**
  43142. * The rotation quaternion of the object in babylon space.
  43143. */
  43144. rotationQuaternion: Quaternion;
  43145. /**
  43146. * The position of the device in babylon space.
  43147. */
  43148. devicePosition?: Vector3;
  43149. /**
  43150. * The rotation quaternion of the device in babylon space.
  43151. */
  43152. deviceRotationQuaternion: Quaternion;
  43153. /**
  43154. * The raw pose coming from the device.
  43155. */
  43156. rawPose: Nullable<DevicePose>;
  43157. /**
  43158. * The scale of the device to be used when translating from device space to babylon space.
  43159. */
  43160. deviceScaleFactor: number;
  43161. /**
  43162. * Updates the poseControlled values based on the input device pose.
  43163. * @param poseData the pose data to update the object with
  43164. */
  43165. updateFromDevice(poseData: DevicePose): void;
  43166. }
  43167. /**
  43168. * Set of options to customize the webVRCamera
  43169. */
  43170. interface WebVROptions {
  43171. /**
  43172. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  43173. */
  43174. trackPosition?: boolean;
  43175. /**
  43176. * Sets the scale of the vrDevice in babylon space. (default: 1)
  43177. */
  43178. positionScale?: number;
  43179. /**
  43180. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43181. */
  43182. displayName?: string;
  43183. /**
  43184. * Should the native controller meshes be initialized. (default: true)
  43185. */
  43186. controllerMeshes?: boolean;
  43187. /**
  43188. * Creating a default HemiLight only on controllers. (default: true)
  43189. */
  43190. defaultLightingOnControllers?: boolean;
  43191. /**
  43192. * If you don't want to use the default VR button of the helper. (default: false)
  43193. */
  43194. useCustomVRButton?: boolean;
  43195. /**
  43196. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43197. */
  43198. customVRButton?: HTMLButtonElement;
  43199. /**
  43200. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43201. */
  43202. rayLength?: number;
  43203. /**
  43204. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43205. */
  43206. defaultHeight?: number;
  43207. }
  43208. /**
  43209. * This represents a WebVR camera.
  43210. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43211. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43212. */
  43213. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43214. private webVROptions;
  43215. /**
  43216. * @hidden
  43217. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43218. */
  43219. _vrDevice: any;
  43220. /**
  43221. * The rawPose of the vrDevice.
  43222. */
  43223. rawPose: Nullable<DevicePose>;
  43224. private _onVREnabled;
  43225. private _specsVersion;
  43226. private _attached;
  43227. private _frameData;
  43228. protected _descendants: Array<Node>;
  43229. private _deviceRoomPosition;
  43230. /** @hidden */
  43231. _deviceRoomRotationQuaternion: Quaternion;
  43232. private _standingMatrix;
  43233. /**
  43234. * Represents device position in babylon space.
  43235. */
  43236. devicePosition: Vector3;
  43237. /**
  43238. * Represents device rotation in babylon space.
  43239. */
  43240. deviceRotationQuaternion: Quaternion;
  43241. /**
  43242. * The scale of the device to be used when translating from device space to babylon space.
  43243. */
  43244. deviceScaleFactor: number;
  43245. private _deviceToWorld;
  43246. private _worldToDevice;
  43247. /**
  43248. * References to the webVR controllers for the vrDevice.
  43249. */
  43250. controllers: Array<WebVRController>;
  43251. /**
  43252. * Emits an event when a controller is attached.
  43253. */
  43254. onControllersAttachedObservable: Observable<WebVRController[]>;
  43255. /**
  43256. * Emits an event when a controller's mesh has been loaded;
  43257. */
  43258. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43259. /**
  43260. * Emits an event when the HMD's pose has been updated.
  43261. */
  43262. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43263. private _poseSet;
  43264. /**
  43265. * If the rig cameras be used as parent instead of this camera.
  43266. */
  43267. rigParenting: boolean;
  43268. private _lightOnControllers;
  43269. private _defaultHeight?;
  43270. /**
  43271. * Instantiates a WebVRFreeCamera.
  43272. * @param name The name of the WebVRFreeCamera
  43273. * @param position The starting anchor position for the camera
  43274. * @param scene The scene the camera belongs to
  43275. * @param webVROptions a set of customizable options for the webVRCamera
  43276. */
  43277. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43278. /**
  43279. * Gets the device distance from the ground in meters.
  43280. * @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.
  43281. */
  43282. deviceDistanceToRoomGround(): number;
  43283. /**
  43284. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43285. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43286. */
  43287. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43288. /**
  43289. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43290. * @returns A promise with a boolean set to if the standing matrix is supported.
  43291. */
  43292. useStandingMatrixAsync(): Promise<boolean>;
  43293. /**
  43294. * Disposes the camera
  43295. */
  43296. dispose(): void;
  43297. /**
  43298. * Gets a vrController by name.
  43299. * @param name The name of the controller to retreive
  43300. * @returns the controller matching the name specified or null if not found
  43301. */
  43302. getControllerByName(name: string): Nullable<WebVRController>;
  43303. private _leftController;
  43304. /**
  43305. * The controller corrisponding to the users left hand.
  43306. */
  43307. readonly leftController: Nullable<WebVRController>;
  43308. private _rightController;
  43309. /**
  43310. * The controller corrisponding to the users right hand.
  43311. */
  43312. readonly rightController: Nullable<WebVRController>;
  43313. /**
  43314. * Casts a ray forward from the vrCamera's gaze.
  43315. * @param length Length of the ray (default: 100)
  43316. * @returns the ray corrisponding to the gaze
  43317. */
  43318. getForwardRay(length?: number): Ray;
  43319. /**
  43320. * @hidden
  43321. * Updates the camera based on device's frame data
  43322. */
  43323. _checkInputs(): void;
  43324. /**
  43325. * Updates the poseControlled values based on the input device pose.
  43326. * @param poseData Pose coming from the device
  43327. */
  43328. updateFromDevice(poseData: DevicePose): void;
  43329. private _htmlElementAttached;
  43330. private _detachIfAttached;
  43331. /**
  43332. * WebVR's attach control will start broadcasting frames to the device.
  43333. * Note that in certain browsers (chrome for example) this function must be called
  43334. * within a user-interaction callback. Example:
  43335. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43336. *
  43337. * @param element html element to attach the vrDevice to
  43338. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43339. */
  43340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43341. /**
  43342. * Detaches the camera from the html element and disables VR
  43343. *
  43344. * @param element html element to detach from
  43345. */
  43346. detachControl(element: HTMLElement): void;
  43347. /**
  43348. * @returns the name of this class
  43349. */
  43350. getClassName(): string;
  43351. /**
  43352. * Calls resetPose on the vrDisplay
  43353. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43354. */
  43355. resetToCurrentRotation(): void;
  43356. /**
  43357. * @hidden
  43358. * Updates the rig cameras (left and right eye)
  43359. */
  43360. _updateRigCameras(): void;
  43361. private _workingVector;
  43362. private _oneVector;
  43363. private _workingMatrix;
  43364. private updateCacheCalled;
  43365. private _correctPositionIfNotTrackPosition;
  43366. /**
  43367. * @hidden
  43368. * Updates the cached values of the camera
  43369. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43370. */
  43371. _updateCache(ignoreParentClass?: boolean): void;
  43372. /**
  43373. * @hidden
  43374. * Get current device position in babylon world
  43375. */
  43376. _computeDevicePosition(): void;
  43377. /**
  43378. * Updates the current device position and rotation in the babylon world
  43379. */
  43380. update(): void;
  43381. /**
  43382. * @hidden
  43383. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43384. * @returns an identity matrix
  43385. */
  43386. _getViewMatrix(): Matrix;
  43387. private _tmpMatrix;
  43388. /**
  43389. * This function is called by the two RIG cameras.
  43390. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43391. */
  43392. protected _getWebVRViewMatrix(): Matrix;
  43393. protected _getWebVRProjectionMatrix(): Matrix;
  43394. private _onGamepadConnectedObserver;
  43395. private _onGamepadDisconnectedObserver;
  43396. private _updateCacheWhenTrackingDisabledObserver;
  43397. /**
  43398. * Initializes the controllers and their meshes
  43399. */
  43400. initControllers(): void;
  43401. }
  43402. }
  43403. declare module BABYLON {
  43404. /**
  43405. * WebXR Camera which holds the views for the xrSession
  43406. * @see https://doc.babylonjs.com/how_to/webxr
  43407. */
  43408. class WebXRCamera extends FreeCamera {
  43409. private static _TmpMatrix;
  43410. /**
  43411. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43412. * @param name the name of the camera
  43413. * @param scene the scene to add the camera to
  43414. */
  43415. constructor(name: string, scene: BABYLON.Scene);
  43416. private _updateNumberOfRigCameras;
  43417. /** @hidden */
  43418. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43419. /**
  43420. * Updates the cameras position from the current pose information of the XR session
  43421. * @param xrSessionManager the session containing pose information
  43422. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43423. */
  43424. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43425. }
  43426. }
  43427. declare module BABYLON {
  43428. /**
  43429. * Button which can be used to enter a different mode of XR
  43430. */
  43431. class WebXREnterExitUIButton {
  43432. /** button element */
  43433. element: HTMLElement;
  43434. /** XR initialization options for the button */
  43435. initializationOptions: XRSessionCreationOptions;
  43436. /**
  43437. * Creates a WebXREnterExitUIButton
  43438. * @param element button element
  43439. * @param initializationOptions XR initialization options for the button
  43440. */
  43441. constructor(
  43442. /** button element */
  43443. element: HTMLElement,
  43444. /** XR initialization options for the button */
  43445. initializationOptions: XRSessionCreationOptions);
  43446. /**
  43447. * Overwritable function which can be used to update the button's visuals when the state changes
  43448. * @param activeButton the current active button in the UI
  43449. */
  43450. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43451. }
  43452. /**
  43453. * Options to create the webXR UI
  43454. */
  43455. class WebXREnterExitUIOptions {
  43456. /**
  43457. * Context to enter xr with
  43458. */
  43459. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43460. /**
  43461. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43462. */
  43463. customButtons?: Array<WebXREnterExitUIButton>;
  43464. }
  43465. /**
  43466. * UI to allow the user to enter/exit XR mode
  43467. */
  43468. class WebXREnterExitUI implements IDisposable {
  43469. private scene;
  43470. private _overlay;
  43471. private _buttons;
  43472. private _activeButton;
  43473. /**
  43474. * Fired every time the active button is changed.
  43475. *
  43476. * When xr is entered via a button that launches xr that button will be the callback parameter
  43477. *
  43478. * When exiting xr the callback parameter will be null)
  43479. */
  43480. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43481. /**
  43482. * Creates UI to allow the user to enter/exit XR mode
  43483. * @param scene the scene to add the ui to
  43484. * @param helper the xr experience helper to enter/exit xr with
  43485. * @param options options to configure the UI
  43486. * @returns the created ui
  43487. */
  43488. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43489. private constructor();
  43490. private _updateButtons;
  43491. /**
  43492. * Disposes of the object
  43493. */
  43494. dispose(): void;
  43495. }
  43496. }
  43497. declare module BABYLON {
  43498. /**
  43499. * States of the webXR experience
  43500. */
  43501. enum WebXRState {
  43502. /**
  43503. * Transitioning to being in XR mode
  43504. */
  43505. ENTERING_XR = 0,
  43506. /**
  43507. * Transitioning to non XR mode
  43508. */
  43509. EXITING_XR = 1,
  43510. /**
  43511. * In XR mode and presenting
  43512. */
  43513. IN_XR = 2,
  43514. /**
  43515. * Not entered XR mode
  43516. */
  43517. NOT_IN_XR = 3
  43518. }
  43519. /**
  43520. * Helper class used to enable XR
  43521. * @see https://doc.babylonjs.com/how_to/webxr
  43522. */
  43523. class WebXRExperienceHelper implements IDisposable {
  43524. private scene;
  43525. /**
  43526. * 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
  43527. */
  43528. container: AbstractMesh;
  43529. /**
  43530. * Camera used to render xr content
  43531. */
  43532. camera: WebXRCamera;
  43533. /**
  43534. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43535. */
  43536. state: WebXRState;
  43537. private _setState;
  43538. private static _TmpVector;
  43539. /**
  43540. * Fires when the state of the experience helper has changed
  43541. */
  43542. onStateChangedObservable: Observable<WebXRState>;
  43543. /** @hidden */
  43544. _sessionManager: WebXRSessionManager;
  43545. private _nonVRCamera;
  43546. private _originalSceneAutoClear;
  43547. private _supported;
  43548. /**
  43549. * Creates the experience helper
  43550. * @param scene the scene to attach the experience helper to
  43551. * @returns a promise for the experience helper
  43552. */
  43553. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43554. /**
  43555. * Creates a WebXRExperienceHelper
  43556. * @param scene The scene the helper should be created in
  43557. */
  43558. private constructor();
  43559. /**
  43560. * Exits XR mode and returns the scene to its original state
  43561. * @returns promise that resolves after xr mode has exited
  43562. */
  43563. exitXRAsync(): Promise<void>;
  43564. /**
  43565. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43566. * @param sessionCreationOptions options for the XR session
  43567. * @param frameOfReference frame of reference of the XR session
  43568. * @returns promise that resolves after xr mode has entered
  43569. */
  43570. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43571. /**
  43572. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43573. * @param ray ray to cast into the environment
  43574. * @returns Promise which resolves with a collision point in the environment if it exists
  43575. */
  43576. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43577. /**
  43578. * Updates the global position of the camera by moving the camera's container
  43579. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43580. * @param position The desired global position of the camera
  43581. */
  43582. setPositionOfCameraUsingContainer(position: Vector3): void;
  43583. /**
  43584. * Rotates the xr camera by rotating the camera's container around the camera's position
  43585. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43586. * @param rotation the desired quaternion rotation to apply to the camera
  43587. */
  43588. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43589. /**
  43590. * Checks if the creation options are supported by the xr session
  43591. * @param options creation options
  43592. * @returns true if supported
  43593. */
  43594. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43595. /**
  43596. * Disposes of the experience helper
  43597. */
  43598. dispose(): void;
  43599. }
  43600. }
  43601. declare module BABYLON {
  43602. /**
  43603. * Represents an XR input
  43604. */
  43605. class WebXRController {
  43606. /**
  43607. * 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
  43608. */
  43609. grip?: BABYLON.AbstractMesh;
  43610. /**
  43611. * Pointer which can be used to select objects or attach a visible laser to
  43612. */
  43613. pointer: BABYLON.AbstractMesh;
  43614. /**
  43615. * Creates the controller
  43616. * @see https://doc.babylonjs.com/how_to/webxr
  43617. * @param scene the scene which the controller should be associated to
  43618. */
  43619. constructor(scene: BABYLON.Scene);
  43620. /**
  43621. * Disposes of the object
  43622. */
  43623. dispose(): void;
  43624. }
  43625. /**
  43626. * XR input used to track XR inputs such as controllers/rays
  43627. */
  43628. class WebXRInput implements IDisposable {
  43629. private helper;
  43630. /**
  43631. * XR controllers being tracked
  43632. */
  43633. controllers: Array<WebXRController>;
  43634. private _tmpMatrix;
  43635. private _frameObserver;
  43636. /**
  43637. * Initializes the WebXRInput
  43638. * @param helper experience helper which the input should be created for
  43639. */
  43640. constructor(helper: WebXRExperienceHelper);
  43641. /**
  43642. * Disposes of the object
  43643. */
  43644. dispose(): void;
  43645. }
  43646. }
  43647. declare module BABYLON {
  43648. /**
  43649. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43650. */
  43651. class WebXRManagedOutputCanvas implements IDisposable {
  43652. private _canvas;
  43653. /**
  43654. * xrpresent context of the canvas which can be used to display/mirror xr content
  43655. */
  43656. canvasContext: Nullable<WebGLRenderingContext>;
  43657. /**
  43658. * Initializes the canvas to be added/removed upon entering/exiting xr
  43659. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43660. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43661. */
  43662. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43663. /**
  43664. * Disposes of the object
  43665. */
  43666. dispose(): void;
  43667. private _setManagedOutputCanvas;
  43668. private _addCanvas;
  43669. private _removeCanvas;
  43670. }
  43671. }
  43672. declare module BABYLON {
  43673. /**
  43674. * Manages an XRSession
  43675. * @see https://doc.babylonjs.com/how_to/webxr
  43676. */
  43677. class WebXRSessionManager implements IDisposable {
  43678. private scene;
  43679. /**
  43680. * Fires every time a new xrFrame arrives which can be used to update the camera
  43681. */
  43682. onXRFrameObservable: Observable<any>;
  43683. /**
  43684. * Fires when the xr session is ended either by the device or manually done
  43685. */
  43686. onXRSessionEnded: Observable<any>;
  43687. /** @hidden */
  43688. _xrSession: XRSession;
  43689. /** @hidden */
  43690. _frameOfReference: XRFrameOfReference;
  43691. /** @hidden */
  43692. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43693. /** @hidden */
  43694. _currentXRFrame: Nullable<XRFrame>;
  43695. private _xrNavigator;
  43696. private _xrDevice;
  43697. private _tmpMatrix;
  43698. /**
  43699. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43700. * @param scene The scene which the session should be created for
  43701. */
  43702. constructor(scene: BABYLON.Scene);
  43703. /**
  43704. * Initializes the manager
  43705. * After initialization enterXR can be called to start an XR session
  43706. * @returns Promise which resolves after it is initialized
  43707. */
  43708. initializeAsync(): Promise<void>;
  43709. /**
  43710. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43711. * @param sessionCreationOptions xr options to create the session with
  43712. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43713. * @returns Promise which resolves after it enters XR
  43714. */
  43715. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43716. /**
  43717. * Stops the xrSession and restores the renderloop
  43718. * @returns Promise which resolves after it exits XR
  43719. */
  43720. exitXRAsync(): Promise<void>;
  43721. /**
  43722. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43723. * @param ray ray to cast into the environment
  43724. * @returns Promise which resolves with a collision point in the environment if it exists
  43725. */
  43726. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43727. /**
  43728. * Checks if a session would be supported for the creation options specified
  43729. * @param options creation options to check if they are supported
  43730. * @returns true if supported
  43731. */
  43732. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43733. /**
  43734. * @hidden
  43735. * Converts the render layer of xrSession to a render target
  43736. * @param session session to create render target for
  43737. * @param scene scene the new render target should be created for
  43738. */
  43739. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43740. /**
  43741. * Disposes of the session manager
  43742. */
  43743. dispose(): void;
  43744. }
  43745. }
  43746. declare module BABYLON {
  43747. /** @hidden */
  43748. class _OcclusionDataStorage {
  43749. /** @hidden */
  43750. occlusionInternalRetryCounter: number;
  43751. /** @hidden */
  43752. isOcclusionQueryInProgress: boolean;
  43753. /** @hidden */
  43754. isOccluded: boolean;
  43755. /** @hidden */
  43756. occlusionRetryCount: number;
  43757. /** @hidden */
  43758. occlusionType: number;
  43759. /** @hidden */
  43760. occlusionQueryAlgorithmType: number;
  43761. }
  43762. interface Engine {
  43763. /**
  43764. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43765. * @return the new query
  43766. */
  43767. createQuery(): WebGLQuery;
  43768. /**
  43769. * Delete and release a webGL query
  43770. * @param query defines the query to delete
  43771. * @return the current engine
  43772. */
  43773. deleteQuery(query: WebGLQuery): Engine;
  43774. /**
  43775. * Check if a given query has resolved and got its value
  43776. * @param query defines the query to check
  43777. * @returns true if the query got its value
  43778. */
  43779. isQueryResultAvailable(query: WebGLQuery): boolean;
  43780. /**
  43781. * Gets the value of a given query
  43782. * @param query defines the query to check
  43783. * @returns the value of the query
  43784. */
  43785. getQueryResult(query: WebGLQuery): number;
  43786. /**
  43787. * Initiates an occlusion query
  43788. * @param algorithmType defines the algorithm to use
  43789. * @param query defines the query to use
  43790. * @returns the current engine
  43791. * @see http://doc.babylonjs.com/features/occlusionquery
  43792. */
  43793. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43794. /**
  43795. * Ends an occlusion query
  43796. * @see http://doc.babylonjs.com/features/occlusionquery
  43797. * @param algorithmType defines the algorithm to use
  43798. * @returns the current engine
  43799. */
  43800. endOcclusionQuery(algorithmType: number): Engine;
  43801. /**
  43802. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43803. * Please note that only one query can be issued at a time
  43804. * @returns a time token used to track the time span
  43805. */
  43806. startTimeQuery(): Nullable<_TimeToken>;
  43807. /**
  43808. * Ends a time query
  43809. * @param token defines the token used to measure the time span
  43810. * @returns the time spent (in ns)
  43811. */
  43812. endTimeQuery(token: _TimeToken): int;
  43813. /** @hidden */
  43814. _currentNonTimestampToken: Nullable<_TimeToken>;
  43815. /** @hidden */
  43816. _createTimeQuery(): WebGLQuery;
  43817. /** @hidden */
  43818. _deleteTimeQuery(query: WebGLQuery): void;
  43819. /** @hidden */
  43820. _getGlAlgorithmType(algorithmType: number): number;
  43821. /** @hidden */
  43822. _getTimeQueryResult(query: WebGLQuery): any;
  43823. /** @hidden */
  43824. _getTimeQueryAvailability(query: WebGLQuery): any;
  43825. }
  43826. interface AbstractMesh {
  43827. /**
  43828. * Backing filed
  43829. * @hidden
  43830. */
  43831. __occlusionDataStorage: _OcclusionDataStorage;
  43832. /**
  43833. * Access property
  43834. * @hidden
  43835. */
  43836. _occlusionDataStorage: _OcclusionDataStorage;
  43837. /**
  43838. * 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.
  43839. * The default value is -1 which means don't break the query and wait till the result
  43840. * @see http://doc.babylonjs.com/features/occlusionquery
  43841. */
  43842. occlusionRetryCount: number;
  43843. /**
  43844. * 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:
  43845. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43846. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43847. * * 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.
  43848. * @see http://doc.babylonjs.com/features/occlusionquery
  43849. */
  43850. occlusionType: number;
  43851. /**
  43852. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43853. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43854. * * 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.
  43855. * @see http://doc.babylonjs.com/features/occlusionquery
  43856. */
  43857. occlusionQueryAlgorithmType: number;
  43858. /**
  43859. * 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
  43860. * @see http://doc.babylonjs.com/features/occlusionquery
  43861. */
  43862. isOccluded: boolean;
  43863. /**
  43864. * Flag to check the progress status of the query
  43865. * @see http://doc.babylonjs.com/features/occlusionquery
  43866. */
  43867. isOcclusionQueryInProgress: boolean;
  43868. }
  43869. }
  43870. declare module BABYLON {
  43871. interface Engine {
  43872. /**
  43873. * Creates a webGL transform feedback object
  43874. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43875. * @returns the webGL transform feedback object
  43876. */
  43877. createTransformFeedback(): WebGLTransformFeedback;
  43878. /**
  43879. * Delete a webGL transform feedback object
  43880. * @param value defines the webGL transform feedback object to delete
  43881. */
  43882. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43883. /**
  43884. * Bind a webGL transform feedback object to the webgl context
  43885. * @param value defines the webGL transform feedback object to bind
  43886. */
  43887. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43888. /**
  43889. * Begins a transform feedback operation
  43890. * @param usePoints defines if points or triangles must be used
  43891. */
  43892. beginTransformFeedback(usePoints: boolean): void;
  43893. /**
  43894. * Ends a transform feedback operation
  43895. */
  43896. endTransformFeedback(): void;
  43897. /**
  43898. * Specify the varyings to use with transform feedback
  43899. * @param program defines the associated webGL program
  43900. * @param value defines the list of strings representing the varying names
  43901. */
  43902. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43903. /**
  43904. * Bind a webGL buffer for a transform feedback operation
  43905. * @param value defines the webGL buffer to bind
  43906. */
  43907. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43908. }
  43909. }
  43910. declare module BABYLON {
  43911. /**
  43912. * Google Daydream controller
  43913. */
  43914. class DaydreamController extends WebVRController {
  43915. /**
  43916. * Base Url for the controller model.
  43917. */
  43918. static MODEL_BASE_URL: string;
  43919. /**
  43920. * File name for the controller model.
  43921. */
  43922. static MODEL_FILENAME: string;
  43923. /**
  43924. * Gamepad Id prefix used to identify Daydream Controller.
  43925. */
  43926. static readonly GAMEPAD_ID_PREFIX: string;
  43927. /**
  43928. * Creates a new DaydreamController from a gamepad
  43929. * @param vrGamepad the gamepad that the controller should be created from
  43930. */
  43931. constructor(vrGamepad: any);
  43932. /**
  43933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43934. * @param scene scene in which to add meshes
  43935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43936. */
  43937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43938. /**
  43939. * Called once for each button that changed state since the last frame
  43940. * @param buttonIdx Which button index changed
  43941. * @param state New state of the button
  43942. * @param changes Which properties on the state changed since last frame
  43943. */
  43944. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43945. }
  43946. }
  43947. declare module BABYLON {
  43948. /**
  43949. * Gear VR Controller
  43950. */
  43951. class GearVRController extends WebVRController {
  43952. /**
  43953. * Base Url for the controller model.
  43954. */
  43955. static MODEL_BASE_URL: string;
  43956. /**
  43957. * File name for the controller model.
  43958. */
  43959. static MODEL_FILENAME: string;
  43960. /**
  43961. * Gamepad Id prefix used to identify this controller.
  43962. */
  43963. static readonly GAMEPAD_ID_PREFIX: string;
  43964. private readonly _buttonIndexToObservableNameMap;
  43965. /**
  43966. * Creates a new GearVRController from a gamepad
  43967. * @param vrGamepad the gamepad that the controller should be created from
  43968. */
  43969. constructor(vrGamepad: any);
  43970. /**
  43971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43972. * @param scene scene in which to add meshes
  43973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43974. */
  43975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43976. /**
  43977. * Called once for each button that changed state since the last frame
  43978. * @param buttonIdx Which button index changed
  43979. * @param state New state of the button
  43980. * @param changes Which properties on the state changed since last frame
  43981. */
  43982. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43983. }
  43984. }
  43985. declare module BABYLON {
  43986. /**
  43987. * Generic Controller
  43988. */
  43989. class GenericController extends WebVRController {
  43990. /**
  43991. * Base Url for the controller model.
  43992. */
  43993. static readonly MODEL_BASE_URL: string;
  43994. /**
  43995. * File name for the controller model.
  43996. */
  43997. static readonly MODEL_FILENAME: string;
  43998. /**
  43999. * Creates a new GenericController from a gamepad
  44000. * @param vrGamepad the gamepad that the controller should be created from
  44001. */
  44002. constructor(vrGamepad: any);
  44003. /**
  44004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44005. * @param scene scene in which to add meshes
  44006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44007. */
  44008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44009. /**
  44010. * Called once for each button that changed state since the last frame
  44011. * @param buttonIdx Which button index changed
  44012. * @param state New state of the button
  44013. * @param changes Which properties on the state changed since last frame
  44014. */
  44015. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44016. }
  44017. }
  44018. declare module BABYLON {
  44019. /**
  44020. * Oculus Touch Controller
  44021. */
  44022. class OculusTouchController extends WebVRController {
  44023. /**
  44024. * Base Url for the controller model.
  44025. */
  44026. static MODEL_BASE_URL: string;
  44027. /**
  44028. * File name for the left controller model.
  44029. */
  44030. static MODEL_LEFT_FILENAME: string;
  44031. /**
  44032. * File name for the right controller model.
  44033. */
  44034. static MODEL_RIGHT_FILENAME: string;
  44035. /**
  44036. * Fired when the secondary trigger on this controller is modified
  44037. */
  44038. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44039. /**
  44040. * Fired when the thumb rest on this controller is modified
  44041. */
  44042. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44043. /**
  44044. * Creates a new OculusTouchController from a gamepad
  44045. * @param vrGamepad the gamepad that the controller should be created from
  44046. */
  44047. constructor(vrGamepad: any);
  44048. /**
  44049. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44050. * @param scene scene in which to add meshes
  44051. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44052. */
  44053. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44054. /**
  44055. * Fired when the A button on this controller is modified
  44056. */
  44057. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44058. /**
  44059. * Fired when the B button on this controller is modified
  44060. */
  44061. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44062. /**
  44063. * Fired when the X button on this controller is modified
  44064. */
  44065. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44066. /**
  44067. * Fired when the Y button on this controller is modified
  44068. */
  44069. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44070. /**
  44071. * Called once for each button that changed state since the last frame
  44072. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44073. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44074. * 2) secondary trigger (same)
  44075. * 3) A (right) X (left), touch, pressed = value
  44076. * 4) B / Y
  44077. * 5) thumb rest
  44078. * @param buttonIdx Which button index changed
  44079. * @param state New state of the button
  44080. * @param changes Which properties on the state changed since last frame
  44081. */
  44082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44083. }
  44084. }
  44085. declare module BABYLON {
  44086. /**
  44087. * Defines the types of pose enabled controllers that are supported
  44088. */
  44089. enum PoseEnabledControllerType {
  44090. /**
  44091. * HTC Vive
  44092. */
  44093. VIVE = 0,
  44094. /**
  44095. * Oculus Rift
  44096. */
  44097. OCULUS = 1,
  44098. /**
  44099. * Windows mixed reality
  44100. */
  44101. WINDOWS = 2,
  44102. /**
  44103. * Samsung gear VR
  44104. */
  44105. GEAR_VR = 3,
  44106. /**
  44107. * Google Daydream
  44108. */
  44109. DAYDREAM = 4,
  44110. /**
  44111. * Generic
  44112. */
  44113. GENERIC = 5
  44114. }
  44115. /**
  44116. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44117. */
  44118. interface MutableGamepadButton {
  44119. /**
  44120. * Value of the button/trigger
  44121. */
  44122. value: number;
  44123. /**
  44124. * If the button/trigger is currently touched
  44125. */
  44126. touched: boolean;
  44127. /**
  44128. * If the button/trigger is currently pressed
  44129. */
  44130. pressed: boolean;
  44131. }
  44132. /**
  44133. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44134. * @hidden
  44135. */
  44136. interface ExtendedGamepadButton extends GamepadButton {
  44137. /**
  44138. * If the button/trigger is currently pressed
  44139. */
  44140. readonly pressed: boolean;
  44141. /**
  44142. * If the button/trigger is currently touched
  44143. */
  44144. readonly touched: boolean;
  44145. /**
  44146. * Value of the button/trigger
  44147. */
  44148. readonly value: number;
  44149. }
  44150. /**
  44151. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44152. */
  44153. class PoseEnabledControllerHelper {
  44154. /**
  44155. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44156. * @param vrGamepad the gamepad to initialized
  44157. * @returns a vr controller of the type the gamepad identified as
  44158. */
  44159. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44160. }
  44161. /**
  44162. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44163. */
  44164. class PoseEnabledController extends Gamepad implements PoseControlled {
  44165. private _deviceRoomPosition;
  44166. private _deviceRoomRotationQuaternion;
  44167. /**
  44168. * The device position in babylon space
  44169. */
  44170. devicePosition: Vector3;
  44171. /**
  44172. * The device rotation in babylon space
  44173. */
  44174. deviceRotationQuaternion: Quaternion;
  44175. /**
  44176. * The scale factor of the device in babylon space
  44177. */
  44178. deviceScaleFactor: number;
  44179. /**
  44180. * (Likely devicePosition should be used instead) The device position in its room space
  44181. */
  44182. position: Vector3;
  44183. /**
  44184. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44185. */
  44186. rotationQuaternion: Quaternion;
  44187. /**
  44188. * The type of controller (Eg. Windows mixed reality)
  44189. */
  44190. controllerType: PoseEnabledControllerType;
  44191. protected _calculatedPosition: Vector3;
  44192. private _calculatedRotation;
  44193. /**
  44194. * The raw pose from the device
  44195. */
  44196. rawPose: DevicePose;
  44197. private _trackPosition;
  44198. private _maxRotationDistFromHeadset;
  44199. private _draggedRoomRotation;
  44200. /**
  44201. * @hidden
  44202. */
  44203. _disableTrackPosition(fixedPosition: Vector3): void;
  44204. /**
  44205. * Internal, the mesh attached to the controller
  44206. * @hidden
  44207. */
  44208. _mesh: Nullable<AbstractMesh>;
  44209. private _poseControlledCamera;
  44210. private _leftHandSystemQuaternion;
  44211. /**
  44212. * Internal, matrix used to convert room space to babylon space
  44213. * @hidden
  44214. */
  44215. _deviceToWorld: Matrix;
  44216. /**
  44217. * Node to be used when casting a ray from the controller
  44218. * @hidden
  44219. */
  44220. _pointingPoseNode: Nullable<TransformNode>;
  44221. /**
  44222. * Name of the child mesh that can be used to cast a ray from the controller
  44223. */
  44224. static readonly POINTING_POSE: string;
  44225. /**
  44226. * Creates a new PoseEnabledController from a gamepad
  44227. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44228. */
  44229. constructor(browserGamepad: any);
  44230. private _workingMatrix;
  44231. /**
  44232. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44233. */
  44234. update(): void;
  44235. /**
  44236. * Updates only the pose device and mesh without doing any button event checking
  44237. */
  44238. protected _updatePoseAndMesh(): void;
  44239. /**
  44240. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44241. * @param poseData raw pose fromthe device
  44242. */
  44243. updateFromDevice(poseData: DevicePose): void;
  44244. /**
  44245. * @hidden
  44246. */
  44247. _meshAttachedObservable: Observable<AbstractMesh>;
  44248. /**
  44249. * Attaches a mesh to the controller
  44250. * @param mesh the mesh to be attached
  44251. */
  44252. attachToMesh(mesh: AbstractMesh): void;
  44253. /**
  44254. * Attaches the controllers mesh to a camera
  44255. * @param camera the camera the mesh should be attached to
  44256. */
  44257. attachToPoseControlledCamera(camera: TargetCamera): void;
  44258. /**
  44259. * Disposes of the controller
  44260. */
  44261. dispose(): void;
  44262. /**
  44263. * The mesh that is attached to the controller
  44264. */
  44265. readonly mesh: Nullable<AbstractMesh>;
  44266. /**
  44267. * Gets the ray of the controller in the direction the controller is pointing
  44268. * @param length the length the resulting ray should be
  44269. * @returns a ray in the direction the controller is pointing
  44270. */
  44271. getForwardRay(length?: number): Ray;
  44272. }
  44273. }
  44274. declare module BABYLON {
  44275. /**
  44276. * Vive Controller
  44277. */
  44278. class ViveController extends WebVRController {
  44279. /**
  44280. * Base Url for the controller model.
  44281. */
  44282. static MODEL_BASE_URL: string;
  44283. /**
  44284. * File name for the controller model.
  44285. */
  44286. static MODEL_FILENAME: string;
  44287. /**
  44288. * Creates a new ViveController from a gamepad
  44289. * @param vrGamepad the gamepad that the controller should be created from
  44290. */
  44291. constructor(vrGamepad: any);
  44292. /**
  44293. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44294. * @param scene scene in which to add meshes
  44295. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44296. */
  44297. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44298. /**
  44299. * Fired when the left button on this controller is modified
  44300. */
  44301. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44302. /**
  44303. * Fired when the right button on this controller is modified
  44304. */
  44305. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44306. /**
  44307. * Fired when the menu button on this controller is modified
  44308. */
  44309. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44310. /**
  44311. * Called once for each button that changed state since the last frame
  44312. * Vive mapping:
  44313. * 0: touchpad
  44314. * 1: trigger
  44315. * 2: left AND right buttons
  44316. * 3: menu button
  44317. * @param buttonIdx Which button index changed
  44318. * @param state New state of the button
  44319. * @param changes Which properties on the state changed since last frame
  44320. */
  44321. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44322. }
  44323. }
  44324. declare module BABYLON {
  44325. /**
  44326. * Defines the WebVRController object that represents controllers tracked in 3D space
  44327. */
  44328. abstract class WebVRController extends PoseEnabledController {
  44329. /**
  44330. * Internal, the default controller model for the controller
  44331. */
  44332. protected _defaultModel: AbstractMesh;
  44333. /**
  44334. * Fired when the trigger state has changed
  44335. */
  44336. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44337. /**
  44338. * Fired when the main button state has changed
  44339. */
  44340. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44341. /**
  44342. * Fired when the secondary button state has changed
  44343. */
  44344. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44345. /**
  44346. * Fired when the pad state has changed
  44347. */
  44348. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44349. /**
  44350. * Fired when controllers stick values have changed
  44351. */
  44352. onPadValuesChangedObservable: Observable<StickValues>;
  44353. /**
  44354. * Array of button availible on the controller
  44355. */
  44356. protected _buttons: Array<MutableGamepadButton>;
  44357. private _onButtonStateChange;
  44358. /**
  44359. * Fired when a controller button's state has changed
  44360. * @param callback the callback containing the button that was modified
  44361. */
  44362. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44363. /**
  44364. * X and Y axis corrisponding to the controllers joystick
  44365. */
  44366. pad: StickValues;
  44367. /**
  44368. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44369. */
  44370. hand: string;
  44371. /**
  44372. * The default controller model for the controller
  44373. */
  44374. readonly defaultModel: AbstractMesh;
  44375. /**
  44376. * Creates a new WebVRController from a gamepad
  44377. * @param vrGamepad the gamepad that the WebVRController should be created from
  44378. */
  44379. constructor(vrGamepad: any);
  44380. /**
  44381. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44382. */
  44383. update(): void;
  44384. /**
  44385. * Function to be called when a button is modified
  44386. */
  44387. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44388. /**
  44389. * Loads a mesh and attaches it to the controller
  44390. * @param scene the scene the mesh should be added to
  44391. * @param meshLoaded callback for when the mesh has been loaded
  44392. */
  44393. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44394. private _setButtonValue;
  44395. private _changes;
  44396. private _checkChanges;
  44397. /**
  44398. * Disposes of th webVRCOntroller
  44399. */
  44400. dispose(): void;
  44401. }
  44402. }
  44403. declare module BABYLON {
  44404. /**
  44405. * Defines the WindowsMotionController object that the state of the windows motion controller
  44406. */
  44407. class WindowsMotionController extends WebVRController {
  44408. /**
  44409. * The base url used to load the left and right controller models
  44410. */
  44411. static MODEL_BASE_URL: string;
  44412. /**
  44413. * The name of the left controller model file
  44414. */
  44415. static MODEL_LEFT_FILENAME: string;
  44416. /**
  44417. * The name of the right controller model file
  44418. */
  44419. static MODEL_RIGHT_FILENAME: string;
  44420. /**
  44421. * The controller name prefix for this controller type
  44422. */
  44423. static readonly GAMEPAD_ID_PREFIX: string;
  44424. /**
  44425. * The controller id pattern for this controller type
  44426. */
  44427. private static readonly GAMEPAD_ID_PATTERN;
  44428. private _loadedMeshInfo;
  44429. private readonly _mapping;
  44430. /**
  44431. * Fired when the trackpad on this controller is clicked
  44432. */
  44433. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44434. /**
  44435. * Fired when the trackpad on this controller is modified
  44436. */
  44437. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44438. /**
  44439. * The current x and y values of this controller's trackpad
  44440. */
  44441. trackpad: StickValues;
  44442. /**
  44443. * Creates a new WindowsMotionController from a gamepad
  44444. * @param vrGamepad the gamepad that the controller should be created from
  44445. */
  44446. constructor(vrGamepad: any);
  44447. /**
  44448. * Fired when the trigger on this controller is modified
  44449. */
  44450. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44451. /**
  44452. * Fired when the menu button on this controller is modified
  44453. */
  44454. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44455. /**
  44456. * Fired when the grip button on this controller is modified
  44457. */
  44458. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44459. /**
  44460. * Fired when the thumbstick button on this controller is modified
  44461. */
  44462. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44463. /**
  44464. * Fired when the touchpad button on this controller is modified
  44465. */
  44466. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44467. /**
  44468. * Fired when the touchpad values on this controller are modified
  44469. */
  44470. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44471. private _updateTrackpad;
  44472. /**
  44473. * Called once per frame by the engine.
  44474. */
  44475. update(): void;
  44476. /**
  44477. * Called once for each button that changed state since the last frame
  44478. * @param buttonIdx Which button index changed
  44479. * @param state New state of the button
  44480. * @param changes Which properties on the state changed since last frame
  44481. */
  44482. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44483. /**
  44484. * Moves the buttons on the controller mesh based on their current state
  44485. * @param buttonName the name of the button to move
  44486. * @param buttonValue the value of the button which determines the buttons new position
  44487. */
  44488. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44489. /**
  44490. * Moves the axis on the controller mesh based on its current state
  44491. * @param axis the index of the axis
  44492. * @param axisValue the value of the axis which determines the meshes new position
  44493. * @hidden
  44494. */
  44495. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44496. /**
  44497. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44498. * @param scene scene in which to add meshes
  44499. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44500. */
  44501. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44502. /**
  44503. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44504. * can be transformed by button presses and axes values, based on this._mapping.
  44505. *
  44506. * @param scene scene in which the meshes exist
  44507. * @param meshes list of meshes that make up the controller model to process
  44508. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44509. */
  44510. private processModel;
  44511. private createMeshInfo;
  44512. /**
  44513. * Gets the ray of the controller in the direction the controller is pointing
  44514. * @param length the length the resulting ray should be
  44515. * @returns a ray in the direction the controller is pointing
  44516. */
  44517. getForwardRay(length?: number): Ray;
  44518. /**
  44519. * Disposes of the controller
  44520. */
  44521. dispose(): void;
  44522. }
  44523. }
  44524. declare module BABYLON {
  44525. /**
  44526. * Interface to implement to create a shadow generator compatible with BJS.
  44527. */
  44528. interface IShadowGenerator {
  44529. /**
  44530. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44531. * @returns The render target texture if present otherwise, null
  44532. */
  44533. getShadowMap(): Nullable<RenderTargetTexture>;
  44534. /**
  44535. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44536. * @returns The render target texture if the shadow map is present otherwise, null
  44537. */
  44538. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44539. /**
  44540. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44541. * @param subMesh The submesh we want to render in the shadow map
  44542. * @param useInstances Defines wether will draw in the map using instances
  44543. * @returns true if ready otherwise, false
  44544. */
  44545. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44546. /**
  44547. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44548. * @param defines Defines of the material we want to update
  44549. * @param lightIndex Index of the light in the enabled light list of the material
  44550. */
  44551. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44552. /**
  44553. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44554. * defined in the generator but impacting the effect).
  44555. * It implies the unifroms available on the materials are the standard BJS ones.
  44556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44557. * @param effect The effect we are binfing the information for
  44558. */
  44559. bindShadowLight(lightIndex: string, effect: Effect): void;
  44560. /**
  44561. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44562. * (eq to shadow prjection matrix * light transform matrix)
  44563. * @returns The transform matrix used to create the shadow map
  44564. */
  44565. getTransformMatrix(): Matrix;
  44566. /**
  44567. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44568. * Cube and 2D textures for instance.
  44569. */
  44570. recreateShadowMap(): void;
  44571. /**
  44572. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44573. * @param onCompiled Callback triggered at the and of the effects compilation
  44574. * @param options Sets of optional options forcing the compilation with different modes
  44575. */
  44576. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44577. useInstances: boolean;
  44578. }>): void;
  44579. /**
  44580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44581. * @param options Sets of optional options forcing the compilation with different modes
  44582. * @returns A promise that resolves when the compilation completes
  44583. */
  44584. forceCompilationAsync(options?: Partial<{
  44585. useInstances: boolean;
  44586. }>): Promise<void>;
  44587. /**
  44588. * Serializes the shadow generator setup to a json object.
  44589. * @returns The serialized JSON object
  44590. */
  44591. serialize(): any;
  44592. /**
  44593. * Disposes the Shadow map and related Textures and effects.
  44594. */
  44595. dispose(): void;
  44596. }
  44597. /**
  44598. * Default implementation IShadowGenerator.
  44599. * This is the main object responsible of generating shadows in the framework.
  44600. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44601. */
  44602. class ShadowGenerator implements IShadowGenerator {
  44603. /**
  44604. * Shadow generator mode None: no filtering applied.
  44605. */
  44606. static readonly FILTER_NONE: number;
  44607. /**
  44608. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44609. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44610. */
  44611. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44612. /**
  44613. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44614. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44615. */
  44616. static readonly FILTER_POISSONSAMPLING: number;
  44617. /**
  44618. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44619. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44620. */
  44621. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44622. /**
  44623. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44624. * edge artifacts on steep falloff.
  44625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44626. */
  44627. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44628. /**
  44629. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44630. * edge artifacts on steep falloff.
  44631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44632. */
  44633. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44634. /**
  44635. * Shadow generator mode PCF: Percentage Closer Filtering
  44636. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44637. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44638. */
  44639. static readonly FILTER_PCF: number;
  44640. /**
  44641. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44642. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44643. * Contact Hardening
  44644. */
  44645. static readonly FILTER_PCSS: number;
  44646. /**
  44647. * Reserved for PCF and PCSS
  44648. * Highest Quality.
  44649. *
  44650. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44651. *
  44652. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44653. */
  44654. static readonly QUALITY_HIGH: number;
  44655. /**
  44656. * Reserved for PCF and PCSS
  44657. * Good tradeoff for quality/perf cross devices
  44658. *
  44659. * Execute PCF on a 3*3 kernel.
  44660. *
  44661. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44662. */
  44663. static readonly QUALITY_MEDIUM: number;
  44664. /**
  44665. * Reserved for PCF and PCSS
  44666. * The lowest quality but the fastest.
  44667. *
  44668. * Execute PCF on a 1*1 kernel.
  44669. *
  44670. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44671. */
  44672. static readonly QUALITY_LOW: number;
  44673. private _bias;
  44674. /**
  44675. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44676. */
  44677. /**
  44678. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44679. */
  44680. bias: number;
  44681. private _normalBias;
  44682. /**
  44683. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44684. */
  44685. /**
  44686. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44687. */
  44688. normalBias: number;
  44689. private _blurBoxOffset;
  44690. /**
  44691. * Gets the blur box offset: offset applied during the blur pass.
  44692. * Only useful if useKernelBlur = false
  44693. */
  44694. /**
  44695. * Sets the blur box offset: offset applied during the blur pass.
  44696. * Only useful if useKernelBlur = false
  44697. */
  44698. blurBoxOffset: number;
  44699. private _blurScale;
  44700. /**
  44701. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44702. * 2 means half of the size.
  44703. */
  44704. /**
  44705. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44706. * 2 means half of the size.
  44707. */
  44708. blurScale: number;
  44709. private _blurKernel;
  44710. /**
  44711. * Gets the blur kernel: kernel size of the blur pass.
  44712. * Only useful if useKernelBlur = true
  44713. */
  44714. /**
  44715. * Sets the blur kernel: kernel size of the blur pass.
  44716. * Only useful if useKernelBlur = true
  44717. */
  44718. blurKernel: number;
  44719. private _useKernelBlur;
  44720. /**
  44721. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44722. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44723. */
  44724. /**
  44725. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44726. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44727. */
  44728. useKernelBlur: boolean;
  44729. private _depthScale;
  44730. /**
  44731. * Gets the depth scale used in ESM mode.
  44732. */
  44733. /**
  44734. * Sets the depth scale used in ESM mode.
  44735. * This can override the scale stored on the light.
  44736. */
  44737. depthScale: number;
  44738. private _filter;
  44739. /**
  44740. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44741. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44742. */
  44743. /**
  44744. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44745. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44746. */
  44747. filter: number;
  44748. /**
  44749. * Gets if the current filter is set to Poisson Sampling.
  44750. */
  44751. /**
  44752. * Sets the current filter to Poisson Sampling.
  44753. */
  44754. usePoissonSampling: boolean;
  44755. /**
  44756. * Gets if the current filter is set to ESM.
  44757. */
  44758. /**
  44759. * Sets the current filter is to ESM.
  44760. */
  44761. useExponentialShadowMap: boolean;
  44762. /**
  44763. * Gets if the current filter is set to filtered ESM.
  44764. */
  44765. /**
  44766. * Gets if the current filter is set to filtered ESM.
  44767. */
  44768. useBlurExponentialShadowMap: boolean;
  44769. /**
  44770. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44771. * exponential to prevent steep falloff artifacts).
  44772. */
  44773. /**
  44774. * Sets the current filter to "close ESM" (using the inverse of the
  44775. * exponential to prevent steep falloff artifacts).
  44776. */
  44777. useCloseExponentialShadowMap: boolean;
  44778. /**
  44779. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44780. * exponential to prevent steep falloff artifacts).
  44781. */
  44782. /**
  44783. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44784. * exponential to prevent steep falloff artifacts).
  44785. */
  44786. useBlurCloseExponentialShadowMap: boolean;
  44787. /**
  44788. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44789. */
  44790. /**
  44791. * Sets the current filter to "PCF" (percentage closer filtering).
  44792. */
  44793. usePercentageCloserFiltering: boolean;
  44794. private _filteringQuality;
  44795. /**
  44796. * Gets the PCF or PCSS Quality.
  44797. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44798. */
  44799. /**
  44800. * Sets the PCF or PCSS Quality.
  44801. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44802. */
  44803. filteringQuality: number;
  44804. /**
  44805. * Gets if the current filter is set to "PCSS" (contact hardening).
  44806. */
  44807. /**
  44808. * Sets the current filter to "PCSS" (contact hardening).
  44809. */
  44810. useContactHardeningShadow: boolean;
  44811. private _contactHardeningLightSizeUVRatio;
  44812. /**
  44813. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44814. * Using a ratio helps keeping shape stability independently of the map size.
  44815. *
  44816. * It does not account for the light projection as it was having too much
  44817. * instability during the light setup or during light position changes.
  44818. *
  44819. * Only valid if useContactHardeningShadow is true.
  44820. */
  44821. /**
  44822. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44823. * Using a ratio helps keeping shape stability independently of the map size.
  44824. *
  44825. * It does not account for the light projection as it was having too much
  44826. * instability during the light setup or during light position changes.
  44827. *
  44828. * Only valid if useContactHardeningShadow is true.
  44829. */
  44830. contactHardeningLightSizeUVRatio: number;
  44831. private _darkness;
  44832. /**
  44833. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44834. * 0 means strongest and 1 would means no shadow.
  44835. * @returns the darkness.
  44836. */
  44837. getDarkness(): number;
  44838. /**
  44839. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44840. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44841. * @returns the shadow generator allowing fluent coding.
  44842. */
  44843. setDarkness(darkness: number): ShadowGenerator;
  44844. private _transparencyShadow;
  44845. /**
  44846. * Sets the ability to have transparent shadow (boolean).
  44847. * @param transparent True if transparent else False
  44848. * @returns the shadow generator allowing fluent coding
  44849. */
  44850. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44851. private _shadowMap;
  44852. private _shadowMap2;
  44853. /**
  44854. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44855. * @returns The render target texture if present otherwise, null
  44856. */
  44857. getShadowMap(): Nullable<RenderTargetTexture>;
  44858. /**
  44859. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44860. * @returns The render target texture if the shadow map is present otherwise, null
  44861. */
  44862. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44863. /**
  44864. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44865. * @param mesh Mesh to add
  44866. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44867. * @returns the Shadow Generator itself
  44868. */
  44869. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44870. /**
  44871. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44872. * @param mesh Mesh to remove
  44873. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44874. * @returns the Shadow Generator itself
  44875. */
  44876. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44877. /**
  44878. * Controls the extent to which the shadows fade out at the edge of the frustum
  44879. * Used only by directionals and spots
  44880. */
  44881. frustumEdgeFalloff: number;
  44882. private _light;
  44883. /**
  44884. * Returns the associated light object.
  44885. * @returns the light generating the shadow
  44886. */
  44887. getLight(): IShadowLight;
  44888. /**
  44889. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44890. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44891. * It might on the other hand introduce peter panning.
  44892. */
  44893. forceBackFacesOnly: boolean;
  44894. private _scene;
  44895. private _lightDirection;
  44896. private _effect;
  44897. private _viewMatrix;
  44898. private _projectionMatrix;
  44899. private _transformMatrix;
  44900. private _cachedPosition;
  44901. private _cachedDirection;
  44902. private _cachedDefines;
  44903. private _currentRenderID;
  44904. private _boxBlurPostprocess;
  44905. private _kernelBlurXPostprocess;
  44906. private _kernelBlurYPostprocess;
  44907. private _blurPostProcesses;
  44908. private _mapSize;
  44909. private _currentFaceIndex;
  44910. private _currentFaceIndexCache;
  44911. private _textureType;
  44912. private _defaultTextureMatrix;
  44913. /**
  44914. * Creates a ShadowGenerator object.
  44915. * A ShadowGenerator is the required tool to use the shadows.
  44916. * Each light casting shadows needs to use its own ShadowGenerator.
  44917. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44918. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44919. * @param light The light object generating the shadows.
  44920. * @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.
  44921. */
  44922. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44923. private _initializeGenerator;
  44924. private _initializeShadowMap;
  44925. private _initializeBlurRTTAndPostProcesses;
  44926. private _renderForShadowMap;
  44927. private _renderSubMeshForShadowMap;
  44928. private _applyFilterValues;
  44929. /**
  44930. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44931. * @param onCompiled Callback triggered at the and of the effects compilation
  44932. * @param options Sets of optional options forcing the compilation with different modes
  44933. */
  44934. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44935. useInstances: boolean;
  44936. }>): void;
  44937. /**
  44938. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44939. * @param options Sets of optional options forcing the compilation with different modes
  44940. * @returns A promise that resolves when the compilation completes
  44941. */
  44942. forceCompilationAsync(options?: Partial<{
  44943. useInstances: boolean;
  44944. }>): Promise<void>;
  44945. /**
  44946. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44947. * @param subMesh The submesh we want to render in the shadow map
  44948. * @param useInstances Defines wether will draw in the map using instances
  44949. * @returns true if ready otherwise, false
  44950. */
  44951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44952. /**
  44953. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44954. * @param defines Defines of the material we want to update
  44955. * @param lightIndex Index of the light in the enabled light list of the material
  44956. */
  44957. prepareDefines(defines: any, lightIndex: number): void;
  44958. /**
  44959. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44960. * defined in the generator but impacting the effect).
  44961. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44962. * @param effect The effect we are binfing the information for
  44963. */
  44964. bindShadowLight(lightIndex: string, effect: Effect): void;
  44965. /**
  44966. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44967. * (eq to shadow prjection matrix * light transform matrix)
  44968. * @returns The transform matrix used to create the shadow map
  44969. */
  44970. getTransformMatrix(): Matrix;
  44971. /**
  44972. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44973. * Cube and 2D textures for instance.
  44974. */
  44975. recreateShadowMap(): void;
  44976. private _disposeBlurPostProcesses;
  44977. private _disposeRTTandPostProcesses;
  44978. /**
  44979. * Disposes the ShadowGenerator.
  44980. * Returns nothing.
  44981. */
  44982. dispose(): void;
  44983. /**
  44984. * Serializes the shadow generator setup to a json object.
  44985. * @returns The serialized JSON object
  44986. */
  44987. serialize(): any;
  44988. /**
  44989. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44990. * @param parsedShadowGenerator The JSON object to parse
  44991. * @param scene The scene to create the shadow map for
  44992. * @returns The parsed shadow generator
  44993. */
  44994. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44995. }
  44996. }
  44997. declare module BABYLON {
  44998. /**
  44999. * Defines the shadow generator component responsible to manage any shadow generators
  45000. * in a given scene.
  45001. */
  45002. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  45003. /**
  45004. * The component name helpfull to identify the component in the list of scene components.
  45005. */
  45006. readonly name: string;
  45007. /**
  45008. * The scene the component belongs to.
  45009. */
  45010. scene: Scene;
  45011. /**
  45012. * Creates a new instance of the component for the given scene
  45013. * @param scene Defines the scene to register the component in
  45014. */
  45015. constructor(scene: Scene);
  45016. /**
  45017. * Registers the component in a given scene
  45018. */
  45019. register(): void;
  45020. /**
  45021. * Rebuilds the elements related to this component in case of
  45022. * context lost for instance.
  45023. */
  45024. rebuild(): void;
  45025. /**
  45026. * Serializes the component data to the specified json object
  45027. * @param serializationObject The object to serialize to
  45028. */
  45029. serialize(serializationObject: any): void;
  45030. /**
  45031. * Adds all the element from the container to the scene
  45032. * @param container the container holding the elements
  45033. */
  45034. addFromContainer(container: AbstractScene): void;
  45035. /**
  45036. * Removes all the elements in the container from the scene
  45037. * @param container contains the elements to remove
  45038. */
  45039. removeFromContainer(container: AbstractScene): void;
  45040. /**
  45041. * Rebuilds the elements related to this component in case of
  45042. * context lost for instance.
  45043. */
  45044. dispose(): void;
  45045. private _gatherRenderTargets;
  45046. }
  45047. }
  45048. declare module BABYLON {
  45049. }
  45050. declare module BABYLON {
  45051. /**
  45052. * Background material used to create an efficient environement around your scene.
  45053. */
  45054. class BackgroundMaterial extends PushMaterial {
  45055. /**
  45056. * Standard reflectance value at parallel view angle.
  45057. */
  45058. static StandardReflectance0: number;
  45059. /**
  45060. * Standard reflectance value at grazing angle.
  45061. */
  45062. static StandardReflectance90: number;
  45063. protected _primaryColor: Color3;
  45064. /**
  45065. * Key light Color (multiply against the environement texture)
  45066. */
  45067. primaryColor: Color3;
  45068. protected __perceptualColor: Nullable<Color3>;
  45069. /**
  45070. * Experimental Internal Use Only.
  45071. *
  45072. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45073. * This acts as a helper to set the primary color to a more "human friendly" value.
  45074. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45075. * output color as close as possible from the chosen value.
  45076. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45077. * part of lighting setup.)
  45078. */
  45079. _perceptualColor: Nullable<Color3>;
  45080. protected _primaryColorShadowLevel: float;
  45081. /**
  45082. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45083. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45084. */
  45085. primaryColorShadowLevel: float;
  45086. protected _primaryColorHighlightLevel: float;
  45087. /**
  45088. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45089. * The primary color is used at the level chosen to define what the white area would look.
  45090. */
  45091. primaryColorHighlightLevel: float;
  45092. protected _reflectionTexture: Nullable<BaseTexture>;
  45093. /**
  45094. * Reflection Texture used in the material.
  45095. * Should be author in a specific way for the best result (refer to the documentation).
  45096. */
  45097. reflectionTexture: Nullable<BaseTexture>;
  45098. protected _reflectionBlur: float;
  45099. /**
  45100. * Reflection Texture level of blur.
  45101. *
  45102. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45103. * texture twice.
  45104. */
  45105. reflectionBlur: float;
  45106. protected _diffuseTexture: Nullable<BaseTexture>;
  45107. /**
  45108. * Diffuse Texture used in the material.
  45109. * Should be author in a specific way for the best result (refer to the documentation).
  45110. */
  45111. diffuseTexture: Nullable<BaseTexture>;
  45112. protected _shadowLights: Nullable<IShadowLight[]>;
  45113. /**
  45114. * Specify the list of lights casting shadow on the material.
  45115. * All scene shadow lights will be included if null.
  45116. */
  45117. shadowLights: Nullable<IShadowLight[]>;
  45118. protected _shadowLevel: float;
  45119. /**
  45120. * Helps adjusting the shadow to a softer level if required.
  45121. * 0 means black shadows and 1 means no shadows.
  45122. */
  45123. shadowLevel: float;
  45124. protected _sceneCenter: Vector3;
  45125. /**
  45126. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45127. * It is usually zero but might be interesting to modify according to your setup.
  45128. */
  45129. sceneCenter: Vector3;
  45130. protected _opacityFresnel: boolean;
  45131. /**
  45132. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45133. * This helps ensuring a nice transition when the camera goes under the ground.
  45134. */
  45135. opacityFresnel: boolean;
  45136. protected _reflectionFresnel: boolean;
  45137. /**
  45138. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45139. * This helps adding a mirror texture on the ground.
  45140. */
  45141. reflectionFresnel: boolean;
  45142. protected _reflectionFalloffDistance: number;
  45143. /**
  45144. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45145. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45146. */
  45147. reflectionFalloffDistance: number;
  45148. protected _reflectionAmount: number;
  45149. /**
  45150. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45151. */
  45152. reflectionAmount: number;
  45153. protected _reflectionReflectance0: number;
  45154. /**
  45155. * This specifies the weight of the reflection at grazing angle.
  45156. */
  45157. reflectionReflectance0: number;
  45158. protected _reflectionReflectance90: number;
  45159. /**
  45160. * This specifies the weight of the reflection at a perpendicular point of view.
  45161. */
  45162. reflectionReflectance90: number;
  45163. /**
  45164. * Sets the reflection reflectance fresnel values according to the default standard
  45165. * empirically know to work well :-)
  45166. */
  45167. reflectionStandardFresnelWeight: number;
  45168. protected _useRGBColor: boolean;
  45169. /**
  45170. * Helps to directly use the maps channels instead of their level.
  45171. */
  45172. useRGBColor: boolean;
  45173. protected _enableNoise: boolean;
  45174. /**
  45175. * This helps reducing the banding effect that could occur on the background.
  45176. */
  45177. enableNoise: boolean;
  45178. /**
  45179. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45180. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45181. * Recommended to be keep at 1.0 except for special cases.
  45182. */
  45183. fovMultiplier: number;
  45184. private _fovMultiplier;
  45185. /**
  45186. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45187. */
  45188. useEquirectangularFOV: boolean;
  45189. private _maxSimultaneousLights;
  45190. /**
  45191. * Number of Simultaneous lights allowed on the material.
  45192. */
  45193. maxSimultaneousLights: int;
  45194. /**
  45195. * Default configuration related to image processing available in the Background Material.
  45196. */
  45197. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45198. /**
  45199. * Keep track of the image processing observer to allow dispose and replace.
  45200. */
  45201. private _imageProcessingObserver;
  45202. /**
  45203. * Attaches a new image processing configuration to the PBR Material.
  45204. * @param configuration (if null the scene configuration will be use)
  45205. */
  45206. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45207. /**
  45208. * Gets the image processing configuration used either in this material.
  45209. */
  45210. /**
  45211. * Sets the Default image processing configuration used either in the this material.
  45212. *
  45213. * If sets to null, the scene one is in use.
  45214. */
  45215. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45216. /**
  45217. * Gets wether the color curves effect is enabled.
  45218. */
  45219. /**
  45220. * Sets wether the color curves effect is enabled.
  45221. */
  45222. cameraColorCurvesEnabled: boolean;
  45223. /**
  45224. * Gets wether the color grading effect is enabled.
  45225. */
  45226. /**
  45227. * Gets wether the color grading effect is enabled.
  45228. */
  45229. cameraColorGradingEnabled: boolean;
  45230. /**
  45231. * Gets wether tonemapping is enabled or not.
  45232. */
  45233. /**
  45234. * Sets wether tonemapping is enabled or not
  45235. */
  45236. cameraToneMappingEnabled: boolean;
  45237. /**
  45238. * The camera exposure used on this material.
  45239. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45240. * This corresponds to a photographic exposure.
  45241. */
  45242. /**
  45243. * The camera exposure used on this material.
  45244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45245. * This corresponds to a photographic exposure.
  45246. */
  45247. cameraExposure: float;
  45248. /**
  45249. * Gets The camera contrast used on this material.
  45250. */
  45251. /**
  45252. * Sets The camera contrast used on this material.
  45253. */
  45254. cameraContrast: float;
  45255. /**
  45256. * Gets the Color Grading 2D Lookup Texture.
  45257. */
  45258. /**
  45259. * Sets the Color Grading 2D Lookup Texture.
  45260. */
  45261. cameraColorGradingTexture: Nullable<BaseTexture>;
  45262. /**
  45263. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45264. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45265. * 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;
  45266. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45267. */
  45268. /**
  45269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45271. * 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;
  45272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45273. */
  45274. cameraColorCurves: Nullable<ColorCurves>;
  45275. /**
  45276. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45277. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45278. */
  45279. switchToBGR: boolean;
  45280. private _renderTargets;
  45281. private _reflectionControls;
  45282. private _white;
  45283. private _primaryShadowColor;
  45284. private _primaryHighlightColor;
  45285. /**
  45286. * Instantiates a Background Material in the given scene
  45287. * @param name The friendly name of the material
  45288. * @param scene The scene to add the material to
  45289. */
  45290. constructor(name: string, scene: Scene);
  45291. /**
  45292. * Gets a boolean indicating that current material needs to register RTT
  45293. */
  45294. readonly hasRenderTargetTextures: boolean;
  45295. /**
  45296. * The entire material has been created in order to prevent overdraw.
  45297. * @returns false
  45298. */
  45299. needAlphaTesting(): boolean;
  45300. /**
  45301. * The entire material has been created in order to prevent overdraw.
  45302. * @returns true if blending is enable
  45303. */
  45304. needAlphaBlending(): boolean;
  45305. /**
  45306. * Checks wether the material is ready to be rendered for a given mesh.
  45307. * @param mesh The mesh to render
  45308. * @param subMesh The submesh to check against
  45309. * @param useInstances Specify wether or not the material is used with instances
  45310. * @returns true if all the dependencies are ready (Textures, Effects...)
  45311. */
  45312. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45313. /**
  45314. * Compute the primary color according to the chosen perceptual color.
  45315. */
  45316. private _computePrimaryColorFromPerceptualColor;
  45317. /**
  45318. * Compute the highlights and shadow colors according to their chosen levels.
  45319. */
  45320. private _computePrimaryColors;
  45321. /**
  45322. * Build the uniform buffer used in the material.
  45323. */
  45324. buildUniformLayout(): void;
  45325. /**
  45326. * Unbind the material.
  45327. */
  45328. unbind(): void;
  45329. /**
  45330. * Bind only the world matrix to the material.
  45331. * @param world The world matrix to bind.
  45332. */
  45333. bindOnlyWorldMatrix(world: Matrix): void;
  45334. /**
  45335. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45336. * @param world The world matrix to bind.
  45337. * @param subMesh The submesh to bind for.
  45338. */
  45339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45340. /**
  45341. * Dispose the material.
  45342. * @param forceDisposeEffect Force disposal of the associated effect.
  45343. * @param forceDisposeTextures Force disposal of the associated textures.
  45344. */
  45345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45346. /**
  45347. * Clones the material.
  45348. * @param name The cloned name.
  45349. * @returns The cloned material.
  45350. */
  45351. clone(name: string): BackgroundMaterial;
  45352. /**
  45353. * Serializes the current material to its JSON representation.
  45354. * @returns The JSON representation.
  45355. */
  45356. serialize(): any;
  45357. /**
  45358. * Gets the class name of the material
  45359. * @returns "BackgroundMaterial"
  45360. */
  45361. getClassName(): string;
  45362. /**
  45363. * Parse a JSON input to create back a background material.
  45364. * @param source The JSON data to parse
  45365. * @param scene The scene to create the parsed material in
  45366. * @param rootUrl The root url of the assets the material depends upon
  45367. * @returns the instantiated BackgroundMaterial.
  45368. */
  45369. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45370. }
  45371. }
  45372. declare module BABYLON {
  45373. /**
  45374. * The Physically based material base class of BJS.
  45375. *
  45376. * This offers the main features of a standard PBR material.
  45377. * For more information, please refer to the documentation :
  45378. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45379. */
  45380. abstract class PBRBaseMaterial extends PushMaterial {
  45381. /**
  45382. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45383. */
  45384. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45385. /**
  45386. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45387. * to enhance interoperability with other engines.
  45388. */
  45389. static readonly LIGHTFALLOFF_GLTF: number;
  45390. /**
  45391. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45392. * to enhance interoperability with other materials.
  45393. */
  45394. static readonly LIGHTFALLOFF_STANDARD: number;
  45395. /**
  45396. * Intensity of the direct lights e.g. the four lights available in your scene.
  45397. * This impacts both the direct diffuse and specular highlights.
  45398. */
  45399. protected _directIntensity: number;
  45400. /**
  45401. * Intensity of the emissive part of the material.
  45402. * This helps controlling the emissive effect without modifying the emissive color.
  45403. */
  45404. protected _emissiveIntensity: number;
  45405. /**
  45406. * Intensity of the environment e.g. how much the environment will light the object
  45407. * either through harmonics for rough material or through the refelction for shiny ones.
  45408. */
  45409. protected _environmentIntensity: number;
  45410. /**
  45411. * This is a special control allowing the reduction of the specular highlights coming from the
  45412. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45413. */
  45414. protected _specularIntensity: number;
  45415. /**
  45416. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45417. */
  45418. private _lightingInfos;
  45419. /**
  45420. * Debug Control allowing disabling the bump map on this material.
  45421. */
  45422. protected _disableBumpMap: boolean;
  45423. /**
  45424. * AKA Diffuse Texture in standard nomenclature.
  45425. */
  45426. protected _albedoTexture: BaseTexture;
  45427. /**
  45428. * AKA Occlusion Texture in other nomenclature.
  45429. */
  45430. protected _ambientTexture: BaseTexture;
  45431. /**
  45432. * AKA Occlusion Texture Intensity in other nomenclature.
  45433. */
  45434. protected _ambientTextureStrength: number;
  45435. /**
  45436. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45437. * 1 means it completely occludes it
  45438. * 0 mean it has no impact
  45439. */
  45440. protected _ambientTextureImpactOnAnalyticalLights: number;
  45441. /**
  45442. * Stores the alpha values in a texture.
  45443. */
  45444. protected _opacityTexture: BaseTexture;
  45445. /**
  45446. * Stores the reflection values in a texture.
  45447. */
  45448. protected _reflectionTexture: BaseTexture;
  45449. /**
  45450. * Stores the refraction values in a texture.
  45451. */
  45452. protected _refractionTexture: BaseTexture;
  45453. /**
  45454. * Stores the emissive values in a texture.
  45455. */
  45456. protected _emissiveTexture: BaseTexture;
  45457. /**
  45458. * AKA Specular texture in other nomenclature.
  45459. */
  45460. protected _reflectivityTexture: BaseTexture;
  45461. /**
  45462. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45463. */
  45464. protected _metallicTexture: BaseTexture;
  45465. /**
  45466. * Specifies the metallic scalar of the metallic/roughness workflow.
  45467. * Can also be used to scale the metalness values of the metallic texture.
  45468. */
  45469. protected _metallic: Nullable<number>;
  45470. /**
  45471. * Specifies the roughness scalar of the metallic/roughness workflow.
  45472. * Can also be used to scale the roughness values of the metallic texture.
  45473. */
  45474. protected _roughness: Nullable<number>;
  45475. /**
  45476. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45477. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45478. */
  45479. protected _microSurfaceTexture: BaseTexture;
  45480. /**
  45481. * Stores surface normal data used to displace a mesh in a texture.
  45482. */
  45483. protected _bumpTexture: BaseTexture;
  45484. /**
  45485. * Stores the pre-calculated light information of a mesh in a texture.
  45486. */
  45487. protected _lightmapTexture: BaseTexture;
  45488. /**
  45489. * The color of a material in ambient lighting.
  45490. */
  45491. protected _ambientColor: Color3;
  45492. /**
  45493. * AKA Diffuse Color in other nomenclature.
  45494. */
  45495. protected _albedoColor: Color3;
  45496. /**
  45497. * AKA Specular Color in other nomenclature.
  45498. */
  45499. protected _reflectivityColor: Color3;
  45500. /**
  45501. * The color applied when light is reflected from a material.
  45502. */
  45503. protected _reflectionColor: Color3;
  45504. /**
  45505. * The color applied when light is emitted from a material.
  45506. */
  45507. protected _emissiveColor: Color3;
  45508. /**
  45509. * AKA Glossiness in other nomenclature.
  45510. */
  45511. protected _microSurface: number;
  45512. /**
  45513. * source material index of refraction (IOR)' / 'destination material IOR.
  45514. */
  45515. protected _indexOfRefraction: number;
  45516. /**
  45517. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45518. */
  45519. protected _invertRefractionY: boolean;
  45520. /**
  45521. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45522. * Materials half opaque for instance using refraction could benefit from this control.
  45523. */
  45524. protected _linkRefractionWithTransparency: boolean;
  45525. /**
  45526. * Specifies that the material will use the light map as a show map.
  45527. */
  45528. protected _useLightmapAsShadowmap: boolean;
  45529. /**
  45530. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45531. * makes the reflect vector face the model (under horizon).
  45532. */
  45533. protected _useHorizonOcclusion: boolean;
  45534. /**
  45535. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45536. * too much the area relying on ambient texture to define their ambient occlusion.
  45537. */
  45538. protected _useRadianceOcclusion: boolean;
  45539. /**
  45540. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45541. */
  45542. protected _useAlphaFromAlbedoTexture: boolean;
  45543. /**
  45544. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45545. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45546. */
  45547. protected _useSpecularOverAlpha: boolean;
  45548. /**
  45549. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45550. */
  45551. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45552. /**
  45553. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45554. */
  45555. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45556. /**
  45557. * Specifies if the metallic texture contains the roughness information in its green channel.
  45558. */
  45559. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45560. /**
  45561. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45562. */
  45563. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45564. /**
  45565. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45566. */
  45567. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45568. /**
  45569. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45570. */
  45571. protected _useAmbientInGrayScale: boolean;
  45572. /**
  45573. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45574. * The material will try to infer what glossiness each pixel should be.
  45575. */
  45576. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45577. /**
  45578. * Defines the falloff type used in this material.
  45579. * It by default is Physical.
  45580. */
  45581. protected _lightFalloff: number;
  45582. /**
  45583. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45584. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45585. */
  45586. protected _useRadianceOverAlpha: boolean;
  45587. /**
  45588. * Allows using an object space normal map (instead of tangent space).
  45589. */
  45590. protected _useObjectSpaceNormalMap: boolean;
  45591. /**
  45592. * Allows using the bump map in parallax mode.
  45593. */
  45594. protected _useParallax: boolean;
  45595. /**
  45596. * Allows using the bump map in parallax occlusion mode.
  45597. */
  45598. protected _useParallaxOcclusion: boolean;
  45599. /**
  45600. * Controls the scale bias of the parallax mode.
  45601. */
  45602. protected _parallaxScaleBias: number;
  45603. /**
  45604. * If sets to true, disables all the lights affecting the material.
  45605. */
  45606. protected _disableLighting: boolean;
  45607. /**
  45608. * Number of Simultaneous lights allowed on the material.
  45609. */
  45610. protected _maxSimultaneousLights: number;
  45611. /**
  45612. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45613. */
  45614. protected _invertNormalMapX: boolean;
  45615. /**
  45616. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45617. */
  45618. protected _invertNormalMapY: boolean;
  45619. /**
  45620. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45621. */
  45622. protected _twoSidedLighting: boolean;
  45623. /**
  45624. * Defines the alpha limits in alpha test mode.
  45625. */
  45626. protected _alphaCutOff: number;
  45627. /**
  45628. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45629. */
  45630. protected _forceAlphaTest: boolean;
  45631. /**
  45632. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45633. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45634. */
  45635. protected _useAlphaFresnel: boolean;
  45636. /**
  45637. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45638. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45639. */
  45640. protected _useLinearAlphaFresnel: boolean;
  45641. /**
  45642. * The transparency mode of the material.
  45643. */
  45644. protected _transparencyMode: Nullable<number>;
  45645. /**
  45646. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45647. * from cos thetav and roughness:
  45648. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45649. */
  45650. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45651. /**
  45652. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45653. */
  45654. protected _forceIrradianceInFragment: boolean;
  45655. /**
  45656. * Force normal to face away from face.
  45657. */
  45658. protected _forceNormalForward: boolean;
  45659. /**
  45660. * Enables specular anti aliasing in the PBR shader.
  45661. * It will both interacts on the Geometry for analytical and IBL lighting.
  45662. * It also prefilter the roughness map based on the bump values.
  45663. */
  45664. protected _enableSpecularAntiAliasing: boolean;
  45665. /**
  45666. * Default configuration related to image processing available in the PBR Material.
  45667. */
  45668. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45669. /**
  45670. * Keep track of the image processing observer to allow dispose and replace.
  45671. */
  45672. private _imageProcessingObserver;
  45673. /**
  45674. * Attaches a new image processing configuration to the PBR Material.
  45675. * @param configuration
  45676. */
  45677. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45678. /**
  45679. * Stores the available render targets.
  45680. */
  45681. private _renderTargets;
  45682. /**
  45683. * Sets the global ambient color for the material used in lighting calculations.
  45684. */
  45685. private _globalAmbientColor;
  45686. /**
  45687. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45688. */
  45689. private _useLogarithmicDepth;
  45690. /**
  45691. * If set to true, no lighting calculations will be applied.
  45692. */
  45693. private _unlit;
  45694. /**
  45695. * Instantiates a new PBRMaterial instance.
  45696. *
  45697. * @param name The material name
  45698. * @param scene The scene the material will be use in.
  45699. */
  45700. constructor(name: string, scene: Scene);
  45701. /**
  45702. * Gets a boolean indicating that current material needs to register RTT
  45703. */
  45704. readonly hasRenderTargetTextures: boolean;
  45705. /**
  45706. * Gets the name of the material class.
  45707. */
  45708. getClassName(): string;
  45709. /**
  45710. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45711. */
  45712. /**
  45713. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45714. */
  45715. useLogarithmicDepth: boolean;
  45716. /**
  45717. * Gets the current transparency mode.
  45718. */
  45719. /**
  45720. * Sets the transparency mode of the material.
  45721. *
  45722. * | Value | Type | Description |
  45723. * | ----- | ----------------------------------- | ----------- |
  45724. * | 0 | OPAQUE | |
  45725. * | 1 | ALPHATEST | |
  45726. * | 2 | ALPHABLEND | |
  45727. * | 3 | ALPHATESTANDBLEND | |
  45728. *
  45729. */
  45730. transparencyMode: Nullable<number>;
  45731. /**
  45732. * Returns true if alpha blending should be disabled.
  45733. */
  45734. private readonly _disableAlphaBlending;
  45735. /**
  45736. * Specifies whether or not this material should be rendered in alpha blend mode.
  45737. */
  45738. needAlphaBlending(): boolean;
  45739. /**
  45740. * Specifies if the mesh will require alpha blending.
  45741. * @param mesh - BJS mesh.
  45742. */
  45743. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45744. /**
  45745. * Specifies whether or not this material should be rendered in alpha test mode.
  45746. */
  45747. needAlphaTesting(): boolean;
  45748. /**
  45749. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45750. */
  45751. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45752. /**
  45753. * Gets the texture used for the alpha test.
  45754. */
  45755. getAlphaTestTexture(): BaseTexture;
  45756. /**
  45757. * Stores the reflectivity values based on metallic roughness workflow.
  45758. */
  45759. private static _scaledReflectivity;
  45760. /**
  45761. * Specifies that the submesh is ready to be used.
  45762. * @param mesh - BJS mesh.
  45763. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45764. * @param useInstances - Specifies that instances should be used.
  45765. * @returns - boolean indicating that the submesh is ready or not.
  45766. */
  45767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45768. /**
  45769. * Specifies if the material uses metallic roughness workflow.
  45770. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45771. */
  45772. isMetallicWorkflow(): boolean;
  45773. private _prepareEffect;
  45774. private _prepareDefines;
  45775. /**
  45776. * Force shader compilation
  45777. */
  45778. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45779. clipPlane: boolean;
  45780. }>): void;
  45781. /**
  45782. * Initializes the uniform buffer layout for the shader.
  45783. */
  45784. buildUniformLayout(): void;
  45785. /**
  45786. * Unbinds the textures.
  45787. */
  45788. unbind(): void;
  45789. /**
  45790. * Binds the submesh data.
  45791. * @param world - The world matrix.
  45792. * @param mesh - The BJS mesh.
  45793. * @param subMesh - A submesh of the BJS mesh.
  45794. */
  45795. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45796. /**
  45797. * Returns the animatable textures.
  45798. * @returns - Array of animatable textures.
  45799. */
  45800. getAnimatables(): IAnimatable[];
  45801. /**
  45802. * Returns the texture used for reflections.
  45803. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45804. */
  45805. private _getReflectionTexture;
  45806. /**
  45807. * Returns the texture used for refraction or null if none is used.
  45808. * @returns - Refection texture if present. If no refraction texture and refraction
  45809. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45810. */
  45811. private _getRefractionTexture;
  45812. /**
  45813. * Disposes the resources of the material.
  45814. * @param forceDisposeEffect - Forces the disposal of effects.
  45815. * @param forceDisposeTextures - Forces the disposal of all textures.
  45816. */
  45817. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45818. }
  45819. }
  45820. declare module BABYLON {
  45821. /**
  45822. * The Physically based simple base material of BJS.
  45823. *
  45824. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45825. * It is used as the base class for both the specGloss and metalRough conventions.
  45826. */
  45827. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45828. /**
  45829. * Number of Simultaneous lights allowed on the material.
  45830. */
  45831. maxSimultaneousLights: number;
  45832. /**
  45833. * If sets to true, disables all the lights affecting the material.
  45834. */
  45835. disableLighting: boolean;
  45836. /**
  45837. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45838. */
  45839. environmentTexture: BaseTexture;
  45840. /**
  45841. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45842. */
  45843. invertNormalMapX: boolean;
  45844. /**
  45845. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45846. */
  45847. invertNormalMapY: boolean;
  45848. /**
  45849. * Normal map used in the model.
  45850. */
  45851. normalTexture: BaseTexture;
  45852. /**
  45853. * Emissivie color used to self-illuminate the model.
  45854. */
  45855. emissiveColor: Color3;
  45856. /**
  45857. * Emissivie texture used to self-illuminate the model.
  45858. */
  45859. emissiveTexture: BaseTexture;
  45860. /**
  45861. * Occlusion Channel Strenght.
  45862. */
  45863. occlusionStrength: number;
  45864. /**
  45865. * Occlusion Texture of the material (adding extra occlusion effects).
  45866. */
  45867. occlusionTexture: BaseTexture;
  45868. /**
  45869. * Defines the alpha limits in alpha test mode.
  45870. */
  45871. alphaCutOff: number;
  45872. /**
  45873. * Gets the current double sided mode.
  45874. */
  45875. /**
  45876. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45877. */
  45878. doubleSided: boolean;
  45879. /**
  45880. * Stores the pre-calculated light information of a mesh in a texture.
  45881. */
  45882. lightmapTexture: BaseTexture;
  45883. /**
  45884. * If true, the light map contains occlusion information instead of lighting info.
  45885. */
  45886. useLightmapAsShadowmap: boolean;
  45887. /**
  45888. * Return the active textures of the material.
  45889. */
  45890. getActiveTextures(): BaseTexture[];
  45891. hasTexture(texture: BaseTexture): boolean;
  45892. /**
  45893. * Instantiates a new PBRMaterial instance.
  45894. *
  45895. * @param name The material name
  45896. * @param scene The scene the material will be use in.
  45897. */
  45898. constructor(name: string, scene: Scene);
  45899. getClassName(): string;
  45900. }
  45901. }
  45902. declare module BABYLON {
  45903. /**
  45904. * The Physically based material of BJS.
  45905. *
  45906. * This offers the main features of a standard PBR material.
  45907. * For more information, please refer to the documentation :
  45908. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45909. */
  45910. class PBRMaterial extends PBRBaseMaterial {
  45911. /**
  45912. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45913. */
  45914. static readonly PBRMATERIAL_OPAQUE: number;
  45915. /**
  45916. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45917. */
  45918. static readonly PBRMATERIAL_ALPHATEST: number;
  45919. /**
  45920. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45921. */
  45922. static readonly PBRMATERIAL_ALPHABLEND: number;
  45923. /**
  45924. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45925. * They are also discarded below the alpha cutoff threshold to improve performances.
  45926. */
  45927. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45928. /**
  45929. * Defines the default value of how much AO map is occluding the analytical lights
  45930. * (point spot...).
  45931. */
  45932. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45933. /**
  45934. * Intensity of the direct lights e.g. the four lights available in your scene.
  45935. * This impacts both the direct diffuse and specular highlights.
  45936. */
  45937. directIntensity: number;
  45938. /**
  45939. * Intensity of the emissive part of the material.
  45940. * This helps controlling the emissive effect without modifying the emissive color.
  45941. */
  45942. emissiveIntensity: number;
  45943. /**
  45944. * Intensity of the environment e.g. how much the environment will light the object
  45945. * either through harmonics for rough material or through the refelction for shiny ones.
  45946. */
  45947. environmentIntensity: number;
  45948. /**
  45949. * This is a special control allowing the reduction of the specular highlights coming from the
  45950. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45951. */
  45952. specularIntensity: number;
  45953. /**
  45954. * Debug Control allowing disabling the bump map on this material.
  45955. */
  45956. disableBumpMap: boolean;
  45957. /**
  45958. * AKA Diffuse Texture in standard nomenclature.
  45959. */
  45960. albedoTexture: BaseTexture;
  45961. /**
  45962. * AKA Occlusion Texture in other nomenclature.
  45963. */
  45964. ambientTexture: BaseTexture;
  45965. /**
  45966. * AKA Occlusion Texture Intensity in other nomenclature.
  45967. */
  45968. ambientTextureStrength: number;
  45969. /**
  45970. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45971. * 1 means it completely occludes it
  45972. * 0 mean it has no impact
  45973. */
  45974. ambientTextureImpactOnAnalyticalLights: number;
  45975. /**
  45976. * Stores the alpha values in a texture.
  45977. */
  45978. opacityTexture: BaseTexture;
  45979. /**
  45980. * Stores the reflection values in a texture.
  45981. */
  45982. reflectionTexture: Nullable<BaseTexture>;
  45983. /**
  45984. * Stores the emissive values in a texture.
  45985. */
  45986. emissiveTexture: BaseTexture;
  45987. /**
  45988. * AKA Specular texture in other nomenclature.
  45989. */
  45990. reflectivityTexture: BaseTexture;
  45991. /**
  45992. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45993. */
  45994. metallicTexture: BaseTexture;
  45995. /**
  45996. * Specifies the metallic scalar of the metallic/roughness workflow.
  45997. * Can also be used to scale the metalness values of the metallic texture.
  45998. */
  45999. metallic: Nullable<number>;
  46000. /**
  46001. * Specifies the roughness scalar of the metallic/roughness workflow.
  46002. * Can also be used to scale the roughness values of the metallic texture.
  46003. */
  46004. roughness: Nullable<number>;
  46005. /**
  46006. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46007. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46008. */
  46009. microSurfaceTexture: BaseTexture;
  46010. /**
  46011. * Stores surface normal data used to displace a mesh in a texture.
  46012. */
  46013. bumpTexture: BaseTexture;
  46014. /**
  46015. * Stores the pre-calculated light information of a mesh in a texture.
  46016. */
  46017. lightmapTexture: BaseTexture;
  46018. /**
  46019. * Stores the refracted light information in a texture.
  46020. */
  46021. refractionTexture: BaseTexture;
  46022. /**
  46023. * The color of a material in ambient lighting.
  46024. */
  46025. ambientColor: Color3;
  46026. /**
  46027. * AKA Diffuse Color in other nomenclature.
  46028. */
  46029. albedoColor: Color3;
  46030. /**
  46031. * AKA Specular Color in other nomenclature.
  46032. */
  46033. reflectivityColor: Color3;
  46034. /**
  46035. * The color reflected from the material.
  46036. */
  46037. reflectionColor: Color3;
  46038. /**
  46039. * The color emitted from the material.
  46040. */
  46041. emissiveColor: Color3;
  46042. /**
  46043. * AKA Glossiness in other nomenclature.
  46044. */
  46045. microSurface: number;
  46046. /**
  46047. * source material index of refraction (IOR)' / 'destination material IOR.
  46048. */
  46049. indexOfRefraction: number;
  46050. /**
  46051. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46052. */
  46053. invertRefractionY: boolean;
  46054. /**
  46055. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46056. * Materials half opaque for instance using refraction could benefit from this control.
  46057. */
  46058. linkRefractionWithTransparency: boolean;
  46059. /**
  46060. * If true, the light map contains occlusion information instead of lighting info.
  46061. */
  46062. useLightmapAsShadowmap: boolean;
  46063. /**
  46064. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46065. */
  46066. useAlphaFromAlbedoTexture: boolean;
  46067. /**
  46068. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46069. */
  46070. forceAlphaTest: boolean;
  46071. /**
  46072. * Defines the alpha limits in alpha test mode.
  46073. */
  46074. alphaCutOff: number;
  46075. /**
  46076. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46078. */
  46079. useSpecularOverAlpha: boolean;
  46080. /**
  46081. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46082. */
  46083. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46084. /**
  46085. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46086. */
  46087. useRoughnessFromMetallicTextureAlpha: boolean;
  46088. /**
  46089. * Specifies if the metallic texture contains the roughness information in its green channel.
  46090. */
  46091. useRoughnessFromMetallicTextureGreen: boolean;
  46092. /**
  46093. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46094. */
  46095. useMetallnessFromMetallicTextureBlue: boolean;
  46096. /**
  46097. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46098. */
  46099. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46100. /**
  46101. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46102. */
  46103. useAmbientInGrayScale: boolean;
  46104. /**
  46105. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46106. * The material will try to infer what glossiness each pixel should be.
  46107. */
  46108. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46109. /**
  46110. * BJS is using an harcoded light falloff based on a manually sets up range.
  46111. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46112. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46113. */
  46114. /**
  46115. * BJS is using an harcoded light falloff based on a manually sets up range.
  46116. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46117. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46118. */
  46119. usePhysicalLightFalloff: boolean;
  46120. /**
  46121. * In order to support the falloff compatibility with gltf, a special mode has been added
  46122. * to reproduce the gltf light falloff.
  46123. */
  46124. /**
  46125. * In order to support the falloff compatibility with gltf, a special mode has been added
  46126. * to reproduce the gltf light falloff.
  46127. */
  46128. useGLTFLightFalloff: boolean;
  46129. /**
  46130. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46131. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46132. */
  46133. useRadianceOverAlpha: boolean;
  46134. /**
  46135. * Allows using an object space normal map (instead of tangent space).
  46136. */
  46137. useObjectSpaceNormalMap: boolean;
  46138. /**
  46139. * Allows using the bump map in parallax mode.
  46140. */
  46141. useParallax: boolean;
  46142. /**
  46143. * Allows using the bump map in parallax occlusion mode.
  46144. */
  46145. useParallaxOcclusion: boolean;
  46146. /**
  46147. * Controls the scale bias of the parallax mode.
  46148. */
  46149. parallaxScaleBias: number;
  46150. /**
  46151. * If sets to true, disables all the lights affecting the material.
  46152. */
  46153. disableLighting: boolean;
  46154. /**
  46155. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46156. */
  46157. forceIrradianceInFragment: boolean;
  46158. /**
  46159. * Number of Simultaneous lights allowed on the material.
  46160. */
  46161. maxSimultaneousLights: number;
  46162. /**
  46163. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46164. */
  46165. invertNormalMapX: boolean;
  46166. /**
  46167. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46168. */
  46169. invertNormalMapY: boolean;
  46170. /**
  46171. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46172. */
  46173. twoSidedLighting: boolean;
  46174. /**
  46175. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46176. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46177. */
  46178. useAlphaFresnel: boolean;
  46179. /**
  46180. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46181. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46182. */
  46183. useLinearAlphaFresnel: boolean;
  46184. /**
  46185. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46186. * And/Or occlude the blended part.
  46187. */
  46188. environmentBRDFTexture: Nullable<BaseTexture>;
  46189. /**
  46190. * Force normal to face away from face.
  46191. */
  46192. forceNormalForward: boolean;
  46193. /**
  46194. * Enables specular anti aliasing in the PBR shader.
  46195. * It will both interacts on the Geometry for analytical and IBL lighting.
  46196. * It also prefilter the roughness map based on the bump values.
  46197. */
  46198. enableSpecularAntiAliasing: boolean;
  46199. /**
  46200. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46201. * makes the reflect vector face the model (under horizon).
  46202. */
  46203. useHorizonOcclusion: boolean;
  46204. /**
  46205. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46206. * too much the area relying on ambient texture to define their ambient occlusion.
  46207. */
  46208. useRadianceOcclusion: boolean;
  46209. /**
  46210. * If set to true, no lighting calculations will be applied.
  46211. */
  46212. unlit: boolean;
  46213. /**
  46214. * Gets the image processing configuration used either in this material.
  46215. */
  46216. /**
  46217. * Sets the Default image processing configuration used either in the this material.
  46218. *
  46219. * If sets to null, the scene one is in use.
  46220. */
  46221. imageProcessingConfiguration: ImageProcessingConfiguration;
  46222. /**
  46223. * Gets wether the color curves effect is enabled.
  46224. */
  46225. /**
  46226. * Sets wether the color curves effect is enabled.
  46227. */
  46228. cameraColorCurvesEnabled: boolean;
  46229. /**
  46230. * Gets wether the color grading effect is enabled.
  46231. */
  46232. /**
  46233. * Gets wether the color grading effect is enabled.
  46234. */
  46235. cameraColorGradingEnabled: boolean;
  46236. /**
  46237. * Gets wether tonemapping is enabled or not.
  46238. */
  46239. /**
  46240. * Sets wether tonemapping is enabled or not
  46241. */
  46242. cameraToneMappingEnabled: boolean;
  46243. /**
  46244. * The camera exposure used on this material.
  46245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46246. * This corresponds to a photographic exposure.
  46247. */
  46248. /**
  46249. * The camera exposure used on this material.
  46250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46251. * This corresponds to a photographic exposure.
  46252. */
  46253. cameraExposure: number;
  46254. /**
  46255. * Gets The camera contrast used on this material.
  46256. */
  46257. /**
  46258. * Sets The camera contrast used on this material.
  46259. */
  46260. cameraContrast: number;
  46261. /**
  46262. * Gets the Color Grading 2D Lookup Texture.
  46263. */
  46264. /**
  46265. * Sets the Color Grading 2D Lookup Texture.
  46266. */
  46267. cameraColorGradingTexture: Nullable<BaseTexture>;
  46268. /**
  46269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46271. * 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;
  46272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46273. */
  46274. /**
  46275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46277. * 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;
  46278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46279. */
  46280. cameraColorCurves: Nullable<ColorCurves>;
  46281. /**
  46282. * Instantiates a new PBRMaterial instance.
  46283. *
  46284. * @param name The material name
  46285. * @param scene The scene the material will be use in.
  46286. */
  46287. constructor(name: string, scene: Scene);
  46288. /**
  46289. * Returns the name of this material class.
  46290. */
  46291. getClassName(): string;
  46292. /**
  46293. * Returns an array of the actively used textures.
  46294. * @returns - Array of BaseTextures
  46295. */
  46296. getActiveTextures(): BaseTexture[];
  46297. /**
  46298. * Checks to see if a texture is used in the material.
  46299. * @param texture - Base texture to use.
  46300. * @returns - Boolean specifying if a texture is used in the material.
  46301. */
  46302. hasTexture(texture: BaseTexture): boolean;
  46303. /**
  46304. * Makes a duplicate of the current material.
  46305. * @param name - name to use for the new material.
  46306. */
  46307. clone(name: string): PBRMaterial;
  46308. /**
  46309. * Serializes this PBR Material.
  46310. * @returns - An object with the serialized material.
  46311. */
  46312. serialize(): any;
  46313. /**
  46314. * Parses a PBR Material from a serialized object.
  46315. * @param source - Serialized object.
  46316. * @param scene - BJS scene instance.
  46317. * @param rootUrl - url for the scene object
  46318. * @returns - PBRMaterial
  46319. */
  46320. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46321. }
  46322. }
  46323. declare module BABYLON {
  46324. /**
  46325. * The PBR material of BJS following the metal roughness convention.
  46326. *
  46327. * This fits to the PBR convention in the GLTF definition:
  46328. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46329. */
  46330. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46331. /**
  46332. * The base color has two different interpretations depending on the value of metalness.
  46333. * When the material is a metal, the base color is the specific measured reflectance value
  46334. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46335. * of the material.
  46336. */
  46337. baseColor: Color3;
  46338. /**
  46339. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46340. * well as opacity information in the alpha channel.
  46341. */
  46342. baseTexture: BaseTexture;
  46343. /**
  46344. * Specifies the metallic scalar value of the material.
  46345. * Can also be used to scale the metalness values of the metallic texture.
  46346. */
  46347. metallic: number;
  46348. /**
  46349. * Specifies the roughness scalar value of the material.
  46350. * Can also be used to scale the roughness values of the metallic texture.
  46351. */
  46352. roughness: number;
  46353. /**
  46354. * Texture containing both the metallic value in the B channel and the
  46355. * roughness value in the G channel to keep better precision.
  46356. */
  46357. metallicRoughnessTexture: BaseTexture;
  46358. /**
  46359. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46360. *
  46361. * @param name The material name
  46362. * @param scene The scene the material will be use in.
  46363. */
  46364. constructor(name: string, scene: Scene);
  46365. /**
  46366. * Return the currrent class name of the material.
  46367. */
  46368. getClassName(): string;
  46369. /**
  46370. * Return the active textures of the material.
  46371. */
  46372. getActiveTextures(): BaseTexture[];
  46373. /**
  46374. * Checks to see if a texture is used in the material.
  46375. * @param texture - Base texture to use.
  46376. * @returns - Boolean specifying if a texture is used in the material.
  46377. */
  46378. hasTexture(texture: BaseTexture): boolean;
  46379. /**
  46380. * Makes a duplicate of the current material.
  46381. * @param name - name to use for the new material.
  46382. */
  46383. clone(name: string): PBRMetallicRoughnessMaterial;
  46384. /**
  46385. * Serialize the material to a parsable JSON object.
  46386. */
  46387. serialize(): any;
  46388. /**
  46389. * Parses a JSON object correponding to the serialize function.
  46390. */
  46391. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46392. }
  46393. }
  46394. declare module BABYLON {
  46395. /**
  46396. * The PBR material of BJS following the specular glossiness convention.
  46397. *
  46398. * This fits to the PBR convention in the GLTF definition:
  46399. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46400. */
  46401. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46402. /**
  46403. * Specifies the diffuse color of the material.
  46404. */
  46405. diffuseColor: Color3;
  46406. /**
  46407. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46408. * channel.
  46409. */
  46410. diffuseTexture: BaseTexture;
  46411. /**
  46412. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46413. */
  46414. specularColor: Color3;
  46415. /**
  46416. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46417. */
  46418. glossiness: number;
  46419. /**
  46420. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46421. */
  46422. specularGlossinessTexture: BaseTexture;
  46423. /**
  46424. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46425. *
  46426. * @param name The material name
  46427. * @param scene The scene the material will be use in.
  46428. */
  46429. constructor(name: string, scene: Scene);
  46430. /**
  46431. * Return the currrent class name of the material.
  46432. */
  46433. getClassName(): string;
  46434. /**
  46435. * Return the active textures of the material.
  46436. */
  46437. getActiveTextures(): BaseTexture[];
  46438. /**
  46439. * Checks to see if a texture is used in the material.
  46440. * @param texture - Base texture to use.
  46441. * @returns - Boolean specifying if a texture is used in the material.
  46442. */
  46443. hasTexture(texture: BaseTexture): boolean;
  46444. /**
  46445. * Makes a duplicate of the current material.
  46446. * @param name - name to use for the new material.
  46447. */
  46448. clone(name: string): PBRSpecularGlossinessMaterial;
  46449. /**
  46450. * Serialize the material to a parsable JSON object.
  46451. */
  46452. serialize(): any;
  46453. /**
  46454. * Parses a JSON object correponding to the serialize function.
  46455. */
  46456. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46457. }
  46458. }
  46459. declare module BABYLON {
  46460. /**
  46461. * Base class of all the textures in babylon.
  46462. * It groups all the common properties the materials, post process, lights... might need
  46463. * in order to make a correct use of the texture.
  46464. */
  46465. class BaseTexture {
  46466. /**
  46467. * Default anisotropic filtering level for the application.
  46468. * It is set to 4 as a good tradeoff between perf and quality.
  46469. */
  46470. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46471. /**
  46472. * Gets or sets the unique id of the texture
  46473. */
  46474. uniqueId: number;
  46475. /**
  46476. * Define the name of the texture.
  46477. */
  46478. name: string;
  46479. /**
  46480. * Gets or sets an object used to store user defined information.
  46481. */
  46482. metadata: any;
  46483. /**
  46484. * For internal use only. Please do not use.
  46485. */
  46486. reservedDataStore: any;
  46487. private _hasAlpha;
  46488. /**
  46489. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46490. */
  46491. hasAlpha: boolean;
  46492. /**
  46493. * Defines if the alpha value should be determined via the rgb values.
  46494. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46495. */
  46496. getAlphaFromRGB: boolean;
  46497. /**
  46498. * Intensity or strength of the texture.
  46499. * It is commonly used by materials to fine tune the intensity of the texture
  46500. */
  46501. level: number;
  46502. /**
  46503. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46504. * This is part of the texture as textures usually maps to one uv set.
  46505. */
  46506. coordinatesIndex: number;
  46507. private _coordinatesMode;
  46508. /**
  46509. * How a texture is mapped.
  46510. *
  46511. * | Value | Type | Description |
  46512. * | ----- | ----------------------------------- | ----------- |
  46513. * | 0 | EXPLICIT_MODE | |
  46514. * | 1 | SPHERICAL_MODE | |
  46515. * | 2 | PLANAR_MODE | |
  46516. * | 3 | CUBIC_MODE | |
  46517. * | 4 | PROJECTION_MODE | |
  46518. * | 5 | SKYBOX_MODE | |
  46519. * | 6 | INVCUBIC_MODE | |
  46520. * | 7 | EQUIRECTANGULAR_MODE | |
  46521. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46522. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46523. */
  46524. coordinatesMode: number;
  46525. /**
  46526. * | Value | Type | Description |
  46527. * | ----- | ------------------ | ----------- |
  46528. * | 0 | CLAMP_ADDRESSMODE | |
  46529. * | 1 | WRAP_ADDRESSMODE | |
  46530. * | 2 | MIRROR_ADDRESSMODE | |
  46531. */
  46532. wrapU: number;
  46533. /**
  46534. * | Value | Type | Description |
  46535. * | ----- | ------------------ | ----------- |
  46536. * | 0 | CLAMP_ADDRESSMODE | |
  46537. * | 1 | WRAP_ADDRESSMODE | |
  46538. * | 2 | MIRROR_ADDRESSMODE | |
  46539. */
  46540. wrapV: number;
  46541. /**
  46542. * | Value | Type | Description |
  46543. * | ----- | ------------------ | ----------- |
  46544. * | 0 | CLAMP_ADDRESSMODE | |
  46545. * | 1 | WRAP_ADDRESSMODE | |
  46546. * | 2 | MIRROR_ADDRESSMODE | |
  46547. */
  46548. wrapR: number;
  46549. /**
  46550. * With compliant hardware and browser (supporting anisotropic filtering)
  46551. * this defines the level of anisotropic filtering in the texture.
  46552. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46553. */
  46554. anisotropicFilteringLevel: number;
  46555. /**
  46556. * Define if the texture is a cube texture or if false a 2d texture.
  46557. */
  46558. isCube: boolean;
  46559. /**
  46560. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46561. */
  46562. is3D: boolean;
  46563. /**
  46564. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46565. * HDR texture are usually stored in linear space.
  46566. * This only impacts the PBR and Background materials
  46567. */
  46568. gammaSpace: boolean;
  46569. /**
  46570. * Gets whether or not the texture contains RGBD data.
  46571. */
  46572. readonly isRGBD: boolean;
  46573. /**
  46574. * Is Z inverted in the texture (useful in a cube texture).
  46575. */
  46576. invertZ: boolean;
  46577. /**
  46578. * Are mip maps generated for this texture or not.
  46579. */
  46580. readonly noMipmap: boolean;
  46581. /**
  46582. * @hidden
  46583. */
  46584. lodLevelInAlpha: boolean;
  46585. /**
  46586. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46587. */
  46588. lodGenerationOffset: number;
  46589. /**
  46590. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46591. */
  46592. lodGenerationScale: number;
  46593. /**
  46594. * Define if the texture is a render target.
  46595. */
  46596. isRenderTarget: boolean;
  46597. /**
  46598. * Define the unique id of the texture in the scene.
  46599. */
  46600. readonly uid: string;
  46601. /**
  46602. * Return a string representation of the texture.
  46603. * @returns the texture as a string
  46604. */
  46605. toString(): string;
  46606. /**
  46607. * Get the class name of the texture.
  46608. * @returns "BaseTexture"
  46609. */
  46610. getClassName(): string;
  46611. /**
  46612. * Define the list of animation attached to the texture.
  46613. */
  46614. animations: Animation[];
  46615. /**
  46616. * An event triggered when the texture is disposed.
  46617. */
  46618. onDisposeObservable: Observable<BaseTexture>;
  46619. private _onDisposeObserver;
  46620. /**
  46621. * Callback triggered when the texture has been disposed.
  46622. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46623. */
  46624. onDispose: () => void;
  46625. /**
  46626. * Define the current state of the loading sequence when in delayed load mode.
  46627. */
  46628. delayLoadState: number;
  46629. private _scene;
  46630. /** @hidden */
  46631. _texture: Nullable<InternalTexture>;
  46632. private _uid;
  46633. /**
  46634. * Define if the texture is preventinga material to render or not.
  46635. * If not and the texture is not ready, the engine will use a default black texture instead.
  46636. */
  46637. readonly isBlocking: boolean;
  46638. /**
  46639. * Instantiates a new BaseTexture.
  46640. * Base class of all the textures in babylon.
  46641. * It groups all the common properties the materials, post process, lights... might need
  46642. * in order to make a correct use of the texture.
  46643. * @param scene Define the scene the texture blongs to
  46644. */
  46645. constructor(scene: Nullable<Scene>);
  46646. /**
  46647. * Get the scene the texture belongs to.
  46648. * @returns the scene or null if undefined
  46649. */
  46650. getScene(): Nullable<Scene>;
  46651. /**
  46652. * Get the texture transform matrix used to offset tile the texture for istance.
  46653. * @returns the transformation matrix
  46654. */
  46655. getTextureMatrix(): Matrix;
  46656. /**
  46657. * Get the texture reflection matrix used to rotate/transform the reflection.
  46658. * @returns the reflection matrix
  46659. */
  46660. getReflectionTextureMatrix(): Matrix;
  46661. /**
  46662. * Get the underlying lower level texture from Babylon.
  46663. * @returns the insternal texture
  46664. */
  46665. getInternalTexture(): Nullable<InternalTexture>;
  46666. /**
  46667. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46668. * @returns true if ready or not blocking
  46669. */
  46670. isReadyOrNotBlocking(): boolean;
  46671. /**
  46672. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46673. * @returns true if fully ready
  46674. */
  46675. isReady(): boolean;
  46676. private _cachedSize;
  46677. /**
  46678. * Get the size of the texture.
  46679. * @returns the texture size.
  46680. */
  46681. getSize(): ISize;
  46682. /**
  46683. * Get the base size of the texture.
  46684. * It can be different from the size if the texture has been resized for POT for instance
  46685. * @returns the base size
  46686. */
  46687. getBaseSize(): ISize;
  46688. /**
  46689. * Update the sampling mode of the texture.
  46690. * Default is Trilinear mode.
  46691. *
  46692. * | Value | Type | Description |
  46693. * | ----- | ------------------ | ----------- |
  46694. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46695. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46696. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46697. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46698. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46699. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46700. * | 7 | NEAREST_LINEAR | |
  46701. * | 8 | NEAREST_NEAREST | |
  46702. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46703. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46704. * | 11 | LINEAR_LINEAR | |
  46705. * | 12 | LINEAR_NEAREST | |
  46706. *
  46707. * > _mag_: magnification filter (close to the viewer)
  46708. * > _min_: minification filter (far from the viewer)
  46709. * > _mip_: filter used between mip map levels
  46710. *@param samplingMode Define the new sampling mode of the texture
  46711. */
  46712. updateSamplingMode(samplingMode: number): void;
  46713. /**
  46714. * Scales the texture if is `canRescale()`
  46715. * @param ratio the resize factor we want to use to rescale
  46716. */
  46717. scale(ratio: number): void;
  46718. /**
  46719. * Get if the texture can rescale.
  46720. */
  46721. readonly canRescale: boolean;
  46722. /** @hidden */
  46723. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46724. /** @hidden */
  46725. _rebuild(): void;
  46726. /**
  46727. * Triggers the load sequence in delayed load mode.
  46728. */
  46729. delayLoad(): void;
  46730. /**
  46731. * Clones the texture.
  46732. * @returns the cloned texture
  46733. */
  46734. clone(): Nullable<BaseTexture>;
  46735. /**
  46736. * Get the texture underlying type (INT, FLOAT...)
  46737. */
  46738. readonly textureType: number;
  46739. /**
  46740. * Get the texture underlying format (RGB, RGBA...)
  46741. */
  46742. readonly textureFormat: number;
  46743. /**
  46744. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46745. * This will returns an RGBA array buffer containing either in values (0-255) or
  46746. * float values (0-1) depending of the underlying buffer type.
  46747. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46748. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46749. * @param buffer defines a user defined buffer to fill with data (can be null)
  46750. * @returns The Array buffer containing the pixels data.
  46751. */
  46752. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46753. /**
  46754. * Release and destroy the underlying lower level texture aka internalTexture.
  46755. */
  46756. releaseInternalTexture(): void;
  46757. /**
  46758. * Get the polynomial representation of the texture data.
  46759. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46760. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46761. */
  46762. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46763. /** @hidden */
  46764. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46765. /** @hidden */
  46766. readonly _lodTextureMid: Nullable<BaseTexture>;
  46767. /** @hidden */
  46768. readonly _lodTextureLow: Nullable<BaseTexture>;
  46769. /**
  46770. * Dispose the texture and release its associated resources.
  46771. */
  46772. dispose(): void;
  46773. /**
  46774. * Serialize the texture into a JSON representation that can be parsed later on.
  46775. * @returns the JSON representation of the texture
  46776. */
  46777. serialize(): any;
  46778. /**
  46779. * Helper function to be called back once a list of texture contains only ready textures.
  46780. * @param textures Define the list of textures to wait for
  46781. * @param callback Define the callback triggered once the entire list will be ready
  46782. */
  46783. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46784. }
  46785. }
  46786. declare module BABYLON {
  46787. /**
  46788. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46789. * It can help converting any input color in a desired output one. This can then be used to create effects
  46790. * from sepia, black and white to sixties or futuristic rendering...
  46791. *
  46792. * The only supported format is currently 3dl.
  46793. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46794. */
  46795. class ColorGradingTexture extends BaseTexture {
  46796. /**
  46797. * The current texture matrix. (will always be identity in color grading texture)
  46798. */
  46799. private _textureMatrix;
  46800. /**
  46801. * The texture URL.
  46802. */
  46803. url: string;
  46804. /**
  46805. * Empty line regex stored for GC.
  46806. */
  46807. private static _noneEmptyLineRegex;
  46808. private _engine;
  46809. /**
  46810. * Instantiates a ColorGradingTexture from the following parameters.
  46811. *
  46812. * @param url The location of the color gradind data (currently only supporting 3dl)
  46813. * @param scene The scene the texture will be used in
  46814. */
  46815. constructor(url: string, scene: Scene);
  46816. /**
  46817. * Returns the texture matrix used in most of the material.
  46818. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46819. */
  46820. getTextureMatrix(): Matrix;
  46821. /**
  46822. * Occurs when the file being loaded is a .3dl LUT file.
  46823. */
  46824. private load3dlTexture;
  46825. /**
  46826. * Starts the loading process of the texture.
  46827. */
  46828. private loadTexture;
  46829. /**
  46830. * Clones the color gradind texture.
  46831. */
  46832. clone(): ColorGradingTexture;
  46833. /**
  46834. * Called during delayed load for textures.
  46835. */
  46836. delayLoad(): void;
  46837. /**
  46838. * Parses a color grading texture serialized by Babylon.
  46839. * @param parsedTexture The texture information being parsedTexture
  46840. * @param scene The scene to load the texture in
  46841. * @param rootUrl The root url of the data assets to load
  46842. * @return A color gradind texture
  46843. */
  46844. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46845. /**
  46846. * Serializes the LUT texture to json format.
  46847. */
  46848. serialize(): any;
  46849. }
  46850. }
  46851. declare module BABYLON {
  46852. /**
  46853. * Class for creating a cube texture
  46854. */
  46855. class CubeTexture extends BaseTexture {
  46856. private _delayedOnLoad;
  46857. /**
  46858. * The url of the texture
  46859. */
  46860. url: string;
  46861. /**
  46862. * Gets or sets the center of the bounding box associated with the cube texture.
  46863. * It must define where the camera used to render the texture was set
  46864. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46865. */
  46866. boundingBoxPosition: Vector3;
  46867. private _boundingBoxSize;
  46868. /**
  46869. * Gets or sets the size of the bounding box associated with the cube texture
  46870. * When defined, the cubemap will switch to local mode
  46871. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46872. * @example https://www.babylonjs-playground.com/#RNASML
  46873. */
  46874. /**
  46875. * Returns the bounding box size
  46876. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46877. */
  46878. boundingBoxSize: Vector3;
  46879. protected _rotationY: number;
  46880. /**
  46881. * Sets texture matrix rotation angle around Y axis in radians.
  46882. */
  46883. /**
  46884. * Gets texture matrix rotation angle around Y axis radians.
  46885. */
  46886. rotationY: number;
  46887. /**
  46888. * Are mip maps generated for this texture or not.
  46889. */
  46890. readonly noMipmap: boolean;
  46891. private _noMipmap;
  46892. private _files;
  46893. private _extensions;
  46894. private _textureMatrix;
  46895. private _format;
  46896. private _createPolynomials;
  46897. /** @hidden */
  46898. _prefiltered: boolean;
  46899. /**
  46900. * Creates a cube texture from an array of image urls
  46901. * @param files defines an array of image urls
  46902. * @param scene defines the hosting scene
  46903. * @param noMipmap specifies if mip maps are not used
  46904. * @returns a cube texture
  46905. */
  46906. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46907. /**
  46908. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46909. * @param url defines the url of the prefiltered texture
  46910. * @param scene defines the scene the texture is attached to
  46911. * @param forcedExtension defines the extension of the file if different from the url
  46912. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46913. * @return the prefiltered texture
  46914. */
  46915. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46916. /**
  46917. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46918. * as prefiltered data.
  46919. * @param rootUrl defines the url of the texture or the root name of the six images
  46920. * @param scene defines the scene the texture is attached to
  46921. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46922. * @param noMipmap defines if mipmaps should be created or not
  46923. * @param files defines the six files to load for the different faces
  46924. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46925. * @param onError defines a callback triggered in case of error during load
  46926. * @param format defines the internal format to use for the texture once loaded
  46927. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46928. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46929. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46930. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46931. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46932. * @return the cube texture
  46933. */
  46934. 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);
  46935. /**
  46936. * Get the current class name of the texture useful for serialization or dynamic coding.
  46937. * @returns "CubeTexture"
  46938. */
  46939. getClassName(): string;
  46940. /**
  46941. * Update the url (and optional buffer) of this texture if url was null during construction.
  46942. * @param url the url of the texture
  46943. * @param forcedExtension defines the extension to use
  46944. * @param onLoad callback called when the texture is loaded (defaults to null)
  46945. */
  46946. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46947. /**
  46948. * Delays loading of the cube texture
  46949. * @param forcedExtension defines the extension to use
  46950. */
  46951. delayLoad(forcedExtension?: string): void;
  46952. /**
  46953. * Returns the reflection texture matrix
  46954. * @returns the reflection texture matrix
  46955. */
  46956. getReflectionTextureMatrix(): Matrix;
  46957. /**
  46958. * Sets the reflection texture matrix
  46959. * @param value Reflection texture matrix
  46960. */
  46961. setReflectionTextureMatrix(value: Matrix): void;
  46962. /**
  46963. * Parses text to create a cube texture
  46964. * @param parsedTexture define the serialized text to read from
  46965. * @param scene defines the hosting scene
  46966. * @param rootUrl defines the root url of the cube texture
  46967. * @returns a cube texture
  46968. */
  46969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46970. /**
  46971. * Makes a clone, or deep copy, of the cube texture
  46972. * @returns a new cube texture
  46973. */
  46974. clone(): CubeTexture;
  46975. }
  46976. }
  46977. declare module BABYLON {
  46978. /**
  46979. * A class extending Texture allowing drawing on a texture
  46980. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46981. */
  46982. class DynamicTexture extends Texture {
  46983. private _generateMipMaps;
  46984. private _canvas;
  46985. private _context;
  46986. private _engine;
  46987. /**
  46988. * Creates a DynamicTexture
  46989. * @param name defines the name of the texture
  46990. * @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
  46991. * @param scene defines the scene where you want the texture
  46992. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46993. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46994. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46995. */
  46996. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46997. /**
  46998. * Get the current class name of the texture useful for serialization or dynamic coding.
  46999. * @returns "DynamicTexture"
  47000. */
  47001. getClassName(): string;
  47002. /**
  47003. * Gets the current state of canRescale
  47004. */
  47005. readonly canRescale: boolean;
  47006. private _recreate;
  47007. /**
  47008. * Scales the texture
  47009. * @param ratio the scale factor to apply to both width and height
  47010. */
  47011. scale(ratio: number): void;
  47012. /**
  47013. * Resizes the texture
  47014. * @param width the new width
  47015. * @param height the new height
  47016. */
  47017. scaleTo(width: number, height: number): void;
  47018. /**
  47019. * Gets the context of the canvas used by the texture
  47020. * @returns the canvas context of the dynamic texture
  47021. */
  47022. getContext(): CanvasRenderingContext2D;
  47023. /**
  47024. * Clears the texture
  47025. */
  47026. clear(): void;
  47027. /**
  47028. * Updates the texture
  47029. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47030. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47031. */
  47032. update(invertY?: boolean, premulAlpha?: boolean): void;
  47033. /**
  47034. * Draws text onto the texture
  47035. * @param text defines the text to be drawn
  47036. * @param x defines the placement of the text from the left
  47037. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47038. * @param font defines the font to be used with font-style, font-size, font-name
  47039. * @param color defines the color used for the text
  47040. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47041. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47042. * @param update defines whether texture is immediately update (default is true)
  47043. */
  47044. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  47045. /**
  47046. * Clones the texture
  47047. * @returns the clone of the texture.
  47048. */
  47049. clone(): DynamicTexture;
  47050. /**
  47051. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47052. * @returns a serialized dynamic texture object
  47053. */
  47054. serialize(): any;
  47055. /** @hidden */
  47056. _rebuild(): void;
  47057. }
  47058. }
  47059. declare module BABYLON {
  47060. /**
  47061. * This represents a texture coming from an HDR input.
  47062. *
  47063. * The only supported format is currently panorama picture stored in RGBE format.
  47064. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47065. */
  47066. class HDRCubeTexture extends BaseTexture {
  47067. private static _facesMapping;
  47068. private _generateHarmonics;
  47069. private _noMipmap;
  47070. private _textureMatrix;
  47071. private _size;
  47072. private _onLoad;
  47073. private _onError;
  47074. /**
  47075. * The texture URL.
  47076. */
  47077. url: string;
  47078. /**
  47079. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47080. */
  47081. coordinatesMode: number;
  47082. protected _isBlocking: boolean;
  47083. /**
  47084. * Sets wether or not the texture is blocking during loading.
  47085. */
  47086. /**
  47087. * Gets wether or not the texture is blocking during loading.
  47088. */
  47089. isBlocking: boolean;
  47090. protected _rotationY: number;
  47091. /**
  47092. * Sets texture matrix rotation angle around Y axis in radians.
  47093. */
  47094. /**
  47095. * Gets texture matrix rotation angle around Y axis radians.
  47096. */
  47097. rotationY: number;
  47098. /**
  47099. * Gets or sets the center of the bounding box associated with the cube texture
  47100. * It must define where the camera used to render the texture was set
  47101. */
  47102. boundingBoxPosition: Vector3;
  47103. private _boundingBoxSize;
  47104. /**
  47105. * Gets or sets the size of the bounding box associated with the cube texture
  47106. * When defined, the cubemap will switch to local mode
  47107. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47108. * @example https://www.babylonjs-playground.com/#RNASML
  47109. */
  47110. boundingBoxSize: Vector3;
  47111. /**
  47112. * Instantiates an HDRTexture from the following parameters.
  47113. *
  47114. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47115. * @param scene The scene the texture will be used in
  47116. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47117. * @param noMipmap Forces to not generate the mipmap if true
  47118. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47119. * @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)
  47120. * @param reserved Reserved flag for internal use.
  47121. */
  47122. 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>);
  47123. /**
  47124. * Get the current class name of the texture useful for serialization or dynamic coding.
  47125. * @returns "HDRCubeTexture"
  47126. */
  47127. getClassName(): string;
  47128. /**
  47129. * Occurs when the file is raw .hdr file.
  47130. */
  47131. private loadTexture;
  47132. clone(): HDRCubeTexture;
  47133. delayLoad(): void;
  47134. /**
  47135. * Get the texture reflection matrix used to rotate/transform the reflection.
  47136. * @returns the reflection matrix
  47137. */
  47138. getReflectionTextureMatrix(): Matrix;
  47139. /**
  47140. * Set the texture reflection matrix used to rotate/transform the reflection.
  47141. * @param value Define the reflection matrix to set
  47142. */
  47143. setReflectionTextureMatrix(value: Matrix): void;
  47144. /**
  47145. * Parses a JSON representation of an HDR Texture in order to create the texture
  47146. * @param parsedTexture Define the JSON representation
  47147. * @param scene Define the scene the texture should be created in
  47148. * @param rootUrl Define the root url in case we need to load relative dependencies
  47149. * @returns the newly created texture after parsing
  47150. */
  47151. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47152. serialize(): any;
  47153. }
  47154. }
  47155. declare module BABYLON {
  47156. /**
  47157. * Class used to store data associated with WebGL texture data for the engine
  47158. * This class should not be used directly
  47159. */
  47160. class InternalTexture implements IInternalTextureTracker {
  47161. /**
  47162. * The source of the texture data is unknown
  47163. */
  47164. static DATASOURCE_UNKNOWN: number;
  47165. /**
  47166. * Texture data comes from an URL
  47167. */
  47168. static DATASOURCE_URL: number;
  47169. /**
  47170. * Texture data is only used for temporary storage
  47171. */
  47172. static DATASOURCE_TEMP: number;
  47173. /**
  47174. * Texture data comes from raw data (ArrayBuffer)
  47175. */
  47176. static DATASOURCE_RAW: number;
  47177. /**
  47178. * Texture content is dynamic (video or dynamic texture)
  47179. */
  47180. static DATASOURCE_DYNAMIC: number;
  47181. /**
  47182. * Texture content is generated by rendering to it
  47183. */
  47184. static DATASOURCE_RENDERTARGET: number;
  47185. /**
  47186. * Texture content is part of a multi render target process
  47187. */
  47188. static DATASOURCE_MULTIRENDERTARGET: number;
  47189. /**
  47190. * Texture data comes from a cube data file
  47191. */
  47192. static DATASOURCE_CUBE: number;
  47193. /**
  47194. * Texture data comes from a raw cube data
  47195. */
  47196. static DATASOURCE_CUBERAW: number;
  47197. /**
  47198. * Texture data come from a prefiltered cube data file
  47199. */
  47200. static DATASOURCE_CUBEPREFILTERED: number;
  47201. /**
  47202. * Texture content is raw 3D data
  47203. */
  47204. static DATASOURCE_RAW3D: number;
  47205. /**
  47206. * Texture content is a depth texture
  47207. */
  47208. static DATASOURCE_DEPTHTEXTURE: number;
  47209. /**
  47210. * Texture data comes from a raw cube data encoded with RGBD
  47211. */
  47212. static DATASOURCE_CUBERAW_RGBD: number;
  47213. /**
  47214. * Defines if the texture is ready
  47215. */
  47216. isReady: boolean;
  47217. /**
  47218. * Defines if the texture is a cube texture
  47219. */
  47220. isCube: boolean;
  47221. /**
  47222. * Defines if the texture contains 3D data
  47223. */
  47224. is3D: boolean;
  47225. /**
  47226. * Gets the URL used to load this texture
  47227. */
  47228. url: string;
  47229. /**
  47230. * Gets the sampling mode of the texture
  47231. */
  47232. samplingMode: number;
  47233. /**
  47234. * Gets a boolean indicating if the texture needs mipmaps generation
  47235. */
  47236. generateMipMaps: boolean;
  47237. /**
  47238. * Gets the number of samples used by the texture (WebGL2+ only)
  47239. */
  47240. samples: number;
  47241. /**
  47242. * Gets the type of the texture (int, float...)
  47243. */
  47244. type: number;
  47245. /**
  47246. * Gets the format of the texture (RGB, RGBA...)
  47247. */
  47248. format: number;
  47249. /**
  47250. * Observable called when the texture is loaded
  47251. */
  47252. onLoadedObservable: Observable<InternalTexture>;
  47253. /**
  47254. * Gets the width of the texture
  47255. */
  47256. width: number;
  47257. /**
  47258. * Gets the height of the texture
  47259. */
  47260. height: number;
  47261. /**
  47262. * Gets the depth of the texture
  47263. */
  47264. depth: number;
  47265. /**
  47266. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47267. */
  47268. baseWidth: number;
  47269. /**
  47270. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47271. */
  47272. baseHeight: number;
  47273. /**
  47274. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47275. */
  47276. baseDepth: number;
  47277. /**
  47278. * Gets a boolean indicating if the texture is inverted on Y axis
  47279. */
  47280. invertY: boolean;
  47281. /**
  47282. * Gets or set the previous tracker in the list
  47283. */
  47284. previous: Nullable<IInternalTextureTracker>;
  47285. /**
  47286. * Gets or set the next tracker in the list
  47287. */
  47288. next: Nullable<IInternalTextureTracker>;
  47289. /** @hidden */
  47290. _invertVScale: boolean;
  47291. /** @hidden */
  47292. _initialSlot: number;
  47293. /** @hidden */
  47294. _designatedSlot: number;
  47295. /** @hidden */
  47296. _dataSource: number;
  47297. /** @hidden */
  47298. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47299. /** @hidden */
  47300. _bufferView: Nullable<ArrayBufferView>;
  47301. /** @hidden */
  47302. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47303. /** @hidden */
  47304. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47305. /** @hidden */
  47306. _size: number;
  47307. /** @hidden */
  47308. _extension: string;
  47309. /** @hidden */
  47310. _files: Nullable<string[]>;
  47311. /** @hidden */
  47312. _workingCanvas: HTMLCanvasElement;
  47313. /** @hidden */
  47314. _workingContext: CanvasRenderingContext2D;
  47315. /** @hidden */
  47316. _framebuffer: Nullable<WebGLFramebuffer>;
  47317. /** @hidden */
  47318. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47319. /** @hidden */
  47320. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47321. /** @hidden */
  47322. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47323. /** @hidden */
  47324. _attachments: Nullable<number[]>;
  47325. /** @hidden */
  47326. _cachedCoordinatesMode: Nullable<number>;
  47327. /** @hidden */
  47328. _cachedWrapU: Nullable<number>;
  47329. /** @hidden */
  47330. _cachedWrapV: Nullable<number>;
  47331. /** @hidden */
  47332. _cachedWrapR: Nullable<number>;
  47333. /** @hidden */
  47334. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47335. /** @hidden */
  47336. _isDisabled: boolean;
  47337. /** @hidden */
  47338. _compression: Nullable<string>;
  47339. /** @hidden */
  47340. _generateStencilBuffer: boolean;
  47341. /** @hidden */
  47342. _generateDepthBuffer: boolean;
  47343. /** @hidden */
  47344. _comparisonFunction: number;
  47345. /** @hidden */
  47346. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47347. /** @hidden */
  47348. _lodGenerationScale: number;
  47349. /** @hidden */
  47350. _lodGenerationOffset: number;
  47351. /** @hidden */
  47352. _lodTextureHigh: BaseTexture;
  47353. /** @hidden */
  47354. _lodTextureMid: BaseTexture;
  47355. /** @hidden */
  47356. _lodTextureLow: BaseTexture;
  47357. /** @hidden */
  47358. _isRGBD: boolean;
  47359. /** @hidden */
  47360. _webGLTexture: Nullable<WebGLTexture>;
  47361. /** @hidden */
  47362. _references: number;
  47363. private _engine;
  47364. /**
  47365. * Gets the Engine the texture belongs to.
  47366. * @returns The babylon engine
  47367. */
  47368. getEngine(): Engine;
  47369. /**
  47370. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47371. */
  47372. readonly dataSource: number;
  47373. /**
  47374. * Creates a new InternalTexture
  47375. * @param engine defines the engine to use
  47376. * @param dataSource defines the type of data that will be used
  47377. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47378. */
  47379. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47380. /**
  47381. * Increments the number of references (ie. the number of Texture that point to it)
  47382. */
  47383. incrementReferences(): void;
  47384. /**
  47385. * Change the size of the texture (not the size of the content)
  47386. * @param width defines the new width
  47387. * @param height defines the new height
  47388. * @param depth defines the new depth (1 by default)
  47389. */
  47390. updateSize(width: int, height: int, depth?: int): void;
  47391. /** @hidden */
  47392. _rebuild(): void;
  47393. /** @hidden */
  47394. _swapAndDie(target: InternalTexture): void;
  47395. /**
  47396. * Dispose the current allocated resources
  47397. */
  47398. dispose(): void;
  47399. }
  47400. }
  47401. declare module BABYLON {
  47402. /**
  47403. * This represents the required contract to create a new type of texture loader.
  47404. */
  47405. interface IInternalTextureLoader {
  47406. /**
  47407. * Defines wether the loader supports cascade loading the different faces.
  47408. */
  47409. supportCascades: boolean;
  47410. /**
  47411. * This returns if the loader support the current file information.
  47412. * @param extension defines the file extension of the file being loaded
  47413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47414. * @param fallback defines the fallback internal texture if any
  47415. * @param isBase64 defines whether the texture is encoded as a base64
  47416. * @param isBuffer defines whether the texture data are stored as a buffer
  47417. * @returns true if the loader can load the specified file
  47418. */
  47419. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47420. /**
  47421. * Transform the url before loading if required.
  47422. * @param rootUrl the url of the texture
  47423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47424. * @returns the transformed texture
  47425. */
  47426. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47427. /**
  47428. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47429. * @param rootUrl the url of the texture
  47430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47431. * @returns the fallback texture
  47432. */
  47433. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47434. /**
  47435. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47436. * @param data contains the texture data
  47437. * @param texture defines the BabylonJS internal texture
  47438. * @param createPolynomials will be true if polynomials have been requested
  47439. * @param onLoad defines the callback to trigger once the texture is ready
  47440. * @param onError defines the callback to trigger in case of error
  47441. */
  47442. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47443. /**
  47444. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47445. * @param data contains the texture data
  47446. * @param texture defines the BabylonJS internal texture
  47447. * @param callback defines the method to call once ready to upload
  47448. */
  47449. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47450. }
  47451. }
  47452. declare module BABYLON {
  47453. /**
  47454. * Internal interface used to track InternalTexture already bound to the GL context
  47455. */
  47456. interface IInternalTextureTracker {
  47457. /**
  47458. * Gets or set the previous tracker in the list
  47459. */
  47460. previous: Nullable<IInternalTextureTracker>;
  47461. /**
  47462. * Gets or set the next tracker in the list
  47463. */
  47464. next: Nullable<IInternalTextureTracker>;
  47465. }
  47466. /**
  47467. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47468. */
  47469. class DummyInternalTextureTracker {
  47470. /**
  47471. * Gets or set the previous tracker in the list
  47472. */
  47473. previous: Nullable<IInternalTextureTracker>;
  47474. /**
  47475. * Gets or set the next tracker in the list
  47476. */
  47477. next: Nullable<IInternalTextureTracker>;
  47478. }
  47479. }
  47480. declare module BABYLON {
  47481. /**
  47482. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47483. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47484. * You can then easily use it as a reflectionTexture on a flat surface.
  47485. * In case the surface is not a plane, please consider relying on reflection probes.
  47486. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47487. */
  47488. class MirrorTexture extends RenderTargetTexture {
  47489. private scene;
  47490. /**
  47491. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47492. * It is possible to directly set the mirrorPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  47493. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47494. */
  47495. mirrorPlane: Plane;
  47496. /**
  47497. * Define the blur ratio used to blur the reflection if needed.
  47498. */
  47499. blurRatio: number;
  47500. /**
  47501. * Define the adaptive blur kernel used to blur the reflection if needed.
  47502. * This will autocompute the closest best match for the `blurKernel`
  47503. */
  47504. adaptiveBlurKernel: number;
  47505. /**
  47506. * Define the blur kernel used to blur the reflection if needed.
  47507. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47508. */
  47509. blurKernel: number;
  47510. /**
  47511. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47512. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47513. */
  47514. blurKernelX: number;
  47515. /**
  47516. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47517. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47518. */
  47519. blurKernelY: number;
  47520. private _autoComputeBlurKernel;
  47521. protected _onRatioRescale(): void;
  47522. private _updateGammaSpace;
  47523. private _imageProcessingConfigChangeObserver;
  47524. private _transformMatrix;
  47525. private _mirrorMatrix;
  47526. private _savedViewMatrix;
  47527. private _blurX;
  47528. private _blurY;
  47529. private _adaptiveBlurKernel;
  47530. private _blurKernelX;
  47531. private _blurKernelY;
  47532. private _blurRatio;
  47533. /**
  47534. * Instantiates a Mirror Texture.
  47535. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47536. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47537. * You can then easily use it as a reflectionTexture on a flat surface.
  47538. * In case the surface is not a plane, please consider relying on reflection probes.
  47539. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47540. * @param name
  47541. * @param size
  47542. * @param scene
  47543. * @param generateMipMaps
  47544. * @param type
  47545. * @param samplingMode
  47546. * @param generateDepthBuffer
  47547. */
  47548. constructor(name: string, size: number | {
  47549. width: number;
  47550. height: number;
  47551. } | {
  47552. ratio: number;
  47553. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47554. private _preparePostProcesses;
  47555. /**
  47556. * Clone the mirror texture.
  47557. * @returns the cloned texture
  47558. */
  47559. clone(): MirrorTexture;
  47560. /**
  47561. * Serialize the texture to a JSON representation you could use in Parse later on
  47562. * @returns the serialized JSON representation
  47563. */
  47564. serialize(): any;
  47565. /**
  47566. * Dispose the texture and release its associated resources.
  47567. */
  47568. dispose(): void;
  47569. }
  47570. }
  47571. declare module BABYLON {
  47572. /**
  47573. * Creation options of the multi render target texture.
  47574. */
  47575. interface IMultiRenderTargetOptions {
  47576. /**
  47577. * Define if the texture needs to create mip maps after render.
  47578. */
  47579. generateMipMaps?: boolean;
  47580. /**
  47581. * Define the types of all the draw buffers we want to create
  47582. */
  47583. types?: number[];
  47584. /**
  47585. * Define the sampling modes of all the draw buffers we want to create
  47586. */
  47587. samplingModes?: number[];
  47588. /**
  47589. * Define if a depth buffer is required
  47590. */
  47591. generateDepthBuffer?: boolean;
  47592. /**
  47593. * Define if a stencil buffer is required
  47594. */
  47595. generateStencilBuffer?: boolean;
  47596. /**
  47597. * Define if a depth texture is required instead of a depth buffer
  47598. */
  47599. generateDepthTexture?: boolean;
  47600. /**
  47601. * Define the number of desired draw buffers
  47602. */
  47603. textureCount?: number;
  47604. /**
  47605. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47606. */
  47607. doNotChangeAspectRatio?: boolean;
  47608. /**
  47609. * Define the default type of the buffers we are creating
  47610. */
  47611. defaultType?: number;
  47612. }
  47613. /**
  47614. * A multi render target, like a render target provides the ability to render to a texture.
  47615. * Unlike the render target, it can render to several draw buffers in one draw.
  47616. * This is specially interesting in deferred rendering or for any effects requiring more than
  47617. * just one color from a single pass.
  47618. */
  47619. class MultiRenderTarget extends RenderTargetTexture {
  47620. private _internalTextures;
  47621. private _textures;
  47622. private _multiRenderTargetOptions;
  47623. /**
  47624. * Get if draw buffers are currently supported by the used hardware and browser.
  47625. */
  47626. readonly isSupported: boolean;
  47627. /**
  47628. * Get the list of textures generated by the multi render target.
  47629. */
  47630. readonly textures: Texture[];
  47631. /**
  47632. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47633. */
  47634. readonly depthTexture: Texture;
  47635. /**
  47636. * Set the wrapping mode on U of all the textures we are rendering to.
  47637. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47638. */
  47639. wrapU: number;
  47640. /**
  47641. * Set the wrapping mode on V of all the textures we are rendering to.
  47642. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47643. */
  47644. wrapV: number;
  47645. /**
  47646. * Instantiate a new multi render target texture.
  47647. * A multi render target, like a render target provides the ability to render to a texture.
  47648. * Unlike the render target, it can render to several draw buffers in one draw.
  47649. * This is specially interesting in deferred rendering or for any effects requiring more than
  47650. * just one color from a single pass.
  47651. * @param name Define the name of the texture
  47652. * @param size Define the size of the buffers to render to
  47653. * @param count Define the number of target we are rendering into
  47654. * @param scene Define the scene the texture belongs to
  47655. * @param options Define the options used to create the multi render target
  47656. */
  47657. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47658. /** @hidden */
  47659. _rebuild(): void;
  47660. private _createInternalTextures;
  47661. private _createTextures;
  47662. /**
  47663. * Define the number of samples used if MSAA is enabled.
  47664. */
  47665. samples: number;
  47666. /**
  47667. * Resize all the textures in the multi render target.
  47668. * Be carrefull as it will recreate all the data in the new texture.
  47669. * @param size Define the new size
  47670. */
  47671. resize(size: any): void;
  47672. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47673. /**
  47674. * Dispose the render targets and their associated resources
  47675. */
  47676. dispose(): void;
  47677. /**
  47678. * Release all the underlying texture used as draw buffers.
  47679. */
  47680. releaseInternalTextures(): void;
  47681. }
  47682. }
  47683. declare module BABYLON {
  47684. /**
  47685. * Raw cube texture where the raw buffers are passed in
  47686. */
  47687. class RawCubeTexture extends CubeTexture {
  47688. /**
  47689. * Creates a cube texture where the raw buffers are passed in.
  47690. * @param scene defines the scene the texture is attached to
  47691. * @param data defines the array of data to use to create each face
  47692. * @param size defines the size of the textures
  47693. * @param format defines the format of the data
  47694. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47695. * @param generateMipMaps defines if the engine should generate the mip levels
  47696. * @param invertY defines if data must be stored with Y axis inverted
  47697. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47698. * @param compression defines the compression used (null by default)
  47699. */
  47700. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47701. /**
  47702. * Updates the raw cube texture.
  47703. * @param data defines the data to store
  47704. * @param format defines the data format
  47705. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47706. * @param invertY defines if data must be stored with Y axis inverted
  47707. * @param compression defines the compression used (null by default)
  47708. * @param level defines which level of the texture to update
  47709. */
  47710. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47711. /**
  47712. * Updates a raw cube texture with RGBD encoded data.
  47713. * @param data defines the array of data [mipmap][face] to use to create each face
  47714. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47715. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47716. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47717. * @returns a promsie that resolves when the operation is complete
  47718. */
  47719. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47720. /**
  47721. * Clones the raw cube texture.
  47722. * @return a new cube texture
  47723. */
  47724. clone(): CubeTexture;
  47725. /** @hidden */
  47726. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47727. }
  47728. }
  47729. declare module BABYLON {
  47730. /**
  47731. * Raw texture can help creating a texture directly from an array of data.
  47732. * This can be super useful if you either get the data from an uncompressed source or
  47733. * if you wish to create your texture pixel by pixel.
  47734. */
  47735. class RawTexture extends Texture {
  47736. /**
  47737. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47738. */
  47739. format: number;
  47740. private _engine;
  47741. /**
  47742. * Instantiates a new RawTexture.
  47743. * Raw texture can help creating a texture directly from an array of data.
  47744. * This can be super useful if you either get the data from an uncompressed source or
  47745. * if you wish to create your texture pixel by pixel.
  47746. * @param data define the array of data to use to create the texture
  47747. * @param width define the width of the texture
  47748. * @param height define the height of the texture
  47749. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47750. * @param scene define the scene the texture belongs to
  47751. * @param generateMipMaps define whether mip maps should be generated or not
  47752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47754. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47755. */
  47756. constructor(data: ArrayBufferView, width: number, height: number,
  47757. /**
  47758. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47759. */
  47760. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47761. /**
  47762. * Updates the texture underlying data.
  47763. * @param data Define the new data of the texture
  47764. */
  47765. update(data: ArrayBufferView): void;
  47766. /**
  47767. * Creates a luminance texture from some data.
  47768. * @param data Define the texture data
  47769. * @param width Define the width of the texture
  47770. * @param height Define the height of the texture
  47771. * @param scene Define the scene the texture belongs to
  47772. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47773. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47774. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47775. * @returns the luminance texture
  47776. */
  47777. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47778. /**
  47779. * Creates a luminance alpha texture from some data.
  47780. * @param data Define the texture data
  47781. * @param width Define the width of the texture
  47782. * @param height Define the height of the texture
  47783. * @param scene Define the scene the texture belongs to
  47784. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47787. * @returns the luminance alpha texture
  47788. */
  47789. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47790. /**
  47791. * Creates an alpha texture from some data.
  47792. * @param data Define the texture data
  47793. * @param width Define the width of the texture
  47794. * @param height Define the height of the texture
  47795. * @param scene Define the scene the texture belongs to
  47796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47799. * @returns the alpha texture
  47800. */
  47801. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47802. /**
  47803. * Creates a RGB texture from some data.
  47804. * @param data Define the texture data
  47805. * @param width Define the width of the texture
  47806. * @param height Define the height of the texture
  47807. * @param scene Define the scene the texture belongs to
  47808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47811. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47812. * @returns the RGB alpha texture
  47813. */
  47814. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47815. /**
  47816. * Creates a RGBA texture from some data.
  47817. * @param data Define the texture data
  47818. * @param width Define the width of the texture
  47819. * @param height Define the height of the texture
  47820. * @param scene Define the scene the texture belongs to
  47821. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47822. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47823. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47824. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47825. * @returns the RGBA texture
  47826. */
  47827. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47828. /**
  47829. * Creates a R texture from some data.
  47830. * @param data Define the texture data
  47831. * @param width Define the width of the texture
  47832. * @param height Define the height of the texture
  47833. * @param scene Define the scene the texture belongs to
  47834. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47835. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47836. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47837. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47838. * @returns the R texture
  47839. */
  47840. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47841. }
  47842. }
  47843. declare module BABYLON {
  47844. /**
  47845. * Class used to store 3D textures containing user data
  47846. */
  47847. class RawTexture3D extends Texture {
  47848. /** Gets or sets the texture format to use */
  47849. format: number;
  47850. private _engine;
  47851. /**
  47852. * Create a new RawTexture3D
  47853. * @param data defines the data of the texture
  47854. * @param width defines the width of the texture
  47855. * @param height defines the height of the texture
  47856. * @param depth defines the depth of the texture
  47857. * @param format defines the texture format to use
  47858. * @param scene defines the hosting scene
  47859. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47860. * @param invertY defines if texture must be stored with Y axis inverted
  47861. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47862. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47863. */
  47864. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47865. /** Gets or sets the texture format to use */
  47866. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47867. /**
  47868. * Update the texture with new data
  47869. * @param data defines the data to store in the texture
  47870. */
  47871. update(data: ArrayBufferView): void;
  47872. }
  47873. }
  47874. declare module BABYLON {
  47875. /**
  47876. * Creates a refraction texture used by refraction channel of the standard material.
  47877. * It is like a mirror but to see through a material.
  47878. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47879. */
  47880. class RefractionTexture extends RenderTargetTexture {
  47881. /**
  47882. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47883. * It is possible to directly set the refractionPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  47884. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47885. */
  47886. refractionPlane: Plane;
  47887. /**
  47888. * Define how deep under the surface we should see.
  47889. */
  47890. depth: number;
  47891. /**
  47892. * Creates a refraction texture used by refraction channel of the standard material.
  47893. * It is like a mirror but to see through a material.
  47894. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47895. * @param name Define the texture name
  47896. * @param size Define the size of the underlying texture
  47897. * @param scene Define the scene the refraction belongs to
  47898. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47899. */
  47900. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47901. /**
  47902. * Clone the refraction texture.
  47903. * @returns the cloned texture
  47904. */
  47905. clone(): RefractionTexture;
  47906. /**
  47907. * Serialize the texture to a JSON representation you could use in Parse later on
  47908. * @returns the serialized JSON representation
  47909. */
  47910. serialize(): any;
  47911. }
  47912. }
  47913. declare module BABYLON {
  47914. /**
  47915. * This Helps creating a texture that will be created from a camera in your scene.
  47916. * It is basically a dynamic texture that could be used to create special effects for instance.
  47917. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47918. */
  47919. class RenderTargetTexture extends Texture {
  47920. isCube: boolean;
  47921. /**
  47922. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47923. */
  47924. static readonly REFRESHRATE_RENDER_ONCE: number;
  47925. /**
  47926. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47927. */
  47928. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47929. /**
  47930. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47931. * the central point of your effect and can save a lot of performances.
  47932. */
  47933. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47934. /**
  47935. * Use this predicate to dynamically define the list of mesh you want to render.
  47936. * If set, the renderList property will be overwritten.
  47937. */
  47938. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47939. private _renderList;
  47940. /**
  47941. * Use this list to define the list of mesh you want to render.
  47942. */
  47943. renderList: Nullable<Array<AbstractMesh>>;
  47944. private _hookArray;
  47945. /**
  47946. * Define if particles should be rendered in your texture.
  47947. */
  47948. renderParticles: boolean;
  47949. /**
  47950. * Define if sprites should be rendered in your texture.
  47951. */
  47952. renderSprites: boolean;
  47953. /**
  47954. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47955. */
  47956. coordinatesMode: number;
  47957. /**
  47958. * Define the camera used to render the texture.
  47959. */
  47960. activeCamera: Nullable<Camera>;
  47961. /**
  47962. * Override the render function of the texture with your own one.
  47963. */
  47964. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47965. /**
  47966. * Define if camera post processes should be use while rendering the texture.
  47967. */
  47968. useCameraPostProcesses: boolean;
  47969. /**
  47970. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47971. */
  47972. ignoreCameraViewport: boolean;
  47973. private _postProcessManager;
  47974. private _postProcesses;
  47975. private _resizeObserver;
  47976. /**
  47977. * An event triggered when the texture is unbind.
  47978. */
  47979. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47980. /**
  47981. * An event triggered when the texture is unbind.
  47982. */
  47983. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47984. private _onAfterUnbindObserver;
  47985. /**
  47986. * Set a after unbind callback in the texture.
  47987. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47988. */
  47989. onAfterUnbind: () => void;
  47990. /**
  47991. * An event triggered before rendering the texture
  47992. */
  47993. onBeforeRenderObservable: Observable<number>;
  47994. private _onBeforeRenderObserver;
  47995. /**
  47996. * Set a before render callback in the texture.
  47997. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47998. */
  47999. onBeforeRender: (faceIndex: number) => void;
  48000. /**
  48001. * An event triggered after rendering the texture
  48002. */
  48003. onAfterRenderObservable: Observable<number>;
  48004. private _onAfterRenderObserver;
  48005. /**
  48006. * Set a after render callback in the texture.
  48007. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  48008. */
  48009. onAfterRender: (faceIndex: number) => void;
  48010. /**
  48011. * An event triggered after the texture clear
  48012. */
  48013. onClearObservable: Observable<Engine>;
  48014. private _onClearObserver;
  48015. /**
  48016. * Set a clear callback in the texture.
  48017. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  48018. */
  48019. onClear: (Engine: Engine) => void;
  48020. /**
  48021. * Define the clear color of the Render Target if it should be different from the scene.
  48022. */
  48023. clearColor: Color4;
  48024. protected _size: number | {
  48025. width: number;
  48026. height: number;
  48027. };
  48028. protected _initialSizeParameter: number | {
  48029. width: number;
  48030. height: number;
  48031. } | {
  48032. ratio: number;
  48033. };
  48034. protected _sizeRatio: Nullable<number>;
  48035. /** @hidden */
  48036. _generateMipMaps: boolean;
  48037. protected _renderingManager: RenderingManager;
  48038. /** @hidden */
  48039. _waitingRenderList: string[];
  48040. protected _doNotChangeAspectRatio: boolean;
  48041. protected _currentRefreshId: number;
  48042. protected _refreshRate: number;
  48043. protected _textureMatrix: Matrix;
  48044. protected _samples: number;
  48045. protected _renderTargetOptions: RenderTargetCreationOptions;
  48046. /**
  48047. * Gets render target creation options that were used.
  48048. */
  48049. readonly renderTargetOptions: RenderTargetCreationOptions;
  48050. protected _engine: Engine;
  48051. protected _onRatioRescale(): void;
  48052. /**
  48053. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  48054. * It must define where the camera used to render the texture is set
  48055. */
  48056. boundingBoxPosition: Vector3;
  48057. private _boundingBoxSize;
  48058. /**
  48059. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  48060. * When defined, the cubemap will switch to local mode
  48061. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48062. * @example https://www.babylonjs-playground.com/#RNASML
  48063. */
  48064. boundingBoxSize: Vector3;
  48065. /**
  48066. * In case the RTT has been created with a depth texture, get the associated
  48067. * depth texture.
  48068. * Otherwise, return null.
  48069. */
  48070. depthStencilTexture: Nullable<InternalTexture>;
  48071. /**
  48072. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  48073. * or used a shadow, depth texture...
  48074. * @param name The friendly name of the texture
  48075. * @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)
  48076. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  48077. * @param generateMipMaps True if mip maps need to be generated after render.
  48078. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  48079. * @param type The type of the buffer in the RTT (int, half float, float...)
  48080. * @param isCube True if a cube texture needs to be created
  48081. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  48082. * @param generateDepthBuffer True to generate a depth buffer
  48083. * @param generateStencilBuffer True to generate a stencil buffer
  48084. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  48085. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  48086. * @param delayAllocation if the texture allocation should be delayed (default: false)
  48087. */
  48088. constructor(name: string, size: number | {
  48089. width: number;
  48090. height: number;
  48091. } | {
  48092. ratio: number;
  48093. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  48094. /**
  48095. * Creates a depth stencil texture.
  48096. * This is only available in WebGL 2 or with the depth texture extension available.
  48097. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48098. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48099. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48100. */
  48101. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48102. private _processSizeParameter;
  48103. /**
  48104. * Define the number of samples to use in case of MSAA.
  48105. * It defaults to one meaning no MSAA has been enabled.
  48106. */
  48107. samples: number;
  48108. /**
  48109. * Resets the refresh counter of the texture and start bak from scratch.
  48110. * Could be useful to regenerate the texture if it is setup to render only once.
  48111. */
  48112. resetRefreshCounter(): void;
  48113. /**
  48114. * Define the refresh rate of the texture or the rendering frequency.
  48115. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48116. */
  48117. refreshRate: number;
  48118. /**
  48119. * Adds a post process to the render target rendering passes.
  48120. * @param postProcess define the post process to add
  48121. */
  48122. addPostProcess(postProcess: PostProcess): void;
  48123. /**
  48124. * Clear all the post processes attached to the render target
  48125. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48126. */
  48127. clearPostProcesses(dispose?: boolean): void;
  48128. /**
  48129. * Remove one of the post process from the list of attached post processes to the texture
  48130. * @param postProcess define the post process to remove from the list
  48131. */
  48132. removePostProcess(postProcess: PostProcess): void;
  48133. /** @hidden */
  48134. _shouldRender(): boolean;
  48135. /**
  48136. * Gets the actual render size of the texture.
  48137. * @returns the width of the render size
  48138. */
  48139. getRenderSize(): number;
  48140. /**
  48141. * Gets the actual render width of the texture.
  48142. * @returns the width of the render size
  48143. */
  48144. getRenderWidth(): number;
  48145. /**
  48146. * Gets the actual render height of the texture.
  48147. * @returns the height of the render size
  48148. */
  48149. getRenderHeight(): number;
  48150. /**
  48151. * Get if the texture can be rescaled or not.
  48152. */
  48153. readonly canRescale: boolean;
  48154. /**
  48155. * Resize the texture using a ratio.
  48156. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48157. */
  48158. scale(ratio: number): void;
  48159. /**
  48160. * Get the texture reflection matrix used to rotate/transform the reflection.
  48161. * @returns the reflection matrix
  48162. */
  48163. getReflectionTextureMatrix(): Matrix;
  48164. /**
  48165. * Resize the texture to a new desired size.
  48166. * Be carrefull as it will recreate all the data in the new texture.
  48167. * @param size Define the new size. It can be:
  48168. * - a number for squared texture,
  48169. * - an object containing { width: number, height: number }
  48170. * - or an object containing a ratio { ratio: number }
  48171. */
  48172. resize(size: number | {
  48173. width: number;
  48174. height: number;
  48175. } | {
  48176. ratio: number;
  48177. }): void;
  48178. /**
  48179. * Renders all the objects from the render list into the texture.
  48180. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48181. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48182. */
  48183. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48184. private _bestReflectionRenderTargetDimension;
  48185. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48186. private renderToTarget;
  48187. /**
  48188. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48189. * This allowed control for front to back rendering or reversly depending of the special needs.
  48190. *
  48191. * @param renderingGroupId The rendering group id corresponding to its index
  48192. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48193. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48194. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48195. */
  48196. 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;
  48197. /**
  48198. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48199. *
  48200. * @param renderingGroupId The rendering group id corresponding to its index
  48201. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48202. */
  48203. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48204. /**
  48205. * Clones the texture.
  48206. * @returns the cloned texture
  48207. */
  48208. clone(): RenderTargetTexture;
  48209. /**
  48210. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48211. * @returns The JSON representation of the texture
  48212. */
  48213. serialize(): any;
  48214. /**
  48215. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48216. */
  48217. disposeFramebufferObjects(): void;
  48218. /**
  48219. * Dispose the texture and release its associated resources.
  48220. */
  48221. dispose(): void;
  48222. /** @hidden */
  48223. _rebuild(): void;
  48224. /**
  48225. * Clear the info related to rendering groups preventing retention point in material dispose.
  48226. */
  48227. freeRenderingGroups(): void;
  48228. }
  48229. }
  48230. declare module BABYLON {
  48231. /**
  48232. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48233. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48234. */
  48235. class Texture extends BaseTexture {
  48236. /** nearest is mag = nearest and min = nearest and mip = linear */
  48237. static readonly NEAREST_SAMPLINGMODE: number;
  48238. /** nearest is mag = nearest and min = nearest and mip = linear */
  48239. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48240. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48241. static readonly BILINEAR_SAMPLINGMODE: number;
  48242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48243. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48244. /** Trilinear is mag = linear and min = linear and mip = linear */
  48245. static readonly TRILINEAR_SAMPLINGMODE: number;
  48246. /** Trilinear is mag = linear and min = linear and mip = linear */
  48247. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48248. /** mag = nearest and min = nearest and mip = nearest */
  48249. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48250. /** mag = nearest and min = linear and mip = nearest */
  48251. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48252. /** mag = nearest and min = linear and mip = linear */
  48253. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48254. /** mag = nearest and min = linear and mip = none */
  48255. static readonly NEAREST_LINEAR: number;
  48256. /** mag = nearest and min = nearest and mip = none */
  48257. static readonly NEAREST_NEAREST: number;
  48258. /** mag = linear and min = nearest and mip = nearest */
  48259. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48260. /** mag = linear and min = nearest and mip = linear */
  48261. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48262. /** mag = linear and min = linear and mip = none */
  48263. static readonly LINEAR_LINEAR: number;
  48264. /** mag = linear and min = nearest and mip = none */
  48265. static readonly LINEAR_NEAREST: number;
  48266. /** Explicit coordinates mode */
  48267. static readonly EXPLICIT_MODE: number;
  48268. /** Spherical coordinates mode */
  48269. static readonly SPHERICAL_MODE: number;
  48270. /** Planar coordinates mode */
  48271. static readonly PLANAR_MODE: number;
  48272. /** Cubic coordinates mode */
  48273. static readonly CUBIC_MODE: number;
  48274. /** Projection coordinates mode */
  48275. static readonly PROJECTION_MODE: number;
  48276. /** Inverse Cubic coordinates mode */
  48277. static readonly SKYBOX_MODE: number;
  48278. /** Inverse Cubic coordinates mode */
  48279. static readonly INVCUBIC_MODE: number;
  48280. /** Equirectangular coordinates mode */
  48281. static readonly EQUIRECTANGULAR_MODE: number;
  48282. /** Equirectangular Fixed coordinates mode */
  48283. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48284. /** Equirectangular Fixed Mirrored coordinates mode */
  48285. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48286. /** Texture is not repeating outside of 0..1 UVs */
  48287. static readonly CLAMP_ADDRESSMODE: number;
  48288. /** Texture is repeating outside of 0..1 UVs */
  48289. static readonly WRAP_ADDRESSMODE: number;
  48290. /** Texture is repeating and mirrored */
  48291. static readonly MIRROR_ADDRESSMODE: number;
  48292. /**
  48293. * 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
  48294. */
  48295. static UseSerializedUrlIfAny: boolean;
  48296. /**
  48297. * Define the url of the texture.
  48298. */
  48299. url: Nullable<string>;
  48300. /**
  48301. * Define an offset on the texture to offset the u coordinates of the UVs
  48302. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48303. */
  48304. uOffset: number;
  48305. /**
  48306. * Define an offset on the texture to offset the v coordinates of the UVs
  48307. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48308. */
  48309. vOffset: number;
  48310. /**
  48311. * Define an offset on the texture to scale the u coordinates of the UVs
  48312. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48313. */
  48314. uScale: number;
  48315. /**
  48316. * Define an offset on the texture to scale the v coordinates of the UVs
  48317. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48318. */
  48319. vScale: number;
  48320. /**
  48321. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48322. * @see http://doc.babylonjs.com/how_to/more_materials
  48323. */
  48324. uAng: number;
  48325. /**
  48326. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48327. * @see http://doc.babylonjs.com/how_to/more_materials
  48328. */
  48329. vAng: number;
  48330. /**
  48331. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48332. * @see http://doc.babylonjs.com/how_to/more_materials
  48333. */
  48334. wAng: number;
  48335. /**
  48336. * Defines the center of rotation (U)
  48337. */
  48338. uRotationCenter: number;
  48339. /**
  48340. * Defines the center of rotation (V)
  48341. */
  48342. vRotationCenter: number;
  48343. /**
  48344. * Defines the center of rotation (W)
  48345. */
  48346. wRotationCenter: number;
  48347. /**
  48348. * Are mip maps generated for this texture or not.
  48349. */
  48350. readonly noMipmap: boolean;
  48351. private _noMipmap;
  48352. /** @hidden */
  48353. _invertY: boolean;
  48354. private _rowGenerationMatrix;
  48355. private _cachedTextureMatrix;
  48356. private _projectionModeMatrix;
  48357. private _t0;
  48358. private _t1;
  48359. private _t2;
  48360. private _cachedUOffset;
  48361. private _cachedVOffset;
  48362. private _cachedUScale;
  48363. private _cachedVScale;
  48364. private _cachedUAng;
  48365. private _cachedVAng;
  48366. private _cachedWAng;
  48367. private _cachedProjectionMatrixId;
  48368. private _cachedCoordinatesMode;
  48369. /** @hidden */
  48370. protected _initialSamplingMode: number;
  48371. /** @hidden */
  48372. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48373. private _deleteBuffer;
  48374. protected _format: Nullable<number>;
  48375. private _delayedOnLoad;
  48376. private _delayedOnError;
  48377. /**
  48378. * Observable triggered once the texture has been loaded.
  48379. */
  48380. onLoadObservable: Observable<Texture>;
  48381. protected _isBlocking: boolean;
  48382. /**
  48383. * Is the texture preventing material to render while loading.
  48384. * If false, a default texture will be used instead of the loading one during the preparation step.
  48385. */
  48386. isBlocking: boolean;
  48387. /**
  48388. * Get the current sampling mode associated with the texture.
  48389. */
  48390. readonly samplingMode: number;
  48391. /**
  48392. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48393. */
  48394. readonly invertY: boolean;
  48395. /**
  48396. * Instantiates a new texture.
  48397. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48398. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48399. * @param url define the url of the picture to load as a texture
  48400. * @param scene define the scene the texture will belong to
  48401. * @param noMipmap define if the texture will require mip maps or not
  48402. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48403. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48404. * @param onLoad define a callback triggered when the texture has been loaded
  48405. * @param onError define a callback triggered when an error occurred during the loading session
  48406. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48407. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48408. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48409. */
  48410. 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);
  48411. /**
  48412. * Update the url (and optional buffer) of this texture if url was null during construction.
  48413. * @param url the url of the texture
  48414. * @param buffer the buffer of the texture (defaults to null)
  48415. * @param onLoad callback called when the texture is loaded (defaults to null)
  48416. */
  48417. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48418. /**
  48419. * Finish the loading sequence of a texture flagged as delayed load.
  48420. * @hidden
  48421. */
  48422. delayLoad(): void;
  48423. private _prepareRowForTextureGeneration;
  48424. /**
  48425. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48426. * @returns the transform matrix of the texture.
  48427. */
  48428. getTextureMatrix(): Matrix;
  48429. /**
  48430. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48431. * @returns The reflection texture transform
  48432. */
  48433. getReflectionTextureMatrix(): Matrix;
  48434. /**
  48435. * Clones the texture.
  48436. * @returns the cloned texture
  48437. */
  48438. clone(): Texture;
  48439. /**
  48440. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48441. * @returns The JSON representation of the texture
  48442. */
  48443. serialize(): any;
  48444. /**
  48445. * Get the current class name of the texture useful for serialization or dynamic coding.
  48446. * @returns "Texture"
  48447. */
  48448. getClassName(): string;
  48449. /**
  48450. * Dispose the texture and release its associated resources.
  48451. */
  48452. dispose(): void;
  48453. /**
  48454. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48455. * @param parsedTexture Define the JSON representation of the texture
  48456. * @param scene Define the scene the parsed texture should be instantiated in
  48457. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48458. * @returns The parsed texture if successful
  48459. */
  48460. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48461. /**
  48462. * Creates a texture from its base 64 representation.
  48463. * @param data Define the base64 payload without the data: prefix
  48464. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48465. * @param scene Define the scene the texture should belong to
  48466. * @param noMipmap Forces the texture to not create mip map information if true
  48467. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48468. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48469. * @param onLoad define a callback triggered when the texture has been loaded
  48470. * @param onError define a callback triggered when an error occurred during the loading session
  48471. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48472. * @returns the created texture
  48473. */
  48474. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48475. /**
  48476. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48477. * @param data Define the base64 payload without the data: prefix
  48478. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48479. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48480. * @param scene Define the scene the texture should belong to
  48481. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48482. * @param noMipmap Forces the texture to not create mip map information if true
  48483. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48484. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48485. * @param onLoad define a callback triggered when the texture has been loaded
  48486. * @param onError define a callback triggered when an error occurred during the loading session
  48487. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48488. * @returns the created texture
  48489. */
  48490. 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;
  48491. }
  48492. }
  48493. declare module BABYLON {
  48494. /**
  48495. * Settings for finer control over video usage
  48496. */
  48497. interface VideoTextureSettings {
  48498. /**
  48499. * Applies `autoplay` to video, if specified
  48500. */
  48501. autoPlay?: boolean;
  48502. /**
  48503. * Applies `loop` to video, if specified
  48504. */
  48505. loop?: boolean;
  48506. /**
  48507. * Automatically updates internal texture from video at every frame in the render loop
  48508. */
  48509. autoUpdateTexture: boolean;
  48510. /**
  48511. * Image src displayed during the video loading or until the user interacts with the video.
  48512. */
  48513. poster?: string;
  48514. }
  48515. /**
  48516. * If you want to display a video in your scene, this is the special texture for that.
  48517. * This special texture works similar to other textures, with the exception of a few parameters.
  48518. * @see https://doc.babylonjs.com/how_to/video_texture
  48519. */
  48520. class VideoTexture extends Texture {
  48521. /**
  48522. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48523. */
  48524. readonly autoUpdateTexture: boolean;
  48525. /**
  48526. * The video instance used by the texture internally
  48527. */
  48528. readonly video: HTMLVideoElement;
  48529. private _onUserActionRequestedObservable;
  48530. /**
  48531. * Event triggerd when a dom action is required by the user to play the video.
  48532. * This happens due to recent changes in browser policies preventing video to auto start.
  48533. */
  48534. readonly onUserActionRequestedObservable: Observable<Texture>;
  48535. private _generateMipMaps;
  48536. private _engine;
  48537. private _stillImageCaptured;
  48538. private _displayingPosterTexture;
  48539. private _settings;
  48540. private _createInternalTextureOnEvent;
  48541. /**
  48542. * Creates a video texture.
  48543. * If you want to display a video in your scene, this is the special texture for that.
  48544. * This special texture works similar to other textures, with the exception of a few parameters.
  48545. * @see https://doc.babylonjs.com/how_to/video_texture
  48546. * @param name optional name, will detect from video source, if not defined
  48547. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48548. * @param scene is obviously the current scene.
  48549. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48550. * @param invertY is false by default but can be used to invert video on Y axis
  48551. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48552. * @param settings allows finer control over video usage
  48553. */
  48554. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48555. private _getName;
  48556. private _getVideo;
  48557. private _createInternalTexture;
  48558. private reset;
  48559. /**
  48560. * @hidden Internal method to initiate `update`.
  48561. */
  48562. _rebuild(): void;
  48563. /**
  48564. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48565. */
  48566. update(): void;
  48567. /**
  48568. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48569. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48570. */
  48571. updateTexture(isVisible: boolean): void;
  48572. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48573. /**
  48574. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48575. * @param url New url.
  48576. */
  48577. updateURL(url: string): void;
  48578. /**
  48579. * Dispose the texture and release its associated resources.
  48580. */
  48581. dispose(): void;
  48582. /**
  48583. * Creates a video texture straight from your WebCam video feed.
  48584. * @param scene Define the scene the texture should be created in
  48585. * @param onReady Define a callback to triggered once the texture will be ready
  48586. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48587. */
  48588. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48589. minWidth: number;
  48590. maxWidth: number;
  48591. minHeight: number;
  48592. maxHeight: number;
  48593. deviceId: string;
  48594. }): void;
  48595. }
  48596. }
  48597. declare var DracoDecoderModule: any;
  48598. declare var WebAssembly: any;
  48599. declare module BABYLON {
  48600. /**
  48601. * Configuration for Draco compression
  48602. */
  48603. interface IDracoCompressionConfiguration {
  48604. /**
  48605. * Configuration for the decoder.
  48606. */
  48607. decoder?: {
  48608. /**
  48609. * The url to the WebAssembly module.
  48610. */
  48611. wasmUrl?: string;
  48612. /**
  48613. * The url to the WebAssembly binary.
  48614. */
  48615. wasmBinaryUrl?: string;
  48616. /**
  48617. * The url to the fallback JavaScript module.
  48618. */
  48619. fallbackUrl?: string;
  48620. };
  48621. }
  48622. /**
  48623. * Draco compression (https://google.github.io/draco/)
  48624. *
  48625. * This class wraps the Draco module.
  48626. *
  48627. * **Encoder**
  48628. *
  48629. * The encoder is not currently implemented.
  48630. *
  48631. * **Decoder**
  48632. *
  48633. * 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.
  48634. *
  48635. * To update the configuration, use the following code:
  48636. * ```javascript
  48637. * BABYLON.DracoCompression.Configuration = {
  48638. * decoder: {
  48639. * wasmUrl: "<url to the WebAssembly library>",
  48640. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48641. * fallbackUrl: "<url to the fallback JavaScript library>",
  48642. * }
  48643. * };
  48644. * ```
  48645. *
  48646. * 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.
  48647. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48648. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48649. *
  48650. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48651. * ```javascript
  48652. * var dracoCompression = new BABYLON.DracoCompression();
  48653. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48654. * [BABYLON.VertexBuffer.PositionKind]: 0
  48655. * });
  48656. * ```
  48657. *
  48658. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48659. */
  48660. class DracoCompression implements IDisposable {
  48661. private static _DecoderModulePromise;
  48662. /**
  48663. * The configuration. Defaults to the following urls:
  48664. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48665. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48666. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48667. */
  48668. static Configuration: IDracoCompressionConfiguration;
  48669. /**
  48670. * Returns true if the decoder is available.
  48671. */
  48672. static readonly DecoderAvailable: boolean;
  48673. /**
  48674. * Constructor
  48675. */
  48676. constructor();
  48677. /**
  48678. * Stop all async operations and release resources.
  48679. */
  48680. dispose(): void;
  48681. /**
  48682. * Decode Draco compressed mesh data to vertex data.
  48683. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48684. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48685. * @returns A promise that resolves with the decoded vertex data
  48686. */
  48687. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48688. [kind: string]: number;
  48689. }): Promise<VertexData>;
  48690. private static _GetDecoderModule;
  48691. private static _LoadScriptAsync;
  48692. private static _LoadFileAsync;
  48693. }
  48694. }
  48695. declare module BABYLON {
  48696. /**
  48697. * Particle emitter emitting particles from the inside of a box.
  48698. * It emits the particles randomly between 2 given directions.
  48699. */
  48700. class BoxParticleEmitter implements IParticleEmitterType {
  48701. /**
  48702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48703. */
  48704. direction1: Vector3;
  48705. /**
  48706. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48707. */
  48708. direction2: Vector3;
  48709. /**
  48710. * 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.
  48711. */
  48712. minEmitBox: Vector3;
  48713. /**
  48714. * 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.
  48715. */
  48716. maxEmitBox: Vector3;
  48717. /**
  48718. * Creates a new instance BoxParticleEmitter
  48719. */
  48720. constructor();
  48721. /**
  48722. * Called by the particle System when the direction is computed for the created particle.
  48723. * @param worldMatrix is the world matrix of the particle system
  48724. * @param directionToUpdate is the direction vector to update with the result
  48725. * @param particle is the particle we are computed the direction for
  48726. */
  48727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48728. /**
  48729. * Called by the particle System when the position is computed for the created particle.
  48730. * @param worldMatrix is the world matrix of the particle system
  48731. * @param positionToUpdate is the position vector to update with the result
  48732. * @param particle is the particle we are computed the position for
  48733. */
  48734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48735. /**
  48736. * Clones the current emitter and returns a copy of it
  48737. * @returns the new emitter
  48738. */
  48739. clone(): BoxParticleEmitter;
  48740. /**
  48741. * Called by the GPUParticleSystem to setup the update shader
  48742. * @param effect defines the update shader
  48743. */
  48744. applyToShader(effect: Effect): void;
  48745. /**
  48746. * Returns a string to use to update the GPU particles update shader
  48747. * @returns a string containng the defines string
  48748. */
  48749. getEffectDefines(): string;
  48750. /**
  48751. * Returns the string "BoxParticleEmitter"
  48752. * @returns a string containing the class name
  48753. */
  48754. getClassName(): string;
  48755. /**
  48756. * Serializes the particle system to a JSON object.
  48757. * @returns the JSON object
  48758. */
  48759. serialize(): any;
  48760. /**
  48761. * Parse properties from a JSON object
  48762. * @param serializationObject defines the JSON object
  48763. */
  48764. parse(serializationObject: any): void;
  48765. }
  48766. }
  48767. declare module BABYLON {
  48768. /**
  48769. * Particle emitter emitting particles from the inside of a cone.
  48770. * It emits the particles alongside the cone volume from the base to the particle.
  48771. * The emission direction might be randomized.
  48772. */
  48773. class ConeParticleEmitter implements IParticleEmitterType {
  48774. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48775. directionRandomizer: number;
  48776. private _radius;
  48777. private _angle;
  48778. private _height;
  48779. /**
  48780. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48781. */
  48782. radiusRange: number;
  48783. /**
  48784. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48785. */
  48786. heightRange: number;
  48787. /**
  48788. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48789. */
  48790. emitFromSpawnPointOnly: boolean;
  48791. /**
  48792. * Gets or sets the radius of the emission cone
  48793. */
  48794. radius: number;
  48795. /**
  48796. * Gets or sets the angle of the emission cone
  48797. */
  48798. angle: number;
  48799. private _buildHeight;
  48800. /**
  48801. * Creates a new instance ConeParticleEmitter
  48802. * @param radius the radius of the emission cone (1 by default)
  48803. * @param angles the cone base angle (PI by default)
  48804. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48805. */
  48806. constructor(radius?: number, angle?: number,
  48807. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48808. directionRandomizer?: number);
  48809. /**
  48810. * Called by the particle System when the direction is computed for the created particle.
  48811. * @param worldMatrix is the world matrix of the particle system
  48812. * @param directionToUpdate is the direction vector to update with the result
  48813. * @param particle is the particle we are computed the direction for
  48814. */
  48815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48816. /**
  48817. * Called by the particle System when the position is computed for the created particle.
  48818. * @param worldMatrix is the world matrix of the particle system
  48819. * @param positionToUpdate is the position vector to update with the result
  48820. * @param particle is the particle we are computed the position for
  48821. */
  48822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48823. /**
  48824. * Clones the current emitter and returns a copy of it
  48825. * @returns the new emitter
  48826. */
  48827. clone(): ConeParticleEmitter;
  48828. /**
  48829. * Called by the GPUParticleSystem to setup the update shader
  48830. * @param effect defines the update shader
  48831. */
  48832. applyToShader(effect: Effect): void;
  48833. /**
  48834. * Returns a string to use to update the GPU particles update shader
  48835. * @returns a string containng the defines string
  48836. */
  48837. getEffectDefines(): string;
  48838. /**
  48839. * Returns the string "ConeParticleEmitter"
  48840. * @returns a string containing the class name
  48841. */
  48842. getClassName(): string;
  48843. /**
  48844. * Serializes the particle system to a JSON object.
  48845. * @returns the JSON object
  48846. */
  48847. serialize(): any;
  48848. /**
  48849. * Parse properties from a JSON object
  48850. * @param serializationObject defines the JSON object
  48851. */
  48852. parse(serializationObject: any): void;
  48853. }
  48854. }
  48855. declare module BABYLON {
  48856. /**
  48857. * Particle emitter emitting particles from the inside of a cylinder.
  48858. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48859. */
  48860. class CylinderParticleEmitter implements IParticleEmitterType {
  48861. /**
  48862. * The radius of the emission cylinder.
  48863. */
  48864. radius: number;
  48865. /**
  48866. * The height of the emission cylinder.
  48867. */
  48868. height: number;
  48869. /**
  48870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48871. */
  48872. radiusRange: number;
  48873. /**
  48874. * How much to randomize the particle direction [0-1].
  48875. */
  48876. directionRandomizer: number;
  48877. /**
  48878. * Creates a new instance CylinderParticleEmitter
  48879. * @param radius the radius of the emission cylinder (1 by default)
  48880. * @param height the height of the emission cylinder (1 by default)
  48881. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48883. */
  48884. constructor(
  48885. /**
  48886. * The radius of the emission cylinder.
  48887. */
  48888. radius?: number,
  48889. /**
  48890. * The height of the emission cylinder.
  48891. */
  48892. height?: number,
  48893. /**
  48894. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48895. */
  48896. radiusRange?: number,
  48897. /**
  48898. * How much to randomize the particle direction [0-1].
  48899. */
  48900. directionRandomizer?: number);
  48901. /**
  48902. * Called by the particle System when the direction is computed for the created particle.
  48903. * @param worldMatrix is the world matrix of the particle system
  48904. * @param directionToUpdate is the direction vector to update with the result
  48905. * @param particle is the particle we are computed the direction for
  48906. */
  48907. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48908. /**
  48909. * Called by the particle System when the position is computed for the created particle.
  48910. * @param worldMatrix is the world matrix of the particle system
  48911. * @param positionToUpdate is the position vector to update with the result
  48912. * @param particle is the particle we are computed the position for
  48913. */
  48914. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48915. /**
  48916. * Clones the current emitter and returns a copy of it
  48917. * @returns the new emitter
  48918. */
  48919. clone(): CylinderParticleEmitter;
  48920. /**
  48921. * Called by the GPUParticleSystem to setup the update shader
  48922. * @param effect defines the update shader
  48923. */
  48924. applyToShader(effect: Effect): void;
  48925. /**
  48926. * Returns a string to use to update the GPU particles update shader
  48927. * @returns a string containng the defines string
  48928. */
  48929. getEffectDefines(): string;
  48930. /**
  48931. * Returns the string "CylinderParticleEmitter"
  48932. * @returns a string containing the class name
  48933. */
  48934. getClassName(): string;
  48935. /**
  48936. * Serializes the particle system to a JSON object.
  48937. * @returns the JSON object
  48938. */
  48939. serialize(): any;
  48940. /**
  48941. * Parse properties from a JSON object
  48942. * @param serializationObject defines the JSON object
  48943. */
  48944. parse(serializationObject: any): void;
  48945. }
  48946. /**
  48947. * Particle emitter emitting particles from the inside of a cylinder.
  48948. * It emits the particles randomly between two vectors.
  48949. */
  48950. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48951. /**
  48952. * The min limit of the emission direction.
  48953. */
  48954. direction1: Vector3;
  48955. /**
  48956. * The max limit of the emission direction.
  48957. */
  48958. direction2: Vector3;
  48959. /**
  48960. * Creates a new instance CylinderDirectedParticleEmitter
  48961. * @param radius the radius of the emission cylinder (1 by default)
  48962. * @param height the height of the emission cylinder (1 by default)
  48963. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48964. * @param direction1 the min limit of the emission direction (up vector by default)
  48965. * @param direction2 the max limit of the emission direction (up vector by default)
  48966. */
  48967. constructor(radius?: number, height?: number, radiusRange?: number,
  48968. /**
  48969. * The min limit of the emission direction.
  48970. */
  48971. direction1?: Vector3,
  48972. /**
  48973. * The max limit of the emission direction.
  48974. */
  48975. direction2?: Vector3);
  48976. /**
  48977. * Called by the particle System when the direction is computed for the created particle.
  48978. * @param worldMatrix is the world matrix of the particle system
  48979. * @param directionToUpdate is the direction vector to update with the result
  48980. * @param particle is the particle we are computed the direction for
  48981. */
  48982. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48983. /**
  48984. * Clones the current emitter and returns a copy of it
  48985. * @returns the new emitter
  48986. */
  48987. clone(): CylinderDirectedParticleEmitter;
  48988. /**
  48989. * Called by the GPUParticleSystem to setup the update shader
  48990. * @param effect defines the update shader
  48991. */
  48992. applyToShader(effect: Effect): void;
  48993. /**
  48994. * Returns a string to use to update the GPU particles update shader
  48995. * @returns a string containng the defines string
  48996. */
  48997. getEffectDefines(): string;
  48998. /**
  48999. * Returns the string "CylinderDirectedParticleEmitter"
  49000. * @returns a string containing the class name
  49001. */
  49002. getClassName(): string;
  49003. /**
  49004. * Serializes the particle system to a JSON object.
  49005. * @returns the JSON object
  49006. */
  49007. serialize(): any;
  49008. /**
  49009. * Parse properties from a JSON object
  49010. * @param serializationObject defines the JSON object
  49011. */
  49012. parse(serializationObject: any): void;
  49013. }
  49014. }
  49015. declare module BABYLON {
  49016. /**
  49017. * Particle emitter emitting particles from the inside of a hemisphere.
  49018. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  49019. */
  49020. class HemisphericParticleEmitter implements IParticleEmitterType {
  49021. /**
  49022. * The radius of the emission hemisphere.
  49023. */
  49024. radius: number;
  49025. /**
  49026. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49027. */
  49028. radiusRange: number;
  49029. /**
  49030. * How much to randomize the particle direction [0-1].
  49031. */
  49032. directionRandomizer: number;
  49033. /**
  49034. * Creates a new instance HemisphericParticleEmitter
  49035. * @param radius the radius of the emission hemisphere (1 by default)
  49036. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49037. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49038. */
  49039. constructor(
  49040. /**
  49041. * The radius of the emission hemisphere.
  49042. */
  49043. radius?: number,
  49044. /**
  49045. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49046. */
  49047. radiusRange?: number,
  49048. /**
  49049. * How much to randomize the particle direction [0-1].
  49050. */
  49051. directionRandomizer?: number);
  49052. /**
  49053. * Called by the particle System when the direction is computed for the created particle.
  49054. * @param worldMatrix is the world matrix of the particle system
  49055. * @param directionToUpdate is the direction vector to update with the result
  49056. * @param particle is the particle we are computed the direction for
  49057. */
  49058. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49059. /**
  49060. * Called by the particle System when the position is computed for the created particle.
  49061. * @param worldMatrix is the world matrix of the particle system
  49062. * @param positionToUpdate is the position vector to update with the result
  49063. * @param particle is the particle we are computed the position for
  49064. */
  49065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49066. /**
  49067. * Clones the current emitter and returns a copy of it
  49068. * @returns the new emitter
  49069. */
  49070. clone(): HemisphericParticleEmitter;
  49071. /**
  49072. * Called by the GPUParticleSystem to setup the update shader
  49073. * @param effect defines the update shader
  49074. */
  49075. applyToShader(effect: Effect): void;
  49076. /**
  49077. * Returns a string to use to update the GPU particles update shader
  49078. * @returns a string containng the defines string
  49079. */
  49080. getEffectDefines(): string;
  49081. /**
  49082. * Returns the string "HemisphericParticleEmitter"
  49083. * @returns a string containing the class name
  49084. */
  49085. getClassName(): string;
  49086. /**
  49087. * Serializes the particle system to a JSON object.
  49088. * @returns the JSON object
  49089. */
  49090. serialize(): any;
  49091. /**
  49092. * Parse properties from a JSON object
  49093. * @param serializationObject defines the JSON object
  49094. */
  49095. parse(serializationObject: any): void;
  49096. }
  49097. }
  49098. declare module BABYLON {
  49099. /**
  49100. * Particle emitter represents a volume emitting particles.
  49101. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49102. */
  49103. interface IParticleEmitterType {
  49104. /**
  49105. * Called by the particle System when the direction is computed for the created particle.
  49106. * @param worldMatrix is the world matrix of the particle system
  49107. * @param directionToUpdate is the direction vector to update with the result
  49108. * @param particle is the particle we are computed the direction for
  49109. */
  49110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49111. /**
  49112. * Called by the particle System when the position is computed for the created particle.
  49113. * @param worldMatrix is the world matrix of the particle system
  49114. * @param positionToUpdate is the position vector to update with the result
  49115. * @param particle is the particle we are computed the position for
  49116. */
  49117. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49118. /**
  49119. * Clones the current emitter and returns a copy of it
  49120. * @returns the new emitter
  49121. */
  49122. clone(): IParticleEmitterType;
  49123. /**
  49124. * Called by the GPUParticleSystem to setup the update shader
  49125. * @param effect defines the update shader
  49126. */
  49127. applyToShader(effect: Effect): void;
  49128. /**
  49129. * Returns a string to use to update the GPU particles update shader
  49130. * @returns the effect defines string
  49131. */
  49132. getEffectDefines(): string;
  49133. /**
  49134. * Returns a string representing the class name
  49135. * @returns a string containing the class name
  49136. */
  49137. getClassName(): string;
  49138. /**
  49139. * Serializes the particle system to a JSON object.
  49140. * @returns the JSON object
  49141. */
  49142. serialize(): any;
  49143. /**
  49144. * Parse properties from a JSON object
  49145. * @param serializationObject defines the JSON object
  49146. */
  49147. parse(serializationObject: any): void;
  49148. }
  49149. }
  49150. declare module BABYLON {
  49151. /**
  49152. * Particle emitter emitting particles from a point.
  49153. * It emits the particles randomly between 2 given directions.
  49154. */
  49155. class PointParticleEmitter implements IParticleEmitterType {
  49156. /**
  49157. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49158. */
  49159. direction1: Vector3;
  49160. /**
  49161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49162. */
  49163. direction2: Vector3;
  49164. /**
  49165. * Creates a new instance PointParticleEmitter
  49166. */
  49167. constructor();
  49168. /**
  49169. * Called by the particle System when the direction is computed for the created particle.
  49170. * @param worldMatrix is the world matrix of the particle system
  49171. * @param directionToUpdate is the direction vector to update with the result
  49172. * @param particle is the particle we are computed the direction for
  49173. */
  49174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49175. /**
  49176. * Called by the particle System when the position is computed for the created particle.
  49177. * @param worldMatrix is the world matrix of the particle system
  49178. * @param positionToUpdate is the position vector to update with the result
  49179. * @param particle is the particle we are computed the position for
  49180. */
  49181. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49182. /**
  49183. * Clones the current emitter and returns a copy of it
  49184. * @returns the new emitter
  49185. */
  49186. clone(): PointParticleEmitter;
  49187. /**
  49188. * Called by the GPUParticleSystem to setup the update shader
  49189. * @param effect defines the update shader
  49190. */
  49191. applyToShader(effect: Effect): void;
  49192. /**
  49193. * Returns a string to use to update the GPU particles update shader
  49194. * @returns a string containng the defines string
  49195. */
  49196. getEffectDefines(): string;
  49197. /**
  49198. * Returns the string "PointParticleEmitter"
  49199. * @returns a string containing the class name
  49200. */
  49201. getClassName(): string;
  49202. /**
  49203. * Serializes the particle system to a JSON object.
  49204. * @returns the JSON object
  49205. */
  49206. serialize(): any;
  49207. /**
  49208. * Parse properties from a JSON object
  49209. * @param serializationObject defines the JSON object
  49210. */
  49211. parse(serializationObject: any): void;
  49212. }
  49213. }
  49214. declare module BABYLON {
  49215. /**
  49216. * Particle emitter emitting particles from the inside of a sphere.
  49217. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49218. */
  49219. class SphereParticleEmitter implements IParticleEmitterType {
  49220. /**
  49221. * The radius of the emission sphere.
  49222. */
  49223. radius: number;
  49224. /**
  49225. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49226. */
  49227. radiusRange: number;
  49228. /**
  49229. * How much to randomize the particle direction [0-1].
  49230. */
  49231. directionRandomizer: number;
  49232. /**
  49233. * Creates a new instance SphereParticleEmitter
  49234. * @param radius the radius of the emission sphere (1 by default)
  49235. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49236. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49237. */
  49238. constructor(
  49239. /**
  49240. * The radius of the emission sphere.
  49241. */
  49242. radius?: number,
  49243. /**
  49244. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49245. */
  49246. radiusRange?: number,
  49247. /**
  49248. * How much to randomize the particle direction [0-1].
  49249. */
  49250. directionRandomizer?: number);
  49251. /**
  49252. * Called by the particle System when the direction is computed for the created particle.
  49253. * @param worldMatrix is the world matrix of the particle system
  49254. * @param directionToUpdate is the direction vector to update with the result
  49255. * @param particle is the particle we are computed the direction for
  49256. */
  49257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49258. /**
  49259. * Called by the particle System when the position is computed for the created particle.
  49260. * @param worldMatrix is the world matrix of the particle system
  49261. * @param positionToUpdate is the position vector to update with the result
  49262. * @param particle is the particle we are computed the position for
  49263. */
  49264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49265. /**
  49266. * Clones the current emitter and returns a copy of it
  49267. * @returns the new emitter
  49268. */
  49269. clone(): SphereParticleEmitter;
  49270. /**
  49271. * Called by the GPUParticleSystem to setup the update shader
  49272. * @param effect defines the update shader
  49273. */
  49274. applyToShader(effect: Effect): void;
  49275. /**
  49276. * Returns a string to use to update the GPU particles update shader
  49277. * @returns a string containng the defines string
  49278. */
  49279. getEffectDefines(): string;
  49280. /**
  49281. * Returns the string "SphereParticleEmitter"
  49282. * @returns a string containing the class name
  49283. */
  49284. getClassName(): string;
  49285. /**
  49286. * Serializes the particle system to a JSON object.
  49287. * @returns the JSON object
  49288. */
  49289. serialize(): any;
  49290. /**
  49291. * Parse properties from a JSON object
  49292. * @param serializationObject defines the JSON object
  49293. */
  49294. parse(serializationObject: any): void;
  49295. }
  49296. /**
  49297. * Particle emitter emitting particles from the inside of a sphere.
  49298. * It emits the particles randomly between two vectors.
  49299. */
  49300. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49301. /**
  49302. * The min limit of the emission direction.
  49303. */
  49304. direction1: Vector3;
  49305. /**
  49306. * The max limit of the emission direction.
  49307. */
  49308. direction2: Vector3;
  49309. /**
  49310. * Creates a new instance SphereDirectedParticleEmitter
  49311. * @param radius the radius of the emission sphere (1 by default)
  49312. * @param direction1 the min limit of the emission direction (up vector by default)
  49313. * @param direction2 the max limit of the emission direction (up vector by default)
  49314. */
  49315. constructor(radius?: number,
  49316. /**
  49317. * The min limit of the emission direction.
  49318. */
  49319. direction1?: Vector3,
  49320. /**
  49321. * The max limit of the emission direction.
  49322. */
  49323. direction2?: Vector3);
  49324. /**
  49325. * Called by the particle System when the direction is computed for the created particle.
  49326. * @param worldMatrix is the world matrix of the particle system
  49327. * @param directionToUpdate is the direction vector to update with the result
  49328. * @param particle is the particle we are computed the direction for
  49329. */
  49330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49331. /**
  49332. * Clones the current emitter and returns a copy of it
  49333. * @returns the new emitter
  49334. */
  49335. clone(): SphereDirectedParticleEmitter;
  49336. /**
  49337. * Called by the GPUParticleSystem to setup the update shader
  49338. * @param effect defines the update shader
  49339. */
  49340. applyToShader(effect: Effect): void;
  49341. /**
  49342. * Returns a string to use to update the GPU particles update shader
  49343. * @returns a string containng the defines string
  49344. */
  49345. getEffectDefines(): string;
  49346. /**
  49347. * Returns the string "SphereDirectedParticleEmitter"
  49348. * @returns a string containing the class name
  49349. */
  49350. getClassName(): string;
  49351. /**
  49352. * Serializes the particle system to a JSON object.
  49353. * @returns the JSON object
  49354. */
  49355. serialize(): any;
  49356. /**
  49357. * Parse properties from a JSON object
  49358. * @param serializationObject defines the JSON object
  49359. */
  49360. parse(serializationObject: any): void;
  49361. }
  49362. }
  49363. declare module BABYLON {
  49364. /**
  49365. * AmmoJS Physics plugin
  49366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49367. * @see https://github.com/kripken/ammo.js/
  49368. */
  49369. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49370. private _useDeltaForWorldStep;
  49371. /**
  49372. * Reference to the Ammo library
  49373. */
  49374. bjsAMMO: any;
  49375. /**
  49376. * Created ammoJS world which physics bodies are added to
  49377. */
  49378. world: any;
  49379. /**
  49380. * Name of the plugin
  49381. */
  49382. name: string;
  49383. private _timeStep;
  49384. private _fixedTimeStep;
  49385. private _maxSteps;
  49386. private _tmpQuaternion;
  49387. private _tmpAmmoTransform;
  49388. private _tmpAmmoQuaternion;
  49389. private _tmpAmmoConcreteContactResultCallback;
  49390. private _collisionConfiguration;
  49391. private _dispatcher;
  49392. private _overlappingPairCache;
  49393. private _solver;
  49394. private _tmpAmmoVectorA;
  49395. private _tmpAmmoVectorB;
  49396. private _tmpAmmoVectorC;
  49397. private _tmpContactCallbackResult;
  49398. private static readonly DISABLE_COLLISION_FLAG;
  49399. private static readonly KINEMATIC_FLAG;
  49400. private static readonly DISABLE_DEACTIVATION_FLAG;
  49401. /**
  49402. * Initializes the ammoJS plugin
  49403. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49404. */
  49405. constructor(_useDeltaForWorldStep?: boolean);
  49406. /**
  49407. * Sets the gravity of the physics world (m/(s^2))
  49408. * @param gravity Gravity to set
  49409. */
  49410. setGravity(gravity: Vector3): void;
  49411. /**
  49412. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49413. * @param timeStep timestep to use in seconds
  49414. */
  49415. setTimeStep(timeStep: number): void;
  49416. /**
  49417. * 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)
  49418. * @param fixedTimeStep fixedTimeStep to use in seconds
  49419. */
  49420. setFixedTimeStep(fixedTimeStep: number): void;
  49421. /**
  49422. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49423. * @param maxSteps the maximum number of steps by the physics engine per frame
  49424. */
  49425. setMaxSteps(maxSteps: number): void;
  49426. /**
  49427. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49428. * @returns the current timestep in seconds
  49429. */
  49430. getTimeStep(): number;
  49431. private _isImpostorInContact;
  49432. private _isImpostorPairInContact;
  49433. private _stepSimulation;
  49434. /**
  49435. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49436. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49437. * After the step the babylon meshes are set to the position of the physics imposters
  49438. * @param delta amount of time to step forward
  49439. * @param impostors array of imposters to update before/after the step
  49440. */
  49441. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49442. /**
  49443. * Applies an implulse on the imposter
  49444. * @param impostor imposter to apply impulse
  49445. * @param force amount of force to be applied to the imposter
  49446. * @param contactPoint the location to apply the impulse on the imposter
  49447. */
  49448. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49449. /**
  49450. * Applies a force on the imposter
  49451. * @param impostor imposter to apply force
  49452. * @param force amount of force to be applied to the imposter
  49453. * @param contactPoint the location to apply the force on the imposter
  49454. */
  49455. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49456. /**
  49457. * Creates a physics body using the plugin
  49458. * @param impostor the imposter to create the physics body on
  49459. */
  49460. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49461. /**
  49462. * Removes the physics body from the imposter and disposes of the body's memory
  49463. * @param impostor imposter to remove the physics body from
  49464. */
  49465. removePhysicsBody(impostor: PhysicsImpostor): void;
  49466. /**
  49467. * Generates a joint
  49468. * @param impostorJoint the imposter joint to create the joint with
  49469. */
  49470. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49471. /**
  49472. * Removes a joint
  49473. * @param impostorJoint the imposter joint to remove the joint from
  49474. */
  49475. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49476. private _addMeshVerts;
  49477. private _createShape;
  49478. /**
  49479. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49480. * @param impostor imposter containing the physics body and babylon object
  49481. */
  49482. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49483. /**
  49484. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49485. * @param impostor imposter containing the physics body and babylon object
  49486. * @param newPosition new position
  49487. * @param newRotation new rotation
  49488. */
  49489. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49490. /**
  49491. * If this plugin is supported
  49492. * @returns true if its supported
  49493. */
  49494. isSupported(): boolean;
  49495. /**
  49496. * Sets the linear velocity of the physics body
  49497. * @param impostor imposter to set the velocity on
  49498. * @param velocity velocity to set
  49499. */
  49500. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49501. /**
  49502. * Sets the angular velocity of the physics body
  49503. * @param impostor imposter to set the velocity on
  49504. * @param velocity velocity to set
  49505. */
  49506. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49507. /**
  49508. * gets the linear velocity
  49509. * @param impostor imposter to get linear velocity from
  49510. * @returns linear velocity
  49511. */
  49512. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49513. /**
  49514. * gets the angular velocity
  49515. * @param impostor imposter to get angular velocity from
  49516. * @returns angular velocity
  49517. */
  49518. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49519. /**
  49520. * Sets the mass of physics body
  49521. * @param impostor imposter to set the mass on
  49522. * @param mass mass to set
  49523. */
  49524. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49525. /**
  49526. * Gets the mass of the physics body
  49527. * @param impostor imposter to get the mass from
  49528. * @returns mass
  49529. */
  49530. getBodyMass(impostor: PhysicsImpostor): number;
  49531. /**
  49532. * Gets friction of the impostor
  49533. * @param impostor impostor to get friction from
  49534. * @returns friction value
  49535. */
  49536. getBodyFriction(impostor: PhysicsImpostor): number;
  49537. /**
  49538. * Sets friction of the impostor
  49539. * @param impostor impostor to set friction on
  49540. * @param friction friction value
  49541. */
  49542. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49543. /**
  49544. * Gets restitution of the impostor
  49545. * @param impostor impostor to get restitution from
  49546. * @returns restitution value
  49547. */
  49548. getBodyRestitution(impostor: PhysicsImpostor): number;
  49549. /**
  49550. * Sets resitution of the impostor
  49551. * @param impostor impostor to set resitution on
  49552. * @param restitution resitution value
  49553. */
  49554. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49555. /**
  49556. * Sleeps the physics body and stops it from being active
  49557. * @param impostor impostor to sleep
  49558. */
  49559. sleepBody(impostor: PhysicsImpostor): void;
  49560. /**
  49561. * Activates the physics body
  49562. * @param impostor impostor to activate
  49563. */
  49564. wakeUpBody(impostor: PhysicsImpostor): void;
  49565. /**
  49566. * Updates the distance parameters of the joint
  49567. * @param joint joint to update
  49568. * @param maxDistance maximum distance of the joint
  49569. * @param minDistance minimum distance of the joint
  49570. */
  49571. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49572. /**
  49573. * Sets a motor on the joint
  49574. * @param joint joint to set motor on
  49575. * @param speed speed of the motor
  49576. * @param maxForce maximum force of the motor
  49577. * @param motorIndex index of the motor
  49578. */
  49579. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49580. /**
  49581. * Sets the motors limit
  49582. * @param joint joint to set limit on
  49583. * @param upperLimit upper limit
  49584. * @param lowerLimit lower limit
  49585. */
  49586. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49587. /**
  49588. * Syncs the position and rotation of a mesh with the impostor
  49589. * @param mesh mesh to sync
  49590. * @param impostor impostor to update the mesh with
  49591. */
  49592. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49593. /**
  49594. * Gets the radius of the impostor
  49595. * @param impostor impostor to get radius from
  49596. * @returns the radius
  49597. */
  49598. getRadius(impostor: PhysicsImpostor): number;
  49599. /**
  49600. * Gets the box size of the impostor
  49601. * @param impostor impostor to get box size from
  49602. * @param result the resulting box size
  49603. */
  49604. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49605. /**
  49606. * Disposes of the impostor
  49607. */
  49608. dispose(): void;
  49609. }
  49610. }
  49611. declare module BABYLON {
  49612. /** @hidden */
  49613. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49614. private _useDeltaForWorldStep;
  49615. world: any;
  49616. name: string;
  49617. private _physicsMaterials;
  49618. private _fixedTimeStep;
  49619. BJSCANNON: any;
  49620. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49621. setGravity(gravity: Vector3): void;
  49622. setTimeStep(timeStep: number): void;
  49623. getTimeStep(): number;
  49624. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49625. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49626. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49627. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49628. private _processChildMeshes;
  49629. removePhysicsBody(impostor: PhysicsImpostor): void;
  49630. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49631. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49632. private _addMaterial;
  49633. private _checkWithEpsilon;
  49634. private _createShape;
  49635. private _createHeightmap;
  49636. private _minus90X;
  49637. private _plus90X;
  49638. private _tmpPosition;
  49639. private _tmpDeltaPosition;
  49640. private _tmpUnityRotation;
  49641. private _updatePhysicsBodyTransformation;
  49642. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49643. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49644. isSupported(): boolean;
  49645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49650. getBodyMass(impostor: PhysicsImpostor): number;
  49651. getBodyFriction(impostor: PhysicsImpostor): number;
  49652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49653. getBodyRestitution(impostor: PhysicsImpostor): number;
  49654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49655. sleepBody(impostor: PhysicsImpostor): void;
  49656. wakeUpBody(impostor: PhysicsImpostor): void;
  49657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49658. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49659. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49661. getRadius(impostor: PhysicsImpostor): number;
  49662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49663. dispose(): void;
  49664. private _extendNamespace;
  49665. }
  49666. }
  49667. declare module BABYLON {
  49668. /** @hidden */
  49669. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49670. world: any;
  49671. name: string;
  49672. BJSOIMO: any;
  49673. constructor(iterations?: number);
  49674. setGravity(gravity: Vector3): void;
  49675. setTimeStep(timeStep: number): void;
  49676. getTimeStep(): number;
  49677. private _tmpImpostorsArray;
  49678. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49679. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49680. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49681. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49682. private _tmpPositionVector;
  49683. removePhysicsBody(impostor: PhysicsImpostor): void;
  49684. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49685. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49686. isSupported(): boolean;
  49687. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49688. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49689. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49690. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49691. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49692. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49693. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49694. getBodyMass(impostor: PhysicsImpostor): number;
  49695. getBodyFriction(impostor: PhysicsImpostor): number;
  49696. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49697. getBodyRestitution(impostor: PhysicsImpostor): number;
  49698. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49699. sleepBody(impostor: PhysicsImpostor): void;
  49700. wakeUpBody(impostor: PhysicsImpostor): void;
  49701. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49702. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49703. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49704. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49705. getRadius(impostor: PhysicsImpostor): number;
  49706. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49707. dispose(): void;
  49708. }
  49709. }
  49710. declare module BABYLON {
  49711. /**
  49712. * This represents a set of one or more post processes in Babylon.
  49713. * A post process can be used to apply a shader to a texture after it is rendered.
  49714. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49715. */
  49716. class PostProcessRenderEffect {
  49717. private _postProcesses;
  49718. private _getPostProcesses;
  49719. private _singleInstance;
  49720. private _cameras;
  49721. private _indicesForCamera;
  49722. /**
  49723. * Name of the effect
  49724. * @hidden
  49725. */
  49726. _name: string;
  49727. /**
  49728. * Instantiates a post process render effect.
  49729. * A post process can be used to apply a shader to a texture after it is rendered.
  49730. * @param engine The engine the effect is tied to
  49731. * @param name The name of the effect
  49732. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49733. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49734. */
  49735. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49736. /**
  49737. * Checks if all the post processes in the effect are supported.
  49738. */
  49739. readonly isSupported: boolean;
  49740. /**
  49741. * Updates the current state of the effect
  49742. * @hidden
  49743. */
  49744. _update(): void;
  49745. /**
  49746. * Attaches the effect on cameras
  49747. * @param cameras The camera to attach to.
  49748. * @hidden
  49749. */
  49750. _attachCameras(cameras: Camera): void;
  49751. /**
  49752. * Attaches the effect on cameras
  49753. * @param cameras The camera to attach to.
  49754. * @hidden
  49755. */
  49756. _attachCameras(cameras: Camera[]): void;
  49757. /**
  49758. * Detatches the effect on cameras
  49759. * @param cameras The camera to detatch from.
  49760. * @hidden
  49761. */
  49762. _detachCameras(cameras: Camera): void;
  49763. /**
  49764. * Detatches the effect on cameras
  49765. * @param cameras The camera to detatch from.
  49766. * @hidden
  49767. */
  49768. _detachCameras(cameras: Camera[]): void;
  49769. /**
  49770. * Enables the effect on given cameras
  49771. * @param cameras The camera to enable.
  49772. * @hidden
  49773. */
  49774. _enable(cameras: Camera): void;
  49775. /**
  49776. * Enables the effect on given cameras
  49777. * @param cameras The camera to enable.
  49778. * @hidden
  49779. */
  49780. _enable(cameras: Nullable<Camera[]>): void;
  49781. /**
  49782. * Disables the effect on the given cameras
  49783. * @param cameras The camera to disable.
  49784. * @hidden
  49785. */
  49786. _disable(cameras: Camera): void;
  49787. /**
  49788. * Disables the effect on the given cameras
  49789. * @param cameras The camera to disable.
  49790. * @hidden
  49791. */
  49792. _disable(cameras: Nullable<Camera[]>): void;
  49793. /**
  49794. * Gets a list of the post processes contained in the effect.
  49795. * @param camera The camera to get the post processes on.
  49796. * @returns The list of the post processes in the effect.
  49797. */
  49798. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49799. }
  49800. }
  49801. declare module BABYLON {
  49802. /**
  49803. * PostProcessRenderPipeline
  49804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49805. */
  49806. class PostProcessRenderPipeline {
  49807. private engine;
  49808. private _renderEffects;
  49809. private _renderEffectsForIsolatedPass;
  49810. /**
  49811. * @hidden
  49812. */
  49813. protected _cameras: Camera[];
  49814. /** @hidden */
  49815. _name: string;
  49816. /**
  49817. * Initializes a PostProcessRenderPipeline
  49818. * @param engine engine to add the pipeline to
  49819. * @param name name of the pipeline
  49820. */
  49821. constructor(engine: Engine, name: string);
  49822. /**
  49823. * "PostProcessRenderPipeline"
  49824. * @returns "PostProcessRenderPipeline"
  49825. */
  49826. getClassName(): string;
  49827. /**
  49828. * If all the render effects in the pipeline are support
  49829. */
  49830. readonly isSupported: boolean;
  49831. /**
  49832. * Adds an effect to the pipeline
  49833. * @param renderEffect the effect to add
  49834. */
  49835. addEffect(renderEffect: PostProcessRenderEffect): void;
  49836. /** @hidden */
  49837. _rebuild(): void;
  49838. /** @hidden */
  49839. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49840. /** @hidden */
  49841. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49842. /** @hidden */
  49843. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49844. /** @hidden */
  49845. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49846. /** @hidden */
  49847. _attachCameras(cameras: Camera, unique: boolean): void;
  49848. /** @hidden */
  49849. _attachCameras(cameras: Camera[], unique: boolean): void;
  49850. /** @hidden */
  49851. _detachCameras(cameras: Camera): void;
  49852. /** @hidden */
  49853. _detachCameras(cameras: Nullable<Camera[]>): void;
  49854. /** @hidden */
  49855. _update(): void;
  49856. /** @hidden */
  49857. _reset(): void;
  49858. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49859. /**
  49860. * Disposes of the pipeline
  49861. */
  49862. dispose(): void;
  49863. }
  49864. }
  49865. declare module BABYLON {
  49866. /**
  49867. * PostProcessRenderPipelineManager class
  49868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49869. */
  49870. class PostProcessRenderPipelineManager {
  49871. private _renderPipelines;
  49872. /**
  49873. * Initializes a PostProcessRenderPipelineManager
  49874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49875. */
  49876. constructor();
  49877. /**
  49878. * Adds a pipeline to the manager
  49879. * @param renderPipeline The pipeline to add
  49880. */
  49881. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49882. /**
  49883. * Attaches a camera to the pipeline
  49884. * @param renderPipelineName The name of the pipeline to attach to
  49885. * @param cameras the camera to attach
  49886. * @param unique if the camera can be attached multiple times to the pipeline
  49887. */
  49888. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49889. /**
  49890. * Detaches a camera from the pipeline
  49891. * @param renderPipelineName The name of the pipeline to detach from
  49892. * @param cameras the camera to detach
  49893. */
  49894. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49895. /**
  49896. * Enables an effect by name on a pipeline
  49897. * @param renderPipelineName the name of the pipeline to enable the effect in
  49898. * @param renderEffectName the name of the effect to enable
  49899. * @param cameras the cameras that the effect should be enabled on
  49900. */
  49901. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49902. /**
  49903. * Disables an effect by name on a pipeline
  49904. * @param renderPipelineName the name of the pipeline to disable the effect in
  49905. * @param renderEffectName the name of the effect to disable
  49906. * @param cameras the cameras that the effect should be disabled on
  49907. */
  49908. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49909. /**
  49910. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49911. */
  49912. update(): void;
  49913. /** @hidden */
  49914. _rebuild(): void;
  49915. /**
  49916. * Disposes of the manager and pipelines
  49917. */
  49918. dispose(): void;
  49919. }
  49920. }
  49921. declare module BABYLON {
  49922. interface Scene {
  49923. /** @hidden (Backing field) */
  49924. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49925. /**
  49926. * Gets the postprocess render pipeline manager
  49927. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49928. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49929. */
  49930. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49931. }
  49932. /**
  49933. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49934. */
  49935. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49936. /**
  49937. * The component name helpfull to identify the component in the list of scene components.
  49938. */
  49939. readonly name: string;
  49940. /**
  49941. * The scene the component belongs to.
  49942. */
  49943. scene: Scene;
  49944. /**
  49945. * Creates a new instance of the component for the given scene
  49946. * @param scene Defines the scene to register the component in
  49947. */
  49948. constructor(scene: Scene);
  49949. /**
  49950. * Registers the component in a given scene
  49951. */
  49952. register(): void;
  49953. /**
  49954. * Rebuilds the elements related to this component in case of
  49955. * context lost for instance.
  49956. */
  49957. rebuild(): void;
  49958. /**
  49959. * Disposes the component and the associated ressources
  49960. */
  49961. dispose(): void;
  49962. private _gatherRenderTargets;
  49963. }
  49964. }
  49965. declare module BABYLON {
  49966. /**
  49967. * Helper class dealing with the extraction of spherical polynomial dataArray
  49968. * from a cube map.
  49969. */
  49970. class CubeMapToSphericalPolynomialTools {
  49971. private static FileFaces;
  49972. /**
  49973. * Converts a texture to the according Spherical Polynomial data.
  49974. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49975. *
  49976. * @param texture The texture to extract the information from.
  49977. * @return The Spherical Polynomial data.
  49978. */
  49979. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49980. /**
  49981. * Converts a cubemap to the according Spherical Polynomial data.
  49982. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49983. *
  49984. * @param cubeInfo The Cube map to extract the information from.
  49985. * @return The Spherical Polynomial data.
  49986. */
  49987. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49988. }
  49989. }
  49990. declare module BABYLON {
  49991. /**
  49992. * Header information of HDR texture files.
  49993. */
  49994. interface HDRInfo {
  49995. /**
  49996. * The height of the texture in pixels.
  49997. */
  49998. height: number;
  49999. /**
  50000. * The width of the texture in pixels.
  50001. */
  50002. width: number;
  50003. /**
  50004. * The index of the beginning of the data in the binary file.
  50005. */
  50006. dataPosition: number;
  50007. }
  50008. /**
  50009. * This groups tools to convert HDR texture to native colors array.
  50010. */
  50011. class HDRTools {
  50012. private static Ldexp;
  50013. private static Rgbe2float;
  50014. private static readStringLine;
  50015. /**
  50016. * Reads header information from an RGBE texture stored in a native array.
  50017. * More information on this format are available here:
  50018. * https://en.wikipedia.org/wiki/RGBE_image_format
  50019. *
  50020. * @param uint8array The binary file stored in native array.
  50021. * @return The header information.
  50022. */
  50023. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50024. /**
  50025. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50026. * This RGBE texture needs to store the information as a panorama.
  50027. *
  50028. * More information on this format are available here:
  50029. * https://en.wikipedia.org/wiki/RGBE_image_format
  50030. *
  50031. * @param buffer The binary file stored in an array buffer.
  50032. * @param size The expected size of the extracted cubemap.
  50033. * @return The Cube Map information.
  50034. */
  50035. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50036. /**
  50037. * Returns the pixels data extracted from an RGBE texture.
  50038. * This pixels will be stored left to right up to down in the R G B order in one array.
  50039. *
  50040. * More information on this format are available here:
  50041. * https://en.wikipedia.org/wiki/RGBE_image_format
  50042. *
  50043. * @param uint8array The binary file stored in an array buffer.
  50044. * @param hdrInfo The header information of the file.
  50045. * @return The pixels data in RGB right to left up to down order.
  50046. */
  50047. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50048. private static RGBE_ReadPixels_RLE;
  50049. }
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50054. */
  50055. interface CubeMapInfo {
  50056. /**
  50057. * The pixel array for the front face.
  50058. * This is stored in format, left to right, up to down format.
  50059. */
  50060. front: Nullable<ArrayBufferView>;
  50061. /**
  50062. * The pixel array for the back face.
  50063. * This is stored in format, left to right, up to down format.
  50064. */
  50065. back: Nullable<ArrayBufferView>;
  50066. /**
  50067. * The pixel array for the left face.
  50068. * This is stored in format, left to right, up to down format.
  50069. */
  50070. left: Nullable<ArrayBufferView>;
  50071. /**
  50072. * The pixel array for the right face.
  50073. * This is stored in format, left to right, up to down format.
  50074. */
  50075. right: Nullable<ArrayBufferView>;
  50076. /**
  50077. * The pixel array for the up face.
  50078. * This is stored in format, left to right, up to down format.
  50079. */
  50080. up: Nullable<ArrayBufferView>;
  50081. /**
  50082. * The pixel array for the down face.
  50083. * This is stored in format, left to right, up to down format.
  50084. */
  50085. down: Nullable<ArrayBufferView>;
  50086. /**
  50087. * The size of the cubemap stored.
  50088. *
  50089. * Each faces will be size * size pixels.
  50090. */
  50091. size: number;
  50092. /**
  50093. * The format of the texture.
  50094. *
  50095. * RGBA, RGB.
  50096. */
  50097. format: number;
  50098. /**
  50099. * The type of the texture data.
  50100. *
  50101. * UNSIGNED_INT, FLOAT.
  50102. */
  50103. type: number;
  50104. /**
  50105. * Specifies whether the texture is in gamma space.
  50106. */
  50107. gammaSpace: boolean;
  50108. }
  50109. /**
  50110. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50111. */
  50112. class PanoramaToCubeMapTools {
  50113. private static FACE_FRONT;
  50114. private static FACE_BACK;
  50115. private static FACE_RIGHT;
  50116. private static FACE_LEFT;
  50117. private static FACE_DOWN;
  50118. private static FACE_UP;
  50119. /**
  50120. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50121. *
  50122. * @param float32Array The source data.
  50123. * @param inputWidth The width of the input panorama.
  50124. * @param inputHeight The height of the input panorama.
  50125. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50126. * @return The cubemap data
  50127. */
  50128. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50129. private static CreateCubemapTexture;
  50130. private static CalcProjectionSpherical;
  50131. }
  50132. }
  50133. declare module BABYLON {
  50134. }
  50135. declare module BABYLON {
  50136. }
  50137. declare module BABYLON {
  50138. }
  50139. declare module BABYLON {
  50140. }
  50141. declare module BABYLON {
  50142. /**
  50143. * 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.
  50144. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50145. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50146. */
  50147. class CustomProceduralTexture extends ProceduralTexture {
  50148. private _animate;
  50149. private _time;
  50150. private _config;
  50151. private _texturePath;
  50152. /**
  50153. * Instantiates a new Custom Procedural Texture.
  50154. * 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.
  50155. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50156. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50157. * @param name Define the name of the texture
  50158. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50159. * @param size Define the size of the texture to create
  50160. * @param scene Define the scene the texture belongs to
  50161. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50162. * @param generateMipMaps Define if the texture should creates mip maps or not
  50163. */
  50164. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50165. private _loadJson;
  50166. /**
  50167. * Is the texture ready to be used ? (rendered at least once)
  50168. * @returns true if ready, otherwise, false.
  50169. */
  50170. isReady(): boolean;
  50171. /**
  50172. * Render the texture to its associated render target.
  50173. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50174. */
  50175. render(useCameraPostProcess?: boolean): void;
  50176. /**
  50177. * Update the list of dependant textures samplers in the shader.
  50178. */
  50179. updateTextures(): void;
  50180. /**
  50181. * Update the uniform values of the procedural texture in the shader.
  50182. */
  50183. updateShaderUniforms(): void;
  50184. /**
  50185. * Define if the texture animates or not.
  50186. */
  50187. animate: boolean;
  50188. }
  50189. }
  50190. declare module BABYLON {
  50191. /**
  50192. * Class used to generate noise procedural textures
  50193. */
  50194. class NoiseProceduralTexture extends ProceduralTexture {
  50195. private _time;
  50196. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50197. brightness: number;
  50198. /** Defines the number of octaves to process */
  50199. octaves: number;
  50200. /** Defines the level of persistence (0.8 by default) */
  50201. persistence: number;
  50202. /** Gets or sets animation speed factor (default is 1) */
  50203. animationSpeedFactor: number;
  50204. /**
  50205. * Creates a new NoiseProceduralTexture
  50206. * @param name defines the name fo the texture
  50207. * @param size defines the size of the texture (default is 256)
  50208. * @param scene defines the hosting scene
  50209. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50210. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50211. */
  50212. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50213. private _updateShaderUniforms;
  50214. protected _getDefines(): string;
  50215. /** Generate the current state of the procedural texture */
  50216. render(useCameraPostProcess?: boolean): void;
  50217. /**
  50218. * Serializes this noise procedural texture
  50219. * @returns a serialized noise procedural texture object
  50220. */
  50221. serialize(): any;
  50222. /**
  50223. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50224. * @param parsedTexture defines parsed texture data
  50225. * @param scene defines the current scene
  50226. * @param rootUrl defines the root URL containing noise procedural texture information
  50227. * @returns a parsed NoiseProceduralTexture
  50228. */
  50229. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50230. }
  50231. }
  50232. declare module BABYLON {
  50233. /**
  50234. * 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.
  50235. * This is the base class of any Procedural texture and contains most of the shareable code.
  50236. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50237. */
  50238. class ProceduralTexture extends Texture {
  50239. isCube: boolean;
  50240. /**
  50241. * Define if the texture is enabled or not (disabled texture will not render)
  50242. */
  50243. isEnabled: boolean;
  50244. /**
  50245. * Define if the texture must be cleared before rendering (default is true)
  50246. */
  50247. autoClear: boolean;
  50248. /**
  50249. * Callback called when the texture is generated
  50250. */
  50251. onGenerated: () => void;
  50252. /**
  50253. * Event raised when the texture is generated
  50254. */
  50255. onGeneratedObservable: Observable<ProceduralTexture>;
  50256. /** @hidden */
  50257. _generateMipMaps: boolean;
  50258. /** @hidden **/
  50259. _effect: Effect;
  50260. /** @hidden */
  50261. _textures: {
  50262. [key: string]: Texture;
  50263. };
  50264. private _size;
  50265. private _currentRefreshId;
  50266. private _refreshRate;
  50267. private _vertexBuffers;
  50268. private _indexBuffer;
  50269. private _uniforms;
  50270. private _samplers;
  50271. private _fragment;
  50272. private _floats;
  50273. private _ints;
  50274. private _floatsArrays;
  50275. private _colors3;
  50276. private _colors4;
  50277. private _vectors2;
  50278. private _vectors3;
  50279. private _matrices;
  50280. private _fallbackTexture;
  50281. private _fallbackTextureUsed;
  50282. private _engine;
  50283. private _cachedDefines;
  50284. private _contentUpdateId;
  50285. private _contentData;
  50286. /**
  50287. * Instantiates a new procedural texture.
  50288. * 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.
  50289. * This is the base class of any Procedural texture and contains most of the shareable code.
  50290. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50291. * @param name Define the name of the texture
  50292. * @param size Define the size of the texture to create
  50293. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50294. * @param scene Define the scene the texture belongs to
  50295. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50296. * @param generateMipMaps Define if the texture should creates mip maps or not
  50297. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50298. */
  50299. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50300. /**
  50301. * The effect that is created when initializing the post process.
  50302. * @returns The created effect corrisponding the the postprocess.
  50303. */
  50304. getEffect(): Effect;
  50305. /**
  50306. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50307. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50308. */
  50309. getContent(): Nullable<ArrayBufferView>;
  50310. private _createIndexBuffer;
  50311. /** @hidden */
  50312. _rebuild(): void;
  50313. /**
  50314. * Resets the texture in order to recreate its associated resources.
  50315. * This can be called in case of context loss
  50316. */
  50317. reset(): void;
  50318. protected _getDefines(): string;
  50319. /**
  50320. * Is the texture ready to be used ? (rendered at least once)
  50321. * @returns true if ready, otherwise, false.
  50322. */
  50323. isReady(): boolean;
  50324. /**
  50325. * Resets the refresh counter of the texture and start bak from scratch.
  50326. * Could be useful to regenerate the texture if it is setup to render only once.
  50327. */
  50328. resetRefreshCounter(): void;
  50329. /**
  50330. * Set the fragment shader to use in order to render the texture.
  50331. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50332. */
  50333. setFragment(fragment: any): void;
  50334. /**
  50335. * Define the refresh rate of the texture or the rendering frequency.
  50336. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50337. */
  50338. refreshRate: number;
  50339. /** @hidden */
  50340. _shouldRender(): boolean;
  50341. /**
  50342. * Get the size the texture is rendering at.
  50343. * @returns the size (texture is always squared)
  50344. */
  50345. getRenderSize(): number;
  50346. /**
  50347. * Resize the texture to new value.
  50348. * @param size Define the new size the texture should have
  50349. * @param generateMipMaps Define whether the new texture should create mip maps
  50350. */
  50351. resize(size: number, generateMipMaps: boolean): void;
  50352. private _checkUniform;
  50353. /**
  50354. * Set a texture in the shader program used to render.
  50355. * @param name Define the name of the uniform samplers as defined in the shader
  50356. * @param texture Define the texture to bind to this sampler
  50357. * @return the texture itself allowing "fluent" like uniform updates
  50358. */
  50359. setTexture(name: string, texture: Texture): ProceduralTexture;
  50360. /**
  50361. * Set a float in the shader.
  50362. * @param name Define the name of the uniform as defined in the shader
  50363. * @param value Define the value to give to the uniform
  50364. * @return the texture itself allowing "fluent" like uniform updates
  50365. */
  50366. setFloat(name: string, value: number): ProceduralTexture;
  50367. /**
  50368. * Set a int in the shader.
  50369. * @param name Define the name of the uniform as defined in the shader
  50370. * @param value Define the value to give to the uniform
  50371. * @return the texture itself allowing "fluent" like uniform updates
  50372. */
  50373. setInt(name: string, value: number): ProceduralTexture;
  50374. /**
  50375. * Set an array of floats in the shader.
  50376. * @param name Define the name of the uniform as defined in the shader
  50377. * @param value Define the value to give to the uniform
  50378. * @return the texture itself allowing "fluent" like uniform updates
  50379. */
  50380. setFloats(name: string, value: number[]): ProceduralTexture;
  50381. /**
  50382. * Set a vec3 in the shader from a Color3.
  50383. * @param name Define the name of the uniform as defined in the shader
  50384. * @param value Define the value to give to the uniform
  50385. * @return the texture itself allowing "fluent" like uniform updates
  50386. */
  50387. setColor3(name: string, value: Color3): ProceduralTexture;
  50388. /**
  50389. * Set a vec4 in the shader from a Color4.
  50390. * @param name Define the name of the uniform as defined in the shader
  50391. * @param value Define the value to give to the uniform
  50392. * @return the texture itself allowing "fluent" like uniform updates
  50393. */
  50394. setColor4(name: string, value: Color4): ProceduralTexture;
  50395. /**
  50396. * Set a vec2 in the shader from a Vector2.
  50397. * @param name Define the name of the uniform as defined in the shader
  50398. * @param value Define the value to give to the uniform
  50399. * @return the texture itself allowing "fluent" like uniform updates
  50400. */
  50401. setVector2(name: string, value: Vector2): ProceduralTexture;
  50402. /**
  50403. * Set a vec3 in the shader from a Vector3.
  50404. * @param name Define the name of the uniform as defined in the shader
  50405. * @param value Define the value to give to the uniform
  50406. * @return the texture itself allowing "fluent" like uniform updates
  50407. */
  50408. setVector3(name: string, value: Vector3): ProceduralTexture;
  50409. /**
  50410. * Set a mat4 in the shader from a MAtrix.
  50411. * @param name Define the name of the uniform as defined in the shader
  50412. * @param value Define the value to give to the uniform
  50413. * @return the texture itself allowing "fluent" like uniform updates
  50414. */
  50415. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50416. /**
  50417. * Render the texture to its associated render target.
  50418. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50419. */
  50420. render(useCameraPostProcess?: boolean): void;
  50421. /**
  50422. * Clone the texture.
  50423. * @returns the cloned texture
  50424. */
  50425. clone(): ProceduralTexture;
  50426. /**
  50427. * Dispose the texture and release its asoociated resources.
  50428. */
  50429. dispose(): void;
  50430. }
  50431. }
  50432. declare module BABYLON {
  50433. interface AbstractScene {
  50434. /**
  50435. * The list of procedural textures added to the scene
  50436. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50437. */
  50438. proceduralTextures: Array<ProceduralTexture>;
  50439. }
  50440. /**
  50441. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50442. * in a given scene.
  50443. */
  50444. class ProceduralTextureSceneComponent implements ISceneComponent {
  50445. /**
  50446. * The component name helpfull to identify the component in the list of scene components.
  50447. */
  50448. readonly name: string;
  50449. /**
  50450. * The scene the component belongs to.
  50451. */
  50452. scene: Scene;
  50453. /**
  50454. * Creates a new instance of the component for the given scene
  50455. * @param scene Defines the scene to register the component in
  50456. */
  50457. constructor(scene: Scene);
  50458. /**
  50459. * Registers the component in a given scene
  50460. */
  50461. register(): void;
  50462. /**
  50463. * Rebuilds the elements related to this component in case of
  50464. * context lost for instance.
  50465. */
  50466. rebuild(): void;
  50467. /**
  50468. * Disposes the component and the associated ressources.
  50469. */
  50470. dispose(): void;
  50471. private _beforeClear;
  50472. }
  50473. }
  50474. declare module BABYLON {
  50475. /**
  50476. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50477. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50478. */
  50479. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50480. private _scene;
  50481. private _camerasToBeAttached;
  50482. /**
  50483. * ID of the sharpen post process,
  50484. */
  50485. private readonly SharpenPostProcessId;
  50486. /**
  50487. * @ignore
  50488. * ID of the image processing post process;
  50489. */
  50490. readonly ImageProcessingPostProcessId: string;
  50491. /**
  50492. * @ignore
  50493. * ID of the Fast Approximate Anti-Aliasing post process;
  50494. */
  50495. readonly FxaaPostProcessId: string;
  50496. /**
  50497. * ID of the chromatic aberration post process,
  50498. */
  50499. private readonly ChromaticAberrationPostProcessId;
  50500. /**
  50501. * ID of the grain post process
  50502. */
  50503. private readonly GrainPostProcessId;
  50504. /**
  50505. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50506. */
  50507. sharpen: SharpenPostProcess;
  50508. private _sharpenEffect;
  50509. private bloom;
  50510. /**
  50511. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50512. */
  50513. depthOfField: DepthOfFieldEffect;
  50514. /**
  50515. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50516. */
  50517. fxaa: FxaaPostProcess;
  50518. /**
  50519. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50520. */
  50521. imageProcessing: ImageProcessingPostProcess;
  50522. /**
  50523. * Chromatic aberration post process which will shift rgb colors in the image
  50524. */
  50525. chromaticAberration: ChromaticAberrationPostProcess;
  50526. private _chromaticAberrationEffect;
  50527. /**
  50528. * Grain post process which add noise to the image
  50529. */
  50530. grain: GrainPostProcess;
  50531. private _grainEffect;
  50532. /**
  50533. * Glow post process which adds a glow to emmisive areas of the image
  50534. */
  50535. private _glowLayer;
  50536. /**
  50537. * Animations which can be used to tweak settings over a period of time
  50538. */
  50539. animations: Animation[];
  50540. private _imageProcessingConfigurationObserver;
  50541. private _sharpenEnabled;
  50542. private _bloomEnabled;
  50543. private _depthOfFieldEnabled;
  50544. private _depthOfFieldBlurLevel;
  50545. private _fxaaEnabled;
  50546. private _imageProcessingEnabled;
  50547. private _defaultPipelineTextureType;
  50548. private _bloomScale;
  50549. private _chromaticAberrationEnabled;
  50550. private _grainEnabled;
  50551. private _buildAllowed;
  50552. /**
  50553. * Enable or disable the sharpen process from the pipeline
  50554. */
  50555. sharpenEnabled: boolean;
  50556. private _resizeObserver;
  50557. private _hardwareScaleLevel;
  50558. private _bloomKernel;
  50559. /**
  50560. * Specifies the size of the bloom blur kernel, relative to the final output size
  50561. */
  50562. bloomKernel: number;
  50563. /**
  50564. * Specifies the weight of the bloom in the final rendering
  50565. */
  50566. private _bloomWeight;
  50567. /**
  50568. * Specifies the luma threshold for the area that will be blurred by the bloom
  50569. */
  50570. private _bloomThreshold;
  50571. private _hdr;
  50572. /**
  50573. * The strength of the bloom.
  50574. */
  50575. bloomWeight: number;
  50576. /**
  50577. * The strength of the bloom.
  50578. */
  50579. bloomThreshold: number;
  50580. /**
  50581. * The scale of the bloom, lower value will provide better performance.
  50582. */
  50583. bloomScale: number;
  50584. /**
  50585. * Enable or disable the bloom from the pipeline
  50586. */
  50587. bloomEnabled: boolean;
  50588. private _rebuildBloom;
  50589. /**
  50590. * If the depth of field is enabled.
  50591. */
  50592. depthOfFieldEnabled: boolean;
  50593. /**
  50594. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50595. */
  50596. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50597. /**
  50598. * If the anti aliasing is enabled.
  50599. */
  50600. fxaaEnabled: boolean;
  50601. private _samples;
  50602. /**
  50603. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50604. */
  50605. samples: number;
  50606. /**
  50607. * If image processing is enabled.
  50608. */
  50609. imageProcessingEnabled: boolean;
  50610. /**
  50611. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50612. */
  50613. glowLayerEnabled: boolean;
  50614. /**
  50615. * Enable or disable the chromaticAberration process from the pipeline
  50616. */
  50617. chromaticAberrationEnabled: boolean;
  50618. /**
  50619. * Enable or disable the grain process from the pipeline
  50620. */
  50621. grainEnabled: boolean;
  50622. /**
  50623. * @constructor
  50624. * @param name - The rendering pipeline name (default: "")
  50625. * @param hdr - If high dynamic range textures should be used (default: true)
  50626. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50627. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50628. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50629. */
  50630. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50631. /**
  50632. * Force the compilation of the entire pipeline.
  50633. */
  50634. prepare(): void;
  50635. private _hasCleared;
  50636. private _prevPostProcess;
  50637. private _prevPrevPostProcess;
  50638. private _setAutoClearAndTextureSharing;
  50639. private _depthOfFieldSceneObserver;
  50640. private _buildPipeline;
  50641. private _disposePostProcesses;
  50642. /**
  50643. * Adds a camera to the pipeline
  50644. * @param camera the camera to be added
  50645. */
  50646. addCamera(camera: Camera): void;
  50647. /**
  50648. * Removes a camera from the pipeline
  50649. * @param camera the camera to remove
  50650. */
  50651. removeCamera(camera: Camera): void;
  50652. /**
  50653. * Dispose of the pipeline and stop all post processes
  50654. */
  50655. dispose(): void;
  50656. /**
  50657. * Serialize the rendering pipeline (Used when exporting)
  50658. * @returns the serialized object
  50659. */
  50660. serialize(): any;
  50661. /**
  50662. * Parse the serialized pipeline
  50663. * @param source Source pipeline.
  50664. * @param scene The scene to load the pipeline to.
  50665. * @param rootUrl The URL of the serialized pipeline.
  50666. * @returns An instantiated pipeline from the serialized object.
  50667. */
  50668. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50669. }
  50670. }
  50671. declare module BABYLON {
  50672. /**
  50673. * BABYLON.JS Chromatic Aberration GLSL Shader
  50674. * Author: Olivier Guyot
  50675. * Separates very slightly R, G and B colors on the edges of the screen
  50676. * Inspired by Francois Tarlier & Martins Upitis
  50677. */
  50678. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50679. /**
  50680. * @ignore
  50681. * The chromatic aberration PostProcess id in the pipeline
  50682. */
  50683. LensChromaticAberrationEffect: string;
  50684. /**
  50685. * @ignore
  50686. * The highlights enhancing PostProcess id in the pipeline
  50687. */
  50688. HighlightsEnhancingEffect: string;
  50689. /**
  50690. * @ignore
  50691. * The depth-of-field PostProcess id in the pipeline
  50692. */
  50693. LensDepthOfFieldEffect: string;
  50694. private _scene;
  50695. private _depthTexture;
  50696. private _grainTexture;
  50697. private _chromaticAberrationPostProcess;
  50698. private _highlightsPostProcess;
  50699. private _depthOfFieldPostProcess;
  50700. private _edgeBlur;
  50701. private _grainAmount;
  50702. private _chromaticAberration;
  50703. private _distortion;
  50704. private _highlightsGain;
  50705. private _highlightsThreshold;
  50706. private _dofDistance;
  50707. private _dofAperture;
  50708. private _dofDarken;
  50709. private _dofPentagon;
  50710. private _blurNoise;
  50711. /**
  50712. * @constructor
  50713. *
  50714. * Effect parameters are as follow:
  50715. * {
  50716. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50717. * edge_blur: number; // from 0 to x (1 for realism)
  50718. * distortion: number; // from 0 to x (1 for realism)
  50719. * grain_amount: number; // from 0 to 1
  50720. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50721. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50722. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50723. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50724. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50725. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50726. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50727. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50728. * }
  50729. * Note: if an effect parameter is unset, effect is disabled
  50730. *
  50731. * @param name The rendering pipeline name
  50732. * @param parameters - An object containing all parameters (see above)
  50733. * @param scene The scene linked to this pipeline
  50734. * @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)
  50735. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50736. */
  50737. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50738. /**
  50739. * Sets the amount of blur at the edges
  50740. * @param amount blur amount
  50741. */
  50742. setEdgeBlur(amount: number): void;
  50743. /**
  50744. * Sets edge blur to 0
  50745. */
  50746. disableEdgeBlur(): void;
  50747. /**
  50748. * Sets the amout of grain
  50749. * @param amount Amount of grain
  50750. */
  50751. setGrainAmount(amount: number): void;
  50752. /**
  50753. * Set grain amount to 0
  50754. */
  50755. disableGrain(): void;
  50756. /**
  50757. * Sets the chromatic aberration amount
  50758. * @param amount amount of chromatic aberration
  50759. */
  50760. setChromaticAberration(amount: number): void;
  50761. /**
  50762. * Sets chromatic aberration amount to 0
  50763. */
  50764. disableChromaticAberration(): void;
  50765. /**
  50766. * Sets the EdgeDistortion amount
  50767. * @param amount amount of EdgeDistortion
  50768. */
  50769. setEdgeDistortion(amount: number): void;
  50770. /**
  50771. * Sets edge distortion to 0
  50772. */
  50773. disableEdgeDistortion(): void;
  50774. /**
  50775. * Sets the FocusDistance amount
  50776. * @param amount amount of FocusDistance
  50777. */
  50778. setFocusDistance(amount: number): void;
  50779. /**
  50780. * Disables depth of field
  50781. */
  50782. disableDepthOfField(): void;
  50783. /**
  50784. * Sets the Aperture amount
  50785. * @param amount amount of Aperture
  50786. */
  50787. setAperture(amount: number): void;
  50788. /**
  50789. * Sets the DarkenOutOfFocus amount
  50790. * @param amount amount of DarkenOutOfFocus
  50791. */
  50792. setDarkenOutOfFocus(amount: number): void;
  50793. /**
  50794. * Creates a pentagon bokeh effect
  50795. */
  50796. enablePentagonBokeh(): void;
  50797. /**
  50798. * Disables the pentagon bokeh effect
  50799. */
  50800. disablePentagonBokeh(): void;
  50801. /**
  50802. * Enables noise blur
  50803. */
  50804. enableNoiseBlur(): void;
  50805. /**
  50806. * Disables noise blur
  50807. */
  50808. disableNoiseBlur(): void;
  50809. /**
  50810. * Sets the HighlightsGain amount
  50811. * @param amount amount of HighlightsGain
  50812. */
  50813. setHighlightsGain(amount: number): void;
  50814. /**
  50815. * Sets the HighlightsThreshold amount
  50816. * @param amount amount of HighlightsThreshold
  50817. */
  50818. setHighlightsThreshold(amount: number): void;
  50819. /**
  50820. * Disables highlights
  50821. */
  50822. disableHighlights(): void;
  50823. /**
  50824. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50825. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50826. */
  50827. dispose(disableDepthRender?: boolean): void;
  50828. private _createChromaticAberrationPostProcess;
  50829. private _createHighlightsPostProcess;
  50830. private _createDepthOfFieldPostProcess;
  50831. private _createGrainTexture;
  50832. }
  50833. }
  50834. declare module BABYLON {
  50835. /**
  50836. * Render pipeline to produce ssao effect
  50837. */
  50838. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50839. /**
  50840. * @ignore
  50841. * The PassPostProcess id in the pipeline that contains the original scene color
  50842. */
  50843. SSAOOriginalSceneColorEffect: string;
  50844. /**
  50845. * @ignore
  50846. * The SSAO PostProcess id in the pipeline
  50847. */
  50848. SSAORenderEffect: string;
  50849. /**
  50850. * @ignore
  50851. * The horizontal blur PostProcess id in the pipeline
  50852. */
  50853. SSAOBlurHRenderEffect: string;
  50854. /**
  50855. * @ignore
  50856. * The vertical blur PostProcess id in the pipeline
  50857. */
  50858. SSAOBlurVRenderEffect: string;
  50859. /**
  50860. * @ignore
  50861. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50862. */
  50863. SSAOCombineRenderEffect: string;
  50864. /**
  50865. * The output strength of the SSAO post-process. Default value is 1.0.
  50866. */
  50867. totalStrength: number;
  50868. /**
  50869. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50870. */
  50871. maxZ: number;
  50872. /**
  50873. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50874. */
  50875. minZAspect: number;
  50876. private _samples;
  50877. /**
  50878. * Number of samples used for the SSAO calculations. Default value is 8
  50879. */
  50880. samples: number;
  50881. private _textureSamples;
  50882. /**
  50883. * Number of samples to use for antialiasing
  50884. */
  50885. textureSamples: number;
  50886. /**
  50887. * Ratio object used for SSAO ratio and blur ratio
  50888. */
  50889. private _ratio;
  50890. /**
  50891. * Dynamically generated sphere sampler.
  50892. */
  50893. private _sampleSphere;
  50894. /**
  50895. * Blur filter offsets
  50896. */
  50897. private _samplerOffsets;
  50898. private _expensiveBlur;
  50899. /**
  50900. * If bilateral blur should be used
  50901. */
  50902. expensiveBlur: boolean;
  50903. /**
  50904. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50905. */
  50906. radius: number;
  50907. /**
  50908. * The base color of the SSAO post-process
  50909. * The final result is "base + ssao" between [0, 1]
  50910. */
  50911. base: number;
  50912. /**
  50913. * Support test.
  50914. */
  50915. static readonly IsSupported: boolean;
  50916. private _scene;
  50917. private _depthTexture;
  50918. private _normalTexture;
  50919. private _randomTexture;
  50920. private _originalColorPostProcess;
  50921. private _ssaoPostProcess;
  50922. private _blurHPostProcess;
  50923. private _blurVPostProcess;
  50924. private _ssaoCombinePostProcess;
  50925. private _firstUpdate;
  50926. /**
  50927. * @constructor
  50928. * @param name The rendering pipeline name
  50929. * @param scene The scene linked to this pipeline
  50930. * @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 }
  50931. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50932. */
  50933. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50934. /**
  50935. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50936. */
  50937. dispose(disableGeometryBufferRenderer?: boolean): void;
  50938. private _createBlurPostProcess;
  50939. /** @hidden */
  50940. _rebuild(): void;
  50941. private _bits;
  50942. private _radicalInverse_VdC;
  50943. private _hammersley;
  50944. private _hemisphereSample_uniform;
  50945. private _generateHemisphere;
  50946. private _createSSAOPostProcess;
  50947. private _createSSAOCombinePostProcess;
  50948. private _createRandomTexture;
  50949. /**
  50950. * Serialize the rendering pipeline (Used when exporting)
  50951. * @returns the serialized object
  50952. */
  50953. serialize(): any;
  50954. /**
  50955. * Parse the serialized pipeline
  50956. * @param source Source pipeline.
  50957. * @param scene The scene to load the pipeline to.
  50958. * @param rootUrl The URL of the serialized pipeline.
  50959. * @returns An instantiated pipeline from the serialized object.
  50960. */
  50961. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * Render pipeline to produce ssao effect
  50967. */
  50968. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50969. /**
  50970. * @ignore
  50971. * The PassPostProcess id in the pipeline that contains the original scene color
  50972. */
  50973. SSAOOriginalSceneColorEffect: string;
  50974. /**
  50975. * @ignore
  50976. * The SSAO PostProcess id in the pipeline
  50977. */
  50978. SSAORenderEffect: string;
  50979. /**
  50980. * @ignore
  50981. * The horizontal blur PostProcess id in the pipeline
  50982. */
  50983. SSAOBlurHRenderEffect: string;
  50984. /**
  50985. * @ignore
  50986. * The vertical blur PostProcess id in the pipeline
  50987. */
  50988. SSAOBlurVRenderEffect: string;
  50989. /**
  50990. * @ignore
  50991. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50992. */
  50993. SSAOCombineRenderEffect: string;
  50994. /**
  50995. * The output strength of the SSAO post-process. Default value is 1.0.
  50996. */
  50997. totalStrength: number;
  50998. /**
  50999. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  51000. */
  51001. radius: number;
  51002. /**
  51003. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  51004. * Must not be equal to fallOff and superior to fallOff.
  51005. * Default value is 0.975
  51006. */
  51007. area: number;
  51008. /**
  51009. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  51010. * Must not be equal to area and inferior to area.
  51011. * Default value is 0.0
  51012. */
  51013. fallOff: number;
  51014. /**
  51015. * The base color of the SSAO post-process
  51016. * The final result is "base + ssao" between [0, 1]
  51017. */
  51018. base: number;
  51019. private _scene;
  51020. private _depthTexture;
  51021. private _randomTexture;
  51022. private _originalColorPostProcess;
  51023. private _ssaoPostProcess;
  51024. private _blurHPostProcess;
  51025. private _blurVPostProcess;
  51026. private _ssaoCombinePostProcess;
  51027. private _firstUpdate;
  51028. /**
  51029. * @constructor
  51030. * @param name - The rendering pipeline name
  51031. * @param scene - The scene linked to this pipeline
  51032. * @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 }
  51033. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  51034. */
  51035. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51036. /**
  51037. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51038. */
  51039. dispose(disableDepthRender?: boolean): void;
  51040. private _createBlurPostProcess;
  51041. /** @hidden */
  51042. _rebuild(): void;
  51043. private _createSSAOPostProcess;
  51044. private _createSSAOCombinePostProcess;
  51045. private _createRandomTexture;
  51046. }
  51047. }
  51048. declare module BABYLON {
  51049. /**
  51050. * Standard rendering pipeline
  51051. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51052. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51053. */
  51054. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51055. /**
  51056. * Public members
  51057. */
  51058. /**
  51059. * Post-process which contains the original scene color before the pipeline applies all the effects
  51060. */
  51061. originalPostProcess: Nullable<PostProcess>;
  51062. /**
  51063. * Post-process used to down scale an image x4
  51064. */
  51065. downSampleX4PostProcess: Nullable<PostProcess>;
  51066. /**
  51067. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51068. */
  51069. brightPassPostProcess: Nullable<PostProcess>;
  51070. /**
  51071. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51072. */
  51073. blurHPostProcesses: PostProcess[];
  51074. /**
  51075. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51076. */
  51077. blurVPostProcesses: PostProcess[];
  51078. /**
  51079. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51080. */
  51081. textureAdderPostProcess: Nullable<PostProcess>;
  51082. /**
  51083. * Post-process used to create volumetric lighting effect
  51084. */
  51085. volumetricLightPostProcess: Nullable<PostProcess>;
  51086. /**
  51087. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51088. */
  51089. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51090. /**
  51091. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51092. */
  51093. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51094. /**
  51095. * Post-process used to merge the volumetric light effect and the real scene color
  51096. */
  51097. volumetricLightMergePostProces: Nullable<PostProcess>;
  51098. /**
  51099. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51100. */
  51101. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51102. /**
  51103. * Base post-process used to calculate the average luminance of the final image for HDR
  51104. */
  51105. luminancePostProcess: Nullable<PostProcess>;
  51106. /**
  51107. * Post-processes used to create down sample post-processes in order to get
  51108. * the average luminance of the final image for HDR
  51109. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51110. */
  51111. luminanceDownSamplePostProcesses: PostProcess[];
  51112. /**
  51113. * Post-process used to create a HDR effect (light adaptation)
  51114. */
  51115. hdrPostProcess: Nullable<PostProcess>;
  51116. /**
  51117. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51118. */
  51119. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51120. /**
  51121. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51122. */
  51123. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51124. /**
  51125. * Post-process used to merge the final HDR post-process and the real scene color
  51126. */
  51127. hdrFinalPostProcess: Nullable<PostProcess>;
  51128. /**
  51129. * Post-process used to create a lens flare effect
  51130. */
  51131. lensFlarePostProcess: Nullable<PostProcess>;
  51132. /**
  51133. * Post-process that merges the result of the lens flare post-process and the real scene color
  51134. */
  51135. lensFlareComposePostProcess: Nullable<PostProcess>;
  51136. /**
  51137. * Post-process used to create a motion blur effect
  51138. */
  51139. motionBlurPostProcess: Nullable<PostProcess>;
  51140. /**
  51141. * Post-process used to create a depth of field effect
  51142. */
  51143. depthOfFieldPostProcess: Nullable<PostProcess>;
  51144. /**
  51145. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51146. */
  51147. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51148. /**
  51149. * Represents the brightness threshold in order to configure the illuminated surfaces
  51150. */
  51151. brightThreshold: number;
  51152. /**
  51153. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51154. */
  51155. blurWidth: number;
  51156. /**
  51157. * Sets if the blur for highlighted surfaces must be only horizontal
  51158. */
  51159. horizontalBlur: boolean;
  51160. /**
  51161. * Sets the overall exposure used by the pipeline
  51162. */
  51163. exposure: number;
  51164. /**
  51165. * Texture used typically to simulate "dirty" on camera lens
  51166. */
  51167. lensTexture: Nullable<Texture>;
  51168. /**
  51169. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51170. */
  51171. volumetricLightCoefficient: number;
  51172. /**
  51173. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51174. */
  51175. volumetricLightPower: number;
  51176. /**
  51177. * Used the set the blur intensity to smooth the volumetric lights
  51178. */
  51179. volumetricLightBlurScale: number;
  51180. /**
  51181. * Light (spot or directional) used to generate the volumetric lights rays
  51182. * The source light must have a shadow generate so the pipeline can get its
  51183. * depth map
  51184. */
  51185. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51186. /**
  51187. * For eye adaptation, represents the minimum luminance the eye can see
  51188. */
  51189. hdrMinimumLuminance: number;
  51190. /**
  51191. * For eye adaptation, represents the decrease luminance speed
  51192. */
  51193. hdrDecreaseRate: number;
  51194. /**
  51195. * For eye adaptation, represents the increase luminance speed
  51196. */
  51197. hdrIncreaseRate: number;
  51198. /**
  51199. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51200. */
  51201. lensColorTexture: Nullable<Texture>;
  51202. /**
  51203. * The overall strengh for the lens flare effect
  51204. */
  51205. lensFlareStrength: number;
  51206. /**
  51207. * Dispersion coefficient for lens flare ghosts
  51208. */
  51209. lensFlareGhostDispersal: number;
  51210. /**
  51211. * Main lens flare halo width
  51212. */
  51213. lensFlareHaloWidth: number;
  51214. /**
  51215. * Based on the lens distortion effect, defines how much the lens flare result
  51216. * is distorted
  51217. */
  51218. lensFlareDistortionStrength: number;
  51219. /**
  51220. * Lens star texture must be used to simulate rays on the flares and is available
  51221. * in the documentation
  51222. */
  51223. lensStarTexture: Nullable<Texture>;
  51224. /**
  51225. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51226. * flare effect by taking account of the dirt texture
  51227. */
  51228. lensFlareDirtTexture: Nullable<Texture>;
  51229. /**
  51230. * Represents the focal length for the depth of field effect
  51231. */
  51232. depthOfFieldDistance: number;
  51233. /**
  51234. * Represents the blur intensity for the blurred part of the depth of field effect
  51235. */
  51236. depthOfFieldBlurWidth: number;
  51237. /**
  51238. * For motion blur, defines how much the image is blurred by the movement
  51239. */
  51240. motionStrength: number;
  51241. /**
  51242. * List of animations for the pipeline (IAnimatable implementation)
  51243. */
  51244. animations: Animation[];
  51245. /**
  51246. * Private members
  51247. */
  51248. private _scene;
  51249. private _currentDepthOfFieldSource;
  51250. private _basePostProcess;
  51251. private _hdrCurrentLuminance;
  51252. private _floatTextureType;
  51253. private _ratio;
  51254. private _bloomEnabled;
  51255. private _depthOfFieldEnabled;
  51256. private _vlsEnabled;
  51257. private _lensFlareEnabled;
  51258. private _hdrEnabled;
  51259. private _motionBlurEnabled;
  51260. private _fxaaEnabled;
  51261. private _motionBlurSamples;
  51262. private _volumetricLightStepsCount;
  51263. private _samples;
  51264. /**
  51265. * @ignore
  51266. * Specifies if the bloom pipeline is enabled
  51267. */
  51268. BloomEnabled: boolean;
  51269. /**
  51270. * @ignore
  51271. * Specifies if the depth of field pipeline is enabed
  51272. */
  51273. DepthOfFieldEnabled: boolean;
  51274. /**
  51275. * @ignore
  51276. * Specifies if the lens flare pipeline is enabed
  51277. */
  51278. LensFlareEnabled: boolean;
  51279. /**
  51280. * @ignore
  51281. * Specifies if the HDR pipeline is enabled
  51282. */
  51283. HDREnabled: boolean;
  51284. /**
  51285. * @ignore
  51286. * Specifies if the volumetric lights scattering effect is enabled
  51287. */
  51288. VLSEnabled: boolean;
  51289. /**
  51290. * @ignore
  51291. * Specifies if the motion blur effect is enabled
  51292. */
  51293. MotionBlurEnabled: boolean;
  51294. /**
  51295. * Specifies if anti-aliasing is enabled
  51296. */
  51297. fxaaEnabled: boolean;
  51298. /**
  51299. * Specifies the number of steps used to calculate the volumetric lights
  51300. * Typically in interval [50, 200]
  51301. */
  51302. volumetricLightStepsCount: number;
  51303. /**
  51304. * Specifies the number of samples used for the motion blur effect
  51305. * Typically in interval [16, 64]
  51306. */
  51307. motionBlurSamples: number;
  51308. /**
  51309. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51310. */
  51311. samples: number;
  51312. /**
  51313. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51314. * @constructor
  51315. * @param name The rendering pipeline name
  51316. * @param scene The scene linked to this pipeline
  51317. * @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)
  51318. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51319. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51320. */
  51321. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51322. private _buildPipeline;
  51323. private _createDownSampleX4PostProcess;
  51324. private _createBrightPassPostProcess;
  51325. private _createBlurPostProcesses;
  51326. private _createTextureAdderPostProcess;
  51327. private _createVolumetricLightPostProcess;
  51328. private _createLuminancePostProcesses;
  51329. private _createHdrPostProcess;
  51330. private _createLensFlarePostProcess;
  51331. private _createDepthOfFieldPostProcess;
  51332. private _createMotionBlurPostProcess;
  51333. private _getDepthTexture;
  51334. private _disposePostProcesses;
  51335. /**
  51336. * Dispose of the pipeline and stop all post processes
  51337. */
  51338. dispose(): void;
  51339. /**
  51340. * Serialize the rendering pipeline (Used when exporting)
  51341. * @returns the serialized object
  51342. */
  51343. serialize(): any;
  51344. /**
  51345. * Parse the serialized pipeline
  51346. * @param source Source pipeline.
  51347. * @param scene The scene to load the pipeline to.
  51348. * @param rootUrl The URL of the serialized pipeline.
  51349. * @returns An instantiated pipeline from the serialized object.
  51350. */
  51351. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51352. /**
  51353. * Luminance steps
  51354. */
  51355. static LuminanceSteps: number;
  51356. }
  51357. }