babylon.d.ts 2.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644
  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. private _animate;
  1867. /** @hidden */
  1868. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1869. private _processLateAnimationBindingsForMatrices;
  1870. private _processLateAnimationBindingsForQuaternions;
  1871. private _processLateAnimationBindings;
  1872. /** @hidden */
  1873. _switchToAlternateCameraConfiguration(active: boolean): void;
  1874. /**
  1875. * Gets the current view matrix
  1876. * @returns a Matrix
  1877. */
  1878. getViewMatrix(): Matrix;
  1879. /**
  1880. * Gets the current projection matrix
  1881. * @returns a Matrix
  1882. */
  1883. getProjectionMatrix(): Matrix;
  1884. /**
  1885. * Gets the current transform matrix
  1886. * @returns a Matrix made of View * Projection
  1887. */
  1888. getTransformMatrix(): Matrix;
  1889. /**
  1890. * Sets the current transform matrix
  1891. * @param view defines the View matrix to use
  1892. * @param projection defines the Projection matrix to use
  1893. */
  1894. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1895. /** @hidden */
  1896. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1897. /**
  1898. * Gets the uniform buffer used to store scene data
  1899. * @returns a UniformBuffer
  1900. */
  1901. getSceneUniformBuffer(): UniformBuffer;
  1902. /**
  1903. * Gets an unique (relatively to the current scene) Id
  1904. * @returns an unique number for the scene
  1905. */
  1906. getUniqueId(): number;
  1907. /**
  1908. * Add a mesh to the list of scene's meshes
  1909. * @param newMesh defines the mesh to add
  1910. * @param recursive if all child meshes should also be added to the scene
  1911. */
  1912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1913. /**
  1914. * Remove a mesh for the list of scene's meshes
  1915. * @param toRemove defines the mesh to remove
  1916. * @param recursive if all child meshes should also be removed from the scene
  1917. * @returns the index where the mesh was in the mesh list
  1918. */
  1919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1920. /**
  1921. * Add a transform node to the list of scene's transform nodes
  1922. * @param newTransformNode defines the transform node to add
  1923. */
  1924. addTransformNode(newTransformNode: TransformNode): void;
  1925. /**
  1926. * Remove a transform node for the list of scene's transform nodes
  1927. * @param toRemove defines the transform node to remove
  1928. * @returns the index where the transform node was in the transform node list
  1929. */
  1930. removeTransformNode(toRemove: TransformNode): number;
  1931. /**
  1932. * Remove a skeleton for the list of scene's skeletons
  1933. * @param toRemove defines the skeleton to remove
  1934. * @returns the index where the skeleton was in the skeleton list
  1935. */
  1936. removeSkeleton(toRemove: Skeleton): number;
  1937. /**
  1938. * Remove a morph target for the list of scene's morph targets
  1939. * @param toRemove defines the morph target to remove
  1940. * @returns the index where the morph target was in the morph target list
  1941. */
  1942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1943. /**
  1944. * Remove a light for the list of scene's lights
  1945. * @param toRemove defines the light to remove
  1946. * @returns the index where the light was in the light list
  1947. */
  1948. removeLight(toRemove: Light): number;
  1949. /**
  1950. * Remove a camera for the list of scene's cameras
  1951. * @param toRemove defines the camera to remove
  1952. * @returns the index where the camera was in the camera list
  1953. */
  1954. removeCamera(toRemove: Camera): number;
  1955. /**
  1956. * Remove a particle system for the list of scene's particle systems
  1957. * @param toRemove defines the particle system to remove
  1958. * @returns the index where the particle system was in the particle system list
  1959. */
  1960. removeParticleSystem(toRemove: IParticleSystem): number;
  1961. /**
  1962. * Remove a animation for the list of scene's animations
  1963. * @param toRemove defines the animation to remove
  1964. * @returns the index where the animation was in the animation list
  1965. */
  1966. removeAnimation(toRemove: Animation): number;
  1967. /**
  1968. * Removes the given animation group from this scene.
  1969. * @param toRemove The animation group to remove
  1970. * @returns The index of the removed animation group
  1971. */
  1972. removeAnimationGroup(toRemove: AnimationGroup): number;
  1973. /**
  1974. * Removes the given multi-material from this scene.
  1975. * @param toRemove The multi-material to remove
  1976. * @returns The index of the removed multi-material
  1977. */
  1978. removeMultiMaterial(toRemove: MultiMaterial): number;
  1979. /**
  1980. * Removes the given material from this scene.
  1981. * @param toRemove The material to remove
  1982. * @returns The index of the removed material
  1983. */
  1984. removeMaterial(toRemove: Material): number;
  1985. /**
  1986. * Removes the given action manager from this scene.
  1987. * @param toRemove The action manager to remove
  1988. * @returns The index of the removed action manager
  1989. */
  1990. removeActionManager(toRemove: ActionManager): number;
  1991. /**
  1992. * Removes the given texture from this scene.
  1993. * @param toRemove The texture to remove
  1994. * @returns The index of the removed texture
  1995. */
  1996. removeTexture(toRemove: BaseTexture): number;
  1997. /**
  1998. * Adds the given light to this scene
  1999. * @param newLight The light to add
  2000. */
  2001. addLight(newLight: Light): void;
  2002. /**
  2003. * Sorts the list list based on light priorities
  2004. */
  2005. sortLightsByPriority(): void;
  2006. /**
  2007. * Adds the given camera to this scene
  2008. * @param newCamera The camera to add
  2009. */
  2010. addCamera(newCamera: Camera): void;
  2011. /**
  2012. * Adds the given skeleton to this scene
  2013. * @param newSkeleton The skeleton to add
  2014. */
  2015. addSkeleton(newSkeleton: Skeleton): void;
  2016. /**
  2017. * Adds the given particle system to this scene
  2018. * @param newParticleSystem The particle system to add
  2019. */
  2020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2021. /**
  2022. * Adds the given animation to this scene
  2023. * @param newAnimation The animation to add
  2024. */
  2025. addAnimation(newAnimation: Animation): void;
  2026. /**
  2027. * Adds the given animation group to this scene.
  2028. * @param newAnimationGroup The animation group to add
  2029. */
  2030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2031. /**
  2032. * Adds the given multi-material to this scene
  2033. * @param newMultiMaterial The multi-material to add
  2034. */
  2035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2036. /**
  2037. * Adds the given material to this scene
  2038. * @param newMaterial The material to add
  2039. */
  2040. addMaterial(newMaterial: Material): void;
  2041. /**
  2042. * Adds the given morph target to this scene
  2043. * @param newMorphTargetManager The morph target to add
  2044. */
  2045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2046. /**
  2047. * Adds the given geometry to this scene
  2048. * @param newGeometry The geometry to add
  2049. */
  2050. addGeometry(newGeometry: Geometry): void;
  2051. /**
  2052. * Adds the given action manager to this scene
  2053. * @param newActionManager The action manager to add
  2054. */
  2055. addActionManager(newActionManager: ActionManager): void;
  2056. /**
  2057. * Adds the given texture to this scene.
  2058. * @param newTexture The texture to add
  2059. */
  2060. addTexture(newTexture: BaseTexture): void;
  2061. /**
  2062. * Switch active camera
  2063. * @param newCamera defines the new active camera
  2064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2065. */
  2066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2067. /**
  2068. * sets the active camera of the scene using its ID
  2069. * @param id defines the camera's ID
  2070. * @return the new active camera or null if none found.
  2071. */
  2072. setActiveCameraByID(id: string): Nullable<Camera>;
  2073. /**
  2074. * sets the active camera of the scene using its name
  2075. * @param name defines the camera's name
  2076. * @returns the new active camera or null if none found.
  2077. */
  2078. setActiveCameraByName(name: string): Nullable<Camera>;
  2079. /**
  2080. * get an animation group using its name
  2081. * @param name defines the material's name
  2082. * @return the animation group or null if none found.
  2083. */
  2084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2085. /**
  2086. * get a material using its id
  2087. * @param id defines the material's ID
  2088. * @return the material or null if none found.
  2089. */
  2090. getMaterialByID(id: string): Nullable<Material>;
  2091. /**
  2092. * Gets a material using its name
  2093. * @param name defines the material's name
  2094. * @return the material or null if none found.
  2095. */
  2096. getMaterialByName(name: string): Nullable<Material>;
  2097. /**
  2098. * Gets a camera using its id
  2099. * @param id defines the id to look for
  2100. * @returns the camera or null if not found
  2101. */
  2102. getCameraByID(id: string): Nullable<Camera>;
  2103. /**
  2104. * Gets a camera using its unique id
  2105. * @param uniqueId defines the unique id to look for
  2106. * @returns the camera or null if not found
  2107. */
  2108. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2109. /**
  2110. * Gets a camera using its name
  2111. * @param name defines the camera's name
  2112. * @return the camera or null if none found.
  2113. */
  2114. getCameraByName(name: string): Nullable<Camera>;
  2115. /**
  2116. * Gets a bone using its id
  2117. * @param id defines the bone's id
  2118. * @return the bone or null if not found
  2119. */
  2120. getBoneByID(id: string): Nullable<Bone>;
  2121. /**
  2122. * Gets a bone using its id
  2123. * @param name defines the bone's name
  2124. * @return the bone or null if not found
  2125. */
  2126. getBoneByName(name: string): Nullable<Bone>;
  2127. /**
  2128. * Gets a light node using its name
  2129. * @param name defines the the light's name
  2130. * @return the light or null if none found.
  2131. */
  2132. getLightByName(name: string): Nullable<Light>;
  2133. /**
  2134. * Gets a light node using its id
  2135. * @param id defines the light's id
  2136. * @return the light or null if none found.
  2137. */
  2138. getLightByID(id: string): Nullable<Light>;
  2139. /**
  2140. * Gets a light node using its scene-generated unique ID
  2141. * @param uniqueId defines the light's unique id
  2142. * @return the light or null if none found.
  2143. */
  2144. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2145. /**
  2146. * Gets a particle system by id
  2147. * @param id defines the particle system id
  2148. * @return the corresponding system or null if none found
  2149. */
  2150. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2151. /**
  2152. * Gets a geometry using its ID
  2153. * @param id defines the geometry's id
  2154. * @return the geometry or null if none found.
  2155. */
  2156. getGeometryByID(id: string): Nullable<Geometry>;
  2157. private _getGeometryByUniqueID;
  2158. /**
  2159. * Add a new geometry to this scene
  2160. * @param geometry defines the geometry to be added to the scene.
  2161. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2162. * @return a boolean defining if the geometry was added or not
  2163. */
  2164. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2165. /**
  2166. * Removes an existing geometry
  2167. * @param geometry defines the geometry to be removed from the scene
  2168. * @return a boolean defining if the geometry was removed or not
  2169. */
  2170. removeGeometry(geometry: Geometry): boolean;
  2171. /**
  2172. * Gets the list of geometries attached to the scene
  2173. * @returns an array of Geometry
  2174. */
  2175. getGeometries(): Geometry[];
  2176. /**
  2177. * Gets the first added mesh found of a given ID
  2178. * @param id defines the id to search for
  2179. * @return the mesh found or null if not found at all
  2180. */
  2181. getMeshByID(id: string): Nullable<AbstractMesh>;
  2182. /**
  2183. * Gets a list of meshes using their id
  2184. * @param id defines the id to search for
  2185. * @returns a list of meshes
  2186. */
  2187. getMeshesByID(id: string): Array<AbstractMesh>;
  2188. /**
  2189. * Gets the first added transform node found of a given ID
  2190. * @param id defines the id to search for
  2191. * @return the found transform node or null if not found at all.
  2192. */
  2193. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2194. /**
  2195. * Gets a list of transform nodes using their id
  2196. * @param id defines the id to search for
  2197. * @returns a list of transform nodes
  2198. */
  2199. getTransformNodesByID(id: string): Array<TransformNode>;
  2200. /**
  2201. * Gets a mesh with its auto-generated unique id
  2202. * @param uniqueId defines the unique id to search for
  2203. * @return the found mesh or null if not found at all.
  2204. */
  2205. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2206. /**
  2207. * Gets a the last added mesh using a given id
  2208. * @param id defines the id to search for
  2209. * @return the found mesh or null if not found at all.
  2210. */
  2211. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2212. /**
  2213. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2214. * @param id defines the id to search for
  2215. * @return the found node or null if not found at all
  2216. */
  2217. getLastEntryByID(id: string): Nullable<Node>;
  2218. /**
  2219. * Gets a node (Mesh, Camera, Light) using a given id
  2220. * @param id defines the id to search for
  2221. * @return the found node or null if not found at all
  2222. */
  2223. getNodeByID(id: string): Nullable<Node>;
  2224. /**
  2225. * Gets a node (Mesh, Camera, Light) using a given name
  2226. * @param name defines the name to search for
  2227. * @return the found node or null if not found at all.
  2228. */
  2229. getNodeByName(name: string): Nullable<Node>;
  2230. /**
  2231. * Gets a mesh using a given name
  2232. * @param name defines the name to search for
  2233. * @return the found mesh or null if not found at all.
  2234. */
  2235. getMeshByName(name: string): Nullable<AbstractMesh>;
  2236. /**
  2237. * Gets a transform node using a given name
  2238. * @param name defines the name to search for
  2239. * @return the found transform node or null if not found at all.
  2240. */
  2241. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2242. /**
  2243. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2244. * @param id defines the id to search for
  2245. * @return the found skeleton or null if not found at all.
  2246. */
  2247. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2248. /**
  2249. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2250. * @param id defines the id to search for
  2251. * @return the found skeleton or null if not found at all.
  2252. */
  2253. getSkeletonById(id: string): Nullable<Skeleton>;
  2254. /**
  2255. * Gets a skeleton using a given name
  2256. * @param name defines the name to search for
  2257. * @return the found skeleton or null if not found at all.
  2258. */
  2259. getSkeletonByName(name: string): Nullable<Skeleton>;
  2260. /**
  2261. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2262. * @param id defines the id to search for
  2263. * @return the found morph target manager or null if not found at all.
  2264. */
  2265. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2266. /**
  2267. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2268. * @param id defines the id to search for
  2269. * @return the found morph target or null if not found at all.
  2270. */
  2271. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2272. /**
  2273. * Gets a boolean indicating if the given mesh is active
  2274. * @param mesh defines the mesh to look for
  2275. * @returns true if the mesh is in the active list
  2276. */
  2277. isActiveMesh(mesh: AbstractMesh): boolean;
  2278. /**
  2279. * Return a unique id as a string which can serve as an identifier for the scene
  2280. */
  2281. readonly uid: string;
  2282. /**
  2283. * Add an externaly attached data from its key.
  2284. * This method call will fail and return false, if such key already exists.
  2285. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2286. * @param key the unique key that identifies the data
  2287. * @param data the data object to associate to the key for this Engine instance
  2288. * @return true if no such key were already present and the data was added successfully, false otherwise
  2289. */
  2290. addExternalData<T>(key: string, data: T): boolean;
  2291. /**
  2292. * Get an externaly attached data from its key
  2293. * @param key the unique key that identifies the data
  2294. * @return the associated data, if present (can be null), or undefined if not present
  2295. */
  2296. getExternalData<T>(key: string): Nullable<T>;
  2297. /**
  2298. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2299. * @param key the unique key that identifies the data
  2300. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2301. * @return the associated data, can be null if the factory returned null.
  2302. */
  2303. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2304. /**
  2305. * Remove an externaly attached data from the Engine instance
  2306. * @param key the unique key that identifies the data
  2307. * @return true if the data was successfully removed, false if it doesn't exist
  2308. */
  2309. removeExternalData(key: string): boolean;
  2310. private _evaluateSubMesh;
  2311. /**
  2312. * Clear the processed materials smart array preventing retention point in material dispose.
  2313. */
  2314. freeProcessedMaterials(): void;
  2315. private _preventFreeActiveMeshesAndRenderingGroups;
  2316. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2317. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2318. * when disposing several meshes in a row or a hierarchy of meshes.
  2319. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2320. */
  2321. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2322. /**
  2323. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2324. */
  2325. freeActiveMeshes(): void;
  2326. /**
  2327. * Clear the info related to rendering groups preventing retention points during dispose.
  2328. */
  2329. freeRenderingGroups(): void;
  2330. /** @hidden */
  2331. _isInIntermediateRendering(): boolean;
  2332. /**
  2333. * Lambda returning the list of potentially active meshes.
  2334. */
  2335. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2336. /**
  2337. * Lambda returning the list of potentially active sub meshes.
  2338. */
  2339. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2340. /**
  2341. * Lambda returning the list of potentially intersecting sub meshes.
  2342. */
  2343. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2344. /**
  2345. * Lambda returning the list of potentially colliding sub meshes.
  2346. */
  2347. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2348. private _activeMeshesFrozen;
  2349. /**
  2350. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2351. * @returns the current scene
  2352. */
  2353. freezeActiveMeshes(): Scene;
  2354. /**
  2355. * Use this function to restart evaluating active meshes on every frame
  2356. * @returns the current scene
  2357. */
  2358. unfreezeActiveMeshes(): Scene;
  2359. private _evaluateActiveMeshes;
  2360. private _activeMesh;
  2361. /**
  2362. * Update the transform matrix to update from the current active camera
  2363. * @param force defines a boolean used to force the update even if cache is up to date
  2364. */
  2365. updateTransformMatrix(force?: boolean): void;
  2366. /**
  2367. * 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)
  2368. * @param alternateCamera defines the camera to use
  2369. */
  2370. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2371. /** @hidden */
  2372. _allowPostProcessClearColor: boolean;
  2373. private _renderForCamera;
  2374. private _processSubCameras;
  2375. private _checkIntersections;
  2376. /** @hidden */
  2377. _advancePhysicsEngineStep(step: number): void;
  2378. /**
  2379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2380. */
  2381. getDeterministicFrameTime: () => number;
  2382. /**
  2383. * Render the scene
  2384. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2385. */
  2386. render(updateCameras?: boolean): void;
  2387. /**
  2388. * Freeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. freezeMaterials(): void;
  2392. /**
  2393. * Unfreeze all materials
  2394. * A frozen material will not be updatable but should be faster to render
  2395. */
  2396. unfreezeMaterials(): void;
  2397. /**
  2398. * Releases all held ressources
  2399. */
  2400. dispose(): void;
  2401. /**
  2402. * Gets if the scene is already disposed
  2403. */
  2404. readonly isDisposed: boolean;
  2405. /**
  2406. * Call this function to reduce memory footprint of the scene.
  2407. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2408. */
  2409. clearCachedVertexData(): void;
  2410. /**
  2411. * This function will remove the local cached buffer data from texture.
  2412. * It will save memory but will prevent the texture from being rebuilt
  2413. */
  2414. cleanCachedTextureBuffer(): void;
  2415. /**
  2416. * Get the world extend vectors with an optional filter
  2417. *
  2418. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2419. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2420. */
  2421. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2422. min: Vector3;
  2423. max: Vector3;
  2424. };
  2425. /**
  2426. * Creates a ray that can be used to pick in the scene
  2427. * @param x defines the x coordinate of the origin (on-screen)
  2428. * @param y defines the y coordinate of the origin (on-screen)
  2429. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2430. * @param camera defines the camera to use for the picking
  2431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2432. * @returns a Ray
  2433. */
  2434. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2435. /**
  2436. * Creates a ray that can be used to pick in the scene
  2437. * @param x defines the x coordinate of the origin (on-screen)
  2438. * @param y defines the y coordinate of the origin (on-screen)
  2439. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2440. * @param result defines the ray where to store the picking ray
  2441. * @param camera defines the camera to use for the picking
  2442. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2443. * @returns the current scene
  2444. */
  2445. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2446. /**
  2447. * Creates a ray that can be used to pick in the scene
  2448. * @param x defines the x coordinate of the origin (on-screen)
  2449. * @param y defines the y coordinate of the origin (on-screen)
  2450. * @param camera defines the camera to use for the picking
  2451. * @returns a Ray
  2452. */
  2453. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2454. /**
  2455. * Creates a ray that can be used to pick in the scene
  2456. * @param x defines the x coordinate of the origin (on-screen)
  2457. * @param y defines the y coordinate of the origin (on-screen)
  2458. * @param result defines the ray where to store the picking ray
  2459. * @param camera defines the camera to use for the picking
  2460. * @returns the current scene
  2461. */
  2462. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2463. private _internalPick;
  2464. private _internalMultiPick;
  2465. private _tempPickingRay;
  2466. /** Launch a ray to try to pick a mesh in the scene
  2467. * @param x position on screen
  2468. * @param y position on screen
  2469. * @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
  2470. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2471. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2472. * @returns a PickingInfo
  2473. */
  2474. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2475. private _cachedRayForTransform;
  2476. /** Use the given ray to pick a mesh in the scene
  2477. * @param ray The ray to use to pick meshes
  2478. * @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
  2479. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2480. * @returns a PickingInfo
  2481. */
  2482. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2483. /**
  2484. * Launch a ray to try to pick a mesh in the scene
  2485. * @param x X position on screen
  2486. * @param y Y position on screen
  2487. * @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
  2488. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2489. * @returns an array of PickingInfo
  2490. */
  2491. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2492. /**
  2493. * Launch a ray to try to pick a mesh in the scene
  2494. * @param ray Ray to use
  2495. * @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
  2496. * @returns an array of PickingInfo
  2497. */
  2498. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2499. /**
  2500. * Force the value of meshUnderPointer
  2501. * @param mesh defines the mesh to use
  2502. */
  2503. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2504. /**
  2505. * Gets the mesh under the pointer
  2506. * @returns a Mesh or null if no mesh is under the pointer
  2507. */
  2508. getPointerOverMesh(): Nullable<AbstractMesh>;
  2509. /** @hidden */
  2510. _rebuildGeometries(): void;
  2511. /** @hidden */
  2512. _rebuildTextures(): void;
  2513. private _getByTags;
  2514. /**
  2515. * Get a list of meshes by tags
  2516. * @param tagsQuery defines the tags query to use
  2517. * @param forEach defines a predicate used to filter results
  2518. * @returns an array of Mesh
  2519. */
  2520. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2521. /**
  2522. * Get a list of cameras by tags
  2523. * @param tagsQuery defines the tags query to use
  2524. * @param forEach defines a predicate used to filter results
  2525. * @returns an array of Camera
  2526. */
  2527. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2528. /**
  2529. * Get a list of lights by tags
  2530. * @param tagsQuery defines the tags query to use
  2531. * @param forEach defines a predicate used to filter results
  2532. * @returns an array of Light
  2533. */
  2534. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2535. /**
  2536. * Get a list of materials by tags
  2537. * @param tagsQuery defines the tags query to use
  2538. * @param forEach defines a predicate used to filter results
  2539. * @returns an array of Material
  2540. */
  2541. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2542. /**
  2543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2544. * This allowed control for front to back rendering or reversly depending of the special needs.
  2545. *
  2546. * @param renderingGroupId The rendering group id corresponding to its index
  2547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2550. */
  2551. 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;
  2552. /**
  2553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2554. *
  2555. * @param renderingGroupId The rendering group id corresponding to its index
  2556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2559. */
  2560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2561. /**
  2562. * Gets the current auto clear configuration for one rendering group of the rendering
  2563. * manager.
  2564. * @param index the rendering group index to get the information for
  2565. * @returns The auto clear setup for the requested rendering group
  2566. */
  2567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2568. private _blockMaterialDirtyMechanism;
  2569. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2570. blockMaterialDirtyMechanism: boolean;
  2571. /**
  2572. * Will flag all materials as dirty to trigger new shader compilation
  2573. * @param flag defines the flag used to specify which material part must be marked as dirty
  2574. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2575. */
  2576. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2577. /** @hidden */
  2578. _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;
  2579. /** @hidden */
  2580. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2581. }
  2582. }
  2583. declare module BABYLON {
  2584. /**
  2585. * Groups all the scene component constants in one place to ease maintenance.
  2586. * @hidden
  2587. */
  2588. class SceneComponentConstants {
  2589. static readonly NAME_EFFECTLAYER: string;
  2590. static readonly NAME_LAYER: string;
  2591. static readonly NAME_LENSFLARESYSTEM: string;
  2592. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2593. static readonly NAME_PARTICLESYSTEM: string;
  2594. static readonly NAME_GAMEPAD: string;
  2595. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2596. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2597. static readonly NAME_DEPTHRENDERER: string;
  2598. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2599. static readonly NAME_SPRITE: string;
  2600. static readonly NAME_OUTLINERENDERER: string;
  2601. static readonly NAME_PROCEDURALTEXTURE: string;
  2602. static readonly NAME_SHADOWGENERATOR: string;
  2603. static readonly NAME_OCTREE: string;
  2604. static readonly NAME_PHYSICSENGINE: string;
  2605. static readonly NAME_AUDIO: string;
  2606. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2607. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2608. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2609. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2610. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2611. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2612. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2613. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2614. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2615. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2616. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2617. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2618. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2619. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2620. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2621. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2622. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2623. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2624. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2625. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2626. static readonly STEP_AFTERRENDER_AUDIO: number;
  2627. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2628. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2629. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2630. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2631. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2632. static readonly STEP_POINTERMOVE_SPRITE: number;
  2633. static readonly STEP_POINTERDOWN_SPRITE: number;
  2634. static readonly STEP_POINTERUP_SPRITE: number;
  2635. }
  2636. /**
  2637. * This represents a scene component.
  2638. *
  2639. * This is used to decouple the dependency the scene is having on the different workloads like
  2640. * layers, post processes...
  2641. */
  2642. interface ISceneComponent {
  2643. /**
  2644. * The name of the component. Each component must have a unique name.
  2645. */
  2646. name: string;
  2647. /**
  2648. * The scene the component belongs to.
  2649. */
  2650. scene: Scene;
  2651. /**
  2652. * Register the component to one instance of a scene.
  2653. */
  2654. register(): void;
  2655. /**
  2656. * Rebuilds the elements related to this component in case of
  2657. * context lost for instance.
  2658. */
  2659. rebuild(): void;
  2660. /**
  2661. * Disposes the component and the associated ressources.
  2662. */
  2663. dispose(): void;
  2664. }
  2665. /**
  2666. * This represents a SERIALIZABLE scene component.
  2667. *
  2668. * This extends Scene Component to add Serialization methods on top.
  2669. */
  2670. interface ISceneSerializableComponent extends ISceneComponent {
  2671. /**
  2672. * Adds all the element from the container to the scene
  2673. * @param container the container holding the elements
  2674. */
  2675. addFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Removes all the elements in the container from the scene
  2678. * @param container contains the elements to remove
  2679. */
  2680. removeFromContainer(container: AbstractScene): void;
  2681. /**
  2682. * Serializes the component data to the specified json object
  2683. * @param serializationObject The object to serialize to
  2684. */
  2685. serialize(serializationObject: any): void;
  2686. }
  2687. /**
  2688. * Strong typing of a Mesh related stage step action
  2689. */
  2690. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2691. /**
  2692. * Strong typing of a Evaluate Sub Mesh related stage step action
  2693. */
  2694. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2695. /**
  2696. * Strong typing of a Active Mesh related stage step action
  2697. */
  2698. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2699. /**
  2700. * Strong typing of a Camera related stage step action
  2701. */
  2702. type CameraStageAction = (camera: Camera) => void;
  2703. /**
  2704. * Strong typing of a Render Target related stage step action
  2705. */
  2706. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2707. /**
  2708. * Strong typing of a RenderingGroup related stage step action
  2709. */
  2710. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2711. /**
  2712. * Strong typing of a Mesh Render related stage step action
  2713. */
  2714. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2715. /**
  2716. * Strong typing of a simple stage step action
  2717. */
  2718. type SimpleStageAction = () => void;
  2719. /**
  2720. * Strong typing of a render target action.
  2721. */
  2722. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2723. /**
  2724. * Strong typing of a pointer move action.
  2725. */
  2726. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2727. /**
  2728. * Strong typing of a pointer up/down action.
  2729. */
  2730. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2731. /**
  2732. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2733. * @hidden
  2734. */
  2735. class Stage<T extends Function> extends Array<{
  2736. index: number;
  2737. component: ISceneComponent;
  2738. action: T;
  2739. }> {
  2740. /**
  2741. * Hide ctor from the rest of the world.
  2742. * @param items The items to add.
  2743. */
  2744. private constructor();
  2745. /**
  2746. * Creates a new Stage.
  2747. * @returns A new instance of a Stage
  2748. */
  2749. static Create<T extends Function>(): Stage<T>;
  2750. /**
  2751. * Registers a step in an ordered way in the targeted stage.
  2752. * @param index Defines the position to register the step in
  2753. * @param component Defines the component attached to the step
  2754. * @param action Defines the action to launch during the step
  2755. */
  2756. registerStep(index: number, component: ISceneComponent, action: T): void;
  2757. /**
  2758. * Clears all the steps from the stage.
  2759. */
  2760. clear(): void;
  2761. }
  2762. }
  2763. declare module BABYLON {
  2764. /** Alias type for value that can be null */
  2765. type Nullable<T> = T | null;
  2766. /**
  2767. * Alias type for number that are floats
  2768. * @ignorenaming
  2769. */
  2770. type float = number;
  2771. /**
  2772. * Alias type for number that are doubles.
  2773. * @ignorenaming
  2774. */
  2775. type double = number;
  2776. /**
  2777. * Alias type for number that are integer
  2778. * @ignorenaming
  2779. */
  2780. type int = number;
  2781. /** Alias type for number array or Float32Array */
  2782. type FloatArray = number[] | Float32Array;
  2783. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2784. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2785. /**
  2786. * Alias for types that can be used by a Buffer or VertexBuffer.
  2787. */
  2788. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2789. /**
  2790. * Alias type for primitive types
  2791. * @ignorenaming
  2792. */
  2793. type Primitive = undefined | null | boolean | string | number | Function;
  2794. /**
  2795. * Type modifier to make all the properties of an object Readonly
  2796. */
  2797. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2798. /**
  2799. * Type modifier to make all the properties of an object Readonly recursively
  2800. */
  2801. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2802. /** @hidden */
  2803. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2804. }
  2805. /** @hidden */
  2806. /** @hidden */
  2807. type DeepImmutableObject<T> = {
  2808. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2809. };
  2810. }
  2811. declare module BABYLON {
  2812. /**
  2813. * Class used to store an actual running animation
  2814. */
  2815. class Animatable {
  2816. /** defines the target object */
  2817. target: any;
  2818. /** defines the starting frame number (default is 0) */
  2819. fromFrame: number;
  2820. /** defines the ending frame number (default is 100) */
  2821. toFrame: number;
  2822. /** defines if the animation must loop (default is false) */
  2823. loopAnimation: boolean;
  2824. /** defines a callback to call when animation ends if it is not looping */
  2825. onAnimationEnd?: (() => void) | null | undefined;
  2826. /** defines a callback to call when animation loops */
  2827. onAnimationLoop?: (() => void) | null | undefined;
  2828. private _localDelayOffset;
  2829. private _pausedDelay;
  2830. private _runtimeAnimations;
  2831. private _paused;
  2832. private _scene;
  2833. private _speedRatio;
  2834. private _weight;
  2835. private _syncRoot;
  2836. /**
  2837. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2838. * This will only apply for non looping animation (default is true)
  2839. */
  2840. disposeOnEnd: boolean;
  2841. /**
  2842. * Gets a boolean indicating if the animation has started
  2843. */
  2844. animationStarted: boolean;
  2845. /**
  2846. * Observer raised when the animation ends
  2847. */
  2848. onAnimationEndObservable: Observable<Animatable>;
  2849. /**
  2850. * Observer raised when the animation loops
  2851. */
  2852. onAnimationLoopObservable: Observable<Animatable>;
  2853. /**
  2854. * Gets the root Animatable used to synchronize and normalize animations
  2855. */
  2856. readonly syncRoot: Animatable;
  2857. /**
  2858. * Gets the current frame of the first RuntimeAnimation
  2859. * Used to synchronize Animatables
  2860. */
  2861. readonly masterFrame: number;
  2862. /**
  2863. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2864. */
  2865. weight: number;
  2866. /**
  2867. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2868. */
  2869. speedRatio: number;
  2870. /**
  2871. * Creates a new Animatable
  2872. * @param scene defines the hosting scene
  2873. * @param target defines the target object
  2874. * @param fromFrame defines the starting frame number (default is 0)
  2875. * @param toFrame defines the ending frame number (default is 100)
  2876. * @param loopAnimation defines if the animation must loop (default is false)
  2877. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2878. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2879. * @param animations defines a group of animation to add to the new Animatable
  2880. * @param onAnimationLoop defines a callback to call when animation loops
  2881. */
  2882. constructor(scene: Scene,
  2883. /** defines the target object */
  2884. target: any,
  2885. /** defines the starting frame number (default is 0) */
  2886. fromFrame?: number,
  2887. /** defines the ending frame number (default is 100) */
  2888. toFrame?: number,
  2889. /** defines if the animation must loop (default is false) */
  2890. loopAnimation?: boolean, speedRatio?: number,
  2891. /** defines a callback to call when animation ends if it is not looping */
  2892. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  2893. /** defines a callback to call when animation loops */
  2894. onAnimationLoop?: (() => void) | null | undefined);
  2895. /**
  2896. * Synchronize and normalize current Animatable with a source Animatable
  2897. * This is useful when using animation weights and when animations are not of the same length
  2898. * @param root defines the root Animatable to synchronize with
  2899. * @returns the current Animatable
  2900. */
  2901. syncWith(root: Animatable): Animatable;
  2902. /**
  2903. * Gets the list of runtime animations
  2904. * @returns an array of RuntimeAnimation
  2905. */
  2906. getAnimations(): RuntimeAnimation[];
  2907. /**
  2908. * Adds more animations to the current animatable
  2909. * @param target defines the target of the animations
  2910. * @param animations defines the new animations to add
  2911. */
  2912. appendAnimations(target: any, animations: Animation[]): void;
  2913. /**
  2914. * Gets the source animation for a specific property
  2915. * @param property defines the propertyu to look for
  2916. * @returns null or the source animation for the given property
  2917. */
  2918. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2919. /**
  2920. * Gets the runtime animation for a specific property
  2921. * @param property defines the propertyu to look for
  2922. * @returns null or the runtime animation for the given property
  2923. */
  2924. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2925. /**
  2926. * Resets the animatable to its original state
  2927. */
  2928. reset(): void;
  2929. /**
  2930. * Allows the animatable to blend with current running animations
  2931. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2932. * @param blendingSpeed defines the blending speed to use
  2933. */
  2934. enableBlending(blendingSpeed: number): void;
  2935. /**
  2936. * Disable animation blending
  2937. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2938. */
  2939. disableBlending(): void;
  2940. /**
  2941. * Jump directly to a given frame
  2942. * @param frame defines the frame to jump to
  2943. */
  2944. goToFrame(frame: number): void;
  2945. /**
  2946. * Pause the animation
  2947. */
  2948. pause(): void;
  2949. /**
  2950. * Restart the animation
  2951. */
  2952. restart(): void;
  2953. private _raiseOnAnimationEnd;
  2954. /**
  2955. * Stop and delete the current animation
  2956. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2957. * @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)
  2958. */
  2959. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  2960. /**
  2961. * Wait asynchronously for the animation to end
  2962. * @returns a promise which will be fullfilled when the animation ends
  2963. */
  2964. waitAsync(): Promise<Animatable>;
  2965. /** @hidden */
  2966. _animate(delay: number): boolean;
  2967. }
  2968. }
  2969. declare module BABYLON {
  2970. /**
  2971. * Represents the range of an animation
  2972. */
  2973. class AnimationRange {
  2974. /**The name of the animation range**/
  2975. name: string;
  2976. /**The starting frame of the animation */
  2977. from: number;
  2978. /**The ending frame of the animation*/
  2979. to: number;
  2980. /**
  2981. * Initializes the range of an animation
  2982. * @param name The name of the animation range
  2983. * @param from The starting frame of the animation
  2984. * @param to The ending frame of the animation
  2985. */
  2986. constructor(
  2987. /**The name of the animation range**/
  2988. name: string,
  2989. /**The starting frame of the animation */
  2990. from: number,
  2991. /**The ending frame of the animation*/
  2992. to: number);
  2993. /**
  2994. * Makes a copy of the animation range
  2995. * @returns A copy of the animation range
  2996. */
  2997. clone(): AnimationRange;
  2998. }
  2999. /**
  3000. * Composed of a frame, and an action function
  3001. */
  3002. class AnimationEvent {
  3003. /** The frame for which the event is triggered **/
  3004. frame: number;
  3005. /** The event to perform when triggered **/
  3006. action: (currentFrame: number) => void;
  3007. /** Specifies if the event should be triggered only once**/
  3008. onlyOnce?: boolean | undefined;
  3009. /**
  3010. * Specifies if the animation event is done
  3011. */
  3012. isDone: boolean;
  3013. /**
  3014. * Initializes the animation event
  3015. * @param frame The frame for which the event is triggered
  3016. * @param action The event to perform when triggered
  3017. * @param onlyOnce Specifies if the event should be triggered only once
  3018. */
  3019. constructor(
  3020. /** The frame for which the event is triggered **/
  3021. frame: number,
  3022. /** The event to perform when triggered **/
  3023. action: (currentFrame: number) => void,
  3024. /** Specifies if the event should be triggered only once**/
  3025. onlyOnce?: boolean | undefined);
  3026. /** @hidden */
  3027. _clone(): AnimationEvent;
  3028. }
  3029. /**
  3030. * A cursor which tracks a point on a path
  3031. */
  3032. class PathCursor {
  3033. private path;
  3034. /**
  3035. * Stores path cursor callbacks for when an onchange event is triggered
  3036. */
  3037. private _onchange;
  3038. /**
  3039. * The value of the path cursor
  3040. */
  3041. value: number;
  3042. /**
  3043. * The animation array of the path cursor
  3044. */
  3045. animations: Animation[];
  3046. /**
  3047. * Initializes the path cursor
  3048. * @param path The path to track
  3049. */
  3050. constructor(path: Path2);
  3051. /**
  3052. * Gets the cursor point on the path
  3053. * @returns A point on the path cursor at the cursor location
  3054. */
  3055. getPoint(): Vector3;
  3056. /**
  3057. * Moves the cursor ahead by the step amount
  3058. * @param step The amount to move the cursor forward
  3059. * @returns This path cursor
  3060. */
  3061. moveAhead(step?: number): PathCursor;
  3062. /**
  3063. * Moves the cursor behind by the step amount
  3064. * @param step The amount to move the cursor back
  3065. * @returns This path cursor
  3066. */
  3067. moveBack(step?: number): PathCursor;
  3068. /**
  3069. * Moves the cursor by the step amount
  3070. * If the step amount is greater than one, an exception is thrown
  3071. * @param step The amount to move the cursor
  3072. * @returns This path cursor
  3073. */
  3074. move(step: number): PathCursor;
  3075. /**
  3076. * Ensures that the value is limited between zero and one
  3077. * @returns This path cursor
  3078. */
  3079. private ensureLimits;
  3080. /**
  3081. * Runs onchange callbacks on change (used by the animation engine)
  3082. * @returns This path cursor
  3083. */
  3084. private raiseOnChange;
  3085. /**
  3086. * Executes a function on change
  3087. * @param f A path cursor onchange callback
  3088. * @returns This path cursor
  3089. */
  3090. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3091. }
  3092. /**
  3093. * Defines an interface which represents an animation key frame
  3094. */
  3095. interface IAnimationKey {
  3096. /**
  3097. * Frame of the key frame
  3098. */
  3099. frame: number;
  3100. /**
  3101. * Value at the specifies key frame
  3102. */
  3103. value: any;
  3104. /**
  3105. * The input tangent for the cubic hermite spline
  3106. */
  3107. inTangent?: any;
  3108. /**
  3109. * The output tangent for the cubic hermite spline
  3110. */
  3111. outTangent?: any;
  3112. /**
  3113. * The animation interpolation type
  3114. */
  3115. interpolation?: AnimationKeyInterpolation;
  3116. }
  3117. /**
  3118. * Enum for the animation key frame interpolation type
  3119. */
  3120. enum AnimationKeyInterpolation {
  3121. /**
  3122. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3123. */
  3124. STEP = 1
  3125. }
  3126. /**
  3127. * Class used to store any kind of animation
  3128. */
  3129. class Animation {
  3130. /**Name of the animation */
  3131. name: string;
  3132. /**Property to animate */
  3133. targetProperty: string;
  3134. /**The frames per second of the animation */
  3135. framePerSecond: number;
  3136. /**The data type of the animation */
  3137. dataType: number;
  3138. /**The loop mode of the animation */
  3139. loopMode?: number | undefined;
  3140. /**Specifies if blending should be enabled */
  3141. enableBlending?: boolean | undefined;
  3142. /**
  3143. * Use matrix interpolation instead of using direct key value when animating matrices
  3144. */
  3145. static AllowMatricesInterpolation: boolean;
  3146. /**
  3147. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3148. */
  3149. static AllowMatrixDecomposeForInterpolation: boolean;
  3150. /**
  3151. * Stores the key frames of the animation
  3152. */
  3153. private _keys;
  3154. /**
  3155. * Stores the easing function of the animation
  3156. */
  3157. private _easingFunction;
  3158. /**
  3159. * @hidden Internal use only
  3160. */
  3161. _runtimeAnimations: RuntimeAnimation[];
  3162. /**
  3163. * The set of event that will be linked to this animation
  3164. */
  3165. private _events;
  3166. /**
  3167. * Stores an array of target property paths
  3168. */
  3169. targetPropertyPath: string[];
  3170. /**
  3171. * Stores the blending speed of the animation
  3172. */
  3173. blendingSpeed: number;
  3174. /**
  3175. * Stores the animation ranges for the animation
  3176. */
  3177. private _ranges;
  3178. /**
  3179. * @hidden Internal use
  3180. */
  3181. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3182. /**
  3183. * Sets up an animation
  3184. * @param property The property to animate
  3185. * @param animationType The animation type to apply
  3186. * @param framePerSecond The frames per second of the animation
  3187. * @param easingFunction The easing function used in the animation
  3188. * @returns The created animation
  3189. */
  3190. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3191. /**
  3192. * Create and start an animation on a node
  3193. * @param name defines the name of the global animation that will be run on all nodes
  3194. * @param node defines the root node where the animation will take place
  3195. * @param targetProperty defines property to animate
  3196. * @param framePerSecond defines the number of frame per second yo use
  3197. * @param totalFrame defines the number of frames in total
  3198. * @param from defines the initial value
  3199. * @param to defines the final value
  3200. * @param loopMode defines which loop mode you want to use (off by default)
  3201. * @param easingFunction defines the easing function to use (linear by default)
  3202. * @param onAnimationEnd defines the callback to call when animation end
  3203. * @returns the animatable created for this animation
  3204. */
  3205. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3206. /**
  3207. * Create and start an animation on a node and its descendants
  3208. * @param name defines the name of the global animation that will be run on all nodes
  3209. * @param node defines the root node where the animation will take place
  3210. * @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
  3211. * @param targetProperty defines property to animate
  3212. * @param framePerSecond defines the number of frame per second to use
  3213. * @param totalFrame defines the number of frames in total
  3214. * @param from defines the initial value
  3215. * @param to defines the final value
  3216. * @param loopMode defines which loop mode you want to use (off by default)
  3217. * @param easingFunction defines the easing function to use (linear by default)
  3218. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3219. * @returns the list of animatables created for all nodes
  3220. * @example https://www.babylonjs-playground.com/#MH0VLI
  3221. */
  3222. 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[]>;
  3223. /**
  3224. * Creates a new animation, merges it with the existing animations and starts it
  3225. * @param name Name of the animation
  3226. * @param node Node which contains the scene that begins the animations
  3227. * @param targetProperty Specifies which property to animate
  3228. * @param framePerSecond The frames per second of the animation
  3229. * @param totalFrame The total number of frames
  3230. * @param from The frame at the beginning of the animation
  3231. * @param to The frame at the end of the animation
  3232. * @param loopMode Specifies the loop mode of the animation
  3233. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3234. * @param onAnimationEnd Callback to run once the animation is complete
  3235. * @returns Nullable animation
  3236. */
  3237. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3238. /**
  3239. * Transition property of an host to the target Value
  3240. * @param property The property to transition
  3241. * @param targetValue The target Value of the property
  3242. * @param host The object where the property to animate belongs
  3243. * @param scene Scene used to run the animation
  3244. * @param frameRate Framerate (in frame/s) to use
  3245. * @param transition The transition type we want to use
  3246. * @param duration The duration of the animation, in milliseconds
  3247. * @param onAnimationEnd Callback trigger at the end of the animation
  3248. * @returns Nullable animation
  3249. */
  3250. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3251. /**
  3252. * Return the array of runtime animations currently using this animation
  3253. */
  3254. readonly runtimeAnimations: RuntimeAnimation[];
  3255. /**
  3256. * Specifies if any of the runtime animations are currently running
  3257. */
  3258. readonly hasRunningRuntimeAnimations: boolean;
  3259. /**
  3260. * Initializes the animation
  3261. * @param name Name of the animation
  3262. * @param targetProperty Property to animate
  3263. * @param framePerSecond The frames per second of the animation
  3264. * @param dataType The data type of the animation
  3265. * @param loopMode The loop mode of the animation
  3266. * @param enableBlendings Specifies if blending should be enabled
  3267. */
  3268. constructor(
  3269. /**Name of the animation */
  3270. name: string,
  3271. /**Property to animate */
  3272. targetProperty: string,
  3273. /**The frames per second of the animation */
  3274. framePerSecond: number,
  3275. /**The data type of the animation */
  3276. dataType: number,
  3277. /**The loop mode of the animation */
  3278. loopMode?: number | undefined,
  3279. /**Specifies if blending should be enabled */
  3280. enableBlending?: boolean | undefined);
  3281. /**
  3282. * Converts the animation to a string
  3283. * @param fullDetails support for multiple levels of logging within scene loading
  3284. * @returns String form of the animation
  3285. */
  3286. toString(fullDetails?: boolean): string;
  3287. /**
  3288. * Add an event to this animation
  3289. * @param event Event to add
  3290. */
  3291. addEvent(event: AnimationEvent): void;
  3292. /**
  3293. * Remove all events found at the given frame
  3294. * @param frame The frame to remove events from
  3295. */
  3296. removeEvents(frame: number): void;
  3297. /**
  3298. * Retrieves all the events from the animation
  3299. * @returns Events from the animation
  3300. */
  3301. getEvents(): AnimationEvent[];
  3302. /**
  3303. * Creates an animation range
  3304. * @param name Name of the animation range
  3305. * @param from Starting frame of the animation range
  3306. * @param to Ending frame of the animation
  3307. */
  3308. createRange(name: string, from: number, to: number): void;
  3309. /**
  3310. * Deletes an animation range by name
  3311. * @param name Name of the animation range to delete
  3312. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3313. */
  3314. deleteRange(name: string, deleteFrames?: boolean): void;
  3315. /**
  3316. * Gets the animation range by name, or null if not defined
  3317. * @param name Name of the animation range
  3318. * @returns Nullable animation range
  3319. */
  3320. getRange(name: string): Nullable<AnimationRange>;
  3321. /**
  3322. * Gets the key frames from the animation
  3323. * @returns The key frames of the animation
  3324. */
  3325. getKeys(): Array<IAnimationKey>;
  3326. /**
  3327. * Gets the highest frame rate of the animation
  3328. * @returns Highest frame rate of the animation
  3329. */
  3330. getHighestFrame(): number;
  3331. /**
  3332. * Gets the easing function of the animation
  3333. * @returns Easing function of the animation
  3334. */
  3335. getEasingFunction(): IEasingFunction;
  3336. /**
  3337. * Sets the easing function of the animation
  3338. * @param easingFunction A custom mathematical formula for animation
  3339. */
  3340. setEasingFunction(easingFunction: EasingFunction): void;
  3341. /**
  3342. * Interpolates a scalar linearly
  3343. * @param startValue Start value of the animation curve
  3344. * @param endValue End value of the animation curve
  3345. * @param gradient Scalar amount to interpolate
  3346. * @returns Interpolated scalar value
  3347. */
  3348. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3349. /**
  3350. * Interpolates a scalar cubically
  3351. * @param startValue Start value of the animation curve
  3352. * @param outTangent End tangent of the animation
  3353. * @param endValue End value of the animation curve
  3354. * @param inTangent Start tangent of the animation curve
  3355. * @param gradient Scalar amount to interpolate
  3356. * @returns Interpolated scalar value
  3357. */
  3358. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3359. /**
  3360. * Interpolates a quaternion using a spherical linear interpolation
  3361. * @param startValue Start value of the animation curve
  3362. * @param endValue End value of the animation curve
  3363. * @param gradient Scalar amount to interpolate
  3364. * @returns Interpolated quaternion value
  3365. */
  3366. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3367. /**
  3368. * Interpolates a quaternion cubically
  3369. * @param startValue Start value of the animation curve
  3370. * @param outTangent End tangent of the animation curve
  3371. * @param endValue End value of the animation curve
  3372. * @param inTangent Start tangent of the animation curve
  3373. * @param gradient Scalar amount to interpolate
  3374. * @returns Interpolated quaternion value
  3375. */
  3376. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3377. /**
  3378. * Interpolates a Vector3 linearl
  3379. * @param startValue Start value of the animation curve
  3380. * @param endValue End value of the animation curve
  3381. * @param gradient Scalar amount to interpolate
  3382. * @returns Interpolated scalar value
  3383. */
  3384. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3385. /**
  3386. * Interpolates a Vector3 cubically
  3387. * @param startValue Start value of the animation curve
  3388. * @param outTangent End tangent of the animation
  3389. * @param endValue End value of the animation curve
  3390. * @param inTangent Start tangent of the animation curve
  3391. * @param gradient Scalar amount to interpolate
  3392. * @returns InterpolatedVector3 value
  3393. */
  3394. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3395. /**
  3396. * Interpolates a Vector2 linearly
  3397. * @param startValue Start value of the animation curve
  3398. * @param endValue End value of the animation curve
  3399. * @param gradient Scalar amount to interpolate
  3400. * @returns Interpolated Vector2 value
  3401. */
  3402. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3403. /**
  3404. * Interpolates a Vector2 cubically
  3405. * @param startValue Start value of the animation curve
  3406. * @param outTangent End tangent of the animation
  3407. * @param endValue End value of the animation curve
  3408. * @param inTangent Start tangent of the animation curve
  3409. * @param gradient Scalar amount to interpolate
  3410. * @returns Interpolated Vector2 value
  3411. */
  3412. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3413. /**
  3414. * Interpolates a size linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated Size value
  3419. */
  3420. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3421. /**
  3422. * Interpolates a Color3 linearly
  3423. * @param startValue Start value of the animation curve
  3424. * @param endValue End value of the animation curve
  3425. * @param gradient Scalar amount to interpolate
  3426. * @returns Interpolated Color3 value
  3427. */
  3428. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3429. /**
  3430. * @hidden Internal use only
  3431. */
  3432. _getKeyValue(value: any): any;
  3433. /**
  3434. * @hidden Internal use only
  3435. */
  3436. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3437. /**
  3438. * Defines the function to use to interpolate matrices
  3439. * @param startValue defines the start matrix
  3440. * @param endValue defines the end matrix
  3441. * @param gradient defines the gradient between both matrices
  3442. * @param result defines an optional target matrix where to store the interpolation
  3443. * @returns the interpolated matrix
  3444. */
  3445. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3446. /**
  3447. * Makes a copy of the animation
  3448. * @returns Cloned animation
  3449. */
  3450. clone(): Animation;
  3451. /**
  3452. * Sets the key frames of the animation
  3453. * @param values The animation key frames to set
  3454. */
  3455. setKeys(values: Array<IAnimationKey>): void;
  3456. /**
  3457. * Serializes the animation to an object
  3458. * @returns Serialized object
  3459. */
  3460. serialize(): any;
  3461. /**
  3462. * Float animation type
  3463. */
  3464. private static _ANIMATIONTYPE_FLOAT;
  3465. /**
  3466. * Vector3 animation type
  3467. */
  3468. private static _ANIMATIONTYPE_VECTOR3;
  3469. /**
  3470. * Quaternion animation type
  3471. */
  3472. private static _ANIMATIONTYPE_QUATERNION;
  3473. /**
  3474. * Matrix animation type
  3475. */
  3476. private static _ANIMATIONTYPE_MATRIX;
  3477. /**
  3478. * Color3 animation type
  3479. */
  3480. private static _ANIMATIONTYPE_COLOR3;
  3481. /**
  3482. * Vector2 animation type
  3483. */
  3484. private static _ANIMATIONTYPE_VECTOR2;
  3485. /**
  3486. * Size animation type
  3487. */
  3488. private static _ANIMATIONTYPE_SIZE;
  3489. /**
  3490. * Relative Loop Mode
  3491. */
  3492. private static _ANIMATIONLOOPMODE_RELATIVE;
  3493. /**
  3494. * Cycle Loop Mode
  3495. */
  3496. private static _ANIMATIONLOOPMODE_CYCLE;
  3497. /**
  3498. * Constant Loop Mode
  3499. */
  3500. private static _ANIMATIONLOOPMODE_CONSTANT;
  3501. /**
  3502. * Get the float animation type
  3503. */
  3504. static readonly ANIMATIONTYPE_FLOAT: number;
  3505. /**
  3506. * Get the Vector3 animation type
  3507. */
  3508. static readonly ANIMATIONTYPE_VECTOR3: number;
  3509. /**
  3510. * Get the Vector2 animation type
  3511. */
  3512. static readonly ANIMATIONTYPE_VECTOR2: number;
  3513. /**
  3514. * Get the Size animation type
  3515. */
  3516. static readonly ANIMATIONTYPE_SIZE: number;
  3517. /**
  3518. * Get the Quaternion animation type
  3519. */
  3520. static readonly ANIMATIONTYPE_QUATERNION: number;
  3521. /**
  3522. * Get the Matrix animation type
  3523. */
  3524. static readonly ANIMATIONTYPE_MATRIX: number;
  3525. /**
  3526. * Get the Color3 animation type
  3527. */
  3528. static readonly ANIMATIONTYPE_COLOR3: number;
  3529. /**
  3530. * Get the Relative Loop Mode
  3531. */
  3532. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3533. /**
  3534. * Get the Cycle Loop Mode
  3535. */
  3536. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3537. /**
  3538. * Get the Constant Loop Mode
  3539. */
  3540. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3541. /** @hidden */
  3542. static _UniversalLerp(left: any, right: any, amount: number): any;
  3543. /**
  3544. * Parses an animation object and creates an animation
  3545. * @param parsedAnimation Parsed animation object
  3546. * @returns Animation object
  3547. */
  3548. static Parse(parsedAnimation: any): Animation;
  3549. /**
  3550. * Appends the serialized animations from the source animations
  3551. * @param source Source containing the animations
  3552. * @param destination Target to store the animations
  3553. */
  3554. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3555. }
  3556. }
  3557. declare module BABYLON {
  3558. /**
  3559. * This class defines the direct association between an animation and a target
  3560. */
  3561. class TargetedAnimation {
  3562. /**
  3563. * Animation to perform
  3564. */
  3565. animation: Animation;
  3566. /**
  3567. * Target to animate
  3568. */
  3569. target: any;
  3570. }
  3571. /**
  3572. * Use this class to create coordinated animations on multiple targets
  3573. */
  3574. class AnimationGroup implements IDisposable {
  3575. /** The name of the animation group */
  3576. name: string;
  3577. private _scene;
  3578. private _targetedAnimations;
  3579. private _animatables;
  3580. private _from;
  3581. private _to;
  3582. private _isStarted;
  3583. private _isPaused;
  3584. private _speedRatio;
  3585. /**
  3586. * Gets or sets the unique id of the node
  3587. */
  3588. uniqueId: number;
  3589. /**
  3590. * This observable will notify when one animation have ended
  3591. */
  3592. onAnimationEndObservable: Observable<TargetedAnimation>;
  3593. /**
  3594. * Observer raised when one animation loops
  3595. */
  3596. onAnimationLoopObservable: Observable<TargetedAnimation>;
  3597. /**
  3598. * This observable will notify when all animations have ended.
  3599. */
  3600. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  3601. /**
  3602. * This observable will notify when all animations have paused.
  3603. */
  3604. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  3605. /**
  3606. * This observable will notify when all animations are playing.
  3607. */
  3608. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  3609. /**
  3610. * Gets the first frame
  3611. */
  3612. readonly from: number;
  3613. /**
  3614. * Gets the last frame
  3615. */
  3616. readonly to: number;
  3617. /**
  3618. * Define if the animations are started
  3619. */
  3620. readonly isStarted: boolean;
  3621. /**
  3622. * Gets a value indicating that the current group is playing
  3623. */
  3624. readonly isPlaying: boolean;
  3625. /**
  3626. * Gets or sets the speed ratio to use for all animations
  3627. */
  3628. /**
  3629. * Gets or sets the speed ratio to use for all animations
  3630. */
  3631. speedRatio: number;
  3632. /**
  3633. * Gets the targeted animations for this animation group
  3634. */
  3635. readonly targetedAnimations: Array<TargetedAnimation>;
  3636. /**
  3637. * returning the list of animatables controlled by this animation group.
  3638. */
  3639. readonly animatables: Array<Animatable>;
  3640. /**
  3641. * Instantiates a new Animation Group.
  3642. * This helps managing several animations at once.
  3643. * @see http://doc.babylonjs.com/how_to/group
  3644. * @param name Defines the name of the group
  3645. * @param scene Defines the scene the group belongs to
  3646. */
  3647. constructor(
  3648. /** The name of the animation group */
  3649. name: string, scene?: Nullable<Scene>);
  3650. /**
  3651. * Add an animation (with its target) in the group
  3652. * @param animation defines the animation we want to add
  3653. * @param target defines the target of the animation
  3654. * @returns the TargetedAnimation object
  3655. */
  3656. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  3657. /**
  3658. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3659. * It can add constant keys at begin or end
  3660. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  3661. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  3662. * @returns the animation group
  3663. */
  3664. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  3665. /**
  3666. * Start all animations on given targets
  3667. * @param loop defines if animations must loop
  3668. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3669. * @param from defines the from key (optional)
  3670. * @param to defines the to key (optional)
  3671. * @returns the current animation group
  3672. */
  3673. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  3674. /**
  3675. * Pause all animations
  3676. * @returns the animation group
  3677. */
  3678. pause(): AnimationGroup;
  3679. /**
  3680. * Play all animations to initial state
  3681. * This function will start() the animations if they were not started or will restart() them if they were paused
  3682. * @param loop defines if animations must loop
  3683. * @returns the animation group
  3684. */
  3685. play(loop?: boolean): AnimationGroup;
  3686. /**
  3687. * Reset all animations to initial state
  3688. * @returns the animation group
  3689. */
  3690. reset(): AnimationGroup;
  3691. /**
  3692. * Restart animations from key 0
  3693. * @returns the animation group
  3694. */
  3695. restart(): AnimationGroup;
  3696. /**
  3697. * Stop all animations
  3698. * @returns the animation group
  3699. */
  3700. stop(): AnimationGroup;
  3701. /**
  3702. * Set animation weight for all animatables
  3703. * @param weight defines the weight to use
  3704. * @return the animationGroup
  3705. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3706. */
  3707. setWeightForAllAnimatables(weight: number): AnimationGroup;
  3708. /**
  3709. * Synchronize and normalize all animatables with a source animatable
  3710. * @param root defines the root animatable to synchronize with
  3711. * @return the animationGroup
  3712. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3713. */
  3714. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  3715. /**
  3716. * Goes to a specific frame in this animation group
  3717. * @param frame the frame number to go to
  3718. * @return the animationGroup
  3719. */
  3720. goToFrame(frame: number): AnimationGroup;
  3721. /**
  3722. * Dispose all associated resources
  3723. */
  3724. dispose(): void;
  3725. private _checkAnimationGroupEnded;
  3726. /**
  3727. * Returns a new AnimationGroup object parsed from the source provided.
  3728. * @param parsedAnimationGroup defines the source
  3729. * @param scene defines the scene that will receive the animationGroup
  3730. * @returns a new AnimationGroup
  3731. */
  3732. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  3733. /**
  3734. * Returns the string "AnimationGroup"
  3735. * @returns "AnimationGroup"
  3736. */
  3737. getClassName(): string;
  3738. /**
  3739. * Creates a detailled string about the object
  3740. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  3741. * @returns a string representing the object
  3742. */
  3743. toString(fullDetails?: boolean): string;
  3744. }
  3745. }
  3746. declare module BABYLON {
  3747. /**
  3748. * Class used to override all child animations of a given target
  3749. */
  3750. class AnimationPropertiesOverride {
  3751. /**
  3752. * Gets or sets a value indicating if animation blending must be used
  3753. */
  3754. enableBlending: boolean;
  3755. /**
  3756. * Gets or sets the blending speed to use when enableBlending is true
  3757. */
  3758. blendingSpeed: number;
  3759. /**
  3760. * Gets or sets the default loop mode to use
  3761. */
  3762. loopMode: number;
  3763. }
  3764. }
  3765. declare module BABYLON {
  3766. /**
  3767. * This represents the main contract an easing function should follow.
  3768. * Easing functions are used throughout the animation system.
  3769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3770. */
  3771. interface IEasingFunction {
  3772. /**
  3773. * Given an input gradient between 0 and 1, this returns the corrseponding value
  3774. * of the easing function.
  3775. * The link below provides some of the most common examples of easing functions.
  3776. * @see https://easings.net/
  3777. * @param gradient Defines the value between 0 and 1 we want the easing value for
  3778. * @returns the corresponding value on the curve defined by the easing function
  3779. */
  3780. ease(gradient: number): number;
  3781. }
  3782. /**
  3783. * Base class used for every default easing function.
  3784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3785. */
  3786. class EasingFunction implements IEasingFunction {
  3787. /**
  3788. * Interpolation follows the mathematical formula associated with the easing function.
  3789. */
  3790. static readonly EASINGMODE_EASEIN: number;
  3791. /**
  3792. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  3793. */
  3794. static readonly EASINGMODE_EASEOUT: number;
  3795. /**
  3796. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  3797. */
  3798. static readonly EASINGMODE_EASEINOUT: number;
  3799. private _easingMode;
  3800. /**
  3801. * Sets the easing mode of the current function.
  3802. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  3803. */
  3804. setEasingMode(easingMode: number): void;
  3805. /**
  3806. * Gets the current easing mode.
  3807. * @returns the easing mode
  3808. */
  3809. getEasingMode(): number;
  3810. /**
  3811. * @hidden
  3812. */
  3813. easeInCore(gradient: number): number;
  3814. /**
  3815. * Given an input gradient between 0 and 1, this returns the corrseponding value
  3816. * of the easing function.
  3817. * @param gradient Defines the value between 0 and 1 we want the easing value for
  3818. * @returns the corresponding value on the curve defined by the easing function
  3819. */
  3820. ease(gradient: number): number;
  3821. }
  3822. /**
  3823. * Easing function with a circle shape (see link below).
  3824. * @see https://easings.net/#easeInCirc
  3825. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3826. */
  3827. class CircleEase extends EasingFunction implements IEasingFunction {
  3828. /** @hidden */
  3829. easeInCore(gradient: number): number;
  3830. }
  3831. /**
  3832. * Easing function with a ease back shape (see link below).
  3833. * @see https://easings.net/#easeInBack
  3834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3835. */
  3836. class BackEase extends EasingFunction implements IEasingFunction {
  3837. /** Defines the amplitude of the function */
  3838. amplitude: number;
  3839. /**
  3840. * Instantiates a back ease easing
  3841. * @see https://easings.net/#easeInBack
  3842. * @param amplitude Defines the amplitude of the function
  3843. */
  3844. constructor(
  3845. /** Defines the amplitude of the function */
  3846. amplitude?: number);
  3847. /** @hidden */
  3848. easeInCore(gradient: number): number;
  3849. }
  3850. /**
  3851. * Easing function with a bouncing shape (see link below).
  3852. * @see https://easings.net/#easeInBounce
  3853. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3854. */
  3855. class BounceEase extends EasingFunction implements IEasingFunction {
  3856. /** Defines the number of bounces */
  3857. bounces: number;
  3858. /** Defines the amplitude of the bounce */
  3859. bounciness: number;
  3860. /**
  3861. * Instantiates a bounce easing
  3862. * @see https://easings.net/#easeInBounce
  3863. * @param bounces Defines the number of bounces
  3864. * @param bounciness Defines the amplitude of the bounce
  3865. */
  3866. constructor(
  3867. /** Defines the number of bounces */
  3868. bounces?: number,
  3869. /** Defines the amplitude of the bounce */
  3870. bounciness?: number);
  3871. /** @hidden */
  3872. easeInCore(gradient: number): number;
  3873. }
  3874. /**
  3875. * Easing function with a power of 3 shape (see link below).
  3876. * @see https://easings.net/#easeInCubic
  3877. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3878. */
  3879. class CubicEase extends EasingFunction implements IEasingFunction {
  3880. /** @hidden */
  3881. easeInCore(gradient: number): number;
  3882. }
  3883. /**
  3884. * Easing function with an elastic shape (see link below).
  3885. * @see https://easings.net/#easeInElastic
  3886. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3887. */
  3888. class ElasticEase extends EasingFunction implements IEasingFunction {
  3889. /** Defines the number of oscillations*/
  3890. oscillations: number;
  3891. /** Defines the amplitude of the oscillations*/
  3892. springiness: number;
  3893. /**
  3894. * Instantiates an elastic easing function
  3895. * @see https://easings.net/#easeInElastic
  3896. * @param oscillations Defines the number of oscillations
  3897. * @param springiness Defines the amplitude of the oscillations
  3898. */
  3899. constructor(
  3900. /** Defines the number of oscillations*/
  3901. oscillations?: number,
  3902. /** Defines the amplitude of the oscillations*/
  3903. springiness?: number);
  3904. /** @hidden */
  3905. easeInCore(gradient: number): number;
  3906. }
  3907. /**
  3908. * Easing function with an exponential shape (see link below).
  3909. * @see https://easings.net/#easeInExpo
  3910. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3911. */
  3912. class ExponentialEase extends EasingFunction implements IEasingFunction {
  3913. /** Defines the exponent of the function */
  3914. exponent: number;
  3915. /**
  3916. * Instantiates an exponential easing function
  3917. * @see https://easings.net/#easeInExpo
  3918. * @param exponent Defines the exponent of the function
  3919. */
  3920. constructor(
  3921. /** Defines the exponent of the function */
  3922. exponent?: number);
  3923. /** @hidden */
  3924. easeInCore(gradient: number): number;
  3925. }
  3926. /**
  3927. * Easing function with a power shape (see link below).
  3928. * @see https://easings.net/#easeInQuad
  3929. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3930. */
  3931. class PowerEase extends EasingFunction implements IEasingFunction {
  3932. /** Defines the power of the function */
  3933. power: number;
  3934. /**
  3935. * Instantiates an power base easing function
  3936. * @see https://easings.net/#easeInQuad
  3937. * @param power Defines the power of the function
  3938. */
  3939. constructor(
  3940. /** Defines the power of the function */
  3941. power?: number);
  3942. /** @hidden */
  3943. easeInCore(gradient: number): number;
  3944. }
  3945. /**
  3946. * Easing function with a power of 2 shape (see link below).
  3947. * @see https://easings.net/#easeInQuad
  3948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3949. */
  3950. class QuadraticEase extends EasingFunction implements IEasingFunction {
  3951. /** @hidden */
  3952. easeInCore(gradient: number): number;
  3953. }
  3954. /**
  3955. * Easing function with a power of 4 shape (see link below).
  3956. * @see https://easings.net/#easeInQuart
  3957. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3958. */
  3959. class QuarticEase extends EasingFunction implements IEasingFunction {
  3960. /** @hidden */
  3961. easeInCore(gradient: number): number;
  3962. }
  3963. /**
  3964. * Easing function with a power of 5 shape (see link below).
  3965. * @see https://easings.net/#easeInQuint
  3966. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3967. */
  3968. class QuinticEase extends EasingFunction implements IEasingFunction {
  3969. /** @hidden */
  3970. easeInCore(gradient: number): number;
  3971. }
  3972. /**
  3973. * Easing function with a sin shape (see link below).
  3974. * @see https://easings.net/#easeInSine
  3975. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3976. */
  3977. class SineEase extends EasingFunction implements IEasingFunction {
  3978. /** @hidden */
  3979. easeInCore(gradient: number): number;
  3980. }
  3981. /**
  3982. * Easing function with a bezier shape (see link below).
  3983. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  3984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3985. */
  3986. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  3987. /** Defines the x component of the start tangent in the bezier curve */
  3988. x1: number;
  3989. /** Defines the y component of the start tangent in the bezier curve */
  3990. y1: number;
  3991. /** Defines the x component of the end tangent in the bezier curve */
  3992. x2: number;
  3993. /** Defines the y component of the end tangent in the bezier curve */
  3994. y2: number;
  3995. /**
  3996. * Instantiates a bezier function
  3997. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  3998. * @param x1 Defines the x component of the start tangent in the bezier curve
  3999. * @param y1 Defines the y component of the start tangent in the bezier curve
  4000. * @param x2 Defines the x component of the end tangent in the bezier curve
  4001. * @param y2 Defines the y component of the end tangent in the bezier curve
  4002. */
  4003. constructor(
  4004. /** Defines the x component of the start tangent in the bezier curve */
  4005. x1?: number,
  4006. /** Defines the y component of the start tangent in the bezier curve */
  4007. y1?: number,
  4008. /** Defines the x component of the end tangent in the bezier curve */
  4009. x2?: number,
  4010. /** Defines the y component of the end tangent in the bezier curve */
  4011. y2?: number);
  4012. /** @hidden */
  4013. easeInCore(gradient: number): number;
  4014. }
  4015. }
  4016. declare module BABYLON {
  4017. /**
  4018. * Defines a runtime animation
  4019. */
  4020. class RuntimeAnimation {
  4021. private _events;
  4022. /**
  4023. * The current frame of the runtime animation
  4024. */
  4025. private _currentFrame;
  4026. /**
  4027. * The animation used by the runtime animation
  4028. */
  4029. private _animation;
  4030. /**
  4031. * The target of the runtime animation
  4032. */
  4033. private _target;
  4034. /**
  4035. * The initiating animatable
  4036. */
  4037. private _host;
  4038. /**
  4039. * The original value of the runtime animation
  4040. */
  4041. private _originalValue;
  4042. /**
  4043. * The original blend value of the runtime animation
  4044. */
  4045. private _originalBlendValue;
  4046. /**
  4047. * The offsets cache of the runtime animation
  4048. */
  4049. private _offsetsCache;
  4050. /**
  4051. * The high limits cache of the runtime animation
  4052. */
  4053. private _highLimitsCache;
  4054. /**
  4055. * Specifies if the runtime animation has been stopped
  4056. */
  4057. private _stopped;
  4058. /**
  4059. * The blending factor of the runtime animation
  4060. */
  4061. private _blendingFactor;
  4062. /**
  4063. * The BabylonJS scene
  4064. */
  4065. private _scene;
  4066. /**
  4067. * The current value of the runtime animation
  4068. */
  4069. private _currentValue;
  4070. /** @hidden */
  4071. _workValue: any;
  4072. /**
  4073. * The active target of the runtime animation
  4074. */
  4075. private _activeTarget;
  4076. /**
  4077. * The target path of the runtime animation
  4078. */
  4079. private _targetPath;
  4080. /**
  4081. * The weight of the runtime animation
  4082. */
  4083. private _weight;
  4084. /**
  4085. * The ratio offset of the runtime animation
  4086. */
  4087. private _ratioOffset;
  4088. /**
  4089. * The previous delay of the runtime animation
  4090. */
  4091. private _previousDelay;
  4092. /**
  4093. * The previous ratio of the runtime animation
  4094. */
  4095. private _previousRatio;
  4096. /**
  4097. * Gets the current frame of the runtime animation
  4098. */
  4099. readonly currentFrame: number;
  4100. /**
  4101. * Gets the weight of the runtime animation
  4102. */
  4103. readonly weight: number;
  4104. /**
  4105. * Gets the current value of the runtime animation
  4106. */
  4107. readonly currentValue: any;
  4108. /**
  4109. * Gets the target path of the runtime animation
  4110. */
  4111. readonly targetPath: string;
  4112. /**
  4113. * Gets the actual target of the runtime animation
  4114. */
  4115. readonly target: any;
  4116. /**
  4117. * Create a new RuntimeAnimation object
  4118. * @param target defines the target of the animation
  4119. * @param animation defines the source animation object
  4120. * @param scene defines the hosting scene
  4121. * @param host defines the initiating Animatable
  4122. */
  4123. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4124. /**
  4125. * Gets the animation from the runtime animation
  4126. */
  4127. readonly animation: Animation;
  4128. /**
  4129. * Resets the runtime animation to the beginning
  4130. * @param restoreOriginal defines whether to restore the target property to the original value
  4131. */
  4132. reset(restoreOriginal?: boolean): void;
  4133. /**
  4134. * Specifies if the runtime animation is stopped
  4135. * @returns Boolean specifying if the runtime animation is stopped
  4136. */
  4137. isStopped(): boolean;
  4138. /**
  4139. * Disposes of the runtime animation
  4140. */
  4141. dispose(): void;
  4142. /**
  4143. * Interpolates the animation from the current frame
  4144. * @param currentFrame The frame to interpolate the animation to
  4145. * @param repeatCount The number of times that the animation should loop
  4146. * @param loopMode The type of looping mode to use
  4147. * @param offsetValue Animation offset value
  4148. * @param highLimitValue The high limit value
  4149. * @returns The interpolated value
  4150. */
  4151. private _interpolate;
  4152. /**
  4153. * Apply the interpolated value to the target
  4154. * @param currentValue defines the value computed by the animation
  4155. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4156. */
  4157. setValue(currentValue: any, weight?: number): void;
  4158. private _setValue;
  4159. /**
  4160. * Gets the loop pmode of the runtime animation
  4161. * @returns Loop Mode
  4162. */
  4163. private _getCorrectLoopMode;
  4164. /**
  4165. * Move the current animation to a given frame
  4166. * @param frame defines the frame to move to
  4167. */
  4168. goToFrame(frame: number): void;
  4169. /**
  4170. * @hidden Internal use only
  4171. */
  4172. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4173. /**
  4174. * Execute the current animation
  4175. * @param delay defines the delay to add to the current frame
  4176. * @param from defines the lower bound of the animation range
  4177. * @param to defines the upper bound of the animation range
  4178. * @param loop defines if the current animation must loop
  4179. * @param speedRatio defines the current speed ratio
  4180. * @param weight defines the weight of the animation (default is -1 so no weight)
  4181. * @param onLoop optional callback called when animation loops
  4182. * @returns a boolean indicating if the animation is running
  4183. */
  4184. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  4185. }
  4186. }
  4187. declare module BABYLON {
  4188. /**
  4189. * The action to be carried out following a trigger
  4190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  4191. */
  4192. class Action {
  4193. /** the trigger, with or without parameters, for the action */
  4194. triggerOptions: any;
  4195. /**
  4196. * Trigger for the action
  4197. */
  4198. trigger: number;
  4199. /**
  4200. * Internal only - manager for action
  4201. * @hidden
  4202. */
  4203. _actionManager: ActionManager;
  4204. private _nextActiveAction;
  4205. private _child;
  4206. private _condition?;
  4207. private _triggerParameter;
  4208. /**
  4209. * An event triggered prior to action being executed.
  4210. */
  4211. onBeforeExecuteObservable: Observable<Action>;
  4212. /**
  4213. * Creates a new Action
  4214. * @param triggerOptions the trigger, with or without parameters, for the action
  4215. * @param condition an optional determinant of action
  4216. */
  4217. constructor(
  4218. /** the trigger, with or without parameters, for the action */
  4219. triggerOptions: any, condition?: Condition);
  4220. /**
  4221. * Internal only
  4222. * @hidden
  4223. */
  4224. _prepare(): void;
  4225. /**
  4226. * Gets the trigger parameters
  4227. * @returns the trigger parameters
  4228. */
  4229. getTriggerParameter(): any;
  4230. /**
  4231. * Internal only - executes current action event
  4232. * @hidden
  4233. */
  4234. _executeCurrent(evt?: ActionEvent): void;
  4235. /**
  4236. * Execute placeholder for child classes
  4237. * @param evt optional action event
  4238. */
  4239. execute(evt?: ActionEvent): void;
  4240. /**
  4241. * Skips to next active action
  4242. */
  4243. skipToNextActiveAction(): void;
  4244. /**
  4245. * Adds action to chain of actions, may be a DoNothingAction
  4246. * @param action defines the next action to execute
  4247. * @returns The action passed in
  4248. * @see https://www.babylonjs-playground.com/#1T30HR#0
  4249. */
  4250. then(action: Action): Action;
  4251. /**
  4252. * Internal only
  4253. * @hidden
  4254. */
  4255. _getProperty(propertyPath: string): string;
  4256. /**
  4257. * Internal only
  4258. * @hidden
  4259. */
  4260. _getEffectiveTarget(target: any, propertyPath: string): any;
  4261. /**
  4262. * Serialize placeholder for child classes
  4263. * @param parent of child
  4264. * @returns the serialized object
  4265. */
  4266. serialize(parent: any): any;
  4267. /**
  4268. * Internal only called by serialize
  4269. * @hidden
  4270. */
  4271. protected _serialize(serializedAction: any, parent?: any): any;
  4272. /**
  4273. * Internal only
  4274. * @hidden
  4275. */
  4276. static _SerializeValueAsString: (value: any) => string;
  4277. /**
  4278. * Internal only
  4279. * @hidden
  4280. */
  4281. static _GetTargetProperty: (target: Scene | Node) => {
  4282. name: string;
  4283. targetType: string;
  4284. value: string;
  4285. };
  4286. }
  4287. }
  4288. declare module BABYLON {
  4289. /**
  4290. * ActionEvent is the event being sent when an action is triggered.
  4291. */
  4292. class ActionEvent {
  4293. /** The mesh or sprite that triggered the action */
  4294. source: any;
  4295. /** The X mouse cursor position at the time of the event */
  4296. pointerX: number;
  4297. /** The Y mouse cursor position at the time of the event */
  4298. pointerY: number;
  4299. /** The mesh that is currently pointed at (can be null) */
  4300. meshUnderPointer: Nullable<AbstractMesh>;
  4301. /** the original (browser) event that triggered the ActionEvent */
  4302. sourceEvent?: any;
  4303. /** additional data for the event */
  4304. additionalData?: any;
  4305. /**
  4306. * Creates a new ActionEvent
  4307. * @param source The mesh or sprite that triggered the action
  4308. * @param pointerX The X mouse cursor position at the time of the event
  4309. * @param pointerY The Y mouse cursor position at the time of the event
  4310. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  4311. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  4312. * @param additionalData additional data for the event
  4313. */
  4314. constructor(
  4315. /** The mesh or sprite that triggered the action */
  4316. source: any,
  4317. /** The X mouse cursor position at the time of the event */
  4318. pointerX: number,
  4319. /** The Y mouse cursor position at the time of the event */
  4320. pointerY: number,
  4321. /** The mesh that is currently pointed at (can be null) */
  4322. meshUnderPointer: Nullable<AbstractMesh>,
  4323. /** the original (browser) event that triggered the ActionEvent */
  4324. sourceEvent?: any,
  4325. /** additional data for the event */
  4326. additionalData?: any);
  4327. /**
  4328. * Helper function to auto-create an ActionEvent from a source mesh.
  4329. * @param source The source mesh that triggered the event
  4330. * @param evt The original (browser) event
  4331. * @param additionalData additional data for the event
  4332. * @returns the new ActionEvent
  4333. */
  4334. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  4335. /**
  4336. * Helper function to auto-create an ActionEvent from a source sprite
  4337. * @param source The source sprite that triggered the event
  4338. * @param scene Scene associated with the sprite
  4339. * @param evt The original (browser) event
  4340. * @param additionalData additional data for the event
  4341. * @returns the new ActionEvent
  4342. */
  4343. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  4344. /**
  4345. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  4346. * @param scene the scene where the event occurred
  4347. * @param evt The original (browser) event
  4348. * @returns the new ActionEvent
  4349. */
  4350. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  4351. /**
  4352. * Helper function to auto-create an ActionEvent from a primitive
  4353. * @param prim defines the target primitive
  4354. * @param pointerPos defines the pointer position
  4355. * @param evt The original (browser) event
  4356. * @param additionalData additional data for the event
  4357. * @returns the new ActionEvent
  4358. */
  4359. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  4360. }
  4361. /**
  4362. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  4363. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  4364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4365. */
  4366. class ActionManager {
  4367. /**
  4368. * Nothing
  4369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4370. */
  4371. static readonly NothingTrigger: number;
  4372. /**
  4373. * On pick
  4374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4375. */
  4376. static readonly OnPickTrigger: number;
  4377. /**
  4378. * On left pick
  4379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4380. */
  4381. static readonly OnLeftPickTrigger: number;
  4382. /**
  4383. * On right pick
  4384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4385. */
  4386. static readonly OnRightPickTrigger: number;
  4387. /**
  4388. * On center pick
  4389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4390. */
  4391. static readonly OnCenterPickTrigger: number;
  4392. /**
  4393. * On pick down
  4394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4395. */
  4396. static readonly OnPickDownTrigger: number;
  4397. /**
  4398. * On double pick
  4399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4400. */
  4401. static readonly OnDoublePickTrigger: number;
  4402. /**
  4403. * On pick up
  4404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4405. */
  4406. static readonly OnPickUpTrigger: number;
  4407. /**
  4408. * On pick out.
  4409. * This trigger will only be raised if you also declared a OnPickDown
  4410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4411. */
  4412. static readonly OnPickOutTrigger: number;
  4413. /**
  4414. * On long press
  4415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4416. */
  4417. static readonly OnLongPressTrigger: number;
  4418. /**
  4419. * On pointer over
  4420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4421. */
  4422. static readonly OnPointerOverTrigger: number;
  4423. /**
  4424. * On pointer out
  4425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4426. */
  4427. static readonly OnPointerOutTrigger: number;
  4428. /**
  4429. * On every frame
  4430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4431. */
  4432. static readonly OnEveryFrameTrigger: number;
  4433. /**
  4434. * On intersection enter
  4435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4436. */
  4437. static readonly OnIntersectionEnterTrigger: number;
  4438. /**
  4439. * On intersection exit
  4440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4441. */
  4442. static readonly OnIntersectionExitTrigger: number;
  4443. /**
  4444. * On key down
  4445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4446. */
  4447. static readonly OnKeyDownTrigger: number;
  4448. /**
  4449. * On key up
  4450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4451. */
  4452. static readonly OnKeyUpTrigger: number;
  4453. /** Gets the list of active triggers */
  4454. static Triggers: {
  4455. [key: string]: number;
  4456. };
  4457. /** Gets the list of actions */
  4458. actions: Action[];
  4459. /** Gets the cursor to use when hovering items */
  4460. hoverCursor: string;
  4461. private _scene;
  4462. /**
  4463. * Creates a new action manager
  4464. * @param scene defines the hosting scene
  4465. */
  4466. constructor(scene: Scene);
  4467. /**
  4468. * Releases all associated resources
  4469. */
  4470. dispose(): void;
  4471. /**
  4472. * Gets hosting scene
  4473. * @returns the hosting scene
  4474. */
  4475. getScene(): Scene;
  4476. /**
  4477. * Does this action manager handles actions of any of the given triggers
  4478. * @param triggers defines the triggers to be tested
  4479. * @return a boolean indicating whether one (or more) of the triggers is handled
  4480. */
  4481. hasSpecificTriggers(triggers: number[]): boolean;
  4482. /**
  4483. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  4484. * speed.
  4485. * @param triggerA defines the trigger to be tested
  4486. * @param triggerB defines the trigger to be tested
  4487. * @return a boolean indicating whether one (or more) of the triggers is handled
  4488. */
  4489. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  4490. /**
  4491. * Does this action manager handles actions of a given trigger
  4492. * @param trigger defines the trigger to be tested
  4493. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  4494. * @return whether the trigger is handled
  4495. */
  4496. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  4497. /**
  4498. * Does this action manager has pointer triggers
  4499. */
  4500. readonly hasPointerTriggers: boolean;
  4501. /**
  4502. * Does this action manager has pick triggers
  4503. */
  4504. readonly hasPickTriggers: boolean;
  4505. /**
  4506. * Does exist one action manager with at least one trigger
  4507. **/
  4508. static readonly HasTriggers: boolean;
  4509. /**
  4510. * Does exist one action manager with at least one pick trigger
  4511. **/
  4512. static readonly HasPickTriggers: boolean;
  4513. /**
  4514. * Does exist one action manager that handles actions of a given trigger
  4515. * @param trigger defines the trigger to be tested
  4516. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  4517. **/
  4518. static HasSpecificTrigger(trigger: number): boolean;
  4519. /**
  4520. * Registers an action to this action manager
  4521. * @param action defines the action to be registered
  4522. * @return the action amended (prepared) after registration
  4523. */
  4524. registerAction(action: Action): Nullable<Action>;
  4525. /**
  4526. * Unregisters an action to this action manager
  4527. * @param action defines the action to be unregistered
  4528. * @return a boolean indicating whether the action has been unregistered
  4529. */
  4530. unregisterAction(action: Action): Boolean;
  4531. /**
  4532. * Process a specific trigger
  4533. * @param trigger defines the trigger to process
  4534. * @param evt defines the event details to be processed
  4535. */
  4536. processTrigger(trigger: number, evt?: ActionEvent): void;
  4537. /** @hidden */
  4538. _getEffectiveTarget(target: any, propertyPath: string): any;
  4539. /** @hidden */
  4540. _getProperty(propertyPath: string): string;
  4541. /**
  4542. * Serialize this manager to a JSON object
  4543. * @param name defines the property name to store this manager
  4544. * @returns a JSON representation of this manager
  4545. */
  4546. serialize(name: string): any;
  4547. /**
  4548. * Creates a new ActionManager from a JSON data
  4549. * @param parsedActions defines the JSON data to read from
  4550. * @param object defines the hosting mesh
  4551. * @param scene defines the hosting scene
  4552. */
  4553. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  4554. /**
  4555. * Get a trigger name by index
  4556. * @param trigger defines the trigger index
  4557. * @returns a trigger name
  4558. */
  4559. static GetTriggerName(trigger: number): string;
  4560. }
  4561. }
  4562. declare module BABYLON {
  4563. /**
  4564. * A Condition applied to an Action
  4565. */
  4566. class Condition {
  4567. /**
  4568. * Internal only - manager for action
  4569. * @hidden
  4570. */
  4571. _actionManager: ActionManager;
  4572. /**
  4573. * Internal only
  4574. * @hidden
  4575. */
  4576. _evaluationId: number;
  4577. /**
  4578. * Internal only
  4579. * @hidden
  4580. */
  4581. _currentResult: boolean;
  4582. /**
  4583. * Creates a new Condition
  4584. * @param actionManager the manager of the action the condition is applied to
  4585. */
  4586. constructor(actionManager: ActionManager);
  4587. /**
  4588. * Check if the current condition is valid
  4589. * @returns a boolean
  4590. */
  4591. isValid(): boolean;
  4592. /**
  4593. * Internal only
  4594. * @hidden
  4595. */
  4596. _getProperty(propertyPath: string): string;
  4597. /**
  4598. * Internal only
  4599. * @hidden
  4600. */
  4601. _getEffectiveTarget(target: any, propertyPath: string): any;
  4602. /**
  4603. * Serialize placeholder for child classes
  4604. * @returns the serialized object
  4605. */
  4606. serialize(): any;
  4607. /**
  4608. * Internal only
  4609. * @hidden
  4610. */
  4611. protected _serialize(serializedCondition: any): any;
  4612. }
  4613. /**
  4614. * Defines specific conditional operators as extensions of Condition
  4615. */
  4616. class ValueCondition extends Condition {
  4617. /** path to specify the property of the target the conditional operator uses */
  4618. propertyPath: string;
  4619. /** the value compared by the conditional operator against the current value of the property */
  4620. value: any;
  4621. /** the conditional operator, default ValueCondition.IsEqual */
  4622. operator: number;
  4623. /**
  4624. * Internal only
  4625. * @hidden
  4626. */
  4627. private static _IsEqual;
  4628. /**
  4629. * Internal only
  4630. * @hidden
  4631. */
  4632. private static _IsDifferent;
  4633. /**
  4634. * Internal only
  4635. * @hidden
  4636. */
  4637. private static _IsGreater;
  4638. /**
  4639. * Internal only
  4640. * @hidden
  4641. */
  4642. private static _IsLesser;
  4643. /**
  4644. * returns the number for IsEqual
  4645. */
  4646. static readonly IsEqual: number;
  4647. /**
  4648. * Returns the number for IsDifferent
  4649. */
  4650. static readonly IsDifferent: number;
  4651. /**
  4652. * Returns the number for IsGreater
  4653. */
  4654. static readonly IsGreater: number;
  4655. /**
  4656. * Returns the number for IsLesser
  4657. */
  4658. static readonly IsLesser: number;
  4659. /**
  4660. * Internal only The action manager for the condition
  4661. * @hidden
  4662. */
  4663. _actionManager: ActionManager;
  4664. /**
  4665. * Internal only
  4666. * @hidden
  4667. */
  4668. private _target;
  4669. /**
  4670. * Internal only
  4671. * @hidden
  4672. */
  4673. private _effectiveTarget;
  4674. /**
  4675. * Internal only
  4676. * @hidden
  4677. */
  4678. private _property;
  4679. /**
  4680. * Creates a new ValueCondition
  4681. * @param actionManager manager for the action the condition applies to
  4682. * @param target for the action
  4683. * @param propertyPath path to specify the property of the target the conditional operator uses
  4684. * @param value the value compared by the conditional operator against the current value of the property
  4685. * @param operator the conditional operator, default ValueCondition.IsEqual
  4686. */
  4687. constructor(actionManager: ActionManager, target: any,
  4688. /** path to specify the property of the target the conditional operator uses */
  4689. propertyPath: string,
  4690. /** the value compared by the conditional operator against the current value of the property */
  4691. value: any,
  4692. /** the conditional operator, default ValueCondition.IsEqual */
  4693. operator?: number);
  4694. /**
  4695. * Compares the given value with the property value for the specified conditional operator
  4696. * @returns the result of the comparison
  4697. */
  4698. isValid(): boolean;
  4699. /**
  4700. * Serialize the ValueCondition into a JSON compatible object
  4701. * @returns serialization object
  4702. */
  4703. serialize(): any;
  4704. /**
  4705. * Gets the name of the conditional operator for the ValueCondition
  4706. * @param operator the conditional operator
  4707. * @returns the name
  4708. */
  4709. static GetOperatorName(operator: number): string;
  4710. }
  4711. /**
  4712. * Defines a predicate condition as an extension of Condition
  4713. */
  4714. class PredicateCondition extends Condition {
  4715. /** defines the predicate function used to validate the condition */
  4716. predicate: () => boolean;
  4717. /**
  4718. * Internal only - manager for action
  4719. * @hidden
  4720. */
  4721. _actionManager: ActionManager;
  4722. /**
  4723. * Creates a new PredicateCondition
  4724. * @param actionManager manager for the action the condition applies to
  4725. * @param predicate defines the predicate function used to validate the condition
  4726. */
  4727. constructor(actionManager: ActionManager,
  4728. /** defines the predicate function used to validate the condition */
  4729. predicate: () => boolean);
  4730. /**
  4731. * @returns the validity of the predicate condition
  4732. */
  4733. isValid(): boolean;
  4734. }
  4735. /**
  4736. * Defines a state condition as an extension of Condition
  4737. */
  4738. class StateCondition extends Condition {
  4739. /** Value to compare with target state */
  4740. value: string;
  4741. /**
  4742. * Internal only - manager for action
  4743. * @hidden
  4744. */
  4745. _actionManager: ActionManager;
  4746. /**
  4747. * Internal only
  4748. * @hidden
  4749. */
  4750. private _target;
  4751. /**
  4752. * Creates a new StateCondition
  4753. * @param actionManager manager for the action the condition applies to
  4754. * @param target of the condition
  4755. * @param value to compare with target state
  4756. */
  4757. constructor(actionManager: ActionManager, target: any,
  4758. /** Value to compare with target state */
  4759. value: string);
  4760. /**
  4761. * Gets a boolean indicating if the current condition is met
  4762. * @returns the validity of the state
  4763. */
  4764. isValid(): boolean;
  4765. /**
  4766. * Serialize the StateCondition into a JSON compatible object
  4767. * @returns serialization object
  4768. */
  4769. serialize(): any;
  4770. }
  4771. }
  4772. declare module BABYLON {
  4773. /**
  4774. * This defines an action responsible to toggle a boolean once triggered.
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4776. */
  4777. class SwitchBooleanAction extends Action {
  4778. /**
  4779. * The path to the boolean property in the target object
  4780. */
  4781. propertyPath: string;
  4782. private _target;
  4783. private _effectiveTarget;
  4784. private _property;
  4785. /**
  4786. * Instantiate the action
  4787. * @param triggerOptions defines the trigger options
  4788. * @param target defines the object containing the boolean
  4789. * @param propertyPath defines the path to the boolean property in the target object
  4790. * @param condition defines the trigger related conditions
  4791. */
  4792. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  4793. /** @hidden */
  4794. _prepare(): void;
  4795. /**
  4796. * Execute the action toggle the boolean value.
  4797. */
  4798. execute(): void;
  4799. /**
  4800. * Serializes the actions and its related information.
  4801. * @param parent defines the object to serialize in
  4802. * @returns the serialized object
  4803. */
  4804. serialize(parent: any): any;
  4805. }
  4806. /**
  4807. * This defines an action responsible to set a the state field of the target
  4808. * to a desired value once triggered.
  4809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4810. */
  4811. class SetStateAction extends Action {
  4812. /**
  4813. * The value to store in the state field.
  4814. */
  4815. value: string;
  4816. private _target;
  4817. /**
  4818. * Instantiate the action
  4819. * @param triggerOptions defines the trigger options
  4820. * @param target defines the object containing the state property
  4821. * @param value defines the value to store in the state field
  4822. * @param condition defines the trigger related conditions
  4823. */
  4824. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  4825. /**
  4826. * Execute the action and store the value on the target state property.
  4827. */
  4828. execute(): void;
  4829. /**
  4830. * Serializes the actions and its related information.
  4831. * @param parent defines the object to serialize in
  4832. * @returns the serialized object
  4833. */
  4834. serialize(parent: any): any;
  4835. }
  4836. /**
  4837. * This defines an action responsible to set a property of the target
  4838. * to a desired value once triggered.
  4839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4840. */
  4841. class SetValueAction extends Action {
  4842. /**
  4843. * The path of the property to set in the target.
  4844. */
  4845. propertyPath: string;
  4846. /**
  4847. * The value to set in the property
  4848. */
  4849. value: any;
  4850. private _target;
  4851. private _effectiveTarget;
  4852. private _property;
  4853. /**
  4854. * Instantiate the action
  4855. * @param triggerOptions defines the trigger options
  4856. * @param target defines the object containing the property
  4857. * @param propertyPath defines the path of the property to set in the target
  4858. * @param value defines the value to set in the property
  4859. * @param condition defines the trigger related conditions
  4860. */
  4861. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  4862. /** @hidden */
  4863. _prepare(): void;
  4864. /**
  4865. * Execute the action and set the targetted property to the desired value.
  4866. */
  4867. execute(): void;
  4868. /**
  4869. * Serializes the actions and its related information.
  4870. * @param parent defines the object to serialize in
  4871. * @returns the serialized object
  4872. */
  4873. serialize(parent: any): any;
  4874. }
  4875. /**
  4876. * This defines an action responsible to increment the target value
  4877. * to a desired value once triggered.
  4878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4879. */
  4880. class IncrementValueAction extends Action {
  4881. /**
  4882. * The path of the property to increment in the target.
  4883. */
  4884. propertyPath: string;
  4885. /**
  4886. * The value we should increment the property by.
  4887. */
  4888. value: any;
  4889. private _target;
  4890. private _effectiveTarget;
  4891. private _property;
  4892. /**
  4893. * Instantiate the action
  4894. * @param triggerOptions defines the trigger options
  4895. * @param target defines the object containing the property
  4896. * @param propertyPath defines the path of the property to increment in the target
  4897. * @param value defines the value value we should increment the property by
  4898. * @param condition defines the trigger related conditions
  4899. */
  4900. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  4901. /** @hidden */
  4902. _prepare(): void;
  4903. /**
  4904. * Execute the action and increment the target of the value amount.
  4905. */
  4906. execute(): void;
  4907. /**
  4908. * Serializes the actions and its related information.
  4909. * @param parent defines the object to serialize in
  4910. * @returns the serialized object
  4911. */
  4912. serialize(parent: any): any;
  4913. }
  4914. /**
  4915. * This defines an action responsible to start an animation once triggered.
  4916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4917. */
  4918. class PlayAnimationAction extends Action {
  4919. /**
  4920. * Where the animation should start (animation frame)
  4921. */
  4922. from: number;
  4923. /**
  4924. * Where the animation should stop (animation frame)
  4925. */
  4926. to: number;
  4927. /**
  4928. * Define if the animation should loop or stop after the first play.
  4929. */
  4930. loop?: boolean;
  4931. private _target;
  4932. /**
  4933. * Instantiate the action
  4934. * @param triggerOptions defines the trigger options
  4935. * @param target defines the target animation or animation name
  4936. * @param from defines from where the animation should start (animation frame)
  4937. * @param end defines where the animation should stop (animation frame)
  4938. * @param loop defines if the animation should loop or stop after the first play
  4939. * @param condition defines the trigger related conditions
  4940. */
  4941. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  4942. /** @hidden */
  4943. _prepare(): void;
  4944. /**
  4945. * Execute the action and play the animation.
  4946. */
  4947. execute(): void;
  4948. /**
  4949. * Serializes the actions and its related information.
  4950. * @param parent defines the object to serialize in
  4951. * @returns the serialized object
  4952. */
  4953. serialize(parent: any): any;
  4954. }
  4955. /**
  4956. * This defines an action responsible to stop an animation once triggered.
  4957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4958. */
  4959. class StopAnimationAction extends Action {
  4960. private _target;
  4961. /**
  4962. * Instantiate the action
  4963. * @param triggerOptions defines the trigger options
  4964. * @param target defines the target animation or animation name
  4965. * @param condition defines the trigger related conditions
  4966. */
  4967. constructor(triggerOptions: any, target: any, condition?: Condition);
  4968. /** @hidden */
  4969. _prepare(): void;
  4970. /**
  4971. * Execute the action and stop the animation.
  4972. */
  4973. execute(): void;
  4974. /**
  4975. * Serializes the actions and its related information.
  4976. * @param parent defines the object to serialize in
  4977. * @returns the serialized object
  4978. */
  4979. serialize(parent: any): any;
  4980. }
  4981. /**
  4982. * This defines an action responsible that does nothing once triggered.
  4983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4984. */
  4985. class DoNothingAction extends Action {
  4986. /**
  4987. * Instantiate the action
  4988. * @param triggerOptions defines the trigger options
  4989. * @param condition defines the trigger related conditions
  4990. */
  4991. constructor(triggerOptions?: any, condition?: Condition);
  4992. /**
  4993. * Execute the action and do nothing.
  4994. */
  4995. execute(): void;
  4996. /**
  4997. * Serializes the actions and its related information.
  4998. * @param parent defines the object to serialize in
  4999. * @returns the serialized object
  5000. */
  5001. serialize(parent: any): any;
  5002. }
  5003. /**
  5004. * This defines an action responsible to trigger several actions once triggered.
  5005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5006. */
  5007. class CombineAction extends Action {
  5008. /**
  5009. * The list of aggregated animations to run.
  5010. */
  5011. children: Action[];
  5012. /**
  5013. * Instantiate the action
  5014. * @param triggerOptions defines the trigger options
  5015. * @param children defines the list of aggregated animations to run
  5016. * @param condition defines the trigger related conditions
  5017. */
  5018. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  5019. /** @hidden */
  5020. _prepare(): void;
  5021. /**
  5022. * Execute the action and executes all the aggregated actions.
  5023. */
  5024. execute(evt: ActionEvent): void;
  5025. /**
  5026. * Serializes the actions and its related information.
  5027. * @param parent defines the object to serialize in
  5028. * @returns the serialized object
  5029. */
  5030. serialize(parent: any): any;
  5031. }
  5032. /**
  5033. * This defines an action responsible to run code (external event) once triggered.
  5034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5035. */
  5036. class ExecuteCodeAction extends Action {
  5037. /**
  5038. * The callback function to run.
  5039. */
  5040. func: (evt: ActionEvent) => void;
  5041. /**
  5042. * Instantiate the action
  5043. * @param triggerOptions defines the trigger options
  5044. * @param func defines the callback function to run
  5045. * @param condition defines the trigger related conditions
  5046. */
  5047. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  5048. /**
  5049. * Execute the action and run the attached code.
  5050. */
  5051. execute(evt: ActionEvent): void;
  5052. }
  5053. /**
  5054. * This defines an action responsible to set the parent property of the target once triggered.
  5055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5056. */
  5057. class SetParentAction extends Action {
  5058. private _parent;
  5059. private _target;
  5060. /**
  5061. * Instantiate the action
  5062. * @param triggerOptions defines the trigger options
  5063. * @param target defines the target containing the parent property
  5064. * @param parent defines from where the animation should start (animation frame)
  5065. * @param condition defines the trigger related conditions
  5066. */
  5067. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  5068. /** @hidden */
  5069. _prepare(): void;
  5070. /**
  5071. * Execute the action and set the parent property.
  5072. */
  5073. execute(): void;
  5074. /**
  5075. * Serializes the actions and its related information.
  5076. * @param parent defines the object to serialize in
  5077. * @returns the serialized object
  5078. */
  5079. serialize(parent: any): any;
  5080. }
  5081. }
  5082. declare module BABYLON {
  5083. /**
  5084. * This defines an action helpful to play a defined sound on a triggered action.
  5085. */
  5086. class PlaySoundAction extends Action {
  5087. private _sound;
  5088. /**
  5089. * Instantiate the action
  5090. * @param triggerOptions defines the trigger options
  5091. * @param sound defines the sound to play
  5092. * @param condition defines the trigger related conditions
  5093. */
  5094. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  5095. /** @hidden */
  5096. _prepare(): void;
  5097. /**
  5098. * Execute the action and play the sound.
  5099. */
  5100. execute(): void;
  5101. /**
  5102. * Serializes the actions and its related information.
  5103. * @param parent defines the object to serialize in
  5104. * @returns the serialized object
  5105. */
  5106. serialize(parent: any): any;
  5107. }
  5108. /**
  5109. * This defines an action helpful to stop a defined sound on a triggered action.
  5110. */
  5111. class StopSoundAction extends Action {
  5112. private _sound;
  5113. /**
  5114. * Instantiate the action
  5115. * @param triggerOptions defines the trigger options
  5116. * @param sound defines the sound to stop
  5117. * @param condition defines the trigger related conditions
  5118. */
  5119. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  5120. /** @hidden */
  5121. _prepare(): void;
  5122. /**
  5123. * Execute the action and stop the sound.
  5124. */
  5125. execute(): void;
  5126. /**
  5127. * Serializes the actions and its related information.
  5128. * @param parent defines the object to serialize in
  5129. * @returns the serialized object
  5130. */
  5131. serialize(parent: any): any;
  5132. }
  5133. }
  5134. declare module BABYLON {
  5135. /**
  5136. * This defines an action responsible to change the value of a property
  5137. * by interpolating between its current value and the newly set one once triggered.
  5138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5139. */
  5140. class InterpolateValueAction extends Action {
  5141. /**
  5142. * Defines the path of the property where the value should be interpolated
  5143. */
  5144. propertyPath: string;
  5145. /**
  5146. * Defines the target value at the end of the interpolation.
  5147. */
  5148. value: any;
  5149. /**
  5150. * Defines the time it will take for the property to interpolate to the value.
  5151. */
  5152. duration: number;
  5153. /**
  5154. * Defines if the other scene animations should be stopped when the action has been triggered
  5155. */
  5156. stopOtherAnimations?: boolean;
  5157. /**
  5158. * Defines a callback raised once the interpolation animation has been done.
  5159. */
  5160. onInterpolationDone?: () => void;
  5161. /**
  5162. * Observable triggered once the interpolation animation has been done.
  5163. */
  5164. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  5165. private _target;
  5166. private _effectiveTarget;
  5167. private _property;
  5168. /**
  5169. * Instantiate the action
  5170. * @param triggerOptions defines the trigger options
  5171. * @param target defines the object containing the value to interpolate
  5172. * @param propertyPath defines the path to the property in the target object
  5173. * @param value defines the target value at the end of the interpolation
  5174. * @param duration deines the time it will take for the property to interpolate to the value.
  5175. * @param condition defines the trigger related conditions
  5176. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  5177. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  5178. */
  5179. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  5180. /** @hidden */
  5181. _prepare(): void;
  5182. /**
  5183. * Execute the action starts the value interpolation.
  5184. */
  5185. execute(): void;
  5186. /**
  5187. * Serializes the actions and its related information.
  5188. * @param parent defines the object to serialize in
  5189. * @returns the serialized object
  5190. */
  5191. serialize(parent: any): any;
  5192. }
  5193. }
  5194. declare module BABYLON {
  5195. /**
  5196. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5198. */
  5199. class Analyser {
  5200. /**
  5201. * Gets or sets the smoothing
  5202. * @ignorenaming
  5203. */
  5204. SMOOTHING: number;
  5205. /**
  5206. * Gets or sets the FFT table size
  5207. * @ignorenaming
  5208. */
  5209. FFT_SIZE: number;
  5210. /**
  5211. * Gets or sets the bar graph amplitude
  5212. * @ignorenaming
  5213. */
  5214. BARGRAPHAMPLITUDE: number;
  5215. /**
  5216. * Gets or sets the position of the debug canvas
  5217. * @ignorenaming
  5218. */
  5219. DEBUGCANVASPOS: {
  5220. x: number;
  5221. y: number;
  5222. };
  5223. /**
  5224. * Gets or sets the debug canvas size
  5225. * @ignorenaming
  5226. */
  5227. DEBUGCANVASSIZE: {
  5228. width: number;
  5229. height: number;
  5230. };
  5231. private _byteFreqs;
  5232. private _byteTime;
  5233. private _floatFreqs;
  5234. private _webAudioAnalyser;
  5235. private _debugCanvas;
  5236. private _debugCanvasContext;
  5237. private _scene;
  5238. private _registerFunc;
  5239. private _audioEngine;
  5240. /**
  5241. * Creates a new analyser
  5242. * @param scene defines hosting scene
  5243. */
  5244. constructor(scene: Scene);
  5245. /**
  5246. * Get the number of data values you will have to play with for the visualization
  5247. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5248. * @returns a number
  5249. */
  5250. getFrequencyBinCount(): number;
  5251. /**
  5252. * Gets the current frequency data as a byte array
  5253. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5254. * @returns a Uint8Array
  5255. */
  5256. getByteFrequencyData(): Uint8Array;
  5257. /**
  5258. * Gets the current waveform as a byte array
  5259. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5260. * @returns a Uint8Array
  5261. */
  5262. getByteTimeDomainData(): Uint8Array;
  5263. /**
  5264. * Gets the current frequency data as a float array
  5265. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5266. * @returns a Float32Array
  5267. */
  5268. getFloatFrequencyData(): Float32Array;
  5269. /**
  5270. * Renders the debug canvas
  5271. */
  5272. drawDebugCanvas(): void;
  5273. /**
  5274. * Stops rendering the debug canvas and removes it
  5275. */
  5276. stopDebugCanvas(): void;
  5277. /**
  5278. * Connects two audio nodes
  5279. * @param inputAudioNode defines first node to connect
  5280. * @param outputAudioNode defines second node to connect
  5281. */
  5282. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5283. /**
  5284. * Releases all associated resources
  5285. */
  5286. dispose(): void;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * This represents an audio engine and it is responsible
  5292. * to play, synchronize and analyse sounds throughout the application.
  5293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5294. */
  5295. interface IAudioEngine extends IDisposable {
  5296. /**
  5297. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5298. */
  5299. readonly canUseWebAudio: boolean;
  5300. /**
  5301. * Gets the current AudioContext if available.
  5302. */
  5303. readonly audioContext: Nullable<AudioContext>;
  5304. /**
  5305. * The master gain node defines the global audio volume of your audio engine.
  5306. */
  5307. readonly masterGain: GainNode;
  5308. /**
  5309. * Gets whether or not mp3 are supported by your browser.
  5310. */
  5311. readonly isMP3supported: boolean;
  5312. /**
  5313. * Gets whether or not ogg are supported by your browser.
  5314. */
  5315. readonly isOGGsupported: boolean;
  5316. /**
  5317. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5318. * @ignoreNaming
  5319. */
  5320. WarnedWebAudioUnsupported: boolean;
  5321. /**
  5322. * Defines if the audio engine relies on a custom unlocked button.
  5323. * In this case, the embedded button will not be displayed.
  5324. */
  5325. useCustomUnlockedButton: boolean;
  5326. /**
  5327. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5328. */
  5329. readonly unlocked: boolean;
  5330. /**
  5331. * Event raised when audio has been unlocked on the browser.
  5332. */
  5333. onAudioUnlockedObservable: Observable<AudioEngine>;
  5334. /**
  5335. * Event raised when audio has been locked on the browser.
  5336. */
  5337. onAudioLockedObservable: Observable<AudioEngine>;
  5338. /**
  5339. * Flags the audio engine in Locked state.
  5340. * This happens due to new browser policies preventing audio to autoplay.
  5341. */
  5342. lock(): void;
  5343. /**
  5344. * Unlocks the audio engine once a user action has been done on the dom.
  5345. * This is helpful to resume play once browser policies have been satisfied.
  5346. */
  5347. unlock(): void;
  5348. }
  5349. /**
  5350. * This represents the default audio engine used in babylon.
  5351. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5353. */
  5354. class AudioEngine implements IAudioEngine {
  5355. private _audioContext;
  5356. private _audioContextInitialized;
  5357. private _muteButton;
  5358. private _hostElement;
  5359. /**
  5360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5361. */
  5362. canUseWebAudio: boolean;
  5363. /**
  5364. * The master gain node defines the global audio volume of your audio engine.
  5365. */
  5366. masterGain: GainNode;
  5367. /**
  5368. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5369. * @ignoreNaming
  5370. */
  5371. WarnedWebAudioUnsupported: boolean;
  5372. /**
  5373. * Gets whether or not mp3 are supported by your browser.
  5374. */
  5375. isMP3supported: boolean;
  5376. /**
  5377. * Gets whether or not ogg are supported by your browser.
  5378. */
  5379. isOGGsupported: boolean;
  5380. /**
  5381. * Gets whether audio has been unlocked on the device.
  5382. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5383. * a user interaction has happened.
  5384. */
  5385. unlocked: boolean;
  5386. /**
  5387. * Defines if the audio engine relies on a custom unlocked button.
  5388. * In this case, the embedded button will not be displayed.
  5389. */
  5390. useCustomUnlockedButton: boolean;
  5391. /**
  5392. * Event raised when audio has been unlocked on the browser.
  5393. */
  5394. onAudioUnlockedObservable: Observable<AudioEngine>;
  5395. /**
  5396. * Event raised when audio has been locked on the browser.
  5397. */
  5398. onAudioLockedObservable: Observable<AudioEngine>;
  5399. /**
  5400. * Gets the current AudioContext if available.
  5401. */
  5402. readonly audioContext: Nullable<AudioContext>;
  5403. private _connectedAnalyser;
  5404. /**
  5405. * Instantiates a new audio engine.
  5406. *
  5407. * There should be only one per page as some browsers restrict the number
  5408. * of audio contexts you can create.
  5409. * @param hostElement defines the host element where to display the mute icon if necessary
  5410. */
  5411. constructor(hostElement?: Nullable<HTMLElement>);
  5412. /**
  5413. * Flags the audio engine in Locked state.
  5414. * This happens due to new browser policies preventing audio to autoplay.
  5415. */
  5416. lock(): void;
  5417. /**
  5418. * Unlocks the audio engine once a user action has been done on the dom.
  5419. * This is helpful to resume play once browser policies have been satisfied.
  5420. */
  5421. unlock(): void;
  5422. private _resumeAudioContext;
  5423. private _initializeAudioContext;
  5424. private _tryToRun;
  5425. private _triggerRunningState;
  5426. private _triggerSuspendedState;
  5427. private _displayMuteButton;
  5428. private _moveButtonToTopLeft;
  5429. private _onResize;
  5430. private _hideMuteButton;
  5431. /**
  5432. * Destroy and release the resources associated with the audio ccontext.
  5433. */
  5434. dispose(): void;
  5435. /**
  5436. * Gets the global volume sets on the master gain.
  5437. * @returns the global volume if set or -1 otherwise
  5438. */
  5439. getGlobalVolume(): number;
  5440. /**
  5441. * Sets the global volume of your experience (sets on the master gain).
  5442. * @param newVolume Defines the new global volume of the application
  5443. */
  5444. setGlobalVolume(newVolume: number): void;
  5445. /**
  5446. * Connect the audio engine to an audio analyser allowing some amazing
  5447. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5449. * @param analyser The analyser to connect to the engine
  5450. */
  5451. connectToAnalyser(analyser: Analyser): void;
  5452. }
  5453. }
  5454. declare module BABYLON {
  5455. interface AbstractScene {
  5456. /**
  5457. * The list of sounds used in the scene.
  5458. */
  5459. sounds: Nullable<Array<Sound>>;
  5460. }
  5461. interface Scene {
  5462. /**
  5463. * @hidden
  5464. * Backing field
  5465. */
  5466. _mainSoundTrack: SoundTrack;
  5467. /**
  5468. * The main sound track played by the scene.
  5469. * It cotains your primary collection of sounds.
  5470. */
  5471. mainSoundTrack: SoundTrack;
  5472. /**
  5473. * The list of sound tracks added to the scene
  5474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5475. */
  5476. soundTracks: Nullable<Array<SoundTrack>>;
  5477. /**
  5478. * Gets a sound using a given name
  5479. * @param name defines the name to search for
  5480. * @return the found sound or null if not found at all.
  5481. */
  5482. getSoundByName(name: string): Nullable<Sound>;
  5483. /**
  5484. * Gets or sets if audio support is enabled
  5485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5486. */
  5487. audioEnabled: boolean;
  5488. /**
  5489. * Gets or sets if audio will be output to headphones
  5490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5491. */
  5492. headphone: boolean;
  5493. }
  5494. /**
  5495. * Defines the sound scene component responsible to manage any sounds
  5496. * in a given scene.
  5497. */
  5498. class AudioSceneComponent implements ISceneSerializableComponent {
  5499. /**
  5500. * The component name helpfull to identify the component in the list of scene components.
  5501. */
  5502. readonly name: string;
  5503. /**
  5504. * The scene the component belongs to.
  5505. */
  5506. scene: Scene;
  5507. private _audioEnabled;
  5508. /**
  5509. * Gets whether audio is enabled or not.
  5510. * Please use related enable/disable method to switch state.
  5511. */
  5512. readonly audioEnabled: boolean;
  5513. private _headphone;
  5514. /**
  5515. * Gets whether audio is outputing to headphone or not.
  5516. * Please use the according Switch methods to change output.
  5517. */
  5518. readonly headphone: boolean;
  5519. /**
  5520. * Creates a new instance of the component for the given scene
  5521. * @param scene Defines the scene to register the component in
  5522. */
  5523. constructor(scene: Scene);
  5524. /**
  5525. * Registers the component in a given scene
  5526. */
  5527. register(): void;
  5528. /**
  5529. * Rebuilds the elements related to this component in case of
  5530. * context lost for instance.
  5531. */
  5532. rebuild(): void;
  5533. /**
  5534. * Serializes the component data to the specified json object
  5535. * @param serializationObject The object to serialize to
  5536. */
  5537. serialize(serializationObject: any): void;
  5538. /**
  5539. * Adds all the element from the container to the scene
  5540. * @param container the container holding the elements
  5541. */
  5542. addFromContainer(container: AbstractScene): void;
  5543. /**
  5544. * Removes all the elements in the container from the scene
  5545. * @param container contains the elements to remove
  5546. */
  5547. removeFromContainer(container: AbstractScene): void;
  5548. /**
  5549. * Disposes the component and the associated ressources.
  5550. */
  5551. dispose(): void;
  5552. /**
  5553. * Disables audio in the associated scene.
  5554. */
  5555. disableAudio(): void;
  5556. /**
  5557. * Enables audio in the associated scene.
  5558. */
  5559. enableAudio(): void;
  5560. /**
  5561. * Switch audio to headphone output.
  5562. */
  5563. switchAudioModeForHeadphones(): void;
  5564. /**
  5565. * Switch audio to normal speakers.
  5566. */
  5567. switchAudioModeForNormalSpeakers(): void;
  5568. private _afterRender;
  5569. }
  5570. }
  5571. declare module BABYLON {
  5572. /**
  5573. * Defines a sound that can be played in the application.
  5574. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5576. */
  5577. class Sound {
  5578. /**
  5579. * The name of the sound in the scene.
  5580. */
  5581. name: string;
  5582. /**
  5583. * Does the sound autoplay once loaded.
  5584. */
  5585. autoplay: boolean;
  5586. /**
  5587. * Does the sound loop after it finishes playing once.
  5588. */
  5589. loop: boolean;
  5590. /**
  5591. * Does the sound use a custom attenuation curve to simulate the falloff
  5592. * happening when the source gets further away from the camera.
  5593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5594. */
  5595. useCustomAttenuation: boolean;
  5596. /**
  5597. * The sound track id this sound belongs to.
  5598. */
  5599. soundTrackId: number;
  5600. /**
  5601. * Is this sound currently played.
  5602. */
  5603. isPlaying: boolean;
  5604. /**
  5605. * Is this sound currently paused.
  5606. */
  5607. isPaused: boolean;
  5608. /**
  5609. * Does this sound enables spatial sound.
  5610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5611. */
  5612. spatialSound: boolean;
  5613. /**
  5614. * Define the reference distance the sound should be heard perfectly.
  5615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5616. */
  5617. refDistance: number;
  5618. /**
  5619. * Define the roll off factor of spatial sounds.
  5620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5621. */
  5622. rolloffFactor: number;
  5623. /**
  5624. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5626. */
  5627. maxDistance: number;
  5628. /**
  5629. * Define the distance attenuation model the sound will follow.
  5630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5631. */
  5632. distanceModel: string;
  5633. /**
  5634. * @hidden
  5635. * Back Compat
  5636. **/
  5637. onended: () => any;
  5638. /**
  5639. * Observable event when the current playing sound finishes.
  5640. */
  5641. onEndedObservable: Observable<Sound>;
  5642. private _panningModel;
  5643. private _playbackRate;
  5644. private _streaming;
  5645. private _startTime;
  5646. private _startOffset;
  5647. private _position;
  5648. /** @hidden */
  5649. _positionInEmitterSpace: boolean;
  5650. private _localDirection;
  5651. private _volume;
  5652. private _isReadyToPlay;
  5653. private _isDirectional;
  5654. private _readyToPlayCallback;
  5655. private _audioBuffer;
  5656. private _soundSource;
  5657. private _streamingSource;
  5658. private _soundPanner;
  5659. private _soundGain;
  5660. private _inputAudioNode;
  5661. private _outputAudioNode;
  5662. private _coneInnerAngle;
  5663. private _coneOuterAngle;
  5664. private _coneOuterGain;
  5665. private _scene;
  5666. private _connectedTransformNode;
  5667. private _customAttenuationFunction;
  5668. private _registerFunc;
  5669. private _isOutputConnected;
  5670. private _htmlAudioElement;
  5671. private _urlType;
  5672. /**
  5673. * Create a sound and attach it to a scene
  5674. * @param name Name of your sound
  5675. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5676. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5677. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5678. */
  5679. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5680. /**
  5681. * Release the sound and its associated resources
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Gets if the sounds is ready to be played or not.
  5686. * @returns true if ready, otherwise false
  5687. */
  5688. isReady(): boolean;
  5689. private _soundLoaded;
  5690. /**
  5691. * Sets the data of the sound from an audiobuffer
  5692. * @param audioBuffer The audioBuffer containing the data
  5693. */
  5694. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5695. /**
  5696. * Updates the current sounds options such as maxdistance, loop...
  5697. * @param options A JSON object containing values named as the object properties
  5698. */
  5699. updateOptions(options: any): void;
  5700. private _createSpatialParameters;
  5701. private _updateSpatialParameters;
  5702. /**
  5703. * Switch the panning model to HRTF:
  5704. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5706. */
  5707. switchPanningModelToHRTF(): void;
  5708. /**
  5709. * Switch the panning model to Equal Power:
  5710. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5712. */
  5713. switchPanningModelToEqualPower(): void;
  5714. private _switchPanningModel;
  5715. /**
  5716. * Connect this sound to a sound track audio node like gain...
  5717. * @param soundTrackAudioNode the sound track audio node to connect to
  5718. */
  5719. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5720. /**
  5721. * Transform this sound into a directional source
  5722. * @param coneInnerAngle Size of the inner cone in degree
  5723. * @param coneOuterAngle Size of the outer cone in degree
  5724. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5725. */
  5726. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5727. /**
  5728. * Gets or sets the inner angle for the directional cone.
  5729. */
  5730. /**
  5731. * Gets or sets the inner angle for the directional cone.
  5732. */
  5733. directionalConeInnerAngle: number;
  5734. /**
  5735. * Gets or sets the outer angle for the directional cone.
  5736. */
  5737. /**
  5738. * Gets or sets the outer angle for the directional cone.
  5739. */
  5740. directionalConeOuterAngle: number;
  5741. /**
  5742. * Sets the position of the emitter if spatial sound is enabled
  5743. * @param newPosition Defines the new posisiton
  5744. */
  5745. setPosition(newPosition: Vector3): void;
  5746. /**
  5747. * Sets the local direction of the emitter if spatial sound is enabled
  5748. * @param newLocalDirection Defines the new local direction
  5749. */
  5750. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5751. private _updateDirection;
  5752. /** @hidden */
  5753. updateDistanceFromListener(): void;
  5754. /**
  5755. * Sets a new custom attenuation function for the sound.
  5756. * @param callback Defines the function used for the attenuation
  5757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5758. */
  5759. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5760. /**
  5761. * Play the sound
  5762. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5763. * @param offset (optional) Start the sound setting it at a specific time
  5764. */
  5765. play(time?: number, offset?: number): void;
  5766. private _onended;
  5767. /**
  5768. * Stop the sound
  5769. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5770. */
  5771. stop(time?: number): void;
  5772. /**
  5773. * Put the sound in pause
  5774. */
  5775. pause(): void;
  5776. /**
  5777. * Sets a dedicated volume for this sounds
  5778. * @param newVolume Define the new volume of the sound
  5779. * @param time Define in how long the sound should be at this value
  5780. */
  5781. setVolume(newVolume: number, time?: number): void;
  5782. /**
  5783. * Set the sound play back rate
  5784. * @param newPlaybackRate Define the playback rate the sound should be played at
  5785. */
  5786. setPlaybackRate(newPlaybackRate: number): void;
  5787. /**
  5788. * Gets the volume of the sound.
  5789. * @returns the volume of the sound
  5790. */
  5791. getVolume(): number;
  5792. /**
  5793. * Attach the sound to a dedicated mesh
  5794. * @param transformNode The transform node to connect the sound with
  5795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5796. */
  5797. attachToMesh(transformNode: TransformNode): void;
  5798. /**
  5799. * Detach the sound from the previously attached mesh
  5800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5801. */
  5802. detachFromMesh(): void;
  5803. private _onRegisterAfterWorldMatrixUpdate;
  5804. /**
  5805. * Clone the current sound in the scene.
  5806. * @returns the new sound clone
  5807. */
  5808. clone(): Nullable<Sound>;
  5809. /**
  5810. * Gets the current underlying audio buffer containing the data
  5811. * @returns the audio buffer
  5812. */
  5813. getAudioBuffer(): Nullable<AudioBuffer>;
  5814. /**
  5815. * Serializes the Sound in a JSON representation
  5816. * @returns the JSON representation of the sound
  5817. */
  5818. serialize(): any;
  5819. /**
  5820. * Parse a JSON representation of a sound to innstantiate in a given scene
  5821. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5822. * @param scene Define the scene the new parsed sound should be created in
  5823. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5824. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5825. * @returns the newly parsed sound
  5826. */
  5827. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5828. }
  5829. }
  5830. declare module BABYLON {
  5831. /**
  5832. * Options allowed during the creation of a sound track.
  5833. */
  5834. interface ISoundTrackOptions {
  5835. /**
  5836. * The volume the sound track should take during creation
  5837. */
  5838. volume?: number;
  5839. /**
  5840. * Define if the sound track is the main sound track of the scene
  5841. */
  5842. mainTrack?: boolean;
  5843. }
  5844. /**
  5845. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5846. * It will be also used in a future release to apply effects on a specific track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. */
  5849. class SoundTrack {
  5850. /**
  5851. * The unique identifier of the sound track in the scene.
  5852. */
  5853. id: number;
  5854. /**
  5855. * The list of sounds included in the sound track.
  5856. */
  5857. soundCollection: Array<Sound>;
  5858. private _outputAudioNode;
  5859. private _scene;
  5860. private _isMainTrack;
  5861. private _connectedAnalyser;
  5862. private _options;
  5863. private _isInitialized;
  5864. /**
  5865. * Creates a new sound track.
  5866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5867. * @param scene Define the scene the sound track belongs to
  5868. * @param options
  5869. */
  5870. constructor(scene: Scene, options?: ISoundTrackOptions);
  5871. private _initializeSoundTrackAudioGraph;
  5872. /**
  5873. * Release the sound track and its associated resources
  5874. */
  5875. dispose(): void;
  5876. /**
  5877. * Adds a sound to this sound track
  5878. * @param sound define the cound to add
  5879. * @ignoreNaming
  5880. */
  5881. AddSound(sound: Sound): void;
  5882. /**
  5883. * Removes a sound to this sound track
  5884. * @param sound define the cound to remove
  5885. * @ignoreNaming
  5886. */
  5887. RemoveSound(sound: Sound): void;
  5888. /**
  5889. * Set a global volume for the full sound track.
  5890. * @param newVolume Define the new volume of the sound track
  5891. */
  5892. setVolume(newVolume: number): void;
  5893. /**
  5894. * Switch the panning model to HRTF:
  5895. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5897. */
  5898. switchPanningModelToHRTF(): void;
  5899. /**
  5900. * Switch the panning model to Equal Power:
  5901. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5903. */
  5904. switchPanningModelToEqualPower(): void;
  5905. /**
  5906. * Connect the sound track to an audio analyser allowing some amazing
  5907. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5909. * @param analyser The analyser to connect to the engine
  5910. */
  5911. connectToAnalyser(analyser: Analyser): void;
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. /**
  5916. * Wraps one or more Sound objects and selects one with random weight for playback.
  5917. */
  5918. class WeightedSound {
  5919. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5920. loop: boolean;
  5921. private _coneInnerAngle;
  5922. private _coneOuterAngle;
  5923. private _volume;
  5924. /** A Sound is currently playing. */
  5925. isPlaying: boolean;
  5926. /** A Sound is currently paused. */
  5927. isPaused: boolean;
  5928. private _sounds;
  5929. private _weights;
  5930. private _currentIndex?;
  5931. /**
  5932. * Creates a new WeightedSound from the list of sounds given.
  5933. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5934. * @param sounds Array of Sounds that will be selected from.
  5935. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5936. */
  5937. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5938. /**
  5939. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5940. */
  5941. /**
  5942. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5943. */
  5944. directionalConeInnerAngle: number;
  5945. /**
  5946. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5947. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5948. */
  5949. /**
  5950. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5951. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5952. */
  5953. directionalConeOuterAngle: number;
  5954. /**
  5955. * Playback volume.
  5956. */
  5957. /**
  5958. * Playback volume.
  5959. */
  5960. volume: number;
  5961. private _onended;
  5962. /**
  5963. * Suspend playback
  5964. */
  5965. pause(): void;
  5966. /**
  5967. * Stop playback
  5968. */
  5969. stop(): void;
  5970. /**
  5971. * Start playback.
  5972. * @param startOffset Position the clip head at a specific time in seconds.
  5973. */
  5974. play(startOffset?: number): void;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. /**
  5979. * Interface used to define a behavior
  5980. */
  5981. interface Behavior<T> {
  5982. /** gets or sets behavior's name */
  5983. name: string;
  5984. /**
  5985. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5986. */
  5987. init(): void;
  5988. /**
  5989. * Called when the behavior is attached to a target
  5990. * @param target defines the target where the behavior is attached to
  5991. */
  5992. attach(target: T): void;
  5993. /**
  5994. * Called when the behavior is detached from its target
  5995. */
  5996. detach(): void;
  5997. }
  5998. /**
  5999. * Interface implemented by classes supporting behaviors
  6000. */
  6001. interface IBehaviorAware<T> {
  6002. /**
  6003. * Attach a behavior
  6004. * @param behavior defines the behavior to attach
  6005. * @returns the current host
  6006. */
  6007. addBehavior(behavior: Behavior<T>): T;
  6008. /**
  6009. * Remove a behavior from the current object
  6010. * @param behavior defines the behavior to detach
  6011. * @returns the current host
  6012. */
  6013. removeBehavior(behavior: Behavior<T>): T;
  6014. /**
  6015. * Gets a behavior using its name to search
  6016. * @param name defines the name to search
  6017. * @returns the behavior or null if not found
  6018. */
  6019. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6020. }
  6021. }
  6022. declare module BABYLON {
  6023. /**
  6024. * Class used to store bone information
  6025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6026. */
  6027. class Bone extends Node {
  6028. /**
  6029. * defines the bone name
  6030. */
  6031. name: string;
  6032. private static _tmpVecs;
  6033. private static _tmpQuat;
  6034. private static _tmpMats;
  6035. /**
  6036. * Gets the list of child bones
  6037. */
  6038. children: Bone[];
  6039. /** Gets the animations associated with this bone */
  6040. animations: Animation[];
  6041. /**
  6042. * Gets or sets bone length
  6043. */
  6044. length: number;
  6045. /**
  6046. * @hidden Internal only
  6047. * Set this value to map this bone to a different index in the transform matrices
  6048. * Set this value to -1 to exclude the bone from the transform matrices
  6049. */
  6050. _index: Nullable<number>;
  6051. private _skeleton;
  6052. private _localMatrix;
  6053. private _restPose;
  6054. private _baseMatrix;
  6055. private _absoluteTransform;
  6056. private _invertedAbsoluteTransform;
  6057. private _parent;
  6058. private _scalingDeterminant;
  6059. private _worldTransform;
  6060. private _localScaling;
  6061. private _localRotation;
  6062. private _localPosition;
  6063. private _needToDecompose;
  6064. private _needToCompose;
  6065. /** @hidden */
  6066. _linkedTransformNode: Nullable<TransformNode>;
  6067. /** @hidden */
  6068. /** @hidden */
  6069. _matrix: Matrix;
  6070. /**
  6071. * Create a new bone
  6072. * @param name defines the bone name
  6073. * @param skeleton defines the parent skeleton
  6074. * @param parentBone defines the parent (can be null if the bone is the root)
  6075. * @param localMatrix defines the local matrix
  6076. * @param restPose defines the rest pose matrix
  6077. * @param baseMatrix defines the base matrix
  6078. * @param index defines index of the bone in the hiearchy
  6079. */
  6080. constructor(
  6081. /**
  6082. * defines the bone name
  6083. */
  6084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6085. /**
  6086. * Gets the parent skeleton
  6087. * @returns a skeleton
  6088. */
  6089. getSkeleton(): Skeleton;
  6090. /**
  6091. * Gets parent bone
  6092. * @returns a bone or null if the bone is the root of the bone hierarchy
  6093. */
  6094. getParent(): Nullable<Bone>;
  6095. /**
  6096. * Sets the parent bone
  6097. * @param parent defines the parent (can be null if the bone is the root)
  6098. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6099. */
  6100. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6101. /**
  6102. * Gets the local matrix
  6103. * @returns a matrix
  6104. */
  6105. getLocalMatrix(): Matrix;
  6106. /**
  6107. * Gets the base matrix (initial matrix which remains unchanged)
  6108. * @returns a matrix
  6109. */
  6110. getBaseMatrix(): Matrix;
  6111. /**
  6112. * Gets the rest pose matrix
  6113. * @returns a matrix
  6114. */
  6115. getRestPose(): Matrix;
  6116. /**
  6117. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6118. */
  6119. getWorldMatrix(): Matrix;
  6120. /**
  6121. * Sets the local matrix to rest pose matrix
  6122. */
  6123. returnToRest(): void;
  6124. /**
  6125. * Gets the inverse of the absolute transform matrix.
  6126. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6127. * @returns a matrix
  6128. */
  6129. getInvertedAbsoluteTransform(): Matrix;
  6130. /**
  6131. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6132. * @returns a matrix
  6133. */
  6134. getAbsoluteTransform(): Matrix;
  6135. /**
  6136. * Links with the given transform node.
  6137. * The local matrix of this bone is copied from the transform node every frame.
  6138. * @param transformNode defines the transform node to link to
  6139. */
  6140. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6141. /** Gets or sets current position (in local space) */
  6142. position: Vector3;
  6143. /** Gets or sets current rotation (in local space) */
  6144. rotation: Vector3;
  6145. /** Gets or sets current rotation quaternion (in local space) */
  6146. rotationQuaternion: Quaternion;
  6147. /** Gets or sets current scaling (in local space) */
  6148. scaling: Vector3;
  6149. /**
  6150. * Gets the animation properties override
  6151. */
  6152. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6153. private _decompose;
  6154. private _compose;
  6155. /**
  6156. * Update the base and local matrices
  6157. * @param matrix defines the new base or local matrix
  6158. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6159. * @param updateLocalMatrix defines if the local matrix should be updated
  6160. */
  6161. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6162. /** @hidden */
  6163. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6164. /**
  6165. * Flag the bone as dirty (Forcing it to update everything)
  6166. */
  6167. markAsDirty(): void;
  6168. private _markAsDirtyAndCompose;
  6169. private _markAsDirtyAndDecompose;
  6170. /**
  6171. * Copy an animation range from another bone
  6172. * @param source defines the source bone
  6173. * @param rangeName defines the range name to copy
  6174. * @param frameOffset defines the frame offset
  6175. * @param rescaleAsRequired defines if rescaling must be applied if required
  6176. * @param skelDimensionsRatio defines the scaling ratio
  6177. * @returns true if operation was successful
  6178. */
  6179. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6180. /**
  6181. * Translate the bone in local or world space
  6182. * @param vec The amount to translate the bone
  6183. * @param space The space that the translation is in
  6184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6185. */
  6186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6187. /**
  6188. * Set the postion of the bone in local or world space
  6189. * @param position The position to set the bone
  6190. * @param space The space that the position is in
  6191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6192. */
  6193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6194. /**
  6195. * Set the absolute position of the bone (world space)
  6196. * @param position The position to set the bone
  6197. * @param mesh The mesh that this bone is attached to
  6198. */
  6199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6200. /**
  6201. * Scale the bone on the x, y and z axes (in local space)
  6202. * @param x The amount to scale the bone on the x axis
  6203. * @param y The amount to scale the bone on the y axis
  6204. * @param z The amount to scale the bone on the z axis
  6205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6206. */
  6207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6208. /**
  6209. * Set the bone scaling in local space
  6210. * @param scale defines the scaling vector
  6211. */
  6212. setScale(scale: Vector3): void;
  6213. /**
  6214. * Gets the current scaling in local space
  6215. * @returns the current scaling vector
  6216. */
  6217. getScale(): Vector3;
  6218. /**
  6219. * Gets the current scaling in local space and stores it in a target vector
  6220. * @param result defines the target vector
  6221. */
  6222. getScaleToRef(result: Vector3): void;
  6223. /**
  6224. * Set the yaw, pitch, and roll of the bone in local or world space
  6225. * @param yaw The rotation of the bone on the y axis
  6226. * @param pitch The rotation of the bone on the x axis
  6227. * @param roll The rotation of the bone on the z axis
  6228. * @param space The space that the axes of rotation are in
  6229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6230. */
  6231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6232. /**
  6233. * Add a rotation to the bone on an axis in local or world space
  6234. * @param axis The axis to rotate the bone on
  6235. * @param amount The amount to rotate the bone
  6236. * @param space The space that the axis is in
  6237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6238. */
  6239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6240. /**
  6241. * Set the rotation of the bone to a particular axis angle in local or world space
  6242. * @param axis The axis to rotate the bone on
  6243. * @param angle The angle that the bone should be rotated to
  6244. * @param space The space that the axis is in
  6245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6246. */
  6247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6248. /**
  6249. * Set the euler rotation of the bone in local of world space
  6250. * @param rotation The euler rotation that the bone should be set to
  6251. * @param space The space that the rotation is in
  6252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6253. */
  6254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6255. /**
  6256. * Set the quaternion rotation of the bone in local of world space
  6257. * @param quat The quaternion rotation that the bone should be set to
  6258. * @param space The space that the rotation is in
  6259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6260. */
  6261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6262. /**
  6263. * Set the rotation matrix of the bone in local of world space
  6264. * @param rotMat The rotation matrix that the bone should be set to
  6265. * @param space The space that the rotation is in
  6266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6267. */
  6268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6269. private _rotateWithMatrix;
  6270. private _getNegativeRotationToRef;
  6271. /**
  6272. * Get the position of the bone in local or world space
  6273. * @param space The space that the returned position is in
  6274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6275. * @returns The position of the bone
  6276. */
  6277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6278. /**
  6279. * Copy the position of the bone to a vector3 in local or world space
  6280. * @param space The space that the returned position is in
  6281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6282. * @param result The vector3 to copy the position to
  6283. */
  6284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6285. /**
  6286. * Get the absolute position of the bone (world space)
  6287. * @param mesh The mesh that this bone is attached to
  6288. * @returns The absolute position of the bone
  6289. */
  6290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6291. /**
  6292. * Copy the absolute position of the bone (world space) to the result param
  6293. * @param mesh The mesh that this bone is attached to
  6294. * @param result The vector3 to copy the absolute position to
  6295. */
  6296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6297. /**
  6298. * Compute the absolute transforms of this bone and its children
  6299. */
  6300. computeAbsoluteTransforms(): void;
  6301. /**
  6302. * Get the world direction from an axis that is in the local space of the bone
  6303. * @param localAxis The local direction that is used to compute the world direction
  6304. * @param mesh The mesh that this bone is attached to
  6305. * @returns The world direction
  6306. */
  6307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6308. /**
  6309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6310. * @param localAxis The local direction that is used to compute the world direction
  6311. * @param mesh The mesh that this bone is attached to
  6312. * @param result The vector3 that the world direction will be copied to
  6313. */
  6314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6315. /**
  6316. * Get the euler rotation of the bone in local or world space
  6317. * @param space The space that the rotation should be in
  6318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6319. * @returns The euler rotation
  6320. */
  6321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6322. /**
  6323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6324. * @param space The space that the rotation should be in
  6325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6326. * @param result The vector3 that the rotation should be copied to
  6327. */
  6328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6329. /**
  6330. * Get the quaternion rotation of the bone in either local or world space
  6331. * @param space The space that the rotation should be in
  6332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6333. * @returns The quaternion rotation
  6334. */
  6335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6336. /**
  6337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6338. * @param space The space that the rotation should be in
  6339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6340. * @param result The quaternion that the rotation should be copied to
  6341. */
  6342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6343. /**
  6344. * Get the rotation matrix of the bone in local or world space
  6345. * @param space The space that the rotation should be in
  6346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6347. * @returns The rotation matrix
  6348. */
  6349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6350. /**
  6351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6352. * @param space The space that the rotation should be in
  6353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6354. * @param result The quaternion that the rotation should be copied to
  6355. */
  6356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6357. /**
  6358. * Get the world position of a point that is in the local space of the bone
  6359. * @param position The local position
  6360. * @param mesh The mesh that this bone is attached to
  6361. * @returns The world position
  6362. */
  6363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6364. /**
  6365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6366. * @param position The local position
  6367. * @param mesh The mesh that this bone is attached to
  6368. * @param result The vector3 that the world position should be copied to
  6369. */
  6370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6371. /**
  6372. * Get the local position of a point that is in world space
  6373. * @param position The world position
  6374. * @param mesh The mesh that this bone is attached to
  6375. * @returns The local position
  6376. */
  6377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6378. /**
  6379. * Get the local position of a point that is in world space and copy it to the result param
  6380. * @param position The world position
  6381. * @param mesh The mesh that this bone is attached to
  6382. * @param result The vector3 that the local position should be copied to
  6383. */
  6384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6385. }
  6386. }
  6387. declare module BABYLON {
  6388. /**
  6389. * Class used to apply inverse kinematics to bones
  6390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6391. */
  6392. class BoneIKController {
  6393. private static _tmpVecs;
  6394. private static _tmpQuat;
  6395. private static _tmpMats;
  6396. /**
  6397. * Gets or sets the target mesh
  6398. */
  6399. targetMesh: AbstractMesh;
  6400. /** Gets or sets the mesh used as pole */
  6401. poleTargetMesh: AbstractMesh;
  6402. /**
  6403. * Gets or sets the bone used as pole
  6404. */
  6405. poleTargetBone: Nullable<Bone>;
  6406. /**
  6407. * Gets or sets the target position
  6408. */
  6409. targetPosition: Vector3;
  6410. /**
  6411. * Gets or sets the pole target position
  6412. */
  6413. poleTargetPosition: Vector3;
  6414. /**
  6415. * Gets or sets the pole target local offset
  6416. */
  6417. poleTargetLocalOffset: Vector3;
  6418. /**
  6419. * Gets or sets the pole angle
  6420. */
  6421. poleAngle: number;
  6422. /**
  6423. * Gets or sets the mesh associated with the controller
  6424. */
  6425. mesh: AbstractMesh;
  6426. /**
  6427. * 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)
  6428. */
  6429. slerpAmount: number;
  6430. private _bone1Quat;
  6431. private _bone1Mat;
  6432. private _bone2Ang;
  6433. private _bone1;
  6434. private _bone2;
  6435. private _bone1Length;
  6436. private _bone2Length;
  6437. private _maxAngle;
  6438. private _maxReach;
  6439. private _rightHandedSystem;
  6440. private _bendAxis;
  6441. private _slerping;
  6442. private _adjustRoll;
  6443. /**
  6444. * Gets or sets maximum allowed angle
  6445. */
  6446. maxAngle: number;
  6447. /**
  6448. * Creates a new BoneIKController
  6449. * @param mesh defines the mesh to control
  6450. * @param bone defines the bone to control
  6451. * @param options defines options to set up the controller
  6452. */
  6453. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6454. targetMesh?: AbstractMesh;
  6455. poleTargetMesh?: AbstractMesh;
  6456. poleTargetBone?: Bone;
  6457. poleTargetLocalOffset?: Vector3;
  6458. poleAngle?: number;
  6459. bendAxis?: Vector3;
  6460. maxAngle?: number;
  6461. slerpAmount?: number;
  6462. });
  6463. private _setMaxAngle;
  6464. /**
  6465. * Force the controller to update the bones
  6466. */
  6467. update(): void;
  6468. }
  6469. }
  6470. declare module BABYLON {
  6471. /**
  6472. * Class used to make a bone look toward a point in space
  6473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6474. */
  6475. class BoneLookController {
  6476. private static _tmpVecs;
  6477. private static _tmpQuat;
  6478. private static _tmpMats;
  6479. /**
  6480. * The target Vector3 that the bone will look at
  6481. */
  6482. target: Vector3;
  6483. /**
  6484. * The mesh that the bone is attached to
  6485. */
  6486. mesh: AbstractMesh;
  6487. /**
  6488. * The bone that will be looking to the target
  6489. */
  6490. bone: Bone;
  6491. /**
  6492. * The up axis of the coordinate system that is used when the bone is rotated
  6493. */
  6494. upAxis: Vector3;
  6495. /**
  6496. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6497. */
  6498. upAxisSpace: Space;
  6499. /**
  6500. * Used to make an adjustment to the yaw of the bone
  6501. */
  6502. adjustYaw: number;
  6503. /**
  6504. * Used to make an adjustment to the pitch of the bone
  6505. */
  6506. adjustPitch: number;
  6507. /**
  6508. * Used to make an adjustment to the roll of the bone
  6509. */
  6510. adjustRoll: number;
  6511. /**
  6512. * 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)
  6513. */
  6514. slerpAmount: number;
  6515. private _minYaw;
  6516. private _maxYaw;
  6517. private _minPitch;
  6518. private _maxPitch;
  6519. private _minYawSin;
  6520. private _minYawCos;
  6521. private _maxYawSin;
  6522. private _maxYawCos;
  6523. private _midYawConstraint;
  6524. private _minPitchTan;
  6525. private _maxPitchTan;
  6526. private _boneQuat;
  6527. private _slerping;
  6528. private _transformYawPitch;
  6529. private _transformYawPitchInv;
  6530. private _firstFrameSkipped;
  6531. private _yawRange;
  6532. private _fowardAxis;
  6533. /**
  6534. * Gets or sets the minimum yaw angle that the bone can look to
  6535. */
  6536. minYaw: number;
  6537. /**
  6538. * Gets or sets the maximum yaw angle that the bone can look to
  6539. */
  6540. maxYaw: number;
  6541. /**
  6542. * Gets or sets the minimum pitch angle that the bone can look to
  6543. */
  6544. minPitch: number;
  6545. /**
  6546. * Gets or sets the maximum pitch angle that the bone can look to
  6547. */
  6548. maxPitch: number;
  6549. /**
  6550. * Create a BoneLookController
  6551. * @param mesh the mesh that the bone belongs to
  6552. * @param bone the bone that will be looking to the target
  6553. * @param target the target Vector3 to look at
  6554. * @param settings optional settings:
  6555. * * maxYaw: the maximum angle the bone will yaw to
  6556. * * minYaw: the minimum angle the bone will yaw to
  6557. * * maxPitch: the maximum angle the bone will pitch to
  6558. * * minPitch: the minimum angle the bone will yaw to
  6559. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6560. * * upAxis: the up axis of the coordinate system
  6561. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6562. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6563. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6564. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6565. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6566. * * adjustRoll: used to make an adjustment to the roll of the bone
  6567. **/
  6568. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6569. maxYaw?: number;
  6570. minYaw?: number;
  6571. maxPitch?: number;
  6572. minPitch?: number;
  6573. slerpAmount?: number;
  6574. upAxis?: Vector3;
  6575. upAxisSpace?: Space;
  6576. yawAxis?: Vector3;
  6577. pitchAxis?: Vector3;
  6578. adjustYaw?: number;
  6579. adjustPitch?: number;
  6580. adjustRoll?: number;
  6581. });
  6582. /**
  6583. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6584. */
  6585. update(): void;
  6586. private _getAngleDiff;
  6587. private _getAngleBetween;
  6588. private _isAngleBetween;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * Class used to handle skinning animations
  6594. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6595. */
  6596. class Skeleton implements IAnimatable {
  6597. /** defines the skeleton name */
  6598. name: string;
  6599. /** defines the skeleton Id */
  6600. id: string;
  6601. /**
  6602. * Defines the list of child bones
  6603. */
  6604. bones: Bone[];
  6605. /**
  6606. * Defines an estimate of the dimension of the skeleton at rest
  6607. */
  6608. dimensionsAtRest: Vector3;
  6609. /**
  6610. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6611. */
  6612. needInitialSkinMatrix: boolean;
  6613. /**
  6614. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6615. */
  6616. overrideMesh: Nullable<AbstractMesh>;
  6617. /**
  6618. * Gets the list of animations attached to this skeleton
  6619. */
  6620. animations: Array<Animation>;
  6621. private _scene;
  6622. private _isDirty;
  6623. private _transformMatrices;
  6624. private _transformMatrixTexture;
  6625. private _meshesWithPoseMatrix;
  6626. private _animatables;
  6627. private _identity;
  6628. private _synchronizedWithMesh;
  6629. private _ranges;
  6630. private _lastAbsoluteTransformsUpdateId;
  6631. private _canUseTextureForBones;
  6632. /** @hidden */
  6633. _numBonesWithLinkedTransformNode: number;
  6634. /**
  6635. * Specifies if the skeleton should be serialized
  6636. */
  6637. doNotSerialize: boolean;
  6638. /**
  6639. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6640. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6641. */
  6642. useTextureToStoreBoneMatrices: boolean;
  6643. private _animationPropertiesOverride;
  6644. /**
  6645. * Gets or sets the animation properties override
  6646. */
  6647. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6648. /**
  6649. * An observable triggered before computing the skeleton's matrices
  6650. */
  6651. onBeforeComputeObservable: Observable<Skeleton>;
  6652. /**
  6653. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6654. */
  6655. readonly isUsingTextureForMatrices: boolean;
  6656. /**
  6657. * Creates a new skeleton
  6658. * @param name defines the skeleton name
  6659. * @param id defines the skeleton Id
  6660. * @param scene defines the hosting scene
  6661. */
  6662. constructor(
  6663. /** defines the skeleton name */
  6664. name: string,
  6665. /** defines the skeleton Id */
  6666. id: string, scene: Scene);
  6667. /**
  6668. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6669. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6670. * @returns a Float32Array containing matrices data
  6671. */
  6672. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6673. /**
  6674. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6675. * @returns a raw texture containing the data
  6676. */
  6677. getTransformMatrixTexture(): Nullable<RawTexture>;
  6678. /**
  6679. * Gets the current hosting scene
  6680. * @returns a scene object
  6681. */
  6682. getScene(): Scene;
  6683. /**
  6684. * Gets a string representing the current skeleton data
  6685. * @param fullDetails defines a boolean indicating if we want a verbose version
  6686. * @returns a string representing the current skeleton data
  6687. */
  6688. toString(fullDetails?: boolean): string;
  6689. /**
  6690. * Get bone's index searching by name
  6691. * @param name defines bone's name to search for
  6692. * @return the indice of the bone. Returns -1 if not found
  6693. */
  6694. getBoneIndexByName(name: string): number;
  6695. /**
  6696. * Creater a new animation range
  6697. * @param name defines the name of the range
  6698. * @param from defines the start key
  6699. * @param to defines the end key
  6700. */
  6701. createAnimationRange(name: string, from: number, to: number): void;
  6702. /**
  6703. * Delete a specific animation range
  6704. * @param name defines the name of the range
  6705. * @param deleteFrames defines if frames must be removed as well
  6706. */
  6707. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6708. /**
  6709. * Gets a specific animation range
  6710. * @param name defines the name of the range to look for
  6711. * @returns the requested animation range or null if not found
  6712. */
  6713. getAnimationRange(name: string): Nullable<AnimationRange>;
  6714. /**
  6715. * Gets the list of all animation ranges defined on this skeleton
  6716. * @returns an array
  6717. */
  6718. getAnimationRanges(): Nullable<AnimationRange>[];
  6719. /**
  6720. * Copy animation range from a source skeleton.
  6721. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6722. * @param source defines the source skeleton
  6723. * @param name defines the name of the range to copy
  6724. * @param rescaleAsRequired defines if rescaling must be applied if required
  6725. * @returns true if operation was successful
  6726. */
  6727. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6728. /**
  6729. * Forces the skeleton to go to rest pose
  6730. */
  6731. returnToRest(): void;
  6732. private _getHighestAnimationFrame;
  6733. /**
  6734. * Begin a specific animation range
  6735. * @param name defines the name of the range to start
  6736. * @param loop defines if looping must be turned on (false by default)
  6737. * @param speedRatio defines the speed ratio to apply (1 by default)
  6738. * @param onAnimationEnd defines a callback which will be called when animation will end
  6739. * @returns a new animatable
  6740. */
  6741. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6742. /** @hidden */
  6743. _markAsDirty(): void;
  6744. /** @hidden */
  6745. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6746. /** @hidden */
  6747. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6748. private _computeTransformMatrices;
  6749. /**
  6750. * Build all resources required to render a skeleton
  6751. */
  6752. prepare(): void;
  6753. /**
  6754. * Gets the list of animatables currently running for this skeleton
  6755. * @returns an array of animatables
  6756. */
  6757. getAnimatables(): IAnimatable[];
  6758. /**
  6759. * Clone the current skeleton
  6760. * @param name defines the name of the new skeleton
  6761. * @param id defines the id of the enw skeleton
  6762. * @returns the new skeleton
  6763. */
  6764. clone(name: string, id: string): Skeleton;
  6765. /**
  6766. * Enable animation blending for this skeleton
  6767. * @param blendingSpeed defines the blending speed to apply
  6768. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6769. */
  6770. enableBlending(blendingSpeed?: number): void;
  6771. /**
  6772. * Releases all resources associated with the current skeleton
  6773. */
  6774. dispose(): void;
  6775. /**
  6776. * Serialize the skeleton in a JSON object
  6777. * @returns a JSON object
  6778. */
  6779. serialize(): any;
  6780. /**
  6781. * Creates a new skeleton from serialized data
  6782. * @param parsedSkeleton defines the serialized data
  6783. * @param scene defines the hosting scene
  6784. * @returns a new skeleton
  6785. */
  6786. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6787. /**
  6788. * Compute all node absolute transforms
  6789. * @param forceUpdate defines if computation must be done even if cache is up to date
  6790. */
  6791. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6792. /**
  6793. * Gets the root pose matrix
  6794. * @returns a matrix
  6795. */
  6796. getPoseMatrix(): Nullable<Matrix>;
  6797. /**
  6798. * Sorts bones per internal index
  6799. */
  6800. sortBones(): void;
  6801. private _sortBones;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /**
  6806. * Class used to store bounding box information
  6807. */
  6808. class BoundingBox implements ICullable {
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in local space
  6811. */
  6812. readonly vectors: Vector3[];
  6813. /**
  6814. * Gets the center of the bounding box in local space
  6815. */
  6816. readonly center: Vector3;
  6817. /**
  6818. * Gets the center of the bounding box in world space
  6819. */
  6820. readonly centerWorld: Vector3;
  6821. /**
  6822. * Gets the extend size in local space
  6823. */
  6824. readonly extendSize: Vector3;
  6825. /**
  6826. * Gets the extend size in world space
  6827. */
  6828. readonly extendSizeWorld: Vector3;
  6829. /**
  6830. * Gets the OBB (object bounding box) directions
  6831. */
  6832. readonly directions: Vector3[];
  6833. /**
  6834. * Gets the 8 vectors representing the bounding box in world space
  6835. */
  6836. readonly vectorsWorld: Vector3[];
  6837. /**
  6838. * Gets the minimum vector in world space
  6839. */
  6840. readonly minimumWorld: Vector3;
  6841. /**
  6842. * Gets the maximum vector in world space
  6843. */
  6844. readonly maximumWorld: Vector3;
  6845. /**
  6846. * Gets the minimum vector in local space
  6847. */
  6848. readonly minimum: Vector3;
  6849. /**
  6850. * Gets the maximum vector in local space
  6851. */
  6852. readonly maximum: Vector3;
  6853. private _worldMatrix;
  6854. private static readonly TmpVector3;
  6855. /**
  6856. * @hidden
  6857. */
  6858. _tag: number;
  6859. /**
  6860. * Creates a new bounding box
  6861. * @param min defines the minimum vector (in local space)
  6862. * @param max defines the maximum vector (in local space)
  6863. * @param worldMatrix defines the new world matrix
  6864. */
  6865. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6866. /**
  6867. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6868. * @param min defines the new minimum vector (in local space)
  6869. * @param max defines the new maximum vector (in local space)
  6870. * @param worldMatrix defines the new world matrix
  6871. */
  6872. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6873. /**
  6874. * Scale the current bounding box by applying a scale factor
  6875. * @param factor defines the scale factor to apply
  6876. * @returns the current bounding box
  6877. */
  6878. scale(factor: number): BoundingBox;
  6879. /**
  6880. * Gets the world matrix of the bounding box
  6881. * @returns a matrix
  6882. */
  6883. getWorldMatrix(): DeepImmutable<Matrix>;
  6884. /** @hidden */
  6885. _update(world: DeepImmutable<Matrix>): void;
  6886. /**
  6887. * Tests if the bounding box is intersecting the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an intersection
  6890. */
  6891. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if the bounding box is entirely inside the frustum planes
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if there is an inclusion
  6896. */
  6897. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if a point is inside the bounding box
  6900. * @param point defines the point to test
  6901. * @returns true if the point is inside the bounding box
  6902. */
  6903. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a bounding sphere
  6906. * @param sphere defines the sphere to test
  6907. * @returns true if there is an intersection
  6908. */
  6909. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6910. /**
  6911. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6912. * @param min defines the min vector to use
  6913. * @param max defines the max vector to use
  6914. * @returns true if there is an intersection
  6915. */
  6916. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6917. /**
  6918. * Tests if two bounding boxes are intersections
  6919. * @param box0 defines the first box to test
  6920. * @param box1 defines the second box to test
  6921. * @returns true if there is an intersection
  6922. */
  6923. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6924. /**
  6925. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6926. * @param minPoint defines the minimum vector of the bounding box
  6927. * @param maxPoint defines the maximum vector of the bounding box
  6928. * @param sphereCenter defines the sphere center
  6929. * @param sphereRadius defines the sphere radius
  6930. * @returns true if there is an intersection
  6931. */
  6932. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6933. /**
  6934. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6935. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6936. * @param frustumPlanes defines the frustum planes to test
  6937. * @return true if there is an inclusion
  6938. */
  6939. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6940. /**
  6941. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6942. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6943. * @param frustumPlanes defines the frustum planes to test
  6944. * @return true if there is an intersection
  6945. */
  6946. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6947. }
  6948. }
  6949. declare module BABYLON {
  6950. /**
  6951. * Interface for cullable objects
  6952. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6953. */
  6954. interface ICullable {
  6955. /**
  6956. * Checks if the object or part of the object is in the frustum
  6957. * @param frustumPlanes Camera near/planes
  6958. * @returns true if the object is in frustum otherwise false
  6959. */
  6960. isInFrustum(frustumPlanes: Plane[]): boolean;
  6961. /**
  6962. * Checks if a cullable object (mesh...) is in the camera frustum
  6963. * Unlike isInFrustum this cheks the full bounding box
  6964. * @param frustumPlanes Camera near/planes
  6965. * @returns true if the object is in frustum otherwise false
  6966. */
  6967. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6968. }
  6969. /**
  6970. * Info for a bounding data of a mesh
  6971. */
  6972. class BoundingInfo implements ICullable {
  6973. /**
  6974. * Bounding box for the mesh
  6975. */
  6976. readonly boundingBox: BoundingBox;
  6977. /**
  6978. * Bounding sphere for the mesh
  6979. */
  6980. readonly boundingSphere: BoundingSphere;
  6981. private _isLocked;
  6982. private static readonly TmpVector3;
  6983. /**
  6984. * Constructs bounding info
  6985. * @param minimum min vector of the bounding box/sphere
  6986. * @param maximum max vector of the bounding box/sphere
  6987. * @param worldMatrix defines the new world matrix
  6988. */
  6989. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6990. /**
  6991. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6992. * @param min defines the new minimum vector (in local space)
  6993. * @param max defines the new maximum vector (in local space)
  6994. * @param worldMatrix defines the new world matrix
  6995. */
  6996. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6997. /**
  6998. * min vector of the bounding box/sphere
  6999. */
  7000. readonly minimum: Vector3;
  7001. /**
  7002. * max vector of the bounding box/sphere
  7003. */
  7004. readonly maximum: Vector3;
  7005. /**
  7006. * If the info is locked and won't be updated to avoid perf overhead
  7007. */
  7008. isLocked: boolean;
  7009. /**
  7010. * Updates the bounding sphere and box
  7011. * @param world world matrix to be used to update
  7012. */
  7013. update(world: DeepImmutable<Matrix>): void;
  7014. /**
  7015. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7016. * @param center New center of the bounding info
  7017. * @param extend New extend of the bounding info
  7018. * @returns the current bounding info
  7019. */
  7020. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7021. /**
  7022. * Scale the current bounding info by applying a scale factor
  7023. * @param factor defines the scale factor to apply
  7024. * @returns the current bounding info
  7025. */
  7026. scale(factor: number): BoundingInfo;
  7027. /**
  7028. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7029. * @param frustumPlanes defines the frustum to test
  7030. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7031. * @returns true if the bounding info is in the frustum planes
  7032. */
  7033. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7034. /**
  7035. * Gets the world distance between the min and max points of the bounding box
  7036. */
  7037. readonly diagonalLength: number;
  7038. /**
  7039. * Checks if a cullable object (mesh...) is in the camera frustum
  7040. * Unlike isInFrustum this cheks the full bounding box
  7041. * @param frustumPlanes Camera near/planes
  7042. * @returns true if the object is in frustum otherwise false
  7043. */
  7044. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7045. /** @hidden */
  7046. _checkCollision(collider: Collider): boolean;
  7047. /**
  7048. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7049. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7050. * @param point the point to check intersection with
  7051. * @returns if the point intersects
  7052. */
  7053. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7054. /**
  7055. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7056. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7057. * @param boundingInfo the bounding info to check intersection with
  7058. * @param precise if the intersection should be done using OBB
  7059. * @returns if the bounding info intersects
  7060. */
  7061. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7062. }
  7063. }
  7064. declare module BABYLON {
  7065. /**
  7066. * Class used to store bounding sphere information
  7067. */
  7068. class BoundingSphere {
  7069. /**
  7070. * Gets the center of the bounding sphere in local space
  7071. */
  7072. readonly center: Vector3;
  7073. /**
  7074. * Radius of the bounding sphere in local space
  7075. */
  7076. radius: number;
  7077. /**
  7078. * Gets the center of the bounding sphere in world space
  7079. */
  7080. readonly centerWorld: Vector3;
  7081. /**
  7082. * Radius of the bounding sphere in world space
  7083. */
  7084. radiusWorld: number;
  7085. /**
  7086. * Gets the minimum vector in local space
  7087. */
  7088. readonly minimum: Vector3;
  7089. /**
  7090. * Gets the maximum vector in local space
  7091. */
  7092. readonly maximum: Vector3;
  7093. private _worldMatrix;
  7094. private static readonly TmpVector3;
  7095. /**
  7096. * Creates a new bounding sphere
  7097. * @param min defines the minimum vector (in local space)
  7098. * @param max defines the maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7102. /**
  7103. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7104. * @param min defines the new minimum vector (in local space)
  7105. * @param max defines the new maximum vector (in local space)
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7109. /**
  7110. * Scale the current bounding sphere by applying a scale factor
  7111. * @param factor defines the scale factor to apply
  7112. * @returns the current bounding box
  7113. */
  7114. scale(factor: number): BoundingSphere;
  7115. /**
  7116. * Gets the world matrix of the bounding box
  7117. * @returns a matrix
  7118. */
  7119. getWorldMatrix(): DeepImmutable<Matrix>;
  7120. /** @hidden */
  7121. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7122. /**
  7123. * Tests if the bounding sphere is intersecting the frustum planes
  7124. * @param frustumPlanes defines the frustum planes to test
  7125. * @returns true if there is an intersection
  7126. */
  7127. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7128. /**
  7129. * Tests if the bounding sphere center is in between the frustum planes.
  7130. * Used for optimistic fast inclusion.
  7131. * @param frustumPlanes defines the frustum planes to test
  7132. * @returns true if the sphere center is in between the frustum planes
  7133. */
  7134. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7135. /**
  7136. * Tests if a point is inside the bounding sphere
  7137. * @param point defines the point to test
  7138. * @returns true if the point is inside the bounding sphere
  7139. */
  7140. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7141. /**
  7142. * Checks if two sphere intersct
  7143. * @param sphere0 sphere 0
  7144. * @param sphere1 sphere 1
  7145. * @returns true if the speres intersect
  7146. */
  7147. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7148. }
  7149. }
  7150. declare module BABYLON {
  7151. /**
  7152. * Class representing a ray with position and direction
  7153. */
  7154. class Ray {
  7155. /** origin point */
  7156. origin: Vector3;
  7157. /** direction */
  7158. direction: Vector3;
  7159. /** length of the ray */
  7160. length: number;
  7161. private static readonly TmpVector3;
  7162. private _tmpRay;
  7163. /**
  7164. * Creates a new ray
  7165. * @param origin origin point
  7166. * @param direction direction
  7167. * @param length length of the ray
  7168. */
  7169. constructor(
  7170. /** origin point */
  7171. origin: Vector3,
  7172. /** direction */
  7173. direction: Vector3,
  7174. /** length of the ray */
  7175. length?: number);
  7176. /**
  7177. * Checks if the ray intersects a box
  7178. * @param minimum bound of the box
  7179. * @param maximum bound of the box
  7180. * @param intersectionTreshold extra extend to be added to the box in all direction
  7181. * @returns if the box was hit
  7182. */
  7183. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7184. /**
  7185. * Checks if the ray intersects a box
  7186. * @param box the bounding box to check
  7187. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7188. * @returns if the box was hit
  7189. */
  7190. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7191. /**
  7192. * If the ray hits a sphere
  7193. * @param sphere the bounding sphere to check
  7194. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7195. * @returns true if it hits the sphere
  7196. */
  7197. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7198. /**
  7199. * If the ray hits a triange
  7200. * @param vertex0 triangle vertex
  7201. * @param vertex1 triangle vertex
  7202. * @param vertex2 triangle vertex
  7203. * @returns intersection information if hit
  7204. */
  7205. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7206. /**
  7207. * Checks if ray intersects a plane
  7208. * @param plane the plane to check
  7209. * @returns the distance away it was hit
  7210. */
  7211. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7212. /**
  7213. * Checks if ray intersects a mesh
  7214. * @param mesh the mesh to check
  7215. * @param fastCheck if only the bounding box should checked
  7216. * @returns picking info of the intersecton
  7217. */
  7218. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7219. /**
  7220. * Checks if ray intersects a mesh
  7221. * @param meshes the meshes to check
  7222. * @param fastCheck if only the bounding box should checked
  7223. * @param results array to store result in
  7224. * @returns Array of picking infos
  7225. */
  7226. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7227. private _comparePickingInfo;
  7228. private static smallnum;
  7229. private static rayl;
  7230. /**
  7231. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7232. * @param sega the first point of the segment to test the intersection against
  7233. * @param segb the second point of the segment to test the intersection against
  7234. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7235. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7236. */
  7237. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7238. /**
  7239. * Update the ray from viewport position
  7240. * @param x position
  7241. * @param y y position
  7242. * @param viewportWidth viewport width
  7243. * @param viewportHeight viewport height
  7244. * @param world world matrix
  7245. * @param view view matrix
  7246. * @param projection projection matrix
  7247. * @returns this ray updated
  7248. */
  7249. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7250. /**
  7251. * Creates a ray with origin and direction of 0,0,0
  7252. * @returns the new ray
  7253. */
  7254. static Zero(): Ray;
  7255. /**
  7256. * Creates a new ray from screen space and viewport
  7257. * @param x position
  7258. * @param y y position
  7259. * @param viewportWidth viewport width
  7260. * @param viewportHeight viewport height
  7261. * @param world world matrix
  7262. * @param view view matrix
  7263. * @param projection projection matrix
  7264. * @returns new ray
  7265. */
  7266. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7267. /**
  7268. * 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
  7269. * transformed to the given world matrix.
  7270. * @param origin The origin point
  7271. * @param end The end point
  7272. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7273. * @returns the new ray
  7274. */
  7275. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7276. /**
  7277. * Transforms a ray by a matrix
  7278. * @param ray ray to transform
  7279. * @param matrix matrix to apply
  7280. * @returns the resulting new ray
  7281. */
  7282. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7283. /**
  7284. * Transforms a ray by a matrix
  7285. * @param ray ray to transform
  7286. * @param matrix matrix to apply
  7287. * @param result ray to store result in
  7288. */
  7289. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7290. }
  7291. }
  7292. /**
  7293. * Module Debug contains the (visual) components to debug a scene correctly
  7294. */
  7295. declare module BABYLON.Debug {
  7296. /**
  7297. * The Axes viewer will show 3 axes in a specific point in space
  7298. */
  7299. class AxesViewer {
  7300. private _xAxis;
  7301. private _yAxis;
  7302. private _zAxis;
  7303. private _scaleLinesFactor;
  7304. private _instanced;
  7305. /**
  7306. * Gets the hosting scene
  7307. */
  7308. scene: Scene;
  7309. /**
  7310. * Gets or sets a number used to scale line length
  7311. */
  7312. scaleLines: number;
  7313. /** Gets the node hierarchy used to render x-axis */
  7314. readonly xAxis: TransformNode;
  7315. /** Gets the node hierarchy used to render y-axis */
  7316. readonly yAxis: TransformNode;
  7317. /** Gets the node hierarchy used to render z-axis */
  7318. readonly zAxis: TransformNode;
  7319. /**
  7320. * Creates a new AxesViewer
  7321. * @param scene defines the hosting scene
  7322. * @param scaleLines defines a number used to scale line length (1 by default)
  7323. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  7324. * @param xAxis defines the node hierarchy used to render the x-axis
  7325. * @param yAxis defines the node hierarchy used to render the y-axis
  7326. * @param zAxis defines the node hierarchy used to render the z-axis
  7327. */
  7328. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  7329. /**
  7330. * Force the viewer to update
  7331. * @param position defines the position of the viewer
  7332. * @param xaxis defines the x axis of the viewer
  7333. * @param yaxis defines the y axis of the viewer
  7334. * @param zaxis defines the z axis of the viewer
  7335. */
  7336. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  7337. /**
  7338. * Creates an instance of this axes viewer.
  7339. * @returns a new axes viewer with instanced meshes
  7340. */
  7341. createInstance(): AxesViewer;
  7342. /** Releases resources */
  7343. dispose(): void;
  7344. private static _SetRenderingGroupId;
  7345. }
  7346. }
  7347. declare module BABYLON.Debug {
  7348. /**
  7349. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  7350. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  7351. */
  7352. class BoneAxesViewer extends AxesViewer {
  7353. /**
  7354. * Gets or sets the target mesh where to display the axes viewer
  7355. */
  7356. mesh: Nullable<Mesh>;
  7357. /**
  7358. * Gets or sets the target bone where to display the axes viewer
  7359. */
  7360. bone: Nullable<Bone>;
  7361. /** Gets current position */
  7362. pos: Vector3;
  7363. /** Gets direction of X axis */
  7364. xaxis: Vector3;
  7365. /** Gets direction of Y axis */
  7366. yaxis: Vector3;
  7367. /** Gets direction of Z axis */
  7368. zaxis: Vector3;
  7369. /**
  7370. * Creates a new BoneAxesViewer
  7371. * @param scene defines the hosting scene
  7372. * @param bone defines the target bone
  7373. * @param mesh defines the target mesh
  7374. * @param scaleLines defines a scaling factor for line length (1 by default)
  7375. */
  7376. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7377. /**
  7378. * Force the viewer to update
  7379. */
  7380. update(): void;
  7381. /** Releases resources */
  7382. dispose(): void;
  7383. }
  7384. }
  7385. declare module BABYLON {
  7386. /**
  7387. * Interface used to define scene explorer extensibility option
  7388. */
  7389. interface IExplorerExtensibilityOption {
  7390. /**
  7391. * Define the option label
  7392. */
  7393. label: string;
  7394. /**
  7395. * Defines the action to execute on click
  7396. */
  7397. action: (entity: any) => void;
  7398. }
  7399. /**
  7400. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  7401. */
  7402. interface IExplorerExtensibilityGroup {
  7403. /**
  7404. * Defines a predicate to test if a given type mut be extended
  7405. */
  7406. predicate: (entity: any) => boolean;
  7407. /**
  7408. * Gets the list of options added to a type
  7409. */
  7410. entries: IExplorerExtensibilityOption[];
  7411. }
  7412. /**
  7413. * Interface used to define the options to use to create the Inspector
  7414. */
  7415. interface IInspectorOptions {
  7416. /**
  7417. * Display in overlay mode (default: false)
  7418. */
  7419. overlay?: boolean;
  7420. /**
  7421. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  7422. */
  7423. globalRoot?: HTMLElement;
  7424. /**
  7425. * Display the Scene explorer
  7426. */
  7427. showExplorer?: boolean;
  7428. /**
  7429. * Display the property inspector
  7430. */
  7431. showInspector?: boolean;
  7432. /**
  7433. * Display in embed mode (both panes on the right)
  7434. */
  7435. embedMode?: boolean;
  7436. /**
  7437. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  7438. */
  7439. handleResize?: boolean;
  7440. /**
  7441. * Allow the panes to popup (default: true)
  7442. */
  7443. enablePopup?: boolean;
  7444. /**
  7445. * Allow the panes to be closed by users (default: true)
  7446. */
  7447. enableClose?: boolean;
  7448. /**
  7449. * Optional list of extensibility entries
  7450. */
  7451. explorerExtensibility?: IExplorerExtensibilityGroup[];
  7452. }
  7453. interface Scene {
  7454. /**
  7455. * @hidden
  7456. * Backing field
  7457. */
  7458. _debugLayer: DebugLayer;
  7459. /**
  7460. * Gets the debug layer (aka Inspector) associated with the scene
  7461. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7462. */
  7463. debugLayer: DebugLayer;
  7464. }
  7465. /**
  7466. * The debug layer (aka Inspector) is the go to tool in order to better understand
  7467. * what is happening in your scene
  7468. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7469. */
  7470. class DebugLayer {
  7471. /**
  7472. * Define the url to get the inspector script from.
  7473. * By default it uses the babylonjs CDN.
  7474. * @ignoreNaming
  7475. */
  7476. static InspectorURL: string;
  7477. private _scene;
  7478. private BJSINSPECTOR;
  7479. /**
  7480. * Observable triggered when a property is changed through the inspector.
  7481. */
  7482. onPropertyChangedObservable: Observable<{
  7483. object: any;
  7484. property: string;
  7485. value: any;
  7486. initialValue: any;
  7487. }>;
  7488. /**
  7489. * Instantiates a new debug layer.
  7490. * The debug layer (aka Inspector) is the go to tool in order to better understand
  7491. * what is happening in your scene
  7492. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7493. * @param scene Defines the scene to inspect
  7494. */
  7495. constructor(scene: Scene);
  7496. /** Creates the inspector window. */
  7497. private _createInspector;
  7498. /** Get the inspector from bundle or global */
  7499. private _getGlobalInspector;
  7500. /**
  7501. * Get if the inspector is visible or not.
  7502. * @returns true if visible otherwise, false
  7503. */
  7504. isVisible(): boolean;
  7505. /**
  7506. * Hide the inspector and close its window.
  7507. */
  7508. hide(): void;
  7509. /**
  7510. * Launch the debugLayer.
  7511. * @param config Define the configuration of the inspector
  7512. */
  7513. show(config?: IInspectorOptions): void;
  7514. }
  7515. }
  7516. declare module BABYLON.Debug {
  7517. /**
  7518. * Used to show the physics impostor around the specific mesh
  7519. */
  7520. class PhysicsViewer {
  7521. /** @hidden */
  7522. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7523. /** @hidden */
  7524. protected _meshes: Array<Nullable<AbstractMesh>>;
  7525. /** @hidden */
  7526. protected _scene: Nullable<Scene>;
  7527. /** @hidden */
  7528. protected _numMeshes: number;
  7529. /** @hidden */
  7530. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7531. private _renderFunction;
  7532. private _utilityLayer;
  7533. private _debugBoxMesh;
  7534. private _debugSphereMesh;
  7535. private _debugMaterial;
  7536. /**
  7537. * Creates a new PhysicsViewer
  7538. * @param scene defines the hosting scene
  7539. */
  7540. constructor(scene: Scene);
  7541. /** @hidden */
  7542. protected _updateDebugMeshes(): void;
  7543. /**
  7544. * Renders a specified physic impostor
  7545. * @param impostor defines the impostor to render
  7546. * @returns the new debug mesh used to render the impostor
  7547. */
  7548. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  7549. /**
  7550. * Hides a specified physic impostor
  7551. * @param impostor defines the impostor to hide
  7552. */
  7553. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7554. private _getDebugMaterial;
  7555. private _getDebugBoxMesh;
  7556. private _getDebugSphereMesh;
  7557. private _getDebugMesh;
  7558. /** Releases all resources */
  7559. dispose(): void;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  7565. * in order to better appreciate the issue one might have.
  7566. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  7567. */
  7568. class RayHelper {
  7569. /**
  7570. * Defines the ray we are currently tryin to visualize.
  7571. */
  7572. ray: Nullable<Ray>;
  7573. private _renderPoints;
  7574. private _renderLine;
  7575. private _renderFunction;
  7576. private _scene;
  7577. private _updateToMeshFunction;
  7578. private _attachedToMesh;
  7579. private _meshSpaceDirection;
  7580. private _meshSpaceOrigin;
  7581. /**
  7582. * Helper function to create a colored helper in a scene in one line.
  7583. * @param ray Defines the ray we are currently tryin to visualize
  7584. * @param scene Defines the scene the ray is used in
  7585. * @param color Defines the color we want to see the ray in
  7586. * @returns The newly created ray helper.
  7587. */
  7588. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7589. /**
  7590. * Instantiate a new ray helper.
  7591. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  7592. * in order to better appreciate the issue one might have.
  7593. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  7594. * @param ray Defines the ray we are currently tryin to visualize
  7595. */
  7596. constructor(ray: Ray);
  7597. /**
  7598. * Shows the ray we are willing to debug.
  7599. * @param scene Defines the scene the ray needs to be rendered in
  7600. * @param color Defines the color the ray needs to be rendered in
  7601. */
  7602. show(scene: Scene, color?: Color3): void;
  7603. /**
  7604. * Hides the ray we are debugging.
  7605. */
  7606. hide(): void;
  7607. private _render;
  7608. /**
  7609. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  7610. * @param mesh Defines the mesh we want the helper attached to
  7611. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  7612. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  7613. * @param length Defines the length of the ray
  7614. */
  7615. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7616. /**
  7617. * Detach the ray helper from the mesh it has previously been attached to.
  7618. */
  7619. detachFromMesh(): void;
  7620. private _updateToMesh;
  7621. /**
  7622. * Dispose the helper and release its associated resources.
  7623. */
  7624. dispose(): void;
  7625. }
  7626. }
  7627. declare module BABYLON.Debug {
  7628. /**
  7629. * Class used to render a debug view of a given skeleton
  7630. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7631. */
  7632. class SkeletonViewer {
  7633. /** defines the skeleton to render */
  7634. skeleton: Skeleton;
  7635. /** defines the mesh attached to the skeleton */
  7636. mesh: AbstractMesh;
  7637. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7638. autoUpdateBonesMatrices: boolean;
  7639. /** defines the rendering group id to use with the viewer */
  7640. renderingGroupId: number;
  7641. /** Gets or sets the color used to render the skeleton */
  7642. color: Color3;
  7643. private _scene;
  7644. private _debugLines;
  7645. private _debugMesh;
  7646. private _isEnabled;
  7647. private _renderFunction;
  7648. private _utilityLayer;
  7649. /**
  7650. * Returns the mesh used to render the bones
  7651. */
  7652. readonly debugMesh: Nullable<LinesMesh>;
  7653. /**
  7654. * Creates a new SkeletonViewer
  7655. * @param skeleton defines the skeleton to render
  7656. * @param mesh defines the mesh attached to the skeleton
  7657. * @param scene defines the hosting scene
  7658. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  7659. * @param renderingGroupId defines the rendering group id to use with the viewer
  7660. */
  7661. constructor(
  7662. /** defines the skeleton to render */
  7663. skeleton: Skeleton,
  7664. /** defines the mesh attached to the skeleton */
  7665. mesh: AbstractMesh, scene: Scene,
  7666. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7667. autoUpdateBonesMatrices?: boolean,
  7668. /** defines the rendering group id to use with the viewer */
  7669. renderingGroupId?: number);
  7670. /** Gets or sets a boolean indicating if the viewer is enabled */
  7671. isEnabled: boolean;
  7672. private _getBonePosition;
  7673. private _getLinesForBonesWithLength;
  7674. private _getLinesForBonesNoLength;
  7675. /** Update the viewer to sync with current skeleton state */
  7676. update(): void;
  7677. /** Release associated resources */
  7678. dispose(): void;
  7679. }
  7680. }
  7681. declare module BABYLON {
  7682. /** @hidden */
  7683. class Collider {
  7684. /** Define if a collision was found */
  7685. collisionFound: boolean;
  7686. /**
  7687. * Define last intersection point in local space
  7688. */
  7689. intersectionPoint: Vector3;
  7690. /**
  7691. * Define last collided mesh
  7692. */
  7693. collidedMesh: Nullable<AbstractMesh>;
  7694. private _collisionPoint;
  7695. private _planeIntersectionPoint;
  7696. private _tempVector;
  7697. private _tempVector2;
  7698. private _tempVector3;
  7699. private _tempVector4;
  7700. private _edge;
  7701. private _baseToVertex;
  7702. private _destinationPoint;
  7703. private _slidePlaneNormal;
  7704. private _displacementVector;
  7705. /** @hidden */
  7706. _radius: Vector3;
  7707. /** @hidden */
  7708. _retry: number;
  7709. private _velocity;
  7710. private _basePoint;
  7711. private _epsilon;
  7712. /** @hidden */
  7713. _velocityWorldLength: number;
  7714. /** @hidden */
  7715. _basePointWorld: Vector3;
  7716. private _velocityWorld;
  7717. private _normalizedVelocity;
  7718. /** @hidden */
  7719. _initialVelocity: Vector3;
  7720. /** @hidden */
  7721. _initialPosition: Vector3;
  7722. private _nearestDistance;
  7723. private _collisionMask;
  7724. collisionMask: number;
  7725. /**
  7726. * Gets the plane normal used to compute the sliding response (in local space)
  7727. */
  7728. readonly slidePlaneNormal: Vector3;
  7729. /** @hidden */
  7730. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7731. /** @hidden */
  7732. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7733. /** @hidden */
  7734. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7735. /** @hidden */
  7736. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7737. /** @hidden */
  7738. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7739. /** @hidden */
  7740. _getResponse(pos: Vector3, vel: Vector3): void;
  7741. }
  7742. }
  7743. declare module BABYLON {
  7744. /** @hidden */
  7745. var CollisionWorker: string;
  7746. /** @hidden */
  7747. interface ICollisionCoordinator {
  7748. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7749. init(scene: Scene): void;
  7750. destroy(): void;
  7751. onMeshAdded(mesh: AbstractMesh): void;
  7752. onMeshUpdated(mesh: AbstractMesh): void;
  7753. onMeshRemoved(mesh: AbstractMesh): void;
  7754. onGeometryAdded(geometry: Geometry): void;
  7755. onGeometryUpdated(geometry: Geometry): void;
  7756. onGeometryDeleted(geometry: Geometry): void;
  7757. }
  7758. /** @hidden */
  7759. interface SerializedMesh {
  7760. id: string;
  7761. name: string;
  7762. uniqueId: number;
  7763. geometryId: Nullable<string>;
  7764. sphereCenter: Array<number>;
  7765. sphereRadius: number;
  7766. boxMinimum: Array<number>;
  7767. boxMaximum: Array<number>;
  7768. worldMatrixFromCache: any;
  7769. subMeshes: Array<SerializedSubMesh>;
  7770. checkCollisions: boolean;
  7771. }
  7772. /** @hidden */
  7773. interface SerializedSubMesh {
  7774. position: number;
  7775. verticesStart: number;
  7776. verticesCount: number;
  7777. indexStart: number;
  7778. indexCount: number;
  7779. hasMaterial: boolean;
  7780. sphereCenter: Array<number>;
  7781. sphereRadius: number;
  7782. boxMinimum: Array<number>;
  7783. boxMaximum: Array<number>;
  7784. }
  7785. /**
  7786. * Interface describing the value associated with a geometry.
  7787. * @hidden
  7788. */
  7789. interface SerializedGeometry {
  7790. /**
  7791. * Defines the unique ID of the geometry
  7792. */
  7793. id: string;
  7794. /**
  7795. * Defines the array containing the positions
  7796. */
  7797. positions: Float32Array;
  7798. /**
  7799. * Defines the array containing the indices
  7800. */
  7801. indices: Uint32Array;
  7802. /**
  7803. * Defines the array containing the normals
  7804. */
  7805. normals: Float32Array;
  7806. }
  7807. /** @hidden */
  7808. interface BabylonMessage {
  7809. taskType: WorkerTaskType;
  7810. payload: InitPayload | CollidePayload | UpdatePayload;
  7811. }
  7812. /** @hidden */
  7813. interface SerializedColliderToWorker {
  7814. position: Array<number>;
  7815. velocity: Array<number>;
  7816. radius: Array<number>;
  7817. }
  7818. /** Defines supported task for worker process */
  7819. enum WorkerTaskType {
  7820. /** Initialization */
  7821. INIT = 0,
  7822. /** Update of geometry */
  7823. UPDATE = 1,
  7824. /** Evaluate collision */
  7825. COLLIDE = 2
  7826. }
  7827. /** @hidden */
  7828. interface WorkerReply {
  7829. error: WorkerReplyType;
  7830. taskType: WorkerTaskType;
  7831. payload?: any;
  7832. }
  7833. /** @hidden */
  7834. interface CollisionReplyPayload {
  7835. newPosition: Array<number>;
  7836. collisionId: number;
  7837. collidedMeshUniqueId: number;
  7838. }
  7839. /** @hidden */
  7840. interface InitPayload {
  7841. }
  7842. /** @hidden */
  7843. interface CollidePayload {
  7844. collisionId: number;
  7845. collider: SerializedColliderToWorker;
  7846. maximumRetry: number;
  7847. excludedMeshUniqueId: Nullable<number>;
  7848. }
  7849. /** @hidden */
  7850. interface UpdatePayload {
  7851. updatedMeshes: {
  7852. [n: number]: SerializedMesh;
  7853. };
  7854. updatedGeometries: {
  7855. [s: string]: SerializedGeometry;
  7856. };
  7857. removedMeshes: Array<number>;
  7858. removedGeometries: Array<string>;
  7859. }
  7860. /** Defines kind of replies returned by worker */
  7861. enum WorkerReplyType {
  7862. /** Success */
  7863. SUCCESS = 0,
  7864. /** Unkown error */
  7865. UNKNOWN_ERROR = 1
  7866. }
  7867. /** @hidden */
  7868. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  7869. private _scene;
  7870. private _scaledPosition;
  7871. private _scaledVelocity;
  7872. private _collisionsCallbackArray;
  7873. private _init;
  7874. private _runningUpdated;
  7875. private _worker;
  7876. private _addUpdateMeshesList;
  7877. private _addUpdateGeometriesList;
  7878. private _toRemoveMeshesArray;
  7879. private _toRemoveGeometryArray;
  7880. constructor();
  7881. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  7882. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  7883. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7884. init(scene: Scene): void;
  7885. destroy(): void;
  7886. onMeshAdded(mesh: AbstractMesh): void;
  7887. onMeshUpdated: (transformNode: TransformNode) => void;
  7888. onMeshRemoved(mesh: AbstractMesh): void;
  7889. onGeometryAdded(geometry: Geometry): void;
  7890. onGeometryUpdated: (geometry: Geometry) => void;
  7891. onGeometryDeleted(geometry: Geometry): void;
  7892. private _afterRender;
  7893. private _onMessageFromWorker;
  7894. }
  7895. /** @hidden */
  7896. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  7897. private _scene;
  7898. private _scaledPosition;
  7899. private _scaledVelocity;
  7900. private _finalPosition;
  7901. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7902. init(scene: Scene): void;
  7903. destroy(): void;
  7904. onMeshAdded(mesh: AbstractMesh): void;
  7905. onMeshUpdated(mesh: AbstractMesh): void;
  7906. onMeshRemoved(mesh: AbstractMesh): void;
  7907. onGeometryAdded(geometry: Geometry): void;
  7908. onGeometryUpdated(geometry: Geometry): void;
  7909. onGeometryDeleted(geometry: Geometry): void;
  7910. private _collideWithWorld;
  7911. }
  7912. }
  7913. declare function importScripts(...urls: string[]): void;
  7914. declare const safePostMessage: any;
  7915. declare module BABYLON {
  7916. /** @hidden */
  7917. var WorkerIncluded: boolean;
  7918. /** @hidden */
  7919. class CollisionCache {
  7920. private _meshes;
  7921. private _geometries;
  7922. getMeshes(): {
  7923. [n: number]: SerializedMesh;
  7924. };
  7925. getGeometries(): {
  7926. [s: number]: SerializedGeometry;
  7927. };
  7928. getMesh(id: any): SerializedMesh;
  7929. addMesh(mesh: SerializedMesh): void;
  7930. removeMesh(uniqueId: number): void;
  7931. getGeometry(id: string): SerializedGeometry;
  7932. addGeometry(geometry: SerializedGeometry): void;
  7933. removeGeometry(id: string): void;
  7934. }
  7935. /** @hidden */
  7936. class CollideWorker {
  7937. collider: Collider;
  7938. private _collisionCache;
  7939. private finalPosition;
  7940. private collisionsScalingMatrix;
  7941. private collisionTranformationMatrix;
  7942. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7943. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7944. private checkCollision;
  7945. private processCollisionsForSubMeshes;
  7946. private collideForSubMesh;
  7947. private checkSubmeshCollision;
  7948. }
  7949. /** @hidden */
  7950. interface ICollisionDetector {
  7951. onInit(payload: InitPayload): void;
  7952. onUpdate(payload: UpdatePayload): void;
  7953. onCollision(payload: CollidePayload): void;
  7954. }
  7955. /** @hidden */
  7956. class CollisionDetectorTransferable implements ICollisionDetector {
  7957. private _collisionCache;
  7958. onInit(payload: InitPayload): void;
  7959. onUpdate(payload: UpdatePayload): void;
  7960. onCollision(payload: CollidePayload): void;
  7961. }
  7962. }
  7963. declare module BABYLON {
  7964. /**
  7965. * @hidden
  7966. */
  7967. class IntersectionInfo {
  7968. bu: Nullable<number>;
  7969. bv: Nullable<number>;
  7970. distance: number;
  7971. faceId: number;
  7972. subMeshId: number;
  7973. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7974. }
  7975. /**
  7976. * Information about the result of picking within a scene
  7977. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7978. */
  7979. class PickingInfo {
  7980. /**
  7981. * If the pick collided with an object
  7982. */
  7983. hit: boolean;
  7984. /**
  7985. * Distance away where the pick collided
  7986. */
  7987. distance: number;
  7988. /**
  7989. * The location of pick collision
  7990. */
  7991. pickedPoint: Nullable<Vector3>;
  7992. /**
  7993. * The mesh corresponding the the pick collision
  7994. */
  7995. pickedMesh: Nullable<AbstractMesh>;
  7996. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7997. bu: number;
  7998. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7999. bv: number;
  8000. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  8001. faceId: number;
  8002. /** Id of the the submesh that was picked */
  8003. subMeshId: number;
  8004. /** If a sprite was picked, this will be the sprite the pick collided with */
  8005. pickedSprite: Nullable<Sprite>;
  8006. /**
  8007. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  8008. */
  8009. originMesh: Nullable<AbstractMesh>;
  8010. /**
  8011. * The ray that was used to perform the picking.
  8012. */
  8013. ray: Nullable<Ray>;
  8014. /**
  8015. * Gets the normal correspodning to the face the pick collided with
  8016. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  8017. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  8018. * @returns The normal correspodning to the face the pick collided with
  8019. */
  8020. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  8021. /**
  8022. * Gets the texture coordinates of where the pick occured
  8023. * @returns the vector containing the coordnates of the texture
  8024. */
  8025. getTextureCoordinates(): Nullable<Vector2>;
  8026. }
  8027. }
  8028. declare module BABYLON {
  8029. /**
  8030. * This represents an orbital type of camera.
  8031. *
  8032. * 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.
  8033. * 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.
  8034. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  8035. */
  8036. class ArcRotateCamera extends TargetCamera {
  8037. /**
  8038. * Defines the rotation angle of the camera along the longitudinal axis.
  8039. */
  8040. alpha: number;
  8041. /**
  8042. * Defines the rotation angle of the camera along the latitudinal axis.
  8043. */
  8044. beta: number;
  8045. /**
  8046. * Defines the radius of the camera from it s target point.
  8047. */
  8048. radius: number;
  8049. protected _target: Vector3;
  8050. protected _targetHost: Nullable<AbstractMesh>;
  8051. /**
  8052. * Defines the target point of the camera.
  8053. * The camera looks towards it form the radius distance.
  8054. */
  8055. target: Vector3;
  8056. /**
  8057. * Current inertia value on the longitudinal axis.
  8058. * The bigger this number the longer it will take for the camera to stop.
  8059. */
  8060. inertialAlphaOffset: number;
  8061. /**
  8062. * Current inertia value on the latitudinal axis.
  8063. * The bigger this number the longer it will take for the camera to stop.
  8064. */
  8065. inertialBetaOffset: number;
  8066. /**
  8067. * Current inertia value on the radius axis.
  8068. * The bigger this number the longer it will take for the camera to stop.
  8069. */
  8070. inertialRadiusOffset: number;
  8071. /**
  8072. * Minimum allowed angle on the longitudinal axis.
  8073. * This can help limiting how the Camera is able to move in the scene.
  8074. */
  8075. lowerAlphaLimit: Nullable<number>;
  8076. /**
  8077. * Maximum allowed angle on the longitudinal axis.
  8078. * This can help limiting how the Camera is able to move in the scene.
  8079. */
  8080. upperAlphaLimit: Nullable<number>;
  8081. /**
  8082. * Minimum allowed angle on the latitudinal axis.
  8083. * This can help limiting how the Camera is able to move in the scene.
  8084. */
  8085. lowerBetaLimit: number;
  8086. /**
  8087. * Maximum allowed angle on the latitudinal axis.
  8088. * This can help limiting how the Camera is able to move in the scene.
  8089. */
  8090. upperBetaLimit: number;
  8091. /**
  8092. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  8093. * This can help limiting how the Camera is able to move in the scene.
  8094. */
  8095. lowerRadiusLimit: Nullable<number>;
  8096. /**
  8097. * Maximum allowed distance of the camera to the target (The camera can not get further).
  8098. * This can help limiting how the Camera is able to move in the scene.
  8099. */
  8100. upperRadiusLimit: Nullable<number>;
  8101. /**
  8102. * Defines the current inertia value used during panning of the camera along the X axis.
  8103. */
  8104. inertialPanningX: number;
  8105. /**
  8106. * Defines the current inertia value used during panning of the camera along the Y axis.
  8107. */
  8108. inertialPanningY: number;
  8109. /**
  8110. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  8111. * Basically if your fingers moves away from more than this distance you will be considered
  8112. * in pinch mode.
  8113. */
  8114. pinchToPanMaxDistance: number;
  8115. /**
  8116. * Defines the maximum distance the camera can pan.
  8117. * This could help keeping the cammera always in your scene.
  8118. */
  8119. panningDistanceLimit: Nullable<number>;
  8120. /**
  8121. * Defines the target of the camera before paning.
  8122. */
  8123. panningOriginTarget: Vector3;
  8124. /**
  8125. * Defines the value of the inertia used during panning.
  8126. * 0 would mean stop inertia and one would mean no decelleration at all.
  8127. */
  8128. panningInertia: number;
  8129. /**
  8130. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  8131. */
  8132. angularSensibilityX: number;
  8133. /**
  8134. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  8135. */
  8136. angularSensibilityY: number;
  8137. /**
  8138. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  8139. */
  8140. pinchPrecision: number;
  8141. /**
  8142. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  8143. * It will be used instead of pinchDeltaPrecision if different from 0.
  8144. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  8145. */
  8146. pinchDeltaPercentage: number;
  8147. /**
  8148. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  8149. */
  8150. panningSensibility: number;
  8151. /**
  8152. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  8153. */
  8154. keysUp: number[];
  8155. /**
  8156. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  8157. */
  8158. keysDown: number[];
  8159. /**
  8160. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  8161. */
  8162. keysLeft: number[];
  8163. /**
  8164. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  8165. */
  8166. keysRight: number[];
  8167. /**
  8168. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  8169. */
  8170. wheelPrecision: number;
  8171. /**
  8172. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  8173. * It will be used instead of pinchDeltaPrecision if different from 0.
  8174. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  8175. */
  8176. wheelDeltaPercentage: number;
  8177. /**
  8178. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  8179. */
  8180. zoomOnFactor: number;
  8181. /**
  8182. * Defines a screen offset for the camera position.
  8183. */
  8184. targetScreenOffset: Vector2;
  8185. /**
  8186. * Allows the camera to be completely reversed.
  8187. * If false the camera can not arrive upside down.
  8188. */
  8189. allowUpsideDown: boolean;
  8190. /**
  8191. * Define if double tap/click is used to restore the previously saved state of the camera.
  8192. */
  8193. useInputToRestoreState: boolean;
  8194. /** @hidden */
  8195. _viewMatrix: Matrix;
  8196. /** @hidden */
  8197. _useCtrlForPanning: boolean;
  8198. /** @hidden */
  8199. _panningMouseButton: number;
  8200. /**
  8201. * Defines the inpute associated to the camera.
  8202. */
  8203. inputs: ArcRotateCameraInputsManager;
  8204. /** @hidden */
  8205. _reset: () => void;
  8206. /**
  8207. * Defines the allowed panning axis.
  8208. */
  8209. panningAxis: Vector3;
  8210. protected _localDirection: Vector3;
  8211. protected _transformedDirection: Vector3;
  8212. private _bouncingBehavior;
  8213. /**
  8214. * Gets the bouncing behavior of the camera if it has been enabled.
  8215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8216. */
  8217. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  8218. /**
  8219. * Defines if the bouncing behavior of the camera is enabled on the camera.
  8220. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8221. */
  8222. useBouncingBehavior: boolean;
  8223. private _framingBehavior;
  8224. /**
  8225. * Gets the framing behavior of the camera if it has been enabled.
  8226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8227. */
  8228. readonly framingBehavior: Nullable<FramingBehavior>;
  8229. /**
  8230. * Defines if the framing behavior of the camera is enabled on the camera.
  8231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8232. */
  8233. useFramingBehavior: boolean;
  8234. private _autoRotationBehavior;
  8235. /**
  8236. * Gets the auto rotation behavior of the camera if it has been enabled.
  8237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  8238. */
  8239. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  8240. /**
  8241. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  8242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  8243. */
  8244. useAutoRotationBehavior: boolean;
  8245. /**
  8246. * Observable triggered when the mesh target has been changed on the camera.
  8247. */
  8248. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  8249. /**
  8250. * Event raised when the camera is colliding with a mesh.
  8251. */
  8252. onCollide: (collidedMesh: AbstractMesh) => void;
  8253. /**
  8254. * Defines whether the camera should check collision with the objects oh the scene.
  8255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  8256. */
  8257. checkCollisions: boolean;
  8258. /**
  8259. * Defines the collision radius of the camera.
  8260. * This simulates a sphere around the camera.
  8261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8262. */
  8263. collisionRadius: Vector3;
  8264. protected _collider: Collider;
  8265. protected _previousPosition: Vector3;
  8266. protected _collisionVelocity: Vector3;
  8267. protected _newPosition: Vector3;
  8268. protected _previousAlpha: number;
  8269. protected _previousBeta: number;
  8270. protected _previousRadius: number;
  8271. protected _collisionTriggered: boolean;
  8272. protected _targetBoundingCenter: Nullable<Vector3>;
  8273. private _computationVector;
  8274. private _tempAxisVector;
  8275. private _tempAxisRotationMatrix;
  8276. /**
  8277. * Instantiates a new ArcRotateCamera in a given scene
  8278. * @param name Defines the name of the camera
  8279. * @param alpha Defines the camera rotation along the logitudinal axis
  8280. * @param beta Defines the camera rotation along the latitudinal axis
  8281. * @param radius Defines the camera distance from its target
  8282. * @param target Defines the camera target
  8283. * @param scene Defines the scene the camera belongs to
  8284. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8285. */
  8286. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8287. /** @hidden */
  8288. _initCache(): void;
  8289. /** @hidden */
  8290. _updateCache(ignoreParentClass?: boolean): void;
  8291. protected _getTargetPosition(): Vector3;
  8292. private _storedAlpha;
  8293. private _storedBeta;
  8294. private _storedRadius;
  8295. private _storedTarget;
  8296. /**
  8297. * Stores the current state of the camera (alpha, beta, radius and target)
  8298. * @returns the camera itself
  8299. */
  8300. storeState(): Camera;
  8301. /**
  8302. * @hidden
  8303. * Restored camera state. You must call storeState() first
  8304. */
  8305. _restoreStateValues(): boolean;
  8306. /** @hidden */
  8307. _isSynchronizedViewMatrix(): boolean;
  8308. /**
  8309. * Attached controls to the current camera.
  8310. * @param element Defines the element the controls should be listened from
  8311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8312. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  8313. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  8314. */
  8315. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  8316. /**
  8317. * Detach the current controls from the camera.
  8318. * The camera will stop reacting to inputs.
  8319. * @param element Defines the element to stop listening the inputs from
  8320. */
  8321. detachControl(element: HTMLElement): void;
  8322. /** @hidden */
  8323. _checkInputs(): void;
  8324. protected _checkLimits(): void;
  8325. /**
  8326. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  8327. */
  8328. rebuildAnglesAndRadius(): void;
  8329. /**
  8330. * Use a position to define the current camera related information like aplha, beta and radius
  8331. * @param position Defines the position to set the camera at
  8332. */
  8333. setPosition(position: Vector3): void;
  8334. /**
  8335. * Defines the target the camera should look at.
  8336. * This will automatically adapt alpha beta and radius to fit within the new target.
  8337. * @param target Defines the new target as a Vector or a mesh
  8338. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  8339. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  8340. */
  8341. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  8342. /** @hidden */
  8343. _getViewMatrix(): Matrix;
  8344. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  8345. /**
  8346. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  8347. * @param meshes Defines the mesh to zoom on
  8348. * @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)
  8349. */
  8350. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  8351. /**
  8352. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  8353. * The target will be changed but the radius
  8354. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  8355. * @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)
  8356. */
  8357. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  8358. min: Vector3;
  8359. max: Vector3;
  8360. distance: number;
  8361. }, doNotUpdateMaxZ?: boolean): void;
  8362. /**
  8363. * @override
  8364. * Override Camera.createRigCamera
  8365. */
  8366. createRigCamera(name: string, cameraIndex: number): Camera;
  8367. /**
  8368. * @hidden
  8369. * @override
  8370. * Override Camera._updateRigCameras
  8371. */
  8372. _updateRigCameras(): void;
  8373. /**
  8374. * Destroy the camera and release the current resources hold by it.
  8375. */
  8376. dispose(): void;
  8377. /**
  8378. * Gets the current object class name.
  8379. * @return the class name
  8380. */
  8381. getClassName(): string;
  8382. }
  8383. }
  8384. declare module BABYLON {
  8385. /**
  8386. * Default Inputs manager for the ArcRotateCamera.
  8387. * It groups all the default supported inputs for ease of use.
  8388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8389. */
  8390. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  8391. /**
  8392. * Instantiates a new ArcRotateCameraInputsManager.
  8393. * @param camera Defines the camera the inputs belong to
  8394. */
  8395. constructor(camera: ArcRotateCamera);
  8396. /**
  8397. * Add mouse wheel input support to the input manager.
  8398. * @returns the current input manager
  8399. */
  8400. addMouseWheel(): ArcRotateCameraInputsManager;
  8401. /**
  8402. * Add pointers input support to the input manager.
  8403. * @returns the current input manager
  8404. */
  8405. addPointers(): ArcRotateCameraInputsManager;
  8406. /**
  8407. * Add keyboard input support to the input manager.
  8408. * @returns the current input manager
  8409. */
  8410. addKeyboard(): ArcRotateCameraInputsManager;
  8411. /**
  8412. * Add orientation input support to the input manager.
  8413. * @returns the current input manager
  8414. */
  8415. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  8416. }
  8417. }
  8418. declare module BABYLON {
  8419. /**
  8420. * This is the base class of all the camera used in the application.
  8421. * @see http://doc.babylonjs.com/features/cameras
  8422. */
  8423. class Camera extends Node {
  8424. /**
  8425. * This is the default projection mode used by the cameras.
  8426. * It helps recreating a feeling of perspective and better appreciate depth.
  8427. * This is the best way to simulate real life cameras.
  8428. */
  8429. static readonly PERSPECTIVE_CAMERA: number;
  8430. /**
  8431. * This helps creating camera with an orthographic mode.
  8432. * 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.
  8433. */
  8434. static readonly ORTHOGRAPHIC_CAMERA: number;
  8435. /**
  8436. * This is the default FOV mode for perspective cameras.
  8437. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8438. */
  8439. static readonly FOVMODE_VERTICAL_FIXED: number;
  8440. /**
  8441. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8442. */
  8443. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8444. /**
  8445. * This specifies ther is no need for a camera rig.
  8446. * Basically only one eye is rendered corresponding to the camera.
  8447. */
  8448. static readonly RIG_MODE_NONE: number;
  8449. /**
  8450. * Simulates a camera Rig with one blue eye and one red eye.
  8451. * This can be use with 3d blue and red glasses.
  8452. */
  8453. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8454. /**
  8455. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  8456. */
  8457. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8458. /**
  8459. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  8460. */
  8461. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8462. /**
  8463. * Defines that both eyes of the camera will be rendered over under each other.
  8464. */
  8465. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8466. /**
  8467. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  8468. */
  8469. static readonly RIG_MODE_VR: number;
  8470. /**
  8471. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  8472. */
  8473. static readonly RIG_MODE_WEBVR: number;
  8474. /**
  8475. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  8476. */
  8477. static readonly RIG_MODE_CUSTOM: number;
  8478. /**
  8479. * Defines if by default attaching controls should prevent the default javascript event to continue.
  8480. */
  8481. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8482. /**
  8483. * @hidden
  8484. * Might be removed once multiview will be a thing
  8485. */
  8486. static UseAlternateWebVRRendering: boolean;
  8487. /**
  8488. * Define the input manager associated with the camera.
  8489. */
  8490. inputs: CameraInputsManager<Camera>;
  8491. /**
  8492. * Define the current local position of the camera in the scene
  8493. */
  8494. position: Vector3;
  8495. /**
  8496. * The vector the camera should consider as up.
  8497. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8498. */
  8499. upVector: Vector3;
  8500. /**
  8501. * Define the current limit on the left side for an orthographic camera
  8502. * In scene unit
  8503. */
  8504. orthoLeft: Nullable<number>;
  8505. /**
  8506. * Define the current limit on the right side for an orthographic camera
  8507. * In scene unit
  8508. */
  8509. orthoRight: Nullable<number>;
  8510. /**
  8511. * Define the current limit on the bottom side for an orthographic camera
  8512. * In scene unit
  8513. */
  8514. orthoBottom: Nullable<number>;
  8515. /**
  8516. * Define the current limit on the top side for an orthographic camera
  8517. * In scene unit
  8518. */
  8519. orthoTop: Nullable<number>;
  8520. /**
  8521. * Field Of View is set in Radians. (default is 0.8)
  8522. */
  8523. fov: number;
  8524. /**
  8525. * Define the minimum distance the camera can see from.
  8526. * This is important to note that the depth buffer are not infinite and the closer it starts
  8527. * the more your scene might encounter depth fighting issue.
  8528. */
  8529. minZ: number;
  8530. /**
  8531. * Define the maximum distance the camera can see to.
  8532. * This is important to note that the depth buffer are not infinite and the further it end
  8533. * the more your scene might encounter depth fighting issue.
  8534. */
  8535. maxZ: number;
  8536. /**
  8537. * Define the default inertia of the camera.
  8538. * This helps giving a smooth feeling to the camera movement.
  8539. */
  8540. inertia: number;
  8541. /**
  8542. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8543. */
  8544. mode: number;
  8545. /**
  8546. * Define wether the camera is intermediate.
  8547. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  8548. */
  8549. isIntermediate: boolean;
  8550. /**
  8551. * Define the viewport of the camera.
  8552. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8553. */
  8554. viewport: Viewport;
  8555. /**
  8556. * Restricts the camera to viewing objects with the same layerMask.
  8557. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8558. */
  8559. layerMask: number;
  8560. /**
  8561. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8562. */
  8563. fovMode: number;
  8564. /**
  8565. * Rig mode of the camera.
  8566. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8567. * This is normally controlled byt the camera themselves as internal use.
  8568. */
  8569. cameraRigMode: number;
  8570. /**
  8571. * Defines the distance between both "eyes" in case of a RIG
  8572. */
  8573. interaxialDistance: number;
  8574. /**
  8575. * Defines if stereoscopic rendering is done side by side or over under.
  8576. */
  8577. isStereoscopicSideBySide: boolean;
  8578. /**
  8579. * 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
  8580. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8581. * else in the scene.
  8582. */
  8583. customRenderTargets: RenderTargetTexture[];
  8584. /**
  8585. * When set, the camera will render to this render target instead of the default canvas
  8586. */
  8587. outputRenderTarget: Nullable<RenderTargetTexture>;
  8588. /**
  8589. * Observable triggered when the camera view matrix has changed.
  8590. */
  8591. onViewMatrixChangedObservable: Observable<Camera>;
  8592. /**
  8593. * Observable triggered when the camera Projection matrix has changed.
  8594. */
  8595. onProjectionMatrixChangedObservable: Observable<Camera>;
  8596. /**
  8597. * Observable triggered when the inputs have been processed.
  8598. */
  8599. onAfterCheckInputsObservable: Observable<Camera>;
  8600. /**
  8601. * Observable triggered when reset has been called and applied to the camera.
  8602. */
  8603. onRestoreStateObservable: Observable<Camera>;
  8604. /** @hidden */
  8605. _cameraRigParams: any;
  8606. /** @hidden */
  8607. _rigCameras: Camera[];
  8608. /** @hidden */
  8609. _rigPostProcess: Nullable<PostProcess>;
  8610. protected _webvrViewMatrix: Matrix;
  8611. /** @hidden */
  8612. _skipRendering: boolean;
  8613. /** @hidden */
  8614. _alternateCamera: Camera;
  8615. /** @hidden */
  8616. _projectionMatrix: Matrix;
  8617. /** @hidden */
  8618. _postProcesses: Nullable<PostProcess>[];
  8619. /** @hidden */
  8620. _activeMeshes: SmartArray<AbstractMesh>;
  8621. protected _globalPosition: Vector3;
  8622. /** hidden */
  8623. _computedViewMatrix: Matrix;
  8624. private _doNotComputeProjectionMatrix;
  8625. private _transformMatrix;
  8626. private _frustumPlanes;
  8627. private _refreshFrustumPlanes;
  8628. private _storedFov;
  8629. private _stateStored;
  8630. /**
  8631. * Instantiates a new camera object.
  8632. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8633. * @see http://doc.babylonjs.com/features/cameras
  8634. * @param name Defines the name of the camera in the scene
  8635. * @param position Defines the position of the camera
  8636. * @param scene Defines the scene the camera belongs too
  8637. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8638. */
  8639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8640. /**
  8641. * Store current camera state (fov, position, etc..)
  8642. * @returns the camera
  8643. */
  8644. storeState(): Camera;
  8645. /**
  8646. * Restores the camera state values if it has been stored. You must call storeState() first
  8647. */
  8648. protected _restoreStateValues(): boolean;
  8649. /**
  8650. * Restored camera state. You must call storeState() first.
  8651. * @returns true if restored and false otherwise
  8652. */
  8653. restoreState(): boolean;
  8654. /**
  8655. * Gets the class name of the camera.
  8656. * @returns the class name
  8657. */
  8658. getClassName(): string;
  8659. /**
  8660. * Gets a string representation of the camera useful for debug purpose.
  8661. * @param fullDetails Defines that a more verboe level of logging is required
  8662. * @returns the string representation
  8663. */
  8664. toString(fullDetails?: boolean): string;
  8665. /**
  8666. * Gets the current world space position of the camera.
  8667. */
  8668. readonly globalPosition: Vector3;
  8669. /**
  8670. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8671. * @returns the active meshe list
  8672. */
  8673. getActiveMeshes(): SmartArray<AbstractMesh>;
  8674. /**
  8675. * Check wether a mesh is part of the current active mesh list of the camera
  8676. * @param mesh Defines the mesh to check
  8677. * @returns true if active, false otherwise
  8678. */
  8679. isActiveMesh(mesh: Mesh): boolean;
  8680. /**
  8681. * Is this camera ready to be used/rendered
  8682. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8683. * @return true if the camera is ready
  8684. */
  8685. isReady(completeCheck?: boolean): boolean;
  8686. /** @hidden */
  8687. _initCache(): void;
  8688. /** @hidden */
  8689. _updateCache(ignoreParentClass?: boolean): void;
  8690. /** @hidden */
  8691. _isSynchronized(): boolean;
  8692. /** @hidden */
  8693. _isSynchronizedViewMatrix(): boolean;
  8694. /** @hidden */
  8695. _isSynchronizedProjectionMatrix(): boolean;
  8696. /**
  8697. * Attach the input controls to a specific dom element to get the input from.
  8698. * @param element Defines the element the controls should be listened from
  8699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8700. */
  8701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8702. /**
  8703. * Detach the current controls from the specified dom element.
  8704. * @param element Defines the element to stop listening the inputs from
  8705. */
  8706. detachControl(element: HTMLElement): void;
  8707. /**
  8708. * Update the camera state according to the different inputs gathered during the frame.
  8709. */
  8710. update(): void;
  8711. /** @hidden */
  8712. _checkInputs(): void;
  8713. /** @hidden */
  8714. readonly rigCameras: Camera[];
  8715. /**
  8716. * Gets the post process used by the rig cameras
  8717. */
  8718. readonly rigPostProcess: Nullable<PostProcess>;
  8719. /**
  8720. * Internal, gets the first post proces.
  8721. * @returns the first post process to be run on this camera.
  8722. */
  8723. _getFirstPostProcess(): Nullable<PostProcess>;
  8724. private _cascadePostProcessesToRigCams;
  8725. /**
  8726. * Attach a post process to the camera.
  8727. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8728. * @param postProcess The post process to attach to the camera
  8729. * @param insertAt The position of the post process in case several of them are in use in the scene
  8730. * @returns the position the post process has been inserted at
  8731. */
  8732. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8733. /**
  8734. * Detach a post process to the camera.
  8735. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8736. * @param postProcess The post process to detach from the camera
  8737. */
  8738. detachPostProcess(postProcess: PostProcess): void;
  8739. /**
  8740. * Gets the current world matrix of the camera
  8741. */
  8742. getWorldMatrix(): Matrix;
  8743. /** @hidden */
  8744. protected _getViewMatrix(): Matrix;
  8745. /**
  8746. * Gets the current view matrix of the camera.
  8747. * @param force forces the camera to recompute the matrix without looking at the cached state
  8748. * @returns the view matrix
  8749. */
  8750. getViewMatrix(force?: boolean): Matrix;
  8751. /**
  8752. * Freeze the projection matrix.
  8753. * It will prevent the cache check of the camera projection compute and can speed up perf
  8754. * if no parameter of the camera are meant to change
  8755. * @param projection Defines manually a projection if necessary
  8756. */
  8757. freezeProjectionMatrix(projection?: Matrix): void;
  8758. /**
  8759. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8760. */
  8761. unfreezeProjectionMatrix(): void;
  8762. /**
  8763. * Gets the current projection matrix of the camera.
  8764. * @param force forces the camera to recompute the matrix without looking at the cached state
  8765. * @returns the projection matrix
  8766. */
  8767. getProjectionMatrix(force?: boolean): Matrix;
  8768. /**
  8769. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8770. * @returns a Matrix
  8771. */
  8772. getTransformationMatrix(): Matrix;
  8773. private _updateFrustumPlanes;
  8774. /**
  8775. * Checks if a cullable object (mesh...) is in the camera frustum
  8776. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8777. * @param target The object to check
  8778. * @returns true if the object is in frustum otherwise false
  8779. */
  8780. isInFrustum(target: ICullable): boolean;
  8781. /**
  8782. * Checks if a cullable object (mesh...) is in the camera frustum
  8783. * Unlike isInFrustum this cheks the full bounding box
  8784. * @param target The object to check
  8785. * @returns true if the object is in frustum otherwise false
  8786. */
  8787. isCompletelyInFrustum(target: ICullable): boolean;
  8788. /**
  8789. * Gets a ray in the forward direction from the camera.
  8790. * @param length Defines the length of the ray to create
  8791. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8792. * @param origin Defines the start point of the ray which defaults to the camera position
  8793. * @returns the forward ray
  8794. */
  8795. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8796. /**
  8797. * Releases resources associated with this node.
  8798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8800. */
  8801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8802. /**
  8803. * Gets the left camera of a rig setup in case of Rigged Camera
  8804. */
  8805. readonly leftCamera: Nullable<FreeCamera>;
  8806. /**
  8807. * Gets the right camera of a rig setup in case of Rigged Camera
  8808. */
  8809. readonly rightCamera: Nullable<FreeCamera>;
  8810. /**
  8811. * Gets the left camera target of a rig setup in case of Rigged Camera
  8812. * @returns the target position
  8813. */
  8814. getLeftTarget(): Nullable<Vector3>;
  8815. /**
  8816. * Gets the right camera target of a rig setup in case of Rigged Camera
  8817. * @returns the target position
  8818. */
  8819. getRightTarget(): Nullable<Vector3>;
  8820. /**
  8821. * @hidden
  8822. */
  8823. setCameraRigMode(mode: number, rigParams: any): void;
  8824. private _getVRProjectionMatrix;
  8825. protected _updateCameraRotationMatrix(): void;
  8826. protected _updateWebVRCameraRotationMatrix(): void;
  8827. /**
  8828. * This function MUST be overwritten by the different WebVR cameras available.
  8829. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8830. */
  8831. protected _getWebVRProjectionMatrix(): Matrix;
  8832. /**
  8833. * This function MUST be overwritten by the different WebVR cameras available.
  8834. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8835. */
  8836. protected _getWebVRViewMatrix(): Matrix;
  8837. /** @hidden */
  8838. setCameraRigParameter(name: string, value: any): void;
  8839. /**
  8840. * needs to be overridden by children so sub has required properties to be copied
  8841. * @hidden
  8842. */
  8843. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8844. /**
  8845. * May need to be overridden by children
  8846. * @hidden
  8847. */
  8848. _updateRigCameras(): void;
  8849. /** @hidden */
  8850. _setupInputs(): void;
  8851. /**
  8852. * Serialiaze the camera setup to a json represention
  8853. * @returns the JSON representation
  8854. */
  8855. serialize(): any;
  8856. /**
  8857. * Clones the current camera.
  8858. * @param name The cloned camera name
  8859. * @returns the cloned camera
  8860. */
  8861. clone(name: string): Camera;
  8862. /**
  8863. * Gets the direction of the camera relative to a given local axis.
  8864. * @param localAxis Defines the reference axis to provide a relative direction.
  8865. * @return the direction
  8866. */
  8867. getDirection(localAxis: Vector3): Vector3;
  8868. /**
  8869. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8870. * @param localAxis Defines the reference axis to provide a relative direction.
  8871. * @param result Defines the vector to store the result in
  8872. */
  8873. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8874. /**
  8875. * Gets a camera constructor for a given camera type
  8876. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8877. * @param name The name of the camera the result will be able to instantiate
  8878. * @param scene The scene the result will construct the camera in
  8879. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8880. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8881. * @returns a factory method to construc the camera
  8882. */
  8883. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8884. /**
  8885. * Compute the world matrix of the camera.
  8886. * @returns the camera workd matrix
  8887. */
  8888. computeWorldMatrix(): Matrix;
  8889. /**
  8890. * Parse a JSON and creates the camera from the parsed information
  8891. * @param parsedCamera The JSON to parse
  8892. * @param scene The scene to instantiate the camera in
  8893. * @returns the newly constructed camera
  8894. */
  8895. static Parse(parsedCamera: any, scene: Scene): Camera;
  8896. }
  8897. }
  8898. declare module BABYLON {
  8899. /**
  8900. * @ignore
  8901. * This is a list of all the different input types that are available in the application.
  8902. * Fo instance: ArcRotateCameraGamepadInput...
  8903. */
  8904. var CameraInputTypes: {};
  8905. /**
  8906. * This is the contract to implement in order to create a new input class.
  8907. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8908. */
  8909. interface ICameraInput<TCamera extends Camera> {
  8910. /**
  8911. * Defines the camera the input is attached to.
  8912. */
  8913. camera: Nullable<TCamera>;
  8914. /**
  8915. * Gets the class name of the current intput.
  8916. * @returns the class name
  8917. */
  8918. getClassName(): string;
  8919. /**
  8920. * Get the friendly name associated with the input class.
  8921. * @returns the input friendly name
  8922. */
  8923. getSimpleName(): string;
  8924. /**
  8925. * Attach the input controls to a specific dom element to get the input from.
  8926. * @param element Defines the element the controls should be listened from
  8927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8928. */
  8929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8930. /**
  8931. * Detach the current controls from the specified dom element.
  8932. * @param element Defines the element to stop listening the inputs from
  8933. */
  8934. detachControl(element: Nullable<HTMLElement>): void;
  8935. /**
  8936. * Update the current camera state depending on the inputs that have been used this frame.
  8937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8938. */
  8939. checkInputs?: () => void;
  8940. }
  8941. /**
  8942. * Represents a map of input types to input instance or input index to input instance.
  8943. */
  8944. interface CameraInputsMap<TCamera extends Camera> {
  8945. /**
  8946. * Accessor to the input by input type.
  8947. */
  8948. [name: string]: ICameraInput<TCamera>;
  8949. /**
  8950. * Accessor to the input by input index.
  8951. */
  8952. [idx: number]: ICameraInput<TCamera>;
  8953. }
  8954. /**
  8955. * This represents the input manager used within a camera.
  8956. * It helps dealing with all the different kind of input attached to a camera.
  8957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8958. */
  8959. class CameraInputsManager<TCamera extends Camera> {
  8960. /**
  8961. * Defines the list of inputs attahed to the camera.
  8962. */
  8963. attached: CameraInputsMap<TCamera>;
  8964. /**
  8965. * Defines the dom element the camera is collecting inputs from.
  8966. * This is null if the controls have not been attached.
  8967. */
  8968. attachedElement: Nullable<HTMLElement>;
  8969. /**
  8970. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8971. */
  8972. noPreventDefault: boolean;
  8973. /**
  8974. * Defined the camera the input manager belongs to.
  8975. */
  8976. camera: TCamera;
  8977. /**
  8978. * Update the current camera state depending on the inputs that have been used this frame.
  8979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8980. */
  8981. checkInputs: () => void;
  8982. /**
  8983. * Instantiate a new Camera Input Manager.
  8984. * @param camera Defines the camera the input manager blongs to
  8985. */
  8986. constructor(camera: TCamera);
  8987. /**
  8988. * Add an input method to a camera
  8989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8990. * @param input camera input method
  8991. */
  8992. add(input: ICameraInput<TCamera>): void;
  8993. /**
  8994. * Remove a specific input method from a camera
  8995. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8996. * @param inputToRemove camera input method
  8997. */
  8998. remove(inputToRemove: ICameraInput<TCamera>): void;
  8999. /**
  9000. * Remove a specific input type from a camera
  9001. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9002. * @param inputType the type of the input to remove
  9003. */
  9004. removeByType(inputType: string): void;
  9005. private _addCheckInputs;
  9006. /**
  9007. * Attach the input controls to the currently attached dom element to listen the events from.
  9008. * @param input Defines the input to attach
  9009. */
  9010. attachInput(input: ICameraInput<TCamera>): void;
  9011. /**
  9012. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9013. * @param element Defines the dom element to collect the events from
  9014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9015. */
  9016. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9017. /**
  9018. * Detach the current manager inputs controls from a specific dom element.
  9019. * @param element Defines the dom element to collect the events from
  9020. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9021. */
  9022. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9023. /**
  9024. * Rebuild the dynamic inputCheck function from the current list of
  9025. * defined inputs in the manager.
  9026. */
  9027. rebuildInputCheck(): void;
  9028. /**
  9029. * Remove all attached input methods from a camera
  9030. */
  9031. clear(): void;
  9032. /**
  9033. * Serialize the current input manager attached to a camera.
  9034. * This ensures than once parsed,
  9035. * the input associated to the camera will be identical to the current ones
  9036. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9037. */
  9038. serialize(serializedCamera: any): void;
  9039. /**
  9040. * Parses an input manager serialized JSON to restore the previous list of inputs
  9041. * and states associated to a camera.
  9042. * @param parsedCamera Defines the JSON to parse
  9043. */
  9044. parse(parsedCamera: any): void;
  9045. }
  9046. }
  9047. declare module BABYLON {
  9048. /**
  9049. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  9050. * being tilted forward or back and left or right.
  9051. */
  9052. class DeviceOrientationCamera extends FreeCamera {
  9053. private _initialQuaternion;
  9054. private _quaternionCache;
  9055. /**
  9056. * Creates a new device orientation camera
  9057. * @param name The name of the camera
  9058. * @param position The start position camera
  9059. * @param scene The scene the camera belongs to
  9060. */
  9061. constructor(name: string, position: Vector3, scene: Scene);
  9062. /**
  9063. * Gets the current instance class name ("DeviceOrientationCamera").
  9064. * This helps avoiding instanceof at run time.
  9065. * @returns the class name
  9066. */
  9067. getClassName(): string;
  9068. /**
  9069. * @hidden
  9070. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  9071. */
  9072. _checkInputs(): void;
  9073. /**
  9074. * Reset the camera to its default orientation on the specified axis only.
  9075. * @param axis The axis to reset
  9076. */
  9077. resetToCurrentRotation(axis?: Axis): void;
  9078. }
  9079. }
  9080. declare module BABYLON {
  9081. /**
  9082. * This is a flying camera, designed for 3D movement and rotation in all directions,
  9083. * such as in a 3D Space Shooter or a Flight Simulator.
  9084. */
  9085. class FlyCamera extends TargetCamera {
  9086. /**
  9087. * Define the collision ellipsoid of the camera.
  9088. * This is helpful for simulating a camera body, like a player's body.
  9089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  9090. */
  9091. ellipsoid: Vector3;
  9092. /**
  9093. * Define an offset for the position of the ellipsoid around the camera.
  9094. * This can be helpful if the camera is attached away from the player's body center,
  9095. * such as at its head.
  9096. */
  9097. ellipsoidOffset: Vector3;
  9098. /**
  9099. * Enable or disable collisions of the camera with the rest of the scene objects.
  9100. */
  9101. checkCollisions: boolean;
  9102. /**
  9103. * Enable or disable gravity on the camera.
  9104. */
  9105. applyGravity: boolean;
  9106. /**
  9107. * Define the current direction the camera is moving to.
  9108. */
  9109. cameraDirection: Vector3;
  9110. /**
  9111. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  9112. * This overrides and empties cameraRotation.
  9113. */
  9114. rotationQuaternion: BABYLON.Quaternion;
  9115. /**
  9116. * Track Roll to maintain the wanted Rolling when looking around.
  9117. */
  9118. _trackRoll: number;
  9119. /**
  9120. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  9121. */
  9122. rollCorrect: number;
  9123. /**
  9124. * Mimic a banked turn, Rolling the camera when Yawing.
  9125. * It's recommended to use rollCorrect = 10 for faster banking correction.
  9126. */
  9127. bankedTurn: boolean;
  9128. /**
  9129. * Limit in radians for how much Roll banking will add. (Default: 90°)
  9130. */
  9131. bankedTurnLimit: number;
  9132. /**
  9133. * Value of 0 disables the banked Roll.
  9134. * Value of 1 is equal to the Yaw angle in radians.
  9135. */
  9136. bankedTurnMultiplier: number;
  9137. /**
  9138. * The inputs manager loads all the input sources, such as keyboard and mouse.
  9139. */
  9140. inputs: FlyCameraInputsManager;
  9141. /**
  9142. * Gets the input sensibility for mouse input.
  9143. * Higher values reduce sensitivity.
  9144. */
  9145. /**
  9146. * Sets the input sensibility for a mouse input.
  9147. * Higher values reduce sensitivity.
  9148. */
  9149. angularSensibility: number;
  9150. /**
  9151. * Get the keys for camera movement forward.
  9152. */
  9153. /**
  9154. * Set the keys for camera movement forward.
  9155. */
  9156. keysForward: number[];
  9157. /**
  9158. * Get the keys for camera movement backward.
  9159. */
  9160. keysBackward: number[];
  9161. /**
  9162. * Get the keys for camera movement up.
  9163. */
  9164. /**
  9165. * Set the keys for camera movement up.
  9166. */
  9167. keysUp: number[];
  9168. /**
  9169. * Get the keys for camera movement down.
  9170. */
  9171. /**
  9172. * Set the keys for camera movement down.
  9173. */
  9174. keysDown: number[];
  9175. /**
  9176. * Get the keys for camera movement left.
  9177. */
  9178. /**
  9179. * Set the keys for camera movement left.
  9180. */
  9181. keysLeft: number[];
  9182. /**
  9183. * Set the keys for camera movement right.
  9184. */
  9185. /**
  9186. * Set the keys for camera movement right.
  9187. */
  9188. keysRight: number[];
  9189. /**
  9190. * Event raised when the camera collides with a mesh in the scene.
  9191. */
  9192. onCollide: (collidedMesh: AbstractMesh) => void;
  9193. private _collider;
  9194. private _needMoveForGravity;
  9195. private _oldPosition;
  9196. private _diffPosition;
  9197. private _newPosition;
  9198. /** @hidden */
  9199. _localDirection: Vector3;
  9200. /** @hidden */
  9201. _transformedDirection: Vector3;
  9202. /**
  9203. * Instantiates a FlyCamera.
  9204. * This is a flying camera, designed for 3D movement and rotation in all directions,
  9205. * such as in a 3D Space Shooter or a Flight Simulator.
  9206. * @param name Define the name of the camera in the scene.
  9207. * @param position Define the starting position of the camera in the scene.
  9208. * @param scene Define the scene the camera belongs to.
  9209. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  9210. */
  9211. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9212. /**
  9213. * Attach a control to the HTML DOM element.
  9214. * @param element Defines the element that listens to the input events.
  9215. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  9216. */
  9217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9218. /**
  9219. * Detach a control from the HTML DOM element.
  9220. * The camera will stop reacting to that input.
  9221. * @param element Defines the element that listens to the input events.
  9222. */
  9223. detachControl(element: HTMLElement): void;
  9224. private _collisionMask;
  9225. /**
  9226. * Get the mask that the camera ignores in collision events.
  9227. */
  9228. /**
  9229. * Set the mask that the camera ignores in collision events.
  9230. */
  9231. collisionMask: number;
  9232. /** @hidden */
  9233. _collideWithWorld(displacement: Vector3): void;
  9234. /** @hidden */
  9235. private _onCollisionPositionChange;
  9236. /** @hidden */
  9237. _checkInputs(): void;
  9238. /** @hidden */
  9239. _decideIfNeedsToMove(): boolean;
  9240. /** @hidden */
  9241. _updatePosition(): void;
  9242. /**
  9243. * Restore the Roll to its target value at the rate specified.
  9244. * @param rate - Higher means slower restoring.
  9245. * @hidden
  9246. */
  9247. restoreRoll(rate: number): void;
  9248. /**
  9249. * Destroy the camera and release the current resources held by it.
  9250. */
  9251. dispose(): void;
  9252. /**
  9253. * Get the current object class name.
  9254. * @returns the class name.
  9255. */
  9256. getClassName(): string;
  9257. }
  9258. }
  9259. declare module BABYLON {
  9260. /**
  9261. * Default Inputs manager for the FlyCamera.
  9262. * It groups all the default supported inputs for ease of use.
  9263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9264. */
  9265. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  9266. /**
  9267. * Instantiates a new FlyCameraInputsManager.
  9268. * @param camera Defines the camera the inputs belong to.
  9269. */
  9270. constructor(camera: FlyCamera);
  9271. /**
  9272. * Add keyboard input support to the input manager.
  9273. * @returns the new FlyCameraKeyboardMoveInput().
  9274. */
  9275. addKeyboard(): FlyCameraInputsManager;
  9276. /**
  9277. * Add mouse input support to the input manager.
  9278. * @param touchEnabled Enable touch screen support.
  9279. * @returns the new FlyCameraMouseInput().
  9280. */
  9281. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  9282. }
  9283. }
  9284. declare module BABYLON {
  9285. /**
  9286. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  9287. * an arc rotate version arcFollowCamera are available.
  9288. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9289. */
  9290. class FollowCamera extends TargetCamera {
  9291. /**
  9292. * Distance the follow camera should follow an object at
  9293. */
  9294. radius: number;
  9295. /**
  9296. * Define a rotation offset between the camera and the object it follows
  9297. */
  9298. rotationOffset: number;
  9299. /**
  9300. * Define a height offset between the camera and the object it follows.
  9301. * It can help following an object from the top (like a car chaing a plane)
  9302. */
  9303. heightOffset: number;
  9304. /**
  9305. * Define how fast the camera can accelerate to follow it s target.
  9306. */
  9307. cameraAcceleration: number;
  9308. /**
  9309. * Define the speed limit of the camera following an object.
  9310. */
  9311. maxCameraSpeed: number;
  9312. /**
  9313. * Define the target of the camera.
  9314. */
  9315. lockedTarget: Nullable<AbstractMesh>;
  9316. /**
  9317. * Instantiates the follow camera.
  9318. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9319. * @param name Define the name of the camera in the scene
  9320. * @param position Define the position of the camera
  9321. * @param scene Define the scene the camera belong to
  9322. * @param lockedTarget Define the target of the camera
  9323. */
  9324. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  9325. private _follow;
  9326. /** @hidden */
  9327. _checkInputs(): void;
  9328. /**
  9329. * Gets the camera class name.
  9330. * @returns the class name
  9331. */
  9332. getClassName(): string;
  9333. }
  9334. /**
  9335. * Arc Rotate version of the follow camera.
  9336. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  9337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9338. */
  9339. class ArcFollowCamera extends TargetCamera {
  9340. /** The longitudinal angle of the camera */
  9341. alpha: number;
  9342. /** The latitudinal angle of the camera */
  9343. beta: number;
  9344. /** The radius of the camera from its target */
  9345. radius: number;
  9346. /** Define the camera target (the messh it should follow) */
  9347. target: Nullable<AbstractMesh>;
  9348. private _cartesianCoordinates;
  9349. /**
  9350. * Instantiates a new ArcFollowCamera
  9351. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9352. * @param name Define the name of the camera
  9353. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  9354. * @param beta Define the rotation angle of the camera around the elevation axis
  9355. * @param radius Define the radius of the camera from its target point
  9356. * @param target Define the target of the camera
  9357. * @param scene Define the scene the camera belongs to
  9358. */
  9359. constructor(name: string,
  9360. /** The longitudinal angle of the camera */
  9361. alpha: number,
  9362. /** The latitudinal angle of the camera */
  9363. beta: number,
  9364. /** The radius of the camera from its target */
  9365. radius: number,
  9366. /** Define the camera target (the messh it should follow) */
  9367. target: Nullable<AbstractMesh>, scene: Scene);
  9368. private _follow;
  9369. /** @hidden */
  9370. _checkInputs(): void;
  9371. /**
  9372. * Returns the class name of the object.
  9373. * It is mostly used internally for serialization purposes.
  9374. */
  9375. getClassName(): string;
  9376. }
  9377. }
  9378. declare module BABYLON {
  9379. /**
  9380. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9381. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  9382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9383. */
  9384. class FreeCamera extends TargetCamera {
  9385. /**
  9386. * Define the collision ellipsoid of the camera.
  9387. * This is helpful to simulate a camera body like the player body around the camera
  9388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  9389. */
  9390. ellipsoid: Vector3;
  9391. /**
  9392. * Define an offset for the position of the ellipsoid around the camera.
  9393. * This can be helpful to determine the center of the body near the gravity center of the body
  9394. * instead of its head.
  9395. */
  9396. ellipsoidOffset: Vector3;
  9397. /**
  9398. * Enable or disable collisions of the camera with the rest of the scene objects.
  9399. */
  9400. checkCollisions: boolean;
  9401. /**
  9402. * Enable or disable gravity on the camera.
  9403. */
  9404. applyGravity: boolean;
  9405. /**
  9406. * Define the input manager associated to the camera.
  9407. */
  9408. inputs: FreeCameraInputsManager;
  9409. /**
  9410. * Gets the input sensibility for a mouse input. (default is 2000.0)
  9411. * Higher values reduce sensitivity.
  9412. */
  9413. /**
  9414. * Sets the input sensibility for a mouse input. (default is 2000.0)
  9415. * Higher values reduce sensitivity.
  9416. */
  9417. angularSensibility: number;
  9418. /**
  9419. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9420. */
  9421. keysUp: number[];
  9422. /**
  9423. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9424. */
  9425. keysDown: number[];
  9426. /**
  9427. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9428. */
  9429. keysLeft: number[];
  9430. /**
  9431. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9432. */
  9433. keysRight: number[];
  9434. /**
  9435. * Event raised when the camera collide with a mesh in the scene.
  9436. */
  9437. onCollide: (collidedMesh: AbstractMesh) => void;
  9438. private _collider;
  9439. private _needMoveForGravity;
  9440. private _oldPosition;
  9441. private _diffPosition;
  9442. private _newPosition;
  9443. /** @hidden */
  9444. _localDirection: Vector3;
  9445. /** @hidden */
  9446. _transformedDirection: Vector3;
  9447. /**
  9448. * Instantiates a Free Camera.
  9449. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9450. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  9451. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9452. * @param name Define the name of the camera in the scene
  9453. * @param position Define the start position of the camera in the scene
  9454. * @param scene Define the scene the camera belongs to
  9455. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9456. */
  9457. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9458. /**
  9459. * Attached controls to the current camera.
  9460. * @param element Defines the element the controls should be listened from
  9461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9462. */
  9463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9464. /**
  9465. * Detach the current controls from the camera.
  9466. * The camera will stop reacting to inputs.
  9467. * @param element Defines the element to stop listening the inputs from
  9468. */
  9469. detachControl(element: HTMLElement): void;
  9470. private _collisionMask;
  9471. /**
  9472. * Define a collision mask to limit the list of object the camera can collide with
  9473. */
  9474. collisionMask: number;
  9475. /** @hidden */
  9476. _collideWithWorld(displacement: Vector3): void;
  9477. private _onCollisionPositionChange;
  9478. /** @hidden */
  9479. _checkInputs(): void;
  9480. /** @hidden */
  9481. _decideIfNeedsToMove(): boolean;
  9482. /** @hidden */
  9483. _updatePosition(): void;
  9484. /**
  9485. * Destroy the camera and release the current resources hold by it.
  9486. */
  9487. dispose(): void;
  9488. /**
  9489. * Gets the current object class name.
  9490. * @return the class name
  9491. */
  9492. getClassName(): string;
  9493. }
  9494. }
  9495. declare module BABYLON {
  9496. /**
  9497. * Default Inputs manager for the FreeCamera.
  9498. * It groups all the default supported inputs for ease of use.
  9499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9500. */
  9501. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9502. /**
  9503. * Instantiates a new FreeCameraInputsManager.
  9504. * @param camera Defines the camera the inputs belong to
  9505. */
  9506. constructor(camera: FreeCamera);
  9507. /**
  9508. * Add keyboard input support to the input manager.
  9509. * @returns the current input manager
  9510. */
  9511. addKeyboard(): FreeCameraInputsManager;
  9512. /**
  9513. * Add mouse input support to the input manager.
  9514. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9515. * @returns the current input manager
  9516. */
  9517. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9518. /**
  9519. * Add orientation input support to the input manager.
  9520. * @returns the current input manager
  9521. */
  9522. addDeviceOrientation(): FreeCameraInputsManager;
  9523. /**
  9524. * Add touch input support to the input manager.
  9525. * @returns the current input manager
  9526. */
  9527. addTouch(): FreeCameraInputsManager;
  9528. /**
  9529. * Add virtual joystick input support to the input manager.
  9530. * @returns the current input manager
  9531. */
  9532. addVirtualJoystick(): FreeCameraInputsManager;
  9533. }
  9534. }
  9535. declare module BABYLON {
  9536. /**
  9537. * This represents a FPS type of camera. This is only here for back compat purpose.
  9538. * Please use the UniversalCamera instead as both are identical.
  9539. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9540. */
  9541. class GamepadCamera extends UniversalCamera {
  9542. /**
  9543. * Instantiates a new Gamepad Camera
  9544. * This represents a FPS type of camera. This is only here for back compat purpose.
  9545. * Please use the UniversalCamera instead as both are identical.
  9546. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9547. * @param name Define the name of the camera in the scene
  9548. * @param position Define the start position of the camera in the scene
  9549. * @param scene Define the scene the camera belongs to
  9550. */
  9551. constructor(name: string, position: Vector3, scene: Scene);
  9552. /**
  9553. * Gets the current object class name.
  9554. * @return the class name
  9555. */
  9556. getClassName(): string;
  9557. }
  9558. }
  9559. declare module BABYLON {
  9560. /**
  9561. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9562. * This is the base of the follow, arc rotate cameras and Free camera
  9563. * @see http://doc.babylonjs.com/features/cameras
  9564. */
  9565. class TargetCamera extends Camera {
  9566. private static _RigCamTransformMatrix;
  9567. private static _TargetTransformMatrix;
  9568. private static _TargetFocalPoint;
  9569. /**
  9570. * Define the current direction the camera is moving to
  9571. */
  9572. cameraDirection: Vector3;
  9573. /**
  9574. * Define the current rotation the camera is rotating to
  9575. */
  9576. cameraRotation: Vector2;
  9577. /**
  9578. * When set, the up vector of the camera will be updated by the rotation of the camera
  9579. */
  9580. updateUpVectorFromRotation: boolean;
  9581. private _tmpQuaternion;
  9582. /**
  9583. * Define the current rotation of the camera
  9584. */
  9585. rotation: Vector3;
  9586. /**
  9587. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9588. */
  9589. rotationQuaternion: Quaternion;
  9590. /**
  9591. * Define the current speed of the camera
  9592. */
  9593. speed: number;
  9594. /**
  9595. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9596. * around all axis.
  9597. */
  9598. noRotationConstraint: boolean;
  9599. /**
  9600. * Define the current target of the camera as an object or a position.
  9601. */
  9602. lockedTarget: any;
  9603. /** @hidden */
  9604. _currentTarget: Vector3;
  9605. /** @hidden */
  9606. _initialFocalDistance: number;
  9607. /** @hidden */
  9608. _viewMatrix: Matrix;
  9609. /** @hidden */
  9610. _camMatrix: Matrix;
  9611. /** @hidden */
  9612. _cameraTransformMatrix: Matrix;
  9613. /** @hidden */
  9614. _cameraRotationMatrix: Matrix;
  9615. /** @hidden */
  9616. _referencePoint: Vector3;
  9617. /** @hidden */
  9618. _transformedReferencePoint: Vector3;
  9619. protected _globalCurrentTarget: Vector3;
  9620. protected _globalCurrentUpVector: Vector3;
  9621. /** @hidden */
  9622. _reset: () => void;
  9623. private _defaultUp;
  9624. /**
  9625. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9626. * This is the base of the follow, arc rotate cameras and Free camera
  9627. * @see http://doc.babylonjs.com/features/cameras
  9628. * @param name Defines the name of the camera in the scene
  9629. * @param position Defines the start position of the camera in the scene
  9630. * @param scene Defines the scene the camera belongs to
  9631. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9632. */
  9633. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9634. /**
  9635. * Gets the position in front of the camera at a given distance.
  9636. * @param distance The distance from the camera we want the position to be
  9637. * @returns the position
  9638. */
  9639. getFrontPosition(distance: number): Vector3;
  9640. /** @hidden */
  9641. _getLockedTargetPosition(): Nullable<Vector3>;
  9642. private _storedPosition;
  9643. private _storedRotation;
  9644. private _storedRotationQuaternion;
  9645. /**
  9646. * Store current camera state of the camera (fov, position, rotation, etc..)
  9647. * @returns the camera
  9648. */
  9649. storeState(): Camera;
  9650. /**
  9651. * Restored camera state. You must call storeState() first
  9652. * @returns whether it was successful or not
  9653. * @hidden
  9654. */
  9655. _restoreStateValues(): boolean;
  9656. /** @hidden */
  9657. _initCache(): void;
  9658. /** @hidden */
  9659. _updateCache(ignoreParentClass?: boolean): void;
  9660. /** @hidden */
  9661. _isSynchronizedViewMatrix(): boolean;
  9662. /** @hidden */
  9663. _computeLocalCameraSpeed(): number;
  9664. /** @hidden */
  9665. setTarget(target: Vector3): void;
  9666. /**
  9667. * Return the current target position of the camera. This value is expressed in local space.
  9668. * @returns the target position
  9669. */
  9670. getTarget(): Vector3;
  9671. /** @hidden */
  9672. _decideIfNeedsToMove(): boolean;
  9673. /** @hidden */
  9674. _updatePosition(): void;
  9675. /** @hidden */
  9676. _checkInputs(): void;
  9677. protected _updateCameraRotationMatrix(): void;
  9678. /**
  9679. * 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)
  9680. * @returns the current camera
  9681. */
  9682. private _rotateUpVectorWithCameraRotationMatrix;
  9683. private _cachedRotationZ;
  9684. private _cachedQuaternionRotationZ;
  9685. /** @hidden */
  9686. _getViewMatrix(): Matrix;
  9687. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9688. /**
  9689. * @hidden
  9690. */
  9691. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9692. /**
  9693. * @hidden
  9694. */
  9695. _updateRigCameras(): void;
  9696. private _getRigCamPositionAndTarget;
  9697. /**
  9698. * Gets the current object class name.
  9699. * @return the class name
  9700. */
  9701. getClassName(): string;
  9702. }
  9703. }
  9704. declare module BABYLON {
  9705. /**
  9706. * This represents a FPS type of camera controlled by touch.
  9707. * This is like a universal camera minus the Gamepad controls.
  9708. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9709. */
  9710. class TouchCamera extends FreeCamera {
  9711. /**
  9712. * Defines the touch sensibility for rotation.
  9713. * The higher the faster.
  9714. */
  9715. touchAngularSensibility: number;
  9716. /**
  9717. * Defines the touch sensibility for move.
  9718. * The higher the faster.
  9719. */
  9720. touchMoveSensibility: number;
  9721. /**
  9722. * Instantiates a new touch camera.
  9723. * This represents a FPS type of camera controlled by touch.
  9724. * This is like a universal camera minus the Gamepad controls.
  9725. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9726. * @param name Define the name of the camera in the scene
  9727. * @param position Define the start position of the camera in the scene
  9728. * @param scene Define the scene the camera belongs to
  9729. */
  9730. constructor(name: string, position: Vector3, scene: Scene);
  9731. /**
  9732. * Gets the current object class name.
  9733. * @return the class name
  9734. */
  9735. getClassName(): string;
  9736. /** @hidden */
  9737. _setupInputs(): void;
  9738. }
  9739. }
  9740. declare module BABYLON {
  9741. /**
  9742. * 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,
  9743. * which still works and will still be found in many Playgrounds.
  9744. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9745. */
  9746. class UniversalCamera extends TouchCamera {
  9747. /**
  9748. * Defines the gamepad rotation sensiblity.
  9749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9750. */
  9751. gamepadAngularSensibility: number;
  9752. /**
  9753. * Defines the gamepad move sensiblity.
  9754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9755. */
  9756. gamepadMoveSensibility: number;
  9757. /**
  9758. * 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,
  9759. * which still works and will still be found in many Playgrounds.
  9760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9761. * @param name Define the name of the camera in the scene
  9762. * @param position Define the start position of the camera in the scene
  9763. * @param scene Define the scene the camera belongs to
  9764. */
  9765. constructor(name: string, position: Vector3, scene: Scene);
  9766. /**
  9767. * Gets the current object class name.
  9768. * @return the class name
  9769. */
  9770. getClassName(): string;
  9771. }
  9772. }
  9773. declare module BABYLON {
  9774. /**
  9775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9776. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9777. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9778. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9779. */
  9780. class VirtualJoysticksCamera extends FreeCamera {
  9781. /**
  9782. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  9783. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9784. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9785. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9786. * @param name Define the name of the camera in the scene
  9787. * @param position Define the start position of the camera in the scene
  9788. * @param scene Define the scene the camera belongs to
  9789. */
  9790. constructor(name: string, position: Vector3, scene: Scene);
  9791. /**
  9792. * Gets the current object class name.
  9793. * @return the class name
  9794. */
  9795. getClassName(): string;
  9796. }
  9797. }
  9798. interface VRDisplay extends EventTarget {
  9799. /**
  9800. * Dictionary of capabilities describing the VRDisplay.
  9801. */
  9802. readonly capabilities: VRDisplayCapabilities;
  9803. /**
  9804. * z-depth defining the far plane of the eye view frustum
  9805. * enables mapping of values in the render target depth
  9806. * attachment to scene coordinates. Initially set to 10000.0.
  9807. */
  9808. depthFar: number;
  9809. /**
  9810. * z-depth defining the near plane of the eye view frustum
  9811. * enables mapping of values in the render target depth
  9812. * attachment to scene coordinates. Initially set to 0.01.
  9813. */
  9814. depthNear: number;
  9815. /**
  9816. * An identifier for this distinct VRDisplay. Used as an
  9817. * association point in the Gamepad API.
  9818. */
  9819. readonly displayId: number;
  9820. /**
  9821. * A display name, a user-readable name identifying it.
  9822. */
  9823. readonly displayName: string;
  9824. readonly isConnected: boolean;
  9825. readonly isPresenting: boolean;
  9826. /**
  9827. * If this VRDisplay supports room-scale experiences, the optional
  9828. * stage attribute contains details on the room-scale parameters.
  9829. */
  9830. readonly stageParameters: VRStageParameters | null;
  9831. /**
  9832. * Passing the value returned by `requestAnimationFrame` to
  9833. * `cancelAnimationFrame` will unregister the callback.
  9834. * @param handle Define the hanle of the request to cancel
  9835. */
  9836. cancelAnimationFrame(handle: number): void;
  9837. /**
  9838. * Stops presenting to the VRDisplay.
  9839. * @returns a promise to know when it stopped
  9840. */
  9841. exitPresent(): Promise<void>;
  9842. /**
  9843. * Return the current VREyeParameters for the given eye.
  9844. * @param whichEye Define the eye we want the parameter for
  9845. * @returns the eye parameters
  9846. */
  9847. getEyeParameters(whichEye: string): VREyeParameters;
  9848. /**
  9849. * Populates the passed VRFrameData with the information required to render
  9850. * the current frame.
  9851. * @param frameData Define the data structure to populate
  9852. * @returns true if ok otherwise false
  9853. */
  9854. getFrameData(frameData: VRFrameData): boolean;
  9855. /**
  9856. * Get the layers currently being presented.
  9857. * @returns the list of VR layers
  9858. */
  9859. getLayers(): VRLayer[];
  9860. /**
  9861. * Return a VRPose containing the future predicted pose of the VRDisplay
  9862. * when the current frame will be presented. The value returned will not
  9863. * change until JavaScript has returned control to the browser.
  9864. *
  9865. * The VRPose will contain the position, orientation, velocity,
  9866. * and acceleration of each of these properties.
  9867. * @returns the pose object
  9868. */
  9869. getPose(): VRPose;
  9870. /**
  9871. * Return the current instantaneous pose of the VRDisplay, with no
  9872. * prediction applied.
  9873. * @returns the current instantaneous pose
  9874. */
  9875. getImmediatePose(): VRPose;
  9876. /**
  9877. * The callback passed to `requestAnimationFrame` will be called
  9878. * any time a new frame should be rendered. When the VRDisplay is
  9879. * presenting the callback will be called at the native refresh
  9880. * rate of the HMD. When not presenting this function acts
  9881. * identically to how window.requestAnimationFrame acts. Content should
  9882. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9883. * asynchronously from other displays and at differing refresh rates.
  9884. * @param callback Define the eaction to run next frame
  9885. * @returns the request handle it
  9886. */
  9887. requestAnimationFrame(callback: FrameRequestCallback): number;
  9888. /**
  9889. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9890. * Repeat calls while already presenting will update the VRLayers being displayed.
  9891. * @param layers Define the list of layer to present
  9892. * @returns a promise to know when the request has been fulfilled
  9893. */
  9894. requestPresent(layers: VRLayer[]): Promise<void>;
  9895. /**
  9896. * Reset the pose for this display, treating its current position and
  9897. * orientation as the "origin/zero" values. VRPose.position,
  9898. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9899. * updated when calling resetPose(). This should be called in only
  9900. * sitting-space experiences.
  9901. */
  9902. resetPose(): void;
  9903. /**
  9904. * The VRLayer provided to the VRDisplay will be captured and presented
  9905. * in the HMD. Calling this function has the same effect on the source
  9906. * canvas as any other operation that uses its source image, and canvases
  9907. * created without preserveDrawingBuffer set to true will be cleared.
  9908. * @param pose Define the pose to submit
  9909. */
  9910. submitFrame(pose?: VRPose): void;
  9911. }
  9912. declare var VRDisplay: {
  9913. prototype: VRDisplay;
  9914. new (): VRDisplay;
  9915. };
  9916. interface VRLayer {
  9917. leftBounds?: number[] | Float32Array | null;
  9918. rightBounds?: number[] | Float32Array | null;
  9919. source?: HTMLCanvasElement | null;
  9920. }
  9921. interface VRDisplayCapabilities {
  9922. readonly canPresent: boolean;
  9923. readonly hasExternalDisplay: boolean;
  9924. readonly hasOrientation: boolean;
  9925. readonly hasPosition: boolean;
  9926. readonly maxLayers: number;
  9927. }
  9928. interface VREyeParameters {
  9929. /** @deprecated */
  9930. readonly fieldOfView: VRFieldOfView;
  9931. readonly offset: Float32Array;
  9932. readonly renderHeight: number;
  9933. readonly renderWidth: number;
  9934. }
  9935. interface VRFieldOfView {
  9936. readonly downDegrees: number;
  9937. readonly leftDegrees: number;
  9938. readonly rightDegrees: number;
  9939. readonly upDegrees: number;
  9940. }
  9941. interface VRFrameData {
  9942. readonly leftProjectionMatrix: Float32Array;
  9943. readonly leftViewMatrix: Float32Array;
  9944. readonly pose: VRPose;
  9945. readonly rightProjectionMatrix: Float32Array;
  9946. readonly rightViewMatrix: Float32Array;
  9947. readonly timestamp: number;
  9948. }
  9949. interface VRPose {
  9950. readonly angularAcceleration: Float32Array | null;
  9951. readonly angularVelocity: Float32Array | null;
  9952. readonly linearAcceleration: Float32Array | null;
  9953. readonly linearVelocity: Float32Array | null;
  9954. readonly orientation: Float32Array | null;
  9955. readonly position: Float32Array | null;
  9956. readonly timestamp: number;
  9957. }
  9958. interface VRStageParameters {
  9959. sittingToStandingTransform?: Float32Array;
  9960. sizeX?: number;
  9961. sizeY?: number;
  9962. }
  9963. interface Navigator {
  9964. getVRDisplays(): Promise<VRDisplay[]>;
  9965. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9966. }
  9967. interface Window {
  9968. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9969. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9970. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9971. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9972. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9973. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9974. }
  9975. interface Gamepad {
  9976. readonly displayId: number;
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Interface for attribute information associated with buffer instanciation
  9981. */
  9982. class InstancingAttributeInfo {
  9983. /**
  9984. * Index/offset of the attribute in the vertex shader
  9985. */
  9986. index: number;
  9987. /**
  9988. * size of the attribute, 1, 2, 3 or 4
  9989. */
  9990. attributeSize: number;
  9991. /**
  9992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9993. * default is FLOAT
  9994. */
  9995. attribyteType: number;
  9996. /**
  9997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9998. */
  9999. normalized: boolean;
  10000. /**
  10001. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  10002. */
  10003. offset: number;
  10004. /**
  10005. * Name of the GLSL attribute, for debugging purpose only
  10006. */
  10007. attributeName: string;
  10008. }
  10009. /**
  10010. * Define options used to create a render target texture
  10011. */
  10012. class RenderTargetCreationOptions {
  10013. /**
  10014. * Specifies is mipmaps must be generated
  10015. */
  10016. generateMipMaps?: boolean;
  10017. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  10018. generateDepthBuffer?: boolean;
  10019. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  10020. generateStencilBuffer?: boolean;
  10021. /** Defines texture type (int by default) */
  10022. type?: number;
  10023. /** Defines sampling mode (trilinear by default) */
  10024. samplingMode?: number;
  10025. /** Defines format (RGBA by default) */
  10026. format?: number;
  10027. }
  10028. /**
  10029. * Define options used to create a depth texture
  10030. */
  10031. class DepthTextureCreationOptions {
  10032. /** Specifies whether or not a stencil should be allocated in the texture */
  10033. generateStencil?: boolean;
  10034. /** Specifies whether or not bilinear filtering is enable on the texture */
  10035. bilinearFiltering?: boolean;
  10036. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10037. comparisonFunction?: number;
  10038. /** Specifies if the created texture is a cube texture */
  10039. isCube?: boolean;
  10040. }
  10041. /**
  10042. * Class used to describe the capabilities of the engine relatively to the current browser
  10043. */
  10044. class EngineCapabilities {
  10045. /** Maximum textures units per fragment shader */
  10046. maxTexturesImageUnits: number;
  10047. /** Maximum texture units per vertex shader */
  10048. maxVertexTextureImageUnits: number;
  10049. /** Maximum textures units in the entire pipeline */
  10050. maxCombinedTexturesImageUnits: number;
  10051. /** Maximum texture size */
  10052. maxTextureSize: number;
  10053. /** Maximum cube texture size */
  10054. maxCubemapTextureSize: number;
  10055. /** Maximum render texture size */
  10056. maxRenderTextureSize: number;
  10057. /** Maximum number of vertex attributes */
  10058. maxVertexAttribs: number;
  10059. /** Maximum number of varyings */
  10060. maxVaryingVectors: number;
  10061. /** Maximum number of uniforms per vertex shader */
  10062. maxVertexUniformVectors: number;
  10063. /** Maximum number of uniforms per fragment shader */
  10064. maxFragmentUniformVectors: number;
  10065. /** Defines if standard derivates (dx/dy) are supported */
  10066. standardDerivatives: boolean;
  10067. /** Defines if s3tc texture compression is supported */
  10068. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10069. /** Defines if pvrtc texture compression is supported */
  10070. pvrtc: any;
  10071. /** Defines if etc1 texture compression is supported */
  10072. etc1: any;
  10073. /** Defines if etc2 texture compression is supported */
  10074. etc2: any;
  10075. /** Defines if astc texture compression is supported */
  10076. astc: any;
  10077. /** Defines if float textures are supported */
  10078. textureFloat: boolean;
  10079. /** Defines if vertex array objects are supported */
  10080. vertexArrayObject: boolean;
  10081. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10082. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10083. /** Gets the maximum level of anisotropy supported */
  10084. maxAnisotropy: number;
  10085. /** Defines if instancing is supported */
  10086. instancedArrays: boolean;
  10087. /** Defines if 32 bits indices are supported */
  10088. uintIndices: boolean;
  10089. /** Defines if high precision shaders are supported */
  10090. highPrecisionShaderSupported: boolean;
  10091. /** Defines if depth reading in the fragment shader is supported */
  10092. fragmentDepthSupported: boolean;
  10093. /** Defines if float texture linear filtering is supported*/
  10094. textureFloatLinearFiltering: boolean;
  10095. /** Defines if rendering to float textures is supported */
  10096. textureFloatRender: boolean;
  10097. /** Defines if half float textures are supported*/
  10098. textureHalfFloat: boolean;
  10099. /** Defines if half float texture linear filtering is supported*/
  10100. textureHalfFloatLinearFiltering: boolean;
  10101. /** Defines if rendering to half float textures is supported */
  10102. textureHalfFloatRender: boolean;
  10103. /** Defines if textureLOD shader command is supported */
  10104. textureLOD: boolean;
  10105. /** Defines if draw buffers extension is supported */
  10106. drawBuffersExtension: boolean;
  10107. /** Defines if depth textures are supported */
  10108. depthTextureExtension: boolean;
  10109. /** Defines if float color buffer are supported */
  10110. colorBufferFloat: boolean;
  10111. /** Gets disjoint timer query extension (null if not supported) */
  10112. timerQuery: EXT_disjoint_timer_query;
  10113. /** Defines if timestamp can be used with timer query */
  10114. canUseTimestampForTimerQuery: boolean;
  10115. /** Function used to let the system compiles shaders in background */
  10116. parallelShaderCompile: {
  10117. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10118. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10119. COMPLETION_STATUS_KHR: number;
  10120. };
  10121. }
  10122. /** Interface defining initialization parameters for Engine class */
  10123. interface EngineOptions extends WebGLContextAttributes {
  10124. /**
  10125. * Defines if the engine should no exceed a specified device ratio
  10126. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10127. */
  10128. limitDeviceRatio?: number;
  10129. /**
  10130. * Defines if webvr should be enabled automatically
  10131. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10132. */
  10133. autoEnableWebVR?: boolean;
  10134. /**
  10135. * Defines if webgl2 should be turned off even if supported
  10136. * @see http://doc.babylonjs.com/features/webgl2
  10137. */
  10138. disableWebGL2Support?: boolean;
  10139. /**
  10140. * Defines if webaudio should be initialized as well
  10141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10142. */
  10143. audioEngine?: boolean;
  10144. /**
  10145. * Defines if animations should run using a deterministic lock step
  10146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10147. */
  10148. deterministicLockstep?: boolean;
  10149. /** Defines the maximum steps to use with deterministic lock step mode */
  10150. lockstepMaxSteps?: number;
  10151. /**
  10152. * Defines that engine should ignore context lost events
  10153. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10154. */
  10155. doNotHandleContextLost?: boolean;
  10156. }
  10157. /**
  10158. * Defines the interface used by display changed events
  10159. */
  10160. interface IDisplayChangedEventArgs {
  10161. /** Gets the vrDisplay object (if any) */
  10162. vrDisplay: Nullable<any>;
  10163. /** Gets a boolean indicating if webVR is supported */
  10164. vrSupported: boolean;
  10165. }
  10166. /**
  10167. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10168. */
  10169. class Engine {
  10170. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10171. static ExceptionList: ({
  10172. key: string;
  10173. capture: string;
  10174. captureConstraint: number;
  10175. targets: string[];
  10176. } | {
  10177. key: string;
  10178. capture: null;
  10179. captureConstraint: null;
  10180. targets: string[];
  10181. })[];
  10182. /** Gets the list of created engines */
  10183. static Instances: Engine[];
  10184. /**
  10185. * Gets the latest created engine
  10186. */
  10187. static readonly LastCreatedEngine: Nullable<Engine>;
  10188. /**
  10189. * Gets the latest created scene
  10190. */
  10191. static readonly LastCreatedScene: Nullable<Scene>;
  10192. /**
  10193. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10194. * @param flag defines which part of the materials must be marked as dirty
  10195. * @param predicate defines a predicate used to filter which materials should be affected
  10196. */
  10197. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10198. /**
  10199. * Hidden
  10200. */
  10201. static _TextureLoaders: IInternalTextureLoader[];
  10202. /** Defines that alpha blending is disabled */
  10203. static readonly ALPHA_DISABLE: number;
  10204. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10205. static readonly ALPHA_ADD: number;
  10206. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10207. static readonly ALPHA_COMBINE: number;
  10208. /** Defines that alpha blending to DEST - SRC * DEST */
  10209. static readonly ALPHA_SUBTRACT: number;
  10210. /** Defines that alpha blending to SRC * DEST */
  10211. static readonly ALPHA_MULTIPLY: number;
  10212. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10213. static readonly ALPHA_MAXIMIZED: number;
  10214. /** Defines that alpha blending to SRC + DEST */
  10215. static readonly ALPHA_ONEONE: number;
  10216. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10217. static readonly ALPHA_PREMULTIPLIED: number;
  10218. /**
  10219. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10220. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10221. */
  10222. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10223. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10224. static readonly ALPHA_INTERPOLATE: number;
  10225. /**
  10226. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10227. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10228. */
  10229. static readonly ALPHA_SCREENMODE: number;
  10230. /** Defines that the ressource is not delayed*/
  10231. static readonly DELAYLOADSTATE_NONE: number;
  10232. /** Defines that the ressource was successfully delay loaded */
  10233. static readonly DELAYLOADSTATE_LOADED: number;
  10234. /** Defines that the ressource is currently delay loading */
  10235. static readonly DELAYLOADSTATE_LOADING: number;
  10236. /** Defines that the ressource is delayed and has not started loading */
  10237. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10238. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10239. static readonly NEVER: number;
  10240. /** 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 */
  10241. static readonly ALWAYS: number;
  10242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10243. static readonly LESS: number;
  10244. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10245. static readonly EQUAL: number;
  10246. /** 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 */
  10247. static readonly LEQUAL: number;
  10248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10249. static readonly GREATER: number;
  10250. /** 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 */
  10251. static readonly GEQUAL: number;
  10252. /** 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 */
  10253. static readonly NOTEQUAL: number;
  10254. /** Passed to stencilOperation to specify that stencil value must be kept */
  10255. static readonly KEEP: number;
  10256. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10257. static readonly REPLACE: number;
  10258. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10259. static readonly INCR: number;
  10260. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10261. static readonly DECR: number;
  10262. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10263. static readonly INVERT: number;
  10264. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10265. static readonly INCR_WRAP: number;
  10266. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10267. static readonly DECR_WRAP: number;
  10268. /** Texture is not repeating outside of 0..1 UVs */
  10269. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10270. /** Texture is repeating outside of 0..1 UVs */
  10271. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10272. /** Texture is repeating and mirrored */
  10273. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10274. /** ALPHA */
  10275. static readonly TEXTUREFORMAT_ALPHA: number;
  10276. /** LUMINANCE */
  10277. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10278. /** LUMINANCE_ALPHA */
  10279. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10280. /** RGB */
  10281. static readonly TEXTUREFORMAT_RGB: number;
  10282. /** RGBA */
  10283. static readonly TEXTUREFORMAT_RGBA: number;
  10284. /** RED */
  10285. static readonly TEXTUREFORMAT_RED: number;
  10286. /** RED (2nd reference) */
  10287. static readonly TEXTUREFORMAT_R: number;
  10288. /** RG */
  10289. static readonly TEXTUREFORMAT_RG: number;
  10290. /** RED_INTEGER */
  10291. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10292. /** RED_INTEGER (2nd reference) */
  10293. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10294. /** RG_INTEGER */
  10295. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10296. /** RGB_INTEGER */
  10297. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10298. /** RGBA_INTEGER */
  10299. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10300. /** UNSIGNED_BYTE */
  10301. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10302. /** UNSIGNED_BYTE (2nd reference) */
  10303. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10304. /** FLOAT */
  10305. static readonly TEXTURETYPE_FLOAT: number;
  10306. /** HALF_FLOAT */
  10307. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10308. /** BYTE */
  10309. static readonly TEXTURETYPE_BYTE: number;
  10310. /** SHORT */
  10311. static readonly TEXTURETYPE_SHORT: number;
  10312. /** UNSIGNED_SHORT */
  10313. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10314. /** INT */
  10315. static readonly TEXTURETYPE_INT: number;
  10316. /** UNSIGNED_INT */
  10317. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10318. /** UNSIGNED_SHORT_4_4_4_4 */
  10319. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10320. /** UNSIGNED_SHORT_5_5_5_1 */
  10321. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10322. /** UNSIGNED_SHORT_5_6_5 */
  10323. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10324. /** UNSIGNED_INT_2_10_10_10_REV */
  10325. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10326. /** UNSIGNED_INT_24_8 */
  10327. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10328. /** UNSIGNED_INT_10F_11F_11F_REV */
  10329. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10330. /** UNSIGNED_INT_5_9_9_9_REV */
  10331. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10332. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10333. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10334. /** nearest is mag = nearest and min = nearest and mip = linear */
  10335. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10336. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10337. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10338. /** Trilinear is mag = linear and min = linear and mip = linear */
  10339. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10340. /** nearest is mag = nearest and min = nearest and mip = linear */
  10341. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10343. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10344. /** Trilinear is mag = linear and min = linear and mip = linear */
  10345. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10346. /** mag = nearest and min = nearest and mip = nearest */
  10347. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10348. /** mag = nearest and min = linear and mip = nearest */
  10349. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10350. /** mag = nearest and min = linear and mip = linear */
  10351. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10352. /** mag = nearest and min = linear and mip = none */
  10353. static readonly TEXTURE_NEAREST_LINEAR: number;
  10354. /** mag = nearest and min = nearest and mip = none */
  10355. static readonly TEXTURE_NEAREST_NEAREST: number;
  10356. /** mag = linear and min = nearest and mip = nearest */
  10357. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10358. /** mag = linear and min = nearest and mip = linear */
  10359. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10360. /** mag = linear and min = linear and mip = none */
  10361. static readonly TEXTURE_LINEAR_LINEAR: number;
  10362. /** mag = linear and min = nearest and mip = none */
  10363. static readonly TEXTURE_LINEAR_NEAREST: number;
  10364. /** Explicit coordinates mode */
  10365. static readonly TEXTURE_EXPLICIT_MODE: number;
  10366. /** Spherical coordinates mode */
  10367. static readonly TEXTURE_SPHERICAL_MODE: number;
  10368. /** Planar coordinates mode */
  10369. static readonly TEXTURE_PLANAR_MODE: number;
  10370. /** Cubic coordinates mode */
  10371. static readonly TEXTURE_CUBIC_MODE: number;
  10372. /** Projection coordinates mode */
  10373. static readonly TEXTURE_PROJECTION_MODE: number;
  10374. /** Skybox coordinates mode */
  10375. static readonly TEXTURE_SKYBOX_MODE: number;
  10376. /** Inverse Cubic coordinates mode */
  10377. static readonly TEXTURE_INVCUBIC_MODE: number;
  10378. /** Equirectangular coordinates mode */
  10379. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10380. /** Equirectangular Fixed coordinates mode */
  10381. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10382. /** Equirectangular Fixed Mirrored coordinates mode */
  10383. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10384. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10385. static readonly SCALEMODE_FLOOR: number;
  10386. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10387. static readonly SCALEMODE_NEAREST: number;
  10388. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10389. static readonly SCALEMODE_CEILING: number;
  10390. /**
  10391. * Returns the current version of the framework
  10392. */
  10393. static readonly Version: string;
  10394. /**
  10395. * Returns a string describing the current engine
  10396. */
  10397. readonly description: string;
  10398. /**
  10399. * Gets or sets the epsilon value used by collision engine
  10400. */
  10401. static CollisionsEpsilon: number;
  10402. /**
  10403. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10404. */
  10405. static CodeRepository: string;
  10406. /**
  10407. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10408. */
  10409. static ShadersRepository: string;
  10410. /**
  10411. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10412. */
  10413. forcePOTTextures: boolean;
  10414. /**
  10415. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10416. */
  10417. isFullscreen: boolean;
  10418. /**
  10419. * Gets a boolean indicating if the pointer is currently locked
  10420. */
  10421. isPointerLock: boolean;
  10422. /**
  10423. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10424. */
  10425. cullBackFaces: boolean;
  10426. /**
  10427. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10428. */
  10429. renderEvenInBackground: boolean;
  10430. /**
  10431. * Gets or sets a boolean indicating that cache can be kept between frames
  10432. */
  10433. preventCacheWipeBetweenFrames: boolean;
  10434. /**
  10435. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10436. **/
  10437. enableOfflineSupport: boolean;
  10438. /**
  10439. * 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)
  10440. **/
  10441. disableManifestCheck: boolean;
  10442. /**
  10443. * Gets the list of created scenes
  10444. */
  10445. scenes: Scene[];
  10446. /**
  10447. * Event raised when a new scene is created
  10448. */
  10449. onNewSceneAddedObservable: Observable<Scene>;
  10450. /**
  10451. * Gets the list of created postprocesses
  10452. */
  10453. postProcesses: PostProcess[];
  10454. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10455. validateShaderPrograms: boolean;
  10456. /**
  10457. * Observable event triggered each time the rendering canvas is resized
  10458. */
  10459. onResizeObservable: Observable<Engine>;
  10460. /**
  10461. * Observable event triggered each time the canvas loses focus
  10462. */
  10463. onCanvasBlurObservable: Observable<Engine>;
  10464. /**
  10465. * Observable event triggered each time the canvas gains focus
  10466. */
  10467. onCanvasFocusObservable: Observable<Engine>;
  10468. /**
  10469. * Observable event triggered each time the canvas receives pointerout event
  10470. */
  10471. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10472. /**
  10473. * Observable event triggered before each texture is initialized
  10474. */
  10475. onBeforeTextureInitObservable: Observable<Texture>;
  10476. private _vrDisplay;
  10477. private _vrSupported;
  10478. private _oldSize;
  10479. private _oldHardwareScaleFactor;
  10480. private _vrExclusivePointerMode;
  10481. private _webVRInitPromise;
  10482. /**
  10483. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10484. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10485. */
  10486. readonly isInVRExclusivePointerMode: boolean;
  10487. /**
  10488. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10489. */
  10490. disableUniformBuffers: boolean;
  10491. /** @hidden */
  10492. _uniformBuffers: UniformBuffer[];
  10493. /**
  10494. * Gets a boolean indicating that the engine supports uniform buffers
  10495. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10496. */
  10497. readonly supportsUniformBuffers: boolean;
  10498. /**
  10499. * Observable raised when the engine begins a new frame
  10500. */
  10501. onBeginFrameObservable: Observable<Engine>;
  10502. /**
  10503. * If set, will be used to request the next animation frame for the render loop
  10504. */
  10505. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10506. /**
  10507. * Observable raised when the engine ends the current frame
  10508. */
  10509. onEndFrameObservable: Observable<Engine>;
  10510. /**
  10511. * Observable raised when the engine is about to compile a shader
  10512. */
  10513. onBeforeShaderCompilationObservable: Observable<Engine>;
  10514. /**
  10515. * Observable raised when the engine has jsut compiled a shader
  10516. */
  10517. onAfterShaderCompilationObservable: Observable<Engine>;
  10518. /** @hidden */
  10519. _gl: WebGLRenderingContext;
  10520. private _renderingCanvas;
  10521. private _windowIsBackground;
  10522. private _webGLVersion;
  10523. /**
  10524. * Gets a boolean indicating that only power of 2 textures are supported
  10525. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10526. */
  10527. readonly needPOTTextures: boolean;
  10528. /** @hidden */
  10529. _badOS: boolean;
  10530. /** @hidden */
  10531. _badDesktopOS: boolean;
  10532. /**
  10533. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10534. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10535. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10536. */
  10537. disableTextureBindingOptimization: boolean;
  10538. /**
  10539. * Gets the audio engine
  10540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10541. * @ignorenaming
  10542. */
  10543. static audioEngine: IAudioEngine;
  10544. /**
  10545. * Default AudioEngine factory responsible of creating the Audio Engine.
  10546. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10547. */
  10548. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10549. /**
  10550. * Default offline support factory responsible of creating a tool used to store data locally.
  10551. * By default, this will create a Database object if the workload has been embedded.
  10552. */
  10553. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10554. private _onFocus;
  10555. private _onBlur;
  10556. private _onCanvasPointerOut;
  10557. private _onCanvasBlur;
  10558. private _onCanvasFocus;
  10559. private _onFullscreenChange;
  10560. private _onPointerLockChange;
  10561. private _onVRDisplayPointerRestricted;
  10562. private _onVRDisplayPointerUnrestricted;
  10563. private _onVrDisplayConnect;
  10564. private _onVrDisplayDisconnect;
  10565. private _onVrDisplayPresentChange;
  10566. /**
  10567. * Observable signaled when VR display mode changes
  10568. */
  10569. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10570. /**
  10571. * Observable signaled when VR request present is complete
  10572. */
  10573. onVRRequestPresentComplete: Observable<boolean>;
  10574. /**
  10575. * Observable signaled when VR request present starts
  10576. */
  10577. onVRRequestPresentStart: Observable<Engine>;
  10578. private _hardwareScalingLevel;
  10579. /** @hidden */
  10580. protected _caps: EngineCapabilities;
  10581. private _pointerLockRequested;
  10582. private _isStencilEnable;
  10583. private _colorWrite;
  10584. private _loadingScreen;
  10585. /** @hidden */
  10586. _drawCalls: PerfCounter;
  10587. /** @hidden */
  10588. _textureCollisions: PerfCounter;
  10589. private _glVersion;
  10590. private _glRenderer;
  10591. private _glVendor;
  10592. private _videoTextureSupported;
  10593. private _renderingQueueLaunched;
  10594. private _activeRenderLoops;
  10595. private _deterministicLockstep;
  10596. private _lockstepMaxSteps;
  10597. /**
  10598. * Observable signaled when a context lost event is raised
  10599. */
  10600. onContextLostObservable: Observable<Engine>;
  10601. /**
  10602. * Observable signaled when a context restored event is raised
  10603. */
  10604. onContextRestoredObservable: Observable<Engine>;
  10605. private _onContextLost;
  10606. private _onContextRestored;
  10607. private _contextWasLost;
  10608. private _doNotHandleContextLost;
  10609. /**
  10610. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10612. */
  10613. doNotHandleContextLost: boolean;
  10614. private _performanceMonitor;
  10615. private _fps;
  10616. private _deltaTime;
  10617. /**
  10618. * Turn this value on if you want to pause FPS computation when in background
  10619. */
  10620. disablePerformanceMonitorInBackground: boolean;
  10621. /**
  10622. * Gets the performance monitor attached to this engine
  10623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10624. */
  10625. readonly performanceMonitor: PerformanceMonitor;
  10626. /** @hidden */
  10627. protected _depthCullingState: _DepthCullingState;
  10628. /** @hidden */
  10629. protected _stencilState: _StencilState;
  10630. /** @hidden */
  10631. protected _alphaState: _AlphaState;
  10632. /** @hidden */
  10633. protected _alphaMode: number;
  10634. protected _internalTexturesCache: InternalTexture[];
  10635. /** @hidden */
  10636. protected _activeChannel: number;
  10637. private _currentTextureChannel;
  10638. /** @hidden */
  10639. protected _boundTexturesCache: {
  10640. [key: string]: Nullable<InternalTexture>;
  10641. };
  10642. /** @hidden */
  10643. protected _currentEffect: Nullable<Effect>;
  10644. /** @hidden */
  10645. protected _currentProgram: Nullable<WebGLProgram>;
  10646. private _compiledEffects;
  10647. private _vertexAttribArraysEnabled;
  10648. /** @hidden */
  10649. protected _cachedViewport: Nullable<Viewport>;
  10650. private _cachedVertexArrayObject;
  10651. /** @hidden */
  10652. protected _cachedVertexBuffers: any;
  10653. /** @hidden */
  10654. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10655. /** @hidden */
  10656. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10657. /** @hidden */
  10658. protected _currentRenderTarget: Nullable<InternalTexture>;
  10659. private _uintIndicesCurrentlySet;
  10660. private _currentBoundBuffer;
  10661. /** @hidden */
  10662. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10663. private _currentBufferPointers;
  10664. private _currentInstanceLocations;
  10665. private _currentInstanceBuffers;
  10666. private _textureUnits;
  10667. private _firstBoundInternalTextureTracker;
  10668. private _lastBoundInternalTextureTracker;
  10669. private _workingCanvas;
  10670. private _workingContext;
  10671. private _rescalePostProcess;
  10672. private _dummyFramebuffer;
  10673. private _externalData;
  10674. private _bindedRenderFunction;
  10675. private _vaoRecordInProgress;
  10676. private _mustWipeVertexAttributes;
  10677. private _emptyTexture;
  10678. private _emptyCubeTexture;
  10679. private _emptyTexture3D;
  10680. /** @hidden */
  10681. _frameHandler: number;
  10682. private _nextFreeTextureSlots;
  10683. private _maxSimultaneousTextures;
  10684. private _activeRequests;
  10685. private _texturesSupported;
  10686. private _textureFormatInUse;
  10687. /**
  10688. * Gets the list of texture formats supported
  10689. */
  10690. readonly texturesSupported: Array<string>;
  10691. /**
  10692. * Gets the list of texture formats in use
  10693. */
  10694. readonly textureFormatInUse: Nullable<string>;
  10695. /**
  10696. * Gets the current viewport
  10697. */
  10698. readonly currentViewport: Nullable<Viewport>;
  10699. /**
  10700. * Gets the default empty texture
  10701. */
  10702. readonly emptyTexture: InternalTexture;
  10703. /**
  10704. * Gets the default empty 3D texture
  10705. */
  10706. readonly emptyTexture3D: InternalTexture;
  10707. /**
  10708. * Gets the default empty cube texture
  10709. */
  10710. readonly emptyCubeTexture: InternalTexture;
  10711. /**
  10712. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10713. */
  10714. readonly premultipliedAlpha: boolean;
  10715. /**
  10716. * Creates a new engine
  10717. * @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
  10718. * @param antialias defines enable antialiasing (default: false)
  10719. * @param options defines further options to be sent to the getContext() function
  10720. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10721. */
  10722. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10723. private _rebuildInternalTextures;
  10724. private _rebuildEffects;
  10725. /**
  10726. * Gets a boolean indicating if all created effects are ready
  10727. * @returns true if all effects are ready
  10728. */
  10729. areAllEffectsReady(): boolean;
  10730. private _rebuildBuffers;
  10731. private _initGLContext;
  10732. /**
  10733. * Gets version of the current webGL context
  10734. */
  10735. readonly webGLVersion: number;
  10736. /**
  10737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10738. */
  10739. readonly isStencilEnable: boolean;
  10740. private _prepareWorkingCanvas;
  10741. /**
  10742. * Reset the texture cache to empty state
  10743. */
  10744. resetTextureCache(): void;
  10745. /**
  10746. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10748. * @returns true if engine is in deterministic lock step mode
  10749. */
  10750. isDeterministicLockStep(): boolean;
  10751. /**
  10752. * Gets the max steps when engine is running in deterministic lock step
  10753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10754. * @returns the max steps
  10755. */
  10756. getLockstepMaxSteps(): number;
  10757. /**
  10758. * Gets an object containing information about the current webGL context
  10759. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10760. */
  10761. getGlInfo(): {
  10762. vendor: string;
  10763. renderer: string;
  10764. version: string;
  10765. };
  10766. /**
  10767. * Gets current aspect ratio
  10768. * @param camera defines the camera to use to get the aspect ratio
  10769. * @param useScreen defines if screen size must be used (or the current render target if any)
  10770. * @returns a number defining the aspect ratio
  10771. */
  10772. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10773. /**
  10774. * Gets current screen aspect ratio
  10775. * @returns a number defining the aspect ratio
  10776. */
  10777. getScreenAspectRatio(): number;
  10778. /**
  10779. * Gets the current render width
  10780. * @param useScreen defines if screen size must be used (or the current render target if any)
  10781. * @returns a number defining the current render width
  10782. */
  10783. getRenderWidth(useScreen?: boolean): number;
  10784. /**
  10785. * Gets the current render height
  10786. * @param useScreen defines if screen size must be used (or the current render target if any)
  10787. * @returns a number defining the current render height
  10788. */
  10789. getRenderHeight(useScreen?: boolean): number;
  10790. /**
  10791. * Gets the HTML canvas attached with the current webGL context
  10792. * @returns a HTML canvas
  10793. */
  10794. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10795. /**
  10796. * Gets the client rect of the HTML canvas attached with the current webGL context
  10797. * @returns a client rectanglee
  10798. */
  10799. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10800. /**
  10801. * Defines the hardware scaling level.
  10802. * By default the hardware scaling level is computed from the window device ratio.
  10803. * 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.
  10804. * @param level defines the level to use
  10805. */
  10806. setHardwareScalingLevel(level: number): void;
  10807. /**
  10808. * Gets the current hardware scaling level.
  10809. * By default the hardware scaling level is computed from the window device ratio.
  10810. * 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.
  10811. * @returns a number indicating the current hardware scaling level
  10812. */
  10813. getHardwareScalingLevel(): number;
  10814. /**
  10815. * Gets the list of loaded textures
  10816. * @returns an array containing all loaded textures
  10817. */
  10818. getLoadedTexturesCache(): InternalTexture[];
  10819. /**
  10820. * Gets the object containing all engine capabilities
  10821. * @returns the EngineCapabilities object
  10822. */
  10823. getCaps(): EngineCapabilities;
  10824. /**
  10825. * Gets the current depth function
  10826. * @returns a number defining the depth function
  10827. */
  10828. getDepthFunction(): Nullable<number>;
  10829. /**
  10830. * Sets the current depth function
  10831. * @param depthFunc defines the function to use
  10832. */
  10833. setDepthFunction(depthFunc: number): void;
  10834. /**
  10835. * Sets the current depth function to GREATER
  10836. */
  10837. setDepthFunctionToGreater(): void;
  10838. /**
  10839. * Sets the current depth function to GEQUAL
  10840. */
  10841. setDepthFunctionToGreaterOrEqual(): void;
  10842. /**
  10843. * Sets the current depth function to LESS
  10844. */
  10845. setDepthFunctionToLess(): void;
  10846. /**
  10847. * Sets the current depth function to LEQUAL
  10848. */
  10849. setDepthFunctionToLessOrEqual(): void;
  10850. /**
  10851. * Gets a boolean indicating if stencil buffer is enabled
  10852. * @returns the current stencil buffer state
  10853. */
  10854. getStencilBuffer(): boolean;
  10855. /**
  10856. * Enable or disable the stencil buffer
  10857. * @param enable defines if the stencil buffer must be enabled or disabled
  10858. */
  10859. setStencilBuffer(enable: boolean): void;
  10860. /**
  10861. * Gets the current stencil mask
  10862. * @returns a number defining the new stencil mask to use
  10863. */
  10864. getStencilMask(): number;
  10865. /**
  10866. * Sets the current stencil mask
  10867. * @param mask defines the new stencil mask to use
  10868. */
  10869. setStencilMask(mask: number): void;
  10870. /**
  10871. * Gets the current stencil function
  10872. * @returns a number defining the stencil function to use
  10873. */
  10874. getStencilFunction(): number;
  10875. /**
  10876. * Gets the current stencil reference value
  10877. * @returns a number defining the stencil reference value to use
  10878. */
  10879. getStencilFunctionReference(): number;
  10880. /**
  10881. * Gets the current stencil mask
  10882. * @returns a number defining the stencil mask to use
  10883. */
  10884. getStencilFunctionMask(): number;
  10885. /**
  10886. * Sets the current stencil function
  10887. * @param stencilFunc defines the new stencil function to use
  10888. */
  10889. setStencilFunction(stencilFunc: number): void;
  10890. /**
  10891. * Sets the current stencil reference
  10892. * @param reference defines the new stencil reference to use
  10893. */
  10894. setStencilFunctionReference(reference: number): void;
  10895. /**
  10896. * Sets the current stencil mask
  10897. * @param mask defines the new stencil mask to use
  10898. */
  10899. setStencilFunctionMask(mask: number): void;
  10900. /**
  10901. * Gets the current stencil operation when stencil fails
  10902. * @returns a number defining stencil operation to use when stencil fails
  10903. */
  10904. getStencilOperationFail(): number;
  10905. /**
  10906. * Gets the current stencil operation when depth fails
  10907. * @returns a number defining stencil operation to use when depth fails
  10908. */
  10909. getStencilOperationDepthFail(): number;
  10910. /**
  10911. * Gets the current stencil operation when stencil passes
  10912. * @returns a number defining stencil operation to use when stencil passes
  10913. */
  10914. getStencilOperationPass(): number;
  10915. /**
  10916. * Sets the stencil operation to use when stencil fails
  10917. * @param operation defines the stencil operation to use when stencil fails
  10918. */
  10919. setStencilOperationFail(operation: number): void;
  10920. /**
  10921. * Sets the stencil operation to use when depth fails
  10922. * @param operation defines the stencil operation to use when depth fails
  10923. */
  10924. setStencilOperationDepthFail(operation: number): void;
  10925. /**
  10926. * Sets the stencil operation to use when stencil passes
  10927. * @param operation defines the stencil operation to use when stencil passes
  10928. */
  10929. setStencilOperationPass(operation: number): void;
  10930. /**
  10931. * Sets a boolean indicating if the dithering state is enabled or disabled
  10932. * @param value defines the dithering state
  10933. */
  10934. setDitheringState(value: boolean): void;
  10935. /**
  10936. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10937. * @param value defines the rasterizer state
  10938. */
  10939. setRasterizerState(value: boolean): void;
  10940. /**
  10941. * stop executing a render loop function and remove it from the execution array
  10942. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10943. */
  10944. stopRenderLoop(renderFunction?: () => void): void;
  10945. /** @hidden */
  10946. _renderLoop(): void;
  10947. /**
  10948. * Register and execute a render loop. The engine can have more than one render function
  10949. * @param renderFunction defines the function to continuously execute
  10950. */
  10951. runRenderLoop(renderFunction: () => void): void;
  10952. /**
  10953. * Toggle full screen mode
  10954. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10955. */
  10956. switchFullscreen(requestPointerLock: boolean): void;
  10957. /**
  10958. * Clear the current render buffer or the current render target (if any is set up)
  10959. * @param color defines the color to use
  10960. * @param backBuffer defines if the back buffer must be cleared
  10961. * @param depth defines if the depth buffer must be cleared
  10962. * @param stencil defines if the stencil buffer must be cleared
  10963. */
  10964. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10965. /**
  10966. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10967. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10968. * @param y defines the y-coordinate of the corner of the clear rectangle
  10969. * @param width defines the width of the clear rectangle
  10970. * @param height defines the height of the clear rectangle
  10971. * @param clearColor defines the clear color
  10972. */
  10973. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10974. /**
  10975. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  10976. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10977. * @param y defines the y-coordinate of the corner of the clear rectangle
  10978. * @param width defines the width of the clear rectangle
  10979. * @param height defines the height of the clear rectangle
  10980. */
  10981. enableScissor(x: number, y: number, width: number, height: number): void;
  10982. /**
  10983. * Disable previously set scissor test rectangle
  10984. */
  10985. disableScissor(): void;
  10986. private _viewportCached;
  10987. /** @hidden */
  10988. _viewport(x: number, y: number, width: number, height: number): void;
  10989. /**
  10990. * Set the WebGL's viewport
  10991. * @param viewport defines the viewport element to be used
  10992. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10993. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10994. */
  10995. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10996. /**
  10997. * Directly set the WebGL Viewport
  10998. * @param x defines the x coordinate of the viewport (in screen space)
  10999. * @param y defines the y coordinate of the viewport (in screen space)
  11000. * @param width defines the width of the viewport (in screen space)
  11001. * @param height defines the height of the viewport (in screen space)
  11002. * @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
  11003. */
  11004. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  11005. /**
  11006. * Begin a new frame
  11007. */
  11008. beginFrame(): void;
  11009. /**
  11010. * Enf the current frame
  11011. */
  11012. endFrame(): void;
  11013. /**
  11014. * Resize the view according to the canvas' size
  11015. */
  11016. resize(): void;
  11017. /**
  11018. * Force a specific size of the canvas
  11019. * @param width defines the new canvas' width
  11020. * @param height defines the new canvas' height
  11021. */
  11022. setSize(width: number, height: number): void;
  11023. /**
  11024. * Gets a boolean indicating if a webVR device was detected
  11025. * @returns true if a webVR device was detected
  11026. */
  11027. isVRDevicePresent(): boolean;
  11028. /**
  11029. * Gets the current webVR device
  11030. * @returns the current webVR device (or null)
  11031. */
  11032. getVRDevice(): any;
  11033. /**
  11034. * Initializes a webVR display and starts listening to display change events
  11035. * The onVRDisplayChangedObservable will be notified upon these changes
  11036. * @returns The onVRDisplayChangedObservable
  11037. */
  11038. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11039. /**
  11040. * Initializes a webVR display and starts listening to display change events
  11041. * The onVRDisplayChangedObservable will be notified upon these changes
  11042. * @returns A promise containing a VRDisplay and if vr is supported
  11043. */
  11044. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11045. /**
  11046. * Call this function to switch to webVR mode
  11047. * Will do nothing if webVR is not supported or if there is no webVR device
  11048. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11049. */
  11050. enableVR(): void;
  11051. /**
  11052. * Call this function to leave webVR mode
  11053. * Will do nothing if webVR is not supported or if there is no webVR device
  11054. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11055. */
  11056. disableVR(): void;
  11057. private _onVRFullScreenTriggered;
  11058. private _getVRDisplaysAsync;
  11059. /**
  11060. * Binds the frame buffer to the specified texture.
  11061. * @param texture The texture to render to or null for the default canvas
  11062. * @param faceIndex The face of the texture to render to in case of cube texture
  11063. * @param requiredWidth The width of the target to render to
  11064. * @param requiredHeight The height of the target to render to
  11065. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11066. * @param depthStencilTexture The depth stencil texture to use to render
  11067. * @param lodLevel defines le lod level to bind to the frame buffer
  11068. */
  11069. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11070. private bindUnboundFramebuffer;
  11071. /**
  11072. * Unbind the current render target texture from the webGL context
  11073. * @param texture defines the render target texture to unbind
  11074. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11075. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11076. */
  11077. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11078. /**
  11079. * Unbind a list of render target textures from the webGL context
  11080. * This is used only when drawBuffer extension or webGL2 are active
  11081. * @param textures defines the render target textures to unbind
  11082. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11083. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11084. */
  11085. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11086. /**
  11087. * Force the mipmap generation for the given render target texture
  11088. * @param texture defines the render target texture to use
  11089. */
  11090. generateMipMapsForCubemap(texture: InternalTexture): void;
  11091. /**
  11092. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11093. */
  11094. flushFramebuffer(): void;
  11095. /**
  11096. * Unbind the current render target and bind the default framebuffer
  11097. */
  11098. restoreDefaultFramebuffer(): void;
  11099. /**
  11100. * Create an uniform buffer
  11101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11102. * @param elements defines the content of the uniform buffer
  11103. * @returns the webGL uniform buffer
  11104. */
  11105. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11106. /**
  11107. * Create a dynamic uniform buffer
  11108. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11109. * @param elements defines the content of the uniform buffer
  11110. * @returns the webGL uniform buffer
  11111. */
  11112. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11113. /**
  11114. * Update an existing uniform buffer
  11115. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11116. * @param uniformBuffer defines the target uniform buffer
  11117. * @param elements defines the content to update
  11118. * @param offset defines the offset in the uniform buffer where update should start
  11119. * @param count defines the size of the data to update
  11120. */
  11121. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11122. private _resetVertexBufferBinding;
  11123. /**
  11124. * Creates a vertex buffer
  11125. * @param data the data for the vertex buffer
  11126. * @returns the new WebGL static buffer
  11127. */
  11128. createVertexBuffer(data: DataArray): WebGLBuffer;
  11129. /**
  11130. * Creates a dynamic vertex buffer
  11131. * @param data the data for the dynamic vertex buffer
  11132. * @returns the new WebGL dynamic buffer
  11133. */
  11134. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11135. /**
  11136. * Update a dynamic index buffer
  11137. * @param indexBuffer defines the target index buffer
  11138. * @param indices defines the data to update
  11139. * @param offset defines the offset in the target index buffer where update should start
  11140. */
  11141. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11142. /**
  11143. * Updates a dynamic vertex buffer.
  11144. * @param vertexBuffer the vertex buffer to update
  11145. * @param data the data used to update the vertex buffer
  11146. * @param byteOffset the byte offset of the data
  11147. * @param byteLength the byte length of the data
  11148. */
  11149. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11150. private _resetIndexBufferBinding;
  11151. /**
  11152. * Creates a new index buffer
  11153. * @param indices defines the content of the index buffer
  11154. * @param updatable defines if the index buffer must be updatable
  11155. * @returns a new webGL buffer
  11156. */
  11157. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11158. /**
  11159. * Bind a webGL buffer to the webGL context
  11160. * @param buffer defines the buffer to bind
  11161. */
  11162. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11163. /**
  11164. * Bind an uniform buffer to the current webGL context
  11165. * @param buffer defines the buffer to bind
  11166. */
  11167. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11168. /**
  11169. * Bind a buffer to the current webGL context at a given location
  11170. * @param buffer defines the buffer to bind
  11171. * @param location defines the index where to bind the buffer
  11172. */
  11173. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11174. /**
  11175. * Bind a specific block at a given index in a specific shader program
  11176. * @param shaderProgram defines the shader program
  11177. * @param blockName defines the block name
  11178. * @param index defines the index where to bind the block
  11179. */
  11180. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11181. private bindIndexBuffer;
  11182. private bindBuffer;
  11183. /**
  11184. * update the bound buffer with the given data
  11185. * @param data defines the data to update
  11186. */
  11187. updateArrayBuffer(data: Float32Array): void;
  11188. private _vertexAttribPointer;
  11189. private _bindIndexBufferWithCache;
  11190. private _bindVertexBuffersAttributes;
  11191. /**
  11192. * Records a vertex array object
  11193. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11194. * @param vertexBuffers defines the list of vertex buffers to store
  11195. * @param indexBuffer defines the index buffer to store
  11196. * @param effect defines the effect to store
  11197. * @returns the new vertex array object
  11198. */
  11199. recordVertexArrayObject(vertexBuffers: {
  11200. [key: string]: VertexBuffer;
  11201. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11202. /**
  11203. * Bind a specific vertex array object
  11204. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11205. * @param vertexArrayObject defines the vertex array object to bind
  11206. * @param indexBuffer defines the index buffer to bind
  11207. */
  11208. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11209. /**
  11210. * Bind webGl buffers directly to the webGL context
  11211. * @param vertexBuffer defines the vertex buffer to bind
  11212. * @param indexBuffer defines the index buffer to bind
  11213. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11214. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11215. * @param effect defines the effect associated with the vertex buffer
  11216. */
  11217. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11218. private _unbindVertexArrayObject;
  11219. /**
  11220. * Bind a list of vertex buffers to the webGL context
  11221. * @param vertexBuffers defines the list of vertex buffers to bind
  11222. * @param indexBuffer defines the index buffer to bind
  11223. * @param effect defines the effect associated with the vertex buffers
  11224. */
  11225. bindBuffers(vertexBuffers: {
  11226. [key: string]: Nullable<VertexBuffer>;
  11227. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11228. /**
  11229. * Unbind all instance attributes
  11230. */
  11231. unbindInstanceAttributes(): void;
  11232. /**
  11233. * Release and free the memory of a vertex array object
  11234. * @param vao defines the vertex array object to delete
  11235. */
  11236. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11237. /** @hidden */
  11238. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11239. /**
  11240. * Creates a webGL buffer to use with instanciation
  11241. * @param capacity defines the size of the buffer
  11242. * @returns the webGL buffer
  11243. */
  11244. createInstancesBuffer(capacity: number): WebGLBuffer;
  11245. /**
  11246. * Delete a webGL buffer used with instanciation
  11247. * @param buffer defines the webGL buffer to delete
  11248. */
  11249. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11250. /**
  11251. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11252. * @param instancesBuffer defines the webGL buffer to update and bind
  11253. * @param data defines the data to store in the buffer
  11254. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11255. */
  11256. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11257. /**
  11258. * Apply all cached states (depth, culling, stencil and alpha)
  11259. */
  11260. applyStates(): void;
  11261. /**
  11262. * Send a draw order
  11263. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11264. * @param indexStart defines the starting index
  11265. * @param indexCount defines the number of index to draw
  11266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11267. */
  11268. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11269. /**
  11270. * Draw a list of points
  11271. * @param verticesStart defines the index of first vertex to draw
  11272. * @param verticesCount defines the count of vertices to draw
  11273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11274. */
  11275. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11276. /**
  11277. * Draw a list of unindexed primitives
  11278. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11279. * @param verticesStart defines the index of first vertex to draw
  11280. * @param verticesCount defines the count of vertices to draw
  11281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11282. */
  11283. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11284. /**
  11285. * Draw a list of indexed primitives
  11286. * @param fillMode defines the primitive to use
  11287. * @param indexStart defines the starting index
  11288. * @param indexCount defines the number of index to draw
  11289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11290. */
  11291. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11292. /**
  11293. * Draw a list of unindexed primitives
  11294. * @param fillMode defines the primitive to use
  11295. * @param verticesStart defines the index of first vertex to draw
  11296. * @param verticesCount defines the count of vertices to draw
  11297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11298. */
  11299. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11300. private _drawMode;
  11301. /** @hidden */
  11302. _releaseEffect(effect: Effect): void;
  11303. /** @hidden */
  11304. _deleteProgram(program: WebGLProgram): void;
  11305. /**
  11306. * Create a new effect (used to store vertex/fragment shaders)
  11307. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11308. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11309. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11310. * @param samplers defines an array of string used to represent textures
  11311. * @param defines defines the string containing the defines to use to compile the shaders
  11312. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11313. * @param onCompiled defines a function to call when the effect creation is successful
  11314. * @param onError defines a function to call when the effect creation has failed
  11315. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11316. * @returns the new Effect
  11317. */
  11318. 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;
  11319. private _compileShader;
  11320. private _compileRawShader;
  11321. /**
  11322. * Directly creates a webGL program
  11323. * @param vertexCode defines the vertex shader code to use
  11324. * @param fragmentCode defines the fragment shader code to use
  11325. * @param context defines the webGL context to use (if not set, the current one will be used)
  11326. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11327. * @returns the new webGL program
  11328. */
  11329. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11330. /**
  11331. * Creates a webGL program
  11332. * @param vertexCode defines the vertex shader code to use
  11333. * @param fragmentCode defines the fragment shader code to use
  11334. * @param defines defines the string containing the defines to use to compile the shaders
  11335. * @param context defines the webGL context to use (if not set, the current one will be used)
  11336. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11337. * @returns the new webGL program
  11338. */
  11339. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11340. private _createShaderProgram;
  11341. private _finalizeProgram;
  11342. /** @hidden */
  11343. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11344. /** @hidden */
  11345. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11346. /**
  11347. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11348. * @param shaderProgram defines the webGL program to use
  11349. * @param uniformsNames defines the list of uniform names
  11350. * @returns an array of webGL uniform locations
  11351. */
  11352. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11353. /**
  11354. * Gets the lsit of active attributes for a given webGL program
  11355. * @param shaderProgram defines the webGL program to use
  11356. * @param attributesNames defines the list of attribute names to get
  11357. * @returns an array of indices indicating the offset of each attribute
  11358. */
  11359. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11360. /**
  11361. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11362. * @param effect defines the effect to activate
  11363. */
  11364. enableEffect(effect: Nullable<Effect>): void;
  11365. /**
  11366. * Set the value of an uniform to an array of int32
  11367. * @param uniform defines the webGL uniform location where to store the value
  11368. * @param array defines the array of int32 to store
  11369. */
  11370. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11371. /**
  11372. * Set the value of an uniform to an array of int32 (stored as vec2)
  11373. * @param uniform defines the webGL uniform location where to store the value
  11374. * @param array defines the array of int32 to store
  11375. */
  11376. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11377. /**
  11378. * Set the value of an uniform to an array of int32 (stored as vec3)
  11379. * @param uniform defines the webGL uniform location where to store the value
  11380. * @param array defines the array of int32 to store
  11381. */
  11382. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11383. /**
  11384. * Set the value of an uniform to an array of int32 (stored as vec4)
  11385. * @param uniform defines the webGL uniform location where to store the value
  11386. * @param array defines the array of int32 to store
  11387. */
  11388. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11389. /**
  11390. * Set the value of an uniform to an array of float32
  11391. * @param uniform defines the webGL uniform location where to store the value
  11392. * @param array defines the array of float32 to store
  11393. */
  11394. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11395. /**
  11396. * Set the value of an uniform to an array of float32 (stored as vec2)
  11397. * @param uniform defines the webGL uniform location where to store the value
  11398. * @param array defines the array of float32 to store
  11399. */
  11400. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11401. /**
  11402. * Set the value of an uniform to an array of float32 (stored as vec3)
  11403. * @param uniform defines the webGL uniform location where to store the value
  11404. * @param array defines the array of float32 to store
  11405. */
  11406. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11407. /**
  11408. * Set the value of an uniform to an array of float32 (stored as vec4)
  11409. * @param uniform defines the webGL uniform location where to store the value
  11410. * @param array defines the array of float32 to store
  11411. */
  11412. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11413. /**
  11414. * Set the value of an uniform to an array of number
  11415. * @param uniform defines the webGL uniform location where to store the value
  11416. * @param array defines the array of number to store
  11417. */
  11418. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11419. /**
  11420. * Set the value of an uniform to an array of number (stored as vec2)
  11421. * @param uniform defines the webGL uniform location where to store the value
  11422. * @param array defines the array of number to store
  11423. */
  11424. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11425. /**
  11426. * Set the value of an uniform to an array of number (stored as vec3)
  11427. * @param uniform defines the webGL uniform location where to store the value
  11428. * @param array defines the array of number to store
  11429. */
  11430. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11431. /**
  11432. * Set the value of an uniform to an array of number (stored as vec4)
  11433. * @param uniform defines the webGL uniform location where to store the value
  11434. * @param array defines the array of number to store
  11435. */
  11436. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11437. /**
  11438. * Set the value of an uniform to an array of float32 (stored as matrices)
  11439. * @param uniform defines the webGL uniform location where to store the value
  11440. * @param matrices defines the array of float32 to store
  11441. */
  11442. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11443. /**
  11444. * Set the value of an uniform to a matrix
  11445. * @param uniform defines the webGL uniform location where to store the value
  11446. * @param matrix defines the matrix to store
  11447. */
  11448. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11449. /**
  11450. * Set the value of an uniform to a matrix (3x3)
  11451. * @param uniform defines the webGL uniform location where to store the value
  11452. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11453. */
  11454. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11455. /**
  11456. * Set the value of an uniform to a matrix (2x2)
  11457. * @param uniform defines the webGL uniform location where to store the value
  11458. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11459. */
  11460. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11461. /**
  11462. * Set the value of an uniform to a number (int)
  11463. * @param uniform defines the webGL uniform location where to store the value
  11464. * @param value defines the int number to store
  11465. */
  11466. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11467. /**
  11468. * Set the value of an uniform to a number (float)
  11469. * @param uniform defines the webGL uniform location where to store the value
  11470. * @param value defines the float number to store
  11471. */
  11472. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11473. /**
  11474. * Set the value of an uniform to a vec2
  11475. * @param uniform defines the webGL uniform location where to store the value
  11476. * @param x defines the 1st component of the value
  11477. * @param y defines the 2nd component of the value
  11478. */
  11479. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11480. /**
  11481. * Set the value of an uniform to a vec3
  11482. * @param uniform defines the webGL uniform location where to store the value
  11483. * @param x defines the 1st component of the value
  11484. * @param y defines the 2nd component of the value
  11485. * @param z defines the 3rd component of the value
  11486. */
  11487. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11488. /**
  11489. * Set the value of an uniform to a boolean
  11490. * @param uniform defines the webGL uniform location where to store the value
  11491. * @param bool defines the boolean to store
  11492. */
  11493. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11494. /**
  11495. * Set the value of an uniform to a vec4
  11496. * @param uniform defines the webGL uniform location where to store the value
  11497. * @param x defines the 1st component of the value
  11498. * @param y defines the 2nd component of the value
  11499. * @param z defines the 3rd component of the value
  11500. * @param w defines the 4th component of the value
  11501. */
  11502. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11503. /**
  11504. * Set the value of an uniform to a Color3
  11505. * @param uniform defines the webGL uniform location where to store the value
  11506. * @param color3 defines the color to store
  11507. */
  11508. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11509. /**
  11510. * Set the value of an uniform to a Color3 and an alpha value
  11511. * @param uniform defines the webGL uniform location where to store the value
  11512. * @param color3 defines the color to store
  11513. * @param alpha defines the alpha component to store
  11514. */
  11515. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11516. /**
  11517. * Sets a Color4 on a uniform variable
  11518. * @param uniform defines the uniform location
  11519. * @param color4 defines the value to be set
  11520. */
  11521. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11522. /**
  11523. * Set various states to the webGL context
  11524. * @param culling defines backface culling state
  11525. * @param zOffset defines the value to apply to zOffset (0 by default)
  11526. * @param force defines if states must be applied even if cache is up to date
  11527. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11528. */
  11529. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11530. /**
  11531. * Set the z offset to apply to current rendering
  11532. * @param value defines the offset to apply
  11533. */
  11534. setZOffset(value: number): void;
  11535. /**
  11536. * Gets the current value of the zOffset
  11537. * @returns the current zOffset state
  11538. */
  11539. getZOffset(): number;
  11540. /**
  11541. * Enable or disable depth buffering
  11542. * @param enable defines the state to set
  11543. */
  11544. setDepthBuffer(enable: boolean): void;
  11545. /**
  11546. * Gets a boolean indicating if depth writing is enabled
  11547. * @returns the current depth writing state
  11548. */
  11549. getDepthWrite(): boolean;
  11550. /**
  11551. * Enable or disable depth writing
  11552. * @param enable defines the state to set
  11553. */
  11554. setDepthWrite(enable: boolean): void;
  11555. /**
  11556. * Enable or disable color writing
  11557. * @param enable defines the state to set
  11558. */
  11559. setColorWrite(enable: boolean): void;
  11560. /**
  11561. * Gets a boolean indicating if color writing is enabled
  11562. * @returns the current color writing state
  11563. */
  11564. getColorWrite(): boolean;
  11565. /**
  11566. * Sets alpha constants used by some alpha blending modes
  11567. * @param r defines the red component
  11568. * @param g defines the green component
  11569. * @param b defines the blue component
  11570. * @param a defines the alpha component
  11571. */
  11572. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11573. /**
  11574. * Sets the current alpha mode
  11575. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11576. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11578. */
  11579. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11580. /**
  11581. * Gets the current alpha mode
  11582. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11583. * @returns the current alpha mode
  11584. */
  11585. getAlphaMode(): number;
  11586. /**
  11587. * Clears the list of texture accessible through engine.
  11588. * This can help preventing texture load conflict due to name collision.
  11589. */
  11590. clearInternalTexturesCache(): void;
  11591. /**
  11592. * Force the entire cache to be cleared
  11593. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11594. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11595. */
  11596. wipeCaches(bruteForce?: boolean): void;
  11597. /**
  11598. * Set the compressed texture format to use, based on the formats you have, and the formats
  11599. * supported by the hardware / browser.
  11600. *
  11601. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11602. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11603. * to API arguments needed to compressed textures. This puts the burden on the container
  11604. * generator to house the arcane code for determining these for current & future formats.
  11605. *
  11606. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11607. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11608. *
  11609. * Note: The result of this call is not taken into account when a texture is base64.
  11610. *
  11611. * @param formatsAvailable defines the list of those format families you have created
  11612. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11613. *
  11614. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11615. * @returns The extension selected.
  11616. */
  11617. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11618. private _getSamplingParameters;
  11619. private _partialLoadImg;
  11620. private _cascadeLoadImgs;
  11621. /** @hidden */
  11622. _createTexture(): WebGLTexture;
  11623. /**
  11624. * Usually called from BABYLON.Texture.ts.
  11625. * Passed information to create a WebGLTexture
  11626. * @param urlArg defines a value which contains one of the following:
  11627. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11628. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11629. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11631. * @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)
  11632. * @param scene needed for loading to the correct scene
  11633. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11634. * @param onLoad optional callback to be called upon successful completion
  11635. * @param onError optional callback to be called upon failure
  11636. * @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
  11637. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11638. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11639. * @param forcedExtension defines the extension to use to pick the right loader
  11640. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11641. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11642. */
  11643. 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;
  11644. private _rescaleTexture;
  11645. /**
  11646. * Update a raw texture
  11647. * @param texture defines the texture to update
  11648. * @param data defines the data to store in the texture
  11649. * @param format defines the format of the data
  11650. * @param invertY defines if data must be stored with Y axis inverted
  11651. * @param compression defines the compression used (null by default)
  11652. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11653. */
  11654. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11655. /**
  11656. * Creates a raw texture
  11657. * @param data defines the data to store in the texture
  11658. * @param width defines the width of the texture
  11659. * @param height defines the height of the texture
  11660. * @param format defines the format of the data
  11661. * @param generateMipMaps defines if the engine should generate the mip levels
  11662. * @param invertY defines if data must be stored with Y axis inverted
  11663. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11664. * @param compression defines the compression used (null by default)
  11665. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11666. * @returns the raw texture inside an InternalTexture
  11667. */
  11668. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11669. private _unpackFlipYCached;
  11670. /**
  11671. * In case you are sharing the context with other applications, it might
  11672. * be interested to not cache the unpack flip y state to ensure a consistent
  11673. * value would be set.
  11674. */
  11675. enableUnpackFlipYCached: boolean;
  11676. /** @hidden */
  11677. _unpackFlipY(value: boolean): void;
  11678. /** @hidden */
  11679. _getUnpackAlignement(): number;
  11680. /**
  11681. * Creates a dynamic texture
  11682. * @param width defines the width of the texture
  11683. * @param height defines the height of the texture
  11684. * @param generateMipMaps defines if the engine should generate the mip levels
  11685. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11686. * @returns the dynamic texture inside an InternalTexture
  11687. */
  11688. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11689. /**
  11690. * Update the sampling mode of a given texture
  11691. * @param samplingMode defines the required sampling mode
  11692. * @param texture defines the texture to update
  11693. */
  11694. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11695. /**
  11696. * Update the content of a dynamic texture
  11697. * @param texture defines the texture to update
  11698. * @param canvas defines the canvas containing the source
  11699. * @param invertY defines if data must be stored with Y axis inverted
  11700. * @param premulAlpha defines if alpha is stored as premultiplied
  11701. * @param format defines the format of the data
  11702. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11703. */
  11704. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11705. /**
  11706. * Update a video texture
  11707. * @param texture defines the texture to update
  11708. * @param video defines the video element to use
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11712. /**
  11713. * Updates a depth texture Comparison Mode and Function.
  11714. * If the comparison Function is equal to 0, the mode will be set to none.
  11715. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11716. * @param texture The texture to set the comparison function for
  11717. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11718. */
  11719. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11720. private _setupDepthStencilTexture;
  11721. /**
  11722. * Creates a depth stencil texture.
  11723. * This is only available in WebGL 2 or with the depth texture extension available.
  11724. * @param size The size of face edge in the texture.
  11725. * @param options The options defining the texture.
  11726. * @returns The texture
  11727. */
  11728. createDepthStencilTexture(size: number | {
  11729. width: number;
  11730. height: number;
  11731. }, options: DepthTextureCreationOptions): InternalTexture;
  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. private _createDepthStencilTexture;
  11740. /**
  11741. * Creates a depth stencil cube texture.
  11742. * This is only available in WebGL 2.
  11743. * @param size The size of face edge in the cube texture.
  11744. * @param options The options defining the cube texture.
  11745. * @returns The cube texture
  11746. */
  11747. private _createDepthStencilCubeTexture;
  11748. /**
  11749. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11750. * @param renderTarget The render target to set the frame buffer for
  11751. */
  11752. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11753. /**
  11754. * Creates a new render target texture
  11755. * @param size defines the size of the texture
  11756. * @param options defines the options used to create the texture
  11757. * @returns a new render target texture stored in an InternalTexture
  11758. */
  11759. createRenderTargetTexture(size: number | {
  11760. width: number;
  11761. height: number;
  11762. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11763. /**
  11764. * Create a multi render target texture
  11765. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11766. * @param size defines the size of the texture
  11767. * @param options defines the creation options
  11768. * @returns the cube texture as an InternalTexture
  11769. */
  11770. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11771. private _setupFramebufferDepthAttachments;
  11772. /**
  11773. * Updates the sample count of a render target texture
  11774. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11775. * @param texture defines the texture to update
  11776. * @param samples defines the sample count to set
  11777. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11778. */
  11779. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11780. /**
  11781. * Update the sample count for a given multiple render target texture
  11782. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11783. * @param textures defines the textures to update
  11784. * @param samples defines the sample count to set
  11785. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11786. */
  11787. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11788. /** @hidden */
  11789. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11790. /** @hidden */
  11791. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11792. /** @hidden */
  11793. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11794. /** @hidden */
  11795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11796. /**
  11797. * Creates a new render target cube texture
  11798. * @param size defines the size of the texture
  11799. * @param options defines the options used to create the texture
  11800. * @returns a new render target cube texture stored in an InternalTexture
  11801. */
  11802. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11803. /**
  11804. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11805. * @param rootUrl defines the url where the file to load is located
  11806. * @param scene defines the current scene
  11807. * @param lodScale defines scale to apply to the mip map selection
  11808. * @param lodOffset defines offset to apply to the mip map selection
  11809. * @param onLoad defines an optional callback raised when the texture is loaded
  11810. * @param onError defines an optional callback raised if there is an issue to load the texture
  11811. * @param format defines the format of the data
  11812. * @param forcedExtension defines the extension to use to pick the right loader
  11813. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11814. * @returns the cube texture as an InternalTexture
  11815. */
  11816. 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;
  11817. /**
  11818. * Creates a cube texture
  11819. * @param rootUrl defines the url where the files to load is located
  11820. * @param scene defines the current scene
  11821. * @param files defines the list of files to load (1 per face)
  11822. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11823. * @param onLoad defines an optional callback raised when the texture is loaded
  11824. * @param onError defines an optional callback raised if there is an issue to load the texture
  11825. * @param format defines the format of the data
  11826. * @param forcedExtension defines the extension to use to pick the right loader
  11827. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11830. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11831. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11832. * @returns the cube texture as an InternalTexture
  11833. */
  11834. 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;
  11835. /**
  11836. * @hidden
  11837. */
  11838. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11839. /**
  11840. * Update a raw cube texture
  11841. * @param texture defines the texture to udpdate
  11842. * @param data defines the data to store
  11843. * @param format defines the data format
  11844. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11845. * @param invertY defines if data must be stored with Y axis inverted
  11846. * @param compression defines the compression used (null by default)
  11847. * @param level defines which level of the texture to update
  11848. */
  11849. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11850. /**
  11851. * Creates a new raw cube texture
  11852. * @param data defines the array of data to use to create each face
  11853. * @param size defines the size of the textures
  11854. * @param format defines the format of the data
  11855. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11856. * @param generateMipMaps defines if the engine should generate the mip levels
  11857. * @param invertY defines if data must be stored with Y axis inverted
  11858. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11859. * @param compression defines the compression used (null by default)
  11860. * @returns the cube texture as an InternalTexture
  11861. */
  11862. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11863. /**
  11864. * Creates a new raw cube texture from a specified url
  11865. * @param url defines the url where the data is located
  11866. * @param scene defines the current scene
  11867. * @param size defines the size of the textures
  11868. * @param format defines the format of the data
  11869. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11870. * @param noMipmap defines if the engine should avoid generating the mip levels
  11871. * @param callback defines a callback used to extract texture data from loaded data
  11872. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11873. * @param onLoad defines a callback called when texture is loaded
  11874. * @param onError defines a callback called if there is an error
  11875. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11876. * @param invertY defines if data must be stored with Y axis inverted
  11877. * @returns the cube texture as an InternalTexture
  11878. */
  11879. 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;
  11880. /**
  11881. * Update a raw 3D texture
  11882. * @param texture defines the texture to update
  11883. * @param data defines the data to store
  11884. * @param format defines the data format
  11885. * @param invertY defines if data must be stored with Y axis inverted
  11886. * @param compression defines the used compression (can be null)
  11887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11888. */
  11889. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11890. /**
  11891. * Creates a new raw 3D texture
  11892. * @param data defines the data used to create the texture
  11893. * @param width defines the width of the texture
  11894. * @param height defines the height of the texture
  11895. * @param depth defines the depth of the texture
  11896. * @param format defines the format of the texture
  11897. * @param generateMipMaps defines if the engine must generate mip levels
  11898. * @param invertY defines if data must be stored with Y axis inverted
  11899. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11900. * @param compression defines the compressed used (can be null)
  11901. * @param textureType defines the compressed used (can be null)
  11902. * @returns a new raw 3D texture (stored in an InternalTexture)
  11903. */
  11904. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11905. private _prepareWebGLTextureContinuation;
  11906. private _prepareWebGLTexture;
  11907. private _convertRGBtoRGBATextureData;
  11908. /** @hidden */
  11909. _releaseFramebufferObjects(texture: InternalTexture): void;
  11910. /** @hidden */
  11911. _releaseTexture(texture: InternalTexture): void;
  11912. private setProgram;
  11913. private _boundUniforms;
  11914. /**
  11915. * Binds an effect to the webGL context
  11916. * @param effect defines the effect to bind
  11917. */
  11918. bindSamplers(effect: Effect): void;
  11919. private _moveBoundTextureOnTop;
  11920. private _getCorrectTextureChannel;
  11921. private _linkTrackers;
  11922. private _removeDesignatedSlot;
  11923. private _activateCurrentTexture;
  11924. /** @hidden */
  11925. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11926. /** @hidden */
  11927. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11928. /**
  11929. * Sets a texture to the webGL context from a postprocess
  11930. * @param channel defines the channel to use
  11931. * @param postProcess defines the source postprocess
  11932. */
  11933. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11934. /**
  11935. * Binds the output of the passed in post process to the texture channel specified
  11936. * @param channel The channel the texture should be bound to
  11937. * @param postProcess The post process which's output should be bound
  11938. */
  11939. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11940. /**
  11941. * Unbind all textures from the webGL context
  11942. */
  11943. unbindAllTextures(): void;
  11944. /**
  11945. * Sets a texture to the according uniform.
  11946. * @param channel The texture channel
  11947. * @param uniform The uniform to set
  11948. * @param texture The texture to apply
  11949. */
  11950. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11951. /**
  11952. * Sets a depth stencil texture from a render target to the according uniform.
  11953. * @param channel The texture channel
  11954. * @param uniform The uniform to set
  11955. * @param texture The render target texture containing the depth stencil texture to apply
  11956. */
  11957. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11958. private _bindSamplerUniformToChannel;
  11959. private _getTextureWrapMode;
  11960. private _setTexture;
  11961. /**
  11962. * Sets an array of texture to the webGL context
  11963. * @param channel defines the channel where the texture array must be set
  11964. * @param uniform defines the associated uniform location
  11965. * @param textures defines the array of textures to bind
  11966. */
  11967. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11968. /** @hidden */
  11969. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11970. private _setTextureParameterFloat;
  11971. private _setTextureParameterInteger;
  11972. /**
  11973. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11974. * @param x defines the x coordinate of the rectangle where pixels must be read
  11975. * @param y defines the y coordinate of the rectangle where pixels must be read
  11976. * @param width defines the width of the rectangle where pixels must be read
  11977. * @param height defines the height of the rectangle where pixels must be read
  11978. * @returns a Uint8Array containing RGBA colors
  11979. */
  11980. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11981. /**
  11982. * Add an externaly attached data from its key.
  11983. * This method call will fail and return false, if such key already exists.
  11984. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11985. * @param key the unique key that identifies the data
  11986. * @param data the data object to associate to the key for this Engine instance
  11987. * @return true if no such key were already present and the data was added successfully, false otherwise
  11988. */
  11989. addExternalData<T>(key: string, data: T): boolean;
  11990. /**
  11991. * Get an externaly attached data from its key
  11992. * @param key the unique key that identifies the data
  11993. * @return the associated data, if present (can be null), or undefined if not present
  11994. */
  11995. getExternalData<T>(key: string): T;
  11996. /**
  11997. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11998. * @param key the unique key that identifies the data
  11999. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  12000. * @return the associated data, can be null if the factory returned null.
  12001. */
  12002. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  12003. /**
  12004. * Remove an externaly attached data from the Engine instance
  12005. * @param key the unique key that identifies the data
  12006. * @return true if the data was successfully removed, false if it doesn't exist
  12007. */
  12008. removeExternalData(key: string): boolean;
  12009. /**
  12010. * Unbind all vertex attributes from the webGL context
  12011. */
  12012. unbindAllAttributes(): void;
  12013. /**
  12014. * 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
  12015. */
  12016. releaseEffects(): void;
  12017. /**
  12018. * Dispose and release all associated resources
  12019. */
  12020. dispose(): void;
  12021. /**
  12022. * Display the loading screen
  12023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12024. */
  12025. displayLoadingUI(): void;
  12026. /**
  12027. * Hide the loading screen
  12028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12029. */
  12030. hideLoadingUI(): void;
  12031. /**
  12032. * Gets the current loading screen object
  12033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12034. */
  12035. /**
  12036. * Sets the current loading screen object
  12037. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12038. */
  12039. loadingScreen: ILoadingScreen;
  12040. /**
  12041. * Sets the current loading screen text
  12042. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12043. */
  12044. loadingUIText: string;
  12045. /**
  12046. * Sets the current loading screen background color
  12047. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12048. */
  12049. loadingUIBackgroundColor: string;
  12050. /**
  12051. * Attach a new callback raised when context lost event is fired
  12052. * @param callback defines the callback to call
  12053. */
  12054. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12055. /**
  12056. * Attach a new callback raised when context restored event is fired
  12057. * @param callback defines the callback to call
  12058. */
  12059. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12060. /**
  12061. * Gets the source code of the vertex shader associated with a specific webGL program
  12062. * @param program defines the program to use
  12063. * @returns a string containing the source code of the vertex shader associated with the program
  12064. */
  12065. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12066. /**
  12067. * Gets the source code of the fragment shader associated with a specific webGL program
  12068. * @param program defines the program to use
  12069. * @returns a string containing the source code of the fragment shader associated with the program
  12070. */
  12071. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12072. /**
  12073. * Get the current error code of the webGL context
  12074. * @returns the error code
  12075. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12076. */
  12077. getError(): number;
  12078. /**
  12079. * Gets the current framerate
  12080. * @returns a number representing the framerate
  12081. */
  12082. getFps(): number;
  12083. /**
  12084. * Gets the time spent between current and previous frame
  12085. * @returns a number representing the delta time in ms
  12086. */
  12087. getDeltaTime(): number;
  12088. private _measureFps;
  12089. /** @hidden */
  12090. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12091. private _canRenderToFloatFramebuffer;
  12092. private _canRenderToHalfFloatFramebuffer;
  12093. private _canRenderToFramebuffer;
  12094. /** @hidden */
  12095. _getWebGLTextureType(type: number): number;
  12096. private _getInternalFormat;
  12097. /** @hidden */
  12098. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12099. /** @hidden */
  12100. _getRGBAMultiSampleBufferFormat(type: number): number;
  12101. /** @hidden */
  12102. _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;
  12103. /** @hidden */
  12104. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12105. private _partialLoadFile;
  12106. private _cascadeLoadFiles;
  12107. /**
  12108. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12109. * @returns true if the engine can be created
  12110. * @ignorenaming
  12111. */
  12112. static isSupported(): boolean;
  12113. }
  12114. }
  12115. declare module BABYLON {
  12116. /**
  12117. * Options to create the null engine
  12118. */
  12119. class NullEngineOptions {
  12120. /**
  12121. * Render width (Default: 512)
  12122. */
  12123. renderWidth: number;
  12124. /**
  12125. * Render height (Default: 256)
  12126. */
  12127. renderHeight: number;
  12128. /**
  12129. * Texture size (Default: 512)
  12130. */
  12131. textureSize: number;
  12132. /**
  12133. * If delta time between frames should be constant
  12134. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12135. */
  12136. deterministicLockstep: boolean;
  12137. /**
  12138. * Maximum about of steps between frames (Default: 4)
  12139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12140. */
  12141. lockstepMaxSteps: number;
  12142. }
  12143. /**
  12144. * The null engine class provides support for headless version of babylon.js.
  12145. * This can be used in server side scenario or for testing purposes
  12146. */
  12147. class NullEngine extends Engine {
  12148. private _options;
  12149. /**
  12150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12151. */
  12152. isDeterministicLockStep(): boolean;
  12153. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12154. getLockstepMaxSteps(): number;
  12155. /**
  12156. * Sets hardware scaling, used to save performance if needed
  12157. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12158. */
  12159. getHardwareScalingLevel(): number;
  12160. constructor(options?: NullEngineOptions);
  12161. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12162. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12163. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12164. getRenderWidth(useScreen?: boolean): number;
  12165. getRenderHeight(useScreen?: boolean): number;
  12166. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12167. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12168. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12169. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12170. bindSamplers(effect: Effect): void;
  12171. enableEffect(effect: Effect): void;
  12172. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12173. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12174. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12175. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12176. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12177. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12178. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12179. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12180. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12181. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12182. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12183. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12184. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12185. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12186. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12187. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12188. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12189. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12190. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12191. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12192. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12193. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12194. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12195. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12196. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12197. bindBuffers(vertexBuffers: {
  12198. [key: string]: VertexBuffer;
  12199. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12200. wipeCaches(bruteForce?: boolean): void;
  12201. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12202. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12203. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12204. /** @hidden */
  12205. _createTexture(): WebGLTexture;
  12206. /** @hidden */
  12207. _releaseTexture(texture: InternalTexture): void;
  12208. 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;
  12209. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12210. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12211. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12212. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12213. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12214. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12215. areAllEffectsReady(): boolean;
  12216. /**
  12217. * @hidden
  12218. * Get the current error code of the webGL context
  12219. * @returns the error code
  12220. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12221. */
  12222. getError(): number;
  12223. /** @hidden */
  12224. _getUnpackAlignement(): number;
  12225. /** @hidden */
  12226. _unpackFlipY(value: boolean): void;
  12227. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12228. /**
  12229. * Updates a dynamic vertex buffer.
  12230. * @param vertexBuffer the vertex buffer to update
  12231. * @param data the data used to update the vertex buffer
  12232. * @param byteOffset the byte offset of the data (optional)
  12233. * @param byteLength the byte length of the data (optional)
  12234. */
  12235. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12236. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12237. /** @hidden */
  12238. _bindTexture(channel: number, texture: InternalTexture): void;
  12239. /** @hidden */
  12240. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12241. releaseEffects(): void;
  12242. displayLoadingUI(): void;
  12243. hideLoadingUI(): void;
  12244. /** @hidden */
  12245. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12246. /** @hidden */
  12247. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12248. /** @hidden */
  12249. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12250. /** @hidden */
  12251. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12252. }
  12253. }
  12254. interface WebGLRenderingContext {
  12255. readonly RASTERIZER_DISCARD: number;
  12256. readonly DEPTH_COMPONENT24: number;
  12257. readonly TEXTURE_3D: number;
  12258. readonly TEXTURE_2D_ARRAY: number;
  12259. readonly TEXTURE_COMPARE_FUNC: number;
  12260. readonly TEXTURE_COMPARE_MODE: number;
  12261. readonly COMPARE_REF_TO_TEXTURE: number;
  12262. readonly TEXTURE_WRAP_R: number;
  12263. readonly HALF_FLOAT: number;
  12264. readonly RGB8: number;
  12265. readonly RED_INTEGER: number;
  12266. readonly RG_INTEGER: number;
  12267. readonly RGB_INTEGER: number;
  12268. readonly RGBA_INTEGER: number;
  12269. readonly R8_SNORM: number;
  12270. readonly RG8_SNORM: number;
  12271. readonly RGB8_SNORM: number;
  12272. readonly RGBA8_SNORM: number;
  12273. readonly R8I: number;
  12274. readonly RG8I: number;
  12275. readonly RGB8I: number;
  12276. readonly RGBA8I: number;
  12277. readonly R8UI: number;
  12278. readonly RG8UI: number;
  12279. readonly RGB8UI: number;
  12280. readonly RGBA8UI: number;
  12281. readonly R16I: number;
  12282. readonly RG16I: number;
  12283. readonly RGB16I: number;
  12284. readonly RGBA16I: number;
  12285. readonly R16UI: number;
  12286. readonly RG16UI: number;
  12287. readonly RGB16UI: number;
  12288. readonly RGBA16UI: number;
  12289. readonly R32I: number;
  12290. readonly RG32I: number;
  12291. readonly RGB32I: number;
  12292. readonly RGBA32I: number;
  12293. readonly R32UI: number;
  12294. readonly RG32UI: number;
  12295. readonly RGB32UI: number;
  12296. readonly RGBA32UI: number;
  12297. readonly RGB10_A2UI: number;
  12298. readonly R11F_G11F_B10F: number;
  12299. readonly RGB9_E5: number;
  12300. readonly RGB10_A2: number;
  12301. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12302. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12303. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12304. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12305. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12306. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12307. 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;
  12308. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12309. readonly TRANSFORM_FEEDBACK: number;
  12310. readonly INTERLEAVED_ATTRIBS: number;
  12311. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12312. createTransformFeedback(): WebGLTransformFeedback;
  12313. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12314. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12315. beginTransformFeedback(primitiveMode: number): void;
  12316. endTransformFeedback(): void;
  12317. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12318. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12319. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12320. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12321. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12322. }
  12323. interface ImageBitmap {
  12324. readonly width: number;
  12325. readonly height: number;
  12326. close(): void;
  12327. }
  12328. interface WebGLQuery extends WebGLObject {
  12329. }
  12330. declare var WebGLQuery: {
  12331. prototype: WebGLQuery;
  12332. new (): WebGLQuery;
  12333. };
  12334. interface WebGLSampler extends WebGLObject {
  12335. }
  12336. declare var WebGLSampler: {
  12337. prototype: WebGLSampler;
  12338. new (): WebGLSampler;
  12339. };
  12340. interface WebGLSync extends WebGLObject {
  12341. }
  12342. declare var WebGLSync: {
  12343. prototype: WebGLSync;
  12344. new (): WebGLSync;
  12345. };
  12346. interface WebGLTransformFeedback extends WebGLObject {
  12347. }
  12348. declare var WebGLTransformFeedback: {
  12349. prototype: WebGLTransformFeedback;
  12350. new (): WebGLTransformFeedback;
  12351. };
  12352. interface WebGLVertexArrayObject extends WebGLObject {
  12353. }
  12354. declare var WebGLVertexArrayObject: {
  12355. prototype: WebGLVertexArrayObject;
  12356. new (): WebGLVertexArrayObject;
  12357. };
  12358. declare module BABYLON {
  12359. /**
  12360. * Gather the list of clipboard event types as constants.
  12361. */
  12362. class ClipboardEventTypes {
  12363. /**
  12364. * The clipboard event is fired when a copy command is active (pressed).
  12365. */
  12366. static readonly COPY: number;
  12367. /**
  12368. * The clipboard event is fired when a cut command is active (pressed).
  12369. */
  12370. static readonly CUT: number;
  12371. /**
  12372. * The clipboard event is fired when a paste command is active (pressed).
  12373. */
  12374. static readonly PASTE: number;
  12375. }
  12376. /**
  12377. * This class is used to store clipboard related info for the onClipboardObservable event.
  12378. */
  12379. class ClipboardInfo {
  12380. /**
  12381. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12382. */
  12383. type: number;
  12384. /**
  12385. * Defines the related dom event
  12386. */
  12387. event: ClipboardEvent;
  12388. /**
  12389. *Creates an instance of ClipboardInfo.
  12390. * @param {number} type
  12391. * @param {ClipboardEvent} event
  12392. */
  12393. constructor(
  12394. /**
  12395. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12396. */
  12397. type: number,
  12398. /**
  12399. * Defines the related dom event
  12400. */
  12401. event: ClipboardEvent);
  12402. /**
  12403. * Get the clipboard event's type from the keycode.
  12404. * @param keyCode Defines the keyCode for the current keyboard event.
  12405. * @return {number}
  12406. */
  12407. static GetTypeFromCharacter(keyCode: number): number;
  12408. }
  12409. }
  12410. declare module BABYLON {
  12411. /**
  12412. * Gather the list of keyboard event types as constants.
  12413. */
  12414. class KeyboardEventTypes {
  12415. /**
  12416. * The keydown event is fired when a key becomes active (pressed).
  12417. */
  12418. static readonly KEYDOWN: number;
  12419. /**
  12420. * The keyup event is fired when a key has been released.
  12421. */
  12422. static readonly KEYUP: number;
  12423. }
  12424. /**
  12425. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12426. */
  12427. class KeyboardInfo {
  12428. /**
  12429. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12430. */
  12431. type: number;
  12432. /**
  12433. * Defines the related dom event
  12434. */
  12435. event: KeyboardEvent;
  12436. /**
  12437. * Instantiates a new keyboard info.
  12438. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12439. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12440. * @param event Defines the related dom event
  12441. */
  12442. constructor(
  12443. /**
  12444. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12445. */
  12446. type: number,
  12447. /**
  12448. * Defines the related dom event
  12449. */
  12450. event: KeyboardEvent);
  12451. }
  12452. /**
  12453. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12454. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12455. */
  12456. class KeyboardInfoPre extends KeyboardInfo {
  12457. /**
  12458. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12459. */
  12460. type: number;
  12461. /**
  12462. * Defines the related dom event
  12463. */
  12464. event: KeyboardEvent;
  12465. /**
  12466. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12467. */
  12468. skipOnPointerObservable: boolean;
  12469. /**
  12470. * Instantiates a new keyboard pre info.
  12471. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12472. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12473. * @param event Defines the related dom event
  12474. */
  12475. constructor(
  12476. /**
  12477. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12478. */
  12479. type: number,
  12480. /**
  12481. * Defines the related dom event
  12482. */
  12483. event: KeyboardEvent);
  12484. }
  12485. }
  12486. declare module BABYLON {
  12487. /**
  12488. * Gather the list of pointer event types as constants.
  12489. */
  12490. class PointerEventTypes {
  12491. /**
  12492. * 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.
  12493. */
  12494. static readonly POINTERDOWN: number;
  12495. /**
  12496. * The pointerup event is fired when a pointer is no longer active.
  12497. */
  12498. static readonly POINTERUP: number;
  12499. /**
  12500. * The pointermove event is fired when a pointer changes coordinates.
  12501. */
  12502. static readonly POINTERMOVE: number;
  12503. /**
  12504. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12505. */
  12506. static readonly POINTERWHEEL: number;
  12507. /**
  12508. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12509. */
  12510. static readonly POINTERPICK: number;
  12511. /**
  12512. * The pointertap event is fired when a the object has been touched and released without drag.
  12513. */
  12514. static readonly POINTERTAP: number;
  12515. /**
  12516. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12517. */
  12518. static readonly POINTERDOUBLETAP: number;
  12519. }
  12520. /**
  12521. * Base class of pointer info types.
  12522. */
  12523. class PointerInfoBase {
  12524. /**
  12525. * Defines the type of event (BABYLON.PointerEventTypes)
  12526. */
  12527. type: number;
  12528. /**
  12529. * Defines the related dom event
  12530. */
  12531. event: PointerEvent | MouseWheelEvent;
  12532. /**
  12533. * Instantiates the base class of pointers info.
  12534. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12535. * @param event Defines the related dom event
  12536. */
  12537. constructor(
  12538. /**
  12539. * Defines the type of event (BABYLON.PointerEventTypes)
  12540. */
  12541. type: number,
  12542. /**
  12543. * Defines the related dom event
  12544. */
  12545. event: PointerEvent | MouseWheelEvent);
  12546. }
  12547. /**
  12548. * This class is used to store pointer related info for the onPrePointerObservable event.
  12549. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12550. */
  12551. class PointerInfoPre extends PointerInfoBase {
  12552. /**
  12553. * Ray from a pointer if availible (eg. 6dof controller)
  12554. */
  12555. ray: Nullable<Ray>;
  12556. /**
  12557. * Defines the local position of the pointer on the canvas.
  12558. */
  12559. localPosition: Vector2;
  12560. /**
  12561. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12562. */
  12563. skipOnPointerObservable: boolean;
  12564. /**
  12565. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12566. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12567. * @param event Defines the related dom event
  12568. * @param localX Defines the local x coordinates of the pointer when the event occured
  12569. * @param localY Defines the local y coordinates of the pointer when the event occured
  12570. */
  12571. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12572. }
  12573. /**
  12574. * This type contains all the data related to a pointer event in Babylon.js.
  12575. * 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.
  12576. */
  12577. class PointerInfo extends PointerInfoBase {
  12578. /**
  12579. * Defines the picking info associated to the info (if any)\
  12580. */
  12581. pickInfo: Nullable<PickingInfo>;
  12582. /**
  12583. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12584. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12585. * @param event Defines the related dom event
  12586. * @param pickInfo Defines the picking info associated to the info (if any)\
  12587. */
  12588. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12589. /**
  12590. * Defines the picking info associated to the info (if any)\
  12591. */
  12592. pickInfo: Nullable<PickingInfo>);
  12593. }
  12594. }
  12595. declare module BABYLON {
  12596. /**
  12597. * Represents a gamepad control stick position
  12598. */
  12599. class StickValues {
  12600. /**
  12601. * The x component of the control stick
  12602. */
  12603. x: number;
  12604. /**
  12605. * The y component of the control stick
  12606. */
  12607. y: number;
  12608. /**
  12609. * Initializes the gamepad x and y control stick values
  12610. * @param x The x component of the gamepad control stick value
  12611. * @param y The y component of the gamepad control stick value
  12612. */
  12613. constructor(
  12614. /**
  12615. * The x component of the control stick
  12616. */
  12617. x: number,
  12618. /**
  12619. * The y component of the control stick
  12620. */
  12621. y: number);
  12622. }
  12623. /**
  12624. * An interface which manages callbacks for gamepad button changes
  12625. */
  12626. interface GamepadButtonChanges {
  12627. /**
  12628. * Called when a gamepad has been changed
  12629. */
  12630. changed: boolean;
  12631. /**
  12632. * Called when a gamepad press event has been triggered
  12633. */
  12634. pressChanged: boolean;
  12635. /**
  12636. * Called when a touch event has been triggered
  12637. */
  12638. touchChanged: boolean;
  12639. /**
  12640. * Called when a value has changed
  12641. */
  12642. valueChanged: boolean;
  12643. }
  12644. /**
  12645. * Represents a gamepad
  12646. */
  12647. class Gamepad {
  12648. /**
  12649. * The id of the gamepad
  12650. */
  12651. id: string;
  12652. /**
  12653. * The index of the gamepad
  12654. */
  12655. index: number;
  12656. /**
  12657. * The browser gamepad
  12658. */
  12659. browserGamepad: any;
  12660. /**
  12661. * Specifies what type of gamepad this represents
  12662. */
  12663. type: number;
  12664. private _leftStick;
  12665. private _rightStick;
  12666. /** @hidden */
  12667. _isConnected: boolean;
  12668. private _leftStickAxisX;
  12669. private _leftStickAxisY;
  12670. private _rightStickAxisX;
  12671. private _rightStickAxisY;
  12672. /**
  12673. * Triggered when the left control stick has been changed
  12674. */
  12675. private _onleftstickchanged;
  12676. /**
  12677. * Triggered when the right control stick has been changed
  12678. */
  12679. private _onrightstickchanged;
  12680. /**
  12681. * Represents a gamepad controller
  12682. */
  12683. static GAMEPAD: number;
  12684. /**
  12685. * Represents a generic controller
  12686. */
  12687. static GENERIC: number;
  12688. /**
  12689. * Represents an XBox controller
  12690. */
  12691. static XBOX: number;
  12692. /**
  12693. * Represents a pose-enabled controller
  12694. */
  12695. static POSE_ENABLED: number;
  12696. /**
  12697. * Specifies whether the left control stick should be Y-inverted
  12698. */
  12699. protected _invertLeftStickY: boolean;
  12700. /**
  12701. * Specifies if the gamepad has been connected
  12702. */
  12703. readonly isConnected: boolean;
  12704. /**
  12705. * Initializes the gamepad
  12706. * @param id The id of the gamepad
  12707. * @param index The index of the gamepad
  12708. * @param browserGamepad The browser gamepad
  12709. * @param leftStickX The x component of the left joystick
  12710. * @param leftStickY The y component of the left joystick
  12711. * @param rightStickX The x component of the right joystick
  12712. * @param rightStickY The y component of the right joystick
  12713. */
  12714. constructor(
  12715. /**
  12716. * The id of the gamepad
  12717. */
  12718. id: string,
  12719. /**
  12720. * The index of the gamepad
  12721. */
  12722. index: number,
  12723. /**
  12724. * The browser gamepad
  12725. */
  12726. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12727. /**
  12728. * Callback triggered when the left joystick has changed
  12729. * @param callback
  12730. */
  12731. onleftstickchanged(callback: (values: StickValues) => void): void;
  12732. /**
  12733. * Callback triggered when the right joystick has changed
  12734. * @param callback
  12735. */
  12736. onrightstickchanged(callback: (values: StickValues) => void): void;
  12737. /**
  12738. * Gets the left joystick
  12739. */
  12740. /**
  12741. * Sets the left joystick values
  12742. */
  12743. leftStick: StickValues;
  12744. /**
  12745. * Gets the right joystick
  12746. */
  12747. /**
  12748. * Sets the right joystick value
  12749. */
  12750. rightStick: StickValues;
  12751. /**
  12752. * Updates the gamepad joystick positions
  12753. */
  12754. update(): void;
  12755. /**
  12756. * Disposes the gamepad
  12757. */
  12758. dispose(): void;
  12759. }
  12760. /**
  12761. * Represents a generic gamepad
  12762. */
  12763. class GenericPad extends Gamepad {
  12764. private _buttons;
  12765. private _onbuttondown;
  12766. private _onbuttonup;
  12767. /**
  12768. * Observable triggered when a button has been pressed
  12769. */
  12770. onButtonDownObservable: Observable<number>;
  12771. /**
  12772. * Observable triggered when a button has been released
  12773. */
  12774. onButtonUpObservable: Observable<number>;
  12775. /**
  12776. * Callback triggered when a button has been pressed
  12777. * @param callback Called when a button has been pressed
  12778. */
  12779. onbuttondown(callback: (buttonPressed: number) => void): void;
  12780. /**
  12781. * Callback triggered when a button has been released
  12782. * @param callback Called when a button has been released
  12783. */
  12784. onbuttonup(callback: (buttonReleased: number) => void): void;
  12785. /**
  12786. * Initializes the generic gamepad
  12787. * @param id The id of the generic gamepad
  12788. * @param index The index of the generic gamepad
  12789. * @param browserGamepad The browser gamepad
  12790. */
  12791. constructor(id: string, index: number, browserGamepad: any);
  12792. private _setButtonValue;
  12793. /**
  12794. * Updates the generic gamepad
  12795. */
  12796. update(): void;
  12797. /**
  12798. * Disposes the generic gamepad
  12799. */
  12800. dispose(): void;
  12801. }
  12802. }
  12803. declare module BABYLON {
  12804. /**
  12805. * Manager for handling gamepads
  12806. */
  12807. class GamepadManager {
  12808. private _scene?;
  12809. private _babylonGamepads;
  12810. private _oneGamepadConnected;
  12811. /** @hidden */
  12812. _isMonitoring: boolean;
  12813. private _gamepadEventSupported;
  12814. private _gamepadSupport;
  12815. /**
  12816. * observable to be triggered when the gamepad controller has been connected
  12817. */
  12818. onGamepadConnectedObservable: Observable<Gamepad>;
  12819. /**
  12820. * observable to be triggered when the gamepad controller has been disconnected
  12821. */
  12822. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12823. private _onGamepadConnectedEvent;
  12824. private _onGamepadDisconnectedEvent;
  12825. /**
  12826. * Initializes the gamepad manager
  12827. * @param _scene BabylonJS scene
  12828. */
  12829. constructor(_scene?: Scene | undefined);
  12830. /**
  12831. * The gamepads in the game pad manager
  12832. */
  12833. readonly gamepads: Gamepad[];
  12834. /**
  12835. * Get the gamepad controllers based on type
  12836. * @param type The type of gamepad controller
  12837. * @returns Nullable gamepad
  12838. */
  12839. getGamepadByType(type?: number): Nullable<Gamepad>;
  12840. /**
  12841. * Disposes the gamepad manager
  12842. */
  12843. dispose(): void;
  12844. private _addNewGamepad;
  12845. private _startMonitoringGamepads;
  12846. private _stopMonitoringGamepads;
  12847. /** @hidden */
  12848. _checkGamepadsStatus(): void;
  12849. private _updateGamepadObjects;
  12850. }
  12851. }
  12852. declare module BABYLON {
  12853. interface Scene {
  12854. /** @hidden */
  12855. _gamepadManager: Nullable<GamepadManager>;
  12856. /**
  12857. * Gets the gamepad manager associated with the scene
  12858. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12859. */
  12860. gamepadManager: GamepadManager;
  12861. }
  12862. /**
  12863. * Interface representing a free camera inputs manager
  12864. */
  12865. interface FreeCameraInputsManager {
  12866. /**
  12867. * Adds gamepad input support to the FreeCameraInputsManager.
  12868. * @returns the FreeCameraInputsManager
  12869. */
  12870. addGamepad(): FreeCameraInputsManager;
  12871. }
  12872. /**
  12873. * Interface representing an arc rotate camera inputs manager
  12874. */
  12875. interface ArcRotateCameraInputsManager {
  12876. /**
  12877. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12878. * @returns the camera inputs manager
  12879. */
  12880. addGamepad(): ArcRotateCameraInputsManager;
  12881. }
  12882. /**
  12883. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12884. */
  12885. class GamepadSystemSceneComponent implements ISceneComponent {
  12886. /**
  12887. * The component name helpfull to identify the component in the list of scene components.
  12888. */
  12889. readonly name: string;
  12890. /**
  12891. * The scene the component belongs to.
  12892. */
  12893. scene: Scene;
  12894. /**
  12895. * Creates a new instance of the component for the given scene
  12896. * @param scene Defines the scene to register the component in
  12897. */
  12898. constructor(scene: Scene);
  12899. /**
  12900. * Registers the component in a given scene
  12901. */
  12902. register(): void;
  12903. /**
  12904. * Rebuilds the elements related to this component in case of
  12905. * context lost for instance.
  12906. */
  12907. rebuild(): void;
  12908. /**
  12909. * Disposes the component and the associated ressources
  12910. */
  12911. dispose(): void;
  12912. private _beforeCameraUpdate;
  12913. }
  12914. }
  12915. declare module BABYLON {
  12916. /**
  12917. * Defines supported buttons for XBox360 compatible gamepads
  12918. */
  12919. enum Xbox360Button {
  12920. /** A */
  12921. A = 0,
  12922. /** B */
  12923. B = 1,
  12924. /** X */
  12925. X = 2,
  12926. /** Y */
  12927. Y = 3,
  12928. /** Start */
  12929. Start = 4,
  12930. /** Back */
  12931. Back = 5,
  12932. /** Left button */
  12933. LB = 6,
  12934. /** Right button */
  12935. RB = 7,
  12936. /** Left stick */
  12937. LeftStick = 8,
  12938. /** Right stick */
  12939. RightStick = 9
  12940. }
  12941. /** Defines values for XBox360 DPad */
  12942. enum Xbox360Dpad {
  12943. /** Up */
  12944. Up = 0,
  12945. /** Down */
  12946. Down = 1,
  12947. /** Left */
  12948. Left = 2,
  12949. /** Right */
  12950. Right = 3
  12951. }
  12952. /**
  12953. * Defines a XBox360 gamepad
  12954. */
  12955. class Xbox360Pad extends Gamepad {
  12956. private _leftTrigger;
  12957. private _rightTrigger;
  12958. private _onlefttriggerchanged;
  12959. private _onrighttriggerchanged;
  12960. private _onbuttondown;
  12961. private _onbuttonup;
  12962. private _ondpaddown;
  12963. private _ondpadup;
  12964. /** Observable raised when a button is pressed */
  12965. onButtonDownObservable: Observable<Xbox360Button>;
  12966. /** Observable raised when a button is released */
  12967. onButtonUpObservable: Observable<Xbox360Button>;
  12968. /** Observable raised when a pad is pressed */
  12969. onPadDownObservable: Observable<Xbox360Dpad>;
  12970. /** Observable raised when a pad is released */
  12971. onPadUpObservable: Observable<Xbox360Dpad>;
  12972. private _buttonA;
  12973. private _buttonB;
  12974. private _buttonX;
  12975. private _buttonY;
  12976. private _buttonBack;
  12977. private _buttonStart;
  12978. private _buttonLB;
  12979. private _buttonRB;
  12980. private _buttonLeftStick;
  12981. private _buttonRightStick;
  12982. private _dPadUp;
  12983. private _dPadDown;
  12984. private _dPadLeft;
  12985. private _dPadRight;
  12986. private _isXboxOnePad;
  12987. /**
  12988. * Creates a new XBox360 gamepad object
  12989. * @param id defines the id of this gamepad
  12990. * @param index defines its index
  12991. * @param gamepad defines the internal HTML gamepad object
  12992. * @param xboxOne defines if it is a XBox One gamepad
  12993. */
  12994. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12995. /**
  12996. * Defines the callback to call when left trigger is pressed
  12997. * @param callback defines the callback to use
  12998. */
  12999. onlefttriggerchanged(callback: (value: number) => void): void;
  13000. /**
  13001. * Defines the callback to call when right trigger is pressed
  13002. * @param callback defines the callback to use
  13003. */
  13004. onrighttriggerchanged(callback: (value: number) => void): void;
  13005. /**
  13006. * Gets the left trigger value
  13007. */
  13008. /**
  13009. * Sets the left trigger value
  13010. */
  13011. leftTrigger: number;
  13012. /**
  13013. * Gets the right trigger value
  13014. */
  13015. /**
  13016. * Sets the right trigger value
  13017. */
  13018. rightTrigger: number;
  13019. /**
  13020. * Defines the callback to call when a button is pressed
  13021. * @param callback defines the callback to use
  13022. */
  13023. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  13024. /**
  13025. * Defines the callback to call when a button is released
  13026. * @param callback defines the callback to use
  13027. */
  13028. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13029. /**
  13030. * Defines the callback to call when a pad is pressed
  13031. * @param callback defines the callback to use
  13032. */
  13033. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13034. /**
  13035. * Defines the callback to call when a pad is released
  13036. * @param callback defines the callback to use
  13037. */
  13038. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13039. private _setButtonValue;
  13040. private _setDPadValue;
  13041. /**
  13042. * Gets the value of the `A` button
  13043. */
  13044. /**
  13045. * Sets the value of the `A` button
  13046. */
  13047. buttonA: number;
  13048. /**
  13049. * Gets the value of the `B` button
  13050. */
  13051. /**
  13052. * Sets the value of the `B` button
  13053. */
  13054. buttonB: number;
  13055. /**
  13056. * Gets the value of the `X` button
  13057. */
  13058. /**
  13059. * Sets the value of the `X` button
  13060. */
  13061. buttonX: number;
  13062. /**
  13063. * Gets the value of the `Y` button
  13064. */
  13065. /**
  13066. * Sets the value of the `Y` button
  13067. */
  13068. buttonY: number;
  13069. /**
  13070. * Gets the value of the `Start` button
  13071. */
  13072. /**
  13073. * Sets the value of the `Start` button
  13074. */
  13075. buttonStart: number;
  13076. /**
  13077. * Gets the value of the `Back` button
  13078. */
  13079. /**
  13080. * Sets the value of the `Back` button
  13081. */
  13082. buttonBack: number;
  13083. /**
  13084. * Gets the value of the `Left` button
  13085. */
  13086. /**
  13087. * Sets the value of the `Left` button
  13088. */
  13089. buttonLB: number;
  13090. /**
  13091. * Gets the value of the `Right` button
  13092. */
  13093. /**
  13094. * Sets the value of the `Right` button
  13095. */
  13096. buttonRB: number;
  13097. /**
  13098. * Gets the value of the Left joystick
  13099. */
  13100. /**
  13101. * Sets the value of the Left joystick
  13102. */
  13103. buttonLeftStick: number;
  13104. /**
  13105. * Gets the value of the Right joystick
  13106. */
  13107. /**
  13108. * Sets the value of the Right joystick
  13109. */
  13110. buttonRightStick: number;
  13111. /**
  13112. * Gets the value of D-pad up
  13113. */
  13114. /**
  13115. * Sets the value of D-pad up
  13116. */
  13117. dPadUp: number;
  13118. /**
  13119. * Gets the value of D-pad down
  13120. */
  13121. /**
  13122. * Sets the value of D-pad down
  13123. */
  13124. dPadDown: number;
  13125. /**
  13126. * Gets the value of D-pad left
  13127. */
  13128. /**
  13129. * Sets the value of D-pad left
  13130. */
  13131. dPadLeft: number;
  13132. /**
  13133. * Gets the value of D-pad right
  13134. */
  13135. /**
  13136. * Sets the value of D-pad right
  13137. */
  13138. dPadRight: number;
  13139. /**
  13140. * Force the gamepad to synchronize with device values
  13141. */
  13142. update(): void;
  13143. /**
  13144. * Disposes the gamepad
  13145. */
  13146. dispose(): void;
  13147. }
  13148. }
  13149. declare module BABYLON {
  13150. /**
  13151. * Represents the different options available during the creation of
  13152. * a Environment helper.
  13153. *
  13154. * This can control the default ground, skybox and image processing setup of your scene.
  13155. */
  13156. interface IEnvironmentHelperOptions {
  13157. /**
  13158. * Specifies wether or not to create a ground.
  13159. * True by default.
  13160. */
  13161. createGround: boolean;
  13162. /**
  13163. * Specifies the ground size.
  13164. * 15 by default.
  13165. */
  13166. groundSize: number;
  13167. /**
  13168. * The texture used on the ground for the main color.
  13169. * Comes from the BabylonJS CDN by default.
  13170. *
  13171. * Remarks: Can be either a texture or a url.
  13172. */
  13173. groundTexture: string | BaseTexture;
  13174. /**
  13175. * The color mixed in the ground texture by default.
  13176. * BabylonJS clearColor by default.
  13177. */
  13178. groundColor: Color3;
  13179. /**
  13180. * Specifies the ground opacity.
  13181. * 1 by default.
  13182. */
  13183. groundOpacity: number;
  13184. /**
  13185. * Enables the ground to receive shadows.
  13186. * True by default.
  13187. */
  13188. enableGroundShadow: boolean;
  13189. /**
  13190. * Helps preventing the shadow to be fully black on the ground.
  13191. * 0.5 by default.
  13192. */
  13193. groundShadowLevel: number;
  13194. /**
  13195. * Creates a mirror texture attach to the ground.
  13196. * false by default.
  13197. */
  13198. enableGroundMirror: boolean;
  13199. /**
  13200. * Specifies the ground mirror size ratio.
  13201. * 0.3 by default as the default kernel is 64.
  13202. */
  13203. groundMirrorSizeRatio: number;
  13204. /**
  13205. * Specifies the ground mirror blur kernel size.
  13206. * 64 by default.
  13207. */
  13208. groundMirrorBlurKernel: number;
  13209. /**
  13210. * Specifies the ground mirror visibility amount.
  13211. * 1 by default
  13212. */
  13213. groundMirrorAmount: number;
  13214. /**
  13215. * Specifies the ground mirror reflectance weight.
  13216. * This uses the standard weight of the background material to setup the fresnel effect
  13217. * of the mirror.
  13218. * 1 by default.
  13219. */
  13220. groundMirrorFresnelWeight: number;
  13221. /**
  13222. * Specifies the ground mirror Falloff distance.
  13223. * This can helps reducing the size of the reflection.
  13224. * 0 by Default.
  13225. */
  13226. groundMirrorFallOffDistance: number;
  13227. /**
  13228. * Specifies the ground mirror texture type.
  13229. * Unsigned Int by Default.
  13230. */
  13231. groundMirrorTextureType: number;
  13232. /**
  13233. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13234. * the shown objects.
  13235. */
  13236. groundYBias: number;
  13237. /**
  13238. * Specifies wether or not to create a skybox.
  13239. * True by default.
  13240. */
  13241. createSkybox: boolean;
  13242. /**
  13243. * Specifies the skybox size.
  13244. * 20 by default.
  13245. */
  13246. skyboxSize: number;
  13247. /**
  13248. * The texture used on the skybox for the main color.
  13249. * Comes from the BabylonJS CDN by default.
  13250. *
  13251. * Remarks: Can be either a texture or a url.
  13252. */
  13253. skyboxTexture: string | BaseTexture;
  13254. /**
  13255. * The color mixed in the skybox texture by default.
  13256. * BabylonJS clearColor by default.
  13257. */
  13258. skyboxColor: Color3;
  13259. /**
  13260. * The background rotation around the Y axis of the scene.
  13261. * This helps aligning the key lights of your scene with the background.
  13262. * 0 by default.
  13263. */
  13264. backgroundYRotation: number;
  13265. /**
  13266. * Compute automatically the size of the elements to best fit with the scene.
  13267. */
  13268. sizeAuto: boolean;
  13269. /**
  13270. * Default position of the rootMesh if autoSize is not true.
  13271. */
  13272. rootPosition: Vector3;
  13273. /**
  13274. * Sets up the image processing in the scene.
  13275. * true by default.
  13276. */
  13277. setupImageProcessing: boolean;
  13278. /**
  13279. * The texture used as your environment texture in the scene.
  13280. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13281. *
  13282. * Remarks: Can be either a texture or a url.
  13283. */
  13284. environmentTexture: string | BaseTexture;
  13285. /**
  13286. * The value of the exposure to apply to the scene.
  13287. * 0.6 by default if setupImageProcessing is true.
  13288. */
  13289. cameraExposure: number;
  13290. /**
  13291. * The value of the contrast to apply to the scene.
  13292. * 1.6 by default if setupImageProcessing is true.
  13293. */
  13294. cameraContrast: number;
  13295. /**
  13296. * Specifies wether or not tonemapping should be enabled in the scene.
  13297. * true by default if setupImageProcessing is true.
  13298. */
  13299. toneMappingEnabled: boolean;
  13300. }
  13301. /**
  13302. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13303. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13304. * It also helps with the default setup of your imageProcessing configuration.
  13305. */
  13306. class EnvironmentHelper {
  13307. /**
  13308. * Default ground texture URL.
  13309. */
  13310. private static _groundTextureCDNUrl;
  13311. /**
  13312. * Default skybox texture URL.
  13313. */
  13314. private static _skyboxTextureCDNUrl;
  13315. /**
  13316. * Default environment texture URL.
  13317. */
  13318. private static _environmentTextureCDNUrl;
  13319. /**
  13320. * Creates the default options for the helper.
  13321. */
  13322. private static _getDefaultOptions;
  13323. private _rootMesh;
  13324. /**
  13325. * Gets the root mesh created by the helper.
  13326. */
  13327. readonly rootMesh: Mesh;
  13328. private _skybox;
  13329. /**
  13330. * Gets the skybox created by the helper.
  13331. */
  13332. readonly skybox: Nullable<Mesh>;
  13333. private _skyboxTexture;
  13334. /**
  13335. * Gets the skybox texture created by the helper.
  13336. */
  13337. readonly skyboxTexture: Nullable<BaseTexture>;
  13338. private _skyboxMaterial;
  13339. /**
  13340. * Gets the skybox material created by the helper.
  13341. */
  13342. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13343. private _ground;
  13344. /**
  13345. * Gets the ground mesh created by the helper.
  13346. */
  13347. readonly ground: Nullable<Mesh>;
  13348. private _groundTexture;
  13349. /**
  13350. * Gets the ground texture created by the helper.
  13351. */
  13352. readonly groundTexture: Nullable<BaseTexture>;
  13353. private _groundMirror;
  13354. /**
  13355. * Gets the ground mirror created by the helper.
  13356. */
  13357. readonly groundMirror: Nullable<MirrorTexture>;
  13358. /**
  13359. * Gets the ground mirror render list to helps pushing the meshes
  13360. * you wish in the ground reflection.
  13361. */
  13362. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13363. private _groundMaterial;
  13364. /**
  13365. * Gets the ground material created by the helper.
  13366. */
  13367. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13368. /**
  13369. * Stores the creation options.
  13370. */
  13371. private readonly _scene;
  13372. private _options;
  13373. /**
  13374. * This observable will be notified with any error during the creation of the environment,
  13375. * mainly texture creation errors.
  13376. */
  13377. onErrorObservable: Observable<{
  13378. message?: string;
  13379. exception?: any;
  13380. }>;
  13381. /**
  13382. * constructor
  13383. * @param options
  13384. * @param scene The scene to add the material to
  13385. */
  13386. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13387. /**
  13388. * Updates the background according to the new options
  13389. * @param options
  13390. */
  13391. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13392. /**
  13393. * Sets the primary color of all the available elements.
  13394. * @param color the main color to affect to the ground and the background
  13395. */
  13396. setMainColor(color: Color3): void;
  13397. /**
  13398. * Setup the image processing according to the specified options.
  13399. */
  13400. private _setupImageProcessing;
  13401. /**
  13402. * Setup the environment texture according to the specified options.
  13403. */
  13404. private _setupEnvironmentTexture;
  13405. /**
  13406. * Setup the background according to the specified options.
  13407. */
  13408. private _setupBackground;
  13409. /**
  13410. * Get the scene sizes according to the setup.
  13411. */
  13412. private _getSceneSize;
  13413. /**
  13414. * Setup the ground according to the specified options.
  13415. */
  13416. private _setupGround;
  13417. /**
  13418. * Setup the ground material according to the specified options.
  13419. */
  13420. private _setupGroundMaterial;
  13421. /**
  13422. * Setup the ground diffuse texture according to the specified options.
  13423. */
  13424. private _setupGroundDiffuseTexture;
  13425. /**
  13426. * Setup the ground mirror texture according to the specified options.
  13427. */
  13428. private _setupGroundMirrorTexture;
  13429. /**
  13430. * Setup the ground to receive the mirror texture.
  13431. */
  13432. private _setupMirrorInGroundMaterial;
  13433. /**
  13434. * Setup the skybox according to the specified options.
  13435. */
  13436. private _setupSkybox;
  13437. /**
  13438. * Setup the skybox material according to the specified options.
  13439. */
  13440. private _setupSkyboxMaterial;
  13441. /**
  13442. * Setup the skybox reflection texture according to the specified options.
  13443. */
  13444. private _setupSkyboxReflectionTexture;
  13445. private _errorHandler;
  13446. /**
  13447. * Dispose all the elements created by the Helper.
  13448. */
  13449. dispose(): void;
  13450. }
  13451. }
  13452. declare module BABYLON {
  13453. /**
  13454. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13455. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13456. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13457. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13458. */
  13459. class PhotoDome extends TransformNode {
  13460. private _useDirectMapping;
  13461. /**
  13462. * The texture being displayed on the sphere
  13463. */
  13464. protected _photoTexture: Texture;
  13465. /**
  13466. * Gets or sets the texture being displayed on the sphere
  13467. */
  13468. photoTexture: Texture;
  13469. /**
  13470. * Observable raised when an error occured while loading the 360 image
  13471. */
  13472. onLoadErrorObservable: Observable<string>;
  13473. /**
  13474. * The skybox material
  13475. */
  13476. protected _material: BackgroundMaterial;
  13477. /**
  13478. * The surface used for the skybox
  13479. */
  13480. protected _mesh: Mesh;
  13481. /**
  13482. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13483. * Also see the options.resolution property.
  13484. */
  13485. fovMultiplier: number;
  13486. /**
  13487. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13488. * @param name Element's name, child elements will append suffixes for their own names.
  13489. * @param urlsOfPhoto defines the url of the photo to display
  13490. * @param options defines an object containing optional or exposed sub element properties
  13491. * @param onError defines a callback called when an error occured while loading the texture
  13492. */
  13493. constructor(name: string, urlOfPhoto: string, options: {
  13494. resolution?: number;
  13495. size?: number;
  13496. useDirectMapping?: boolean;
  13497. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13498. /**
  13499. * Releases resources associated with this node.
  13500. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13501. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13502. */
  13503. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13504. }
  13505. }
  13506. declare module BABYLON {
  13507. interface Scene {
  13508. /**
  13509. * Creates a default light for the scene.
  13510. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13511. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13512. */
  13513. createDefaultLight(replace?: boolean): void;
  13514. /**
  13515. * Creates a default camera for the scene.
  13516. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13517. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13518. * @param replace has default false, when true replaces the active camera in the scene
  13519. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13520. */
  13521. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13522. /**
  13523. * Creates a default camera and a default light.
  13524. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13525. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13526. * @param replace has the default false, when true replaces the active camera/light in the scene
  13527. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13528. */
  13529. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13530. /**
  13531. * Creates a new sky box
  13532. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13533. * @param environmentTexture defines the texture to use as environment texture
  13534. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13535. * @param scale defines the overall scale of the skybox
  13536. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13537. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13538. * @returns a new mesh holding the sky box
  13539. */
  13540. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13541. /**
  13542. * Creates a new environment
  13543. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13544. * @param options defines the options you can use to configure the environment
  13545. * @returns the new EnvironmentHelper
  13546. */
  13547. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13548. /**
  13549. * Creates a new VREXperienceHelper
  13550. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13551. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13552. * @returns a new VREXperienceHelper
  13553. */
  13554. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13555. /**
  13556. * Creates a new XREXperienceHelper
  13557. * @see http://doc.babylonjs.com/how_to/webxr
  13558. * @returns a promise for a new XREXperienceHelper
  13559. */
  13560. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13561. }
  13562. }
  13563. declare module BABYLON {
  13564. /**
  13565. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13566. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13567. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13568. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13569. */
  13570. class VideoDome extends TransformNode {
  13571. private _useDirectMapping;
  13572. /**
  13573. * The video texture being displayed on the sphere
  13574. */
  13575. protected _videoTexture: VideoTexture;
  13576. /**
  13577. * Gets the video texture being displayed on the sphere
  13578. */
  13579. readonly videoTexture: VideoTexture;
  13580. /**
  13581. * The skybox material
  13582. */
  13583. protected _material: BackgroundMaterial;
  13584. /**
  13585. * The surface used for the skybox
  13586. */
  13587. protected _mesh: Mesh;
  13588. /**
  13589. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13590. * Also see the options.resolution property.
  13591. */
  13592. fovMultiplier: number;
  13593. /**
  13594. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13595. * @param name Element's name, child elements will append suffixes for their own names.
  13596. * @param urlsOrVideo defines the url(s) or the video element to use
  13597. * @param options An object containing optional or exposed sub element properties
  13598. */
  13599. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13600. resolution?: number;
  13601. clickToPlay?: boolean;
  13602. autoPlay?: boolean;
  13603. loop?: boolean;
  13604. size?: number;
  13605. poster?: string;
  13606. useDirectMapping?: boolean;
  13607. }, scene: Scene);
  13608. /**
  13609. * Releases resources associated with this node.
  13610. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13611. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13612. */
  13613. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13614. }
  13615. }
  13616. declare module BABYLON {
  13617. /**
  13618. * This class can be used to get instrumentation data from a Babylon engine
  13619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13620. */
  13621. class EngineInstrumentation implements IDisposable {
  13622. /**
  13623. * Define the instrumented engine.
  13624. */
  13625. engine: Engine;
  13626. private _captureGPUFrameTime;
  13627. private _gpuFrameTimeToken;
  13628. private _gpuFrameTime;
  13629. private _captureShaderCompilationTime;
  13630. private _shaderCompilationTime;
  13631. private _onBeginFrameObserver;
  13632. private _onEndFrameObserver;
  13633. private _onBeforeShaderCompilationObserver;
  13634. private _onAfterShaderCompilationObserver;
  13635. /**
  13636. * Gets the perf counter used for GPU frame time
  13637. */
  13638. readonly gpuFrameTimeCounter: PerfCounter;
  13639. /**
  13640. * Gets the GPU frame time capture status
  13641. */
  13642. /**
  13643. * Enable or disable the GPU frame time capture
  13644. */
  13645. captureGPUFrameTime: boolean;
  13646. /**
  13647. * Gets the perf counter used for shader compilation time
  13648. */
  13649. readonly shaderCompilationTimeCounter: PerfCounter;
  13650. /**
  13651. * Gets the shader compilation time capture status
  13652. */
  13653. /**
  13654. * Enable or disable the shader compilation time capture
  13655. */
  13656. captureShaderCompilationTime: boolean;
  13657. /**
  13658. * Instantiates a new engine instrumentation.
  13659. * This class can be used to get instrumentation data from a Babylon engine
  13660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13661. * @param engine Defines the engine to instrument
  13662. */
  13663. constructor(
  13664. /**
  13665. * Define the instrumented engine.
  13666. */
  13667. engine: Engine);
  13668. /**
  13669. * Dispose and release associated resources.
  13670. */
  13671. dispose(): void;
  13672. }
  13673. }
  13674. declare module BABYLON {
  13675. /**
  13676. * This class can be used to get instrumentation data from a Babylon engine
  13677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13678. */
  13679. class SceneInstrumentation implements IDisposable {
  13680. /**
  13681. * Defines the scene to instrument
  13682. */
  13683. scene: Scene;
  13684. private _captureActiveMeshesEvaluationTime;
  13685. private _activeMeshesEvaluationTime;
  13686. private _captureRenderTargetsRenderTime;
  13687. private _renderTargetsRenderTime;
  13688. private _captureFrameTime;
  13689. private _frameTime;
  13690. private _captureRenderTime;
  13691. private _renderTime;
  13692. private _captureInterFrameTime;
  13693. private _interFrameTime;
  13694. private _captureParticlesRenderTime;
  13695. private _particlesRenderTime;
  13696. private _captureSpritesRenderTime;
  13697. private _spritesRenderTime;
  13698. private _capturePhysicsTime;
  13699. private _physicsTime;
  13700. private _captureAnimationsTime;
  13701. private _animationsTime;
  13702. private _captureCameraRenderTime;
  13703. private _cameraRenderTime;
  13704. private _onBeforeActiveMeshesEvaluationObserver;
  13705. private _onAfterActiveMeshesEvaluationObserver;
  13706. private _onBeforeRenderTargetsRenderObserver;
  13707. private _onAfterRenderTargetsRenderObserver;
  13708. private _onAfterRenderObserver;
  13709. private _onBeforeDrawPhaseObserver;
  13710. private _onAfterDrawPhaseObserver;
  13711. private _onBeforeAnimationsObserver;
  13712. private _onBeforeParticlesRenderingObserver;
  13713. private _onAfterParticlesRenderingObserver;
  13714. private _onBeforeSpritesRenderingObserver;
  13715. private _onAfterSpritesRenderingObserver;
  13716. private _onBeforePhysicsObserver;
  13717. private _onAfterPhysicsObserver;
  13718. private _onAfterAnimationsObserver;
  13719. private _onBeforeCameraRenderObserver;
  13720. private _onAfterCameraRenderObserver;
  13721. /**
  13722. * Gets the perf counter used for active meshes evaluation time
  13723. */
  13724. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13725. /**
  13726. * Gets the active meshes evaluation time capture status
  13727. */
  13728. /**
  13729. * Enable or disable the active meshes evaluation time capture
  13730. */
  13731. captureActiveMeshesEvaluationTime: boolean;
  13732. /**
  13733. * Gets the perf counter used for render targets render time
  13734. */
  13735. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13736. /**
  13737. * Gets the render targets render time capture status
  13738. */
  13739. /**
  13740. * Enable or disable the render targets render time capture
  13741. */
  13742. captureRenderTargetsRenderTime: boolean;
  13743. /**
  13744. * Gets the perf counter used for particles render time
  13745. */
  13746. readonly particlesRenderTimeCounter: PerfCounter;
  13747. /**
  13748. * Gets the particles render time capture status
  13749. */
  13750. /**
  13751. * Enable or disable the particles render time capture
  13752. */
  13753. captureParticlesRenderTime: boolean;
  13754. /**
  13755. * Gets the perf counter used for sprites render time
  13756. */
  13757. readonly spritesRenderTimeCounter: PerfCounter;
  13758. /**
  13759. * Gets the sprites render time capture status
  13760. */
  13761. /**
  13762. * Enable or disable the sprites render time capture
  13763. */
  13764. captureSpritesRenderTime: boolean;
  13765. /**
  13766. * Gets the perf counter used for physics time
  13767. */
  13768. readonly physicsTimeCounter: PerfCounter;
  13769. /**
  13770. * Gets the physics time capture status
  13771. */
  13772. /**
  13773. * Enable or disable the physics time capture
  13774. */
  13775. capturePhysicsTime: boolean;
  13776. /**
  13777. * Gets the perf counter used for animations time
  13778. */
  13779. readonly animationsTimeCounter: PerfCounter;
  13780. /**
  13781. * Gets the animations time capture status
  13782. */
  13783. /**
  13784. * Enable or disable the animations time capture
  13785. */
  13786. captureAnimationsTime: boolean;
  13787. /**
  13788. * Gets the perf counter used for frame time capture
  13789. */
  13790. readonly frameTimeCounter: PerfCounter;
  13791. /**
  13792. * Gets the frame time capture status
  13793. */
  13794. /**
  13795. * Enable or disable the frame time capture
  13796. */
  13797. captureFrameTime: boolean;
  13798. /**
  13799. * Gets the perf counter used for inter-frames time capture
  13800. */
  13801. readonly interFrameTimeCounter: PerfCounter;
  13802. /**
  13803. * Gets the inter-frames time capture status
  13804. */
  13805. /**
  13806. * Enable or disable the inter-frames time capture
  13807. */
  13808. captureInterFrameTime: boolean;
  13809. /**
  13810. * Gets the perf counter used for render time capture
  13811. */
  13812. readonly renderTimeCounter: PerfCounter;
  13813. /**
  13814. * Gets the render time capture status
  13815. */
  13816. /**
  13817. * Enable or disable the render time capture
  13818. */
  13819. captureRenderTime: boolean;
  13820. /**
  13821. * Gets the perf counter used for camera render time capture
  13822. */
  13823. readonly cameraRenderTimeCounter: PerfCounter;
  13824. /**
  13825. * Gets the camera render time capture status
  13826. */
  13827. /**
  13828. * Enable or disable the camera render time capture
  13829. */
  13830. captureCameraRenderTime: boolean;
  13831. /**
  13832. * Gets the perf counter used for draw calls
  13833. */
  13834. readonly drawCallsCounter: PerfCounter;
  13835. /**
  13836. * Gets the perf counter used for texture collisions
  13837. */
  13838. readonly textureCollisionsCounter: PerfCounter;
  13839. /**
  13840. * Instantiates a new scene instrumentation.
  13841. * This class can be used to get instrumentation data from a Babylon engine
  13842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13843. * @param scene Defines the scene to instrument
  13844. */
  13845. constructor(
  13846. /**
  13847. * Defines the scene to instrument
  13848. */
  13849. scene: Scene);
  13850. /**
  13851. * Dispose and release associated resources.
  13852. */
  13853. dispose(): void;
  13854. }
  13855. }
  13856. declare module BABYLON {
  13857. /**
  13858. * @hidden
  13859. **/
  13860. class _TimeToken {
  13861. _startTimeQuery: Nullable<WebGLQuery>;
  13862. _endTimeQuery: Nullable<WebGLQuery>;
  13863. _timeElapsedQuery: Nullable<WebGLQuery>;
  13864. _timeElapsedQueryEnded: boolean;
  13865. }
  13866. }
  13867. declare module BABYLON {
  13868. /**
  13869. * Single axis drag gizmo
  13870. */
  13871. class AxisDragGizmo extends Gizmo {
  13872. /**
  13873. * Drag behavior responsible for the gizmos dragging interactions
  13874. */
  13875. dragBehavior: PointerDragBehavior;
  13876. private _pointerObserver;
  13877. /**
  13878. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13879. */
  13880. snapDistance: number;
  13881. /**
  13882. * Event that fires each time the gizmo snaps to a new location.
  13883. * * snapDistance is the the change in distance
  13884. */
  13885. onSnapObservable: Observable<{
  13886. snapDistance: number;
  13887. }>;
  13888. /** @hidden */
  13889. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13890. /** @hidden */
  13891. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13892. /**
  13893. * Creates an AxisDragGizmo
  13894. * @param gizmoLayer The utility layer the gizmo will be added to
  13895. * @param dragAxis The axis which the gizmo will be able to drag on
  13896. * @param color The color of the gizmo
  13897. */
  13898. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13899. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13900. /**
  13901. * Disposes of the gizmo
  13902. */
  13903. dispose(): void;
  13904. }
  13905. }
  13906. declare module BABYLON {
  13907. /**
  13908. * Single axis scale gizmo
  13909. */
  13910. class AxisScaleGizmo extends Gizmo {
  13911. private _coloredMaterial;
  13912. /**
  13913. * Drag behavior responsible for the gizmos dragging interactions
  13914. */
  13915. dragBehavior: PointerDragBehavior;
  13916. private _pointerObserver;
  13917. /**
  13918. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13919. */
  13920. snapDistance: number;
  13921. /**
  13922. * Event that fires each time the gizmo snaps to a new location.
  13923. * * snapDistance is the the change in distance
  13924. */
  13925. onSnapObservable: Observable<{
  13926. snapDistance: number;
  13927. }>;
  13928. /**
  13929. * If the scaling operation should be done on all axis (default: false)
  13930. */
  13931. uniformScaling: boolean;
  13932. /**
  13933. * Creates an AxisScaleGizmo
  13934. * @param gizmoLayer The utility layer the gizmo will be added to
  13935. * @param dragAxis The axis which the gizmo will be able to scale on
  13936. * @param color The color of the gizmo
  13937. */
  13938. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13939. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13940. /**
  13941. * Disposes of the gizmo
  13942. */
  13943. dispose(): void;
  13944. /**
  13945. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13946. * @param mesh The mesh to replace the default mesh of the gizmo
  13947. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13948. */
  13949. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13950. }
  13951. }
  13952. declare module BABYLON {
  13953. /**
  13954. * Bounding box gizmo
  13955. */
  13956. class BoundingBoxGizmo extends Gizmo {
  13957. private _lineBoundingBox;
  13958. private _rotateSpheresParent;
  13959. private _scaleBoxesParent;
  13960. private _boundingDimensions;
  13961. private _renderObserver;
  13962. private _pointerObserver;
  13963. private _scaleDragSpeed;
  13964. private _tmpQuaternion;
  13965. private _tmpVector;
  13966. private _tmpRotationMatrix;
  13967. /**
  13968. * 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)
  13969. */
  13970. ignoreChildren: boolean;
  13971. /**
  13972. * 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)
  13973. */
  13974. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13975. /**
  13976. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13977. */
  13978. rotationSphereSize: number;
  13979. /**
  13980. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13981. */
  13982. scaleBoxSize: number;
  13983. /**
  13984. * 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)
  13985. */
  13986. fixedDragMeshScreenSize: boolean;
  13987. /**
  13988. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13989. */
  13990. fixedDragMeshScreenSizeDistanceFactor: number;
  13991. /**
  13992. * Fired when a rotation sphere or scale box is dragged
  13993. */
  13994. onDragStartObservable: Observable<{}>;
  13995. /**
  13996. * Fired when a scale box is dragged
  13997. */
  13998. onScaleBoxDragObservable: Observable<{}>;
  13999. /**
  14000. * Fired when a scale box drag is ended
  14001. */
  14002. onScaleBoxDragEndObservable: Observable<{}>;
  14003. /**
  14004. * Fired when a rotation sphere is dragged
  14005. */
  14006. onRotationSphereDragObservable: Observable<{}>;
  14007. /**
  14008. * Fired when a rotation sphere drag is ended
  14009. */
  14010. onRotationSphereDragEndObservable: Observable<{}>;
  14011. /**
  14012. * 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)
  14013. */
  14014. scalePivot: Nullable<Vector3>;
  14015. private _anchorMesh;
  14016. private _existingMeshScale;
  14017. private _dragMesh;
  14018. private pointerDragBehavior;
  14019. private static _PivotCached;
  14020. private static _OldPivotPoint;
  14021. private static _PivotTranslation;
  14022. private static _PivotTmpVector;
  14023. /** @hidden */
  14024. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  14025. /** @hidden */
  14026. static _RestorePivotPoint(mesh: AbstractMesh): void;
  14027. /**
  14028. * Creates an BoundingBoxGizmo
  14029. * @param gizmoLayer The utility layer the gizmo will be added to
  14030. * @param color The color of the gizmo
  14031. */
  14032. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  14033. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  14034. private _selectNode;
  14035. /**
  14036. * Updates the bounding box information for the Gizmo
  14037. */
  14038. updateBoundingBox(): void;
  14039. private _updateRotationSpheres;
  14040. private _updateScaleBoxes;
  14041. /**
  14042. * Enables rotation on the specified axis and disables rotation on the others
  14043. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  14044. */
  14045. setEnabledRotationAxis(axis: string): void;
  14046. private _updateDummy;
  14047. /**
  14048. * Enables a pointer drag behavior on the bounding box of the gizmo
  14049. */
  14050. enableDragBehavior(): void;
  14051. /**
  14052. * Disposes of the gizmo
  14053. */
  14054. dispose(): void;
  14055. /**
  14056. * 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)
  14057. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  14058. * @returns the bounding box mesh with the passed in mesh as a child
  14059. */
  14060. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  14061. /**
  14062. * CustomMeshes are not supported by this gizmo
  14063. * @param mesh The mesh to replace the default mesh of the gizmo
  14064. */
  14065. setCustomMesh(mesh: Mesh): void;
  14066. }
  14067. }
  14068. declare module BABYLON {
  14069. /**
  14070. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  14071. */
  14072. class Gizmo implements IDisposable {
  14073. /** The utility layer the gizmo will be added to */
  14074. gizmoLayer: UtilityLayerRenderer;
  14075. /**
  14076. * The root mesh of the gizmo
  14077. */
  14078. protected _rootMesh: Mesh;
  14079. private _attachedMesh;
  14080. /**
  14081. * Ratio for the scale of the gizmo (Default: 1)
  14082. */
  14083. scaleRatio: number;
  14084. private _tmpMatrix;
  14085. /**
  14086. * If a custom mesh has been set (Default: false)
  14087. */
  14088. protected _customMeshSet: boolean;
  14089. /**
  14090. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  14091. * * When set, interactions will be enabled
  14092. */
  14093. attachedMesh: Nullable<AbstractMesh>;
  14094. /**
  14095. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  14096. * @param mesh The mesh to replace the default mesh of the gizmo
  14097. */
  14098. setCustomMesh(mesh: Mesh): void;
  14099. /**
  14100. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  14101. */
  14102. updateGizmoRotationToMatchAttachedMesh: boolean;
  14103. /**
  14104. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  14105. */
  14106. updateGizmoPositionToMatchAttachedMesh: boolean;
  14107. /**
  14108. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  14109. */
  14110. protected _updateScale: boolean;
  14111. protected _interactionsEnabled: boolean;
  14112. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  14113. private _beforeRenderObserver;
  14114. /**
  14115. * Creates a gizmo
  14116. * @param gizmoLayer The utility layer the gizmo will be added to
  14117. */
  14118. constructor(
  14119. /** The utility layer the gizmo will be added to */
  14120. gizmoLayer?: UtilityLayerRenderer);
  14121. private _tempVector;
  14122. /**
  14123. * @hidden
  14124. * Updates the gizmo to match the attached mesh's position/rotation
  14125. */
  14126. protected _update(): void;
  14127. /**
  14128. * Disposes of the gizmo
  14129. */
  14130. dispose(): void;
  14131. }
  14132. }
  14133. declare module BABYLON {
  14134. /**
  14135. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  14136. */
  14137. class GizmoManager implements IDisposable {
  14138. private scene;
  14139. /**
  14140. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  14141. */
  14142. gizmos: {
  14143. positionGizmo: Nullable<PositionGizmo>;
  14144. rotationGizmo: Nullable<RotationGizmo>;
  14145. scaleGizmo: Nullable<ScaleGizmo>;
  14146. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  14147. };
  14148. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  14149. clearGizmoOnEmptyPointerEvent: boolean;
  14150. /** Fires an event when the manager is attached to a mesh */
  14151. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  14152. private _gizmosEnabled;
  14153. private _pointerObserver;
  14154. private _attachedMesh;
  14155. private _boundingBoxColor;
  14156. private _defaultUtilityLayer;
  14157. private _defaultKeepDepthUtilityLayer;
  14158. /**
  14159. * When bounding box gizmo is enabled, this can be used to track drag/end events
  14160. */
  14161. boundingBoxDragBehavior: SixDofDragBehavior;
  14162. /**
  14163. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  14164. */
  14165. attachableMeshes: Nullable<Array<AbstractMesh>>;
  14166. /**
  14167. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  14168. */
  14169. usePointerToAttachGizmos: boolean;
  14170. /**
  14171. * Instatiates a gizmo manager
  14172. * @param scene the scene to overlay the gizmos on top of
  14173. */
  14174. constructor(scene: Scene);
  14175. /**
  14176. * Attaches a set of gizmos to the specified mesh
  14177. * @param mesh The mesh the gizmo's should be attached to
  14178. */
  14179. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  14180. /**
  14181. * If the position gizmo is enabled
  14182. */
  14183. positionGizmoEnabled: boolean;
  14184. /**
  14185. * If the rotation gizmo is enabled
  14186. */
  14187. rotationGizmoEnabled: boolean;
  14188. /**
  14189. * If the scale gizmo is enabled
  14190. */
  14191. scaleGizmoEnabled: boolean;
  14192. /**
  14193. * If the boundingBox gizmo is enabled
  14194. */
  14195. boundingBoxGizmoEnabled: boolean;
  14196. /**
  14197. * Disposes of the gizmo manager
  14198. */
  14199. dispose(): void;
  14200. }
  14201. }
  14202. declare module BABYLON {
  14203. /**
  14204. * Single plane rotation gizmo
  14205. */
  14206. class PlaneRotationGizmo extends Gizmo {
  14207. /**
  14208. * Drag behavior responsible for the gizmos dragging interactions
  14209. */
  14210. dragBehavior: PointerDragBehavior;
  14211. private _pointerObserver;
  14212. /**
  14213. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  14214. */
  14215. snapDistance: number;
  14216. /**
  14217. * Event that fires each time the gizmo snaps to a new location.
  14218. * * snapDistance is the the change in distance
  14219. */
  14220. onSnapObservable: Observable<{
  14221. snapDistance: number;
  14222. }>;
  14223. /**
  14224. * Creates a PlaneRotationGizmo
  14225. * @param gizmoLayer The utility layer the gizmo will be added to
  14226. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  14227. * @param color The color of the gizmo
  14228. * @param tessellation Amount of tessellation to be used when creating rotation circles
  14229. */
  14230. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  14231. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  14232. /**
  14233. * Disposes of the gizmo
  14234. */
  14235. dispose(): void;
  14236. }
  14237. }
  14238. declare module BABYLON {
  14239. /**
  14240. * Gizmo that enables dragging a mesh along 3 axis
  14241. */
  14242. class PositionGizmo extends Gizmo {
  14243. /**
  14244. * Internal gizmo used for interactions on the x axis
  14245. */
  14246. xGizmo: AxisDragGizmo;
  14247. /**
  14248. * Internal gizmo used for interactions on the y axis
  14249. */
  14250. yGizmo: AxisDragGizmo;
  14251. /**
  14252. * Internal gizmo used for interactions on the z axis
  14253. */
  14254. zGizmo: AxisDragGizmo;
  14255. /** Fires an event when any of it's sub gizmos are dragged */
  14256. onDragStartObservable: Observable<{}>;
  14257. /** Fires an event when any of it's sub gizmos are released from dragging */
  14258. onDragEndObservable: Observable<{}>;
  14259. attachedMesh: Nullable<AbstractMesh>;
  14260. /**
  14261. * Creates a PositionGizmo
  14262. * @param gizmoLayer The utility layer the gizmo will be added to
  14263. */
  14264. constructor(gizmoLayer?: UtilityLayerRenderer);
  14265. updateGizmoRotationToMatchAttachedMesh: boolean;
  14266. /**
  14267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  14268. */
  14269. snapDistance: number;
  14270. /**
  14271. * Ratio for the scale of the gizmo (Default: 1)
  14272. */
  14273. scaleRatio: number;
  14274. /**
  14275. * Disposes of the gizmo
  14276. */
  14277. dispose(): void;
  14278. /**
  14279. * CustomMeshes are not supported by this gizmo
  14280. * @param mesh The mesh to replace the default mesh of the gizmo
  14281. */
  14282. setCustomMesh(mesh: Mesh): void;
  14283. }
  14284. }
  14285. declare module BABYLON {
  14286. /**
  14287. * Gizmo that enables rotating a mesh along 3 axis
  14288. */
  14289. class RotationGizmo extends Gizmo {
  14290. /**
  14291. * Internal gizmo used for interactions on the x axis
  14292. */
  14293. xGizmo: PlaneRotationGizmo;
  14294. /**
  14295. * Internal gizmo used for interactions on the y axis
  14296. */
  14297. yGizmo: PlaneRotationGizmo;
  14298. /**
  14299. * Internal gizmo used for interactions on the z axis
  14300. */
  14301. zGizmo: PlaneRotationGizmo;
  14302. /** Fires an event when any of it's sub gizmos are dragged */
  14303. onDragStartObservable: Observable<{}>;
  14304. /** Fires an event when any of it's sub gizmos are released from dragging */
  14305. onDragEndObservable: Observable<{}>;
  14306. attachedMesh: Nullable<AbstractMesh>;
  14307. /**
  14308. * Creates a RotationGizmo
  14309. * @param gizmoLayer The utility layer the gizmo will be added to
  14310. * @param tessellation Amount of tessellation to be used when creating rotation circles
  14311. */
  14312. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  14313. updateGizmoRotationToMatchAttachedMesh: boolean;
  14314. /**
  14315. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  14316. */
  14317. snapDistance: number;
  14318. /**
  14319. * Ratio for the scale of the gizmo (Default: 1)
  14320. */
  14321. scaleRatio: number;
  14322. /**
  14323. * Disposes of the gizmo
  14324. */
  14325. dispose(): void;
  14326. /**
  14327. * CustomMeshes are not supported by this gizmo
  14328. * @param mesh The mesh to replace the default mesh of the gizmo
  14329. */
  14330. setCustomMesh(mesh: Mesh): void;
  14331. }
  14332. }
  14333. declare module BABYLON {
  14334. /**
  14335. * Gizmo that enables scaling a mesh along 3 axis
  14336. */
  14337. class ScaleGizmo extends Gizmo {
  14338. /**
  14339. * Internal gizmo used for interactions on the x axis
  14340. */
  14341. xGizmo: AxisScaleGizmo;
  14342. /**
  14343. * Internal gizmo used for interactions on the y axis
  14344. */
  14345. yGizmo: AxisScaleGizmo;
  14346. /**
  14347. * Internal gizmo used for interactions on the z axis
  14348. */
  14349. zGizmo: AxisScaleGizmo;
  14350. /**
  14351. * Internal gizmo used to scale all axis equally
  14352. */
  14353. uniformScaleGizmo: AxisScaleGizmo;
  14354. /** Fires an event when any of it's sub gizmos are dragged */
  14355. onDragStartObservable: Observable<{}>;
  14356. /** Fires an event when any of it's sub gizmos are released from dragging */
  14357. onDragEndObservable: Observable<{}>;
  14358. attachedMesh: Nullable<AbstractMesh>;
  14359. /**
  14360. * Creates a ScaleGizmo
  14361. * @param gizmoLayer The utility layer the gizmo will be added to
  14362. */
  14363. constructor(gizmoLayer?: UtilityLayerRenderer);
  14364. updateGizmoRotationToMatchAttachedMesh: boolean;
  14365. /**
  14366. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  14367. */
  14368. snapDistance: number;
  14369. /**
  14370. * Ratio for the scale of the gizmo (Default: 1)
  14371. */
  14372. scaleRatio: number;
  14373. /**
  14374. * Disposes of the gizmo
  14375. */
  14376. dispose(): void;
  14377. }
  14378. }
  14379. declare module BABYLON {
  14380. /**
  14381. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14382. * It controls one of the indiviual texture used in the effect.
  14383. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14384. */
  14385. class LensFlare {
  14386. /**
  14387. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14388. */
  14389. size: number;
  14390. /**
  14391. * 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.
  14392. */
  14393. position: number;
  14394. /**
  14395. * Define the lens color.
  14396. */
  14397. color: Color3;
  14398. /**
  14399. * Define the lens texture.
  14400. */
  14401. texture: Nullable<Texture>;
  14402. /**
  14403. * Define the alpha mode to render this particular lens.
  14404. */
  14405. alphaMode: number;
  14406. private _system;
  14407. /**
  14408. * Creates a new Lens Flare.
  14409. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14410. * It controls one of the indiviual texture used in the effect.
  14411. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14412. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14413. * @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.
  14414. * @param color Define the lens color
  14415. * @param imgUrl Define the lens texture url
  14416. * @param system Define the `lensFlareSystem` this flare is part of
  14417. * @returns The newly created Lens Flare
  14418. */
  14419. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14420. /**
  14421. * Instantiates a new Lens Flare.
  14422. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14423. * It controls one of the indiviual texture used in the effect.
  14424. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14425. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14426. * @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.
  14427. * @param color Define the lens color
  14428. * @param imgUrl Define the lens texture url
  14429. * @param system Define the `lensFlareSystem` this flare is part of
  14430. */
  14431. constructor(
  14432. /**
  14433. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14434. */
  14435. size: number,
  14436. /**
  14437. * 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.
  14438. */
  14439. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14440. /**
  14441. * Dispose and release the lens flare with its associated resources.
  14442. */
  14443. dispose(): void;
  14444. }
  14445. }
  14446. declare module BABYLON {
  14447. /**
  14448. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14449. * It is usually composed of several `BABYLON.lensFlare`.
  14450. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14451. */
  14452. class LensFlareSystem {
  14453. /**
  14454. * Define the name of the lens flare system
  14455. */
  14456. name: string;
  14457. /**
  14458. * List of lens flares used in this system.
  14459. */
  14460. lensFlares: LensFlare[];
  14461. /**
  14462. * Define a limit from the border the lens flare can be visible.
  14463. */
  14464. borderLimit: number;
  14465. /**
  14466. * Define a viewport border we do not want to see the lens flare in.
  14467. */
  14468. viewportBorder: number;
  14469. /**
  14470. * Define a predicate which could limit the list of meshes able to occlude the effect.
  14471. */
  14472. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  14473. /**
  14474. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  14475. */
  14476. layerMask: number;
  14477. /**
  14478. * Define the id of the lens flare system in the scene.
  14479. * (equal to name by default)
  14480. */
  14481. id: string;
  14482. private _scene;
  14483. private _emitter;
  14484. private _vertexBuffers;
  14485. private _indexBuffer;
  14486. private _effect;
  14487. private _positionX;
  14488. private _positionY;
  14489. private _isEnabled;
  14490. /**
  14491. * Instantiates a lens flare system.
  14492. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14493. * It is usually composed of several `BABYLON.lensFlare`.
  14494. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14495. * @param name Define the name of the lens flare system in the scene
  14496. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  14497. * @param scene Define the scene the lens flare system belongs to
  14498. */
  14499. constructor(
  14500. /**
  14501. * Define the name of the lens flare system
  14502. */
  14503. name: string, emitter: any, scene: Scene);
  14504. /**
  14505. * Define if the lens flare system is enabled.
  14506. */
  14507. isEnabled: boolean;
  14508. /**
  14509. * Get the scene the effects belongs to.
  14510. * @returns the scene holding the lens flare system
  14511. */
  14512. getScene(): Scene;
  14513. /**
  14514. * Get the emitter of the lens flare system.
  14515. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14516. * @returns the emitter of the lens flare system
  14517. */
  14518. getEmitter(): any;
  14519. /**
  14520. * Set the emitter of the lens flare system.
  14521. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14522. * @param newEmitter Define the new emitter of the system
  14523. */
  14524. setEmitter(newEmitter: any): void;
  14525. /**
  14526. * Get the lens flare system emitter position.
  14527. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  14528. * @returns the position
  14529. */
  14530. getEmitterPosition(): Vector3;
  14531. /**
  14532. * @hidden
  14533. */
  14534. computeEffectivePosition(globalViewport: Viewport): boolean;
  14535. /** @hidden */
  14536. _isVisible(): boolean;
  14537. /**
  14538. * @hidden
  14539. */
  14540. render(): boolean;
  14541. /**
  14542. * Dispose and release the lens flare with its associated resources.
  14543. */
  14544. dispose(): void;
  14545. /**
  14546. * Parse a lens flare system from a JSON repressentation
  14547. * @param parsedLensFlareSystem Define the JSON to parse
  14548. * @param scene Define the scene the parsed system should be instantiated in
  14549. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  14550. * @returns the parsed system
  14551. */
  14552. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  14553. /**
  14554. * Serialize the current Lens Flare System into a JSON representation.
  14555. * @returns the serialized JSON
  14556. */
  14557. serialize(): any;
  14558. }
  14559. }
  14560. declare module BABYLON {
  14561. interface AbstractScene {
  14562. /**
  14563. * The list of lens flare system added to the scene
  14564. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14565. */
  14566. lensFlareSystems: Array<LensFlareSystem>;
  14567. /**
  14568. * Removes the given lens flare system from this scene.
  14569. * @param toRemove The lens flare system to remove
  14570. * @returns The index of the removed lens flare system
  14571. */
  14572. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  14573. /**
  14574. * Adds the given lens flare system to this scene
  14575. * @param newLensFlareSystem The lens flare system to add
  14576. */
  14577. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  14578. /**
  14579. * Gets a lens flare system using its name
  14580. * @param name defines the name to look for
  14581. * @returns the lens flare system or null if not found
  14582. */
  14583. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  14584. /**
  14585. * Gets a lens flare system using its id
  14586. * @param id defines the id to look for
  14587. * @returns the lens flare system or null if not found
  14588. */
  14589. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  14590. }
  14591. /**
  14592. * Defines the lens flare scene component responsible to manage any lens flares
  14593. * in a given scene.
  14594. */
  14595. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  14596. /**
  14597. * The component name helpfull to identify the component in the list of scene components.
  14598. */
  14599. readonly name: string;
  14600. /**
  14601. * The scene the component belongs to.
  14602. */
  14603. scene: Scene;
  14604. /**
  14605. * Creates a new instance of the component for the given scene
  14606. * @param scene Defines the scene to register the component in
  14607. */
  14608. constructor(scene: Scene);
  14609. /**
  14610. * Registers the component in a given scene
  14611. */
  14612. register(): void;
  14613. /**
  14614. * Rebuilds the elements related to this component in case of
  14615. * context lost for instance.
  14616. */
  14617. rebuild(): void;
  14618. /**
  14619. * Adds all the element from the container to the scene
  14620. * @param container the container holding the elements
  14621. */
  14622. addFromContainer(container: AbstractScene): void;
  14623. /**
  14624. * Removes all the elements in the container from the scene
  14625. * @param container contains the elements to remove
  14626. */
  14627. removeFromContainer(container: AbstractScene): void;
  14628. /**
  14629. * Serializes the component data to the specified json object
  14630. * @param serializationObject The object to serialize to
  14631. */
  14632. serialize(serializationObject: any): void;
  14633. /**
  14634. * Disposes the component and the associated ressources.
  14635. */
  14636. dispose(): void;
  14637. private _draw;
  14638. }
  14639. }
  14640. declare module BABYLON {
  14641. /**
  14642. * Effect layer options. This helps customizing the behaviour
  14643. * of the effect layer.
  14644. */
  14645. interface IEffectLayerOptions {
  14646. /**
  14647. * Multiplication factor apply to the canvas size to compute the render target size
  14648. * used to generated the objects (the smaller the faster).
  14649. */
  14650. mainTextureRatio: number;
  14651. /**
  14652. * Enforces a fixed size texture to ensure effect stability across devices.
  14653. */
  14654. mainTextureFixedSize?: number;
  14655. /**
  14656. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14657. */
  14658. alphaBlendingMode: number;
  14659. /**
  14660. * The camera attached to the layer.
  14661. */
  14662. camera: Nullable<Camera>;
  14663. /**
  14664. * The rendering group to draw the layer in.
  14665. */
  14666. renderingGroupId: number;
  14667. }
  14668. /**
  14669. * The effect layer Helps adding post process effect blended with the main pass.
  14670. *
  14671. * This can be for instance use to generate glow or higlight effects on the scene.
  14672. *
  14673. * The effect layer class can not be used directly and is intented to inherited from to be
  14674. * customized per effects.
  14675. */
  14676. abstract class EffectLayer {
  14677. private _vertexBuffers;
  14678. private _indexBuffer;
  14679. private _cachedDefines;
  14680. private _effectLayerMapGenerationEffect;
  14681. private _effectLayerOptions;
  14682. private _mergeEffect;
  14683. protected _scene: Scene;
  14684. protected _engine: Engine;
  14685. protected _maxSize: number;
  14686. protected _mainTextureDesiredSize: ISize;
  14687. protected _mainTexture: RenderTargetTexture;
  14688. protected _shouldRender: boolean;
  14689. protected _postProcesses: PostProcess[];
  14690. protected _textures: BaseTexture[];
  14691. protected _emissiveTextureAndColor: {
  14692. texture: Nullable<BaseTexture>;
  14693. color: Color4;
  14694. };
  14695. /**
  14696. * The name of the layer
  14697. */
  14698. name: string;
  14699. /**
  14700. * The clear color of the texture used to generate the glow map.
  14701. */
  14702. neutralColor: Color4;
  14703. /**
  14704. * Specifies wether the highlight layer is enabled or not.
  14705. */
  14706. isEnabled: boolean;
  14707. /**
  14708. * Gets the camera attached to the layer.
  14709. */
  14710. readonly camera: Nullable<Camera>;
  14711. /**
  14712. * Gets the rendering group id the layer should render in.
  14713. */
  14714. readonly renderingGroupId: number;
  14715. /**
  14716. * An event triggered when the effect layer has been disposed.
  14717. */
  14718. onDisposeObservable: Observable<EffectLayer>;
  14719. /**
  14720. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14721. */
  14722. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14723. /**
  14724. * An event triggered when the generated texture is being merged in the scene.
  14725. */
  14726. onBeforeComposeObservable: Observable<EffectLayer>;
  14727. /**
  14728. * An event triggered when the generated texture has been merged in the scene.
  14729. */
  14730. onAfterComposeObservable: Observable<EffectLayer>;
  14731. /**
  14732. * An event triggered when the efffect layer changes its size.
  14733. */
  14734. onSizeChangedObservable: Observable<EffectLayer>;
  14735. /**
  14736. * Instantiates a new effect Layer and references it in the scene.
  14737. * @param name The name of the layer
  14738. * @param scene The scene to use the layer in
  14739. */
  14740. constructor(
  14741. /** The Friendly of the effect in the scene */
  14742. name: string, scene: Scene);
  14743. /**
  14744. * Get the effect name of the layer.
  14745. * @return The effect name
  14746. */
  14747. abstract getEffectName(): string;
  14748. /**
  14749. * Checks for the readiness of the element composing the layer.
  14750. * @param subMesh the mesh to check for
  14751. * @param useInstances specify wether or not to use instances to render the mesh
  14752. * @return true if ready otherwise, false
  14753. */
  14754. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14755. /**
  14756. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14757. * @returns true if the effect requires stencil during the main canvas render pass.
  14758. */
  14759. abstract needStencil(): boolean;
  14760. /**
  14761. * Create the merge effect. This is the shader use to blit the information back
  14762. * to the main canvas at the end of the scene rendering.
  14763. * @returns The effect containing the shader used to merge the effect on the main canvas
  14764. */
  14765. protected abstract _createMergeEffect(): Effect;
  14766. /**
  14767. * Creates the render target textures and post processes used in the effect layer.
  14768. */
  14769. protected abstract _createTextureAndPostProcesses(): void;
  14770. /**
  14771. * Implementation specific of rendering the generating effect on the main canvas.
  14772. * @param effect The effect used to render through
  14773. */
  14774. protected abstract _internalRender(effect: Effect): void;
  14775. /**
  14776. * Sets the required values for both the emissive texture and and the main color.
  14777. */
  14778. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14779. /**
  14780. * Free any resources and references associated to a mesh.
  14781. * Internal use
  14782. * @param mesh The mesh to free.
  14783. */
  14784. abstract _disposeMesh(mesh: Mesh): void;
  14785. /**
  14786. * Serializes this layer (Glow or Highlight for example)
  14787. * @returns a serialized layer object
  14788. */
  14789. abstract serialize?(): any;
  14790. /**
  14791. * Initializes the effect layer with the required options.
  14792. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14793. */
  14794. protected _init(options: Partial<IEffectLayerOptions>): void;
  14795. /**
  14796. * Generates the index buffer of the full screen quad blending to the main canvas.
  14797. */
  14798. private _generateIndexBuffer;
  14799. /**
  14800. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14801. */
  14802. private _genrateVertexBuffer;
  14803. /**
  14804. * Sets the main texture desired size which is the closest power of two
  14805. * of the engine canvas size.
  14806. */
  14807. private _setMainTextureSize;
  14808. /**
  14809. * Creates the main texture for the effect layer.
  14810. */
  14811. protected _createMainTexture(): void;
  14812. /**
  14813. * Checks for the readiness of the element composing the layer.
  14814. * @param subMesh the mesh to check for
  14815. * @param useInstances specify wether or not to use instances to render the mesh
  14816. * @param emissiveTexture the associated emissive texture used to generate the glow
  14817. * @return true if ready otherwise, false
  14818. */
  14819. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14820. /**
  14821. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14822. */
  14823. render(): void;
  14824. /**
  14825. * Determine if a given mesh will be used in the current effect.
  14826. * @param mesh mesh to test
  14827. * @returns true if the mesh will be used
  14828. */
  14829. hasMesh(mesh: AbstractMesh): boolean;
  14830. /**
  14831. * Returns true if the layer contains information to display, otherwise false.
  14832. * @returns true if the glow layer should be rendered
  14833. */
  14834. shouldRender(): boolean;
  14835. /**
  14836. * Returns true if the mesh should render, otherwise false.
  14837. * @param mesh The mesh to render
  14838. * @returns true if it should render otherwise false
  14839. */
  14840. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14841. /**
  14842. * Returns true if the mesh should render, otherwise false.
  14843. * @param mesh The mesh to render
  14844. * @returns true if it should render otherwise false
  14845. */
  14846. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14847. /**
  14848. * Renders the submesh passed in parameter to the generation map.
  14849. */
  14850. protected _renderSubMesh(subMesh: SubMesh): void;
  14851. /**
  14852. * Rebuild the required buffers.
  14853. * @hidden Internal use only.
  14854. */
  14855. _rebuild(): void;
  14856. /**
  14857. * Dispose only the render target textures and post process.
  14858. */
  14859. private _disposeTextureAndPostProcesses;
  14860. /**
  14861. * Dispose the highlight layer and free resources.
  14862. */
  14863. dispose(): void;
  14864. /**
  14865. * Gets the class name of the effect layer
  14866. * @returns the string with the class name of the effect layer
  14867. */
  14868. getClassName(): string;
  14869. /**
  14870. * Creates an effect layer from parsed effect layer data
  14871. * @param parsedEffectLayer defines effect layer data
  14872. * @param scene defines the current scene
  14873. * @param rootUrl defines the root URL containing the effect layer information
  14874. * @returns a parsed effect Layer
  14875. */
  14876. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14877. }
  14878. }
  14879. declare module BABYLON {
  14880. interface AbstractScene {
  14881. /**
  14882. * The list of effect layers (highlights/glow) added to the scene
  14883. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14884. * @see http://doc.babylonjs.com/how_to/glow_layer
  14885. */
  14886. effectLayers: Array<EffectLayer>;
  14887. /**
  14888. * Removes the given effect layer from this scene.
  14889. * @param toRemove defines the effect layer to remove
  14890. * @returns the index of the removed effect layer
  14891. */
  14892. removeEffectLayer(toRemove: EffectLayer): number;
  14893. /**
  14894. * Adds the given effect layer to this scene
  14895. * @param newEffectLayer defines the effect layer to add
  14896. */
  14897. addEffectLayer(newEffectLayer: EffectLayer): void;
  14898. }
  14899. /**
  14900. * Defines the layer scene component responsible to manage any effect layers
  14901. * in a given scene.
  14902. */
  14903. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14904. /**
  14905. * The component name helpfull to identify the component in the list of scene components.
  14906. */
  14907. readonly name: string;
  14908. /**
  14909. * The scene the component belongs to.
  14910. */
  14911. scene: Scene;
  14912. private _engine;
  14913. private _renderEffects;
  14914. private _needStencil;
  14915. private _previousStencilState;
  14916. /**
  14917. * Creates a new instance of the component for the given scene
  14918. * @param scene Defines the scene to register the component in
  14919. */
  14920. constructor(scene: Scene);
  14921. /**
  14922. * Registers the component in a given scene
  14923. */
  14924. register(): void;
  14925. /**
  14926. * Rebuilds the elements related to this component in case of
  14927. * context lost for instance.
  14928. */
  14929. rebuild(): void;
  14930. /**
  14931. * Serializes the component data to the specified json object
  14932. * @param serializationObject The object to serialize to
  14933. */
  14934. serialize(serializationObject: any): void;
  14935. /**
  14936. * Adds all the element from the container to the scene
  14937. * @param container the container holding the elements
  14938. */
  14939. addFromContainer(container: AbstractScene): void;
  14940. /**
  14941. * Removes all the elements in the container from the scene
  14942. * @param container contains the elements to remove
  14943. */
  14944. removeFromContainer(container: AbstractScene): void;
  14945. /**
  14946. * Disposes the component and the associated ressources.
  14947. */
  14948. dispose(): void;
  14949. private _isReadyForMesh;
  14950. private _renderMainTexture;
  14951. private _setStencil;
  14952. private _setStencilBack;
  14953. private _draw;
  14954. private _drawCamera;
  14955. private _drawRenderingGroup;
  14956. }
  14957. }
  14958. declare module BABYLON {
  14959. interface AbstractScene {
  14960. /**
  14961. * Return a the first highlight layer of the scene with a given name.
  14962. * @param name The name of the highlight layer to look for.
  14963. * @return The highlight layer if found otherwise null.
  14964. */
  14965. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14966. }
  14967. /**
  14968. * Glow layer options. This helps customizing the behaviour
  14969. * of the glow layer.
  14970. */
  14971. interface IGlowLayerOptions {
  14972. /**
  14973. * Multiplication factor apply to the canvas size to compute the render target size
  14974. * used to generated the glowing objects (the smaller the faster).
  14975. */
  14976. mainTextureRatio: number;
  14977. /**
  14978. * Enforces a fixed size texture to ensure resize independant blur.
  14979. */
  14980. mainTextureFixedSize?: number;
  14981. /**
  14982. * How big is the kernel of the blur texture.
  14983. */
  14984. blurKernelSize: number;
  14985. /**
  14986. * The camera attached to the layer.
  14987. */
  14988. camera: Nullable<Camera>;
  14989. /**
  14990. * Enable MSAA by chosing the number of samples.
  14991. */
  14992. mainTextureSamples?: number;
  14993. /**
  14994. * The rendering group to draw the layer in.
  14995. */
  14996. renderingGroupId: number;
  14997. }
  14998. /**
  14999. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  15000. *
  15001. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  15002. * glowy meshes to your scene.
  15003. *
  15004. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  15005. */
  15006. class GlowLayer extends EffectLayer {
  15007. /**
  15008. * Effect Name of the layer.
  15009. */
  15010. static readonly EffectName: string;
  15011. /**
  15012. * The default blur kernel size used for the glow.
  15013. */
  15014. static DefaultBlurKernelSize: number;
  15015. /**
  15016. * The default texture size ratio used for the glow.
  15017. */
  15018. static DefaultTextureRatio: number;
  15019. /**
  15020. * Sets the kernel size of the blur.
  15021. */
  15022. /**
  15023. * Gets the kernel size of the blur.
  15024. */
  15025. blurKernelSize: number;
  15026. /**
  15027. * Sets the glow intensity.
  15028. */
  15029. /**
  15030. * Gets the glow intensity.
  15031. */
  15032. intensity: number;
  15033. private _options;
  15034. private _intensity;
  15035. private _horizontalBlurPostprocess1;
  15036. private _verticalBlurPostprocess1;
  15037. private _horizontalBlurPostprocess2;
  15038. private _verticalBlurPostprocess2;
  15039. private _blurTexture1;
  15040. private _blurTexture2;
  15041. private _postProcesses1;
  15042. private _postProcesses2;
  15043. private _includedOnlyMeshes;
  15044. private _excludedMeshes;
  15045. /**
  15046. * Callback used to let the user override the color selection on a per mesh basis
  15047. */
  15048. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  15049. /**
  15050. * Callback used to let the user override the texture selection on a per mesh basis
  15051. */
  15052. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  15053. /**
  15054. * Instantiates a new glow Layer and references it to the scene.
  15055. * @param name The name of the layer
  15056. * @param scene The scene to use the layer in
  15057. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  15058. */
  15059. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  15060. /**
  15061. * Get the effect name of the layer.
  15062. * @return The effect name
  15063. */
  15064. getEffectName(): string;
  15065. /**
  15066. * Create the merge effect. This is the shader use to blit the information back
  15067. * to the main canvas at the end of the scene rendering.
  15068. */
  15069. protected _createMergeEffect(): Effect;
  15070. /**
  15071. * Creates the render target textures and post processes used in the glow layer.
  15072. */
  15073. protected _createTextureAndPostProcesses(): void;
  15074. /**
  15075. * Checks for the readiness of the element composing the layer.
  15076. * @param subMesh the mesh to check for
  15077. * @param useInstances specify wether or not to use instances to render the mesh
  15078. * @param emissiveTexture the associated emissive texture used to generate the glow
  15079. * @return true if ready otherwise, false
  15080. */
  15081. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15082. /**
  15083. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15084. */
  15085. needStencil(): boolean;
  15086. /**
  15087. * Implementation specific of rendering the generating effect on the main canvas.
  15088. * @param effect The effect used to render through
  15089. */
  15090. protected _internalRender(effect: Effect): void;
  15091. /**
  15092. * Sets the required values for both the emissive texture and and the main color.
  15093. */
  15094. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15095. /**
  15096. * Returns true if the mesh should render, otherwise false.
  15097. * @param mesh The mesh to render
  15098. * @returns true if it should render otherwise false
  15099. */
  15100. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15101. /**
  15102. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  15103. * @param mesh The mesh to exclude from the glow layer
  15104. */
  15105. addExcludedMesh(mesh: Mesh): void;
  15106. /**
  15107. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  15108. * @param mesh The mesh to remove
  15109. */
  15110. removeExcludedMesh(mesh: Mesh): void;
  15111. /**
  15112. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  15113. * @param mesh The mesh to include in the glow layer
  15114. */
  15115. addIncludedOnlyMesh(mesh: Mesh): void;
  15116. /**
  15117. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  15118. * @param mesh The mesh to remove
  15119. */
  15120. removeIncludedOnlyMesh(mesh: Mesh): void;
  15121. /**
  15122. * Determine if a given mesh will be used in the glow layer
  15123. * @param mesh The mesh to test
  15124. * @returns true if the mesh will be highlighted by the current glow layer
  15125. */
  15126. hasMesh(mesh: AbstractMesh): boolean;
  15127. /**
  15128. * Free any resources and references associated to a mesh.
  15129. * Internal use
  15130. * @param mesh The mesh to free.
  15131. * @hidden
  15132. */
  15133. _disposeMesh(mesh: Mesh): void;
  15134. /**
  15135. * Gets the class name of the effect layer
  15136. * @returns the string with the class name of the effect layer
  15137. */
  15138. getClassName(): string;
  15139. /**
  15140. * Serializes this glow layer
  15141. * @returns a serialized glow layer object
  15142. */
  15143. serialize(): any;
  15144. /**
  15145. * Creates a Glow Layer from parsed glow layer data
  15146. * @param parsedGlowLayer defines glow layer data
  15147. * @param scene defines the current scene
  15148. * @param rootUrl defines the root URL containing the glow layer information
  15149. * @returns a parsed Glow Layer
  15150. */
  15151. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  15152. }
  15153. }
  15154. declare module BABYLON {
  15155. interface AbstractScene {
  15156. /**
  15157. * Return a the first highlight layer of the scene with a given name.
  15158. * @param name The name of the highlight layer to look for.
  15159. * @return The highlight layer if found otherwise null.
  15160. */
  15161. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  15162. }
  15163. /**
  15164. * Highlight layer options. This helps customizing the behaviour
  15165. * of the highlight layer.
  15166. */
  15167. interface IHighlightLayerOptions {
  15168. /**
  15169. * Multiplication factor apply to the canvas size to compute the render target size
  15170. * used to generated the glowing objects (the smaller the faster).
  15171. */
  15172. mainTextureRatio: number;
  15173. /**
  15174. * Enforces a fixed size texture to ensure resize independant blur.
  15175. */
  15176. mainTextureFixedSize?: number;
  15177. /**
  15178. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  15179. * of the picture to blur (the smaller the faster).
  15180. */
  15181. blurTextureSizeRatio: number;
  15182. /**
  15183. * How big in texel of the blur texture is the vertical blur.
  15184. */
  15185. blurVerticalSize: number;
  15186. /**
  15187. * How big in texel of the blur texture is the horizontal blur.
  15188. */
  15189. blurHorizontalSize: number;
  15190. /**
  15191. * Alpha blending mode used to apply the blur. Default is combine.
  15192. */
  15193. alphaBlendingMode: number;
  15194. /**
  15195. * The camera attached to the layer.
  15196. */
  15197. camera: Nullable<Camera>;
  15198. /**
  15199. * Should we display highlight as a solid stroke?
  15200. */
  15201. isStroke?: boolean;
  15202. /**
  15203. * The rendering group to draw the layer in.
  15204. */
  15205. renderingGroupId: number;
  15206. }
  15207. /**
  15208. * The highlight layer Helps adding a glow effect around a mesh.
  15209. *
  15210. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  15211. * glowy meshes to your scene.
  15212. *
  15213. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  15214. */
  15215. class HighlightLayer extends EffectLayer {
  15216. name: string;
  15217. /**
  15218. * Effect Name of the highlight layer.
  15219. */
  15220. static readonly EffectName: string;
  15221. /**
  15222. * The neutral color used during the preparation of the glow effect.
  15223. * This is black by default as the blend operation is a blend operation.
  15224. */
  15225. static NeutralColor: Color4;
  15226. /**
  15227. * Stencil value used for glowing meshes.
  15228. */
  15229. static GlowingMeshStencilReference: number;
  15230. /**
  15231. * Stencil value used for the other meshes in the scene.
  15232. */
  15233. static NormalMeshStencilReference: number;
  15234. /**
  15235. * Specifies whether or not the inner glow is ACTIVE in the layer.
  15236. */
  15237. innerGlow: boolean;
  15238. /**
  15239. * Specifies whether or not the outer glow is ACTIVE in the layer.
  15240. */
  15241. outerGlow: boolean;
  15242. /**
  15243. * Specifies the horizontal size of the blur.
  15244. */
  15245. /**
  15246. * Gets the horizontal size of the blur.
  15247. */
  15248. blurHorizontalSize: number;
  15249. /**
  15250. * Specifies the vertical size of the blur.
  15251. */
  15252. /**
  15253. * Gets the vertical size of the blur.
  15254. */
  15255. blurVerticalSize: number;
  15256. /**
  15257. * An event triggered when the highlight layer is being blurred.
  15258. */
  15259. onBeforeBlurObservable: Observable<HighlightLayer>;
  15260. /**
  15261. * An event triggered when the highlight layer has been blurred.
  15262. */
  15263. onAfterBlurObservable: Observable<HighlightLayer>;
  15264. private _instanceGlowingMeshStencilReference;
  15265. private _options;
  15266. private _downSamplePostprocess;
  15267. private _horizontalBlurPostprocess;
  15268. private _verticalBlurPostprocess;
  15269. private _blurTexture;
  15270. private _meshes;
  15271. private _excludedMeshes;
  15272. /**
  15273. * Instantiates a new highlight Layer and references it to the scene..
  15274. * @param name The name of the layer
  15275. * @param scene The scene to use the layer in
  15276. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15277. */
  15278. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15279. /**
  15280. * Get the effect name of the layer.
  15281. * @return The effect name
  15282. */
  15283. getEffectName(): string;
  15284. /**
  15285. * Create the merge effect. This is the shader use to blit the information back
  15286. * to the main canvas at the end of the scene rendering.
  15287. */
  15288. protected _createMergeEffect(): Effect;
  15289. /**
  15290. * Creates the render target textures and post processes used in the highlight layer.
  15291. */
  15292. protected _createTextureAndPostProcesses(): void;
  15293. /**
  15294. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15295. */
  15296. needStencil(): boolean;
  15297. /**
  15298. * Checks for the readiness of the element composing the layer.
  15299. * @param subMesh the mesh to check for
  15300. * @param useInstances specify wether or not to use instances to render the mesh
  15301. * @param emissiveTexture the associated emissive texture used to generate the glow
  15302. * @return true if ready otherwise, false
  15303. */
  15304. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15305. /**
  15306. * Implementation specific of rendering the generating effect on the main canvas.
  15307. * @param effect The effect used to render through
  15308. */
  15309. protected _internalRender(effect: Effect): void;
  15310. /**
  15311. * Returns true if the layer contains information to display, otherwise false.
  15312. */
  15313. shouldRender(): boolean;
  15314. /**
  15315. * Returns true if the mesh should render, otherwise false.
  15316. * @param mesh The mesh to render
  15317. * @returns true if it should render otherwise false
  15318. */
  15319. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15320. /**
  15321. * Sets the required values for both the emissive texture and and the main color.
  15322. */
  15323. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15324. /**
  15325. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15326. * @param mesh The mesh to exclude from the highlight layer
  15327. */
  15328. addExcludedMesh(mesh: Mesh): void;
  15329. /**
  15330. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15331. * @param mesh The mesh to highlight
  15332. */
  15333. removeExcludedMesh(mesh: Mesh): void;
  15334. /**
  15335. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15336. * @param mesh mesh to test
  15337. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15338. */
  15339. hasMesh(mesh: AbstractMesh): boolean;
  15340. /**
  15341. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15342. * @param mesh The mesh to highlight
  15343. * @param color The color of the highlight
  15344. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15345. */
  15346. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15347. /**
  15348. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15349. * @param mesh The mesh to highlight
  15350. */
  15351. removeMesh(mesh: Mesh): void;
  15352. /**
  15353. * Force the stencil to the normal expected value for none glowing parts
  15354. */
  15355. private _defaultStencilReference;
  15356. /**
  15357. * Free any resources and references associated to a mesh.
  15358. * Internal use
  15359. * @param mesh The mesh to free.
  15360. * @hidden
  15361. */
  15362. _disposeMesh(mesh: Mesh): void;
  15363. /**
  15364. * Dispose the highlight layer and free resources.
  15365. */
  15366. dispose(): void;
  15367. /**
  15368. * Gets the class name of the effect layer
  15369. * @returns the string with the class name of the effect layer
  15370. */
  15371. getClassName(): string;
  15372. /**
  15373. * Serializes this Highlight layer
  15374. * @returns a serialized Highlight layer object
  15375. */
  15376. serialize(): any;
  15377. /**
  15378. * Creates a Highlight layer from parsed Highlight layer data
  15379. * @param parsedHightlightLayer defines the Highlight layer data
  15380. * @param scene defines the current scene
  15381. * @param rootUrl defines the root URL containing the Highlight layer information
  15382. * @returns a parsed Highlight layer
  15383. */
  15384. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15385. }
  15386. }
  15387. declare module BABYLON {
  15388. /**
  15389. * This represents a full screen 2d layer.
  15390. * This can be useful to display a picture in the background of your scene for instance.
  15391. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15392. */
  15393. class Layer {
  15394. /**
  15395. * Define the name of the layer.
  15396. */
  15397. name: string;
  15398. /**
  15399. * Define the texture the layer should display.
  15400. */
  15401. texture: Nullable<Texture>;
  15402. /**
  15403. * Is the layer in background or foreground.
  15404. */
  15405. isBackground: boolean;
  15406. /**
  15407. * Define the color of the layer (instead of texture).
  15408. */
  15409. color: Color4;
  15410. /**
  15411. * Define the scale of the layer in order to zoom in out of the texture.
  15412. */
  15413. scale: Vector2;
  15414. /**
  15415. * Define an offset for the layer in order to shift the texture.
  15416. */
  15417. offset: Vector2;
  15418. /**
  15419. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15420. */
  15421. alphaBlendingMode: number;
  15422. /**
  15423. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15424. * Alpha test will not mix with the background color in case of transparency.
  15425. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15426. */
  15427. alphaTest: boolean;
  15428. /**
  15429. * Define a mask to restrict the layer to only some of the scene cameras.
  15430. */
  15431. layerMask: number;
  15432. /**
  15433. * Define the list of render target the layer is visible into.
  15434. */
  15435. renderTargetTextures: RenderTargetTexture[];
  15436. /**
  15437. * Define if the layer is only used in renderTarget or if it also
  15438. * renders in the main frame buffer of the canvas.
  15439. */
  15440. renderOnlyInRenderTargetTextures: boolean;
  15441. private _scene;
  15442. private _vertexBuffers;
  15443. private _indexBuffer;
  15444. private _effect;
  15445. private _alphaTestEffect;
  15446. /**
  15447. * An event triggered when the layer is disposed.
  15448. */
  15449. onDisposeObservable: Observable<Layer>;
  15450. private _onDisposeObserver;
  15451. /**
  15452. * Back compatibility with callback before the onDisposeObservable existed.
  15453. * The set callback will be triggered when the layer has been disposed.
  15454. */
  15455. onDispose: () => void;
  15456. /**
  15457. * An event triggered before rendering the scene
  15458. */
  15459. onBeforeRenderObservable: Observable<Layer>;
  15460. private _onBeforeRenderObserver;
  15461. /**
  15462. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15463. * The set callback will be triggered just before rendering the layer.
  15464. */
  15465. onBeforeRender: () => void;
  15466. /**
  15467. * An event triggered after rendering the scene
  15468. */
  15469. onAfterRenderObservable: Observable<Layer>;
  15470. private _onAfterRenderObserver;
  15471. /**
  15472. * Back compatibility with callback before the onAfterRenderObservable existed.
  15473. * The set callback will be triggered just after rendering the layer.
  15474. */
  15475. onAfterRender: () => void;
  15476. /**
  15477. * Instantiates a new layer.
  15478. * This represents a full screen 2d layer.
  15479. * This can be useful to display a picture in the background of your scene for instance.
  15480. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15481. * @param name Define the name of the layer in the scene
  15482. * @param imgUrl Define the url of the texture to display in the layer
  15483. * @param scene Define the scene the layer belongs to
  15484. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15485. * @param color Defines a color for the layer
  15486. */
  15487. constructor(
  15488. /**
  15489. * Define the name of the layer.
  15490. */
  15491. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15492. private _createIndexBuffer;
  15493. /** @hidden */
  15494. _rebuild(): void;
  15495. /**
  15496. * Renders the layer in the scene.
  15497. */
  15498. render(): void;
  15499. /**
  15500. * Disposes and releases the associated ressources.
  15501. */
  15502. dispose(): void;
  15503. }
  15504. }
  15505. declare module BABYLON {
  15506. interface AbstractScene {
  15507. /**
  15508. * The list of layers (background and foreground) of the scene
  15509. */
  15510. layers: Array<Layer>;
  15511. }
  15512. /**
  15513. * Defines the layer scene component responsible to manage any layers
  15514. * in a given scene.
  15515. */
  15516. class LayerSceneComponent implements ISceneComponent {
  15517. /**
  15518. * The component name helpfull to identify the component in the list of scene components.
  15519. */
  15520. readonly name: string;
  15521. /**
  15522. * The scene the component belongs to.
  15523. */
  15524. scene: Scene;
  15525. private _engine;
  15526. /**
  15527. * Creates a new instance of the component for the given scene
  15528. * @param scene Defines the scene to register the component in
  15529. */
  15530. constructor(scene: Scene);
  15531. /**
  15532. * Registers the component in a given scene
  15533. */
  15534. register(): void;
  15535. /**
  15536. * Rebuilds the elements related to this component in case of
  15537. * context lost for instance.
  15538. */
  15539. rebuild(): void;
  15540. /**
  15541. * Disposes the component and the associated ressources.
  15542. */
  15543. dispose(): void;
  15544. private _draw;
  15545. private _drawCameraPredicate;
  15546. private _drawCameraBackground;
  15547. private _drawCameraForeground;
  15548. private _drawRenderTargetPredicate;
  15549. private _drawRenderTargetBackground;
  15550. private _drawRenderTargetForeground;
  15551. }
  15552. }
  15553. declare module BABYLON {
  15554. /**
  15555. * A directional light is defined by a direction (what a surprise!).
  15556. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15557. * 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.
  15558. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15559. */
  15560. class DirectionalLight extends ShadowLight {
  15561. private _shadowFrustumSize;
  15562. /**
  15563. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15564. */
  15565. /**
  15566. * Specifies a fix frustum size for the shadow generation.
  15567. */
  15568. shadowFrustumSize: number;
  15569. private _shadowOrthoScale;
  15570. /**
  15571. * Gets the shadow projection scale against the optimal computed one.
  15572. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15573. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15574. */
  15575. /**
  15576. * Sets the shadow projection scale against the optimal computed one.
  15577. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15578. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15579. */
  15580. shadowOrthoScale: number;
  15581. /**
  15582. * Automatically compute the projection matrix to best fit (including all the casters)
  15583. * on each frame.
  15584. */
  15585. autoUpdateExtends: boolean;
  15586. private _orthoLeft;
  15587. private _orthoRight;
  15588. private _orthoTop;
  15589. private _orthoBottom;
  15590. /**
  15591. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15592. * The directional light is emitted from everywhere in the given direction.
  15593. * It can cast shadows.
  15594. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15595. * @param name The friendly name of the light
  15596. * @param direction The direction of the light
  15597. * @param scene The scene the light belongs to
  15598. */
  15599. constructor(name: string, direction: Vector3, scene: Scene);
  15600. /**
  15601. * Returns the string "DirectionalLight".
  15602. * @return The class name
  15603. */
  15604. getClassName(): string;
  15605. /**
  15606. * Returns the integer 1.
  15607. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15608. */
  15609. getTypeID(): number;
  15610. /**
  15611. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15612. * Returns the DirectionalLight Shadow projection matrix.
  15613. */
  15614. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15615. /**
  15616. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15617. * Returns the DirectionalLight Shadow projection matrix.
  15618. */
  15619. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15620. /**
  15621. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15622. * Returns the DirectionalLight Shadow projection matrix.
  15623. */
  15624. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15625. protected _buildUniformLayout(): void;
  15626. /**
  15627. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15628. * @param effect The effect to update
  15629. * @param lightIndex The index of the light in the effect to update
  15630. * @returns The directional light
  15631. */
  15632. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15633. /**
  15634. * Gets the minZ used for shadow according to both the scene and the light.
  15635. *
  15636. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15637. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15638. * @param activeCamera The camera we are returning the min for
  15639. * @returns the depth min z
  15640. */
  15641. getDepthMinZ(activeCamera: Camera): number;
  15642. /**
  15643. * Gets the maxZ used for shadow according to both the scene and the light.
  15644. *
  15645. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15646. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15647. * @param activeCamera The camera we are returning the max for
  15648. * @returns the depth max z
  15649. */
  15650. getDepthMaxZ(activeCamera: Camera): number;
  15651. /**
  15652. * Prepares the list of defines specific to the light type.
  15653. * @param defines the list of defines
  15654. * @param lightIndex defines the index of the light for the effect
  15655. */
  15656. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15657. }
  15658. }
  15659. declare module BABYLON {
  15660. /**
  15661. * The HemisphericLight simulates the ambient environment light,
  15662. * so the passed direction is the light reflection direction, not the incoming direction.
  15663. */
  15664. class HemisphericLight extends Light {
  15665. /**
  15666. * The groundColor is the light in the opposite direction to the one specified during creation.
  15667. * 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.
  15668. */
  15669. groundColor: Color3;
  15670. /**
  15671. * The light reflection direction, not the incoming direction.
  15672. */
  15673. direction: Vector3;
  15674. /**
  15675. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15676. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15677. * The HemisphericLight can't cast shadows.
  15678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15679. * @param name The friendly name of the light
  15680. * @param direction The direction of the light reflection
  15681. * @param scene The scene the light belongs to
  15682. */
  15683. constructor(name: string, direction: Vector3, scene: Scene);
  15684. protected _buildUniformLayout(): void;
  15685. /**
  15686. * Returns the string "HemisphericLight".
  15687. * @return The class name
  15688. */
  15689. getClassName(): string;
  15690. /**
  15691. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15692. * Returns the updated direction.
  15693. * @param target The target the direction should point to
  15694. * @return The computed direction
  15695. */
  15696. setDirectionToTarget(target: Vector3): Vector3;
  15697. /**
  15698. * Returns the shadow generator associated to the light.
  15699. * @returns Always null for hemispheric lights because it does not support shadows.
  15700. */
  15701. getShadowGenerator(): Nullable<IShadowGenerator>;
  15702. /**
  15703. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15704. * @param effect The effect to update
  15705. * @param lightIndex The index of the light in the effect to update
  15706. * @returns The hemispheric light
  15707. */
  15708. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15709. /**
  15710. * Computes the world matrix of the node
  15711. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15712. * @param useWasUpdatedFlag defines a reserved property
  15713. * @returns the world matrix
  15714. */
  15715. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15716. /**
  15717. * Returns the integer 3.
  15718. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15719. */
  15720. getTypeID(): number;
  15721. /**
  15722. * Prepares the list of defines specific to the light type.
  15723. * @param defines the list of defines
  15724. * @param lightIndex defines the index of the light for the effect
  15725. */
  15726. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15727. }
  15728. }
  15729. declare module BABYLON {
  15730. /**
  15731. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15732. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15733. * 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.
  15734. */
  15735. abstract class Light extends Node {
  15736. /**
  15737. * Falloff Default: light is falling off following the material specification:
  15738. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15739. */
  15740. static readonly FALLOFF_DEFAULT: number;
  15741. /**
  15742. * Falloff Physical: light is falling off following the inverse squared distance law.
  15743. */
  15744. static readonly FALLOFF_PHYSICAL: number;
  15745. /**
  15746. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15747. * to enhance interoperability with other engines.
  15748. */
  15749. static readonly FALLOFF_GLTF: number;
  15750. /**
  15751. * Falloff Standard: light is falling off like in the standard material
  15752. * to enhance interoperability with other materials.
  15753. */
  15754. static readonly FALLOFF_STANDARD: number;
  15755. /**
  15756. * If every light affecting the material is in this lightmapMode,
  15757. * material.lightmapTexture adds or multiplies
  15758. * (depends on material.useLightmapAsShadowmap)
  15759. * after every other light calculations.
  15760. */
  15761. static readonly LIGHTMAP_DEFAULT: number;
  15762. /**
  15763. * material.lightmapTexture as only diffuse lighting from this light
  15764. * adds only specular lighting from this light
  15765. * adds dynamic shadows
  15766. */
  15767. static readonly LIGHTMAP_SPECULAR: number;
  15768. /**
  15769. * material.lightmapTexture as only lighting
  15770. * no light calculation from this light
  15771. * only adds dynamic shadows from this light
  15772. */
  15773. static readonly LIGHTMAP_SHADOWSONLY: number;
  15774. /**
  15775. * Each light type uses the default quantity according to its type:
  15776. * point/spot lights use luminous intensity
  15777. * directional lights use illuminance
  15778. */
  15779. static readonly INTENSITYMODE_AUTOMATIC: number;
  15780. /**
  15781. * lumen (lm)
  15782. */
  15783. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15784. /**
  15785. * candela (lm/sr)
  15786. */
  15787. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15788. /**
  15789. * lux (lm/m^2)
  15790. */
  15791. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15792. /**
  15793. * nit (cd/m^2)
  15794. */
  15795. static readonly INTENSITYMODE_LUMINANCE: number;
  15796. /**
  15797. * Light type const id of the point light.
  15798. */
  15799. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15800. /**
  15801. * Light type const id of the directional light.
  15802. */
  15803. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15804. /**
  15805. * Light type const id of the spot light.
  15806. */
  15807. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15808. /**
  15809. * Light type const id of the hemispheric light.
  15810. */
  15811. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15812. /**
  15813. * Diffuse gives the basic color to an object.
  15814. */
  15815. diffuse: Color3;
  15816. /**
  15817. * Specular produces a highlight color on an object.
  15818. * Note: This is note affecting PBR materials.
  15819. */
  15820. specular: Color3;
  15821. /**
  15822. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15823. * falling off base on range or angle.
  15824. * This can be set to any values in Light.FALLOFF_x.
  15825. *
  15826. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15827. * other types of materials.
  15828. */
  15829. falloffType: number;
  15830. /**
  15831. * Strength of the light.
  15832. * Note: By default it is define in the framework own unit.
  15833. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15834. */
  15835. intensity: number;
  15836. private _range;
  15837. protected _inverseSquaredRange: number;
  15838. /**
  15839. * Defines how far from the source the light is impacting in scene units.
  15840. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15841. */
  15842. /**
  15843. * Defines how far from the source the light is impacting in scene units.
  15844. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15845. */
  15846. range: number;
  15847. /**
  15848. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15849. * of light.
  15850. */
  15851. private _photometricScale;
  15852. private _intensityMode;
  15853. /**
  15854. * Gets the photometric scale used to interpret the intensity.
  15855. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15856. */
  15857. /**
  15858. * Sets the photometric scale used to interpret the intensity.
  15859. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15860. */
  15861. intensityMode: number;
  15862. private _radius;
  15863. /**
  15864. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15865. */
  15866. /**
  15867. * sets the light radius used by PBR Materials to simulate soft area lights.
  15868. */
  15869. radius: number;
  15870. private _renderPriority;
  15871. /**
  15872. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15873. * exceeding the number allowed of the materials.
  15874. */
  15875. renderPriority: number;
  15876. private _shadowEnabled;
  15877. /**
  15878. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15879. * the current shadow generator.
  15880. */
  15881. /**
  15882. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15883. * the current shadow generator.
  15884. */
  15885. shadowEnabled: boolean;
  15886. private _includedOnlyMeshes;
  15887. /**
  15888. * Gets the only meshes impacted by this light.
  15889. */
  15890. /**
  15891. * Sets the only meshes impacted by this light.
  15892. */
  15893. includedOnlyMeshes: AbstractMesh[];
  15894. private _excludedMeshes;
  15895. /**
  15896. * Gets the meshes not impacted by this light.
  15897. */
  15898. /**
  15899. * Sets the meshes not impacted by this light.
  15900. */
  15901. excludedMeshes: AbstractMesh[];
  15902. private _excludeWithLayerMask;
  15903. /**
  15904. * Gets the layer id use to find what meshes are not impacted by the light.
  15905. * Inactive if 0
  15906. */
  15907. /**
  15908. * Sets the layer id use to find what meshes are not impacted by the light.
  15909. * Inactive if 0
  15910. */
  15911. excludeWithLayerMask: number;
  15912. private _includeOnlyWithLayerMask;
  15913. /**
  15914. * Gets the layer id use to find what meshes are impacted by the light.
  15915. * Inactive if 0
  15916. */
  15917. /**
  15918. * Sets the layer id use to find what meshes are impacted by the light.
  15919. * Inactive if 0
  15920. */
  15921. includeOnlyWithLayerMask: number;
  15922. private _lightmapMode;
  15923. /**
  15924. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15925. */
  15926. /**
  15927. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15928. */
  15929. lightmapMode: number;
  15930. /**
  15931. * Shadow generator associted to the light.
  15932. * @hidden Internal use only.
  15933. */
  15934. _shadowGenerator: Nullable<IShadowGenerator>;
  15935. /**
  15936. * @hidden Internal use only.
  15937. */
  15938. _excludedMeshesIds: string[];
  15939. /**
  15940. * @hidden Internal use only.
  15941. */
  15942. _includedOnlyMeshesIds: string[];
  15943. /**
  15944. * The current light unifom buffer.
  15945. * @hidden Internal use only.
  15946. */
  15947. _uniformBuffer: UniformBuffer;
  15948. /**
  15949. * Creates a Light object in the scene.
  15950. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15951. * @param name The firendly name of the light
  15952. * @param scene The scene the light belongs too
  15953. */
  15954. constructor(name: string, scene: Scene);
  15955. protected abstract _buildUniformLayout(): void;
  15956. /**
  15957. * Sets the passed Effect "effect" with the Light information.
  15958. * @param effect The effect to update
  15959. * @param lightIndex The index of the light in the effect to update
  15960. * @returns The light
  15961. */
  15962. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15963. /**
  15964. * Returns the string "Light".
  15965. * @returns the class name
  15966. */
  15967. getClassName(): string;
  15968. /**
  15969. * Converts the light information to a readable string for debug purpose.
  15970. * @param fullDetails Supports for multiple levels of logging within scene loading
  15971. * @returns the human readable light info
  15972. */
  15973. toString(fullDetails?: boolean): string;
  15974. /** @hidden */
  15975. protected _syncParentEnabledState(): void;
  15976. /**
  15977. * Set the enabled state of this node.
  15978. * @param value - the new enabled state
  15979. */
  15980. setEnabled(value: boolean): void;
  15981. /**
  15982. * Returns the Light associated shadow generator if any.
  15983. * @return the associated shadow generator.
  15984. */
  15985. getShadowGenerator(): Nullable<IShadowGenerator>;
  15986. /**
  15987. * Returns a Vector3, the absolute light position in the World.
  15988. * @returns the world space position of the light
  15989. */
  15990. getAbsolutePosition(): Vector3;
  15991. /**
  15992. * Specifies if the light will affect the passed mesh.
  15993. * @param mesh The mesh to test against the light
  15994. * @return true the mesh is affected otherwise, false.
  15995. */
  15996. canAffectMesh(mesh: AbstractMesh): boolean;
  15997. /**
  15998. * Sort function to order lights for rendering.
  15999. * @param a First Light object to compare to second.
  16000. * @param b Second Light object to compare first.
  16001. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16002. */
  16003. static CompareLightsPriority(a: Light, b: Light): number;
  16004. /**
  16005. * Releases resources associated with this node.
  16006. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16007. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16008. */
  16009. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16010. /**
  16011. * Returns the light type ID (integer).
  16012. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16013. */
  16014. getTypeID(): number;
  16015. /**
  16016. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16017. * @returns the scaled intensity in intensity mode unit
  16018. */
  16019. getScaledIntensity(): number;
  16020. /**
  16021. * Returns a new Light object, named "name", from the current one.
  16022. * @param name The name of the cloned light
  16023. * @returns the new created light
  16024. */
  16025. clone(name: string): Nullable<Light>;
  16026. /**
  16027. * Serializes the current light into a Serialization object.
  16028. * @returns the serialized object.
  16029. */
  16030. serialize(): any;
  16031. /**
  16032. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16033. * This new light is named "name" and added to the passed scene.
  16034. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16035. * @param name The friendly name of the light
  16036. * @param scene The scene the new light will belong to
  16037. * @returns the constructor function
  16038. */
  16039. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16040. /**
  16041. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16042. * @param parsedLight The JSON representation of the light
  16043. * @param scene The scene to create the parsed light in
  16044. * @returns the created light after parsing
  16045. */
  16046. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16047. private _hookArrayForExcluded;
  16048. private _hookArrayForIncludedOnly;
  16049. private _resyncMeshes;
  16050. /**
  16051. * Forces the meshes to update their light related information in their rendering used effects
  16052. * @hidden Internal Use Only
  16053. */
  16054. _markMeshesAsLightDirty(): void;
  16055. /**
  16056. * Recomputes the cached photometric scale if needed.
  16057. */
  16058. private _computePhotometricScale;
  16059. /**
  16060. * Returns the Photometric Scale according to the light type and intensity mode.
  16061. */
  16062. private _getPhotometricScale;
  16063. /**
  16064. * Reorder the light in the scene according to their defined priority.
  16065. * @hidden Internal Use Only
  16066. */
  16067. _reorderLightsInScene(): void;
  16068. /**
  16069. * Prepares the list of defines specific to the light type.
  16070. * @param defines the list of defines
  16071. * @param lightIndex defines the index of the light for the effect
  16072. */
  16073. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16074. }
  16075. }
  16076. declare module BABYLON {
  16077. /**
  16078. * A point light is a light defined by an unique point in world space.
  16079. * The light is emitted in every direction from this point.
  16080. * A good example of a point light is a standard light bulb.
  16081. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16082. */
  16083. class PointLight extends ShadowLight {
  16084. private _shadowAngle;
  16085. /**
  16086. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16087. * This specifies what angle the shadow will use to be created.
  16088. *
  16089. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16090. */
  16091. /**
  16092. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16093. * This specifies what angle the shadow will use to be created.
  16094. *
  16095. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16096. */
  16097. shadowAngle: number;
  16098. /**
  16099. * Gets the direction if it has been set.
  16100. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16101. */
  16102. /**
  16103. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16104. */
  16105. direction: Vector3;
  16106. /**
  16107. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16108. * A PointLight emits the light in every direction.
  16109. * It can cast shadows.
  16110. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16111. * ```javascript
  16112. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16113. * ```
  16114. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16115. * @param name The light friendly name
  16116. * @param position The position of the point light in the scene
  16117. * @param scene The scene the lights belongs to
  16118. */
  16119. constructor(name: string, position: Vector3, scene: Scene);
  16120. /**
  16121. * Returns the string "PointLight"
  16122. * @returns the class name
  16123. */
  16124. getClassName(): string;
  16125. /**
  16126. * Returns the integer 0.
  16127. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16128. */
  16129. getTypeID(): number;
  16130. /**
  16131. * Specifies wether or not the shadowmap should be a cube texture.
  16132. * @returns true if the shadowmap needs to be a cube texture.
  16133. */
  16134. needCube(): boolean;
  16135. /**
  16136. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16137. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16138. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16139. */
  16140. getShadowDirection(faceIndex?: number): Vector3;
  16141. /**
  16142. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16143. * - fov = PI / 2
  16144. * - aspect ratio : 1.0
  16145. * - z-near and far equal to the active camera minZ and maxZ.
  16146. * Returns the PointLight.
  16147. */
  16148. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16149. protected _buildUniformLayout(): void;
  16150. /**
  16151. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16152. * @param effect The effect to update
  16153. * @param lightIndex The index of the light in the effect to update
  16154. * @returns The point light
  16155. */
  16156. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16157. /**
  16158. * Prepares the list of defines specific to the light type.
  16159. * @param defines the list of defines
  16160. * @param lightIndex defines the index of the light for the effect
  16161. */
  16162. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16163. }
  16164. }
  16165. declare module BABYLON {
  16166. /**
  16167. * Interface describing all the common properties and methods a shadow light needs to implement.
  16168. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16169. * as well as binding the different shadow properties to the effects.
  16170. */
  16171. interface IShadowLight extends Light {
  16172. /**
  16173. * The light id in the scene (used in scene.findLighById for instance)
  16174. */
  16175. id: string;
  16176. /**
  16177. * The position the shdow will be casted from.
  16178. */
  16179. position: Vector3;
  16180. /**
  16181. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16182. */
  16183. direction: Vector3;
  16184. /**
  16185. * The transformed position. Position of the light in world space taking parenting in account.
  16186. */
  16187. transformedPosition: Vector3;
  16188. /**
  16189. * The transformed direction. Direction of the light in world space taking parenting in account.
  16190. */
  16191. transformedDirection: Vector3;
  16192. /**
  16193. * The friendly name of the light in the scene.
  16194. */
  16195. name: string;
  16196. /**
  16197. * Defines the shadow projection clipping minimum z value.
  16198. */
  16199. shadowMinZ: number;
  16200. /**
  16201. * Defines the shadow projection clipping maximum z value.
  16202. */
  16203. shadowMaxZ: number;
  16204. /**
  16205. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16206. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16207. */
  16208. computeTransformedInformation(): boolean;
  16209. /**
  16210. * Gets the scene the light belongs to.
  16211. * @returns The scene
  16212. */
  16213. getScene(): Scene;
  16214. /**
  16215. * Callback defining a custom Projection Matrix Builder.
  16216. * This can be used to override the default projection matrix computation.
  16217. */
  16218. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16219. /**
  16220. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16221. * @param matrix The materix to updated with the projection information
  16222. * @param viewMatrix The transform matrix of the light
  16223. * @param renderList The list of mesh to render in the map
  16224. * @returns The current light
  16225. */
  16226. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16227. /**
  16228. * Gets the current depth scale used in ESM.
  16229. * @returns The scale
  16230. */
  16231. getDepthScale(): number;
  16232. /**
  16233. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16234. * @returns true if a cube texture needs to be use
  16235. */
  16236. needCube(): boolean;
  16237. /**
  16238. * Detects if the projection matrix requires to be recomputed this frame.
  16239. * @returns true if it requires to be recomputed otherwise, false.
  16240. */
  16241. needProjectionMatrixCompute(): boolean;
  16242. /**
  16243. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16244. */
  16245. forceProjectionMatrixCompute(): void;
  16246. /**
  16247. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16248. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16249. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16250. */
  16251. getShadowDirection(faceIndex?: number): Vector3;
  16252. /**
  16253. * Gets the minZ used for shadow according to both the scene and the light.
  16254. * @param activeCamera The camera we are returning the min for
  16255. * @returns the depth min z
  16256. */
  16257. getDepthMinZ(activeCamera: Camera): number;
  16258. /**
  16259. * Gets the maxZ used for shadow according to both the scene and the light.
  16260. * @param activeCamera The camera we are returning the max for
  16261. * @returns the depth max z
  16262. */
  16263. getDepthMaxZ(activeCamera: Camera): number;
  16264. }
  16265. /**
  16266. * Base implementation IShadowLight
  16267. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16268. */
  16269. abstract class ShadowLight extends Light implements IShadowLight {
  16270. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16271. protected _position: Vector3;
  16272. protected _setPosition(value: Vector3): void;
  16273. /**
  16274. * Sets the position the shadow will be casted from. Also use as the light position for both
  16275. * point and spot lights.
  16276. */
  16277. /**
  16278. * Sets the position the shadow will be casted from. Also use as the light position for both
  16279. * point and spot lights.
  16280. */
  16281. position: Vector3;
  16282. protected _direction: Vector3;
  16283. protected _setDirection(value: Vector3): void;
  16284. /**
  16285. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16286. * Also use as the light direction on spot and directional lights.
  16287. */
  16288. /**
  16289. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16290. * Also use as the light direction on spot and directional lights.
  16291. */
  16292. direction: Vector3;
  16293. private _shadowMinZ;
  16294. /**
  16295. * Gets the shadow projection clipping minimum z value.
  16296. */
  16297. /**
  16298. * Sets the shadow projection clipping minimum z value.
  16299. */
  16300. shadowMinZ: number;
  16301. private _shadowMaxZ;
  16302. /**
  16303. * Sets the shadow projection clipping maximum z value.
  16304. */
  16305. /**
  16306. * Gets the shadow projection clipping maximum z value.
  16307. */
  16308. shadowMaxZ: number;
  16309. /**
  16310. * Callback defining a custom Projection Matrix Builder.
  16311. * This can be used to override the default projection matrix computation.
  16312. */
  16313. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16314. /**
  16315. * The transformed position. Position of the light in world space taking parenting in account.
  16316. */
  16317. transformedPosition: Vector3;
  16318. /**
  16319. * The transformed direction. Direction of the light in world space taking parenting in account.
  16320. */
  16321. transformedDirection: Vector3;
  16322. private _needProjectionMatrixCompute;
  16323. /**
  16324. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16325. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16326. */
  16327. computeTransformedInformation(): boolean;
  16328. /**
  16329. * Return the depth scale used for the shadow map.
  16330. * @returns the depth scale.
  16331. */
  16332. getDepthScale(): number;
  16333. /**
  16334. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16335. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16336. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16337. */
  16338. getShadowDirection(faceIndex?: number): Vector3;
  16339. /**
  16340. * Returns the ShadowLight absolute position in the World.
  16341. * @returns the position vector in world space
  16342. */
  16343. getAbsolutePosition(): Vector3;
  16344. /**
  16345. * Sets the ShadowLight direction toward the passed target.
  16346. * @param target The point tot target in local space
  16347. * @returns the updated ShadowLight direction
  16348. */
  16349. setDirectionToTarget(target: Vector3): Vector3;
  16350. /**
  16351. * Returns the light rotation in euler definition.
  16352. * @returns the x y z rotation in local space.
  16353. */
  16354. getRotation(): Vector3;
  16355. /**
  16356. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16357. * @returns true if a cube texture needs to be use
  16358. */
  16359. needCube(): boolean;
  16360. /**
  16361. * Detects if the projection matrix requires to be recomputed this frame.
  16362. * @returns true if it requires to be recomputed otherwise, false.
  16363. */
  16364. needProjectionMatrixCompute(): boolean;
  16365. /**
  16366. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16367. */
  16368. forceProjectionMatrixCompute(): void;
  16369. /** @hidden */
  16370. _initCache(): void;
  16371. /** @hidden */
  16372. _isSynchronized(): boolean;
  16373. /**
  16374. * Computes the world matrix of the node
  16375. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16376. * @returns the world matrix
  16377. */
  16378. computeWorldMatrix(force?: boolean): Matrix;
  16379. /**
  16380. * Gets the minZ used for shadow according to both the scene and the light.
  16381. * @param activeCamera The camera we are returning the min for
  16382. * @returns the depth min z
  16383. */
  16384. getDepthMinZ(activeCamera: Camera): number;
  16385. /**
  16386. * Gets the maxZ used for shadow according to both the scene and the light.
  16387. * @param activeCamera The camera we are returning the max for
  16388. * @returns the depth max z
  16389. */
  16390. getDepthMaxZ(activeCamera: Camera): number;
  16391. /**
  16392. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16393. * @param matrix The materix to updated with the projection information
  16394. * @param viewMatrix The transform matrix of the light
  16395. * @param renderList The list of mesh to render in the map
  16396. * @returns The current light
  16397. */
  16398. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16399. }
  16400. }
  16401. declare module BABYLON {
  16402. /**
  16403. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16404. * These values define a cone of light starting from the position, emitting toward the direction.
  16405. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16406. * and the exponent defines the speed of the decay of the light with distance (reach).
  16407. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16408. */
  16409. class SpotLight extends ShadowLight {
  16410. private _angle;
  16411. private _innerAngle;
  16412. private _cosHalfAngle;
  16413. private _lightAngleScale;
  16414. private _lightAngleOffset;
  16415. /**
  16416. * Gets the cone angle of the spot light in Radians.
  16417. */
  16418. /**
  16419. * Sets the cone angle of the spot light in Radians.
  16420. */
  16421. angle: number;
  16422. /**
  16423. * Only used in gltf falloff mode, this defines the angle where
  16424. * the directional falloff will start before cutting at angle which could be seen
  16425. * as outer angle.
  16426. */
  16427. /**
  16428. * Only used in gltf falloff mode, this defines the angle where
  16429. * the directional falloff will start before cutting at angle which could be seen
  16430. * as outer angle.
  16431. */
  16432. innerAngle: number;
  16433. private _shadowAngleScale;
  16434. /**
  16435. * Allows scaling the angle of the light for shadow generation only.
  16436. */
  16437. /**
  16438. * Allows scaling the angle of the light for shadow generation only.
  16439. */
  16440. shadowAngleScale: number;
  16441. /**
  16442. * The light decay speed with the distance from the emission spot.
  16443. */
  16444. exponent: number;
  16445. private _projectionTextureMatrix;
  16446. /**
  16447. * Allows reading the projecton texture
  16448. */
  16449. readonly projectionTextureMatrix: Matrix;
  16450. protected _projectionTextureLightNear: number;
  16451. /**
  16452. * Gets the near clip of the Spotlight for texture projection.
  16453. */
  16454. /**
  16455. * Sets the near clip of the Spotlight for texture projection.
  16456. */
  16457. projectionTextureLightNear: number;
  16458. protected _projectionTextureLightFar: number;
  16459. /**
  16460. * Gets the far clip of the Spotlight for texture projection.
  16461. */
  16462. /**
  16463. * Sets the far clip of the Spotlight for texture projection.
  16464. */
  16465. projectionTextureLightFar: number;
  16466. protected _projectionTextureUpDirection: Vector3;
  16467. /**
  16468. * Gets the Up vector of the Spotlight for texture projection.
  16469. */
  16470. /**
  16471. * Sets the Up vector of the Spotlight for texture projection.
  16472. */
  16473. projectionTextureUpDirection: Vector3;
  16474. private _projectionTexture;
  16475. /**
  16476. * Gets the projection texture of the light.
  16477. */
  16478. /**
  16479. * Sets the projection texture of the light.
  16480. */
  16481. projectionTexture: Nullable<BaseTexture>;
  16482. private _projectionTextureViewLightDirty;
  16483. private _projectionTextureProjectionLightDirty;
  16484. private _projectionTextureDirty;
  16485. private _projectionTextureViewTargetVector;
  16486. private _projectionTextureViewLightMatrix;
  16487. private _projectionTextureProjectionLightMatrix;
  16488. private _projectionTextureScalingMatrix;
  16489. /**
  16490. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16491. * It can cast shadows.
  16492. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16493. * @param name The light friendly name
  16494. * @param position The position of the spot light in the scene
  16495. * @param direction The direction of the light in the scene
  16496. * @param angle The cone angle of the light in Radians
  16497. * @param exponent The light decay speed with the distance from the emission spot
  16498. * @param scene The scene the lights belongs to
  16499. */
  16500. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16501. /**
  16502. * Returns the string "SpotLight".
  16503. * @returns the class name
  16504. */
  16505. getClassName(): string;
  16506. /**
  16507. * Returns the integer 2.
  16508. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16509. */
  16510. getTypeID(): number;
  16511. /**
  16512. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16513. */
  16514. protected _setDirection(value: Vector3): void;
  16515. /**
  16516. * Overrides the position setter to recompute the projection texture view light Matrix.
  16517. */
  16518. protected _setPosition(value: Vector3): void;
  16519. /**
  16520. * 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.
  16521. * Returns the SpotLight.
  16522. */
  16523. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16524. protected _computeProjectionTextureViewLightMatrix(): void;
  16525. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16526. /**
  16527. * Main function for light texture projection matrix computing.
  16528. */
  16529. protected _computeProjectionTextureMatrix(): void;
  16530. protected _buildUniformLayout(): void;
  16531. private _computeAngleValues;
  16532. /**
  16533. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16534. * @param effect The effect to update
  16535. * @param lightIndex The index of the light in the effect to update
  16536. * @returns The spot light
  16537. */
  16538. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16539. /**
  16540. * Disposes the light and the associated resources.
  16541. */
  16542. dispose(): void;
  16543. /**
  16544. * Prepares the list of defines specific to the light type.
  16545. * @param defines the list of defines
  16546. * @param lightIndex defines the index of the light for the effect
  16547. */
  16548. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16549. }
  16550. }
  16551. declare module BABYLON {
  16552. /**
  16553. * Interface used to present a loading screen while loading a scene
  16554. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16555. */
  16556. interface ILoadingScreen {
  16557. /**
  16558. * Function called to display the loading screen
  16559. */
  16560. displayLoadingUI: () => void;
  16561. /**
  16562. * Function called to hide the loading screen
  16563. */
  16564. hideLoadingUI: () => void;
  16565. /**
  16566. * Gets or sets the color to use for the background
  16567. */
  16568. loadingUIBackgroundColor: string;
  16569. /**
  16570. * Gets or sets the text to display while loading
  16571. */
  16572. loadingUIText: string;
  16573. }
  16574. /**
  16575. * Class used for the default loading screen
  16576. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16577. */
  16578. class DefaultLoadingScreen implements ILoadingScreen {
  16579. private _renderingCanvas;
  16580. private _loadingText;
  16581. private _loadingDivBackgroundColor;
  16582. private _loadingDiv;
  16583. private _loadingTextDiv;
  16584. /**
  16585. * Creates a new default loading screen
  16586. * @param _renderingCanvas defines the canvas used to render the scene
  16587. * @param _loadingText defines the default text to display
  16588. * @param _loadingDivBackgroundColor defines the default background color
  16589. */
  16590. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16591. /**
  16592. * Function called to display the loading screen
  16593. */
  16594. displayLoadingUI(): void;
  16595. /**
  16596. * Function called to hide the loading screen
  16597. */
  16598. hideLoadingUI(): void;
  16599. /**
  16600. * Gets or sets the text to display while loading
  16601. */
  16602. loadingUIText: string;
  16603. /**
  16604. * Gets or sets the color to use for the background
  16605. */
  16606. loadingUIBackgroundColor: string;
  16607. private _resizeLoadingUI;
  16608. }
  16609. }
  16610. declare module BABYLON {
  16611. /**
  16612. * Class used to represent data loading progression
  16613. */
  16614. class SceneLoaderProgressEvent {
  16615. /** defines if data length to load can be evaluated */
  16616. readonly lengthComputable: boolean;
  16617. /** defines the loaded data length */
  16618. readonly loaded: number;
  16619. /** defines the data length to load */
  16620. readonly total: number;
  16621. /**
  16622. * Create a new progress event
  16623. * @param lengthComputable defines if data length to load can be evaluated
  16624. * @param loaded defines the loaded data length
  16625. * @param total defines the data length to load
  16626. */
  16627. constructor(
  16628. /** defines if data length to load can be evaluated */
  16629. lengthComputable: boolean,
  16630. /** defines the loaded data length */
  16631. loaded: number,
  16632. /** defines the data length to load */
  16633. total: number);
  16634. /**
  16635. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16636. * @param event defines the source event
  16637. * @returns a new SceneLoaderProgressEvent
  16638. */
  16639. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16640. }
  16641. /**
  16642. * Interface used by SceneLoader plugins to define supported file extensions
  16643. */
  16644. interface ISceneLoaderPluginExtensions {
  16645. /**
  16646. * Defines the list of supported extensions
  16647. */
  16648. [extension: string]: {
  16649. isBinary: boolean;
  16650. };
  16651. }
  16652. /**
  16653. * Interface used by SceneLoader plugin factory
  16654. */
  16655. interface ISceneLoaderPluginFactory {
  16656. /**
  16657. * Defines the name of the factory
  16658. */
  16659. name: string;
  16660. /**
  16661. * Function called to create a new plugin
  16662. * @return the new plugin
  16663. */
  16664. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16665. /**
  16666. * Boolean indicating if the plugin can direct load specific data
  16667. */
  16668. canDirectLoad?: (data: string) => boolean;
  16669. }
  16670. /**
  16671. * Interface used to define a SceneLoader plugin
  16672. */
  16673. interface ISceneLoaderPlugin {
  16674. /**
  16675. * The friendly name of this plugin.
  16676. */
  16677. name: string;
  16678. /**
  16679. * The file extensions supported by this plugin.
  16680. */
  16681. extensions: string | ISceneLoaderPluginExtensions;
  16682. /**
  16683. * Import meshes into a scene.
  16684. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16685. * @param scene The scene to import into
  16686. * @param data The data to import
  16687. * @param rootUrl The root url for scene and resources
  16688. * @param meshes The meshes array to import into
  16689. * @param particleSystems The particle systems array to import into
  16690. * @param skeletons The skeletons array to import into
  16691. * @param onError The callback when import fails
  16692. * @returns True if successful or false otherwise
  16693. */
  16694. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16695. /**
  16696. * Load into a scene.
  16697. * @param scene The scene to load into
  16698. * @param data The data to import
  16699. * @param rootUrl The root url for scene and resources
  16700. * @param onError The callback when import fails
  16701. * @returns true if successful or false otherwise
  16702. */
  16703. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16704. /**
  16705. * The callback that returns true if the data can be directly loaded.
  16706. */
  16707. canDirectLoad?: (data: string) => boolean;
  16708. /**
  16709. * The callback that allows custom handling of the root url based on the response url.
  16710. */
  16711. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16712. /**
  16713. * Load into an asset container.
  16714. * @param scene The scene to load into
  16715. * @param data The data to import
  16716. * @param rootUrl The root url for scene and resources
  16717. * @param onError The callback when import fails
  16718. * @returns The loaded asset container
  16719. */
  16720. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16721. }
  16722. /**
  16723. * Interface used to define an async SceneLoader plugin
  16724. */
  16725. interface ISceneLoaderPluginAsync {
  16726. /**
  16727. * The friendly name of this plugin.
  16728. */
  16729. name: string;
  16730. /**
  16731. * The file extensions supported by this plugin.
  16732. */
  16733. extensions: string | ISceneLoaderPluginExtensions;
  16734. /**
  16735. * Import meshes into a scene.
  16736. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16737. * @param scene The scene to import into
  16738. * @param data The data to import
  16739. * @param rootUrl The root url for scene and resources
  16740. * @param onProgress The callback when the load progresses
  16741. * @param fileName Defines the name of the file to load
  16742. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16743. */
  16744. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16745. meshes: AbstractMesh[];
  16746. particleSystems: IParticleSystem[];
  16747. skeletons: Skeleton[];
  16748. animationGroups: AnimationGroup[];
  16749. }>;
  16750. /**
  16751. * Load into a scene.
  16752. * @param scene The scene to load into
  16753. * @param data The data to import
  16754. * @param rootUrl The root url for scene and resources
  16755. * @param onProgress The callback when the load progresses
  16756. * @param fileName Defines the name of the file to load
  16757. * @returns Nothing
  16758. */
  16759. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16760. /**
  16761. * The callback that returns true if the data can be directly loaded.
  16762. */
  16763. canDirectLoad?: (data: string) => boolean;
  16764. /**
  16765. * The callback that allows custom handling of the root url based on the response url.
  16766. */
  16767. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16768. /**
  16769. * Load into an asset container.
  16770. * @param scene The scene to load into
  16771. * @param data The data to import
  16772. * @param rootUrl The root url for scene and resources
  16773. * @param onProgress The callback when the load progresses
  16774. * @param fileName Defines the name of the file to load
  16775. * @returns The loaded asset container
  16776. */
  16777. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16778. }
  16779. /**
  16780. * Class used to load scene from various file formats using registered plugins
  16781. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16782. */
  16783. class SceneLoader {
  16784. private static _ForceFullSceneLoadingForIncremental;
  16785. private static _ShowLoadingScreen;
  16786. private static _CleanBoneMatrixWeights;
  16787. /**
  16788. * No logging while loading
  16789. */
  16790. static readonly NO_LOGGING: number;
  16791. /**
  16792. * Minimal logging while loading
  16793. */
  16794. static readonly MINIMAL_LOGGING: number;
  16795. /**
  16796. * Summary logging while loading
  16797. */
  16798. static readonly SUMMARY_LOGGING: number;
  16799. /**
  16800. * Detailled logging while loading
  16801. */
  16802. static readonly DETAILED_LOGGING: number;
  16803. private static _loggingLevel;
  16804. /**
  16805. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16806. */
  16807. static ForceFullSceneLoadingForIncremental: boolean;
  16808. /**
  16809. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16810. */
  16811. static ShowLoadingScreen: boolean;
  16812. /**
  16813. * Defines the current logging level (while loading the scene)
  16814. * @ignorenaming
  16815. */
  16816. static loggingLevel: number;
  16817. /**
  16818. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16819. */
  16820. static CleanBoneMatrixWeights: boolean;
  16821. /**
  16822. * Event raised when a plugin is used to load a scene
  16823. */
  16824. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16825. private static _registeredPlugins;
  16826. private static _getDefaultPlugin;
  16827. private static _getPluginForExtension;
  16828. private static _getPluginForDirectLoad;
  16829. private static _getPluginForFilename;
  16830. private static _getDirectLoad;
  16831. private static _loadData;
  16832. private static _getFileInfo;
  16833. /**
  16834. * Gets a plugin that can load the given extension
  16835. * @param extension defines the extension to load
  16836. * @returns a plugin or null if none works
  16837. */
  16838. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16839. /**
  16840. * Gets a boolean indicating that the given extension can be loaded
  16841. * @param extension defines the extension to load
  16842. * @returns true if the extension is supported
  16843. */
  16844. static IsPluginForExtensionAvailable(extension: string): boolean;
  16845. /**
  16846. * Adds a new plugin to the list of registered plugins
  16847. * @param plugin defines the plugin to add
  16848. */
  16849. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16850. /**
  16851. * Import meshes into a scene
  16852. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16853. * @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)
  16854. * @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)
  16855. * @param scene the instance of BABYLON.Scene to append to
  16856. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16857. * @param onProgress a callback with a progress event for each file being loaded
  16858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16859. * @param pluginExtension the extension used to determine the plugin
  16860. * @returns The loaded plugin
  16861. */
  16862. 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>;
  16863. /**
  16864. * Import meshes into a scene
  16865. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16866. * @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)
  16867. * @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)
  16868. * @param scene the instance of BABYLON.Scene to append to
  16869. * @param onProgress a callback with a progress event for each file being loaded
  16870. * @param pluginExtension the extension used to determine the plugin
  16871. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16872. */
  16873. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16874. meshes: AbstractMesh[];
  16875. particleSystems: IParticleSystem[];
  16876. skeletons: Skeleton[];
  16877. animationGroups: AnimationGroup[];
  16878. }>;
  16879. /**
  16880. * Load a scene
  16881. * @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)
  16882. * @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)
  16883. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16884. * @param onSuccess a callback with the scene when import succeeds
  16885. * @param onProgress a callback with a progress event for each file being loaded
  16886. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16887. * @param pluginExtension the extension used to determine the plugin
  16888. * @returns The loaded plugin
  16889. */
  16890. 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>;
  16891. /**
  16892. * Load a scene
  16893. * @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)
  16894. * @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)
  16895. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16896. * @param onProgress a callback with a progress event for each file being loaded
  16897. * @param pluginExtension the extension used to determine the plugin
  16898. * @returns The loaded scene
  16899. */
  16900. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16901. /**
  16902. * Append a scene
  16903. * @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)
  16904. * @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)
  16905. * @param scene is the instance of BABYLON.Scene to append to
  16906. * @param onSuccess a callback with the scene when import succeeds
  16907. * @param onProgress a callback with a progress event for each file being loaded
  16908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16909. * @param pluginExtension the extension used to determine the plugin
  16910. * @returns The loaded plugin
  16911. */
  16912. 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>;
  16913. /**
  16914. * Append a scene
  16915. * @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)
  16916. * @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)
  16917. * @param scene is the instance of BABYLON.Scene to append to
  16918. * @param onProgress a callback with a progress event for each file being loaded
  16919. * @param pluginExtension the extension used to determine the plugin
  16920. * @returns The given scene
  16921. */
  16922. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16923. /**
  16924. * Load a scene into an asset container
  16925. * @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)
  16926. * @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)
  16927. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16928. * @param onSuccess a callback with the scene when import succeeds
  16929. * @param onProgress a callback with a progress event for each file being loaded
  16930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16931. * @param pluginExtension the extension used to determine the plugin
  16932. * @returns The loaded plugin
  16933. */
  16934. 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>;
  16935. /**
  16936. * Load a scene into an asset container
  16937. * @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)
  16938. * @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)
  16939. * @param scene is the instance of BABYLON.Scene to append to
  16940. * @param onProgress a callback with a progress event for each file being loaded
  16941. * @param pluginExtension the extension used to determine the plugin
  16942. * @returns The loaded asset container
  16943. */
  16944. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16945. }
  16946. }
  16947. declare module BABYLON {
  16948. /**
  16949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16951. * 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;
  16952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16953. */
  16954. class ColorCurves {
  16955. private _dirty;
  16956. private _tempColor;
  16957. private _globalCurve;
  16958. private _highlightsCurve;
  16959. private _midtonesCurve;
  16960. private _shadowsCurve;
  16961. private _positiveCurve;
  16962. private _negativeCurve;
  16963. private _globalHue;
  16964. private _globalDensity;
  16965. private _globalSaturation;
  16966. private _globalExposure;
  16967. /**
  16968. * Gets the global Hue value.
  16969. * 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).
  16970. */
  16971. /**
  16972. * Sets the global Hue value.
  16973. * 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).
  16974. */
  16975. globalHue: number;
  16976. /**
  16977. * Gets the global Density value.
  16978. * 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.
  16979. * Values less than zero provide a filter of opposite hue.
  16980. */
  16981. /**
  16982. * Sets the global Density value.
  16983. * 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.
  16984. * Values less than zero provide a filter of opposite hue.
  16985. */
  16986. globalDensity: number;
  16987. /**
  16988. * Gets the global Saturation value.
  16989. * 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.
  16990. */
  16991. /**
  16992. * Sets the global Saturation value.
  16993. * 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.
  16994. */
  16995. globalSaturation: number;
  16996. /**
  16997. * Gets the global Exposure value.
  16998. * 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.
  16999. */
  17000. /**
  17001. * Sets the global Exposure value.
  17002. * 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.
  17003. */
  17004. globalExposure: number;
  17005. private _highlightsHue;
  17006. private _highlightsDensity;
  17007. private _highlightsSaturation;
  17008. private _highlightsExposure;
  17009. /**
  17010. * Gets the highlights Hue value.
  17011. * 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).
  17012. */
  17013. /**
  17014. * Sets the highlights Hue value.
  17015. * 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).
  17016. */
  17017. highlightsHue: number;
  17018. /**
  17019. * Gets the highlights Density value.
  17020. * 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.
  17021. * Values less than zero provide a filter of opposite hue.
  17022. */
  17023. /**
  17024. * Sets the highlights Density value.
  17025. * 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.
  17026. * Values less than zero provide a filter of opposite hue.
  17027. */
  17028. highlightsDensity: number;
  17029. /**
  17030. * Gets the highlights Saturation value.
  17031. * 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.
  17032. */
  17033. /**
  17034. * Sets the highlights Saturation value.
  17035. * 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.
  17036. */
  17037. highlightsSaturation: number;
  17038. /**
  17039. * Gets the highlights Exposure value.
  17040. * 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.
  17041. */
  17042. /**
  17043. * Sets the highlights Exposure value.
  17044. * 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.
  17045. */
  17046. highlightsExposure: number;
  17047. private _midtonesHue;
  17048. private _midtonesDensity;
  17049. private _midtonesSaturation;
  17050. private _midtonesExposure;
  17051. /**
  17052. * Gets the midtones Hue value.
  17053. * 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).
  17054. */
  17055. /**
  17056. * Sets the midtones Hue value.
  17057. * 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).
  17058. */
  17059. midtonesHue: number;
  17060. /**
  17061. * Gets the midtones Density value.
  17062. * 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.
  17063. * Values less than zero provide a filter of opposite hue.
  17064. */
  17065. /**
  17066. * Sets the midtones Density value.
  17067. * 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.
  17068. * Values less than zero provide a filter of opposite hue.
  17069. */
  17070. midtonesDensity: number;
  17071. /**
  17072. * Gets the midtones Saturation value.
  17073. * 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.
  17074. */
  17075. /**
  17076. * Sets the midtones Saturation value.
  17077. * 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.
  17078. */
  17079. midtonesSaturation: number;
  17080. /**
  17081. * Gets the midtones Exposure value.
  17082. * 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.
  17083. */
  17084. /**
  17085. * Sets the midtones Exposure value.
  17086. * 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.
  17087. */
  17088. midtonesExposure: number;
  17089. private _shadowsHue;
  17090. private _shadowsDensity;
  17091. private _shadowsSaturation;
  17092. private _shadowsExposure;
  17093. /**
  17094. * Gets the shadows Hue value.
  17095. * 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).
  17096. */
  17097. /**
  17098. * Sets the shadows Hue value.
  17099. * 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).
  17100. */
  17101. shadowsHue: number;
  17102. /**
  17103. * Gets the shadows Density value.
  17104. * 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.
  17105. * Values less than zero provide a filter of opposite hue.
  17106. */
  17107. /**
  17108. * Sets the shadows Density value.
  17109. * 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.
  17110. * Values less than zero provide a filter of opposite hue.
  17111. */
  17112. shadowsDensity: number;
  17113. /**
  17114. * Gets the shadows Saturation value.
  17115. * 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.
  17116. */
  17117. /**
  17118. * Sets the shadows Saturation value.
  17119. * 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.
  17120. */
  17121. shadowsSaturation: number;
  17122. /**
  17123. * Gets the shadows Exposure value.
  17124. * 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.
  17125. */
  17126. /**
  17127. * Sets the shadows Exposure value.
  17128. * 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.
  17129. */
  17130. shadowsExposure: number;
  17131. /**
  17132. * Returns the class name
  17133. * @returns The class name
  17134. */
  17135. getClassName(): string;
  17136. /**
  17137. * Binds the color curves to the shader.
  17138. * @param colorCurves The color curve to bind
  17139. * @param effect The effect to bind to
  17140. * @param positiveUniform The positive uniform shader parameter
  17141. * @param neutralUniform The neutral uniform shader parameter
  17142. * @param negativeUniform The negative uniform shader parameter
  17143. */
  17144. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17145. /**
  17146. * Prepare the list of uniforms associated with the ColorCurves effects.
  17147. * @param uniformsList The list of uniforms used in the effect
  17148. */
  17149. static PrepareUniforms(uniformsList: string[]): void;
  17150. /**
  17151. * Returns color grading data based on a hue, density, saturation and exposure value.
  17152. * @param filterHue The hue of the color filter.
  17153. * @param filterDensity The density of the color filter.
  17154. * @param saturation The saturation.
  17155. * @param exposure The exposure.
  17156. * @param result The result data container.
  17157. */
  17158. private getColorGradingDataToRef;
  17159. /**
  17160. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17161. * @param value The input slider value in range [-100,100].
  17162. * @returns Adjusted value.
  17163. */
  17164. private static applyColorGradingSliderNonlinear;
  17165. /**
  17166. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17167. * @param hue The hue (H) input.
  17168. * @param saturation The saturation (S) input.
  17169. * @param brightness The brightness (B) input.
  17170. * @result An RGBA color represented as Vector4.
  17171. */
  17172. private static fromHSBToRef;
  17173. /**
  17174. * Returns a value clamped between min and max
  17175. * @param value The value to clamp
  17176. * @param min The minimum of value
  17177. * @param max The maximum of value
  17178. * @returns The clamped value.
  17179. */
  17180. private static clamp;
  17181. /**
  17182. * Clones the current color curve instance.
  17183. * @return The cloned curves
  17184. */
  17185. clone(): ColorCurves;
  17186. /**
  17187. * Serializes the current color curve instance to a json representation.
  17188. * @return a JSON representation
  17189. */
  17190. serialize(): any;
  17191. /**
  17192. * Parses the color curve from a json representation.
  17193. * @param source the JSON source to parse
  17194. * @return The parsed curves
  17195. */
  17196. static Parse(source: any): ColorCurves;
  17197. }
  17198. }
  17199. declare module BABYLON {
  17200. /**
  17201. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17202. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17203. */
  17204. class EffectFallbacks {
  17205. private _defines;
  17206. private _currentRank;
  17207. private _maxRank;
  17208. private _mesh;
  17209. /**
  17210. * Removes the fallback from the bound mesh.
  17211. */
  17212. unBindMesh(): void;
  17213. /**
  17214. * Adds a fallback on the specified property.
  17215. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17216. * @param define The name of the define in the shader
  17217. */
  17218. addFallback(rank: number, define: string): void;
  17219. /**
  17220. * Sets the mesh to use CPU skinning when needing to fallback.
  17221. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17222. * @param mesh The mesh to use the fallbacks.
  17223. */
  17224. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17225. /**
  17226. * Checks to see if more fallbacks are still availible.
  17227. */
  17228. readonly isMoreFallbacks: boolean;
  17229. /**
  17230. * Removes the defines that shoould be removed when falling back.
  17231. * @param currentDefines defines the current define statements for the shader.
  17232. * @param effect defines the current effect we try to compile
  17233. * @returns The resulting defines with defines of the current rank removed.
  17234. */
  17235. reduce(currentDefines: string, effect: Effect): string;
  17236. }
  17237. /**
  17238. * Options to be used when creating an effect.
  17239. */
  17240. class EffectCreationOptions {
  17241. /**
  17242. * Atrributes that will be used in the shader.
  17243. */
  17244. attributes: string[];
  17245. /**
  17246. * Uniform varible names that will be set in the shader.
  17247. */
  17248. uniformsNames: string[];
  17249. /**
  17250. * Uniform buffer varible names that will be set in the shader.
  17251. */
  17252. uniformBuffersNames: string[];
  17253. /**
  17254. * Sampler texture variable names that will be set in the shader.
  17255. */
  17256. samplers: string[];
  17257. /**
  17258. * Define statements that will be set in the shader.
  17259. */
  17260. defines: any;
  17261. /**
  17262. * Possible fallbacks for this effect to improve performance when needed.
  17263. */
  17264. fallbacks: Nullable<EffectFallbacks>;
  17265. /**
  17266. * Callback that will be called when the shader is compiled.
  17267. */
  17268. onCompiled: Nullable<(effect: Effect) => void>;
  17269. /**
  17270. * Callback that will be called if an error occurs during shader compilation.
  17271. */
  17272. onError: Nullable<(effect: Effect, errors: string) => void>;
  17273. /**
  17274. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17275. */
  17276. indexParameters: any;
  17277. /**
  17278. * Max number of lights that can be used in the shader.
  17279. */
  17280. maxSimultaneousLights: number;
  17281. /**
  17282. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17283. */
  17284. transformFeedbackVaryings: Nullable<string[]>;
  17285. }
  17286. /**
  17287. * Effect containing vertex and fragment shader that can be executed on an object.
  17288. */
  17289. class Effect {
  17290. /**
  17291. * Name of the effect.
  17292. */
  17293. name: any;
  17294. /**
  17295. * String container all the define statements that should be set on the shader.
  17296. */
  17297. defines: string;
  17298. /**
  17299. * Callback that will be called when the shader is compiled.
  17300. */
  17301. onCompiled: Nullable<(effect: Effect) => void>;
  17302. /**
  17303. * Callback that will be called if an error occurs during shader compilation.
  17304. */
  17305. onError: Nullable<(effect: Effect, errors: string) => void>;
  17306. /**
  17307. * Callback that will be called when effect is bound.
  17308. */
  17309. onBind: Nullable<(effect: Effect) => void>;
  17310. /**
  17311. * Unique ID of the effect.
  17312. */
  17313. uniqueId: number;
  17314. /**
  17315. * Observable that will be called when the shader is compiled.
  17316. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17317. */
  17318. onCompileObservable: Observable<Effect>;
  17319. /**
  17320. * Observable that will be called if an error occurs during shader compilation.
  17321. */
  17322. onErrorObservable: Observable<Effect>;
  17323. /** @hidden */
  17324. _onBindObservable: Nullable<Observable<Effect>>;
  17325. /**
  17326. * Observable that will be called when effect is bound.
  17327. */
  17328. readonly onBindObservable: Observable<Effect>;
  17329. /** @hidden */
  17330. _bonesComputationForcedToCPU: boolean;
  17331. private static _uniqueIdSeed;
  17332. private _engine;
  17333. private _uniformBuffersNames;
  17334. private _uniformsNames;
  17335. private _samplers;
  17336. private _isReady;
  17337. private _compilationError;
  17338. private _attributesNames;
  17339. private _attributes;
  17340. private _uniforms;
  17341. /**
  17342. * Key for the effect.
  17343. * @hidden
  17344. */
  17345. _key: string;
  17346. private _indexParameters;
  17347. private _fallbacks;
  17348. private _vertexSourceCode;
  17349. private _fragmentSourceCode;
  17350. private _vertexSourceCodeOverride;
  17351. private _fragmentSourceCodeOverride;
  17352. private _transformFeedbackVaryings;
  17353. /**
  17354. * Compiled shader to webGL program.
  17355. * @hidden
  17356. */
  17357. _program: WebGLProgram;
  17358. private _valueCache;
  17359. private static _baseCache;
  17360. /**
  17361. * Instantiates an effect.
  17362. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17363. * @param baseName Name of the effect.
  17364. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17365. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17366. * @param samplers List of sampler variables that will be passed to the shader.
  17367. * @param engine Engine to be used to render the effect
  17368. * @param defines Define statements to be added to the shader.
  17369. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17370. * @param onCompiled Callback that will be called when the shader is compiled.
  17371. * @param onError Callback that will be called if an error occurs during shader compilation.
  17372. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17373. */
  17374. 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);
  17375. /**
  17376. * Unique key for this effect
  17377. */
  17378. readonly key: string;
  17379. /**
  17380. * If the effect has been compiled and prepared.
  17381. * @returns if the effect is compiled and prepared.
  17382. */
  17383. isReady(): boolean;
  17384. /**
  17385. * The engine the effect was initialized with.
  17386. * @returns the engine.
  17387. */
  17388. getEngine(): Engine;
  17389. /**
  17390. * The compiled webGL program for the effect
  17391. * @returns the webGL program.
  17392. */
  17393. getProgram(): WebGLProgram;
  17394. /**
  17395. * The set of names of attribute variables for the shader.
  17396. * @returns An array of attribute names.
  17397. */
  17398. getAttributesNames(): string[];
  17399. /**
  17400. * Returns the attribute at the given index.
  17401. * @param index The index of the attribute.
  17402. * @returns The location of the attribute.
  17403. */
  17404. getAttributeLocation(index: number): number;
  17405. /**
  17406. * Returns the attribute based on the name of the variable.
  17407. * @param name of the attribute to look up.
  17408. * @returns the attribute location.
  17409. */
  17410. getAttributeLocationByName(name: string): number;
  17411. /**
  17412. * The number of attributes.
  17413. * @returns the numnber of attributes.
  17414. */
  17415. getAttributesCount(): number;
  17416. /**
  17417. * Gets the index of a uniform variable.
  17418. * @param uniformName of the uniform to look up.
  17419. * @returns the index.
  17420. */
  17421. getUniformIndex(uniformName: string): number;
  17422. /**
  17423. * Returns the attribute based on the name of the variable.
  17424. * @param uniformName of the uniform to look up.
  17425. * @returns the location of the uniform.
  17426. */
  17427. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17428. /**
  17429. * Returns an array of sampler variable names
  17430. * @returns The array of sampler variable neames.
  17431. */
  17432. getSamplers(): string[];
  17433. /**
  17434. * The error from the last compilation.
  17435. * @returns the error string.
  17436. */
  17437. getCompilationError(): string;
  17438. /**
  17439. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17440. * @param func The callback to be used.
  17441. */
  17442. executeWhenCompiled(func: (effect: Effect) => void): void;
  17443. private _checkIsReady;
  17444. /** @hidden */
  17445. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17446. /** @hidden */
  17447. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17448. /** @hidden */
  17449. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17450. private _processShaderConversion;
  17451. private _processIncludes;
  17452. private _processPrecision;
  17453. /**
  17454. * Recompiles the webGL program
  17455. * @param vertexSourceCode The source code for the vertex shader.
  17456. * @param fragmentSourceCode The source code for the fragment shader.
  17457. * @param onCompiled Callback called when completed.
  17458. * @param onError Callback called on error.
  17459. * @hidden
  17460. */
  17461. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17462. /**
  17463. * Gets the uniform locations of the the specified variable names
  17464. * @param names THe names of the variables to lookup.
  17465. * @returns Array of locations in the same order as variable names.
  17466. */
  17467. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17468. /**
  17469. * Prepares the effect
  17470. * @hidden
  17471. */
  17472. _prepareEffect(): void;
  17473. /**
  17474. * Checks if the effect is supported. (Must be called after compilation)
  17475. */
  17476. readonly isSupported: boolean;
  17477. /**
  17478. * Binds a texture to the engine to be used as output of the shader.
  17479. * @param channel Name of the output variable.
  17480. * @param texture Texture to bind.
  17481. * @hidden
  17482. */
  17483. _bindTexture(channel: string, texture: InternalTexture): void;
  17484. /**
  17485. * Sets a texture on the engine to be used in the shader.
  17486. * @param channel Name of the sampler variable.
  17487. * @param texture Texture to set.
  17488. */
  17489. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17490. /**
  17491. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17492. * @param channel Name of the sampler variable.
  17493. * @param texture Texture to set.
  17494. */
  17495. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17496. /**
  17497. * Sets an array of textures on the engine to be used in the shader.
  17498. * @param channel Name of the variable.
  17499. * @param textures Textures to set.
  17500. */
  17501. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17502. /**
  17503. * 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)
  17504. * @param channel Name of the sampler variable.
  17505. * @param postProcess Post process to get the input texture from.
  17506. */
  17507. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17508. /**
  17509. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17510. * 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)
  17511. * @param channel Name of the sampler variable.
  17512. * @param postProcess Post process to get the output texture from.
  17513. */
  17514. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17515. /** @hidden */
  17516. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17517. /** @hidden */
  17518. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17519. /** @hidden */
  17520. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17521. /** @hidden */
  17522. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17523. /**
  17524. * Binds a buffer to a uniform.
  17525. * @param buffer Buffer to bind.
  17526. * @param name Name of the uniform variable to bind to.
  17527. */
  17528. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17529. /**
  17530. * Binds block to a uniform.
  17531. * @param blockName Name of the block to bind.
  17532. * @param index Index to bind.
  17533. */
  17534. bindUniformBlock(blockName: string, index: number): void;
  17535. /**
  17536. * Sets an interger value on a uniform variable.
  17537. * @param uniformName Name of the variable.
  17538. * @param value Value to be set.
  17539. * @returns this effect.
  17540. */
  17541. setInt(uniformName: string, value: number): Effect;
  17542. /**
  17543. * Sets an int array on a uniform variable.
  17544. * @param uniformName Name of the variable.
  17545. * @param array array to be set.
  17546. * @returns this effect.
  17547. */
  17548. setIntArray(uniformName: string, array: Int32Array): Effect;
  17549. /**
  17550. * 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)
  17551. * @param uniformName Name of the variable.
  17552. * @param array array to be set.
  17553. * @returns this effect.
  17554. */
  17555. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17556. /**
  17557. * 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)
  17558. * @param uniformName Name of the variable.
  17559. * @param array array to be set.
  17560. * @returns this effect.
  17561. */
  17562. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17563. /**
  17564. * 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)
  17565. * @param uniformName Name of the variable.
  17566. * @param array array to be set.
  17567. * @returns this effect.
  17568. */
  17569. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17570. /**
  17571. * Sets an float array on a uniform variable.
  17572. * @param uniformName Name of the variable.
  17573. * @param array array to be set.
  17574. * @returns this effect.
  17575. */
  17576. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17577. /**
  17578. * 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)
  17579. * @param uniformName Name of the variable.
  17580. * @param array array to be set.
  17581. * @returns this effect.
  17582. */
  17583. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17584. /**
  17585. * 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)
  17586. * @param uniformName Name of the variable.
  17587. * @param array array to be set.
  17588. * @returns this effect.
  17589. */
  17590. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17591. /**
  17592. * 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)
  17593. * @param uniformName Name of the variable.
  17594. * @param array array to be set.
  17595. * @returns this effect.
  17596. */
  17597. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17598. /**
  17599. * Sets an array on a uniform variable.
  17600. * @param uniformName Name of the variable.
  17601. * @param array array to be set.
  17602. * @returns this effect.
  17603. */
  17604. setArray(uniformName: string, array: number[]): Effect;
  17605. /**
  17606. * 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)
  17607. * @param uniformName Name of the variable.
  17608. * @param array array to be set.
  17609. * @returns this effect.
  17610. */
  17611. setArray2(uniformName: string, array: number[]): Effect;
  17612. /**
  17613. * 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)
  17614. * @param uniformName Name of the variable.
  17615. * @param array array to be set.
  17616. * @returns this effect.
  17617. */
  17618. setArray3(uniformName: string, array: number[]): Effect;
  17619. /**
  17620. * 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)
  17621. * @param uniformName Name of the variable.
  17622. * @param array array to be set.
  17623. * @returns this effect.
  17624. */
  17625. setArray4(uniformName: string, array: number[]): Effect;
  17626. /**
  17627. * Sets matrices on a uniform variable.
  17628. * @param uniformName Name of the variable.
  17629. * @param matrices matrices to be set.
  17630. * @returns this effect.
  17631. */
  17632. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17633. /**
  17634. * Sets matrix on a uniform variable.
  17635. * @param uniformName Name of the variable.
  17636. * @param matrix matrix to be set.
  17637. * @returns this effect.
  17638. */
  17639. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17640. /**
  17641. * 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)
  17642. * @param uniformName Name of the variable.
  17643. * @param matrix matrix to be set.
  17644. * @returns this effect.
  17645. */
  17646. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17647. /**
  17648. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17649. * @param uniformName Name of the variable.
  17650. * @param matrix matrix to be set.
  17651. * @returns this effect.
  17652. */
  17653. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17654. /**
  17655. * Sets a float on a uniform variable.
  17656. * @param uniformName Name of the variable.
  17657. * @param value value to be set.
  17658. * @returns this effect.
  17659. */
  17660. setFloat(uniformName: string, value: number): Effect;
  17661. /**
  17662. * Sets a boolean on a uniform variable.
  17663. * @param uniformName Name of the variable.
  17664. * @param bool value to be set.
  17665. * @returns this effect.
  17666. */
  17667. setBool(uniformName: string, bool: boolean): Effect;
  17668. /**
  17669. * Sets a Vector2 on a uniform variable.
  17670. * @param uniformName Name of the variable.
  17671. * @param vector2 vector2 to be set.
  17672. * @returns this effect.
  17673. */
  17674. setVector2(uniformName: string, vector2: Vector2): Effect;
  17675. /**
  17676. * Sets a float2 on a uniform variable.
  17677. * @param uniformName Name of the variable.
  17678. * @param x First float in float2.
  17679. * @param y Second float in float2.
  17680. * @returns this effect.
  17681. */
  17682. setFloat2(uniformName: string, x: number, y: number): Effect;
  17683. /**
  17684. * Sets a Vector3 on a uniform variable.
  17685. * @param uniformName Name of the variable.
  17686. * @param vector3 Value to be set.
  17687. * @returns this effect.
  17688. */
  17689. setVector3(uniformName: string, vector3: Vector3): Effect;
  17690. /**
  17691. * Sets a float3 on a uniform variable.
  17692. * @param uniformName Name of the variable.
  17693. * @param x First float in float3.
  17694. * @param y Second float in float3.
  17695. * @param z Third float in float3.
  17696. * @returns this effect.
  17697. */
  17698. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17699. /**
  17700. * Sets a Vector4 on a uniform variable.
  17701. * @param uniformName Name of the variable.
  17702. * @param vector4 Value to be set.
  17703. * @returns this effect.
  17704. */
  17705. setVector4(uniformName: string, vector4: Vector4): Effect;
  17706. /**
  17707. * Sets a float4 on a uniform variable.
  17708. * @param uniformName Name of the variable.
  17709. * @param x First float in float4.
  17710. * @param y Second float in float4.
  17711. * @param z Third float in float4.
  17712. * @param w Fourth float in float4.
  17713. * @returns this effect.
  17714. */
  17715. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17716. /**
  17717. * Sets a Color3 on a uniform variable.
  17718. * @param uniformName Name of the variable.
  17719. * @param color3 Value to be set.
  17720. * @returns this effect.
  17721. */
  17722. setColor3(uniformName: string, color3: Color3): Effect;
  17723. /**
  17724. * Sets a Color4 on a uniform variable.
  17725. * @param uniformName Name of the variable.
  17726. * @param color3 Value to be set.
  17727. * @param alpha Alpha value to be set.
  17728. * @returns this effect.
  17729. */
  17730. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17731. /**
  17732. * Sets a Color4 on a uniform variable
  17733. * @param uniformName defines the name of the variable
  17734. * @param color4 defines the value to be set
  17735. * @returns this effect.
  17736. */
  17737. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17738. /**
  17739. * This function will add a new shader to the shader store
  17740. * @param name the name of the shader
  17741. * @param pixelShader optional pixel shader content
  17742. * @param vertexShader optional vertex shader content
  17743. */
  17744. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17745. /**
  17746. * Store of each shader (The can be looked up using effect.key)
  17747. */
  17748. static ShadersStore: {
  17749. [key: string]: string;
  17750. };
  17751. /**
  17752. * Store of each included file for a shader (The can be looked up using effect.key)
  17753. */
  17754. static IncludesShadersStore: {
  17755. [key: string]: string;
  17756. };
  17757. /**
  17758. * Resets the cache of effects.
  17759. */
  17760. static ResetCache(): void;
  17761. }
  17762. }
  17763. declare module BABYLON {
  17764. /**
  17765. * This represents all the required information to add a fresnel effect on a material:
  17766. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17767. */
  17768. class FresnelParameters {
  17769. private _isEnabled;
  17770. /**
  17771. * Define if the fresnel effect is enable or not.
  17772. */
  17773. isEnabled: boolean;
  17774. /**
  17775. * Define the color used on edges (grazing angle)
  17776. */
  17777. leftColor: Color3;
  17778. /**
  17779. * Define the color used on center
  17780. */
  17781. rightColor: Color3;
  17782. /**
  17783. * Define bias applied to computed fresnel term
  17784. */
  17785. bias: number;
  17786. /**
  17787. * Defined the power exponent applied to fresnel term
  17788. */
  17789. power: number;
  17790. /**
  17791. * Clones the current fresnel and its valuues
  17792. * @returns a clone fresnel configuration
  17793. */
  17794. clone(): FresnelParameters;
  17795. /**
  17796. * Serializes the current fresnel parameters to a JSON representation.
  17797. * @return the JSON serialization
  17798. */
  17799. serialize(): any;
  17800. /**
  17801. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17802. * @param parsedFresnelParameters Define the JSON representation
  17803. * @returns the parsed parameters
  17804. */
  17805. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17806. }
  17807. }
  17808. declare module BABYLON {
  17809. /**
  17810. * Interface to follow in your material defines to integrate easily the
  17811. * Image proccessing functions.
  17812. * @hidden
  17813. */
  17814. interface IImageProcessingConfigurationDefines {
  17815. IMAGEPROCESSING: boolean;
  17816. VIGNETTE: boolean;
  17817. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17818. VIGNETTEBLENDMODEOPAQUE: boolean;
  17819. TONEMAPPING: boolean;
  17820. TONEMAPPING_ACES: boolean;
  17821. CONTRAST: boolean;
  17822. EXPOSURE: boolean;
  17823. COLORCURVES: boolean;
  17824. COLORGRADING: boolean;
  17825. COLORGRADING3D: boolean;
  17826. SAMPLER3DGREENDEPTH: boolean;
  17827. SAMPLER3DBGRMAP: boolean;
  17828. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17829. }
  17830. /**
  17831. * @hidden
  17832. */
  17833. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17834. IMAGEPROCESSING: boolean;
  17835. VIGNETTE: boolean;
  17836. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17837. VIGNETTEBLENDMODEOPAQUE: boolean;
  17838. TONEMAPPING: boolean;
  17839. TONEMAPPING_ACES: boolean;
  17840. CONTRAST: boolean;
  17841. COLORCURVES: boolean;
  17842. COLORGRADING: boolean;
  17843. COLORGRADING3D: boolean;
  17844. SAMPLER3DGREENDEPTH: boolean;
  17845. SAMPLER3DBGRMAP: boolean;
  17846. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17847. EXPOSURE: boolean;
  17848. constructor();
  17849. }
  17850. /**
  17851. * This groups together the common properties used for image processing either in direct forward pass
  17852. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17853. * or not.
  17854. */
  17855. class ImageProcessingConfiguration {
  17856. /**
  17857. * Default tone mapping applied in BabylonJS.
  17858. */
  17859. static readonly TONEMAPPING_STANDARD: number;
  17860. /**
  17861. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17862. * to other engines rendering to increase portability.
  17863. */
  17864. static readonly TONEMAPPING_ACES: number;
  17865. /**
  17866. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17867. */
  17868. colorCurves: Nullable<ColorCurves>;
  17869. private _colorCurvesEnabled;
  17870. /**
  17871. * Gets wether the color curves effect is enabled.
  17872. */
  17873. /**
  17874. * Sets wether the color curves effect is enabled.
  17875. */
  17876. colorCurvesEnabled: boolean;
  17877. private _colorGradingTexture;
  17878. /**
  17879. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17880. */
  17881. /**
  17882. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17883. */
  17884. colorGradingTexture: Nullable<BaseTexture>;
  17885. private _colorGradingEnabled;
  17886. /**
  17887. * Gets wether the color grading effect is enabled.
  17888. */
  17889. /**
  17890. * Sets wether the color grading effect is enabled.
  17891. */
  17892. colorGradingEnabled: boolean;
  17893. private _colorGradingWithGreenDepth;
  17894. /**
  17895. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17896. */
  17897. /**
  17898. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17899. */
  17900. colorGradingWithGreenDepth: boolean;
  17901. private _colorGradingBGR;
  17902. /**
  17903. * Gets wether the color grading texture contains BGR values.
  17904. */
  17905. /**
  17906. * Sets wether the color grading texture contains BGR values.
  17907. */
  17908. colorGradingBGR: boolean;
  17909. /** @hidden */
  17910. _exposure: number;
  17911. /**
  17912. * Gets the Exposure used in the effect.
  17913. */
  17914. /**
  17915. * Sets the Exposure used in the effect.
  17916. */
  17917. exposure: number;
  17918. private _toneMappingEnabled;
  17919. /**
  17920. * Gets wether the tone mapping effect is enabled.
  17921. */
  17922. /**
  17923. * Sets wether the tone mapping effect is enabled.
  17924. */
  17925. toneMappingEnabled: boolean;
  17926. private _toneMappingType;
  17927. /**
  17928. * Gets the type of tone mapping effect.
  17929. */
  17930. /**
  17931. * Sets the type of tone mapping effect used in BabylonJS.
  17932. */
  17933. toneMappingType: number;
  17934. protected _contrast: number;
  17935. /**
  17936. * Gets the contrast used in the effect.
  17937. */
  17938. /**
  17939. * Sets the contrast used in the effect.
  17940. */
  17941. contrast: number;
  17942. /**
  17943. * Vignette stretch size.
  17944. */
  17945. vignetteStretch: number;
  17946. /**
  17947. * Vignette centre X Offset.
  17948. */
  17949. vignetteCentreX: number;
  17950. /**
  17951. * Vignette centre Y Offset.
  17952. */
  17953. vignetteCentreY: number;
  17954. /**
  17955. * Vignette weight or intensity of the vignette effect.
  17956. */
  17957. vignetteWeight: number;
  17958. /**
  17959. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17960. * if vignetteEnabled is set to true.
  17961. */
  17962. vignetteColor: Color4;
  17963. /**
  17964. * Camera field of view used by the Vignette effect.
  17965. */
  17966. vignetteCameraFov: number;
  17967. private _vignetteBlendMode;
  17968. /**
  17969. * Gets the vignette blend mode allowing different kind of effect.
  17970. */
  17971. /**
  17972. * Sets the vignette blend mode allowing different kind of effect.
  17973. */
  17974. vignetteBlendMode: number;
  17975. private _vignetteEnabled;
  17976. /**
  17977. * Gets wether the vignette effect is enabled.
  17978. */
  17979. /**
  17980. * Sets wether the vignette effect is enabled.
  17981. */
  17982. vignetteEnabled: boolean;
  17983. private _applyByPostProcess;
  17984. /**
  17985. * Gets wether the image processing is applied through a post process or not.
  17986. */
  17987. /**
  17988. * Sets wether the image processing is applied through a post process or not.
  17989. */
  17990. applyByPostProcess: boolean;
  17991. private _isEnabled;
  17992. /**
  17993. * Gets wether the image processing is enabled or not.
  17994. */
  17995. /**
  17996. * Sets wether the image processing is enabled or not.
  17997. */
  17998. isEnabled: boolean;
  17999. /**
  18000. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  18001. */
  18002. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  18003. /**
  18004. * Method called each time the image processing information changes requires to recompile the effect.
  18005. */
  18006. protected _updateParameters(): void;
  18007. /**
  18008. * Gets the current class name.
  18009. * @return "ImageProcessingConfiguration"
  18010. */
  18011. getClassName(): string;
  18012. /**
  18013. * Prepare the list of uniforms associated with the Image Processing effects.
  18014. * @param uniforms The list of uniforms used in the effect
  18015. * @param defines the list of defines currently in use
  18016. */
  18017. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  18018. /**
  18019. * Prepare the list of samplers associated with the Image Processing effects.
  18020. * @param samplersList The list of uniforms used in the effect
  18021. * @param defines the list of defines currently in use
  18022. */
  18023. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  18024. /**
  18025. * Prepare the list of defines associated to the shader.
  18026. * @param defines the list of defines to complete
  18027. * @param forPostProcess Define if we are currently in post process mode or not
  18028. */
  18029. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  18030. /**
  18031. * Returns true if all the image processing information are ready.
  18032. * @returns True if ready, otherwise, false
  18033. */
  18034. isReady(): boolean;
  18035. /**
  18036. * Binds the image processing to the shader.
  18037. * @param effect The effect to bind to
  18038. * @param aspectRatio Define the current aspect ratio of the effect
  18039. */
  18040. bind(effect: Effect, aspectRatio?: number): void;
  18041. /**
  18042. * Clones the current image processing instance.
  18043. * @return The cloned image processing
  18044. */
  18045. clone(): ImageProcessingConfiguration;
  18046. /**
  18047. * Serializes the current image processing instance to a json representation.
  18048. * @return a JSON representation
  18049. */
  18050. serialize(): any;
  18051. /**
  18052. * Parses the image processing from a json representation.
  18053. * @param source the JSON source to parse
  18054. * @return The parsed image processing
  18055. */
  18056. static Parse(source: any): ImageProcessingConfiguration;
  18057. private static _VIGNETTEMODE_MULTIPLY;
  18058. private static _VIGNETTEMODE_OPAQUE;
  18059. /**
  18060. * Used to apply the vignette as a mix with the pixel color.
  18061. */
  18062. static readonly VIGNETTEMODE_MULTIPLY: number;
  18063. /**
  18064. * Used to apply the vignette as a replacement of the pixel color.
  18065. */
  18066. static readonly VIGNETTEMODE_OPAQUE: number;
  18067. }
  18068. }
  18069. declare module BABYLON {
  18070. /**
  18071. * Manages the defines for the Material
  18072. */
  18073. class MaterialDefines {
  18074. private _keys;
  18075. private _isDirty;
  18076. /** @hidden */
  18077. _renderId: number;
  18078. /** @hidden */
  18079. _areLightsDirty: boolean;
  18080. /** @hidden */
  18081. _areAttributesDirty: boolean;
  18082. /** @hidden */
  18083. _areTexturesDirty: boolean;
  18084. /** @hidden */
  18085. _areFresnelDirty: boolean;
  18086. /** @hidden */
  18087. _areMiscDirty: boolean;
  18088. /** @hidden */
  18089. _areImageProcessingDirty: boolean;
  18090. /** @hidden */
  18091. _normals: boolean;
  18092. /** @hidden */
  18093. _uvs: boolean;
  18094. /** @hidden */
  18095. _needNormals: boolean;
  18096. /** @hidden */
  18097. _needUVs: boolean;
  18098. /**
  18099. * Specifies if the material needs to be re-calculated
  18100. */
  18101. readonly isDirty: boolean;
  18102. /**
  18103. * Marks the material to indicate that it has been re-calculated
  18104. */
  18105. markAsProcessed(): void;
  18106. /**
  18107. * Marks the material to indicate that it needs to be re-calculated
  18108. */
  18109. markAsUnprocessed(): void;
  18110. /**
  18111. * Marks the material to indicate all of its defines need to be re-calculated
  18112. */
  18113. markAllAsDirty(): void;
  18114. /**
  18115. * Marks the material to indicate that image processing needs to be re-calculated
  18116. */
  18117. markAsImageProcessingDirty(): void;
  18118. /**
  18119. * Marks the material to indicate the lights need to be re-calculated
  18120. */
  18121. markAsLightDirty(): void;
  18122. /**
  18123. * Marks the attribute state as changed
  18124. */
  18125. markAsAttributesDirty(): void;
  18126. /**
  18127. * Marks the texture state as changed
  18128. */
  18129. markAsTexturesDirty(): void;
  18130. /**
  18131. * Marks the fresnel state as changed
  18132. */
  18133. markAsFresnelDirty(): void;
  18134. /**
  18135. * Marks the misc state as changed
  18136. */
  18137. markAsMiscDirty(): void;
  18138. /**
  18139. * Rebuilds the material defines
  18140. */
  18141. rebuild(): void;
  18142. /**
  18143. * Specifies if two material defines are equal
  18144. * @param other - A material define instance to compare to
  18145. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18146. */
  18147. isEqual(other: MaterialDefines): boolean;
  18148. /**
  18149. * Clones this instance's defines to another instance
  18150. * @param other - material defines to clone values to
  18151. */
  18152. cloneTo(other: MaterialDefines): void;
  18153. /**
  18154. * Resets the material define values
  18155. */
  18156. reset(): void;
  18157. /**
  18158. * Converts the material define values to a string
  18159. * @returns - String of material define information
  18160. */
  18161. toString(): string;
  18162. }
  18163. /**
  18164. * Base class for the main features of a material in Babylon.js
  18165. */
  18166. class Material implements IAnimatable {
  18167. private static _TriangleFillMode;
  18168. private static _WireFrameFillMode;
  18169. private static _PointFillMode;
  18170. private static _PointListDrawMode;
  18171. private static _LineListDrawMode;
  18172. private static _LineLoopDrawMode;
  18173. private static _LineStripDrawMode;
  18174. private static _TriangleStripDrawMode;
  18175. private static _TriangleFanDrawMode;
  18176. /**
  18177. * Returns the triangle fill mode
  18178. */
  18179. static readonly TriangleFillMode: number;
  18180. /**
  18181. * Returns the wireframe mode
  18182. */
  18183. static readonly WireFrameFillMode: number;
  18184. /**
  18185. * Returns the point fill mode
  18186. */
  18187. static readonly PointFillMode: number;
  18188. /**
  18189. * Returns the point list draw mode
  18190. */
  18191. static readonly PointListDrawMode: number;
  18192. /**
  18193. * Returns the line list draw mode
  18194. */
  18195. static readonly LineListDrawMode: number;
  18196. /**
  18197. * Returns the line loop draw mode
  18198. */
  18199. static readonly LineLoopDrawMode: number;
  18200. /**
  18201. * Returns the line strip draw mode
  18202. */
  18203. static readonly LineStripDrawMode: number;
  18204. /**
  18205. * Returns the triangle strip draw mode
  18206. */
  18207. static readonly TriangleStripDrawMode: number;
  18208. /**
  18209. * Returns the triangle fan draw mode
  18210. */
  18211. static readonly TriangleFanDrawMode: number;
  18212. /**
  18213. * Stores the clock-wise side orientation
  18214. */
  18215. private static _ClockWiseSideOrientation;
  18216. /**
  18217. * Stores the counter clock-wise side orientation
  18218. */
  18219. private static _CounterClockWiseSideOrientation;
  18220. /**
  18221. * Returns the clock-wise side orientation
  18222. */
  18223. static readonly ClockWiseSideOrientation: number;
  18224. /**
  18225. * Returns the counter clock-wise side orientation
  18226. */
  18227. static readonly CounterClockWiseSideOrientation: number;
  18228. /**
  18229. * The dirty texture flag value
  18230. */
  18231. static readonly TextureDirtyFlag: number;
  18232. /**
  18233. * The dirty light flag value
  18234. */
  18235. static readonly LightDirtyFlag: number;
  18236. /**
  18237. * The dirty fresnel flag value
  18238. */
  18239. static readonly FresnelDirtyFlag: number;
  18240. /**
  18241. * The dirty attribute flag value
  18242. */
  18243. static readonly AttributesDirtyFlag: number;
  18244. /**
  18245. * The dirty misc flag value
  18246. */
  18247. static readonly MiscDirtyFlag: number;
  18248. /**
  18249. * The all dirty flag value
  18250. */
  18251. static readonly AllDirtyFlag: number;
  18252. /**
  18253. * The ID of the material
  18254. */
  18255. id: string;
  18256. /**
  18257. * Gets or sets the unique id of the material
  18258. */
  18259. uniqueId: number;
  18260. /**
  18261. * The name of the material
  18262. */
  18263. name: string;
  18264. /**
  18265. * Gets or sets user defined metadata
  18266. */
  18267. metadata: any;
  18268. /**
  18269. * For internal use only. Please do not use.
  18270. */
  18271. reservedDataStore: any;
  18272. /**
  18273. * Specifies if the ready state should be checked on each call
  18274. */
  18275. checkReadyOnEveryCall: boolean;
  18276. /**
  18277. * Specifies if the ready state should be checked once
  18278. */
  18279. checkReadyOnlyOnce: boolean;
  18280. /**
  18281. * The state of the material
  18282. */
  18283. state: string;
  18284. /**
  18285. * The alpha value of the material
  18286. */
  18287. protected _alpha: number;
  18288. /**
  18289. * Sets the alpha value of the material
  18290. */
  18291. /**
  18292. * Gets the alpha value of the material
  18293. */
  18294. alpha: number;
  18295. /**
  18296. * Specifies if back face culling is enabled
  18297. */
  18298. protected _backFaceCulling: boolean;
  18299. /**
  18300. * Sets the back-face culling state
  18301. */
  18302. /**
  18303. * Gets the back-face culling state
  18304. */
  18305. backFaceCulling: boolean;
  18306. /**
  18307. * Stores the value for side orientation
  18308. */
  18309. sideOrientation: number;
  18310. /**
  18311. * Callback triggered when the material is compiled
  18312. */
  18313. onCompiled: (effect: Effect) => void;
  18314. /**
  18315. * Callback triggered when an error occurs
  18316. */
  18317. onError: (effect: Effect, errors: string) => void;
  18318. /**
  18319. * Callback triggered to get the render target textures
  18320. */
  18321. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18322. /**
  18323. * Gets a boolean indicating that current material needs to register RTT
  18324. */
  18325. readonly hasRenderTargetTextures: boolean;
  18326. /**
  18327. * Specifies if the material should be serialized
  18328. */
  18329. doNotSerialize: boolean;
  18330. /**
  18331. * @hidden
  18332. */
  18333. _storeEffectOnSubMeshes: boolean;
  18334. /**
  18335. * Stores the animations for the material
  18336. */
  18337. animations: Array<Animation>;
  18338. /**
  18339. * An event triggered when the material is disposed
  18340. */
  18341. onDisposeObservable: Observable<Material>;
  18342. /**
  18343. * An observer which watches for dispose events
  18344. */
  18345. private _onDisposeObserver;
  18346. private _onUnBindObservable;
  18347. /**
  18348. * Called during a dispose event
  18349. */
  18350. onDispose: () => void;
  18351. private _onBindObservable;
  18352. /**
  18353. * An event triggered when the material is bound
  18354. */
  18355. readonly onBindObservable: Observable<AbstractMesh>;
  18356. /**
  18357. * An observer which watches for bind events
  18358. */
  18359. private _onBindObserver;
  18360. /**
  18361. * Called during a bind event
  18362. */
  18363. onBind: (Mesh: AbstractMesh) => void;
  18364. /**
  18365. * An event triggered when the material is unbound
  18366. */
  18367. readonly onUnBindObservable: Observable<Material>;
  18368. /**
  18369. * Stores the value of the alpha mode
  18370. */
  18371. private _alphaMode;
  18372. /**
  18373. * Sets the value of the alpha mode.
  18374. *
  18375. * | Value | Type | Description |
  18376. * | --- | --- | --- |
  18377. * | 0 | ALPHA_DISABLE | |
  18378. * | 1 | ALPHA_ADD | |
  18379. * | 2 | ALPHA_COMBINE | |
  18380. * | 3 | ALPHA_SUBTRACT | |
  18381. * | 4 | ALPHA_MULTIPLY | |
  18382. * | 5 | ALPHA_MAXIMIZED | |
  18383. * | 6 | ALPHA_ONEONE | |
  18384. * | 7 | ALPHA_PREMULTIPLIED | |
  18385. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18386. * | 9 | ALPHA_INTERPOLATE | |
  18387. * | 10 | ALPHA_SCREENMODE | |
  18388. *
  18389. */
  18390. /**
  18391. * Gets the value of the alpha mode
  18392. */
  18393. alphaMode: number;
  18394. /**
  18395. * Stores the state of the need depth pre-pass value
  18396. */
  18397. private _needDepthPrePass;
  18398. /**
  18399. * Sets the need depth pre-pass value
  18400. */
  18401. /**
  18402. * Gets the depth pre-pass value
  18403. */
  18404. needDepthPrePass: boolean;
  18405. /**
  18406. * Specifies if depth writing should be disabled
  18407. */
  18408. disableDepthWrite: boolean;
  18409. /**
  18410. * Specifies if depth writing should be forced
  18411. */
  18412. forceDepthWrite: boolean;
  18413. /**
  18414. * Specifies if there should be a separate pass for culling
  18415. */
  18416. separateCullingPass: boolean;
  18417. /**
  18418. * Stores the state specifing if fog should be enabled
  18419. */
  18420. private _fogEnabled;
  18421. /**
  18422. * Sets the state for enabling fog
  18423. */
  18424. /**
  18425. * Gets the value of the fog enabled state
  18426. */
  18427. fogEnabled: boolean;
  18428. /**
  18429. * Stores the size of points
  18430. */
  18431. pointSize: number;
  18432. /**
  18433. * Stores the z offset value
  18434. */
  18435. zOffset: number;
  18436. /**
  18437. * Gets a value specifying if wireframe mode is enabled
  18438. */
  18439. /**
  18440. * Sets the state of wireframe mode
  18441. */
  18442. wireframe: boolean;
  18443. /**
  18444. * Gets the value specifying if point clouds are enabled
  18445. */
  18446. /**
  18447. * Sets the state of point cloud mode
  18448. */
  18449. pointsCloud: boolean;
  18450. /**
  18451. * Gets the material fill mode
  18452. */
  18453. /**
  18454. * Sets the material fill mode
  18455. */
  18456. fillMode: number;
  18457. /**
  18458. * @hidden
  18459. * Stores the effects for the material
  18460. */
  18461. _effect: Nullable<Effect>;
  18462. /**
  18463. * @hidden
  18464. * Specifies if the material was previously ready
  18465. */
  18466. _wasPreviouslyReady: boolean;
  18467. /**
  18468. * Specifies if uniform buffers should be used
  18469. */
  18470. private _useUBO;
  18471. /**
  18472. * Stores a reference to the scene
  18473. */
  18474. private _scene;
  18475. /**
  18476. * Stores the fill mode state
  18477. */
  18478. private _fillMode;
  18479. /**
  18480. * Specifies if the depth write state should be cached
  18481. */
  18482. private _cachedDepthWriteState;
  18483. /**
  18484. * Stores the uniform buffer
  18485. */
  18486. protected _uniformBuffer: UniformBuffer;
  18487. /** @hidden */
  18488. _indexInSceneMaterialArray: number;
  18489. /** @hidden */
  18490. meshMap: Nullable<{
  18491. [id: string]: AbstractMesh | undefined;
  18492. }>;
  18493. /**
  18494. * Creates a material instance
  18495. * @param name defines the name of the material
  18496. * @param scene defines the scene to reference
  18497. * @param doNotAdd specifies if the material should be added to the scene
  18498. */
  18499. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18500. /**
  18501. * Returns a string representation of the current material
  18502. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18503. * @returns a string with material information
  18504. */
  18505. toString(fullDetails?: boolean): string;
  18506. /**
  18507. * Gets the class name of the material
  18508. * @returns a string with the class name of the material
  18509. */
  18510. getClassName(): string;
  18511. /**
  18512. * Specifies if updates for the material been locked
  18513. */
  18514. readonly isFrozen: boolean;
  18515. /**
  18516. * Locks updates for the material
  18517. */
  18518. freeze(): void;
  18519. /**
  18520. * Unlocks updates for the material
  18521. */
  18522. unfreeze(): void;
  18523. /**
  18524. * Specifies if the material is ready to be used
  18525. * @param mesh defines the mesh to check
  18526. * @param useInstances specifies if instances should be used
  18527. * @returns a boolean indicating if the material is ready to be used
  18528. */
  18529. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18530. /**
  18531. * Specifies that the submesh is ready to be used
  18532. * @param mesh defines the mesh to check
  18533. * @param subMesh defines which submesh to check
  18534. * @param useInstances specifies that instances should be used
  18535. * @returns a boolean indicating that the submesh is ready or not
  18536. */
  18537. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18538. /**
  18539. * Returns the material effect
  18540. * @returns the effect associated with the material
  18541. */
  18542. getEffect(): Nullable<Effect>;
  18543. /**
  18544. * Returns the current scene
  18545. * @returns a Scene
  18546. */
  18547. getScene(): Scene;
  18548. /**
  18549. * Specifies if the material will require alpha blending
  18550. * @returns a boolean specifying if alpha blending is needed
  18551. */
  18552. needAlphaBlending(): boolean;
  18553. /**
  18554. * Specifies if the mesh will require alpha blending
  18555. * @param mesh defines the mesh to check
  18556. * @returns a boolean specifying if alpha blending is needed for the mesh
  18557. */
  18558. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18559. /**
  18560. * Specifies if this material should be rendered in alpha test mode
  18561. * @returns a boolean specifying if an alpha test is needed.
  18562. */
  18563. needAlphaTesting(): boolean;
  18564. /**
  18565. * Gets the texture used for the alpha test
  18566. * @returns the texture to use for alpha testing
  18567. */
  18568. getAlphaTestTexture(): Nullable<BaseTexture>;
  18569. /**
  18570. * Marks the material to indicate that it needs to be re-calculated
  18571. */
  18572. markDirty(): void;
  18573. /** @hidden */
  18574. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18575. /**
  18576. * Binds the material to the mesh
  18577. * @param world defines the world transformation matrix
  18578. * @param mesh defines the mesh to bind the material to
  18579. */
  18580. bind(world: Matrix, mesh?: Mesh): void;
  18581. /**
  18582. * Binds the submesh to the material
  18583. * @param world defines the world transformation matrix
  18584. * @param mesh defines the mesh containing the submesh
  18585. * @param subMesh defines the submesh to bind the material to
  18586. */
  18587. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18588. /**
  18589. * Binds the world matrix to the material
  18590. * @param world defines the world transformation matrix
  18591. */
  18592. bindOnlyWorldMatrix(world: Matrix): void;
  18593. /**
  18594. * Binds the scene's uniform buffer to the effect.
  18595. * @param effect defines the effect to bind to the scene uniform buffer
  18596. * @param sceneUbo defines the uniform buffer storing scene data
  18597. */
  18598. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18599. /**
  18600. * Binds the view matrix to the effect
  18601. * @param effect defines the effect to bind the view matrix to
  18602. */
  18603. bindView(effect: Effect): void;
  18604. /**
  18605. * Binds the view projection matrix to the effect
  18606. * @param effect defines the effect to bind the view projection matrix to
  18607. */
  18608. bindViewProjection(effect: Effect): void;
  18609. /**
  18610. * Specifies if material alpha testing should be turned on for the mesh
  18611. * @param mesh defines the mesh to check
  18612. */
  18613. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18614. /**
  18615. * Processes to execute after binding the material to a mesh
  18616. * @param mesh defines the rendered mesh
  18617. */
  18618. protected _afterBind(mesh?: Mesh): void;
  18619. /**
  18620. * Unbinds the material from the mesh
  18621. */
  18622. unbind(): void;
  18623. /**
  18624. * Gets the active textures from the material
  18625. * @returns an array of textures
  18626. */
  18627. getActiveTextures(): BaseTexture[];
  18628. /**
  18629. * Specifies if the material uses a texture
  18630. * @param texture defines the texture to check against the material
  18631. * @returns a boolean specifying if the material uses the texture
  18632. */
  18633. hasTexture(texture: BaseTexture): boolean;
  18634. /**
  18635. * Makes a duplicate of the material, and gives it a new name
  18636. * @param name defines the new name for the duplicated material
  18637. * @returns the cloned material
  18638. */
  18639. clone(name: string): Nullable<Material>;
  18640. /**
  18641. * Gets the meshes bound to the material
  18642. * @returns an array of meshes bound to the material
  18643. */
  18644. getBindedMeshes(): AbstractMesh[];
  18645. /**
  18646. * Force shader compilation
  18647. * @param mesh defines the mesh associated with this material
  18648. * @param onCompiled defines a function to execute once the material is compiled
  18649. * @param options defines the options to configure the compilation
  18650. */
  18651. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18652. clipPlane: boolean;
  18653. }>): void;
  18654. /**
  18655. * Force shader compilation
  18656. * @param mesh defines the mesh that will use this material
  18657. * @param options defines additional options for compiling the shaders
  18658. * @returns a promise that resolves when the compilation completes
  18659. */
  18660. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18661. clipPlane: boolean;
  18662. }>): Promise<void>;
  18663. private static readonly _ImageProcessingDirtyCallBack;
  18664. private static readonly _TextureDirtyCallBack;
  18665. private static readonly _FresnelDirtyCallBack;
  18666. private static readonly _MiscDirtyCallBack;
  18667. private static readonly _LightsDirtyCallBack;
  18668. private static readonly _AttributeDirtyCallBack;
  18669. private static _FresnelAndMiscDirtyCallBack;
  18670. private static _TextureAndMiscDirtyCallBack;
  18671. private static readonly _DirtyCallbackArray;
  18672. private static readonly _RunDirtyCallBacks;
  18673. /**
  18674. * Marks a define in the material to indicate that it needs to be re-computed
  18675. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18676. */
  18677. markAsDirty(flag: number): void;
  18678. /**
  18679. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18680. * @param func defines a function which checks material defines against the submeshes
  18681. */
  18682. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18683. /**
  18684. * Indicates that image processing needs to be re-calculated for all submeshes
  18685. */
  18686. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18687. /**
  18688. * Indicates that textures need to be re-calculated for all submeshes
  18689. */
  18690. protected _markAllSubMeshesAsTexturesDirty(): void;
  18691. /**
  18692. * Indicates that fresnel needs to be re-calculated for all submeshes
  18693. */
  18694. protected _markAllSubMeshesAsFresnelDirty(): void;
  18695. /**
  18696. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18697. */
  18698. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18699. /**
  18700. * Indicates that lights need to be re-calculated for all submeshes
  18701. */
  18702. protected _markAllSubMeshesAsLightsDirty(): void;
  18703. /**
  18704. * Indicates that attributes need to be re-calculated for all submeshes
  18705. */
  18706. protected _markAllSubMeshesAsAttributesDirty(): void;
  18707. /**
  18708. * Indicates that misc needs to be re-calculated for all submeshes
  18709. */
  18710. protected _markAllSubMeshesAsMiscDirty(): void;
  18711. /**
  18712. * Indicates that textures and misc need to be re-calculated for all submeshes
  18713. */
  18714. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18715. /**
  18716. * Disposes the material
  18717. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18718. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18719. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18720. */
  18721. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18722. /** @hidden */
  18723. private releaseVertexArrayObject;
  18724. /**
  18725. * Serializes this material
  18726. * @returns the serialized material object
  18727. */
  18728. serialize(): any;
  18729. /**
  18730. * Creates a MultiMaterial from parsed MultiMaterial data.
  18731. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18732. * @param scene defines the hosting scene
  18733. * @returns a new MultiMaterial
  18734. */
  18735. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18736. /**
  18737. * Creates a material from parsed material data
  18738. * @param parsedMaterial defines parsed material data
  18739. * @param scene defines the hosting scene
  18740. * @param rootUrl defines the root URL to use to load textures
  18741. * @returns a new material
  18742. */
  18743. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18744. }
  18745. }
  18746. declare module BABYLON {
  18747. /**
  18748. * "Static Class" containing the most commonly used helper while dealing with material for
  18749. * rendering purpose.
  18750. *
  18751. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18752. *
  18753. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18754. */
  18755. class MaterialHelper {
  18756. /**
  18757. * Bind the current view position to an effect.
  18758. * @param effect The effect to be bound
  18759. * @param scene The scene the eyes position is used from
  18760. */
  18761. static BindEyePosition(effect: Effect, scene: Scene): void;
  18762. /**
  18763. * Helps preparing the defines values about the UVs in used in the effect.
  18764. * UVs are shared as much as we can accross channels in the shaders.
  18765. * @param texture The texture we are preparing the UVs for
  18766. * @param defines The defines to update
  18767. * @param key The channel key "diffuse", "specular"... used in the shader
  18768. */
  18769. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18770. /**
  18771. * Binds a texture matrix value to its corrsponding uniform
  18772. * @param texture The texture to bind the matrix for
  18773. * @param uniformBuffer The uniform buffer receivin the data
  18774. * @param key The channel key "diffuse", "specular"... used in the shader
  18775. */
  18776. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18777. /**
  18778. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18779. * @param mesh defines the current mesh
  18780. * @param scene defines the current scene
  18781. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18782. * @param pointsCloud defines if point cloud rendering has to be turned on
  18783. * @param fogEnabled defines if fog has to be turned on
  18784. * @param alphaTest defines if alpha testing has to be turned on
  18785. * @param defines defines the current list of defines
  18786. */
  18787. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18788. /**
  18789. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18790. * @param scene defines the current scene
  18791. * @param engine defines the current engine
  18792. * @param defines specifies the list of active defines
  18793. * @param useInstances defines if instances have to be turned on
  18794. * @param useClipPlane defines if clip plane have to be turned on
  18795. */
  18796. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18797. /**
  18798. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18799. * @param mesh The mesh containing the geometry data we will draw
  18800. * @param defines The defines to update
  18801. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18802. * @param useBones Precise whether bones should be used or not (override mesh info)
  18803. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18804. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18805. * @returns false if defines are considered not dirty and have not been checked
  18806. */
  18807. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18808. /**
  18809. * Prepares the defines related to the light information passed in parameter
  18810. * @param scene The scene we are intending to draw
  18811. * @param mesh The mesh the effect is compiling for
  18812. * @param defines The defines to update
  18813. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18814. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18815. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18816. * @returns true if normals will be required for the rest of the effect
  18817. */
  18818. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18819. /**
  18820. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18821. * that won t be acctive due to defines being turned off.
  18822. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18823. * @param samplersList The samplers list
  18824. * @param defines The defines helping in the list generation
  18825. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18826. */
  18827. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18828. /**
  18829. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18830. * @param defines The defines to update while falling back
  18831. * @param fallbacks The authorized effect fallbacks
  18832. * @param maxSimultaneousLights The maximum number of lights allowed
  18833. * @param rank the current rank of the Effect
  18834. * @returns The newly affected rank
  18835. */
  18836. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18837. /**
  18838. * Prepares the list of attributes required for morph targets according to the effect defines.
  18839. * @param attribs The current list of supported attribs
  18840. * @param mesh The mesh to prepare the morph targets attributes for
  18841. * @param defines The current Defines of the effect
  18842. */
  18843. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18844. /**
  18845. * Prepares the list of attributes required for bones according to the effect defines.
  18846. * @param attribs The current list of supported attribs
  18847. * @param mesh The mesh to prepare the bones attributes for
  18848. * @param defines The current Defines of the effect
  18849. * @param fallbacks The current efffect fallback strategy
  18850. */
  18851. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18852. /**
  18853. * Prepares the list of attributes required for instances according to the effect defines.
  18854. * @param attribs The current list of supported attribs
  18855. * @param defines The current Defines of the effect
  18856. */
  18857. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18858. /**
  18859. * Binds the light shadow information to the effect for the given mesh.
  18860. * @param light The light containing the generator
  18861. * @param scene The scene the lights belongs to
  18862. * @param mesh The mesh we are binding the information to render
  18863. * @param lightIndex The light index in the effect used to render the mesh
  18864. * @param effect The effect we are binding the data to
  18865. */
  18866. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18867. /**
  18868. * Binds the light information to the effect.
  18869. * @param light The light containing the generator
  18870. * @param effect The effect we are binding the data to
  18871. * @param lightIndex The light index in the effect used to render
  18872. */
  18873. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18874. /**
  18875. * Binds the lights information from the scene to the effect for the given mesh.
  18876. * @param scene The scene the lights belongs to
  18877. * @param mesh The mesh we are binding the information to render
  18878. * @param effect The effect we are binding the data to
  18879. * @param defines The generated defines for the effect
  18880. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18881. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18882. */
  18883. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18884. private static _tempFogColor;
  18885. /**
  18886. * Binds the fog information from the scene to the effect for the given mesh.
  18887. * @param scene The scene the lights belongs to
  18888. * @param mesh The mesh we are binding the information to render
  18889. * @param effect The effect we are binding the data to
  18890. * @param linearSpace Defines if the fog effect is applied in linear space
  18891. */
  18892. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18893. /**
  18894. * Binds the bones information from the mesh to the effect.
  18895. * @param mesh The mesh we are binding the information to render
  18896. * @param effect The effect we are binding the data to
  18897. */
  18898. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18899. /**
  18900. * Binds the morph targets information from the mesh to the effect.
  18901. * @param abstractMesh The mesh we are binding the information to render
  18902. * @param effect The effect we are binding the data to
  18903. */
  18904. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18905. /**
  18906. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18907. * @param defines The generated defines used in the effect
  18908. * @param effect The effect we are binding the data to
  18909. * @param scene The scene we are willing to render with logarithmic scale for
  18910. */
  18911. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18912. /**
  18913. * Binds the clip plane information from the scene to the effect.
  18914. * @param scene The scene the clip plane information are extracted from
  18915. * @param effect The effect we are binding the data to
  18916. */
  18917. static BindClipPlane(effect: Effect, scene: Scene): void;
  18918. }
  18919. }
  18920. declare module BABYLON {
  18921. /**
  18922. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18923. * separate meshes. This can be use to improve performances.
  18924. * @see http://doc.babylonjs.com/how_to/multi_materials
  18925. */
  18926. class MultiMaterial extends Material {
  18927. private _subMaterials;
  18928. /**
  18929. * Gets or Sets the list of Materials used within the multi material.
  18930. * They need to be ordered according to the submeshes order in the associated mesh
  18931. */
  18932. subMaterials: Nullable<Material>[];
  18933. /**
  18934. * Function used to align with Node.getChildren()
  18935. * @returns the list of Materials used within the multi material
  18936. */
  18937. getChildren(): Nullable<Material>[];
  18938. /**
  18939. * Instantiates a new Multi Material
  18940. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18941. * separate meshes. This can be use to improve performances.
  18942. * @see http://doc.babylonjs.com/how_to/multi_materials
  18943. * @param name Define the name in the scene
  18944. * @param scene Define the scene the material belongs to
  18945. */
  18946. constructor(name: string, scene: Scene);
  18947. private _hookArray;
  18948. /**
  18949. * Get one of the submaterial by its index in the submaterials array
  18950. * @param index The index to look the sub material at
  18951. * @returns The Material if the index has been defined
  18952. */
  18953. getSubMaterial(index: number): Nullable<Material>;
  18954. /**
  18955. * Get the list of active textures for the whole sub materials list.
  18956. * @returns All the textures that will be used during the rendering
  18957. */
  18958. getActiveTextures(): BaseTexture[];
  18959. /**
  18960. * Gets the current class name of the material e.g. "MultiMaterial"
  18961. * Mainly use in serialization.
  18962. * @returns the class name
  18963. */
  18964. getClassName(): string;
  18965. /**
  18966. * Checks if the material is ready to render the requested sub mesh
  18967. * @param mesh Define the mesh the submesh belongs to
  18968. * @param subMesh Define the sub mesh to look readyness for
  18969. * @param useInstances Define whether or not the material is used with instances
  18970. * @returns true if ready, otherwise false
  18971. */
  18972. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18973. /**
  18974. * Clones the current material and its related sub materials
  18975. * @param name Define the name of the newly cloned material
  18976. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18977. * @returns the cloned material
  18978. */
  18979. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18980. /**
  18981. * Serializes the materials into a JSON representation.
  18982. * @returns the JSON representation
  18983. */
  18984. serialize(): any;
  18985. /**
  18986. * Dispose the material and release its associated resources
  18987. * @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)
  18988. * @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)
  18989. */
  18990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18991. }
  18992. }
  18993. declare module BABYLON {
  18994. /**
  18995. * Base class of materials working in push mode in babylon JS
  18996. * @hidden
  18997. */
  18998. class PushMaterial extends Material {
  18999. protected _activeEffect: Effect;
  19000. protected _normalMatrix: Matrix;
  19001. /**
  19002. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  19003. * This means that the material can keep using a previous shader while a new one is being compiled.
  19004. * This is mostly used when shader parallel compilation is supported (true by default)
  19005. */
  19006. allowShaderHotSwapping: boolean;
  19007. constructor(name: string, scene: Scene);
  19008. getEffect(): Effect;
  19009. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19010. /**
  19011. * Binds the given world matrix to the active effect
  19012. *
  19013. * @param world the matrix to bind
  19014. */
  19015. bindOnlyWorldMatrix(world: Matrix): void;
  19016. /**
  19017. * Binds the given normal matrix to the active effect
  19018. *
  19019. * @param normalMatrix the matrix to bind
  19020. */
  19021. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  19022. bind(world: Matrix, mesh?: Mesh): void;
  19023. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  19024. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  19025. }
  19026. }
  19027. declare module BABYLON {
  19028. /**
  19029. * Defines the options associated with the creation of a shader material.
  19030. */
  19031. interface IShaderMaterialOptions {
  19032. /**
  19033. * Does the material work in alpha blend mode
  19034. */
  19035. needAlphaBlending: boolean;
  19036. /**
  19037. * Does the material work in alpha test mode
  19038. */
  19039. needAlphaTesting: boolean;
  19040. /**
  19041. * The list of attribute names used in the shader
  19042. */
  19043. attributes: string[];
  19044. /**
  19045. * The list of unifrom names used in the shader
  19046. */
  19047. uniforms: string[];
  19048. /**
  19049. * The list of UBO names used in the shader
  19050. */
  19051. uniformBuffers: string[];
  19052. /**
  19053. * The list of sampler names used in the shader
  19054. */
  19055. samplers: string[];
  19056. /**
  19057. * The list of defines used in the shader
  19058. */
  19059. defines: string[];
  19060. }
  19061. /**
  19062. * 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.
  19063. *
  19064. * This returned material effects how the mesh will look based on the code in the shaders.
  19065. *
  19066. * @see http://doc.babylonjs.com/how_to/shader_material
  19067. */
  19068. class ShaderMaterial extends Material {
  19069. private _shaderPath;
  19070. private _options;
  19071. private _textures;
  19072. private _textureArrays;
  19073. private _floats;
  19074. private _ints;
  19075. private _floatsArrays;
  19076. private _colors3;
  19077. private _colors3Arrays;
  19078. private _colors4;
  19079. private _vectors2;
  19080. private _vectors3;
  19081. private _vectors4;
  19082. private _matrices;
  19083. private _matrices3x3;
  19084. private _matrices2x2;
  19085. private _vectors2Arrays;
  19086. private _vectors3Arrays;
  19087. private _cachedWorldViewMatrix;
  19088. private _renderId;
  19089. /**
  19090. * Instantiate a new shader material.
  19091. * 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.
  19092. * This returned material effects how the mesh will look based on the code in the shaders.
  19093. * @see http://doc.babylonjs.com/how_to/shader_material
  19094. * @param name Define the name of the material in the scene
  19095. * @param scene Define the scene the material belongs to
  19096. * @param shaderPath Defines the route to the shader code in one of three ways:
  19097. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  19098. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19099. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19100. * @param options Define the options used to create the shader
  19101. */
  19102. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19103. /**
  19104. * Gets the current class name of the material e.g. "ShaderMaterial"
  19105. * Mainly use in serialization.
  19106. * @returns the class name
  19107. */
  19108. getClassName(): string;
  19109. /**
  19110. * Specifies if the material will require alpha blending
  19111. * @returns a boolean specifying if alpha blending is needed
  19112. */
  19113. needAlphaBlending(): boolean;
  19114. /**
  19115. * Specifies if this material should be rendered in alpha test mode
  19116. * @returns a boolean specifying if an alpha test is needed.
  19117. */
  19118. needAlphaTesting(): boolean;
  19119. private _checkUniform;
  19120. /**
  19121. * Set a texture in the shader.
  19122. * @param name Define the name of the uniform samplers as defined in the shader
  19123. * @param texture Define the texture to bind to this sampler
  19124. * @return the material itself allowing "fluent" like uniform updates
  19125. */
  19126. setTexture(name: string, texture: Texture): ShaderMaterial;
  19127. /**
  19128. * Set a texture array in the shader.
  19129. * @param name Define the name of the uniform sampler array as defined in the shader
  19130. * @param textures Define the list of textures to bind to this sampler
  19131. * @return the material itself allowing "fluent" like uniform updates
  19132. */
  19133. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19134. /**
  19135. * Set a float in the shader.
  19136. * @param name Define the name of the uniform as defined in the shader
  19137. * @param value Define the value to give to the uniform
  19138. * @return the material itself allowing "fluent" like uniform updates
  19139. */
  19140. setFloat(name: string, value: number): ShaderMaterial;
  19141. /**
  19142. * Set a int in the shader.
  19143. * @param name Define the name of the uniform as defined in the shader
  19144. * @param value Define the value to give to the uniform
  19145. * @return the material itself allowing "fluent" like uniform updates
  19146. */
  19147. setInt(name: string, value: number): ShaderMaterial;
  19148. /**
  19149. * Set an array of floats in the shader.
  19150. * @param name Define the name of the uniform as defined in the shader
  19151. * @param value Define the value to give to the uniform
  19152. * @return the material itself allowing "fluent" like uniform updates
  19153. */
  19154. setFloats(name: string, value: number[]): ShaderMaterial;
  19155. /**
  19156. * Set a vec3 in the shader from a Color3.
  19157. * @param name Define the name of the uniform as defined in the shader
  19158. * @param value Define the value to give to the uniform
  19159. * @return the material itself allowing "fluent" like uniform updates
  19160. */
  19161. setColor3(name: string, value: Color3): ShaderMaterial;
  19162. /**
  19163. * Set a vec3 array in the shader from a Color3 array.
  19164. * @param name Define the name of the uniform as defined in the shader
  19165. * @param value Define the value to give to the uniform
  19166. * @return the material itself allowing "fluent" like uniform updates
  19167. */
  19168. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19169. /**
  19170. * Set a vec4 in the shader from a Color4.
  19171. * @param name Define the name of the uniform as defined in the shader
  19172. * @param value Define the value to give to the uniform
  19173. * @return the material itself allowing "fluent" like uniform updates
  19174. */
  19175. setColor4(name: string, value: Color4): ShaderMaterial;
  19176. /**
  19177. * Set a vec2 in the shader from a Vector2.
  19178. * @param name Define the name of the uniform as defined in the shader
  19179. * @param value Define the value to give to the uniform
  19180. * @return the material itself allowing "fluent" like uniform updates
  19181. */
  19182. setVector2(name: string, value: Vector2): ShaderMaterial;
  19183. /**
  19184. * Set a vec3 in the shader from a Vector3.
  19185. * @param name Define the name of the uniform as defined in the shader
  19186. * @param value Define the value to give to the uniform
  19187. * @return the material itself allowing "fluent" like uniform updates
  19188. */
  19189. setVector3(name: string, value: Vector3): ShaderMaterial;
  19190. /**
  19191. * Set a vec4 in the shader from a Vector4.
  19192. * @param name Define the name of the uniform as defined in the shader
  19193. * @param value Define the value to give to the uniform
  19194. * @return the material itself allowing "fluent" like uniform updates
  19195. */
  19196. setVector4(name: string, value: Vector4): ShaderMaterial;
  19197. /**
  19198. * Set a mat4 in the shader from a Matrix.
  19199. * @param name Define the name of the uniform as defined in the shader
  19200. * @param value Define the value to give to the uniform
  19201. * @return the material itself allowing "fluent" like uniform updates
  19202. */
  19203. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19204. /**
  19205. * Set a mat3 in the shader from a Float32Array.
  19206. * @param name Define the name of the uniform as defined in the shader
  19207. * @param value Define the value to give to the uniform
  19208. * @return the material itself allowing "fluent" like uniform updates
  19209. */
  19210. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19211. /**
  19212. * Set a mat2 in the shader from a Float32Array.
  19213. * @param name Define the name of the uniform as defined in the shader
  19214. * @param value Define the value to give to the uniform
  19215. * @return the material itself allowing "fluent" like uniform updates
  19216. */
  19217. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19218. /**
  19219. * Set a vec2 array in the shader from a number array.
  19220. * @param name Define the name of the uniform as defined in the shader
  19221. * @param value Define the value to give to the uniform
  19222. * @return the material itself allowing "fluent" like uniform updates
  19223. */
  19224. setArray2(name: string, value: number[]): ShaderMaterial;
  19225. /**
  19226. * Set a vec3 array in the shader from a number array.
  19227. * @param name Define the name of the uniform as defined in the shader
  19228. * @param value Define the value to give to the uniform
  19229. * @return the material itself allowing "fluent" like uniform updates
  19230. */
  19231. setArray3(name: string, value: number[]): ShaderMaterial;
  19232. private _checkCache;
  19233. /**
  19234. * Checks if the material is ready to render the requested mesh
  19235. * @param mesh Define the mesh to render
  19236. * @param useInstances Define whether or not the material is used with instances
  19237. * @returns true if ready, otherwise false
  19238. */
  19239. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19240. /**
  19241. * Binds the world matrix to the material
  19242. * @param world defines the world transformation matrix
  19243. */
  19244. bindOnlyWorldMatrix(world: Matrix): void;
  19245. /**
  19246. * Binds the material to the mesh
  19247. * @param world defines the world transformation matrix
  19248. * @param mesh defines the mesh to bind the material to
  19249. */
  19250. bind(world: Matrix, mesh?: Mesh): void;
  19251. /**
  19252. * Gets the active textures from the material
  19253. * @returns an array of textures
  19254. */
  19255. getActiveTextures(): BaseTexture[];
  19256. /**
  19257. * Specifies if the material uses a texture
  19258. * @param texture defines the texture to check against the material
  19259. * @returns a boolean specifying if the material uses the texture
  19260. */
  19261. hasTexture(texture: BaseTexture): boolean;
  19262. /**
  19263. * Makes a duplicate of the material, and gives it a new name
  19264. * @param name defines the new name for the duplicated material
  19265. * @returns the cloned material
  19266. */
  19267. clone(name: string): ShaderMaterial;
  19268. /**
  19269. * Disposes the material
  19270. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19271. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19272. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19273. */
  19274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19275. /**
  19276. * Serializes this material in a JSON representation
  19277. * @returns the serialized material object
  19278. */
  19279. serialize(): any;
  19280. /**
  19281. * Creates a shader material from parsed shader material data
  19282. * @param source defines the JSON represnetation of the material
  19283. * @param scene defines the hosting scene
  19284. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19285. * @returns a new material
  19286. */
  19287. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19288. }
  19289. }
  19290. declare module BABYLON {
  19291. /** @hidden */
  19292. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19293. MAINUV1: boolean;
  19294. MAINUV2: boolean;
  19295. DIFFUSE: boolean;
  19296. DIFFUSEDIRECTUV: number;
  19297. AMBIENT: boolean;
  19298. AMBIENTDIRECTUV: number;
  19299. OPACITY: boolean;
  19300. OPACITYDIRECTUV: number;
  19301. OPACITYRGB: boolean;
  19302. REFLECTION: boolean;
  19303. EMISSIVE: boolean;
  19304. EMISSIVEDIRECTUV: number;
  19305. SPECULAR: boolean;
  19306. SPECULARDIRECTUV: number;
  19307. BUMP: boolean;
  19308. BUMPDIRECTUV: number;
  19309. PARALLAX: boolean;
  19310. PARALLAXOCCLUSION: boolean;
  19311. SPECULAROVERALPHA: boolean;
  19312. CLIPPLANE: boolean;
  19313. CLIPPLANE2: boolean;
  19314. CLIPPLANE3: boolean;
  19315. CLIPPLANE4: boolean;
  19316. ALPHATEST: boolean;
  19317. DEPTHPREPASS: boolean;
  19318. ALPHAFROMDIFFUSE: boolean;
  19319. POINTSIZE: boolean;
  19320. FOG: boolean;
  19321. SPECULARTERM: boolean;
  19322. DIFFUSEFRESNEL: boolean;
  19323. OPACITYFRESNEL: boolean;
  19324. REFLECTIONFRESNEL: boolean;
  19325. REFRACTIONFRESNEL: boolean;
  19326. EMISSIVEFRESNEL: boolean;
  19327. FRESNEL: boolean;
  19328. NORMAL: boolean;
  19329. UV1: boolean;
  19330. UV2: boolean;
  19331. VERTEXCOLOR: boolean;
  19332. VERTEXALPHA: boolean;
  19333. NUM_BONE_INFLUENCERS: number;
  19334. BonesPerMesh: number;
  19335. BONETEXTURE: boolean;
  19336. INSTANCES: boolean;
  19337. GLOSSINESS: boolean;
  19338. ROUGHNESS: boolean;
  19339. EMISSIVEASILLUMINATION: boolean;
  19340. LINKEMISSIVEWITHDIFFUSE: boolean;
  19341. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19342. LIGHTMAP: boolean;
  19343. LIGHTMAPDIRECTUV: number;
  19344. OBJECTSPACE_NORMALMAP: boolean;
  19345. USELIGHTMAPASSHADOWMAP: boolean;
  19346. REFLECTIONMAP_3D: boolean;
  19347. REFLECTIONMAP_SPHERICAL: boolean;
  19348. REFLECTIONMAP_PLANAR: boolean;
  19349. REFLECTIONMAP_CUBIC: boolean;
  19350. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19351. REFLECTIONMAP_PROJECTION: boolean;
  19352. REFLECTIONMAP_SKYBOX: boolean;
  19353. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19354. REFLECTIONMAP_EXPLICIT: boolean;
  19355. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19356. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19357. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19358. INVERTCUBICMAP: boolean;
  19359. LOGARITHMICDEPTH: boolean;
  19360. REFRACTION: boolean;
  19361. REFRACTIONMAP_3D: boolean;
  19362. REFLECTIONOVERALPHA: boolean;
  19363. TWOSIDEDLIGHTING: boolean;
  19364. SHADOWFLOAT: boolean;
  19365. MORPHTARGETS: boolean;
  19366. MORPHTARGETS_NORMAL: boolean;
  19367. MORPHTARGETS_TANGENT: boolean;
  19368. NUM_MORPH_INFLUENCERS: number;
  19369. NONUNIFORMSCALING: boolean;
  19370. PREMULTIPLYALPHA: boolean;
  19371. IMAGEPROCESSING: boolean;
  19372. VIGNETTE: boolean;
  19373. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19374. VIGNETTEBLENDMODEOPAQUE: boolean;
  19375. TONEMAPPING: boolean;
  19376. TONEMAPPING_ACES: boolean;
  19377. CONTRAST: boolean;
  19378. COLORCURVES: boolean;
  19379. COLORGRADING: boolean;
  19380. COLORGRADING3D: boolean;
  19381. SAMPLER3DGREENDEPTH: boolean;
  19382. SAMPLER3DBGRMAP: boolean;
  19383. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19384. /**
  19385. * If the reflection texture on this material is in linear color space
  19386. * @hidden
  19387. */
  19388. IS_REFLECTION_LINEAR: boolean;
  19389. /**
  19390. * If the refraction texture on this material is in linear color space
  19391. * @hidden
  19392. */
  19393. IS_REFRACTION_LINEAR: boolean;
  19394. EXPOSURE: boolean;
  19395. constructor();
  19396. setReflectionMode(modeToEnable: string): void;
  19397. }
  19398. /**
  19399. * This is the default material used in Babylon. It is the best trade off between quality
  19400. * and performances.
  19401. * @see http://doc.babylonjs.com/babylon101/materials
  19402. */
  19403. class StandardMaterial extends PushMaterial {
  19404. private _diffuseTexture;
  19405. /**
  19406. * The basic texture of the material as viewed under a light.
  19407. */
  19408. diffuseTexture: Nullable<BaseTexture>;
  19409. private _ambientTexture;
  19410. /**
  19411. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19412. */
  19413. ambientTexture: Nullable<BaseTexture>;
  19414. private _opacityTexture;
  19415. /**
  19416. * Define the transparency of the material from a texture.
  19417. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19418. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19419. */
  19420. opacityTexture: Nullable<BaseTexture>;
  19421. private _reflectionTexture;
  19422. /**
  19423. * Define the texture used to display the reflection.
  19424. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19425. */
  19426. reflectionTexture: Nullable<BaseTexture>;
  19427. private _emissiveTexture;
  19428. /**
  19429. * Define texture of the material as if self lit.
  19430. * This will be mixed in the final result even in the absence of light.
  19431. */
  19432. emissiveTexture: Nullable<BaseTexture>;
  19433. private _specularTexture;
  19434. /**
  19435. * Define how the color and intensity of the highlight given by the light in the material.
  19436. */
  19437. specularTexture: Nullable<BaseTexture>;
  19438. private _bumpTexture;
  19439. /**
  19440. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19441. * 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.
  19442. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19443. */
  19444. bumpTexture: Nullable<BaseTexture>;
  19445. private _lightmapTexture;
  19446. /**
  19447. * Complex lighting can be computationally expensive to compute at runtime.
  19448. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19449. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19450. */
  19451. lightmapTexture: Nullable<BaseTexture>;
  19452. private _refractionTexture;
  19453. /**
  19454. * Define the texture used to display the refraction.
  19455. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19456. */
  19457. refractionTexture: Nullable<BaseTexture>;
  19458. /**
  19459. * The color of the material lit by the environmental background lighting.
  19460. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19461. */
  19462. ambientColor: Color3;
  19463. /**
  19464. * The basic color of the material as viewed under a light.
  19465. */
  19466. diffuseColor: Color3;
  19467. /**
  19468. * Define how the color and intensity of the highlight given by the light in the material.
  19469. */
  19470. specularColor: Color3;
  19471. /**
  19472. * Define the color of the material as if self lit.
  19473. * This will be mixed in the final result even in the absence of light.
  19474. */
  19475. emissiveColor: Color3;
  19476. /**
  19477. * Defines how sharp are the highlights in the material.
  19478. * The bigger the value the sharper giving a more glossy feeling to the result.
  19479. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19480. */
  19481. specularPower: number;
  19482. private _useAlphaFromDiffuseTexture;
  19483. /**
  19484. * Does the transparency come from the diffuse texture alpha channel.
  19485. */
  19486. useAlphaFromDiffuseTexture: boolean;
  19487. private _useEmissiveAsIllumination;
  19488. /**
  19489. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19490. */
  19491. useEmissiveAsIllumination: boolean;
  19492. private _linkEmissiveWithDiffuse;
  19493. /**
  19494. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19495. * the emissive level when the final color is close to one.
  19496. */
  19497. linkEmissiveWithDiffuse: boolean;
  19498. private _useSpecularOverAlpha;
  19499. /**
  19500. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19501. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19502. */
  19503. useSpecularOverAlpha: boolean;
  19504. private _useReflectionOverAlpha;
  19505. /**
  19506. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19507. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19508. */
  19509. useReflectionOverAlpha: boolean;
  19510. private _disableLighting;
  19511. /**
  19512. * Does lights from the scene impacts this material.
  19513. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19514. */
  19515. disableLighting: boolean;
  19516. private _useObjectSpaceNormalMap;
  19517. /**
  19518. * Allows using an object space normal map (instead of tangent space).
  19519. */
  19520. useObjectSpaceNormalMap: boolean;
  19521. private _useParallax;
  19522. /**
  19523. * Is parallax enabled or not.
  19524. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19525. */
  19526. useParallax: boolean;
  19527. private _useParallaxOcclusion;
  19528. /**
  19529. * Is parallax occlusion enabled or not.
  19530. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19531. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19532. */
  19533. useParallaxOcclusion: boolean;
  19534. /**
  19535. * 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.
  19536. */
  19537. parallaxScaleBias: number;
  19538. private _roughness;
  19539. /**
  19540. * Helps to define how blurry the reflections should appears in the material.
  19541. */
  19542. roughness: number;
  19543. /**
  19544. * In case of refraction, define the value of the indice of refraction.
  19545. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19546. */
  19547. indexOfRefraction: number;
  19548. /**
  19549. * Invert the refraction texture alongside the y axis.
  19550. * It can be useful with procedural textures or probe for instance.
  19551. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19552. */
  19553. invertRefractionY: boolean;
  19554. /**
  19555. * Defines the alpha limits in alpha test mode.
  19556. */
  19557. alphaCutOff: number;
  19558. private _useLightmapAsShadowmap;
  19559. /**
  19560. * In case of light mapping, define whether the map contains light or shadow informations.
  19561. */
  19562. useLightmapAsShadowmap: boolean;
  19563. private _diffuseFresnelParameters;
  19564. /**
  19565. * Define the diffuse fresnel parameters of the material.
  19566. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19567. */
  19568. diffuseFresnelParameters: FresnelParameters;
  19569. private _opacityFresnelParameters;
  19570. /**
  19571. * Define the opacity fresnel parameters of the material.
  19572. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19573. */
  19574. opacityFresnelParameters: FresnelParameters;
  19575. private _reflectionFresnelParameters;
  19576. /**
  19577. * Define the reflection fresnel parameters of the material.
  19578. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19579. */
  19580. reflectionFresnelParameters: FresnelParameters;
  19581. private _refractionFresnelParameters;
  19582. /**
  19583. * Define the refraction fresnel parameters of the material.
  19584. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19585. */
  19586. refractionFresnelParameters: FresnelParameters;
  19587. private _emissiveFresnelParameters;
  19588. /**
  19589. * Define the emissive fresnel parameters of the material.
  19590. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19591. */
  19592. emissiveFresnelParameters: FresnelParameters;
  19593. private _useReflectionFresnelFromSpecular;
  19594. /**
  19595. * If true automatically deducts the fresnels values from the material specularity.
  19596. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19597. */
  19598. useReflectionFresnelFromSpecular: boolean;
  19599. private _useGlossinessFromSpecularMapAlpha;
  19600. /**
  19601. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19602. */
  19603. useGlossinessFromSpecularMapAlpha: boolean;
  19604. private _maxSimultaneousLights;
  19605. /**
  19606. * Defines the maximum number of lights that can be used in the material
  19607. */
  19608. maxSimultaneousLights: number;
  19609. private _invertNormalMapX;
  19610. /**
  19611. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19612. */
  19613. invertNormalMapX: boolean;
  19614. private _invertNormalMapY;
  19615. /**
  19616. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19617. */
  19618. invertNormalMapY: boolean;
  19619. private _twoSidedLighting;
  19620. /**
  19621. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19622. */
  19623. twoSidedLighting: boolean;
  19624. /**
  19625. * Default configuration related to image processing available in the standard Material.
  19626. */
  19627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19628. /**
  19629. * Gets the image processing configuration used either in this material.
  19630. */
  19631. /**
  19632. * Sets the Default image processing configuration used either in the this material.
  19633. *
  19634. * If sets to null, the scene one is in use.
  19635. */
  19636. imageProcessingConfiguration: ImageProcessingConfiguration;
  19637. /**
  19638. * Keep track of the image processing observer to allow dispose and replace.
  19639. */
  19640. private _imageProcessingObserver;
  19641. /**
  19642. * Attaches a new image processing configuration to the Standard Material.
  19643. * @param configuration
  19644. */
  19645. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19646. /**
  19647. * Gets wether the color curves effect is enabled.
  19648. */
  19649. /**
  19650. * Sets wether the color curves effect is enabled.
  19651. */
  19652. cameraColorCurvesEnabled: boolean;
  19653. /**
  19654. * Gets wether the color grading effect is enabled.
  19655. */
  19656. /**
  19657. * Gets wether the color grading effect is enabled.
  19658. */
  19659. cameraColorGradingEnabled: boolean;
  19660. /**
  19661. * Gets wether tonemapping is enabled or not.
  19662. */
  19663. /**
  19664. * Sets wether tonemapping is enabled or not
  19665. */
  19666. cameraToneMappingEnabled: boolean;
  19667. /**
  19668. * The camera exposure used on this material.
  19669. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19670. * This corresponds to a photographic exposure.
  19671. */
  19672. /**
  19673. * The camera exposure used on this material.
  19674. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19675. * This corresponds to a photographic exposure.
  19676. */
  19677. cameraExposure: number;
  19678. /**
  19679. * Gets The camera contrast used on this material.
  19680. */
  19681. /**
  19682. * Sets The camera contrast used on this material.
  19683. */
  19684. cameraContrast: number;
  19685. /**
  19686. * Gets the Color Grading 2D Lookup Texture.
  19687. */
  19688. /**
  19689. * Sets the Color Grading 2D Lookup Texture.
  19690. */
  19691. cameraColorGradingTexture: Nullable<BaseTexture>;
  19692. /**
  19693. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19694. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19695. * 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;
  19696. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19697. */
  19698. /**
  19699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19701. * 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;
  19702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19703. */
  19704. cameraColorCurves: Nullable<ColorCurves>;
  19705. /**
  19706. * Custom callback helping to override the default shader used in the material.
  19707. */
  19708. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19709. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19710. protected _worldViewProjectionMatrix: Matrix;
  19711. protected _globalAmbientColor: Color3;
  19712. protected _useLogarithmicDepth: boolean;
  19713. /**
  19714. * Instantiates a new standard material.
  19715. * This is the default material used in Babylon. It is the best trade off between quality
  19716. * and performances.
  19717. * @see http://doc.babylonjs.com/babylon101/materials
  19718. * @param name Define the name of the material in the scene
  19719. * @param scene Define the scene the material belong to
  19720. */
  19721. constructor(name: string, scene: Scene);
  19722. /**
  19723. * Gets a boolean indicating that current material needs to register RTT
  19724. */
  19725. readonly hasRenderTargetTextures: boolean;
  19726. /**
  19727. * Gets the current class name of the material e.g. "StandardMaterial"
  19728. * Mainly use in serialization.
  19729. * @returns the class name
  19730. */
  19731. getClassName(): string;
  19732. /**
  19733. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19734. * You can try switching to logarithmic depth.
  19735. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19736. */
  19737. useLogarithmicDepth: boolean;
  19738. /**
  19739. * Specifies if the material will require alpha blending
  19740. * @returns a boolean specifying if alpha blending is needed
  19741. */
  19742. needAlphaBlending(): boolean;
  19743. /**
  19744. * Specifies if this material should be rendered in alpha test mode
  19745. * @returns a boolean specifying if an alpha test is needed.
  19746. */
  19747. needAlphaTesting(): boolean;
  19748. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19749. /**
  19750. * Get the texture used for alpha test purpose.
  19751. * @returns the diffuse texture in case of the standard material.
  19752. */
  19753. getAlphaTestTexture(): Nullable<BaseTexture>;
  19754. /**
  19755. * Get if the submesh is ready to be used and all its information available.
  19756. * Child classes can use it to update shaders
  19757. * @param mesh defines the mesh to check
  19758. * @param subMesh defines which submesh to check
  19759. * @param useInstances specifies that instances should be used
  19760. * @returns a boolean indicating that the submesh is ready or not
  19761. */
  19762. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19763. /**
  19764. * Builds the material UBO layouts.
  19765. * Used internally during the effect preparation.
  19766. */
  19767. buildUniformLayout(): void;
  19768. /**
  19769. * Unbinds the material from the mesh
  19770. */
  19771. unbind(): void;
  19772. /**
  19773. * Binds the submesh to this material by preparing the effect and shader to draw
  19774. * @param world defines the world transformation matrix
  19775. * @param mesh defines the mesh containing the submesh
  19776. * @param subMesh defines the submesh to bind the material to
  19777. */
  19778. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19779. /**
  19780. * Get the list of animatables in the material.
  19781. * @returns the list of animatables object used in the material
  19782. */
  19783. getAnimatables(): IAnimatable[];
  19784. /**
  19785. * Gets the active textures from the material
  19786. * @returns an array of textures
  19787. */
  19788. getActiveTextures(): BaseTexture[];
  19789. /**
  19790. * Specifies if the material uses a texture
  19791. * @param texture defines the texture to check against the material
  19792. * @returns a boolean specifying if the material uses the texture
  19793. */
  19794. hasTexture(texture: BaseTexture): boolean;
  19795. /**
  19796. * Disposes the material
  19797. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19798. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19799. */
  19800. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19801. /**
  19802. * Makes a duplicate of the material, and gives it a new name
  19803. * @param name defines the new name for the duplicated material
  19804. * @returns the cloned material
  19805. */
  19806. clone(name: string): StandardMaterial;
  19807. /**
  19808. * Serializes this material in a JSON representation
  19809. * @returns the serialized material object
  19810. */
  19811. serialize(): any;
  19812. /**
  19813. * Creates a standard material from parsed material data
  19814. * @param source defines the JSON representation of the material
  19815. * @param scene defines the hosting scene
  19816. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19817. * @returns a new standard material
  19818. */
  19819. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19820. private static _DiffuseTextureEnabled;
  19821. /**
  19822. * Are diffuse textures enabled in the application.
  19823. */
  19824. static DiffuseTextureEnabled: boolean;
  19825. private static _AmbientTextureEnabled;
  19826. /**
  19827. * Are ambient textures enabled in the application.
  19828. */
  19829. static AmbientTextureEnabled: boolean;
  19830. private static _OpacityTextureEnabled;
  19831. /**
  19832. * Are opacity textures enabled in the application.
  19833. */
  19834. static OpacityTextureEnabled: boolean;
  19835. private static _ReflectionTextureEnabled;
  19836. /**
  19837. * Are reflection textures enabled in the application.
  19838. */
  19839. static ReflectionTextureEnabled: boolean;
  19840. private static _EmissiveTextureEnabled;
  19841. /**
  19842. * Are emissive textures enabled in the application.
  19843. */
  19844. static EmissiveTextureEnabled: boolean;
  19845. private static _SpecularTextureEnabled;
  19846. /**
  19847. * Are specular textures enabled in the application.
  19848. */
  19849. static SpecularTextureEnabled: boolean;
  19850. private static _BumpTextureEnabled;
  19851. /**
  19852. * Are bump textures enabled in the application.
  19853. */
  19854. static BumpTextureEnabled: boolean;
  19855. private static _LightmapTextureEnabled;
  19856. /**
  19857. * Are lightmap textures enabled in the application.
  19858. */
  19859. static LightmapTextureEnabled: boolean;
  19860. private static _RefractionTextureEnabled;
  19861. /**
  19862. * Are refraction textures enabled in the application.
  19863. */
  19864. static RefractionTextureEnabled: boolean;
  19865. private static _ColorGradingTextureEnabled;
  19866. /**
  19867. * Are color grading textures enabled in the application.
  19868. */
  19869. static ColorGradingTextureEnabled: boolean;
  19870. private static _FresnelEnabled;
  19871. /**
  19872. * Are fresnels enabled in the application.
  19873. */
  19874. static FresnelEnabled: boolean;
  19875. }
  19876. }
  19877. declare module BABYLON {
  19878. /**
  19879. * Uniform buffer objects.
  19880. *
  19881. * Handles blocks of uniform on the GPU.
  19882. *
  19883. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19884. *
  19885. * For more information, please refer to :
  19886. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19887. */
  19888. class UniformBuffer {
  19889. private _engine;
  19890. private _buffer;
  19891. private _data;
  19892. private _bufferData;
  19893. private _dynamic?;
  19894. private _uniformLocations;
  19895. private _uniformSizes;
  19896. private _uniformLocationPointer;
  19897. private _needSync;
  19898. private _noUBO;
  19899. private _currentEffect;
  19900. private static _MAX_UNIFORM_SIZE;
  19901. private static _tempBuffer;
  19902. /**
  19903. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19904. * This is dynamic to allow compat with webgl 1 and 2.
  19905. * You will need to pass the name of the uniform as well as the value.
  19906. */
  19907. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19908. /**
  19909. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19910. * This is dynamic to allow compat with webgl 1 and 2.
  19911. * You will need to pass the name of the uniform as well as the value.
  19912. */
  19913. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19914. /**
  19915. * Lambda to Update a single float in a uniform buffer.
  19916. * This is dynamic to allow compat with webgl 1 and 2.
  19917. * You will need to pass the name of the uniform as well as the value.
  19918. */
  19919. updateFloat: (name: string, x: number) => void;
  19920. /**
  19921. * Lambda to Update a vec2 of float in a uniform buffer.
  19922. * This is dynamic to allow compat with webgl 1 and 2.
  19923. * You will need to pass the name of the uniform as well as the value.
  19924. */
  19925. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19926. /**
  19927. * Lambda to Update a vec3 of float in a uniform buffer.
  19928. * This is dynamic to allow compat with webgl 1 and 2.
  19929. * You will need to pass the name of the uniform as well as the value.
  19930. */
  19931. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19932. /**
  19933. * Lambda to Update a vec4 of float in a uniform buffer.
  19934. * This is dynamic to allow compat with webgl 1 and 2.
  19935. * You will need to pass the name of the uniform as well as the value.
  19936. */
  19937. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19938. /**
  19939. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19940. * This is dynamic to allow compat with webgl 1 and 2.
  19941. * You will need to pass the name of the uniform as well as the value.
  19942. */
  19943. updateMatrix: (name: string, mat: Matrix) => void;
  19944. /**
  19945. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19946. * This is dynamic to allow compat with webgl 1 and 2.
  19947. * You will need to pass the name of the uniform as well as the value.
  19948. */
  19949. updateVector3: (name: string, vector: Vector3) => void;
  19950. /**
  19951. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19952. * This is dynamic to allow compat with webgl 1 and 2.
  19953. * You will need to pass the name of the uniform as well as the value.
  19954. */
  19955. updateVector4: (name: string, vector: Vector4) => void;
  19956. /**
  19957. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19958. * This is dynamic to allow compat with webgl 1 and 2.
  19959. * You will need to pass the name of the uniform as well as the value.
  19960. */
  19961. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19962. /**
  19963. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19964. * This is dynamic to allow compat with webgl 1 and 2.
  19965. * You will need to pass the name of the uniform as well as the value.
  19966. */
  19967. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19968. /**
  19969. * Instantiates a new Uniform buffer objects.
  19970. *
  19971. * Handles blocks of uniform on the GPU.
  19972. *
  19973. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19974. *
  19975. * For more information, please refer to :
  19976. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19977. * @param engine Define the engine the buffer is associated with
  19978. * @param data Define the data contained in the buffer
  19979. * @param dynamic Define if the buffer is updatable
  19980. */
  19981. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19982. /**
  19983. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19984. * or just falling back on setUniformXXX calls.
  19985. */
  19986. readonly useUbo: boolean;
  19987. /**
  19988. * Indicates if the WebGL underlying uniform buffer is in sync
  19989. * with the javascript cache data.
  19990. */
  19991. readonly isSync: boolean;
  19992. /**
  19993. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19994. * Also, a dynamic UniformBuffer will disable cache verification and always
  19995. * update the underlying WebGL uniform buffer to the GPU.
  19996. * @returns if Dynamic, otherwise false
  19997. */
  19998. isDynamic(): boolean;
  19999. /**
  20000. * The data cache on JS side.
  20001. * @returns the underlying data as a float array
  20002. */
  20003. getData(): Float32Array;
  20004. /**
  20005. * The underlying WebGL Uniform buffer.
  20006. * @returns the webgl buffer
  20007. */
  20008. getBuffer(): Nullable<WebGLBuffer>;
  20009. /**
  20010. * std140 layout specifies how to align data within an UBO structure.
  20011. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  20012. * for specs.
  20013. */
  20014. private _fillAlignment;
  20015. /**
  20016. * Adds an uniform in the buffer.
  20017. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  20018. * for the layout to be correct !
  20019. * @param name Name of the uniform, as used in the uniform block in the shader.
  20020. * @param size Data size, or data directly.
  20021. */
  20022. addUniform(name: string, size: number | number[]): void;
  20023. /**
  20024. * Adds a Matrix 4x4 to the uniform buffer.
  20025. * @param name Name of the uniform, as used in the uniform block in the shader.
  20026. * @param mat A 4x4 matrix.
  20027. */
  20028. addMatrix(name: string, mat: Matrix): void;
  20029. /**
  20030. * Adds a vec2 to the uniform buffer.
  20031. * @param name Name of the uniform, as used in the uniform block in the shader.
  20032. * @param x Define the x component value of the vec2
  20033. * @param y Define the y component value of the vec2
  20034. */
  20035. addFloat2(name: string, x: number, y: number): void;
  20036. /**
  20037. * Adds a vec3 to the uniform buffer.
  20038. * @param name Name of the uniform, as used in the uniform block in the shader.
  20039. * @param x Define the x component value of the vec3
  20040. * @param y Define the y component value of the vec3
  20041. * @param z Define the z component value of the vec3
  20042. */
  20043. addFloat3(name: string, x: number, y: number, z: number): void;
  20044. /**
  20045. * Adds a vec3 to the uniform buffer.
  20046. * @param name Name of the uniform, as used in the uniform block in the shader.
  20047. * @param color Define the vec3 from a Color
  20048. */
  20049. addColor3(name: string, color: Color3): void;
  20050. /**
  20051. * Adds a vec4 to the uniform buffer.
  20052. * @param name Name of the uniform, as used in the uniform block in the shader.
  20053. * @param color Define the rgb components from a Color
  20054. * @param alpha Define the a component of the vec4
  20055. */
  20056. addColor4(name: string, color: Color3, alpha: number): void;
  20057. /**
  20058. * Adds a vec3 to the uniform buffer.
  20059. * @param name Name of the uniform, as used in the uniform block in the shader.
  20060. * @param vector Define the vec3 components from a Vector
  20061. */
  20062. addVector3(name: string, vector: Vector3): void;
  20063. /**
  20064. * Adds a Matrix 3x3 to the uniform buffer.
  20065. * @param name Name of the uniform, as used in the uniform block in the shader.
  20066. */
  20067. addMatrix3x3(name: string): void;
  20068. /**
  20069. * Adds a Matrix 2x2 to the uniform buffer.
  20070. * @param name Name of the uniform, as used in the uniform block in the shader.
  20071. */
  20072. addMatrix2x2(name: string): void;
  20073. /**
  20074. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  20075. */
  20076. create(): void;
  20077. /** @hidden */
  20078. _rebuild(): void;
  20079. /**
  20080. * Updates the WebGL Uniform Buffer on the GPU.
  20081. * If the `dynamic` flag is set to true, no cache comparison is done.
  20082. * Otherwise, the buffer will be updated only if the cache differs.
  20083. */
  20084. update(): void;
  20085. /**
  20086. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  20087. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20088. * @param data Define the flattened data
  20089. * @param size Define the size of the data.
  20090. */
  20091. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  20092. private _updateMatrix3x3ForUniform;
  20093. private _updateMatrix3x3ForEffect;
  20094. private _updateMatrix2x2ForEffect;
  20095. private _updateMatrix2x2ForUniform;
  20096. private _updateFloatForEffect;
  20097. private _updateFloatForUniform;
  20098. private _updateFloat2ForEffect;
  20099. private _updateFloat2ForUniform;
  20100. private _updateFloat3ForEffect;
  20101. private _updateFloat3ForUniform;
  20102. private _updateFloat4ForEffect;
  20103. private _updateFloat4ForUniform;
  20104. private _updateMatrixForEffect;
  20105. private _updateMatrixForUniform;
  20106. private _updateVector3ForEffect;
  20107. private _updateVector3ForUniform;
  20108. private _updateVector4ForEffect;
  20109. private _updateVector4ForUniform;
  20110. private _updateColor3ForEffect;
  20111. private _updateColor3ForUniform;
  20112. private _updateColor4ForEffect;
  20113. private _updateColor4ForUniform;
  20114. /**
  20115. * Sets a sampler uniform on the effect.
  20116. * @param name Define the name of the sampler.
  20117. * @param texture Define the texture to set in the sampler
  20118. */
  20119. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  20120. /**
  20121. * Directly updates the value of the uniform in the cache AND on the GPU.
  20122. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20123. * @param data Define the flattened data
  20124. */
  20125. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  20126. /**
  20127. * Binds this uniform buffer to an effect.
  20128. * @param effect Define the effect to bind the buffer to
  20129. * @param name Name of the uniform block in the shader.
  20130. */
  20131. bindToEffect(effect: Effect, name: string): void;
  20132. /**
  20133. * Disposes the uniform buffer.
  20134. */
  20135. dispose(): void;
  20136. }
  20137. }
  20138. declare module BABYLON {
  20139. /**
  20140. * Scalar computation library
  20141. */
  20142. class Scalar {
  20143. /**
  20144. * Two pi constants convenient for computation.
  20145. */
  20146. static TwoPi: number;
  20147. /**
  20148. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20149. * @param a number
  20150. * @param b number
  20151. * @param epsilon (default = 1.401298E-45)
  20152. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20153. */
  20154. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20155. /**
  20156. * Returns a string : the upper case translation of the number i to hexadecimal.
  20157. * @param i number
  20158. * @returns the upper case translation of the number i to hexadecimal.
  20159. */
  20160. static ToHex(i: number): string;
  20161. /**
  20162. * Returns -1 if value is negative and +1 is value is positive.
  20163. * @param value the value
  20164. * @returns the value itself if it's equal to zero.
  20165. */
  20166. static Sign(value: number): number;
  20167. /**
  20168. * Returns the value itself if it's between min and max.
  20169. * Returns min if the value is lower than min.
  20170. * Returns max if the value is greater than max.
  20171. * @param value the value to clmap
  20172. * @param min the min value to clamp to (default: 0)
  20173. * @param max the max value to clamp to (default: 1)
  20174. * @returns the clamped value
  20175. */
  20176. static Clamp(value: number, min?: number, max?: number): number;
  20177. /**
  20178. * the log2 of value.
  20179. * @param value the value to compute log2 of
  20180. * @returns the log2 of value.
  20181. */
  20182. static Log2(value: number): number;
  20183. /**
  20184. * Loops the value, so that it is never larger than length and never smaller than 0.
  20185. *
  20186. * This is similar to the modulo operator but it works with floating point numbers.
  20187. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20188. * With t = 5 and length = 2.5, the result would be 0.0.
  20189. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20190. * @param value the value
  20191. * @param length the length
  20192. * @returns the looped value
  20193. */
  20194. static Repeat(value: number, length: number): number;
  20195. /**
  20196. * Normalize the value between 0.0 and 1.0 using min and max values
  20197. * @param value value to normalize
  20198. * @param min max to normalize between
  20199. * @param max min to normalize between
  20200. * @returns the normalized value
  20201. */
  20202. static Normalize(value: number, min: number, max: number): number;
  20203. /**
  20204. * Denormalize the value from 0.0 and 1.0 using min and max values
  20205. * @param normalized value to denormalize
  20206. * @param min max to denormalize between
  20207. * @param max min to denormalize between
  20208. * @returns the denormalized value
  20209. */
  20210. static Denormalize(normalized: number, min: number, max: number): number;
  20211. /**
  20212. * Calculates the shortest difference between two given angles given in degrees.
  20213. * @param current current angle in degrees
  20214. * @param target target angle in degrees
  20215. * @returns the delta
  20216. */
  20217. static DeltaAngle(current: number, target: number): number;
  20218. /**
  20219. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20220. * @param tx value
  20221. * @param length length
  20222. * @returns The returned value will move back and forth between 0 and length
  20223. */
  20224. static PingPong(tx: number, length: number): number;
  20225. /**
  20226. * Interpolates between min and max with smoothing at the limits.
  20227. *
  20228. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20229. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20230. * @param from from
  20231. * @param to to
  20232. * @param tx value
  20233. * @returns the smooth stepped value
  20234. */
  20235. static SmoothStep(from: number, to: number, tx: number): number;
  20236. /**
  20237. * Moves a value current towards target.
  20238. *
  20239. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20240. * Negative values of maxDelta pushes the value away from target.
  20241. * @param current current value
  20242. * @param target target value
  20243. * @param maxDelta max distance to move
  20244. * @returns resulting value
  20245. */
  20246. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20247. /**
  20248. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20249. *
  20250. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20251. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20252. * @param current current value
  20253. * @param target target value
  20254. * @param maxDelta max distance to move
  20255. * @returns resulting angle
  20256. */
  20257. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20258. /**
  20259. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20260. * @param start start value
  20261. * @param end target value
  20262. * @param amount amount to lerp between
  20263. * @returns the lerped value
  20264. */
  20265. static Lerp(start: number, end: number, amount: number): number;
  20266. /**
  20267. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20268. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20269. * @param start start value
  20270. * @param end target value
  20271. * @param amount amount to lerp between
  20272. * @returns the lerped value
  20273. */
  20274. static LerpAngle(start: number, end: number, amount: number): number;
  20275. /**
  20276. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20277. * @param a start value
  20278. * @param b target value
  20279. * @param value value between a and b
  20280. * @returns the inverseLerp value
  20281. */
  20282. static InverseLerp(a: number, b: number, value: number): number;
  20283. /**
  20284. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20285. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20286. * @param value1 spline value
  20287. * @param tangent1 spline value
  20288. * @param value2 spline value
  20289. * @param tangent2 spline value
  20290. * @param amount input value
  20291. * @returns hermite result
  20292. */
  20293. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20294. /**
  20295. * Returns a random float number between and min and max values
  20296. * @param min min value of random
  20297. * @param max max value of random
  20298. * @returns random value
  20299. */
  20300. static RandomRange(min: number, max: number): number;
  20301. /**
  20302. * This function returns percentage of a number in a given range.
  20303. *
  20304. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20305. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20306. * @param number to convert to percentage
  20307. * @param min min range
  20308. * @param max max range
  20309. * @returns the percentage
  20310. */
  20311. static RangeToPercent(number: number, min: number, max: number): number;
  20312. /**
  20313. * This function returns number that corresponds to the percentage in a given range.
  20314. *
  20315. * PercentToRange(0.34,0,100) will return 34.
  20316. * @param percent to convert to number
  20317. * @param min min range
  20318. * @param max max range
  20319. * @returns the number
  20320. */
  20321. static PercentToRange(percent: number, min: number, max: number): number;
  20322. /**
  20323. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20324. * @param angle The angle to normalize in radian.
  20325. * @return The converted angle.
  20326. */
  20327. static NormalizeRadians(angle: number): number;
  20328. }
  20329. }
  20330. declare module BABYLON {
  20331. /**
  20332. * Constant used to convert a value to gamma space
  20333. * @ignorenaming
  20334. */
  20335. const ToGammaSpace: number;
  20336. /**
  20337. * Constant used to convert a value to linear space
  20338. * @ignorenaming
  20339. */
  20340. const ToLinearSpace = 2.2;
  20341. /**
  20342. * Constant used to define the minimal number value in Babylon.js
  20343. * @ignorenaming
  20344. */
  20345. const Epsilon = 0.001;
  20346. /**
  20347. * Class used to hold a RBG color
  20348. */
  20349. class Color3 {
  20350. /**
  20351. * Defines the red component (between 0 and 1, default is 0)
  20352. */
  20353. r: number;
  20354. /**
  20355. * Defines the green component (between 0 and 1, default is 0)
  20356. */
  20357. g: number;
  20358. /**
  20359. * Defines the blue component (between 0 and 1, default is 0)
  20360. */
  20361. b: number;
  20362. /**
  20363. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20364. * @param r defines the red component (between 0 and 1, default is 0)
  20365. * @param g defines the green component (between 0 and 1, default is 0)
  20366. * @param b defines the blue component (between 0 and 1, default is 0)
  20367. */
  20368. constructor(
  20369. /**
  20370. * Defines the red component (between 0 and 1, default is 0)
  20371. */
  20372. r?: number,
  20373. /**
  20374. * Defines the green component (between 0 and 1, default is 0)
  20375. */
  20376. g?: number,
  20377. /**
  20378. * Defines the blue component (between 0 and 1, default is 0)
  20379. */
  20380. b?: number);
  20381. /**
  20382. * Creates a string with the Color3 current values
  20383. * @returns the string representation of the Color3 object
  20384. */
  20385. toString(): string;
  20386. /**
  20387. * Returns the string "Color3"
  20388. * @returns "Color3"
  20389. */
  20390. getClassName(): string;
  20391. /**
  20392. * Compute the Color3 hash code
  20393. * @returns an unique number that can be used to hash Color3 objects
  20394. */
  20395. getHashCode(): number;
  20396. /**
  20397. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20398. * @param array defines the array where to store the r,g,b components
  20399. * @param index defines an optional index in the target array to define where to start storing values
  20400. * @returns the current Color3 object
  20401. */
  20402. toArray(array: FloatArray, index?: number): Color3;
  20403. /**
  20404. * Returns a new Color4 object from the current Color3 and the given alpha
  20405. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20406. * @returns a new Color4 object
  20407. */
  20408. toColor4(alpha?: number): Color4;
  20409. /**
  20410. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20411. * @returns the new array
  20412. */
  20413. asArray(): number[];
  20414. /**
  20415. * Returns the luminance value
  20416. * @returns a float value
  20417. */
  20418. toLuminance(): number;
  20419. /**
  20420. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20421. * @param otherColor defines the second operand
  20422. * @returns the new Color3 object
  20423. */
  20424. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20425. /**
  20426. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20427. * @param otherColor defines the second operand
  20428. * @param result defines the Color3 object where to store the result
  20429. * @returns the current Color3
  20430. */
  20431. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20432. /**
  20433. * Determines equality between Color3 objects
  20434. * @param otherColor defines the second operand
  20435. * @returns true if the rgb values are equal to the given ones
  20436. */
  20437. equals(otherColor: DeepImmutable<Color3>): boolean;
  20438. /**
  20439. * Determines equality between the current Color3 object and a set of r,b,g values
  20440. * @param r defines the red component to check
  20441. * @param g defines the green component to check
  20442. * @param b defines the blue component to check
  20443. * @returns true if the rgb values are equal to the given ones
  20444. */
  20445. equalsFloats(r: number, g: number, b: number): boolean;
  20446. /**
  20447. * Multiplies in place each rgb value by scale
  20448. * @param scale defines the scaling factor
  20449. * @returns the updated Color3
  20450. */
  20451. scale(scale: number): Color3;
  20452. /**
  20453. * Multiplies the rgb values by scale and stores the result into "result"
  20454. * @param scale defines the scaling factor
  20455. * @param result defines the Color3 object where to store the result
  20456. * @returns the unmodified current Color3
  20457. */
  20458. scaleToRef(scale: number, result: Color3): Color3;
  20459. /**
  20460. * Scale the current Color3 values by a factor and add the result to a given Color3
  20461. * @param scale defines the scale factor
  20462. * @param result defines color to store the result into
  20463. * @returns the unmodified current Color3
  20464. */
  20465. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20466. /**
  20467. * Clamps the rgb values by the min and max values and stores the result into "result"
  20468. * @param min defines minimum clamping value (default is 0)
  20469. * @param max defines maximum clamping value (default is 1)
  20470. * @param result defines color to store the result into
  20471. * @returns the original Color3
  20472. */
  20473. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20474. /**
  20475. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20476. * @param otherColor defines the second operand
  20477. * @returns the new Color3
  20478. */
  20479. add(otherColor: DeepImmutable<Color3>): Color3;
  20480. /**
  20481. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20482. * @param otherColor defines the second operand
  20483. * @param result defines Color3 object to store the result into
  20484. * @returns the unmodified current Color3
  20485. */
  20486. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20487. /**
  20488. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20489. * @param otherColor defines the second operand
  20490. * @returns the new Color3
  20491. */
  20492. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20493. /**
  20494. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20495. * @param otherColor defines the second operand
  20496. * @param result defines Color3 object to store the result into
  20497. * @returns the unmodified current Color3
  20498. */
  20499. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20500. /**
  20501. * Copy the current object
  20502. * @returns a new Color3 copied the current one
  20503. */
  20504. clone(): Color3;
  20505. /**
  20506. * Copies the rgb values from the source in the current Color3
  20507. * @param source defines the source Color3 object
  20508. * @returns the updated Color3 object
  20509. */
  20510. copyFrom(source: DeepImmutable<Color3>): Color3;
  20511. /**
  20512. * Updates the Color3 rgb values from the given floats
  20513. * @param r defines the red component to read from
  20514. * @param g defines the green component to read from
  20515. * @param b defines the blue component to read from
  20516. * @returns the current Color3 object
  20517. */
  20518. copyFromFloats(r: number, g: number, b: number): Color3;
  20519. /**
  20520. * Updates the Color3 rgb values from the given floats
  20521. * @param r defines the red component to read from
  20522. * @param g defines the green component to read from
  20523. * @param b defines the blue component to read from
  20524. * @returns the current Color3 object
  20525. */
  20526. set(r: number, g: number, b: number): Color3;
  20527. /**
  20528. * Compute the Color3 hexadecimal code as a string
  20529. * @returns a string containing the hexadecimal representation of the Color3 object
  20530. */
  20531. toHexString(): string;
  20532. /**
  20533. * Computes a new Color3 converted from the current one to linear space
  20534. * @returns a new Color3 object
  20535. */
  20536. toLinearSpace(): Color3;
  20537. /**
  20538. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20539. * @param convertedColor defines the Color3 object where to store the linear space version
  20540. * @returns the unmodified Color3
  20541. */
  20542. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20543. /**
  20544. * Computes a new Color3 converted from the current one to gamma space
  20545. * @returns a new Color3 object
  20546. */
  20547. toGammaSpace(): Color3;
  20548. /**
  20549. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20550. * @param convertedColor defines the Color3 object where to store the gamma space version
  20551. * @returns the unmodified Color3
  20552. */
  20553. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20554. /**
  20555. * Creates a new Color3 from the string containing valid hexadecimal values
  20556. * @param hex defines a string containing valid hexadecimal values
  20557. * @returns a new Color3 object
  20558. */
  20559. static FromHexString(hex: string): Color3;
  20560. /**
  20561. * Creates a new Vector3 from the starting index of the given array
  20562. * @param array defines the source array
  20563. * @param offset defines an offset in the source array
  20564. * @returns a new Color3 object
  20565. */
  20566. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20567. /**
  20568. * Creates a new Color3 from integer values (< 256)
  20569. * @param r defines the red component to read from (value between 0 and 255)
  20570. * @param g defines the green component to read from (value between 0 and 255)
  20571. * @param b defines the blue component to read from (value between 0 and 255)
  20572. * @returns a new Color3 object
  20573. */
  20574. static FromInts(r: number, g: number, b: number): Color3;
  20575. /**
  20576. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20577. * @param start defines the start Color3 value
  20578. * @param end defines the end Color3 value
  20579. * @param amount defines the gradient value between start and end
  20580. * @returns a new Color3 object
  20581. */
  20582. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20583. /**
  20584. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20585. * @param left defines the start value
  20586. * @param right defines the end value
  20587. * @param amount defines the gradient factor
  20588. * @param result defines the Color3 object where to store the result
  20589. */
  20590. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20591. /**
  20592. * Returns a Color3 value containing a red color
  20593. * @returns a new Color3 object
  20594. */
  20595. static Red(): Color3;
  20596. /**
  20597. * Returns a Color3 value containing a green color
  20598. * @returns a new Color3 object
  20599. */
  20600. static Green(): Color3;
  20601. /**
  20602. * Returns a Color3 value containing a blue color
  20603. * @returns a new Color3 object
  20604. */
  20605. static Blue(): Color3;
  20606. /**
  20607. * Returns a Color3 value containing a black color
  20608. * @returns a new Color3 object
  20609. */
  20610. static Black(): Color3;
  20611. /**
  20612. * Returns a Color3 value containing a white color
  20613. * @returns a new Color3 object
  20614. */
  20615. static White(): Color3;
  20616. /**
  20617. * Returns a Color3 value containing a purple color
  20618. * @returns a new Color3 object
  20619. */
  20620. static Purple(): Color3;
  20621. /**
  20622. * Returns a Color3 value containing a magenta color
  20623. * @returns a new Color3 object
  20624. */
  20625. static Magenta(): Color3;
  20626. /**
  20627. * Returns a Color3 value containing a yellow color
  20628. * @returns a new Color3 object
  20629. */
  20630. static Yellow(): Color3;
  20631. /**
  20632. * Returns a Color3 value containing a gray color
  20633. * @returns a new Color3 object
  20634. */
  20635. static Gray(): Color3;
  20636. /**
  20637. * Returns a Color3 value containing a teal color
  20638. * @returns a new Color3 object
  20639. */
  20640. static Teal(): Color3;
  20641. /**
  20642. * Returns a Color3 value containing a random color
  20643. * @returns a new Color3 object
  20644. */
  20645. static Random(): Color3;
  20646. }
  20647. /**
  20648. * Class used to hold a RBGA color
  20649. */
  20650. class Color4 {
  20651. /**
  20652. * Defines the red component (between 0 and 1, default is 0)
  20653. */
  20654. r: number;
  20655. /**
  20656. * Defines the green component (between 0 and 1, default is 0)
  20657. */
  20658. g: number;
  20659. /**
  20660. * Defines the blue component (between 0 and 1, default is 0)
  20661. */
  20662. b: number;
  20663. /**
  20664. * Defines the alpha component (between 0 and 1, default is 1)
  20665. */
  20666. a: number;
  20667. /**
  20668. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20669. * @param r defines the red component (between 0 and 1, default is 0)
  20670. * @param g defines the green component (between 0 and 1, default is 0)
  20671. * @param b defines the blue component (between 0 and 1, default is 0)
  20672. * @param a defines the alpha component (between 0 and 1, default is 1)
  20673. */
  20674. constructor(
  20675. /**
  20676. * Defines the red component (between 0 and 1, default is 0)
  20677. */
  20678. r?: number,
  20679. /**
  20680. * Defines the green component (between 0 and 1, default is 0)
  20681. */
  20682. g?: number,
  20683. /**
  20684. * Defines the blue component (between 0 and 1, default is 0)
  20685. */
  20686. b?: number,
  20687. /**
  20688. * Defines the alpha component (between 0 and 1, default is 1)
  20689. */
  20690. a?: number);
  20691. /**
  20692. * Adds in place the given Color4 values to the current Color4 object
  20693. * @param right defines the second operand
  20694. * @returns the current updated Color4 object
  20695. */
  20696. addInPlace(right: DeepImmutable<Color4>): Color4;
  20697. /**
  20698. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20699. * @returns the new array
  20700. */
  20701. asArray(): number[];
  20702. /**
  20703. * Stores from the starting index in the given array the Color4 successive values
  20704. * @param array defines the array where to store the r,g,b components
  20705. * @param index defines an optional index in the target array to define where to start storing values
  20706. * @returns the current Color4 object
  20707. */
  20708. toArray(array: number[], index?: number): Color4;
  20709. /**
  20710. * Determines equality between Color4 objects
  20711. * @param otherColor defines the second operand
  20712. * @returns true if the rgba values are equal to the given ones
  20713. */
  20714. equals(otherColor: DeepImmutable<Color4>): boolean;
  20715. /**
  20716. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20717. * @param right defines the second operand
  20718. * @returns a new Color4 object
  20719. */
  20720. add(right: DeepImmutable<Color4>): Color4;
  20721. /**
  20722. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20723. * @param right defines the second operand
  20724. * @returns a new Color4 object
  20725. */
  20726. subtract(right: DeepImmutable<Color4>): Color4;
  20727. /**
  20728. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20729. * @param right defines the second operand
  20730. * @param result defines the Color4 object where to store the result
  20731. * @returns the current Color4 object
  20732. */
  20733. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20734. /**
  20735. * Creates a new Color4 with the current Color4 values multiplied by scale
  20736. * @param scale defines the scaling factor to apply
  20737. * @returns a new Color4 object
  20738. */
  20739. scale(scale: number): Color4;
  20740. /**
  20741. * Multiplies the current Color4 values by scale and stores the result in "result"
  20742. * @param scale defines the scaling factor to apply
  20743. * @param result defines the Color4 object where to store the result
  20744. * @returns the current unmodified Color4
  20745. */
  20746. scaleToRef(scale: number, result: Color4): Color4;
  20747. /**
  20748. * Scale the current Color4 values by a factor and add the result to a given Color4
  20749. * @param scale defines the scale factor
  20750. * @param result defines the Color4 object where to store the result
  20751. * @returns the unmodified current Color4
  20752. */
  20753. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20754. /**
  20755. * Clamps the rgb values by the min and max values and stores the result into "result"
  20756. * @param min defines minimum clamping value (default is 0)
  20757. * @param max defines maximum clamping value (default is 1)
  20758. * @param result defines color to store the result into.
  20759. * @returns the cuurent Color4
  20760. */
  20761. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20762. /**
  20763. * Multipy an Color4 value by another and return a new Color4 object
  20764. * @param color defines the Color4 value to multiply by
  20765. * @returns a new Color4 object
  20766. */
  20767. multiply(color: Color4): Color4;
  20768. /**
  20769. * Multipy a Color4 value by another and push the result in a reference value
  20770. * @param color defines the Color4 value to multiply by
  20771. * @param result defines the Color4 to fill the result in
  20772. * @returns the result Color4
  20773. */
  20774. multiplyToRef(color: Color4, result: Color4): Color4;
  20775. /**
  20776. * Creates a string with the Color4 current values
  20777. * @returns the string representation of the Color4 object
  20778. */
  20779. toString(): string;
  20780. /**
  20781. * Returns the string "Color4"
  20782. * @returns "Color4"
  20783. */
  20784. getClassName(): string;
  20785. /**
  20786. * Compute the Color4 hash code
  20787. * @returns an unique number that can be used to hash Color4 objects
  20788. */
  20789. getHashCode(): number;
  20790. /**
  20791. * Creates a new Color4 copied from the current one
  20792. * @returns a new Color4 object
  20793. */
  20794. clone(): Color4;
  20795. /**
  20796. * Copies the given Color4 values into the current one
  20797. * @param source defines the source Color4 object
  20798. * @returns the current updated Color4 object
  20799. */
  20800. copyFrom(source: Color4): Color4;
  20801. /**
  20802. * Copies the given float values into the current one
  20803. * @param r defines the red component to read from
  20804. * @param g defines the green component to read from
  20805. * @param b defines the blue component to read from
  20806. * @param a defines the alpha component to read from
  20807. * @returns the current updated Color4 object
  20808. */
  20809. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20810. /**
  20811. * Copies the given float values into the current one
  20812. * @param r defines the red component to read from
  20813. * @param g defines the green component to read from
  20814. * @param b defines the blue component to read from
  20815. * @param a defines the alpha component to read from
  20816. * @returns the current updated Color4 object
  20817. */
  20818. set(r: number, g: number, b: number, a: number): Color4;
  20819. /**
  20820. * Compute the Color4 hexadecimal code as a string
  20821. * @returns a string containing the hexadecimal representation of the Color4 object
  20822. */
  20823. toHexString(): string;
  20824. /**
  20825. * Computes a new Color4 converted from the current one to linear space
  20826. * @returns a new Color4 object
  20827. */
  20828. toLinearSpace(): Color4;
  20829. /**
  20830. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20831. * @param convertedColor defines the Color4 object where to store the linear space version
  20832. * @returns the unmodified Color4
  20833. */
  20834. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20835. /**
  20836. * Computes a new Color4 converted from the current one to gamma space
  20837. * @returns a new Color4 object
  20838. */
  20839. toGammaSpace(): Color4;
  20840. /**
  20841. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20842. * @param convertedColor defines the Color4 object where to store the gamma space version
  20843. * @returns the unmodified Color4
  20844. */
  20845. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20846. /**
  20847. * Creates a new Color4 from the string containing valid hexadecimal values
  20848. * @param hex defines a string containing valid hexadecimal values
  20849. * @returns a new Color4 object
  20850. */
  20851. static FromHexString(hex: string): Color4;
  20852. /**
  20853. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20854. * @param left defines the start value
  20855. * @param right defines the end value
  20856. * @param amount defines the gradient factor
  20857. * @returns a new Color4 object
  20858. */
  20859. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20860. /**
  20861. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20862. * @param left defines the start value
  20863. * @param right defines the end value
  20864. * @param amount defines the gradient factor
  20865. * @param result defines the Color4 object where to store data
  20866. */
  20867. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20868. /**
  20869. * Creates a new Color4 from a Color3 and an alpha value
  20870. * @param color3 defines the source Color3 to read from
  20871. * @param alpha defines the alpha component (1.0 by default)
  20872. * @returns a new Color4 object
  20873. */
  20874. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20875. /**
  20876. * Creates a new Color4 from the starting index element of the given array
  20877. * @param array defines the source array to read from
  20878. * @param offset defines the offset in the source array
  20879. * @returns a new Color4 object
  20880. */
  20881. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20882. /**
  20883. * Creates a new Color3 from integer values (< 256)
  20884. * @param r defines the red component to read from (value between 0 and 255)
  20885. * @param g defines the green component to read from (value between 0 and 255)
  20886. * @param b defines the blue component to read from (value between 0 and 255)
  20887. * @param a defines the alpha component to read from (value between 0 and 255)
  20888. * @returns a new Color3 object
  20889. */
  20890. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20891. /**
  20892. * Check the content of a given array and convert it to an array containing RGBA data
  20893. * If the original array was already containing count * 4 values then it is returned directly
  20894. * @param colors defines the array to check
  20895. * @param count defines the number of RGBA data to expect
  20896. * @returns an array containing count * 4 values (RGBA)
  20897. */
  20898. static CheckColors4(colors: number[], count: number): number[];
  20899. }
  20900. /**
  20901. * Class representing a vector containing 2 coordinates
  20902. */
  20903. class Vector2 {
  20904. /** defines the first coordinate */
  20905. x: number;
  20906. /** defines the second coordinate */
  20907. y: number;
  20908. /**
  20909. * Creates a new Vector2 from the given x and y coordinates
  20910. * @param x defines the first coordinate
  20911. * @param y defines the second coordinate
  20912. */
  20913. constructor(
  20914. /** defines the first coordinate */
  20915. x?: number,
  20916. /** defines the second coordinate */
  20917. y?: number);
  20918. /**
  20919. * Gets a string with the Vector2 coordinates
  20920. * @returns a string with the Vector2 coordinates
  20921. */
  20922. toString(): string;
  20923. /**
  20924. * Gets class name
  20925. * @returns the string "Vector2"
  20926. */
  20927. getClassName(): string;
  20928. /**
  20929. * Gets current vector hash code
  20930. * @returns the Vector2 hash code as a number
  20931. */
  20932. getHashCode(): number;
  20933. /**
  20934. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20935. * @param array defines the source array
  20936. * @param index defines the offset in source array
  20937. * @returns the current Vector2
  20938. */
  20939. toArray(array: FloatArray, index?: number): Vector2;
  20940. /**
  20941. * Copy the current vector to an array
  20942. * @returns a new array with 2 elements: the Vector2 coordinates.
  20943. */
  20944. asArray(): number[];
  20945. /**
  20946. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20947. * @param source defines the source Vector2
  20948. * @returns the current updated Vector2
  20949. */
  20950. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20951. /**
  20952. * Sets the Vector2 coordinates with the given floats
  20953. * @param x defines the first coordinate
  20954. * @param y defines the second coordinate
  20955. * @returns the current updated Vector2
  20956. */
  20957. copyFromFloats(x: number, y: number): Vector2;
  20958. /**
  20959. * Sets the Vector2 coordinates with the given floats
  20960. * @param x defines the first coordinate
  20961. * @param y defines the second coordinate
  20962. * @returns the current updated Vector2
  20963. */
  20964. set(x: number, y: number): Vector2;
  20965. /**
  20966. * Add another vector with the current one
  20967. * @param otherVector defines the other vector
  20968. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20969. */
  20970. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20971. /**
  20972. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20973. * @param otherVector defines the other vector
  20974. * @param result defines the target vector
  20975. * @returns the unmodified current Vector2
  20976. */
  20977. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20978. /**
  20979. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20980. * @param otherVector defines the other vector
  20981. * @returns the current updated Vector2
  20982. */
  20983. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20984. /**
  20985. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20986. * @param otherVector defines the other vector
  20987. * @returns a new Vector2
  20988. */
  20989. addVector3(otherVector: Vector3): Vector2;
  20990. /**
  20991. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20992. * @param otherVector defines the other vector
  20993. * @returns a new Vector2
  20994. */
  20995. subtract(otherVector: Vector2): Vector2;
  20996. /**
  20997. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20998. * @param otherVector defines the other vector
  20999. * @param result defines the target vector
  21000. * @returns the unmodified current Vector2
  21001. */
  21002. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21003. /**
  21004. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  21005. * @param otherVector defines the other vector
  21006. * @returns the current updated Vector2
  21007. */
  21008. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21009. /**
  21010. * Multiplies in place the current Vector2 coordinates by the given ones
  21011. * @param otherVector defines the other vector
  21012. * @returns the current updated Vector2
  21013. */
  21014. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21015. /**
  21016. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  21017. * @param otherVector defines the other vector
  21018. * @returns a new Vector2
  21019. */
  21020. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  21021. /**
  21022. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  21023. * @param otherVector defines the other vector
  21024. * @param result defines the target vector
  21025. * @returns the unmodified current Vector2
  21026. */
  21027. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21028. /**
  21029. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  21030. * @param x defines the first coordinate
  21031. * @param y defines the second coordinate
  21032. * @returns a new Vector2
  21033. */
  21034. multiplyByFloats(x: number, y: number): Vector2;
  21035. /**
  21036. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  21037. * @param otherVector defines the other vector
  21038. * @returns a new Vector2
  21039. */
  21040. divide(otherVector: Vector2): Vector2;
  21041. /**
  21042. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  21043. * @param otherVector defines the other vector
  21044. * @param result defines the target vector
  21045. * @returns the unmodified current Vector2
  21046. */
  21047. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21048. /**
  21049. * Divides the current Vector2 coordinates by the given ones
  21050. * @param otherVector defines the other vector
  21051. * @returns the current updated Vector2
  21052. */
  21053. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21054. /**
  21055. * Gets a new Vector2 with current Vector2 negated coordinates
  21056. * @returns a new Vector2
  21057. */
  21058. negate(): Vector2;
  21059. /**
  21060. * Multiply the Vector2 coordinates by scale
  21061. * @param scale defines the scaling factor
  21062. * @returns the current updated Vector2
  21063. */
  21064. scaleInPlace(scale: number): Vector2;
  21065. /**
  21066. * Returns a new Vector2 scaled by "scale" from the current Vector2
  21067. * @param scale defines the scaling factor
  21068. * @returns a new Vector2
  21069. */
  21070. scale(scale: number): Vector2;
  21071. /**
  21072. * Scale the current Vector2 values by a factor to a given Vector2
  21073. * @param scale defines the scale factor
  21074. * @param result defines the Vector2 object where to store the result
  21075. * @returns the unmodified current Vector2
  21076. */
  21077. scaleToRef(scale: number, result: Vector2): Vector2;
  21078. /**
  21079. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  21080. * @param scale defines the scale factor
  21081. * @param result defines the Vector2 object where to store the result
  21082. * @returns the unmodified current Vector2
  21083. */
  21084. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  21085. /**
  21086. * Gets a boolean if two vectors are equals
  21087. * @param otherVector defines the other vector
  21088. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  21089. */
  21090. equals(otherVector: DeepImmutable<Vector2>): boolean;
  21091. /**
  21092. * Gets a boolean if two vectors are equals (using an epsilon value)
  21093. * @param otherVector defines the other vector
  21094. * @param epsilon defines the minimal distance to consider equality
  21095. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  21096. */
  21097. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  21098. /**
  21099. * Gets a new Vector2 from current Vector2 floored values
  21100. * @returns a new Vector2
  21101. */
  21102. floor(): Vector2;
  21103. /**
  21104. * Gets a new Vector2 from current Vector2 floored values
  21105. * @returns a new Vector2
  21106. */
  21107. fract(): Vector2;
  21108. /**
  21109. * Gets the length of the vector
  21110. * @returns the vector length (float)
  21111. */
  21112. length(): number;
  21113. /**
  21114. * Gets the vector squared length
  21115. * @returns the vector squared length (float)
  21116. */
  21117. lengthSquared(): number;
  21118. /**
  21119. * Normalize the vector
  21120. * @returns the current updated Vector2
  21121. */
  21122. normalize(): Vector2;
  21123. /**
  21124. * Gets a new Vector2 copied from the Vector2
  21125. * @returns a new Vector2
  21126. */
  21127. clone(): Vector2;
  21128. /**
  21129. * Gets a new Vector2(0, 0)
  21130. * @returns a new Vector2
  21131. */
  21132. static Zero(): Vector2;
  21133. /**
  21134. * Gets a new Vector2(1, 1)
  21135. * @returns a new Vector2
  21136. */
  21137. static One(): Vector2;
  21138. /**
  21139. * Gets a new Vector2 set from the given index element of the given array
  21140. * @param array defines the data source
  21141. * @param offset defines the offset in the data source
  21142. * @returns a new Vector2
  21143. */
  21144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21145. /**
  21146. * Sets "result" from the given index element of the given array
  21147. * @param array defines the data source
  21148. * @param offset defines the offset in the data source
  21149. * @param result defines the target vector
  21150. */
  21151. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21152. /**
  21153. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21154. * @param value1 defines 1st point of control
  21155. * @param value2 defines 2nd point of control
  21156. * @param value3 defines 3rd point of control
  21157. * @param value4 defines 4th point of control
  21158. * @param amount defines the interpolation factor
  21159. * @returns a new Vector2
  21160. */
  21161. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21162. /**
  21163. * 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".
  21164. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21165. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21166. * @param value defines the value to clamp
  21167. * @param min defines the lower limit
  21168. * @param max defines the upper limit
  21169. * @returns a new Vector2
  21170. */
  21171. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21172. /**
  21173. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21174. * @param value1 defines the 1st control point
  21175. * @param tangent1 defines the outgoing tangent
  21176. * @param value2 defines the 2nd control point
  21177. * @param tangent2 defines the incoming tangent
  21178. * @param amount defines the interpolation factor
  21179. * @returns a new Vector2
  21180. */
  21181. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21182. /**
  21183. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21184. * @param start defines the start vector
  21185. * @param end defines the end vector
  21186. * @param amount defines the interpolation factor
  21187. * @returns a new Vector2
  21188. */
  21189. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21190. /**
  21191. * Gets the dot product of the vector "left" and the vector "right"
  21192. * @param left defines first vector
  21193. * @param right defines second vector
  21194. * @returns the dot product (float)
  21195. */
  21196. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21197. /**
  21198. * Returns a new Vector2 equal to the normalized given vector
  21199. * @param vector defines the vector to normalize
  21200. * @returns a new Vector2
  21201. */
  21202. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21203. /**
  21204. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21205. * @param left defines 1st vector
  21206. * @param right defines 2nd vector
  21207. * @returns a new Vector2
  21208. */
  21209. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21210. /**
  21211. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21212. * @param left defines 1st vector
  21213. * @param right defines 2nd vector
  21214. * @returns a new Vector2
  21215. */
  21216. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21217. /**
  21218. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21219. * @param vector defines the vector to transform
  21220. * @param transformation defines the matrix to apply
  21221. * @returns a new Vector2
  21222. */
  21223. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21224. /**
  21225. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21226. * @param vector defines the vector to transform
  21227. * @param transformation defines the matrix to apply
  21228. * @param result defines the target vector
  21229. */
  21230. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21231. /**
  21232. * Determines if a given vector is included in a triangle
  21233. * @param p defines the vector to test
  21234. * @param p0 defines 1st triangle point
  21235. * @param p1 defines 2nd triangle point
  21236. * @param p2 defines 3rd triangle point
  21237. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21238. */
  21239. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21240. /**
  21241. * Gets the distance between the vectors "value1" and "value2"
  21242. * @param value1 defines first vector
  21243. * @param value2 defines second vector
  21244. * @returns the distance between vectors
  21245. */
  21246. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21247. /**
  21248. * Returns the squared distance between the vectors "value1" and "value2"
  21249. * @param value1 defines first vector
  21250. * @param value2 defines second vector
  21251. * @returns the squared distance between vectors
  21252. */
  21253. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21254. /**
  21255. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21256. * @param value1 defines first vector
  21257. * @param value2 defines second vector
  21258. * @returns a new Vector2
  21259. */
  21260. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21261. /**
  21262. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21263. * @param p defines the middle point
  21264. * @param segA defines one point of the segment
  21265. * @param segB defines the other point of the segment
  21266. * @returns the shortest distance
  21267. */
  21268. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21269. }
  21270. /**
  21271. * Classed used to store (x,y,z) vector representation
  21272. * A Vector3 is the main object used in 3D geometry
  21273. * It can represent etiher the coordinates of a point the space, either a direction
  21274. * Reminder: Babylon.js uses a left handed forward facing system
  21275. */
  21276. class Vector3 {
  21277. /**
  21278. * Defines the first coordinates (on X axis)
  21279. */
  21280. x: number;
  21281. /**
  21282. * Defines the second coordinates (on Y axis)
  21283. */
  21284. y: number;
  21285. /**
  21286. * Defines the third coordinates (on Z axis)
  21287. */
  21288. z: number;
  21289. private static _UpReadOnly;
  21290. /**
  21291. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21292. * @param x defines the first coordinates (on X axis)
  21293. * @param y defines the second coordinates (on Y axis)
  21294. * @param z defines the third coordinates (on Z axis)
  21295. */
  21296. constructor(
  21297. /**
  21298. * Defines the first coordinates (on X axis)
  21299. */
  21300. x?: number,
  21301. /**
  21302. * Defines the second coordinates (on Y axis)
  21303. */
  21304. y?: number,
  21305. /**
  21306. * Defines the third coordinates (on Z axis)
  21307. */
  21308. z?: number);
  21309. /**
  21310. * Creates a string representation of the Vector3
  21311. * @returns a string with the Vector3 coordinates.
  21312. */
  21313. toString(): string;
  21314. /**
  21315. * Gets the class name
  21316. * @returns the string "Vector3"
  21317. */
  21318. getClassName(): string;
  21319. /**
  21320. * Creates the Vector3 hash code
  21321. * @returns a number which tends to be unique between Vector3 instances
  21322. */
  21323. getHashCode(): number;
  21324. /**
  21325. * Creates an array containing three elements : the coordinates of the Vector3
  21326. * @returns a new array of numbers
  21327. */
  21328. asArray(): number[];
  21329. /**
  21330. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21331. * @param array defines the destination array
  21332. * @param index defines the offset in the destination array
  21333. * @returns the current Vector3
  21334. */
  21335. toArray(array: FloatArray, index?: number): Vector3;
  21336. /**
  21337. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21338. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21339. */
  21340. toQuaternion(): Quaternion;
  21341. /**
  21342. * Adds the given vector to the current Vector3
  21343. * @param otherVector defines the second operand
  21344. * @returns the current updated Vector3
  21345. */
  21346. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21347. /**
  21348. * Adds the given coordinates to the current Vector3
  21349. * @param x defines the x coordinate of the operand
  21350. * @param y defines the y coordinate of the operand
  21351. * @param z defines the z coordinate of the operand
  21352. * @returns the current updated Vector3
  21353. */
  21354. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21355. /**
  21356. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21357. * @param otherVector defines the second operand
  21358. * @returns the resulting Vector3
  21359. */
  21360. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21361. /**
  21362. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21363. * @param otherVector defines the second operand
  21364. * @param result defines the Vector3 object where to store the result
  21365. * @returns the current Vector3
  21366. */
  21367. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21368. /**
  21369. * Subtract the given vector from the current Vector3
  21370. * @param otherVector defines the second operand
  21371. * @returns the current updated Vector3
  21372. */
  21373. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21374. /**
  21375. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21376. * @param otherVector defines the second operand
  21377. * @returns the resulting Vector3
  21378. */
  21379. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21380. /**
  21381. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21382. * @param otherVector defines the second operand
  21383. * @param result defines the Vector3 object where to store the result
  21384. * @returns the current Vector3
  21385. */
  21386. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21387. /**
  21388. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21389. * @param x defines the x coordinate of the operand
  21390. * @param y defines the y coordinate of the operand
  21391. * @param z defines the z coordinate of the operand
  21392. * @returns the resulting Vector3
  21393. */
  21394. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21395. /**
  21396. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21397. * @param x defines the x coordinate of the operand
  21398. * @param y defines the y coordinate of the operand
  21399. * @param z defines the z coordinate of the operand
  21400. * @param result defines the Vector3 object where to store the result
  21401. * @returns the current Vector3
  21402. */
  21403. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21404. /**
  21405. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21406. * @returns a new Vector3
  21407. */
  21408. negate(): Vector3;
  21409. /**
  21410. * Multiplies the Vector3 coordinates by the float "scale"
  21411. * @param scale defines the multiplier factor
  21412. * @returns the current updated Vector3
  21413. */
  21414. scaleInPlace(scale: number): Vector3;
  21415. /**
  21416. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21417. * @param scale defines the multiplier factor
  21418. * @returns a new Vector3
  21419. */
  21420. scale(scale: number): Vector3;
  21421. /**
  21422. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21423. * @param scale defines the multiplier factor
  21424. * @param result defines the Vector3 object where to store the result
  21425. * @returns the current Vector3
  21426. */
  21427. scaleToRef(scale: number, result: Vector3): Vector3;
  21428. /**
  21429. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21430. * @param scale defines the scale factor
  21431. * @param result defines the Vector3 object where to store the result
  21432. * @returns the unmodified current Vector3
  21433. */
  21434. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21435. /**
  21436. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21437. * @param otherVector defines the second operand
  21438. * @returns true if both vectors are equals
  21439. */
  21440. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21441. /**
  21442. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21443. * @param otherVector defines the second operand
  21444. * @param epsilon defines the minimal distance to define values as equals
  21445. * @returns true if both vectors are distant less than epsilon
  21446. */
  21447. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21448. /**
  21449. * Returns true if the current Vector3 coordinates equals the given floats
  21450. * @param x defines the x coordinate of the operand
  21451. * @param y defines the y coordinate of the operand
  21452. * @param z defines the z coordinate of the operand
  21453. * @returns true if both vectors are equals
  21454. */
  21455. equalsToFloats(x: number, y: number, z: number): boolean;
  21456. /**
  21457. * Multiplies the current Vector3 coordinates by the given ones
  21458. * @param otherVector defines the second operand
  21459. * @returns the current updated Vector3
  21460. */
  21461. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21462. /**
  21463. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21464. * @param otherVector defines the second operand
  21465. * @returns the new Vector3
  21466. */
  21467. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21468. /**
  21469. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21470. * @param otherVector defines the second operand
  21471. * @param result defines the Vector3 object where to store the result
  21472. * @returns the current Vector3
  21473. */
  21474. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21475. /**
  21476. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21477. * @param x defines the x coordinate of the operand
  21478. * @param y defines the y coordinate of the operand
  21479. * @param z defines the z coordinate of the operand
  21480. * @returns the new Vector3
  21481. */
  21482. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21483. /**
  21484. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21485. * @param otherVector defines the second operand
  21486. * @returns the new Vector3
  21487. */
  21488. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21489. /**
  21490. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21491. * @param otherVector defines the second operand
  21492. * @param result defines the Vector3 object where to store the result
  21493. * @returns the current Vector3
  21494. */
  21495. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21496. /**
  21497. * Divides the current Vector3 coordinates by the given ones.
  21498. * @param otherVector defines the second operand
  21499. * @returns the current updated Vector3
  21500. */
  21501. divideInPlace(otherVector: Vector3): Vector3;
  21502. /**
  21503. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21504. * @param other defines the second operand
  21505. * @returns the current updated Vector3
  21506. */
  21507. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21508. /**
  21509. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21510. * @param other defines the second operand
  21511. * @returns the current updated Vector3
  21512. */
  21513. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21514. /**
  21515. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21516. * @param x defines the x coordinate of the operand
  21517. * @param y defines the y coordinate of the operand
  21518. * @param z defines the z coordinate of the operand
  21519. * @returns the current updated Vector3
  21520. */
  21521. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21522. /**
  21523. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21524. * @param x defines the x coordinate of the operand
  21525. * @param y defines the y coordinate of the operand
  21526. * @param z defines the z coordinate of the operand
  21527. * @returns the current updated Vector3
  21528. */
  21529. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21530. /**
  21531. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21532. */
  21533. readonly isNonUniform: boolean;
  21534. /**
  21535. * Gets a new Vector3 from current Vector3 floored values
  21536. * @returns a new Vector3
  21537. */
  21538. floor(): Vector3;
  21539. /**
  21540. * Gets a new Vector3 from current Vector3 floored values
  21541. * @returns a new Vector3
  21542. */
  21543. fract(): Vector3;
  21544. /**
  21545. * Gets the length of the Vector3
  21546. * @returns the length of the Vecto3
  21547. */
  21548. length(): number;
  21549. /**
  21550. * Gets the squared length of the Vector3
  21551. * @returns squared length of the Vector3
  21552. */
  21553. lengthSquared(): number;
  21554. /**
  21555. * Normalize the current Vector3.
  21556. * Please note that this is an in place operation.
  21557. * @returns the current updated Vector3
  21558. */
  21559. normalize(): Vector3;
  21560. /**
  21561. * Reorders the x y z properties of the vector in place
  21562. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21563. * @returns the current updated vector
  21564. */
  21565. reorderInPlace(order: string): this;
  21566. /**
  21567. * Rotates the vector around 0,0,0 by a quaternion
  21568. * @param quaternion the rotation quaternion
  21569. * @param result vector to store the result
  21570. * @returns the resulting vector
  21571. */
  21572. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21573. /**
  21574. * Rotates a vector around a given point
  21575. * @param quaternion the rotation quaternion
  21576. * @param point the point to rotate around
  21577. * @param result vector to store the result
  21578. * @returns the resulting vector
  21579. */
  21580. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21581. /**
  21582. * Normalize the current Vector3 with the given input length.
  21583. * Please note that this is an in place operation.
  21584. * @param len the length of the vector
  21585. * @returns the current updated Vector3
  21586. */
  21587. normalizeFromLength(len: number): Vector3;
  21588. /**
  21589. * Normalize the current Vector3 to a new vector
  21590. * @returns the new Vector3
  21591. */
  21592. normalizeToNew(): Vector3;
  21593. /**
  21594. * Normalize the current Vector3 to the reference
  21595. * @param reference define the Vector3 to update
  21596. * @returns the updated Vector3
  21597. */
  21598. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21599. /**
  21600. * Creates a new Vector3 copied from the current Vector3
  21601. * @returns the new Vector3
  21602. */
  21603. clone(): Vector3;
  21604. /**
  21605. * Copies the given vector coordinates to the current Vector3 ones
  21606. * @param source defines the source Vector3
  21607. * @returns the current updated Vector3
  21608. */
  21609. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21610. /**
  21611. * Copies the given floats to the current Vector3 coordinates
  21612. * @param x defines the x coordinate of the operand
  21613. * @param y defines the y coordinate of the operand
  21614. * @param z defines the z coordinate of the operand
  21615. * @returns the current updated Vector3
  21616. */
  21617. copyFromFloats(x: number, y: number, z: number): Vector3;
  21618. /**
  21619. * Copies the given floats to the current Vector3 coordinates
  21620. * @param x defines the x coordinate of the operand
  21621. * @param y defines the y coordinate of the operand
  21622. * @param z defines the z coordinate of the operand
  21623. * @returns the current updated Vector3
  21624. */
  21625. set(x: number, y: number, z: number): Vector3;
  21626. /**
  21627. * Copies the given float to the current Vector3 coordinates
  21628. * @param v defines the x, y and z coordinates of the operand
  21629. * @returns the current updated Vector3
  21630. */
  21631. setAll(v: number): Vector3;
  21632. /**
  21633. * Get the clip factor between two vectors
  21634. * @param vector0 defines the first operand
  21635. * @param vector1 defines the second operand
  21636. * @param axis defines the axis to use
  21637. * @param size defines the size along the axis
  21638. * @returns the clip factor
  21639. */
  21640. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21641. /**
  21642. * Get angle between two vectors
  21643. * @param vector0 angle between vector0 and vector1
  21644. * @param vector1 angle between vector0 and vector1
  21645. * @param normal direction of the normal
  21646. * @return the angle between vector0 and vector1
  21647. */
  21648. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21649. /**
  21650. * Returns a new Vector3 set from the index "offset" of the given array
  21651. * @param array defines the source array
  21652. * @param offset defines the offset in the source array
  21653. * @returns the new Vector3
  21654. */
  21655. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21656. /**
  21657. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21658. * This function is deprecated. Use FromArray instead
  21659. * @param array defines the source array
  21660. * @param offset defines the offset in the source array
  21661. * @returns the new Vector3
  21662. */
  21663. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21664. /**
  21665. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21666. * @param array defines the source array
  21667. * @param offset defines the offset in the source array
  21668. * @param result defines the Vector3 where to store the result
  21669. */
  21670. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21671. /**
  21672. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21673. * This function is deprecated. Use FromArrayToRef instead.
  21674. * @param array defines the source array
  21675. * @param offset defines the offset in the source array
  21676. * @param result defines the Vector3 where to store the result
  21677. */
  21678. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21679. /**
  21680. * Sets the given vector "result" with the given floats.
  21681. * @param x defines the x coordinate of the source
  21682. * @param y defines the y coordinate of the source
  21683. * @param z defines the z coordinate of the source
  21684. * @param result defines the Vector3 where to store the result
  21685. */
  21686. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21687. /**
  21688. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21689. * @returns a new empty Vector3
  21690. */
  21691. static Zero(): Vector3;
  21692. /**
  21693. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21694. * @returns a new unit Vector3
  21695. */
  21696. static One(): Vector3;
  21697. /**
  21698. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21699. * @returns a new up Vector3
  21700. */
  21701. static Up(): Vector3;
  21702. /**
  21703. * Gets a up Vector3 that must not be updated
  21704. */
  21705. static readonly UpReadOnly: DeepImmutable<Vector3>;
  21706. /**
  21707. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21708. * @returns a new down Vector3
  21709. */
  21710. static Down(): Vector3;
  21711. /**
  21712. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21713. * @returns a new forward Vector3
  21714. */
  21715. static Forward(): Vector3;
  21716. /**
  21717. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21718. * @returns a new forward Vector3
  21719. */
  21720. static Backward(): Vector3;
  21721. /**
  21722. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21723. * @returns a new right Vector3
  21724. */
  21725. static Right(): Vector3;
  21726. /**
  21727. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21728. * @returns a new left Vector3
  21729. */
  21730. static Left(): Vector3;
  21731. /**
  21732. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21733. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21734. * @param vector defines the Vector3 to transform
  21735. * @param transformation defines the transformation matrix
  21736. * @returns the transformed Vector3
  21737. */
  21738. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21739. /**
  21740. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21741. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21742. * @param vector defines the Vector3 to transform
  21743. * @param transformation defines the transformation matrix
  21744. * @param result defines the Vector3 where to store the result
  21745. */
  21746. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21747. /**
  21748. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21749. * This method computes tranformed coordinates only, not transformed direction vectors
  21750. * @param x define the x coordinate of the source vector
  21751. * @param y define the y coordinate of the source vector
  21752. * @param z define the z coordinate of the source vector
  21753. * @param transformation defines the transformation matrix
  21754. * @param result defines the Vector3 where to store the result
  21755. */
  21756. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21757. /**
  21758. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21759. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21760. * @param vector defines the Vector3 to transform
  21761. * @param transformation defines the transformation matrix
  21762. * @returns the new Vector3
  21763. */
  21764. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21765. /**
  21766. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21767. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21768. * @param vector defines the Vector3 to transform
  21769. * @param transformation defines the transformation matrix
  21770. * @param result defines the Vector3 where to store the result
  21771. */
  21772. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21773. /**
  21774. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21776. * @param x define the x coordinate of the source vector
  21777. * @param y define the y coordinate of the source vector
  21778. * @param z define the z coordinate of the source vector
  21779. * @param transformation defines the transformation matrix
  21780. * @param result defines the Vector3 where to store the result
  21781. */
  21782. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21783. /**
  21784. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21785. * @param value1 defines the first control point
  21786. * @param value2 defines the second control point
  21787. * @param value3 defines the third control point
  21788. * @param value4 defines the fourth control point
  21789. * @param amount defines the amount on the spline to use
  21790. * @returns the new Vector3
  21791. */
  21792. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21793. /**
  21794. * 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"
  21795. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21796. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21797. * @param value defines the current value
  21798. * @param min defines the lower range value
  21799. * @param max defines the upper range value
  21800. * @returns the new Vector3
  21801. */
  21802. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21803. /**
  21804. * 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"
  21805. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21806. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21807. * @param value defines the current value
  21808. * @param min defines the lower range value
  21809. * @param max defines the upper range value
  21810. * @param result defines the Vector3 where to store the result
  21811. */
  21812. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21813. /**
  21814. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21815. * @param value1 defines the first control point
  21816. * @param tangent1 defines the first tangent vector
  21817. * @param value2 defines the second control point
  21818. * @param tangent2 defines the second tangent vector
  21819. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21820. * @returns the new Vector3
  21821. */
  21822. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21823. /**
  21824. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21825. * @param start defines the start value
  21826. * @param end defines the end value
  21827. * @param amount max defines amount between both (between 0 and 1)
  21828. * @returns the new Vector3
  21829. */
  21830. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21831. /**
  21832. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21833. * @param start defines the start value
  21834. * @param end defines the end value
  21835. * @param amount max defines amount between both (between 0 and 1)
  21836. * @param result defines the Vector3 where to store the result
  21837. */
  21838. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21839. /**
  21840. * Returns the dot product (float) between the vectors "left" and "right"
  21841. * @param left defines the left operand
  21842. * @param right defines the right operand
  21843. * @returns the dot product
  21844. */
  21845. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21846. /**
  21847. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21848. * The cross product is then orthogonal to both "left" and "right"
  21849. * @param left defines the left operand
  21850. * @param right defines the right operand
  21851. * @returns the cross product
  21852. */
  21853. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21854. /**
  21855. * Sets the given vector "result" with the cross product of "left" and "right"
  21856. * The cross product is then orthogonal to both "left" and "right"
  21857. * @param left defines the left operand
  21858. * @param right defines the right operand
  21859. * @param result defines the Vector3 where to store the result
  21860. */
  21861. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21862. /**
  21863. * Returns a new Vector3 as the normalization of the given vector
  21864. * @param vector defines the Vector3 to normalize
  21865. * @returns the new Vector3
  21866. */
  21867. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21868. /**
  21869. * Sets the given vector "result" with the normalization of the given first vector
  21870. * @param vector defines the Vector3 to normalize
  21871. * @param result defines the Vector3 where to store the result
  21872. */
  21873. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21874. /**
  21875. * Project a Vector3 onto screen space
  21876. * @param vector defines the Vector3 to project
  21877. * @param world defines the world matrix to use
  21878. * @param transform defines the transform (view x projection) matrix to use
  21879. * @param viewport defines the screen viewport to use
  21880. * @returns the new Vector3
  21881. */
  21882. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21883. /** @hidden */
  21884. private static UnprojectFromInvertedMatrixToRef;
  21885. /**
  21886. * Unproject from screen space to object space
  21887. * @param source defines the screen space Vector3 to use
  21888. * @param viewportWidth defines the current width of the viewport
  21889. * @param viewportHeight defines the current height of the viewport
  21890. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21891. * @param transform defines the transform (view x projection) matrix to use
  21892. * @returns the new Vector3
  21893. */
  21894. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21895. /**
  21896. * Unproject from screen space to object space
  21897. * @param source defines the screen space Vector3 to use
  21898. * @param viewportWidth defines the current width of the viewport
  21899. * @param viewportHeight defines the current height of the viewport
  21900. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21901. * @param view defines the view matrix to use
  21902. * @param projection defines the projection matrix to use
  21903. * @returns the new Vector3
  21904. */
  21905. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21906. /**
  21907. * Unproject from screen space to object space
  21908. * @param source defines the screen space Vector3 to use
  21909. * @param viewportWidth defines the current width of the viewport
  21910. * @param viewportHeight defines the current height of the viewport
  21911. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21912. * @param view defines the view matrix to use
  21913. * @param projection defines the projection matrix to use
  21914. * @param result defines the Vector3 where to store the result
  21915. */
  21916. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21917. /**
  21918. * Unproject from screen space to object space
  21919. * @param sourceX defines the screen space x coordinate to use
  21920. * @param sourceY defines the screen space y coordinate to use
  21921. * @param sourceZ defines the screen space z coordinate to use
  21922. * @param viewportWidth defines the current width of the viewport
  21923. * @param viewportHeight defines the current height of the viewport
  21924. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21925. * @param view defines the view matrix to use
  21926. * @param projection defines the projection matrix to use
  21927. * @param result defines the Vector3 where to store the result
  21928. */
  21929. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21930. /**
  21931. * Unproject a ray from screen space to object space
  21932. * @param sourceX defines the screen space x coordinate to use
  21933. * @param sourceY defines the screen space y coordinate to use
  21934. * @param viewportWidth defines the current width of the viewport
  21935. * @param viewportHeight defines the current height of the viewport
  21936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21937. * @param view defines the view matrix to use
  21938. * @param projection defines the projection matrix to use
  21939. * @param ray defines the Ray where to store the result
  21940. */
  21941. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21942. /**
  21943. * Gets the minimal coordinate values between two Vector3
  21944. * @param left defines the first operand
  21945. * @param right defines the second operand
  21946. * @returns the new Vector3
  21947. */
  21948. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21949. /**
  21950. * Gets the maximal coordinate values between two Vector3
  21951. * @param left defines the first operand
  21952. * @param right defines the second operand
  21953. * @returns the new Vector3
  21954. */
  21955. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21956. /**
  21957. * Returns the distance between the vectors "value1" and "value2"
  21958. * @param value1 defines the first operand
  21959. * @param value2 defines the second operand
  21960. * @returns the distance
  21961. */
  21962. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21963. /**
  21964. * Returns the squared distance between the vectors "value1" and "value2"
  21965. * @param value1 defines the first operand
  21966. * @param value2 defines the second operand
  21967. * @returns the squared distance
  21968. */
  21969. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21970. /**
  21971. * Returns a new Vector3 located at the center between "value1" and "value2"
  21972. * @param value1 defines the first operand
  21973. * @param value2 defines the second operand
  21974. * @returns the new Vector3
  21975. */
  21976. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21977. /**
  21978. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21979. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21980. * to something in order to rotate it from its local system to the given target system
  21981. * Note: axis1, axis2 and axis3 are normalized during this operation
  21982. * @param axis1 defines the first axis
  21983. * @param axis2 defines the second axis
  21984. * @param axis3 defines the third axis
  21985. * @returns a new Vector3
  21986. */
  21987. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21988. /**
  21989. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21990. * @param axis1 defines the first axis
  21991. * @param axis2 defines the second axis
  21992. * @param axis3 defines the third axis
  21993. * @param ref defines the Vector3 where to store the result
  21994. */
  21995. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21996. }
  21997. /**
  21998. * Vector4 class created for EulerAngle class conversion to Quaternion
  21999. */
  22000. class Vector4 {
  22001. /** x value of the vector */
  22002. x: number;
  22003. /** y value of the vector */
  22004. y: number;
  22005. /** z value of the vector */
  22006. z: number;
  22007. /** w value of the vector */
  22008. w: number;
  22009. /**
  22010. * Creates a Vector4 object from the given floats.
  22011. * @param x x value of the vector
  22012. * @param y y value of the vector
  22013. * @param z z value of the vector
  22014. * @param w w value of the vector
  22015. */
  22016. constructor(
  22017. /** x value of the vector */
  22018. x: number,
  22019. /** y value of the vector */
  22020. y: number,
  22021. /** z value of the vector */
  22022. z: number,
  22023. /** w value of the vector */
  22024. w: number);
  22025. /**
  22026. * Returns the string with the Vector4 coordinates.
  22027. * @returns a string containing all the vector values
  22028. */
  22029. toString(): string;
  22030. /**
  22031. * Returns the string "Vector4".
  22032. * @returns "Vector4"
  22033. */
  22034. getClassName(): string;
  22035. /**
  22036. * Returns the Vector4 hash code.
  22037. * @returns a unique hash code
  22038. */
  22039. getHashCode(): number;
  22040. /**
  22041. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  22042. * @returns the resulting array
  22043. */
  22044. asArray(): number[];
  22045. /**
  22046. * Populates the given array from the given index with the Vector4 coordinates.
  22047. * @param array array to populate
  22048. * @param index index of the array to start at (default: 0)
  22049. * @returns the Vector4.
  22050. */
  22051. toArray(array: FloatArray, index?: number): Vector4;
  22052. /**
  22053. * Adds the given vector to the current Vector4.
  22054. * @param otherVector the vector to add
  22055. * @returns the updated Vector4.
  22056. */
  22057. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22058. /**
  22059. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  22060. * @param otherVector the vector to add
  22061. * @returns the resulting vector
  22062. */
  22063. add(otherVector: DeepImmutable<Vector4>): Vector4;
  22064. /**
  22065. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  22066. * @param otherVector the vector to add
  22067. * @param result the vector to store the result
  22068. * @returns the current Vector4.
  22069. */
  22070. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22071. /**
  22072. * Subtract in place the given vector from the current Vector4.
  22073. * @param otherVector the vector to subtract
  22074. * @returns the updated Vector4.
  22075. */
  22076. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22077. /**
  22078. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  22079. * @param otherVector the vector to add
  22080. * @returns the new vector with the result
  22081. */
  22082. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  22083. /**
  22084. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  22085. * @param otherVector the vector to subtract
  22086. * @param result the vector to store the result
  22087. * @returns the current Vector4.
  22088. */
  22089. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22090. /**
  22091. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22092. */
  22093. /**
  22094. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22095. * @param x value to subtract
  22096. * @param y value to subtract
  22097. * @param z value to subtract
  22098. * @param w value to subtract
  22099. * @returns new vector containing the result
  22100. */
  22101. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22102. /**
  22103. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22104. * @param x value to subtract
  22105. * @param y value to subtract
  22106. * @param z value to subtract
  22107. * @param w value to subtract
  22108. * @param result the vector to store the result in
  22109. * @returns the current Vector4.
  22110. */
  22111. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  22112. /**
  22113. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  22114. * @returns a new vector with the negated values
  22115. */
  22116. negate(): Vector4;
  22117. /**
  22118. * Multiplies the current Vector4 coordinates by scale (float).
  22119. * @param scale the number to scale with
  22120. * @returns the updated Vector4.
  22121. */
  22122. scaleInPlace(scale: number): Vector4;
  22123. /**
  22124. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22125. * @param scale the number to scale with
  22126. * @returns a new vector with the result
  22127. */
  22128. scale(scale: number): Vector4;
  22129. /**
  22130. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22131. * @param scale the number to scale with
  22132. * @param result a vector to store the result in
  22133. * @returns the current Vector4.
  22134. */
  22135. scaleToRef(scale: number, result: Vector4): Vector4;
  22136. /**
  22137. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22138. * @param scale defines the scale factor
  22139. * @param result defines the Vector4 object where to store the result
  22140. * @returns the unmodified current Vector4
  22141. */
  22142. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22143. /**
  22144. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22145. * @param otherVector the vector to compare against
  22146. * @returns true if they are equal
  22147. */
  22148. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22149. /**
  22150. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22151. * @param otherVector vector to compare against
  22152. * @param epsilon (Default: very small number)
  22153. * @returns true if they are equal
  22154. */
  22155. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22156. /**
  22157. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22158. * @param x x value to compare against
  22159. * @param y y value to compare against
  22160. * @param z z value to compare against
  22161. * @param w w value to compare against
  22162. * @returns true if equal
  22163. */
  22164. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22165. /**
  22166. * Multiplies in place the current Vector4 by the given one.
  22167. * @param otherVector vector to multiple with
  22168. * @returns the updated Vector4.
  22169. */
  22170. multiplyInPlace(otherVector: Vector4): Vector4;
  22171. /**
  22172. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22173. * @param otherVector vector to multiple with
  22174. * @returns resulting new vector
  22175. */
  22176. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22177. /**
  22178. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22179. * @param otherVector vector to multiple with
  22180. * @param result vector to store the result
  22181. * @returns the current Vector4.
  22182. */
  22183. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22184. /**
  22185. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22186. * @param x x value multiply with
  22187. * @param y y value multiply with
  22188. * @param z z value multiply with
  22189. * @param w w value multiply with
  22190. * @returns resulting new vector
  22191. */
  22192. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22193. /**
  22194. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22195. * @param otherVector vector to devide with
  22196. * @returns resulting new vector
  22197. */
  22198. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22199. /**
  22200. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22201. * @param otherVector vector to devide with
  22202. * @param result vector to store the result
  22203. * @returns the current Vector4.
  22204. */
  22205. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22206. /**
  22207. * Divides the current Vector3 coordinates by the given ones.
  22208. * @param otherVector vector to devide with
  22209. * @returns the updated Vector3.
  22210. */
  22211. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22212. /**
  22213. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22214. * @param other defines the second operand
  22215. * @returns the current updated Vector4
  22216. */
  22217. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22218. /**
  22219. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22220. * @param other defines the second operand
  22221. * @returns the current updated Vector4
  22222. */
  22223. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22224. /**
  22225. * Gets a new Vector4 from current Vector4 floored values
  22226. * @returns a new Vector4
  22227. */
  22228. floor(): Vector4;
  22229. /**
  22230. * Gets a new Vector4 from current Vector3 floored values
  22231. * @returns a new Vector4
  22232. */
  22233. fract(): Vector4;
  22234. /**
  22235. * Returns the Vector4 length (float).
  22236. * @returns the length
  22237. */
  22238. length(): number;
  22239. /**
  22240. * Returns the Vector4 squared length (float).
  22241. * @returns the length squared
  22242. */
  22243. lengthSquared(): number;
  22244. /**
  22245. * Normalizes in place the Vector4.
  22246. * @returns the updated Vector4.
  22247. */
  22248. normalize(): Vector4;
  22249. /**
  22250. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22251. * @returns this converted to a new vector3
  22252. */
  22253. toVector3(): Vector3;
  22254. /**
  22255. * Returns a new Vector4 copied from the current one.
  22256. * @returns the new cloned vector
  22257. */
  22258. clone(): Vector4;
  22259. /**
  22260. * Updates the current Vector4 with the given one coordinates.
  22261. * @param source the source vector to copy from
  22262. * @returns the updated Vector4.
  22263. */
  22264. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22265. /**
  22266. * Updates the current Vector4 coordinates with the given floats.
  22267. * @param x float to copy from
  22268. * @param y float to copy from
  22269. * @param z float to copy from
  22270. * @param w float to copy from
  22271. * @returns the updated Vector4.
  22272. */
  22273. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22274. /**
  22275. * Updates the current Vector4 coordinates with the given floats.
  22276. * @param x float to set from
  22277. * @param y float to set from
  22278. * @param z float to set from
  22279. * @param w float to set from
  22280. * @returns the updated Vector4.
  22281. */
  22282. set(x: number, y: number, z: number, w: number): Vector4;
  22283. /**
  22284. * Copies the given float to the current Vector3 coordinates
  22285. * @param v defines the x, y, z and w coordinates of the operand
  22286. * @returns the current updated Vector3
  22287. */
  22288. setAll(v: number): Vector4;
  22289. /**
  22290. * Returns a new Vector4 set from the starting index of the given array.
  22291. * @param array the array to pull values from
  22292. * @param offset the offset into the array to start at
  22293. * @returns the new vector
  22294. */
  22295. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22296. /**
  22297. * Updates the given vector "result" from the starting index of the given array.
  22298. * @param array the array to pull values from
  22299. * @param offset the offset into the array to start at
  22300. * @param result the vector to store the result in
  22301. */
  22302. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22303. /**
  22304. * Updates the given vector "result" from the starting index of the given Float32Array.
  22305. * @param array the array to pull values from
  22306. * @param offset the offset into the array to start at
  22307. * @param result the vector to store the result in
  22308. */
  22309. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22310. /**
  22311. * Updates the given vector "result" coordinates from the given floats.
  22312. * @param x float to set from
  22313. * @param y float to set from
  22314. * @param z float to set from
  22315. * @param w float to set from
  22316. * @param result the vector to the floats in
  22317. */
  22318. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22319. /**
  22320. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22321. * @returns the new vector
  22322. */
  22323. static Zero(): Vector4;
  22324. /**
  22325. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22326. * @returns the new vector
  22327. */
  22328. static One(): Vector4;
  22329. /**
  22330. * Returns a new normalized Vector4 from the given one.
  22331. * @param vector the vector to normalize
  22332. * @returns the vector
  22333. */
  22334. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22335. /**
  22336. * Updates the given vector "result" from the normalization of the given one.
  22337. * @param vector the vector to normalize
  22338. * @param result the vector to store the result in
  22339. */
  22340. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22341. /**
  22342. * Returns a vector with the minimum values from the left and right vectors
  22343. * @param left left vector to minimize
  22344. * @param right right vector to minimize
  22345. * @returns a new vector with the minimum of the left and right vector values
  22346. */
  22347. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22348. /**
  22349. * Returns a vector with the maximum values from the left and right vectors
  22350. * @param left left vector to maximize
  22351. * @param right right vector to maximize
  22352. * @returns a new vector with the maximum of the left and right vector values
  22353. */
  22354. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22355. /**
  22356. * Returns the distance (float) between the vectors "value1" and "value2".
  22357. * @param value1 value to calulate the distance between
  22358. * @param value2 value to calulate the distance between
  22359. * @return the distance between the two vectors
  22360. */
  22361. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22362. /**
  22363. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22364. * @param value1 value to calulate the distance between
  22365. * @param value2 value to calulate the distance between
  22366. * @return the distance between the two vectors squared
  22367. */
  22368. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22369. /**
  22370. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22371. * @param value1 value to calulate the center between
  22372. * @param value2 value to calulate the center between
  22373. * @return the center between the two vectors
  22374. */
  22375. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22376. /**
  22377. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22378. * This methods computes transformed normalized direction vectors only.
  22379. * @param vector the vector to transform
  22380. * @param transformation the transformation matrix to apply
  22381. * @returns the new vector
  22382. */
  22383. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22384. /**
  22385. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22386. * This methods computes transformed normalized direction vectors only.
  22387. * @param vector the vector to transform
  22388. * @param transformation the transformation matrix to apply
  22389. * @param result the vector to store the result in
  22390. */
  22391. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22392. /**
  22393. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22394. * This methods computes transformed normalized direction vectors only.
  22395. * @param x value to transform
  22396. * @param y value to transform
  22397. * @param z value to transform
  22398. * @param w value to transform
  22399. * @param transformation the transformation matrix to apply
  22400. * @param result the vector to store the results in
  22401. */
  22402. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22403. /**
  22404. * Creates a new Vector4 from a Vector3
  22405. * @param source defines the source data
  22406. * @param w defines the 4th component (default is 0)
  22407. * @returns a new Vector4
  22408. */
  22409. static FromVector3(source: Vector3, w?: number): Vector4;
  22410. }
  22411. /**
  22412. * Interface for the size containing width and height
  22413. */
  22414. interface ISize {
  22415. /**
  22416. * Width
  22417. */
  22418. width: number;
  22419. /**
  22420. * Heighht
  22421. */
  22422. height: number;
  22423. }
  22424. /**
  22425. * Size containing widht and height
  22426. */
  22427. class Size implements ISize {
  22428. /**
  22429. * Width
  22430. */
  22431. width: number;
  22432. /**
  22433. * Height
  22434. */
  22435. height: number;
  22436. /**
  22437. * Creates a Size object from the given width and height (floats).
  22438. * @param width width of the new size
  22439. * @param height height of the new size
  22440. */
  22441. constructor(width: number, height: number);
  22442. /**
  22443. * Returns a string with the Size width and height
  22444. * @returns a string with the Size width and height
  22445. */
  22446. toString(): string;
  22447. /**
  22448. * "Size"
  22449. * @returns the string "Size"
  22450. */
  22451. getClassName(): string;
  22452. /**
  22453. * Returns the Size hash code.
  22454. * @returns a hash code for a unique width and height
  22455. */
  22456. getHashCode(): number;
  22457. /**
  22458. * Updates the current size from the given one.
  22459. * @param src the given size
  22460. */
  22461. copyFrom(src: Size): void;
  22462. /**
  22463. * Updates in place the current Size from the given floats.
  22464. * @param width width of the new size
  22465. * @param height height of the new size
  22466. * @returns the updated Size.
  22467. */
  22468. copyFromFloats(width: number, height: number): Size;
  22469. /**
  22470. * Updates in place the current Size from the given floats.
  22471. * @param width width to set
  22472. * @param height height to set
  22473. * @returns the updated Size.
  22474. */
  22475. set(width: number, height: number): Size;
  22476. /**
  22477. * Multiplies the width and height by numbers
  22478. * @param w factor to multiple the width by
  22479. * @param h factor to multiple the height by
  22480. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22481. */
  22482. multiplyByFloats(w: number, h: number): Size;
  22483. /**
  22484. * Clones the size
  22485. * @returns a new Size copied from the given one.
  22486. */
  22487. clone(): Size;
  22488. /**
  22489. * True if the current Size and the given one width and height are strictly equal.
  22490. * @param other the other size to compare against
  22491. * @returns True if the current Size and the given one width and height are strictly equal.
  22492. */
  22493. equals(other: Size): boolean;
  22494. /**
  22495. * The surface of the Size : width * height (float).
  22496. */
  22497. readonly surface: number;
  22498. /**
  22499. * Create a new size of zero
  22500. * @returns a new Size set to (0.0, 0.0)
  22501. */
  22502. static Zero(): Size;
  22503. /**
  22504. * Sums the width and height of two sizes
  22505. * @param otherSize size to add to this size
  22506. * @returns a new Size set as the addition result of the current Size and the given one.
  22507. */
  22508. add(otherSize: Size): Size;
  22509. /**
  22510. * Subtracts the width and height of two
  22511. * @param otherSize size to subtract to this size
  22512. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22513. */
  22514. subtract(otherSize: Size): Size;
  22515. /**
  22516. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22517. * @param start starting size to lerp between
  22518. * @param end end size to lerp between
  22519. * @param amount amount to lerp between the start and end values
  22520. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22521. */
  22522. static Lerp(start: Size, end: Size, amount: number): Size;
  22523. }
  22524. /**
  22525. * Class used to store quaternion data
  22526. * @see https://en.wikipedia.org/wiki/Quaternion
  22527. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22528. */
  22529. class Quaternion {
  22530. /** defines the first component (0 by default) */
  22531. x: number;
  22532. /** defines the second component (0 by default) */
  22533. y: number;
  22534. /** defines the third component (0 by default) */
  22535. z: number;
  22536. /** defines the fourth component (1.0 by default) */
  22537. w: number;
  22538. /**
  22539. * Creates a new Quaternion from the given floats
  22540. * @param x defines the first component (0 by default)
  22541. * @param y defines the second component (0 by default)
  22542. * @param z defines the third component (0 by default)
  22543. * @param w defines the fourth component (1.0 by default)
  22544. */
  22545. constructor(
  22546. /** defines the first component (0 by default) */
  22547. x?: number,
  22548. /** defines the second component (0 by default) */
  22549. y?: number,
  22550. /** defines the third component (0 by default) */
  22551. z?: number,
  22552. /** defines the fourth component (1.0 by default) */
  22553. w?: number);
  22554. /**
  22555. * Gets a string representation for the current quaternion
  22556. * @returns a string with the Quaternion coordinates
  22557. */
  22558. toString(): string;
  22559. /**
  22560. * Gets the class name of the quaternion
  22561. * @returns the string "Quaternion"
  22562. */
  22563. getClassName(): string;
  22564. /**
  22565. * Gets a hash code for this quaternion
  22566. * @returns the quaternion hash code
  22567. */
  22568. getHashCode(): number;
  22569. /**
  22570. * Copy the quaternion to an array
  22571. * @returns a new array populated with 4 elements from the quaternion coordinates
  22572. */
  22573. asArray(): number[];
  22574. /**
  22575. * Check if two quaternions are equals
  22576. * @param otherQuaternion defines the second operand
  22577. * @return true if the current quaternion and the given one coordinates are strictly equals
  22578. */
  22579. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22580. /**
  22581. * Clone the current quaternion
  22582. * @returns a new quaternion copied from the current one
  22583. */
  22584. clone(): Quaternion;
  22585. /**
  22586. * Copy a quaternion to the current one
  22587. * @param other defines the other quaternion
  22588. * @returns the updated current quaternion
  22589. */
  22590. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22591. /**
  22592. * Updates the current quaternion with the given float coordinates
  22593. * @param x defines the x coordinate
  22594. * @param y defines the y coordinate
  22595. * @param z defines the z coordinate
  22596. * @param w defines the w coordinate
  22597. * @returns the updated current quaternion
  22598. */
  22599. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22600. /**
  22601. * Updates the current quaternion from the given float coordinates
  22602. * @param x defines the x coordinate
  22603. * @param y defines the y coordinate
  22604. * @param z defines the z coordinate
  22605. * @param w defines the w coordinate
  22606. * @returns the updated current quaternion
  22607. */
  22608. set(x: number, y: number, z: number, w: number): Quaternion;
  22609. /**
  22610. * Adds two quaternions
  22611. * @param other defines the second operand
  22612. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22613. */
  22614. add(other: DeepImmutable<Quaternion>): Quaternion;
  22615. /**
  22616. * Add a quaternion to the current one
  22617. * @param other defines the quaternion to add
  22618. * @returns the current quaternion
  22619. */
  22620. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22621. /**
  22622. * Subtract two quaternions
  22623. * @param other defines the second operand
  22624. * @returns a new quaternion as the subtraction result of the given one from the current one
  22625. */
  22626. subtract(other: Quaternion): Quaternion;
  22627. /**
  22628. * Multiplies the current quaternion by a scale factor
  22629. * @param value defines the scale factor
  22630. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22631. */
  22632. scale(value: number): Quaternion;
  22633. /**
  22634. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22635. * @param scale defines the scale factor
  22636. * @param result defines the Quaternion object where to store the result
  22637. * @returns the unmodified current quaternion
  22638. */
  22639. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22640. /**
  22641. * Multiplies in place the current quaternion by a scale factor
  22642. * @param value defines the scale factor
  22643. * @returns the current modified quaternion
  22644. */
  22645. scaleInPlace(value: number): Quaternion;
  22646. /**
  22647. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22648. * @param scale defines the scale factor
  22649. * @param result defines the Quaternion object where to store the result
  22650. * @returns the unmodified current quaternion
  22651. */
  22652. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22653. /**
  22654. * Multiplies two quaternions
  22655. * @param q1 defines the second operand
  22656. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22657. */
  22658. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22659. /**
  22660. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22661. * @param q1 defines the second operand
  22662. * @param result defines the target quaternion
  22663. * @returns the current quaternion
  22664. */
  22665. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22666. /**
  22667. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22668. * @param q1 defines the second operand
  22669. * @returns the currentupdated quaternion
  22670. */
  22671. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22672. /**
  22673. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22674. * @param ref defines the target quaternion
  22675. * @returns the current quaternion
  22676. */
  22677. conjugateToRef(ref: Quaternion): Quaternion;
  22678. /**
  22679. * Conjugates in place (1-q) the current quaternion
  22680. * @returns the current updated quaternion
  22681. */
  22682. conjugateInPlace(): Quaternion;
  22683. /**
  22684. * Conjugates in place (1-q) the current quaternion
  22685. * @returns a new quaternion
  22686. */
  22687. conjugate(): Quaternion;
  22688. /**
  22689. * Gets length of current quaternion
  22690. * @returns the quaternion length (float)
  22691. */
  22692. length(): number;
  22693. /**
  22694. * Normalize in place the current quaternion
  22695. * @returns the current updated quaternion
  22696. */
  22697. normalize(): Quaternion;
  22698. /**
  22699. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22700. * @param order is a reserved parameter and is ignore for now
  22701. * @returns a new Vector3 containing the Euler angles
  22702. */
  22703. toEulerAngles(order?: string): Vector3;
  22704. /**
  22705. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22706. * @param result defines the vector which will be filled with the Euler angles
  22707. * @param order is a reserved parameter and is ignore for now
  22708. * @returns the current unchanged quaternion
  22709. */
  22710. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22711. /**
  22712. * Updates the given rotation matrix with the current quaternion values
  22713. * @param result defines the target matrix
  22714. * @returns the current unchanged quaternion
  22715. */
  22716. toRotationMatrix(result: Matrix): Quaternion;
  22717. /**
  22718. * Updates the current quaternion from the given rotation matrix values
  22719. * @param matrix defines the source matrix
  22720. * @returns the current updated quaternion
  22721. */
  22722. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22723. /**
  22724. * Creates a new quaternion from a rotation matrix
  22725. * @param matrix defines the source matrix
  22726. * @returns a new quaternion created from the given rotation matrix values
  22727. */
  22728. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22729. /**
  22730. * Updates the given quaternion with the given rotation matrix values
  22731. * @param matrix defines the source matrix
  22732. * @param result defines the target quaternion
  22733. */
  22734. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22735. /**
  22736. * Returns the dot product (float) between the quaternions "left" and "right"
  22737. * @param left defines the left operand
  22738. * @param right defines the right operand
  22739. * @returns the dot product
  22740. */
  22741. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22742. /**
  22743. * Checks if the two quaternions are close to each other
  22744. * @param quat0 defines the first quaternion to check
  22745. * @param quat1 defines the second quaternion to check
  22746. * @returns true if the two quaternions are close to each other
  22747. */
  22748. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22749. /**
  22750. * Creates an empty quaternion
  22751. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22752. */
  22753. static Zero(): Quaternion;
  22754. /**
  22755. * Inverse a given quaternion
  22756. * @param q defines the source quaternion
  22757. * @returns a new quaternion as the inverted current quaternion
  22758. */
  22759. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22760. /**
  22761. * Inverse a given quaternion
  22762. * @param q defines the source quaternion
  22763. * @param result the quaternion the result will be stored in
  22764. * @returns the result quaternion
  22765. */
  22766. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22767. /**
  22768. * Creates an identity quaternion
  22769. * @returns the identity quaternion
  22770. */
  22771. static Identity(): Quaternion;
  22772. /**
  22773. * Gets a boolean indicating if the given quaternion is identity
  22774. * @param quaternion defines the quaternion to check
  22775. * @returns true if the quaternion is identity
  22776. */
  22777. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22778. /**
  22779. * Creates a quaternion from a rotation around an axis
  22780. * @param axis defines the axis to use
  22781. * @param angle defines the angle to use
  22782. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22783. */
  22784. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22785. /**
  22786. * Creates a rotation around an axis and stores it into the given quaternion
  22787. * @param axis defines the axis to use
  22788. * @param angle defines the angle to use
  22789. * @param result defines the target quaternion
  22790. * @returns the target quaternion
  22791. */
  22792. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22793. /**
  22794. * Creates a new quaternion from data stored into an array
  22795. * @param array defines the data source
  22796. * @param offset defines the offset in the source array where the data starts
  22797. * @returns a new quaternion
  22798. */
  22799. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22800. /**
  22801. * Create a quaternion from Euler rotation angles
  22802. * @param x Pitch
  22803. * @param y Yaw
  22804. * @param z Roll
  22805. * @returns the new Quaternion
  22806. */
  22807. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22808. /**
  22809. * Updates a quaternion from Euler rotation angles
  22810. * @param x Pitch
  22811. * @param y Yaw
  22812. * @param z Roll
  22813. * @param result the quaternion to store the result
  22814. * @returns the updated quaternion
  22815. */
  22816. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22817. /**
  22818. * Create a quaternion from Euler rotation vector
  22819. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22820. * @returns the new Quaternion
  22821. */
  22822. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22823. /**
  22824. * Updates a quaternion from Euler rotation vector
  22825. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22826. * @param result the quaternion to store the result
  22827. * @returns the updated quaternion
  22828. */
  22829. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22830. /**
  22831. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22832. * @param yaw defines the rotation around Y axis
  22833. * @param pitch defines the rotation around X axis
  22834. * @param roll defines the rotation around Z axis
  22835. * @returns the new quaternion
  22836. */
  22837. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22838. /**
  22839. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22840. * @param yaw defines the rotation around Y axis
  22841. * @param pitch defines the rotation around X axis
  22842. * @param roll defines the rotation around Z axis
  22843. * @param result defines the target quaternion
  22844. */
  22845. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22846. /**
  22847. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22848. * @param alpha defines the rotation around first axis
  22849. * @param beta defines the rotation around second axis
  22850. * @param gamma defines the rotation around third axis
  22851. * @returns the new quaternion
  22852. */
  22853. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22854. /**
  22855. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22856. * @param alpha defines the rotation around first axis
  22857. * @param beta defines the rotation around second axis
  22858. * @param gamma defines the rotation around third axis
  22859. * @param result defines the target quaternion
  22860. */
  22861. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22862. /**
  22863. * 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)
  22864. * @param axis1 defines the first axis
  22865. * @param axis2 defines the second axis
  22866. * @param axis3 defines the third axis
  22867. * @returns the new quaternion
  22868. */
  22869. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22870. /**
  22871. * 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
  22872. * @param axis1 defines the first axis
  22873. * @param axis2 defines the second axis
  22874. * @param axis3 defines the third axis
  22875. * @param ref defines the target quaternion
  22876. */
  22877. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22878. /**
  22879. * Interpolates between two quaternions
  22880. * @param left defines first quaternion
  22881. * @param right defines second quaternion
  22882. * @param amount defines the gradient to use
  22883. * @returns the new interpolated quaternion
  22884. */
  22885. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22886. /**
  22887. * Interpolates between two quaternions and stores it into a target quaternion
  22888. * @param left defines first quaternion
  22889. * @param right defines second quaternion
  22890. * @param amount defines the gradient to use
  22891. * @param result defines the target quaternion
  22892. */
  22893. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22894. /**
  22895. * Interpolate between two quaternions using Hermite interpolation
  22896. * @param value1 defines first quaternion
  22897. * @param tangent1 defines the incoming tangent
  22898. * @param value2 defines second quaternion
  22899. * @param tangent2 defines the outgoing tangent
  22900. * @param amount defines the target quaternion
  22901. * @returns the new interpolated quaternion
  22902. */
  22903. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22904. }
  22905. /**
  22906. * Class used to store matrix data (4x4)
  22907. */
  22908. class Matrix {
  22909. private static _updateFlagSeed;
  22910. private static _identityReadOnly;
  22911. private _isIdentity;
  22912. private _isIdentityDirty;
  22913. private _isIdentity3x2;
  22914. private _isIdentity3x2Dirty;
  22915. /**
  22916. * Gets the update flag of the matrix which is an unique number for the matrix.
  22917. * It will be incremented every time the matrix data change.
  22918. * You can use it to speed the comparison between two versions of the same matrix.
  22919. */
  22920. updateFlag: number;
  22921. private readonly _m;
  22922. /**
  22923. * Gets the internal data of the matrix
  22924. */
  22925. readonly m: DeepImmutable<Float32Array>;
  22926. /** @hidden */
  22927. _markAsUpdated(): void;
  22928. /** @hidden */
  22929. private _updateIdentityStatus;
  22930. /**
  22931. * Creates an empty matrix (filled with zeros)
  22932. */
  22933. constructor();
  22934. /**
  22935. * Check if the current matrix is identity
  22936. * @returns true is the matrix is the identity matrix
  22937. */
  22938. isIdentity(): boolean;
  22939. /**
  22940. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22941. * @returns true is the matrix is the identity matrix
  22942. */
  22943. isIdentityAs3x2(): boolean;
  22944. /**
  22945. * Gets the determinant of the matrix
  22946. * @returns the matrix determinant
  22947. */
  22948. determinant(): number;
  22949. /**
  22950. * Returns the matrix as a Float32Array
  22951. * @returns the matrix underlying array
  22952. */
  22953. toArray(): DeepImmutable<Float32Array>;
  22954. /**
  22955. * Returns the matrix as a Float32Array
  22956. * @returns the matrix underlying array.
  22957. */
  22958. asArray(): DeepImmutable<Float32Array>;
  22959. /**
  22960. * Inverts the current matrix in place
  22961. * @returns the current inverted matrix
  22962. */
  22963. invert(): Matrix;
  22964. /**
  22965. * Sets all the matrix elements to zero
  22966. * @returns the current matrix
  22967. */
  22968. reset(): Matrix;
  22969. /**
  22970. * Adds the current matrix with a second one
  22971. * @param other defines the matrix to add
  22972. * @returns a new matrix as the addition of the current matrix and the given one
  22973. */
  22974. add(other: DeepImmutable<Matrix>): Matrix;
  22975. /**
  22976. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22977. * @param other defines the matrix to add
  22978. * @param result defines the target matrix
  22979. * @returns the current matrix
  22980. */
  22981. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22982. /**
  22983. * Adds in place the given matrix to the current matrix
  22984. * @param other defines the second operand
  22985. * @returns the current updated matrix
  22986. */
  22987. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22988. /**
  22989. * Sets the given matrix to the current inverted Matrix
  22990. * @param other defines the target matrix
  22991. * @returns the unmodified current matrix
  22992. */
  22993. invertToRef(other: Matrix): Matrix;
  22994. /**
  22995. * add a value at the specified position in the current Matrix
  22996. * @param index the index of the value within the matrix. between 0 and 15.
  22997. * @param value the value to be added
  22998. * @returns the current updated matrix
  22999. */
  23000. addAtIndex(index: number, value: number): Matrix;
  23001. /**
  23002. * mutiply the specified position in the current Matrix by a value
  23003. * @param index the index of the value within the matrix. between 0 and 15.
  23004. * @param value the value to be added
  23005. * @returns the current updated matrix
  23006. */
  23007. multiplyAtIndex(index: number, value: number): Matrix;
  23008. /**
  23009. * Inserts the translation vector (using 3 floats) in the current matrix
  23010. * @param x defines the 1st component of the translation
  23011. * @param y defines the 2nd component of the translation
  23012. * @param z defines the 3rd component of the translation
  23013. * @returns the current updated matrix
  23014. */
  23015. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  23016. /**
  23017. * Inserts the translation vector in the current matrix
  23018. * @param vector3 defines the translation to insert
  23019. * @returns the current updated matrix
  23020. */
  23021. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  23022. /**
  23023. * Gets the translation value of the current matrix
  23024. * @returns a new Vector3 as the extracted translation from the matrix
  23025. */
  23026. getTranslation(): Vector3;
  23027. /**
  23028. * Fill a Vector3 with the extracted translation from the matrix
  23029. * @param result defines the Vector3 where to store the translation
  23030. * @returns the current matrix
  23031. */
  23032. getTranslationToRef(result: Vector3): Matrix;
  23033. /**
  23034. * Remove rotation and scaling part from the matrix
  23035. * @returns the updated matrix
  23036. */
  23037. removeRotationAndScaling(): Matrix;
  23038. /**
  23039. * Multiply two matrices
  23040. * @param other defines the second operand
  23041. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  23042. */
  23043. multiply(other: DeepImmutable<Matrix>): Matrix;
  23044. /**
  23045. * Copy the current matrix from the given one
  23046. * @param other defines the source matrix
  23047. * @returns the current updated matrix
  23048. */
  23049. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  23050. /**
  23051. * Populates the given array from the starting index with the current matrix values
  23052. * @param array defines the target array
  23053. * @param offset defines the offset in the target array where to start storing values
  23054. * @returns the current matrix
  23055. */
  23056. copyToArray(array: Float32Array, offset?: number): Matrix;
  23057. /**
  23058. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  23059. * @param other defines the second operand
  23060. * @param result defines the matrix where to store the multiplication
  23061. * @returns the current matrix
  23062. */
  23063. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  23064. /**
  23065. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  23066. * @param other defines the second operand
  23067. * @param result defines the array where to store the multiplication
  23068. * @param offset defines the offset in the target array where to start storing values
  23069. * @returns the current matrix
  23070. */
  23071. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  23072. /**
  23073. * Check equality between this matrix and a second one
  23074. * @param value defines the second matrix to compare
  23075. * @returns true is the current matrix and the given one values are strictly equal
  23076. */
  23077. equals(value: DeepImmutable<Matrix>): boolean;
  23078. /**
  23079. * Clone the current matrix
  23080. * @returns a new matrix from the current matrix
  23081. */
  23082. clone(): Matrix;
  23083. /**
  23084. * Returns the name of the current matrix class
  23085. * @returns the string "Matrix"
  23086. */
  23087. getClassName(): string;
  23088. /**
  23089. * Gets the hash code of the current matrix
  23090. * @returns the hash code
  23091. */
  23092. getHashCode(): number;
  23093. /**
  23094. * Decomposes the current Matrix into a translation, rotation and scaling components
  23095. * @param scale defines the scale vector3 given as a reference to update
  23096. * @param rotation defines the rotation quaternion given as a reference to update
  23097. * @param translation defines the translation vector3 given as a reference to update
  23098. * @returns true if operation was successful
  23099. */
  23100. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  23101. /**
  23102. * Gets specific row of the matrix
  23103. * @param index defines the number of the row to get
  23104. * @returns the index-th row of the current matrix as a new Vector4
  23105. */
  23106. getRow(index: number): Nullable<Vector4>;
  23107. /**
  23108. * Sets the index-th row of the current matrix to the vector4 values
  23109. * @param index defines the number of the row to set
  23110. * @param row defines the target vector4
  23111. * @returns the updated current matrix
  23112. */
  23113. setRow(index: number, row: Vector4): Matrix;
  23114. /**
  23115. * Compute the transpose of the matrix
  23116. * @returns the new transposed matrix
  23117. */
  23118. transpose(): Matrix;
  23119. /**
  23120. * Compute the transpose of the matrix and store it in a given matrix
  23121. * @param result defines the target matrix
  23122. * @returns the current matrix
  23123. */
  23124. transposeToRef(result: Matrix): Matrix;
  23125. /**
  23126. * Sets the index-th row of the current matrix with the given 4 x float values
  23127. * @param index defines the row index
  23128. * @param x defines the x component to set
  23129. * @param y defines the y component to set
  23130. * @param z defines the z component to set
  23131. * @param w defines the w component to set
  23132. * @returns the updated current matrix
  23133. */
  23134. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23135. /**
  23136. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23137. * @param scale defines the scale factor
  23138. * @returns a new matrix
  23139. */
  23140. scale(scale: number): Matrix;
  23141. /**
  23142. * Scale the current matrix values by a factor to a given result matrix
  23143. * @param scale defines the scale factor
  23144. * @param result defines the matrix to store the result
  23145. * @returns the current matrix
  23146. */
  23147. scaleToRef(scale: number, result: Matrix): Matrix;
  23148. /**
  23149. * Scale the current matrix values by a factor and add the result to a given matrix
  23150. * @param scale defines the scale factor
  23151. * @param result defines the Matrix to store the result
  23152. * @returns the current matrix
  23153. */
  23154. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23155. /**
  23156. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23157. * @param ref matrix to store the result
  23158. */
  23159. toNormalMatrix(ref: Matrix): void;
  23160. /**
  23161. * Gets only rotation part of the current matrix
  23162. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23163. */
  23164. getRotationMatrix(): Matrix;
  23165. /**
  23166. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23167. * @param result defines the target matrix to store data to
  23168. * @returns the current matrix
  23169. */
  23170. getRotationMatrixToRef(result: Matrix): Matrix;
  23171. /**
  23172. * Toggles model matrix from being right handed to left handed in place and vice versa
  23173. */
  23174. toggleModelMatrixHandInPlace(): void;
  23175. /**
  23176. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23177. */
  23178. toggleProjectionMatrixHandInPlace(): void;
  23179. /**
  23180. * Creates a matrix from an array
  23181. * @param array defines the source array
  23182. * @param offset defines an offset in the source array
  23183. * @returns a new Matrix set from the starting index of the given array
  23184. */
  23185. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23186. /**
  23187. * Copy the content of an array into a given matrix
  23188. * @param array defines the source array
  23189. * @param offset defines an offset in the source array
  23190. * @param result defines the target matrix
  23191. */
  23192. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23193. /**
  23194. * Stores an array into a matrix after having multiplied each component by a given factor
  23195. * @param array defines the source array
  23196. * @param offset defines the offset in the source array
  23197. * @param scale defines the scaling factor
  23198. * @param result defines the target matrix
  23199. */
  23200. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23201. /**
  23202. * Gets an identity matrix that must not be updated
  23203. */
  23204. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23205. /**
  23206. * Stores a list of values (16) inside a given matrix
  23207. * @param initialM11 defines 1st value of 1st row
  23208. * @param initialM12 defines 2nd value of 1st row
  23209. * @param initialM13 defines 3rd value of 1st row
  23210. * @param initialM14 defines 4th value of 1st row
  23211. * @param initialM21 defines 1st value of 2nd row
  23212. * @param initialM22 defines 2nd value of 2nd row
  23213. * @param initialM23 defines 3rd value of 2nd row
  23214. * @param initialM24 defines 4th value of 2nd row
  23215. * @param initialM31 defines 1st value of 3rd row
  23216. * @param initialM32 defines 2nd value of 3rd row
  23217. * @param initialM33 defines 3rd value of 3rd row
  23218. * @param initialM34 defines 4th value of 3rd row
  23219. * @param initialM41 defines 1st value of 4th row
  23220. * @param initialM42 defines 2nd value of 4th row
  23221. * @param initialM43 defines 3rd value of 4th row
  23222. * @param initialM44 defines 4th value of 4th row
  23223. * @param result defines the target matrix
  23224. */
  23225. 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;
  23226. /**
  23227. * Creates new matrix from a list of values (16)
  23228. * @param initialM11 defines 1st value of 1st row
  23229. * @param initialM12 defines 2nd value of 1st row
  23230. * @param initialM13 defines 3rd value of 1st row
  23231. * @param initialM14 defines 4th value of 1st row
  23232. * @param initialM21 defines 1st value of 2nd row
  23233. * @param initialM22 defines 2nd value of 2nd row
  23234. * @param initialM23 defines 3rd value of 2nd row
  23235. * @param initialM24 defines 4th value of 2nd row
  23236. * @param initialM31 defines 1st value of 3rd row
  23237. * @param initialM32 defines 2nd value of 3rd row
  23238. * @param initialM33 defines 3rd value of 3rd row
  23239. * @param initialM34 defines 4th value of 3rd row
  23240. * @param initialM41 defines 1st value of 4th row
  23241. * @param initialM42 defines 2nd value of 4th row
  23242. * @param initialM43 defines 3rd value of 4th row
  23243. * @param initialM44 defines 4th value of 4th row
  23244. * @returns the new matrix
  23245. */
  23246. 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;
  23247. /**
  23248. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23249. * @param scale defines the scale vector3
  23250. * @param rotation defines the rotation quaternion
  23251. * @param translation defines the translation vector3
  23252. * @returns a new matrix
  23253. */
  23254. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23255. /**
  23256. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23257. * @param scale defines the scale vector3
  23258. * @param rotation defines the rotation quaternion
  23259. * @param translation defines the translation vector3
  23260. * @param result defines the target matrix
  23261. */
  23262. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23263. /**
  23264. * Creates a new identity matrix
  23265. * @returns a new identity matrix
  23266. */
  23267. static Identity(): Matrix;
  23268. /**
  23269. * Creates a new identity matrix and stores the result in a given matrix
  23270. * @param result defines the target matrix
  23271. */
  23272. static IdentityToRef(result: Matrix): void;
  23273. /**
  23274. * Creates a new zero matrix
  23275. * @returns a new zero matrix
  23276. */
  23277. static Zero(): Matrix;
  23278. /**
  23279. * Creates a new rotation matrix for "angle" radians around the X axis
  23280. * @param angle defines the angle (in radians) to use
  23281. * @return the new matrix
  23282. */
  23283. static RotationX(angle: number): Matrix;
  23284. /**
  23285. * Creates a new matrix as the invert of a given matrix
  23286. * @param source defines the source matrix
  23287. * @returns the new matrix
  23288. */
  23289. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23290. /**
  23291. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23292. * @param angle defines the angle (in radians) to use
  23293. * @param result defines the target matrix
  23294. */
  23295. static RotationXToRef(angle: number, result: Matrix): void;
  23296. /**
  23297. * Creates a new rotation matrix for "angle" radians around the Y axis
  23298. * @param angle defines the angle (in radians) to use
  23299. * @return the new matrix
  23300. */
  23301. static RotationY(angle: number): Matrix;
  23302. /**
  23303. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23304. * @param angle defines the angle (in radians) to use
  23305. * @param result defines the target matrix
  23306. */
  23307. static RotationYToRef(angle: number, result: Matrix): void;
  23308. /**
  23309. * Creates a new rotation matrix for "angle" radians around the Z axis
  23310. * @param angle defines the angle (in radians) to use
  23311. * @return the new matrix
  23312. */
  23313. static RotationZ(angle: number): Matrix;
  23314. /**
  23315. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23316. * @param angle defines the angle (in radians) to use
  23317. * @param result defines the target matrix
  23318. */
  23319. static RotationZToRef(angle: number, result: Matrix): void;
  23320. /**
  23321. * Creates a new rotation matrix for "angle" radians around the given axis
  23322. * @param axis defines the axis to use
  23323. * @param angle defines the angle (in radians) to use
  23324. * @return the new matrix
  23325. */
  23326. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23327. /**
  23328. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23329. * @param axis defines the axis to use
  23330. * @param angle defines the angle (in radians) to use
  23331. * @param result defines the target matrix
  23332. */
  23333. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23334. /**
  23335. * Creates a rotation matrix
  23336. * @param yaw defines the yaw angle in radians (Y axis)
  23337. * @param pitch defines the pitch angle in radians (X axis)
  23338. * @param roll defines the roll angle in radians (X axis)
  23339. * @returns the new rotation matrix
  23340. */
  23341. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23342. /**
  23343. * Creates a rotation matrix and stores it in a given matrix
  23344. * @param yaw defines the yaw angle in radians (Y axis)
  23345. * @param pitch defines the pitch angle in radians (X axis)
  23346. * @param roll defines the roll angle in radians (X axis)
  23347. * @param result defines the target matrix
  23348. */
  23349. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23350. /**
  23351. * Creates a scaling matrix
  23352. * @param x defines the scale factor on X axis
  23353. * @param y defines the scale factor on Y axis
  23354. * @param z defines the scale factor on Z axis
  23355. * @returns the new matrix
  23356. */
  23357. static Scaling(x: number, y: number, z: number): Matrix;
  23358. /**
  23359. * Creates a scaling matrix and stores it in a given matrix
  23360. * @param x defines the scale factor on X axis
  23361. * @param y defines the scale factor on Y axis
  23362. * @param z defines the scale factor on Z axis
  23363. * @param result defines the target matrix
  23364. */
  23365. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23366. /**
  23367. * Creates a translation matrix
  23368. * @param x defines the translation on X axis
  23369. * @param y defines the translation on Y axis
  23370. * @param z defines the translationon Z axis
  23371. * @returns the new matrix
  23372. */
  23373. static Translation(x: number, y: number, z: number): Matrix;
  23374. /**
  23375. * Creates a translation matrix and stores it in a given matrix
  23376. * @param x defines the translation on X axis
  23377. * @param y defines the translation on Y axis
  23378. * @param z defines the translationon Z axis
  23379. * @param result defines the target matrix
  23380. */
  23381. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23382. /**
  23383. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23384. * @param startValue defines the start value
  23385. * @param endValue defines the end value
  23386. * @param gradient defines the gradient factor
  23387. * @returns the new matrix
  23388. */
  23389. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23390. /**
  23391. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23392. * @param startValue defines the start value
  23393. * @param endValue defines the end value
  23394. * @param gradient defines the gradient factor
  23395. * @param result defines the Matrix object where to store data
  23396. */
  23397. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23398. /**
  23399. * Builds a new matrix whose values are computed by:
  23400. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23401. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23402. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23403. * @param startValue defines the first matrix
  23404. * @param endValue defines the second matrix
  23405. * @param gradient defines the gradient between the two matrices
  23406. * @returns the new matrix
  23407. */
  23408. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23409. /**
  23410. * Update a matrix to values which are computed by:
  23411. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23412. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23413. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23414. * @param startValue defines the first matrix
  23415. * @param endValue defines the second matrix
  23416. * @param gradient defines the gradient between the two matrices
  23417. * @param result defines the target matrix
  23418. */
  23419. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23420. /**
  23421. * 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"
  23422. * This function works in left handed mode
  23423. * @param eye defines the final position of the entity
  23424. * @param target defines where the entity should look at
  23425. * @param up defines the up vector for the entity
  23426. * @returns the new matrix
  23427. */
  23428. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23429. /**
  23430. * 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".
  23431. * This function works in left handed mode
  23432. * @param eye defines the final position of the entity
  23433. * @param target defines where the entity should look at
  23434. * @param up defines the up vector for the entity
  23435. * @param result defines the target matrix
  23436. */
  23437. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23438. /**
  23439. * 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"
  23440. * This function works in right handed mode
  23441. * @param eye defines the final position of the entity
  23442. * @param target defines where the entity should look at
  23443. * @param up defines the up vector for the entity
  23444. * @returns the new matrix
  23445. */
  23446. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23447. /**
  23448. * 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".
  23449. * This function works in right handed mode
  23450. * @param eye defines the final position of the entity
  23451. * @param target defines where the entity should look at
  23452. * @param up defines the up vector for the entity
  23453. * @param result defines the target matrix
  23454. */
  23455. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23456. /**
  23457. * Create a left-handed orthographic projection matrix
  23458. * @param width defines the viewport width
  23459. * @param height defines the viewport height
  23460. * @param znear defines the near clip plane
  23461. * @param zfar defines the far clip plane
  23462. * @returns a new matrix as a left-handed orthographic projection matrix
  23463. */
  23464. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23465. /**
  23466. * Store a left-handed orthographic projection to a given matrix
  23467. * @param width defines the viewport width
  23468. * @param height defines the viewport height
  23469. * @param znear defines the near clip plane
  23470. * @param zfar defines the far clip plane
  23471. * @param result defines the target matrix
  23472. */
  23473. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23474. /**
  23475. * Create a left-handed orthographic projection matrix
  23476. * @param left defines the viewport left coordinate
  23477. * @param right defines the viewport right coordinate
  23478. * @param bottom defines the viewport bottom coordinate
  23479. * @param top defines the viewport top coordinate
  23480. * @param znear defines the near clip plane
  23481. * @param zfar defines the far clip plane
  23482. * @returns a new matrix as a left-handed orthographic projection matrix
  23483. */
  23484. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23485. /**
  23486. * Stores a left-handed orthographic projection into a given matrix
  23487. * @param left defines the viewport left coordinate
  23488. * @param right defines the viewport right coordinate
  23489. * @param bottom defines the viewport bottom coordinate
  23490. * @param top defines the viewport top coordinate
  23491. * @param znear defines the near clip plane
  23492. * @param zfar defines the far clip plane
  23493. * @param result defines the target matrix
  23494. */
  23495. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23496. /**
  23497. * Creates a right-handed orthographic projection matrix
  23498. * @param left defines the viewport left coordinate
  23499. * @param right defines the viewport right coordinate
  23500. * @param bottom defines the viewport bottom coordinate
  23501. * @param top defines the viewport top coordinate
  23502. * @param znear defines the near clip plane
  23503. * @param zfar defines the far clip plane
  23504. * @returns a new matrix as a right-handed orthographic projection matrix
  23505. */
  23506. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23507. /**
  23508. * Stores a right-handed orthographic projection into a given matrix
  23509. * @param left defines the viewport left coordinate
  23510. * @param right defines the viewport right coordinate
  23511. * @param bottom defines the viewport bottom coordinate
  23512. * @param top defines the viewport top coordinate
  23513. * @param znear defines the near clip plane
  23514. * @param zfar defines the far clip plane
  23515. * @param result defines the target matrix
  23516. */
  23517. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23518. /**
  23519. * Creates a left-handed perspective projection matrix
  23520. * @param width defines the viewport width
  23521. * @param height defines the viewport height
  23522. * @param znear defines the near clip plane
  23523. * @param zfar defines the far clip plane
  23524. * @returns a new matrix as a left-handed perspective projection matrix
  23525. */
  23526. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23527. /**
  23528. * Creates a left-handed perspective projection matrix
  23529. * @param fov defines the horizontal field of view
  23530. * @param aspect defines the aspect ratio
  23531. * @param znear defines the near clip plane
  23532. * @param zfar defines the far clip plane
  23533. * @returns a new matrix as a left-handed perspective projection matrix
  23534. */
  23535. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23536. /**
  23537. * Stores a left-handed perspective projection into a given matrix
  23538. * @param fov defines the horizontal field of view
  23539. * @param aspect defines the aspect ratio
  23540. * @param znear defines the near clip plane
  23541. * @param zfar defines the far clip plane
  23542. * @param result defines the target matrix
  23543. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23544. */
  23545. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23546. /**
  23547. * Creates a right-handed perspective projection matrix
  23548. * @param fov defines the horizontal field of view
  23549. * @param aspect defines the aspect ratio
  23550. * @param znear defines the near clip plane
  23551. * @param zfar defines the far clip plane
  23552. * @returns a new matrix as a right-handed perspective projection matrix
  23553. */
  23554. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23555. /**
  23556. * Stores a right-handed perspective projection into a given matrix
  23557. * @param fov defines the horizontal field of view
  23558. * @param aspect defines the aspect ratio
  23559. * @param znear defines the near clip plane
  23560. * @param zfar defines the far clip plane
  23561. * @param result defines the target matrix
  23562. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23563. */
  23564. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23565. /**
  23566. * Stores a perspective projection for WebVR info a given matrix
  23567. * @param fov defines the field of view
  23568. * @param znear defines the near clip plane
  23569. * @param zfar defines the far clip plane
  23570. * @param result defines the target matrix
  23571. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23572. */
  23573. static PerspectiveFovWebVRToRef(fov: {
  23574. upDegrees: number;
  23575. downDegrees: number;
  23576. leftDegrees: number;
  23577. rightDegrees: number;
  23578. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23579. /**
  23580. * Computes a complete transformation matrix
  23581. * @param viewport defines the viewport to use
  23582. * @param world defines the world matrix
  23583. * @param view defines the view matrix
  23584. * @param projection defines the projection matrix
  23585. * @param zmin defines the near clip plane
  23586. * @param zmax defines the far clip plane
  23587. * @returns the transformation matrix
  23588. */
  23589. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23590. /**
  23591. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23592. * @param matrix defines the matrix to use
  23593. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23594. */
  23595. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23596. /**
  23597. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23598. * @param matrix defines the matrix to use
  23599. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23600. */
  23601. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23602. /**
  23603. * Compute the transpose of a given matrix
  23604. * @param matrix defines the matrix to transpose
  23605. * @returns the new matrix
  23606. */
  23607. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23608. /**
  23609. * Compute the transpose of a matrix and store it in a target matrix
  23610. * @param matrix defines the matrix to transpose
  23611. * @param result defines the target matrix
  23612. */
  23613. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23614. /**
  23615. * Computes a reflection matrix from a plane
  23616. * @param plane defines the reflection plane
  23617. * @returns a new matrix
  23618. */
  23619. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23620. /**
  23621. * Computes a reflection matrix from a plane
  23622. * @param plane defines the reflection plane
  23623. * @param result defines the target matrix
  23624. */
  23625. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23626. /**
  23627. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23628. * @param xaxis defines the value of the 1st axis
  23629. * @param yaxis defines the value of the 2nd axis
  23630. * @param zaxis defines the value of the 3rd axis
  23631. * @param result defines the target matrix
  23632. */
  23633. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23634. /**
  23635. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23636. * @param quat defines the quaternion to use
  23637. * @param result defines the target matrix
  23638. */
  23639. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23640. }
  23641. /**
  23642. * Represens a plane by the equation ax + by + cz + d = 0
  23643. */
  23644. class Plane {
  23645. /**
  23646. * Normal of the plane (a,b,c)
  23647. */
  23648. normal: Vector3;
  23649. /**
  23650. * d component of the plane
  23651. */
  23652. d: number;
  23653. /**
  23654. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23655. * @param a a component of the plane
  23656. * @param b b component of the plane
  23657. * @param c c component of the plane
  23658. * @param d d component of the plane
  23659. */
  23660. constructor(a: number, b: number, c: number, d: number);
  23661. /**
  23662. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23663. */
  23664. asArray(): number[];
  23665. /**
  23666. * @returns a new plane copied from the current Plane.
  23667. */
  23668. clone(): Plane;
  23669. /**
  23670. * @returns the string "Plane".
  23671. */
  23672. getClassName(): string;
  23673. /**
  23674. * @returns the Plane hash code.
  23675. */
  23676. getHashCode(): number;
  23677. /**
  23678. * Normalize the current Plane in place.
  23679. * @returns the updated Plane.
  23680. */
  23681. normalize(): Plane;
  23682. /**
  23683. * Applies a transformation the plane and returns the result
  23684. * @param transformation the transformation matrix to be applied to the plane
  23685. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23686. */
  23687. transform(transformation: DeepImmutable<Matrix>): Plane;
  23688. /**
  23689. * Calcualtte the dot product between the point and the plane normal
  23690. * @param point point to calculate the dot product with
  23691. * @returns the dot product (float) of the point coordinates and the plane normal.
  23692. */
  23693. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23694. /**
  23695. * Updates the current Plane from the plane defined by the three given points.
  23696. * @param point1 one of the points used to contruct the plane
  23697. * @param point2 one of the points used to contruct the plane
  23698. * @param point3 one of the points used to contruct the plane
  23699. * @returns the updated Plane.
  23700. */
  23701. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23702. /**
  23703. * Checks if the plane is facing a given direction
  23704. * @param direction the direction to check if the plane is facing
  23705. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23706. * @returns True is the vector "direction" is the same side than the plane normal.
  23707. */
  23708. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23709. /**
  23710. * Calculates the distance to a point
  23711. * @param point point to calculate distance to
  23712. * @returns the signed distance (float) from the given point to the Plane.
  23713. */
  23714. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23715. /**
  23716. * Creates a plane from an array
  23717. * @param array the array to create a plane from
  23718. * @returns a new Plane from the given array.
  23719. */
  23720. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23721. /**
  23722. * Creates a plane from three points
  23723. * @param point1 point used to create the plane
  23724. * @param point2 point used to create the plane
  23725. * @param point3 point used to create the plane
  23726. * @returns a new Plane defined by the three given points.
  23727. */
  23728. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23729. /**
  23730. * Creates a plane from an origin point and a normal
  23731. * @param origin origin of the plane to be constructed
  23732. * @param normal normal of the plane to be constructed
  23733. * @returns a new Plane the normal vector to this plane at the given origin point.
  23734. * Note : the vector "normal" is updated because normalized.
  23735. */
  23736. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23737. /**
  23738. * Calculates the distance from a plane and a point
  23739. * @param origin origin of the plane to be constructed
  23740. * @param normal normal of the plane to be constructed
  23741. * @param point point to calculate distance to
  23742. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23743. */
  23744. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23745. }
  23746. /**
  23747. * Class used to represent a viewport on screen
  23748. */
  23749. class Viewport {
  23750. /** viewport left coordinate */
  23751. x: number;
  23752. /** viewport top coordinate */
  23753. y: number;
  23754. /**viewport width */
  23755. width: number;
  23756. /** viewport height */
  23757. height: number;
  23758. /**
  23759. * Creates a Viewport object located at (x, y) and sized (width, height)
  23760. * @param x defines viewport left coordinate
  23761. * @param y defines viewport top coordinate
  23762. * @param width defines the viewport width
  23763. * @param height defines the viewport height
  23764. */
  23765. constructor(
  23766. /** viewport left coordinate */
  23767. x: number,
  23768. /** viewport top coordinate */
  23769. y: number,
  23770. /**viewport width */
  23771. width: number,
  23772. /** viewport height */
  23773. height: number);
  23774. /**
  23775. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23776. * @param renderWidthOrEngine defines either an engine or the rendering width
  23777. * @param renderHeight defines the rendering height
  23778. * @returns a new Viewport
  23779. */
  23780. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23781. /**
  23782. * Returns a new Viewport copied from the current one
  23783. * @returns a new Viewport
  23784. */
  23785. clone(): Viewport;
  23786. }
  23787. /**
  23788. * Reprasents a camera frustum
  23789. */
  23790. class Frustum {
  23791. /**
  23792. * Gets the planes representing the frustum
  23793. * @param transform matrix to be applied to the returned planes
  23794. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23795. */
  23796. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23797. /**
  23798. * Gets the near frustum plane transformed by the transform matrix
  23799. * @param transform transformation matrix to be applied to the resulting frustum plane
  23800. * @param frustumPlane the resuling frustum plane
  23801. */
  23802. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23803. /**
  23804. * Gets the far frustum plane transformed by the transform matrix
  23805. * @param transform transformation matrix to be applied to the resulting frustum plane
  23806. * @param frustumPlane the resuling frustum plane
  23807. */
  23808. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23809. /**
  23810. * Gets the left frustum plane transformed by the transform matrix
  23811. * @param transform transformation matrix to be applied to the resulting frustum plane
  23812. * @param frustumPlane the resuling frustum plane
  23813. */
  23814. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23815. /**
  23816. * Gets the right frustum plane transformed by the transform matrix
  23817. * @param transform transformation matrix to be applied to the resulting frustum plane
  23818. * @param frustumPlane the resuling frustum plane
  23819. */
  23820. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23821. /**
  23822. * Gets the top frustum plane transformed by the transform matrix
  23823. * @param transform transformation matrix to be applied to the resulting frustum plane
  23824. * @param frustumPlane the resuling frustum plane
  23825. */
  23826. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23827. /**
  23828. * Gets the bottom frustum plane transformed by the transform matrix
  23829. * @param transform transformation matrix to be applied to the resulting frustum plane
  23830. * @param frustumPlane the resuling frustum plane
  23831. */
  23832. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23833. /**
  23834. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23835. * @param transform transformation matrix to be applied to the resulting frustum planes
  23836. * @param frustumPlanes the resuling frustum planes
  23837. */
  23838. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23839. }
  23840. /** Defines supported spaces */
  23841. enum Space {
  23842. /** Local (object) space */
  23843. LOCAL = 0,
  23844. /** World space */
  23845. WORLD = 1,
  23846. /** Bone space */
  23847. BONE = 2
  23848. }
  23849. /** Defines the 3 main axes */
  23850. class Axis {
  23851. /** X axis */
  23852. static X: Vector3;
  23853. /** Y axis */
  23854. static Y: Vector3;
  23855. /** Z axis */
  23856. static Z: Vector3;
  23857. }
  23858. /** Class used to represent a Bezier curve */
  23859. class BezierCurve {
  23860. /**
  23861. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23862. * @param t defines the time
  23863. * @param x1 defines the left coordinate on X axis
  23864. * @param y1 defines the left coordinate on Y axis
  23865. * @param x2 defines the right coordinate on X axis
  23866. * @param y2 defines the right coordinate on Y axis
  23867. * @returns the interpolated value
  23868. */
  23869. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23870. }
  23871. /**
  23872. * Defines potential orientation for back face culling
  23873. */
  23874. enum Orientation {
  23875. /**
  23876. * Clockwise
  23877. */
  23878. CW = 0,
  23879. /** Counter clockwise */
  23880. CCW = 1
  23881. }
  23882. /**
  23883. * Defines angle representation
  23884. */
  23885. class Angle {
  23886. private _radians;
  23887. /**
  23888. * Creates an Angle object of "radians" radians (float).
  23889. */
  23890. constructor(radians: number);
  23891. /**
  23892. * Get value in degrees
  23893. * @returns the Angle value in degrees (float)
  23894. */
  23895. degrees(): number;
  23896. /**
  23897. * Get value in radians
  23898. * @returns the Angle value in radians (float)
  23899. */
  23900. radians(): number;
  23901. /**
  23902. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23903. * @param a defines first vector
  23904. * @param b defines second vector
  23905. * @returns a new Angle
  23906. */
  23907. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23908. /**
  23909. * Gets a new Angle object from the given float in radians
  23910. * @param radians defines the angle value in radians
  23911. * @returns a new Angle
  23912. */
  23913. static FromRadians(radians: number): Angle;
  23914. /**
  23915. * Gets a new Angle object from the given float in degrees
  23916. * @param degrees defines the angle value in degrees
  23917. * @returns a new Angle
  23918. */
  23919. static FromDegrees(degrees: number): Angle;
  23920. }
  23921. /**
  23922. * This represents an arc in a 2d space.
  23923. */
  23924. class Arc2 {
  23925. /** Defines the start point of the arc */
  23926. startPoint: Vector2;
  23927. /** Defines the mid point of the arc */
  23928. midPoint: Vector2;
  23929. /** Defines the end point of the arc */
  23930. endPoint: Vector2;
  23931. /**
  23932. * Defines the center point of the arc.
  23933. */
  23934. centerPoint: Vector2;
  23935. /**
  23936. * Defines the radius of the arc.
  23937. */
  23938. radius: number;
  23939. /**
  23940. * Defines the angle of the arc (from mid point to end point).
  23941. */
  23942. angle: Angle;
  23943. /**
  23944. * Defines the start angle of the arc (from start point to middle point).
  23945. */
  23946. startAngle: Angle;
  23947. /**
  23948. * Defines the orientation of the arc (clock wise/counter clock wise).
  23949. */
  23950. orientation: Orientation;
  23951. /**
  23952. * Creates an Arc object from the three given points : start, middle and end.
  23953. * @param startPoint Defines the start point of the arc
  23954. * @param midPoint Defines the midlle point of the arc
  23955. * @param endPoint Defines the end point of the arc
  23956. */
  23957. constructor(
  23958. /** Defines the start point of the arc */
  23959. startPoint: Vector2,
  23960. /** Defines the mid point of the arc */
  23961. midPoint: Vector2,
  23962. /** Defines the end point of the arc */
  23963. endPoint: Vector2);
  23964. }
  23965. /**
  23966. * Represents a 2D path made up of multiple 2D points
  23967. */
  23968. class Path2 {
  23969. private _points;
  23970. private _length;
  23971. /**
  23972. * If the path start and end point are the same
  23973. */
  23974. closed: boolean;
  23975. /**
  23976. * Creates a Path2 object from the starting 2D coordinates x and y.
  23977. * @param x the starting points x value
  23978. * @param y the starting points y value
  23979. */
  23980. constructor(x: number, y: number);
  23981. /**
  23982. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23983. * @param x the added points x value
  23984. * @param y the added points y value
  23985. * @returns the updated Path2.
  23986. */
  23987. addLineTo(x: number, y: number): Path2;
  23988. /**
  23989. * 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.
  23990. * @param midX middle point x value
  23991. * @param midY middle point y value
  23992. * @param endX end point x value
  23993. * @param endY end point y value
  23994. * @param numberOfSegments (default: 36)
  23995. * @returns the updated Path2.
  23996. */
  23997. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23998. /**
  23999. * Closes the Path2.
  24000. * @returns the Path2.
  24001. */
  24002. close(): Path2;
  24003. /**
  24004. * Gets the sum of the distance between each sequential point in the path
  24005. * @returns the Path2 total length (float).
  24006. */
  24007. length(): number;
  24008. /**
  24009. * Gets the points which construct the path
  24010. * @returns the Path2 internal array of points.
  24011. */
  24012. getPoints(): Vector2[];
  24013. /**
  24014. * Retreives the point at the distance aways from the starting point
  24015. * @param normalizedLengthPosition the length along the path to retreive the point from
  24016. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  24017. */
  24018. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  24019. /**
  24020. * Creates a new path starting from an x and y position
  24021. * @param x starting x value
  24022. * @param y starting y value
  24023. * @returns a new Path2 starting at the coordinates (x, y).
  24024. */
  24025. static StartingAt(x: number, y: number): Path2;
  24026. }
  24027. /**
  24028. * Represents a 3D path made up of multiple 3D points
  24029. */
  24030. class Path3D {
  24031. /**
  24032. * an array of Vector3, the curve axis of the Path3D
  24033. */
  24034. path: Vector3[];
  24035. private _curve;
  24036. private _distances;
  24037. private _tangents;
  24038. private _normals;
  24039. private _binormals;
  24040. private _raw;
  24041. /**
  24042. * new Path3D(path, normal, raw)
  24043. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  24044. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  24045. * @param path an array of Vector3, the curve axis of the Path3D
  24046. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  24047. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  24048. */
  24049. constructor(
  24050. /**
  24051. * an array of Vector3, the curve axis of the Path3D
  24052. */
  24053. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  24054. /**
  24055. * Returns the Path3D array of successive Vector3 designing its curve.
  24056. * @returns the Path3D array of successive Vector3 designing its curve.
  24057. */
  24058. getCurve(): Vector3[];
  24059. /**
  24060. * Returns an array populated with tangent vectors on each Path3D curve point.
  24061. * @returns an array populated with tangent vectors on each Path3D curve point.
  24062. */
  24063. getTangents(): Vector3[];
  24064. /**
  24065. * Returns an array populated with normal vectors on each Path3D curve point.
  24066. * @returns an array populated with normal vectors on each Path3D curve point.
  24067. */
  24068. getNormals(): Vector3[];
  24069. /**
  24070. * Returns an array populated with binormal vectors on each Path3D curve point.
  24071. * @returns an array populated with binormal vectors on each Path3D curve point.
  24072. */
  24073. getBinormals(): Vector3[];
  24074. /**
  24075. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  24076. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  24077. */
  24078. getDistances(): number[];
  24079. /**
  24080. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  24081. * @param path path which all values are copied into the curves points
  24082. * @param firstNormal which should be projected onto the curve
  24083. * @returns the same object updated.
  24084. */
  24085. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  24086. private _compute;
  24087. private _getFirstNonNullVector;
  24088. private _getLastNonNullVector;
  24089. private _normalVector;
  24090. }
  24091. /**
  24092. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24093. * A Curve3 is designed from a series of successive Vector3.
  24094. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  24095. */
  24096. class Curve3 {
  24097. private _points;
  24098. private _length;
  24099. /**
  24100. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  24101. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  24102. * @param v1 (Vector3) the control point
  24103. * @param v2 (Vector3) the end point of the Quadratic Bezier
  24104. * @param nbPoints (integer) the wanted number of points in the curve
  24105. * @returns the created Curve3
  24106. */
  24107. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24108. /**
  24109. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  24110. * @param v0 (Vector3) the origin point of the Cubic Bezier
  24111. * @param v1 (Vector3) the first control point
  24112. * @param v2 (Vector3) the second control point
  24113. * @param v3 (Vector3) the end point of the Cubic Bezier
  24114. * @param nbPoints (integer) the wanted number of points in the curve
  24115. * @returns the created Curve3
  24116. */
  24117. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24118. /**
  24119. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  24120. * @param p1 (Vector3) the origin point of the Hermite Spline
  24121. * @param t1 (Vector3) the tangent vector at the origin point
  24122. * @param p2 (Vector3) the end point of the Hermite Spline
  24123. * @param t2 (Vector3) the tangent vector at the end point
  24124. * @param nbPoints (integer) the wanted number of points in the curve
  24125. * @returns the created Curve3
  24126. */
  24127. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24128. /**
  24129. * Returns a Curve3 object along a CatmullRom Spline curve :
  24130. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24131. * @param nbPoints (integer) the wanted number of points between each curve control points
  24132. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24133. * @returns the created Curve3
  24134. */
  24135. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24136. /**
  24137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24138. * A Curve3 is designed from a series of successive Vector3.
  24139. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24140. * @param points points which make up the curve
  24141. */
  24142. constructor(points: Vector3[]);
  24143. /**
  24144. * @returns the Curve3 stored array of successive Vector3
  24145. */
  24146. getPoints(): Vector3[];
  24147. /**
  24148. * @returns the computed length (float) of the curve.
  24149. */
  24150. length(): number;
  24151. /**
  24152. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24153. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24154. * curveA and curveB keep unchanged.
  24155. * @param curve the curve to continue from this curve
  24156. * @returns the newly constructed curve
  24157. */
  24158. continue(curve: DeepImmutable<Curve3>): Curve3;
  24159. private _computeLength;
  24160. }
  24161. /**
  24162. * Contains position and normal vectors for a vertex
  24163. */
  24164. class PositionNormalVertex {
  24165. /** the position of the vertex (defaut: 0,0,0) */
  24166. position: Vector3;
  24167. /** the normal of the vertex (defaut: 0,1,0) */
  24168. normal: Vector3;
  24169. /**
  24170. * Creates a PositionNormalVertex
  24171. * @param position the position of the vertex (defaut: 0,0,0)
  24172. * @param normal the normal of the vertex (defaut: 0,1,0)
  24173. */
  24174. constructor(
  24175. /** the position of the vertex (defaut: 0,0,0) */
  24176. position?: Vector3,
  24177. /** the normal of the vertex (defaut: 0,1,0) */
  24178. normal?: Vector3);
  24179. /**
  24180. * Clones the PositionNormalVertex
  24181. * @returns the cloned PositionNormalVertex
  24182. */
  24183. clone(): PositionNormalVertex;
  24184. }
  24185. /**
  24186. * Contains position, normal and uv vectors for a vertex
  24187. */
  24188. class PositionNormalTextureVertex {
  24189. /** the position of the vertex (defaut: 0,0,0) */
  24190. position: Vector3;
  24191. /** the normal of the vertex (defaut: 0,1,0) */
  24192. normal: Vector3;
  24193. /** the uv of the vertex (default: 0,0) */
  24194. uv: Vector2;
  24195. /**
  24196. * Creates a PositionNormalTextureVertex
  24197. * @param position the position of the vertex (defaut: 0,0,0)
  24198. * @param normal the normal of the vertex (defaut: 0,1,0)
  24199. * @param uv the uv of the vertex (default: 0,0)
  24200. */
  24201. constructor(
  24202. /** the position of the vertex (defaut: 0,0,0) */
  24203. position?: Vector3,
  24204. /** the normal of the vertex (defaut: 0,1,0) */
  24205. normal?: Vector3,
  24206. /** the uv of the vertex (default: 0,0) */
  24207. uv?: Vector2);
  24208. /**
  24209. * Clones the PositionNormalTextureVertex
  24210. * @returns the cloned PositionNormalTextureVertex
  24211. */
  24212. clone(): PositionNormalTextureVertex;
  24213. }
  24214. /**
  24215. * @hidden
  24216. */
  24217. class Tmp {
  24218. static Color3: Color3[];
  24219. static Color4: Color4[];
  24220. static Vector2: Vector2[];
  24221. static Vector3: Vector3[];
  24222. static Vector4: Vector4[];
  24223. static Quaternion: Quaternion[];
  24224. static Matrix: Matrix[];
  24225. }
  24226. }
  24227. declare module BABYLON {
  24228. /**
  24229. * Class representing spherical polynomial coefficients to the 3rd degree
  24230. */
  24231. class SphericalPolynomial {
  24232. /**
  24233. * The x coefficients of the spherical polynomial
  24234. */
  24235. x: Vector3;
  24236. /**
  24237. * The y coefficients of the spherical polynomial
  24238. */
  24239. y: Vector3;
  24240. /**
  24241. * The z coefficients of the spherical polynomial
  24242. */
  24243. z: Vector3;
  24244. /**
  24245. * The xx coefficients of the spherical polynomial
  24246. */
  24247. xx: Vector3;
  24248. /**
  24249. * The yy coefficients of the spherical polynomial
  24250. */
  24251. yy: Vector3;
  24252. /**
  24253. * The zz coefficients of the spherical polynomial
  24254. */
  24255. zz: Vector3;
  24256. /**
  24257. * The xy coefficients of the spherical polynomial
  24258. */
  24259. xy: Vector3;
  24260. /**
  24261. * The yz coefficients of the spherical polynomial
  24262. */
  24263. yz: Vector3;
  24264. /**
  24265. * The zx coefficients of the spherical polynomial
  24266. */
  24267. zx: Vector3;
  24268. /**
  24269. * Adds an ambient color to the spherical polynomial
  24270. * @param color the color to add
  24271. */
  24272. addAmbient(color: Color3): void;
  24273. /**
  24274. * Scales the spherical polynomial by the given amount
  24275. * @param scale the amount to scale
  24276. */
  24277. scale(scale: number): void;
  24278. /**
  24279. * Gets the spherical polynomial from harmonics
  24280. * @param harmonics the spherical harmonics
  24281. * @returns the spherical polynomial
  24282. */
  24283. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24284. /**
  24285. * Constructs a spherical polynomial from an array.
  24286. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24287. * @returns the spherical polynomial
  24288. */
  24289. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24290. }
  24291. /**
  24292. * Class representing spherical harmonics coefficients to the 3rd degree
  24293. */
  24294. class SphericalHarmonics {
  24295. /**
  24296. * The l0,0 coefficients of the spherical harmonics
  24297. */
  24298. l00: Vector3;
  24299. /**
  24300. * The l1,-1 coefficients of the spherical harmonics
  24301. */
  24302. l1_1: Vector3;
  24303. /**
  24304. * The l1,0 coefficients of the spherical harmonics
  24305. */
  24306. l10: Vector3;
  24307. /**
  24308. * The l1,1 coefficients of the spherical harmonics
  24309. */
  24310. l11: Vector3;
  24311. /**
  24312. * The l2,-2 coefficients of the spherical harmonics
  24313. */
  24314. l2_2: Vector3;
  24315. /**
  24316. * The l2,-1 coefficients of the spherical harmonics
  24317. */
  24318. l2_1: Vector3;
  24319. /**
  24320. * The l2,0 coefficients of the spherical harmonics
  24321. */
  24322. l20: Vector3;
  24323. /**
  24324. * The l2,1 coefficients of the spherical harmonics
  24325. */
  24326. l21: Vector3;
  24327. /**
  24328. * The l2,2 coefficients of the spherical harmonics
  24329. */
  24330. lL22: Vector3;
  24331. /**
  24332. * Adds a light to the spherical harmonics
  24333. * @param direction the direction of the light
  24334. * @param color the color of the light
  24335. * @param deltaSolidAngle the delta solid angle of the light
  24336. */
  24337. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24338. /**
  24339. * Scales the spherical harmonics by the given amount
  24340. * @param scale the amount to scale
  24341. */
  24342. scale(scale: number): void;
  24343. /**
  24344. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24345. *
  24346. * ```
  24347. * E_lm = A_l * L_lm
  24348. * ```
  24349. *
  24350. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24351. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24352. * the scaling factors are given in equation 9.
  24353. */
  24354. convertIncidentRadianceToIrradiance(): void;
  24355. /**
  24356. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24357. *
  24358. * ```
  24359. * L = (1/pi) * E * rho
  24360. * ```
  24361. *
  24362. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24363. */
  24364. convertIrradianceToLambertianRadiance(): void;
  24365. /**
  24366. * Gets the spherical harmonics from polynomial
  24367. * @param polynomial the spherical polynomial
  24368. * @returns the spherical harmonics
  24369. */
  24370. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24371. /**
  24372. * Constructs a spherical harmonics from an array.
  24373. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24374. * @returns the spherical harmonics
  24375. */
  24376. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24377. }
  24378. }
  24379. declare module BABYLON {
  24380. /**
  24381. * Class used to store all common mesh properties
  24382. */
  24383. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24384. /** No occlusion */
  24385. static OCCLUSION_TYPE_NONE: number;
  24386. /** Occlusion set to optimisitic */
  24387. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24388. /** Occlusion set to strict */
  24389. static OCCLUSION_TYPE_STRICT: number;
  24390. /** Use an accurante occlusion algorithm */
  24391. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24392. /** Use a conservative occlusion algorithm */
  24393. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24394. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24395. * Test order :
  24396. * Is the bounding sphere outside the frustum ?
  24397. * If not, are the bounding box vertices outside the frustum ?
  24398. * It not, then the cullable object is in the frustum.
  24399. */
  24400. static readonly CULLINGSTRATEGY_STANDARD: number;
  24401. /** Culling strategy : Bounding Sphere Only.
  24402. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24403. * It's also less accurate than the standard because some not visible objects can still be selected.
  24404. * Test : is the bounding sphere outside the frustum ?
  24405. * If not, then the cullable object is in the frustum.
  24406. */
  24407. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24408. /** Culling strategy : Optimistic Inclusion.
  24409. * This in an inclusion test first, then the standard exclusion test.
  24410. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24411. * 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.
  24412. * Anyway, it's as accurate as the standard strategy.
  24413. * Test :
  24414. * Is the cullable object bounding sphere center in the frustum ?
  24415. * If not, apply the default culling strategy.
  24416. */
  24417. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24418. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24419. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24420. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24421. * 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.
  24422. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24423. * Test :
  24424. * Is the cullable object bounding sphere center in the frustum ?
  24425. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24426. */
  24427. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24428. /**
  24429. * No billboard
  24430. */
  24431. static readonly BILLBOARDMODE_NONE: number;
  24432. /** Billboard on X axis */
  24433. static readonly BILLBOARDMODE_X: number;
  24434. /** Billboard on Y axis */
  24435. static readonly BILLBOARDMODE_Y: number;
  24436. /** Billboard on Z axis */
  24437. static readonly BILLBOARDMODE_Z: number;
  24438. /** Billboard on all axes */
  24439. static readonly BILLBOARDMODE_ALL: number;
  24440. private _facetData;
  24441. /**
  24442. * The culling strategy to use to check whether the mesh must be rendered or not.
  24443. * This value can be changed at any time and will be used on the next render mesh selection.
  24444. * The possible values are :
  24445. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24446. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24447. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24448. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24449. * Please read each static variable documentation to get details about the culling process.
  24450. * */
  24451. cullingStrategy: number;
  24452. /**
  24453. * Gets the number of facets in the mesh
  24454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24455. */
  24456. readonly facetNb: number;
  24457. /**
  24458. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24459. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24460. */
  24461. partitioningSubdivisions: number;
  24462. /**
  24463. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24464. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24466. */
  24467. partitioningBBoxRatio: number;
  24468. /**
  24469. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24470. * Works only for updatable meshes.
  24471. * Doesn't work with multi-materials
  24472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24473. */
  24474. mustDepthSortFacets: boolean;
  24475. /**
  24476. * The location (Vector3) where the facet depth sort must be computed from.
  24477. * By default, the active camera position.
  24478. * Used only when facet depth sort is enabled
  24479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24480. */
  24481. facetDepthSortFrom: Vector3;
  24482. /**
  24483. * gets a boolean indicating if facetData is enabled
  24484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24485. */
  24486. readonly isFacetDataEnabled: boolean;
  24487. /** @hidden */
  24488. _updateNonUniformScalingState(value: boolean): boolean;
  24489. /**
  24490. * An event triggered when this mesh collides with another one
  24491. */
  24492. onCollideObservable: Observable<AbstractMesh>;
  24493. private _onCollideObserver;
  24494. /** Set a function to call when this mesh collides with another one */
  24495. onCollide: () => void;
  24496. /**
  24497. * An event triggered when the collision's position changes
  24498. */
  24499. onCollisionPositionChangeObservable: Observable<Vector3>;
  24500. private _onCollisionPositionChangeObserver;
  24501. /** Set a function to call when the collision's position changes */
  24502. onCollisionPositionChange: () => void;
  24503. /**
  24504. * An event triggered when material is changed
  24505. */
  24506. onMaterialChangedObservable: Observable<AbstractMesh>;
  24507. /**
  24508. * Gets or sets the orientation for POV movement & rotation
  24509. */
  24510. definedFacingForward: boolean;
  24511. /** @hidden */
  24512. _occlusionQuery: Nullable<WebGLQuery>;
  24513. private _visibility;
  24514. /**
  24515. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24516. */
  24517. /**
  24518. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24519. */
  24520. visibility: number;
  24521. /** Gets or sets the alpha index used to sort transparent meshes
  24522. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24523. */
  24524. alphaIndex: number;
  24525. /**
  24526. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24527. */
  24528. isVisible: boolean;
  24529. /**
  24530. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24531. */
  24532. isPickable: boolean;
  24533. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24534. showSubMeshesBoundingBox: boolean;
  24535. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24536. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24537. */
  24538. isBlocker: boolean;
  24539. /**
  24540. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24541. */
  24542. enablePointerMoveEvents: boolean;
  24543. /**
  24544. * Specifies the rendering group id for this mesh (0 by default)
  24545. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24546. */
  24547. renderingGroupId: number;
  24548. private _material;
  24549. /** Gets or sets current material */
  24550. material: Nullable<Material>;
  24551. private _receiveShadows;
  24552. /**
  24553. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24554. * @see http://doc.babylonjs.com/babylon101/shadows
  24555. */
  24556. receiveShadows: boolean;
  24557. /** Defines color to use when rendering outline */
  24558. outlineColor: Color3;
  24559. /** Define width to use when rendering outline */
  24560. outlineWidth: number;
  24561. /** Defines color to use when rendering overlay */
  24562. overlayColor: Color3;
  24563. /** Defines alpha to use when rendering overlay */
  24564. overlayAlpha: number;
  24565. private _hasVertexAlpha;
  24566. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24567. hasVertexAlpha: boolean;
  24568. private _useVertexColors;
  24569. /** 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) */
  24570. useVertexColors: boolean;
  24571. private _computeBonesUsingShaders;
  24572. /**
  24573. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24574. */
  24575. computeBonesUsingShaders: boolean;
  24576. private _numBoneInfluencers;
  24577. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24578. numBoneInfluencers: number;
  24579. private _applyFog;
  24580. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24581. applyFog: boolean;
  24582. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24583. useOctreeForRenderingSelection: boolean;
  24584. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24585. useOctreeForPicking: boolean;
  24586. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24587. useOctreeForCollisions: boolean;
  24588. private _layerMask;
  24589. /**
  24590. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24591. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24592. */
  24593. layerMask: number;
  24594. /**
  24595. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24596. */
  24597. alwaysSelectAsActiveMesh: boolean;
  24598. /**
  24599. * Gets or sets the current action manager
  24600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24601. */
  24602. actionManager: Nullable<ActionManager>;
  24603. private _checkCollisions;
  24604. private _collisionMask;
  24605. private _collisionGroup;
  24606. /**
  24607. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24609. */
  24610. ellipsoid: Vector3;
  24611. /**
  24612. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24613. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24614. */
  24615. ellipsoidOffset: Vector3;
  24616. private _collider;
  24617. private _oldPositionForCollisions;
  24618. private _diffPositionForCollisions;
  24619. /**
  24620. * Gets or sets a collision mask used to mask collisions (default is -1).
  24621. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24622. */
  24623. collisionMask: number;
  24624. /**
  24625. * Gets or sets the current collision group mask (-1 by default).
  24626. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24627. */
  24628. collisionGroup: number;
  24629. /**
  24630. * Defines edge width used when edgesRenderer is enabled
  24631. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24632. */
  24633. edgesWidth: number;
  24634. /**
  24635. * Defines edge color used when edgesRenderer is enabled
  24636. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24637. */
  24638. edgesColor: Color4;
  24639. /** @hidden */
  24640. _edgesRenderer: Nullable<IEdgesRenderer>;
  24641. /** @hidden */
  24642. _masterMesh: Nullable<AbstractMesh>;
  24643. /** @hidden */
  24644. _boundingInfo: Nullable<BoundingInfo>;
  24645. /** @hidden */
  24646. _renderId: number;
  24647. /**
  24648. * Gets or sets the list of subMeshes
  24649. * @see http://doc.babylonjs.com/how_to/multi_materials
  24650. */
  24651. subMeshes: SubMesh[];
  24652. /** @hidden */
  24653. _intersectionsInProgress: AbstractMesh[];
  24654. /** @hidden */
  24655. _unIndexed: boolean;
  24656. /** @hidden */
  24657. _lightSources: Light[];
  24658. /** @hidden */
  24659. readonly _positions: Nullable<Vector3[]>;
  24660. /** @hidden */
  24661. _waitingActions: any;
  24662. /** @hidden */
  24663. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24664. private _skeleton;
  24665. /** @hidden */
  24666. _bonesTransformMatrices: Nullable<Float32Array>;
  24667. /**
  24668. * Gets or sets a skeleton to apply skining transformations
  24669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24670. */
  24671. skeleton: Nullable<Skeleton>;
  24672. /**
  24673. * An event triggered when the mesh is rebuilt.
  24674. */
  24675. onRebuildObservable: Observable<AbstractMesh>;
  24676. /**
  24677. * Creates a new AbstractMesh
  24678. * @param name defines the name of the mesh
  24679. * @param scene defines the hosting scene
  24680. */
  24681. constructor(name: string, scene?: Nullable<Scene>);
  24682. /**
  24683. * Returns the string "AbstractMesh"
  24684. * @returns "AbstractMesh"
  24685. */
  24686. getClassName(): string;
  24687. /**
  24688. * Gets a string representation of the current mesh
  24689. * @param fullDetails defines a boolean indicating if full details must be included
  24690. * @returns a string representation of the current mesh
  24691. */
  24692. toString(fullDetails?: boolean): string;
  24693. /** @hidden */
  24694. _rebuild(): void;
  24695. /** @hidden */
  24696. _resyncLightSources(): void;
  24697. /** @hidden */
  24698. _resyncLighSource(light: Light): void;
  24699. /** @hidden */
  24700. _unBindEffect(): void;
  24701. /** @hidden */
  24702. _removeLightSource(light: Light): void;
  24703. private _markSubMeshesAsDirty;
  24704. /** @hidden */
  24705. _markSubMeshesAsLightDirty(): void;
  24706. /** @hidden */
  24707. _markSubMeshesAsAttributesDirty(): void;
  24708. /** @hidden */
  24709. _markSubMeshesAsMiscDirty(): void;
  24710. /**
  24711. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24712. */
  24713. scaling: Vector3;
  24714. /**
  24715. * Returns true if the mesh is blocked. Implemented by child classes
  24716. */
  24717. readonly isBlocked: boolean;
  24718. /**
  24719. * Returns the mesh itself by default. Implemented by child classes
  24720. * @param camera defines the camera to use to pick the right LOD level
  24721. * @returns the currentAbstractMesh
  24722. */
  24723. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24724. /**
  24725. * Returns 0 by default. Implemented by child classes
  24726. * @returns an integer
  24727. */
  24728. getTotalVertices(): number;
  24729. /**
  24730. * Returns a positive integer : the total number of indices in this mesh geometry.
  24731. * @returns the numner of indices or zero if the mesh has no geometry.
  24732. */
  24733. getTotalIndices(): number;
  24734. /**
  24735. * Returns null by default. Implemented by child classes
  24736. * @returns null
  24737. */
  24738. getIndices(): Nullable<IndicesArray>;
  24739. /**
  24740. * Returns the array of the requested vertex data kind. Implemented by child classes
  24741. * @param kind defines the vertex data kind to use
  24742. * @returns null
  24743. */
  24744. getVerticesData(kind: string): Nullable<FloatArray>;
  24745. /**
  24746. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24747. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24748. * Note that a new underlying VertexBuffer object is created each call.
  24749. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24750. * @param kind defines vertex data kind:
  24751. * * BABYLON.VertexBuffer.PositionKind
  24752. * * BABYLON.VertexBuffer.UVKind
  24753. * * BABYLON.VertexBuffer.UV2Kind
  24754. * * BABYLON.VertexBuffer.UV3Kind
  24755. * * BABYLON.VertexBuffer.UV4Kind
  24756. * * BABYLON.VertexBuffer.UV5Kind
  24757. * * BABYLON.VertexBuffer.UV6Kind
  24758. * * BABYLON.VertexBuffer.ColorKind
  24759. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24760. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24761. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24762. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24763. * @param data defines the data source
  24764. * @param updatable defines if the data must be flagged as updatable (or static)
  24765. * @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
  24766. * @returns the current mesh
  24767. */
  24768. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24769. /**
  24770. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24771. * If the mesh has no geometry, it is simply returned as it is.
  24772. * @param kind defines vertex data kind:
  24773. * * BABYLON.VertexBuffer.PositionKind
  24774. * * BABYLON.VertexBuffer.UVKind
  24775. * * BABYLON.VertexBuffer.UV2Kind
  24776. * * BABYLON.VertexBuffer.UV3Kind
  24777. * * BABYLON.VertexBuffer.UV4Kind
  24778. * * BABYLON.VertexBuffer.UV5Kind
  24779. * * BABYLON.VertexBuffer.UV6Kind
  24780. * * BABYLON.VertexBuffer.ColorKind
  24781. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24782. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24783. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24784. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24785. * @param data defines the data source
  24786. * @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
  24787. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24788. * @returns the current mesh
  24789. */
  24790. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24791. /**
  24792. * Sets the mesh indices,
  24793. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24794. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24795. * @param totalVertices Defines the total number of vertices
  24796. * @returns the current mesh
  24797. */
  24798. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24799. /**
  24800. * Gets a boolean indicating if specific vertex data is present
  24801. * @param kind defines the vertex data kind to use
  24802. * @returns true is data kind is present
  24803. */
  24804. isVerticesDataPresent(kind: string): boolean;
  24805. /**
  24806. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24807. * @returns a BoundingInfo
  24808. */
  24809. getBoundingInfo(): BoundingInfo;
  24810. /**
  24811. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24812. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24813. * @returns the current mesh
  24814. */
  24815. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24816. /**
  24817. * Overwrite the current bounding info
  24818. * @param boundingInfo defines the new bounding info
  24819. * @returns the current mesh
  24820. */
  24821. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24822. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24823. readonly useBones: boolean;
  24824. /** @hidden */
  24825. _preActivate(): void;
  24826. /** @hidden */
  24827. _preActivateForIntermediateRendering(renderId: number): void;
  24828. /** @hidden */
  24829. _activate(renderId: number): void;
  24830. /**
  24831. * Gets the current world matrix
  24832. * @returns a Matrix
  24833. */
  24834. getWorldMatrix(): Matrix;
  24835. /** @hidden */
  24836. _getWorldMatrixDeterminant(): number;
  24837. /**
  24838. * Perform relative position change from the point of view of behind the front of the mesh.
  24839. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24840. * Supports definition of mesh facing forward or backward
  24841. * @param amountRight defines the distance on the right axis
  24842. * @param amountUp defines the distance on the up axis
  24843. * @param amountForward defines the distance on the forward axis
  24844. * @returns the current mesh
  24845. */
  24846. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24847. /**
  24848. * Calculate relative position change from the point of view of behind the front of the mesh.
  24849. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24850. * Supports definition of mesh facing forward or backward
  24851. * @param amountRight defines the distance on the right axis
  24852. * @param amountUp defines the distance on the up axis
  24853. * @param amountForward defines the distance on the forward axis
  24854. * @returns the new displacement vector
  24855. */
  24856. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24857. /**
  24858. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24859. * Supports definition of mesh facing forward or backward
  24860. * @param flipBack defines the flip
  24861. * @param twirlClockwise defines the twirl
  24862. * @param tiltRight defines the tilt
  24863. * @returns the current mesh
  24864. */
  24865. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24866. /**
  24867. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24868. * Supports definition of mesh facing forward or backward.
  24869. * @param flipBack defines the flip
  24870. * @param twirlClockwise defines the twirl
  24871. * @param tiltRight defines the tilt
  24872. * @returns the new rotation vector
  24873. */
  24874. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24875. /**
  24876. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24877. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24878. * @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
  24879. * @returns the new bounding vectors
  24880. */
  24881. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24882. min: Vector3;
  24883. max: Vector3;
  24884. };
  24885. /**
  24886. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24887. * This means the mesh underlying bounding box and sphere are recomputed.
  24888. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24889. * @returns the current mesh
  24890. */
  24891. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24892. /** @hidden */
  24893. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24894. /** @hidden */
  24895. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24896. /** @hidden */
  24897. _updateBoundingInfo(): AbstractMesh;
  24898. /** @hidden */
  24899. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24900. /** @hidden */
  24901. protected _afterComputeWorldMatrix(): void;
  24902. /**
  24903. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24904. * A mesh is in the frustum if its bounding box intersects the frustum
  24905. * @param frustumPlanes defines the frustum to test
  24906. * @returns true if the mesh is in the frustum planes
  24907. */
  24908. isInFrustum(frustumPlanes: Plane[]): boolean;
  24909. /**
  24910. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24911. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24912. * @param frustumPlanes defines the frustum to test
  24913. * @returns true if the mesh is completely in the frustum planes
  24914. */
  24915. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24916. /**
  24917. * True if the mesh intersects another mesh or a SolidParticle object
  24918. * @param mesh defines a target mesh or SolidParticle to test
  24919. * @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)
  24920. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24921. * @returns true if there is an intersection
  24922. */
  24923. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24924. /**
  24925. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24926. * @param point defines the point to test
  24927. * @returns true if there is an intersection
  24928. */
  24929. intersectsPoint(point: Vector3): boolean;
  24930. /**
  24931. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24932. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24933. */
  24934. checkCollisions: boolean;
  24935. /**
  24936. * Gets Collider object used to compute collisions (not physics)
  24937. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24938. */
  24939. readonly collider: Collider;
  24940. /**
  24941. * Move the mesh using collision engine
  24942. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24943. * @param displacement defines the requested displacement vector
  24944. * @returns the current mesh
  24945. */
  24946. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24947. private _onCollisionPositionChange;
  24948. /** @hidden */
  24949. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24950. /** @hidden */
  24951. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24952. /** @hidden */
  24953. _checkCollision(collider: Collider): AbstractMesh;
  24954. /** @hidden */
  24955. _generatePointsArray(): boolean;
  24956. /**
  24957. * Checks if the passed Ray intersects with the mesh
  24958. * @param ray defines the ray to use
  24959. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24960. * @returns the picking info
  24961. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24962. */
  24963. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24964. /**
  24965. * Clones the current mesh
  24966. * @param name defines the mesh name
  24967. * @param newParent defines the new mesh parent
  24968. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24969. * @returns the new mesh
  24970. */
  24971. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24972. /**
  24973. * Disposes all the submeshes of the current meshnp
  24974. * @returns the current mesh
  24975. */
  24976. releaseSubMeshes(): AbstractMesh;
  24977. /**
  24978. * Releases resources associated with this abstract mesh.
  24979. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24980. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24981. */
  24982. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24983. /**
  24984. * Adds the passed mesh as a child to the current mesh
  24985. * @param mesh defines the child mesh
  24986. * @returns the current mesh
  24987. */
  24988. addChild(mesh: AbstractMesh): AbstractMesh;
  24989. /**
  24990. * Removes the passed mesh from the current mesh children list
  24991. * @param mesh defines the child mesh
  24992. * @returns the current mesh
  24993. */
  24994. removeChild(mesh: AbstractMesh): AbstractMesh;
  24995. /** @hidden */
  24996. private _initFacetData;
  24997. /**
  24998. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24999. * This method can be called within the render loop.
  25000. * 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
  25001. * @returns the current mesh
  25002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25003. */
  25004. updateFacetData(): AbstractMesh;
  25005. /**
  25006. * Returns the facetLocalNormals array.
  25007. * The normals are expressed in the mesh local spac
  25008. * @returns an array of Vector3
  25009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25010. */
  25011. getFacetLocalNormals(): Vector3[];
  25012. /**
  25013. * Returns the facetLocalPositions array.
  25014. * The facet positions are expressed in the mesh local space
  25015. * @returns an array of Vector3
  25016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25017. */
  25018. getFacetLocalPositions(): Vector3[];
  25019. /**
  25020. * Returns the facetLocalPartioning array
  25021. * @returns an array of array of numbers
  25022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25023. */
  25024. getFacetLocalPartitioning(): number[][];
  25025. /**
  25026. * Returns the i-th facet position in the world system.
  25027. * This method allocates a new Vector3 per call
  25028. * @param i defines the facet index
  25029. * @returns a new Vector3
  25030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25031. */
  25032. getFacetPosition(i: number): Vector3;
  25033. /**
  25034. * Sets the reference Vector3 with the i-th facet position in the world system
  25035. * @param i defines the facet index
  25036. * @param ref defines the target vector
  25037. * @returns the current mesh
  25038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25039. */
  25040. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25041. /**
  25042. * Returns the i-th facet normal in the world system.
  25043. * This method allocates a new Vector3 per call
  25044. * @param i defines the facet index
  25045. * @returns a new Vector3
  25046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25047. */
  25048. getFacetNormal(i: number): Vector3;
  25049. /**
  25050. * Sets the reference Vector3 with the i-th facet normal in the world system
  25051. * @param i defines the facet index
  25052. * @param ref defines the target vector
  25053. * @returns the current mesh
  25054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25055. */
  25056. getFacetNormalToRef(i: number, ref: Vector3): this;
  25057. /**
  25058. * 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)
  25059. * @param x defines x coordinate
  25060. * @param y defines y coordinate
  25061. * @param z defines z coordinate
  25062. * @returns the array of facet indexes
  25063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25064. */
  25065. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25066. /**
  25067. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25068. * @param projected sets as the (x,y,z) world projection on the facet
  25069. * @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
  25070. * @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
  25071. * @param x defines x coordinate
  25072. * @param y defines y coordinate
  25073. * @param z defines z coordinate
  25074. * @returns the face index if found (or null instead)
  25075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25076. */
  25077. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25078. /**
  25079. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25080. * @param projected sets as the (x,y,z) local projection on the facet
  25081. * @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
  25082. * @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
  25083. * @param x defines x coordinate
  25084. * @param y defines y coordinate
  25085. * @param z defines z coordinate
  25086. * @returns the face index if found (or null instead)
  25087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25088. */
  25089. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25090. /**
  25091. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25092. * @returns the parameters
  25093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25094. */
  25095. getFacetDataParameters(): any;
  25096. /**
  25097. * Disables the feature FacetData and frees the related memory
  25098. * @returns the current mesh
  25099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25100. */
  25101. disableFacetData(): AbstractMesh;
  25102. /**
  25103. * Updates the AbstractMesh indices array
  25104. * @param indices defines the data source
  25105. * @returns the current mesh
  25106. */
  25107. updateIndices(indices: IndicesArray): AbstractMesh;
  25108. /**
  25109. * Creates new normals data for the mesh
  25110. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25111. * @returns the current mesh
  25112. */
  25113. createNormals(updatable: boolean): AbstractMesh;
  25114. /**
  25115. * Align the mesh with a normal
  25116. * @param normal defines the normal to use
  25117. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25118. * @returns the current mesh
  25119. */
  25120. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25121. /** @hidden */
  25122. _checkOcclusionQuery(): boolean;
  25123. }
  25124. }
  25125. declare module BABYLON {
  25126. /**
  25127. * Class used to store data that will be store in GPU memory
  25128. */
  25129. class Buffer {
  25130. private _engine;
  25131. private _buffer;
  25132. /** @hidden */
  25133. _data: Nullable<DataArray>;
  25134. private _updatable;
  25135. private _instanced;
  25136. /**
  25137. * Gets the byte stride.
  25138. */
  25139. readonly byteStride: number;
  25140. /**
  25141. * Constructor
  25142. * @param engine the engine
  25143. * @param data the data to use for this buffer
  25144. * @param updatable whether the data is updatable
  25145. * @param stride the stride (optional)
  25146. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25147. * @param instanced whether the buffer is instanced (optional)
  25148. * @param useBytes set to true if the stride in in bytes (optional)
  25149. */
  25150. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25151. /**
  25152. * Create a new VertexBuffer based on the current buffer
  25153. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25154. * @param offset defines offset in the buffer (0 by default)
  25155. * @param size defines the size in floats of attributes (position is 3 for instance)
  25156. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25157. * @param instanced defines if the vertex buffer contains indexed data
  25158. * @param useBytes defines if the offset and stride are in bytes
  25159. * @returns the new vertex buffer
  25160. */
  25161. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25162. /**
  25163. * Gets a boolean indicating if the Buffer is updatable?
  25164. * @returns true if the buffer is updatable
  25165. */
  25166. isUpdatable(): boolean;
  25167. /**
  25168. * Gets current buffer's data
  25169. * @returns a DataArray or null
  25170. */
  25171. getData(): Nullable<DataArray>;
  25172. /**
  25173. * Gets underlying native buffer
  25174. * @returns underlying native buffer
  25175. */
  25176. getBuffer(): Nullable<WebGLBuffer>;
  25177. /**
  25178. * Gets the stride in float32 units (i.e. byte stride / 4).
  25179. * May not be an integer if the byte stride is not divisible by 4.
  25180. * DEPRECATED. Use byteStride instead.
  25181. * @returns the stride in float32 units
  25182. */
  25183. getStrideSize(): number;
  25184. /**
  25185. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25186. * @param data defines the data to store
  25187. */
  25188. create(data?: Nullable<DataArray>): void;
  25189. /** @hidden */
  25190. _rebuild(): void;
  25191. /**
  25192. * Update current buffer data
  25193. * @param data defines the data to store
  25194. */
  25195. update(data: DataArray): void;
  25196. /**
  25197. * Updates the data directly.
  25198. * @param data the new data
  25199. * @param offset the new offset
  25200. * @param vertexCount the vertex count (optional)
  25201. * @param useBytes set to true if the offset is in bytes
  25202. */
  25203. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25204. /**
  25205. * Release all resources
  25206. */
  25207. dispose(): void;
  25208. }
  25209. }
  25210. declare module BABYLON {
  25211. /**
  25212. * Class for building Constructive Solid Geometry
  25213. */
  25214. class CSG {
  25215. private polygons;
  25216. /**
  25217. * The world matrix
  25218. */
  25219. matrix: Matrix;
  25220. /**
  25221. * Stores the position
  25222. */
  25223. position: Vector3;
  25224. /**
  25225. * Stores the rotation
  25226. */
  25227. rotation: Vector3;
  25228. /**
  25229. * Stores the rotation quaternion
  25230. */
  25231. rotationQuaternion: Nullable<Quaternion>;
  25232. /**
  25233. * Stores the scaling vector
  25234. */
  25235. scaling: Vector3;
  25236. /**
  25237. * Convert the BABYLON.Mesh to BABYLON.CSG
  25238. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25239. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25240. */
  25241. static FromMesh(mesh: Mesh): CSG;
  25242. /**
  25243. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25244. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25245. */
  25246. private static FromPolygons;
  25247. /**
  25248. * Clones, or makes a deep copy, of the BABYLON.CSG
  25249. * @returns A new BABYLON.CSG
  25250. */
  25251. clone(): CSG;
  25252. /**
  25253. * Unions this CSG with another CSG
  25254. * @param csg The CSG to union against this CSG
  25255. * @returns The unioned CSG
  25256. */
  25257. union(csg: CSG): CSG;
  25258. /**
  25259. * Unions this CSG with another CSG in place
  25260. * @param csg The CSG to union against this CSG
  25261. */
  25262. unionInPlace(csg: CSG): void;
  25263. /**
  25264. * Subtracts this CSG with another CSG
  25265. * @param csg The CSG to subtract against this CSG
  25266. * @returns A new BABYLON.CSG
  25267. */
  25268. subtract(csg: CSG): CSG;
  25269. /**
  25270. * Subtracts this CSG with another CSG in place
  25271. * @param csg The CSG to subtact against this CSG
  25272. */
  25273. subtractInPlace(csg: CSG): void;
  25274. /**
  25275. * Intersect this CSG with another CSG
  25276. * @param csg The CSG to intersect against this CSG
  25277. * @returns A new BABYLON.CSG
  25278. */
  25279. intersect(csg: CSG): CSG;
  25280. /**
  25281. * Intersects this CSG with another CSG in place
  25282. * @param csg The CSG to intersect against this CSG
  25283. */
  25284. intersectInPlace(csg: CSG): void;
  25285. /**
  25286. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25287. * not modified.
  25288. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25289. */
  25290. inverse(): CSG;
  25291. /**
  25292. * Inverses the BABYLON.CSG in place
  25293. */
  25294. inverseInPlace(): void;
  25295. /**
  25296. * This is used to keep meshes transformations so they can be restored
  25297. * when we build back a Babylon Mesh
  25298. * NB : All CSG operations are performed in world coordinates
  25299. * @param csg The BABYLON.CSG to copy the transform attributes from
  25300. * @returns This BABYLON.CSG
  25301. */
  25302. copyTransformAttributes(csg: CSG): CSG;
  25303. /**
  25304. * Build Raw mesh from CSG
  25305. * Coordinates here are in world space
  25306. * @param name The name of the mesh geometry
  25307. * @param scene The BABYLON.Scene
  25308. * @param keepSubMeshes Specifies if the submeshes should be kept
  25309. * @returns A new BABYLON.Mesh
  25310. */
  25311. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25312. /**
  25313. * Build Mesh from CSG taking material and transforms into account
  25314. * @param name The name of the BABYLON.Mesh
  25315. * @param material The material of the BABYLON.Mesh
  25316. * @param scene The BABYLON.Scene
  25317. * @param keepSubMeshes Specifies if submeshes should be kept
  25318. * @returns The new BABYLON.Mesh
  25319. */
  25320. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25321. }
  25322. }
  25323. declare module BABYLON {
  25324. /**
  25325. * Class used to store geometry data (vertex buffers + index buffer)
  25326. */
  25327. class Geometry implements IGetSetVerticesData {
  25328. /**
  25329. * Gets or sets the ID of the geometry
  25330. */
  25331. id: string;
  25332. /**
  25333. * Gets or sets the unique ID of the geometry
  25334. */
  25335. uniqueId: number;
  25336. /**
  25337. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25338. */
  25339. delayLoadState: number;
  25340. /**
  25341. * Gets the file containing the data to load when running in delay load state
  25342. */
  25343. delayLoadingFile: Nullable<string>;
  25344. /**
  25345. * Callback called when the geometry is updated
  25346. */
  25347. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25348. private _scene;
  25349. private _engine;
  25350. private _meshes;
  25351. private _totalVertices;
  25352. /** @hidden */
  25353. _indices: IndicesArray;
  25354. /** @hidden */
  25355. _vertexBuffers: {
  25356. [key: string]: VertexBuffer;
  25357. };
  25358. private _isDisposed;
  25359. private _extend;
  25360. private _boundingBias;
  25361. /** @hidden */
  25362. _delayInfo: Array<string>;
  25363. private _indexBuffer;
  25364. private _indexBufferIsUpdatable;
  25365. /** @hidden */
  25366. _boundingInfo: Nullable<BoundingInfo>;
  25367. /** @hidden */
  25368. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25369. /** @hidden */
  25370. _softwareSkinningFrameId: number;
  25371. private _vertexArrayObjects;
  25372. private _updatable;
  25373. /** @hidden */
  25374. _positions: Nullable<Vector3[]>;
  25375. /**
  25376. * 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
  25377. */
  25378. /**
  25379. * 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
  25380. */
  25381. boundingBias: Vector2;
  25382. /**
  25383. * Static function used to attach a new empty geometry to a mesh
  25384. * @param mesh defines the mesh to attach the geometry to
  25385. * @returns the new Geometry
  25386. */
  25387. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25388. /**
  25389. * Creates a new geometry
  25390. * @param id defines the unique ID
  25391. * @param scene defines the hosting scene
  25392. * @param vertexData defines the VertexData used to get geometry data
  25393. * @param updatable defines if geometry must be updatable (false by default)
  25394. * @param mesh defines the mesh that will be associated with the geometry
  25395. */
  25396. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25397. /**
  25398. * Gets the current extend of the geometry
  25399. */
  25400. readonly extend: {
  25401. minimum: Vector3;
  25402. maximum: Vector3;
  25403. };
  25404. /**
  25405. * Gets the hosting scene
  25406. * @returns the hosting Scene
  25407. */
  25408. getScene(): Scene;
  25409. /**
  25410. * Gets the hosting engine
  25411. * @returns the hosting Engine
  25412. */
  25413. getEngine(): Engine;
  25414. /**
  25415. * Defines if the geometry is ready to use
  25416. * @returns true if the geometry is ready to be used
  25417. */
  25418. isReady(): boolean;
  25419. /**
  25420. * Gets a value indicating that the geometry should not be serialized
  25421. */
  25422. readonly doNotSerialize: boolean;
  25423. /** @hidden */
  25424. _rebuild(): void;
  25425. /**
  25426. * Affects all geometry data in one call
  25427. * @param vertexData defines the geometry data
  25428. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25429. */
  25430. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25431. /**
  25432. * Set specific vertex data
  25433. * @param kind defines the data kind (Position, normal, etc...)
  25434. * @param data defines the vertex data to use
  25435. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25436. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25437. */
  25438. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25439. /**
  25440. * Removes a specific vertex data
  25441. * @param kind defines the data kind (Position, normal, etc...)
  25442. */
  25443. removeVerticesData(kind: string): void;
  25444. /**
  25445. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25446. * @param buffer defines the vertex buffer to use
  25447. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25448. */
  25449. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25450. /**
  25451. * Update a specific vertex buffer
  25452. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25453. * It will do nothing if the buffer is not updatable
  25454. * @param kind defines the data kind (Position, normal, etc...)
  25455. * @param data defines the data to use
  25456. * @param offset defines the offset in the target buffer where to store the data
  25457. * @param useBytes set to true if the offset is in bytes
  25458. */
  25459. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25460. /**
  25461. * Update a specific vertex buffer
  25462. * This function will create a new buffer if the current one is not updatable
  25463. * @param kind defines the data kind (Position, normal, etc...)
  25464. * @param data defines the data to use
  25465. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25466. */
  25467. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25468. private _updateBoundingInfo;
  25469. /** @hidden */
  25470. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25471. /**
  25472. * Gets total number of vertices
  25473. * @returns the total number of vertices
  25474. */
  25475. getTotalVertices(): number;
  25476. /**
  25477. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25478. * @param kind defines the data kind (Position, normal, etc...)
  25479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25481. * @returns a float array containing vertex data
  25482. */
  25483. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25484. /**
  25485. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25486. * @param kind defines the data kind (Position, normal, etc...)
  25487. * @returns true if the vertex buffer with the specified kind is updatable
  25488. */
  25489. isVertexBufferUpdatable(kind: string): boolean;
  25490. /**
  25491. * Gets a specific vertex buffer
  25492. * @param kind defines the data kind (Position, normal, etc...)
  25493. * @returns a VertexBuffer
  25494. */
  25495. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25496. /**
  25497. * Returns all vertex buffers
  25498. * @return an object holding all vertex buffers indexed by kind
  25499. */
  25500. getVertexBuffers(): Nullable<{
  25501. [key: string]: VertexBuffer;
  25502. }>;
  25503. /**
  25504. * Gets a boolean indicating if specific vertex buffer is present
  25505. * @param kind defines the data kind (Position, normal, etc...)
  25506. * @returns true if data is present
  25507. */
  25508. isVerticesDataPresent(kind: string): boolean;
  25509. /**
  25510. * Gets a list of all attached data kinds (Position, normal, etc...)
  25511. * @returns a list of string containing all kinds
  25512. */
  25513. getVerticesDataKinds(): string[];
  25514. /**
  25515. * Update index buffer
  25516. * @param indices defines the indices to store in the index buffer
  25517. * @param offset defines the offset in the target buffer where to store the data
  25518. */
  25519. updateIndices(indices: IndicesArray, offset?: number): void;
  25520. /**
  25521. * Creates a new index buffer
  25522. * @param indices defines the indices to store in the index buffer
  25523. * @param totalVertices defines the total number of vertices (could be null)
  25524. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25525. */
  25526. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25527. /**
  25528. * Return the total number of indices
  25529. * @returns the total number of indices
  25530. */
  25531. getTotalIndices(): number;
  25532. /**
  25533. * Gets the index buffer array
  25534. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25535. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25536. * @returns the index buffer array
  25537. */
  25538. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25539. /**
  25540. * Gets the index buffer
  25541. * @return the index buffer
  25542. */
  25543. getIndexBuffer(): Nullable<WebGLBuffer>;
  25544. /** @hidden */
  25545. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25546. /**
  25547. * Release the associated resources for a specific mesh
  25548. * @param mesh defines the source mesh
  25549. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25550. */
  25551. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25552. /**
  25553. * Apply current geometry to a given mesh
  25554. * @param mesh defines the mesh to apply geometry to
  25555. */
  25556. applyToMesh(mesh: Mesh): void;
  25557. private _updateExtend;
  25558. private _applyToMesh;
  25559. private notifyUpdate;
  25560. /**
  25561. * Load the geometry if it was flagged as delay loaded
  25562. * @param scene defines the hosting scene
  25563. * @param onLoaded defines a callback called when the geometry is loaded
  25564. */
  25565. load(scene: Scene, onLoaded?: () => void): void;
  25566. private _queueLoad;
  25567. /**
  25568. * Invert the geometry to move from a right handed system to a left handed one.
  25569. */
  25570. toLeftHanded(): void;
  25571. /** @hidden */
  25572. _resetPointsArrayCache(): void;
  25573. /** @hidden */
  25574. _generatePointsArray(): boolean;
  25575. /**
  25576. * Gets a value indicating if the geometry is disposed
  25577. * @returns true if the geometry was disposed
  25578. */
  25579. isDisposed(): boolean;
  25580. private _disposeVertexArrayObjects;
  25581. /**
  25582. * Free all associated resources
  25583. */
  25584. dispose(): void;
  25585. /**
  25586. * Clone the current geometry into a new geometry
  25587. * @param id defines the unique ID of the new geometry
  25588. * @returns a new geometry object
  25589. */
  25590. copy(id: string): Geometry;
  25591. /**
  25592. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25593. * @return a JSON representation of the current geometry data (without the vertices data)
  25594. */
  25595. serialize(): any;
  25596. private toNumberArray;
  25597. /**
  25598. * Serialize all vertices data into a JSON oject
  25599. * @returns a JSON representation of the current geometry data
  25600. */
  25601. serializeVerticeData(): any;
  25602. /**
  25603. * Extracts a clone of a mesh geometry
  25604. * @param mesh defines the source mesh
  25605. * @param id defines the unique ID of the new geometry object
  25606. * @returns the new geometry object
  25607. */
  25608. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25609. /**
  25610. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25611. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25612. * Be aware Math.random() could cause collisions, but:
  25613. * "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"
  25614. * @returns a string containing a new GUID
  25615. */
  25616. static RandomId(): string;
  25617. /** @hidden */
  25618. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25619. private static _CleanMatricesWeights;
  25620. /**
  25621. * Create a new geometry from persisted data (Using .babylon file format)
  25622. * @param parsedVertexData defines the persisted data
  25623. * @param scene defines the hosting scene
  25624. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25625. * @returns the new geometry object
  25626. */
  25627. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25628. }
  25629. /**
  25630. * Abstract class used to provide common services for all typed geometries
  25631. * @hidden
  25632. */
  25633. class _PrimitiveGeometry extends Geometry {
  25634. private _canBeRegenerated;
  25635. private _beingRegenerated;
  25636. /**
  25637. * Creates a new typed geometry
  25638. * @param id defines the unique ID of the geometry
  25639. * @param scene defines the hosting scene
  25640. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25641. * @param mesh defines the hosting mesh (can be null)
  25642. */
  25643. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25644. /**
  25645. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25646. * @returns true if the geometry can be regenerated
  25647. */
  25648. canBeRegenerated(): boolean;
  25649. /**
  25650. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25651. */
  25652. regenerate(): void;
  25653. /**
  25654. * Clone the geometry
  25655. * @param id defines the unique ID of the new geometry
  25656. * @returns the new geometry
  25657. */
  25658. asNewGeometry(id: string): Geometry;
  25659. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25660. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25661. /** @hidden */
  25662. _regenerateVertexData(): VertexData;
  25663. copy(id: string): Geometry;
  25664. serialize(): any;
  25665. }
  25666. /**
  25667. * Creates a ribbon geometry
  25668. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25669. */
  25670. class RibbonGeometry extends _PrimitiveGeometry {
  25671. /**
  25672. * Defines the array of paths to use
  25673. */
  25674. pathArray: Vector3[][];
  25675. /**
  25676. * Defines if the last and first points of each path in your pathArray must be joined
  25677. */
  25678. closeArray: boolean;
  25679. /**
  25680. * Defines if the last and first points of each path in your pathArray must be joined
  25681. */
  25682. closePath: boolean;
  25683. /**
  25684. * Defines the offset between points
  25685. */
  25686. offset: number;
  25687. /**
  25688. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25689. */
  25690. side: number;
  25691. /**
  25692. * Creates a ribbon geometry
  25693. * @param id defines the unique ID of the geometry
  25694. * @param scene defines the hosting scene
  25695. * @param pathArray defines the array of paths to use
  25696. * @param closeArray defines if the last path and the first path must be joined
  25697. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25698. * @param offset defines the offset between points
  25699. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25700. * @param mesh defines the hosting mesh (can be null)
  25701. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25702. */
  25703. constructor(id: string, scene: Scene,
  25704. /**
  25705. * Defines the array of paths to use
  25706. */
  25707. pathArray: Vector3[][],
  25708. /**
  25709. * Defines if the last and first points of each path in your pathArray must be joined
  25710. */
  25711. closeArray: boolean,
  25712. /**
  25713. * Defines if the last and first points of each path in your pathArray must be joined
  25714. */
  25715. closePath: boolean,
  25716. /**
  25717. * Defines the offset between points
  25718. */
  25719. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25720. /**
  25721. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25722. */
  25723. side?: number);
  25724. /** @hidden */
  25725. _regenerateVertexData(): VertexData;
  25726. copy(id: string): Geometry;
  25727. }
  25728. /**
  25729. * Creates a box geometry
  25730. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25731. */
  25732. class BoxGeometry extends _PrimitiveGeometry {
  25733. /**
  25734. * Defines the zise of the box (width, height and depth are the same)
  25735. */
  25736. size: number;
  25737. /**
  25738. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25739. */
  25740. side: number;
  25741. /**
  25742. * Creates a box geometry
  25743. * @param id defines the unique ID of the geometry
  25744. * @param scene defines the hosting scene
  25745. * @param size defines the zise of the box (width, height and depth are the same)
  25746. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25747. * @param mesh defines the hosting mesh (can be null)
  25748. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25749. */
  25750. constructor(id: string, scene: Scene,
  25751. /**
  25752. * Defines the zise of the box (width, height and depth are the same)
  25753. */
  25754. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25755. /**
  25756. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25757. */
  25758. side?: number);
  25759. /** @hidden */
  25760. _regenerateVertexData(): VertexData;
  25761. copy(id: string): Geometry;
  25762. serialize(): any;
  25763. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25764. }
  25765. /**
  25766. * Creates a sphere geometry
  25767. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25768. */
  25769. class SphereGeometry extends _PrimitiveGeometry {
  25770. /**
  25771. * Defines the number of segments to use to create the sphere
  25772. */
  25773. segments: number;
  25774. /**
  25775. * Defines the diameter of the sphere
  25776. */
  25777. diameter: number;
  25778. /**
  25779. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25780. */
  25781. side: number;
  25782. /**
  25783. * Create a new sphere geometry
  25784. * @param id defines the unique ID of the geometry
  25785. * @param scene defines the hosting scene
  25786. * @param segments defines the number of segments to use to create the sphere
  25787. * @param diameter defines the diameter of the sphere
  25788. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25789. * @param mesh defines the hosting mesh (can be null)
  25790. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25791. */
  25792. constructor(id: string, scene: Scene,
  25793. /**
  25794. * Defines the number of segments to use to create the sphere
  25795. */
  25796. segments: number,
  25797. /**
  25798. * Defines the diameter of the sphere
  25799. */
  25800. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25801. /**
  25802. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25803. */
  25804. side?: number);
  25805. /** @hidden */
  25806. _regenerateVertexData(): VertexData;
  25807. copy(id: string): Geometry;
  25808. serialize(): any;
  25809. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25810. }
  25811. /**
  25812. * Creates a disc geometry
  25813. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25814. */
  25815. class DiscGeometry extends _PrimitiveGeometry {
  25816. /**
  25817. * Defines the radius of the disc
  25818. */
  25819. radius: number;
  25820. /**
  25821. * Defines the tesselation factor to apply to the disc
  25822. */
  25823. tessellation: number;
  25824. /**
  25825. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25826. */
  25827. side: number;
  25828. /**
  25829. * Creates a new disc geometry
  25830. * @param id defines the unique ID of the geometry
  25831. * @param scene defines the hosting scene
  25832. * @param radius defines the radius of the disc
  25833. * @param tessellation defines the tesselation factor to apply to the disc
  25834. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25835. * @param mesh defines the hosting mesh (can be null)
  25836. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25837. */
  25838. constructor(id: string, scene: Scene,
  25839. /**
  25840. * Defines the radius of the disc
  25841. */
  25842. radius: number,
  25843. /**
  25844. * Defines the tesselation factor to apply to the disc
  25845. */
  25846. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25847. /**
  25848. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25849. */
  25850. side?: number);
  25851. /** @hidden */
  25852. _regenerateVertexData(): VertexData;
  25853. copy(id: string): Geometry;
  25854. }
  25855. /**
  25856. * Creates a new cylinder geometry
  25857. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25858. */
  25859. class CylinderGeometry extends _PrimitiveGeometry {
  25860. /**
  25861. * Defines the height of the cylinder
  25862. */
  25863. height: number;
  25864. /**
  25865. * Defines the diameter of the cylinder's top cap
  25866. */
  25867. diameterTop: number;
  25868. /**
  25869. * Defines the diameter of the cylinder's bottom cap
  25870. */
  25871. diameterBottom: number;
  25872. /**
  25873. * Defines the tessellation factor to apply to the cylinder
  25874. */
  25875. tessellation: number;
  25876. /**
  25877. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25878. */
  25879. subdivisions: number;
  25880. /**
  25881. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25882. */
  25883. side: number;
  25884. /**
  25885. * Creates a new cylinder geometry
  25886. * @param id defines the unique ID of the geometry
  25887. * @param scene defines the hosting scene
  25888. * @param height defines the height of the cylinder
  25889. * @param diameterTop defines the diameter of the cylinder's top cap
  25890. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25891. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25892. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25893. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25894. * @param mesh defines the hosting mesh (can be null)
  25895. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25896. */
  25897. constructor(id: string, scene: Scene,
  25898. /**
  25899. * Defines the height of the cylinder
  25900. */
  25901. height: number,
  25902. /**
  25903. * Defines the diameter of the cylinder's top cap
  25904. */
  25905. diameterTop: number,
  25906. /**
  25907. * Defines the diameter of the cylinder's bottom cap
  25908. */
  25909. diameterBottom: number,
  25910. /**
  25911. * Defines the tessellation factor to apply to the cylinder
  25912. */
  25913. tessellation: number,
  25914. /**
  25915. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25916. */
  25917. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25918. /**
  25919. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25920. */
  25921. side?: number);
  25922. /** @hidden */
  25923. _regenerateVertexData(): VertexData;
  25924. copy(id: string): Geometry;
  25925. serialize(): any;
  25926. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25927. }
  25928. /**
  25929. * Creates a new torus geometry
  25930. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25931. */
  25932. class TorusGeometry extends _PrimitiveGeometry {
  25933. /**
  25934. * Defines the diameter of the torus
  25935. */
  25936. diameter: number;
  25937. /**
  25938. * Defines the thickness of the torus (ie. internal diameter)
  25939. */
  25940. thickness: number;
  25941. /**
  25942. * Defines the tesselation factor to apply to the torus
  25943. */
  25944. tessellation: number;
  25945. /**
  25946. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25947. */
  25948. side: number;
  25949. /**
  25950. * Creates a new torus geometry
  25951. * @param id defines the unique ID of the geometry
  25952. * @param scene defines the hosting scene
  25953. * @param diameter defines the diameter of the torus
  25954. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25955. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25956. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25957. * @param mesh defines the hosting mesh (can be null)
  25958. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25959. */
  25960. constructor(id: string, scene: Scene,
  25961. /**
  25962. * Defines the diameter of the torus
  25963. */
  25964. diameter: number,
  25965. /**
  25966. * Defines the thickness of the torus (ie. internal diameter)
  25967. */
  25968. thickness: number,
  25969. /**
  25970. * Defines the tesselation factor to apply to the torus
  25971. */
  25972. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25973. /**
  25974. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25975. */
  25976. side?: number);
  25977. /** @hidden */
  25978. _regenerateVertexData(): VertexData;
  25979. copy(id: string): Geometry;
  25980. serialize(): any;
  25981. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25982. }
  25983. /**
  25984. * Creates a new ground geometry
  25985. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25986. */
  25987. class GroundGeometry extends _PrimitiveGeometry {
  25988. /**
  25989. * Defines the width of the ground
  25990. */
  25991. width: number;
  25992. /**
  25993. * Defines the height of the ground
  25994. */
  25995. height: number;
  25996. /**
  25997. * Defines the subdivisions to apply to the ground
  25998. */
  25999. subdivisions: number;
  26000. /**
  26001. * Creates a new ground geometry
  26002. * @param id defines the unique ID of the geometry
  26003. * @param scene defines the hosting scene
  26004. * @param width defines the width of the ground
  26005. * @param height defines the height of the ground
  26006. * @param subdivisions defines the subdivisions to apply to the ground
  26007. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26008. * @param mesh defines the hosting mesh (can be null)
  26009. */
  26010. constructor(id: string, scene: Scene,
  26011. /**
  26012. * Defines the width of the ground
  26013. */
  26014. width: number,
  26015. /**
  26016. * Defines the height of the ground
  26017. */
  26018. height: number,
  26019. /**
  26020. * Defines the subdivisions to apply to the ground
  26021. */
  26022. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26023. /** @hidden */
  26024. _regenerateVertexData(): VertexData;
  26025. copy(id: string): Geometry;
  26026. serialize(): any;
  26027. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  26028. }
  26029. /**
  26030. * Creates a tiled ground geometry
  26031. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  26032. */
  26033. class TiledGroundGeometry extends _PrimitiveGeometry {
  26034. /**
  26035. * Defines the minimum value on X axis
  26036. */
  26037. xmin: number;
  26038. /**
  26039. * Defines the minimum value on Z axis
  26040. */
  26041. zmin: number;
  26042. /**
  26043. * Defines the maximum value on X axis
  26044. */
  26045. xmax: number;
  26046. /**
  26047. * Defines the maximum value on Z axis
  26048. */
  26049. zmax: number;
  26050. /**
  26051. * Defines the subdivisions to apply to the ground
  26052. */
  26053. subdivisions: {
  26054. w: number;
  26055. h: number;
  26056. };
  26057. /**
  26058. * Defines the precision to use when computing the tiles
  26059. */
  26060. precision: {
  26061. w: number;
  26062. h: number;
  26063. };
  26064. /**
  26065. * Creates a tiled ground geometry
  26066. * @param id defines the unique ID of the geometry
  26067. * @param scene defines the hosting scene
  26068. * @param xmin defines the minimum value on X axis
  26069. * @param zmin defines the minimum value on Z axis
  26070. * @param xmax defines the maximum value on X axis
  26071. * @param zmax defines the maximum value on Z axis
  26072. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26073. * @param precision defines the precision to use when computing the tiles
  26074. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26075. * @param mesh defines the hosting mesh (can be null)
  26076. */
  26077. constructor(id: string, scene: Scene,
  26078. /**
  26079. * Defines the minimum value on X axis
  26080. */
  26081. xmin: number,
  26082. /**
  26083. * Defines the minimum value on Z axis
  26084. */
  26085. zmin: number,
  26086. /**
  26087. * Defines the maximum value on X axis
  26088. */
  26089. xmax: number,
  26090. /**
  26091. * Defines the maximum value on Z axis
  26092. */
  26093. zmax: number,
  26094. /**
  26095. * Defines the subdivisions to apply to the ground
  26096. */
  26097. subdivisions: {
  26098. w: number;
  26099. h: number;
  26100. },
  26101. /**
  26102. * Defines the precision to use when computing the tiles
  26103. */
  26104. precision: {
  26105. w: number;
  26106. h: number;
  26107. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26108. /** @hidden */
  26109. _regenerateVertexData(): VertexData;
  26110. copy(id: string): Geometry;
  26111. }
  26112. /**
  26113. * Creates a plane geometry
  26114. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26115. */
  26116. class PlaneGeometry extends _PrimitiveGeometry {
  26117. /**
  26118. * Defines the size of the plane (width === height)
  26119. */
  26120. size: number;
  26121. /**
  26122. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26123. */
  26124. side: number;
  26125. /**
  26126. * Creates a plane geometry
  26127. * @param id defines the unique ID of the geometry
  26128. * @param scene defines the hosting scene
  26129. * @param size defines the size of the plane (width === height)
  26130. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26131. * @param mesh defines the hosting mesh (can be null)
  26132. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26133. */
  26134. constructor(id: string, scene: Scene,
  26135. /**
  26136. * Defines the size of the plane (width === height)
  26137. */
  26138. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26139. /**
  26140. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26141. */
  26142. side?: number);
  26143. /** @hidden */
  26144. _regenerateVertexData(): VertexData;
  26145. copy(id: string): Geometry;
  26146. serialize(): any;
  26147. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26148. }
  26149. /**
  26150. * Creates a torus knot geometry
  26151. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26152. */
  26153. class TorusKnotGeometry extends _PrimitiveGeometry {
  26154. /**
  26155. * Defines the radius of the torus knot
  26156. */
  26157. radius: number;
  26158. /**
  26159. * Defines the thickness of the torus knot tube
  26160. */
  26161. tube: number;
  26162. /**
  26163. * Defines the number of radial segments
  26164. */
  26165. radialSegments: number;
  26166. /**
  26167. * Defines the number of tubular segments
  26168. */
  26169. tubularSegments: number;
  26170. /**
  26171. * Defines the first number of windings
  26172. */
  26173. p: number;
  26174. /**
  26175. * Defines the second number of windings
  26176. */
  26177. q: number;
  26178. /**
  26179. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26180. */
  26181. side: number;
  26182. /**
  26183. * Creates a torus knot geometry
  26184. * @param id defines the unique ID of the geometry
  26185. * @param scene defines the hosting scene
  26186. * @param radius defines the radius of the torus knot
  26187. * @param tube defines the thickness of the torus knot tube
  26188. * @param radialSegments defines the number of radial segments
  26189. * @param tubularSegments defines the number of tubular segments
  26190. * @param p defines the first number of windings
  26191. * @param q defines the second number of windings
  26192. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26193. * @param mesh defines the hosting mesh (can be null)
  26194. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26195. */
  26196. constructor(id: string, scene: Scene,
  26197. /**
  26198. * Defines the radius of the torus knot
  26199. */
  26200. radius: number,
  26201. /**
  26202. * Defines the thickness of the torus knot tube
  26203. */
  26204. tube: number,
  26205. /**
  26206. * Defines the number of radial segments
  26207. */
  26208. radialSegments: number,
  26209. /**
  26210. * Defines the number of tubular segments
  26211. */
  26212. tubularSegments: number,
  26213. /**
  26214. * Defines the first number of windings
  26215. */
  26216. p: number,
  26217. /**
  26218. * Defines the second number of windings
  26219. */
  26220. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26221. /**
  26222. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26223. */
  26224. side?: number);
  26225. /** @hidden */
  26226. _regenerateVertexData(): VertexData;
  26227. copy(id: string): Geometry;
  26228. serialize(): any;
  26229. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26230. }
  26231. }
  26232. declare module BABYLON {
  26233. /**
  26234. * Mesh representing the gorund
  26235. */
  26236. class GroundMesh extends Mesh {
  26237. /** If octree should be generated */
  26238. generateOctree: boolean;
  26239. private _heightQuads;
  26240. /** @hidden */
  26241. _subdivisionsX: number;
  26242. /** @hidden */
  26243. _subdivisionsY: number;
  26244. /** @hidden */
  26245. _width: number;
  26246. /** @hidden */
  26247. _height: number;
  26248. /** @hidden */
  26249. _minX: number;
  26250. /** @hidden */
  26251. _maxX: number;
  26252. /** @hidden */
  26253. _minZ: number;
  26254. /** @hidden */
  26255. _maxZ: number;
  26256. constructor(name: string, scene: Scene);
  26257. /**
  26258. * "GroundMesh"
  26259. * @returns "GroundMesh"
  26260. */
  26261. getClassName(): string;
  26262. /**
  26263. * The minimum of x and y subdivisions
  26264. */
  26265. readonly subdivisions: number;
  26266. /**
  26267. * X subdivisions
  26268. */
  26269. readonly subdivisionsX: number;
  26270. /**
  26271. * Y subdivisions
  26272. */
  26273. readonly subdivisionsY: number;
  26274. /**
  26275. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26276. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26277. * @param chunksCount the number of subdivisions for x and y
  26278. * @param octreeBlocksSize (Default: 32)
  26279. */
  26280. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26281. /**
  26282. * Returns a height (y) value in the Worl system :
  26283. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26284. * @param x x coordinate
  26285. * @param z z coordinate
  26286. * @returns the ground y position if (x, z) are outside the ground surface.
  26287. */
  26288. getHeightAtCoordinates(x: number, z: number): number;
  26289. /**
  26290. * Returns a normalized vector (Vector3) orthogonal to the ground
  26291. * at the ground coordinates (x, z) expressed in the World system.
  26292. * @param x x coordinate
  26293. * @param z z coordinate
  26294. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26295. */
  26296. getNormalAtCoordinates(x: number, z: number): Vector3;
  26297. /**
  26298. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26299. * at the ground coordinates (x, z) expressed in the World system.
  26300. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26301. * @param x x coordinate
  26302. * @param z z coordinate
  26303. * @param ref vector to store the result
  26304. * @returns the GroundMesh.
  26305. */
  26306. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26307. /**
  26308. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26309. * if the ground has been updated.
  26310. * This can be used in the render loop.
  26311. * @returns the GroundMesh.
  26312. */
  26313. updateCoordinateHeights(): GroundMesh;
  26314. private _getFacetAt;
  26315. private _initHeightQuads;
  26316. private _computeHeightQuads;
  26317. /**
  26318. * Serializes this ground mesh
  26319. * @param serializationObject object to write serialization to
  26320. */
  26321. serialize(serializationObject: any): void;
  26322. /**
  26323. * Parses a serialized ground mesh
  26324. * @param parsedMesh the serialized mesh
  26325. * @param scene the scene to create the ground mesh in
  26326. * @returns the created ground mesh
  26327. */
  26328. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26329. }
  26330. }
  26331. declare module BABYLON {
  26332. /**
  26333. * Creates an instance based on a source mesh.
  26334. */
  26335. class InstancedMesh extends AbstractMesh {
  26336. private _sourceMesh;
  26337. private _currentLOD;
  26338. /** @hidden */
  26339. _indexInSourceMeshInstanceArray: number;
  26340. constructor(name: string, source: Mesh);
  26341. /**
  26342. * Returns the string "InstancedMesh".
  26343. */
  26344. getClassName(): string;
  26345. /**
  26346. * If the source mesh receives shadows
  26347. */
  26348. readonly receiveShadows: boolean;
  26349. /**
  26350. * The material of the source mesh
  26351. */
  26352. readonly material: Nullable<Material>;
  26353. /**
  26354. * Visibility of the source mesh
  26355. */
  26356. readonly visibility: number;
  26357. /**
  26358. * Skeleton of the source mesh
  26359. */
  26360. readonly skeleton: Nullable<Skeleton>;
  26361. /**
  26362. * Rendering ground id of the source mesh
  26363. */
  26364. renderingGroupId: number;
  26365. /**
  26366. * Returns the total number of vertices (integer).
  26367. */
  26368. getTotalVertices(): number;
  26369. /**
  26370. * Returns a positive integer : the total number of indices in this mesh geometry.
  26371. * @returns the numner of indices or zero if the mesh has no geometry.
  26372. */
  26373. getTotalIndices(): number;
  26374. /**
  26375. * The source mesh of the instance
  26376. */
  26377. readonly sourceMesh: Mesh;
  26378. /**
  26379. * Is this node ready to be used/rendered
  26380. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26381. * @return {boolean} is it ready
  26382. */
  26383. isReady(completeCheck?: boolean): boolean;
  26384. /**
  26385. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26386. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26387. * @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.
  26388. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26389. */
  26390. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26391. /**
  26392. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26393. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26394. * The `data` are either a numeric array either a Float32Array.
  26395. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26396. * 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).
  26397. * Note that a new underlying VertexBuffer object is created each call.
  26398. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26399. *
  26400. * Possible `kind` values :
  26401. * - BABYLON.VertexBuffer.PositionKind
  26402. * - BABYLON.VertexBuffer.UVKind
  26403. * - BABYLON.VertexBuffer.UV2Kind
  26404. * - BABYLON.VertexBuffer.UV3Kind
  26405. * - BABYLON.VertexBuffer.UV4Kind
  26406. * - BABYLON.VertexBuffer.UV5Kind
  26407. * - BABYLON.VertexBuffer.UV6Kind
  26408. * - BABYLON.VertexBuffer.ColorKind
  26409. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26410. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26411. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26412. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26413. *
  26414. * Returns the Mesh.
  26415. */
  26416. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26417. /**
  26418. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26419. * If the mesh has no geometry, it is simply returned as it is.
  26420. * The `data` are either a numeric array either a Float32Array.
  26421. * No new underlying VertexBuffer object is created.
  26422. * 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.
  26423. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26424. *
  26425. * Possible `kind` values :
  26426. * - BABYLON.VertexBuffer.PositionKind
  26427. * - BABYLON.VertexBuffer.UVKind
  26428. * - BABYLON.VertexBuffer.UV2Kind
  26429. * - BABYLON.VertexBuffer.UV3Kind
  26430. * - BABYLON.VertexBuffer.UV4Kind
  26431. * - BABYLON.VertexBuffer.UV5Kind
  26432. * - BABYLON.VertexBuffer.UV6Kind
  26433. * - BABYLON.VertexBuffer.ColorKind
  26434. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26435. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26436. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26437. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26438. *
  26439. * Returns the Mesh.
  26440. */
  26441. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26442. /**
  26443. * Sets the mesh indices.
  26444. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26445. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26446. * This method creates a new index buffer each call.
  26447. * Returns the Mesh.
  26448. */
  26449. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26450. /**
  26451. * Boolean : True if the mesh owns the requested kind of data.
  26452. */
  26453. isVerticesDataPresent(kind: string): boolean;
  26454. /**
  26455. * Returns an array of indices (IndicesArray).
  26456. */
  26457. getIndices(): Nullable<IndicesArray>;
  26458. readonly _positions: Nullable<Vector3[]>;
  26459. /**
  26460. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26461. * This means the mesh underlying bounding box and sphere are recomputed.
  26462. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26463. * @returns the current mesh
  26464. */
  26465. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26466. /** @hidden */
  26467. _preActivate(): InstancedMesh;
  26468. /** @hidden */
  26469. _activate(renderId: number): InstancedMesh;
  26470. /**
  26471. * Returns the current associated LOD AbstractMesh.
  26472. */
  26473. getLOD(camera: Camera): AbstractMesh;
  26474. /** @hidden */
  26475. _syncSubMeshes(): InstancedMesh;
  26476. /** @hidden */
  26477. _generatePointsArray(): boolean;
  26478. /**
  26479. * Creates a new InstancedMesh from the current mesh.
  26480. * - name (string) : the cloned mesh name
  26481. * - newParent (optional Node) : the optional Node to parent the clone to.
  26482. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26483. *
  26484. * Returns the clone.
  26485. */
  26486. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26487. /**
  26488. * Disposes the InstancedMesh.
  26489. * Returns nothing.
  26490. */
  26491. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26492. }
  26493. }
  26494. declare module BABYLON {
  26495. /**
  26496. * Line mesh
  26497. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26498. */
  26499. class LinesMesh extends Mesh {
  26500. /**
  26501. * If vertex color should be applied to the mesh
  26502. */
  26503. useVertexColor?: boolean | undefined;
  26504. /**
  26505. * If vertex alpha should be applied to the mesh
  26506. */
  26507. useVertexAlpha?: boolean | undefined;
  26508. /**
  26509. * Color of the line (Default: White)
  26510. */
  26511. color: Color3;
  26512. /**
  26513. * Alpha of the line (Default: 1)
  26514. */
  26515. alpha: number;
  26516. /**
  26517. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26518. * This margin is expressed in world space coordinates, so its value may vary.
  26519. * Default value is 0.1
  26520. */
  26521. intersectionThreshold: number;
  26522. private _colorShader;
  26523. /**
  26524. * Creates a new LinesMesh
  26525. * @param name defines the name
  26526. * @param scene defines the hosting scene
  26527. * @param parent defines the parent mesh if any
  26528. * @param source defines the optional source LinesMesh used to clone data from
  26529. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26530. * When false, achieved by calling a clone(), also passing False.
  26531. * This will make creation of children, recursive.
  26532. * @param useVertexColor defines if this LinesMesh supports vertex color
  26533. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26534. */
  26535. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26536. /**
  26537. * If vertex color should be applied to the mesh
  26538. */
  26539. useVertexColor?: boolean | undefined,
  26540. /**
  26541. * If vertex alpha should be applied to the mesh
  26542. */
  26543. useVertexAlpha?: boolean | undefined);
  26544. /**
  26545. * Returns the string "LineMesh"
  26546. */
  26547. getClassName(): string;
  26548. /**
  26549. * @hidden
  26550. */
  26551. /**
  26552. * @hidden
  26553. */
  26554. material: Material;
  26555. /**
  26556. * @hidden
  26557. */
  26558. readonly checkCollisions: boolean;
  26559. /** @hidden */
  26560. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26561. /** @hidden */
  26562. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26563. /**
  26564. * Disposes of the line mesh
  26565. * @param doNotRecurse If children should be disposed
  26566. */
  26567. dispose(doNotRecurse?: boolean): void;
  26568. /**
  26569. * Returns a new LineMesh object cloned from the current one.
  26570. */
  26571. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26572. /**
  26573. * Creates a new InstancedLinesMesh object from the mesh model.
  26574. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26575. * @param name defines the name of the new instance
  26576. * @returns a new InstancedLinesMesh
  26577. */
  26578. createInstance(name: string): InstancedLinesMesh;
  26579. }
  26580. /**
  26581. * Creates an instance based on a source LinesMesh
  26582. */
  26583. class InstancedLinesMesh extends InstancedMesh {
  26584. /**
  26585. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26586. * This margin is expressed in world space coordinates, so its value may vary.
  26587. * Initilized with the intersectionThreshold value of the source LinesMesh
  26588. */
  26589. intersectionThreshold: number;
  26590. constructor(name: string, source: LinesMesh);
  26591. /**
  26592. * Returns the string "InstancedLinesMesh".
  26593. */
  26594. getClassName(): string;
  26595. }
  26596. }
  26597. declare module BABYLON {
  26598. /**
  26599. * @hidden
  26600. **/
  26601. class _CreationDataStorage {
  26602. closePath?: boolean;
  26603. closeArray?: boolean;
  26604. idx: number[];
  26605. dashSize: number;
  26606. gapSize: number;
  26607. path3D: Path3D;
  26608. pathArray: Vector3[][];
  26609. arc: number;
  26610. radius: number;
  26611. cap: number;
  26612. tessellation: number;
  26613. }
  26614. /**
  26615. * @hidden
  26616. **/
  26617. class _InstanceDataStorage {
  26618. visibleInstances: any;
  26619. renderIdForInstances: number[];
  26620. batchCache: _InstancesBatch;
  26621. instancesBufferSize: number;
  26622. instancesBuffer: Nullable<Buffer>;
  26623. instancesData: Float32Array;
  26624. overridenInstanceCount: number;
  26625. }
  26626. /**
  26627. * @hidden
  26628. **/
  26629. class _InstancesBatch {
  26630. mustReturn: boolean;
  26631. visibleInstances: Nullable<InstancedMesh[]>[];
  26632. renderSelf: boolean[];
  26633. }
  26634. /**
  26635. * Class used to represent renderable models
  26636. */
  26637. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26638. /**
  26639. * Mesh side orientation : usually the external or front surface
  26640. */
  26641. static readonly FRONTSIDE: number;
  26642. /**
  26643. * Mesh side orientation : usually the internal or back surface
  26644. */
  26645. static readonly BACKSIDE: number;
  26646. /**
  26647. * Mesh side orientation : both internal and external or front and back surfaces
  26648. */
  26649. static readonly DOUBLESIDE: number;
  26650. /**
  26651. * Mesh side orientation : by default, `FRONTSIDE`
  26652. */
  26653. static readonly DEFAULTSIDE: number;
  26654. /**
  26655. * Mesh cap setting : no cap
  26656. */
  26657. static readonly NO_CAP: number;
  26658. /**
  26659. * Mesh cap setting : one cap at the beginning of the mesh
  26660. */
  26661. static readonly CAP_START: number;
  26662. /**
  26663. * Mesh cap setting : one cap at the end of the mesh
  26664. */
  26665. static readonly CAP_END: number;
  26666. /**
  26667. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26668. */
  26669. static readonly CAP_ALL: number;
  26670. private _onBeforeRenderObservable;
  26671. private _onAfterRenderObservable;
  26672. private _onBeforeDrawObservable;
  26673. /**
  26674. * An event triggered before rendering the mesh
  26675. */
  26676. readonly onBeforeRenderObservable: Observable<Mesh>;
  26677. /**
  26678. * An event triggered after rendering the mesh
  26679. */
  26680. readonly onAfterRenderObservable: Observable<Mesh>;
  26681. /**
  26682. * An event triggered before drawing the mesh
  26683. */
  26684. readonly onBeforeDrawObservable: Observable<Mesh>;
  26685. private _onBeforeDrawObserver;
  26686. /**
  26687. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26688. */
  26689. onBeforeDraw: () => void;
  26690. /**
  26691. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26692. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26693. */
  26694. delayLoadState: number;
  26695. /**
  26696. * Gets the list of instances created from this mesh
  26697. * it is not supposed to be modified manually.
  26698. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26699. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26700. */
  26701. instances: InstancedMesh[];
  26702. /**
  26703. * Gets the file containing delay loading data for this mesh
  26704. */
  26705. delayLoadingFile: string;
  26706. /** @hidden */
  26707. _binaryInfo: any;
  26708. private _LODLevels;
  26709. /**
  26710. * User defined function used to change how LOD level selection is done
  26711. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26712. */
  26713. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26714. private _morphTargetManager;
  26715. /**
  26716. * Gets or sets the morph target manager
  26717. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26718. */
  26719. morphTargetManager: Nullable<MorphTargetManager>;
  26720. /** @hidden */
  26721. _creationDataStorage: Nullable<_CreationDataStorage>;
  26722. /** @hidden */
  26723. _geometry: Nullable<Geometry>;
  26724. /** @hidden */
  26725. _delayInfo: Array<string>;
  26726. /** @hidden */
  26727. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26728. /** @hidden */
  26729. _instanceDataStorage: _InstanceDataStorage;
  26730. private _effectiveMaterial;
  26731. /** @hidden */
  26732. _shouldGenerateFlatShading: boolean;
  26733. private _preActivateId;
  26734. /** @hidden */
  26735. _originalBuilderSideOrientation: number;
  26736. /**
  26737. * Use this property to change the original side orientation defined at construction time
  26738. */
  26739. overrideMaterialSideOrientation: Nullable<number>;
  26740. private _areNormalsFrozen;
  26741. private _sourcePositions;
  26742. private _sourceNormals;
  26743. private _source;
  26744. private meshMap;
  26745. /**
  26746. * Gets the source mesh (the one used to clone this one from)
  26747. */
  26748. readonly source: Nullable<Mesh>;
  26749. /**
  26750. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26751. */
  26752. isUnIndexed: boolean;
  26753. /**
  26754. * @constructor
  26755. * @param name The value used by scene.getMeshByName() to do a lookup.
  26756. * @param scene The scene to add this mesh to.
  26757. * @param parent The parent of this mesh, if it has one
  26758. * @param source An optional Mesh from which geometry is shared, cloned.
  26759. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26760. * When false, achieved by calling a clone(), also passing False.
  26761. * This will make creation of children, recursive.
  26762. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26763. */
  26764. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26765. /**
  26766. * Gets the class name
  26767. * @returns the string "Mesh".
  26768. */
  26769. getClassName(): string;
  26770. /**
  26771. * Returns a description of this mesh
  26772. * @param fullDetails define if full details about this mesh must be used
  26773. * @returns a descriptive string representing this mesh
  26774. */
  26775. toString(fullDetails?: boolean): string;
  26776. /** @hidden */
  26777. _unBindEffect(): void;
  26778. /**
  26779. * Gets a boolean indicating if this mesh has LOD
  26780. */
  26781. readonly hasLODLevels: boolean;
  26782. /**
  26783. * Gets the list of MeshLODLevel associated with the current mesh
  26784. * @returns an array of MeshLODLevel
  26785. */
  26786. getLODLevels(): MeshLODLevel[];
  26787. private _sortLODLevels;
  26788. /**
  26789. * Add a mesh as LOD level triggered at the given distance.
  26790. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26791. * @param distance The distance from the center of the object to show this level
  26792. * @param mesh The mesh to be added as LOD level (can be null)
  26793. * @return This mesh (for chaining)
  26794. */
  26795. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26796. /**
  26797. * Returns the LOD level mesh at the passed distance or null if not found.
  26798. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26799. * @param distance The distance from the center of the object to show this level
  26800. * @returns a Mesh or `null`
  26801. */
  26802. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26803. /**
  26804. * Remove a mesh from the LOD array
  26805. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26806. * @param mesh defines the mesh to be removed
  26807. * @return This mesh (for chaining)
  26808. */
  26809. removeLODLevel(mesh: Mesh): Mesh;
  26810. /**
  26811. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26812. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26813. * @param camera defines the camera to use to compute distance
  26814. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26815. * @return This mesh (for chaining)
  26816. */
  26817. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26818. /**
  26819. * Gets the mesh internal Geometry object
  26820. */
  26821. readonly geometry: Nullable<Geometry>;
  26822. /**
  26823. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26824. * @returns the total number of vertices
  26825. */
  26826. getTotalVertices(): number;
  26827. /**
  26828. * Returns the content of an associated vertex buffer
  26829. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26830. * - BABYLON.VertexBuffer.PositionKind
  26831. * - BABYLON.VertexBuffer.UVKind
  26832. * - BABYLON.VertexBuffer.UV2Kind
  26833. * - BABYLON.VertexBuffer.UV3Kind
  26834. * - BABYLON.VertexBuffer.UV4Kind
  26835. * - BABYLON.VertexBuffer.UV5Kind
  26836. * - BABYLON.VertexBuffer.UV6Kind
  26837. * - BABYLON.VertexBuffer.ColorKind
  26838. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26839. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26840. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26841. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26842. * @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
  26843. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26844. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26845. */
  26846. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26847. /**
  26848. * Returns the mesh VertexBuffer object from the requested `kind`
  26849. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26850. * - BABYLON.VertexBuffer.PositionKind
  26851. * - BABYLON.VertexBuffer.UVKind
  26852. * - BABYLON.VertexBuffer.UV2Kind
  26853. * - BABYLON.VertexBuffer.UV3Kind
  26854. * - BABYLON.VertexBuffer.UV4Kind
  26855. * - BABYLON.VertexBuffer.UV5Kind
  26856. * - BABYLON.VertexBuffer.UV6Kind
  26857. * - BABYLON.VertexBuffer.ColorKind
  26858. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26859. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26860. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26861. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26862. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26863. */
  26864. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26865. /**
  26866. * Tests if a specific vertex buffer is associated with this mesh
  26867. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26868. * - BABYLON.VertexBuffer.PositionKind
  26869. * - BABYLON.VertexBuffer.UVKind
  26870. * - BABYLON.VertexBuffer.UV2Kind
  26871. * - BABYLON.VertexBuffer.UV3Kind
  26872. * - BABYLON.VertexBuffer.UV4Kind
  26873. * - BABYLON.VertexBuffer.UV5Kind
  26874. * - BABYLON.VertexBuffer.UV6Kind
  26875. * - BABYLON.VertexBuffer.ColorKind
  26876. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26877. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26878. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26879. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26880. * @returns a boolean
  26881. */
  26882. isVerticesDataPresent(kind: string): boolean;
  26883. /**
  26884. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26885. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26886. * - BABYLON.VertexBuffer.PositionKind
  26887. * - BABYLON.VertexBuffer.UVKind
  26888. * - BABYLON.VertexBuffer.UV2Kind
  26889. * - BABYLON.VertexBuffer.UV3Kind
  26890. * - BABYLON.VertexBuffer.UV4Kind
  26891. * - BABYLON.VertexBuffer.UV5Kind
  26892. * - BABYLON.VertexBuffer.UV6Kind
  26893. * - BABYLON.VertexBuffer.ColorKind
  26894. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26895. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26896. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26897. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26898. * @returns a boolean
  26899. */
  26900. isVertexBufferUpdatable(kind: string): boolean;
  26901. /**
  26902. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26903. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26904. * - BABYLON.VertexBuffer.PositionKind
  26905. * - BABYLON.VertexBuffer.UVKind
  26906. * - BABYLON.VertexBuffer.UV2Kind
  26907. * - BABYLON.VertexBuffer.UV3Kind
  26908. * - BABYLON.VertexBuffer.UV4Kind
  26909. * - BABYLON.VertexBuffer.UV5Kind
  26910. * - BABYLON.VertexBuffer.UV6Kind
  26911. * - BABYLON.VertexBuffer.ColorKind
  26912. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26913. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26914. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26915. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26916. * @returns an array of strings
  26917. */
  26918. getVerticesDataKinds(): string[];
  26919. /**
  26920. * Returns a positive integer : the total number of indices in this mesh geometry.
  26921. * @returns the numner of indices or zero if the mesh has no geometry.
  26922. */
  26923. getTotalIndices(): number;
  26924. /**
  26925. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26926. * @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.
  26927. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26928. * @returns the indices array or an empty array if the mesh has no geometry
  26929. */
  26930. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26931. readonly isBlocked: boolean;
  26932. /**
  26933. * Determine if the current mesh is ready to be rendered
  26934. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26935. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26936. * @returns true if all associated assets are ready (material, textures, shaders)
  26937. */
  26938. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26939. /**
  26940. * 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.
  26941. */
  26942. readonly areNormalsFrozen: boolean;
  26943. /**
  26944. * 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.
  26945. * @returns the current mesh
  26946. */
  26947. freezeNormals(): Mesh;
  26948. /**
  26949. * 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
  26950. * @returns the current mesh
  26951. */
  26952. unfreezeNormals(): Mesh;
  26953. /**
  26954. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26955. */
  26956. overridenInstanceCount: number;
  26957. /** @hidden */
  26958. _preActivate(): Mesh;
  26959. /** @hidden */
  26960. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26961. /** @hidden */
  26962. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26963. /**
  26964. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26965. * This means the mesh underlying bounding box and sphere are recomputed.
  26966. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26967. * @returns the current mesh
  26968. */
  26969. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26970. /** @hidden */
  26971. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26972. /**
  26973. * This function will subdivide the mesh into multiple submeshes
  26974. * @param count defines the expected number of submeshes
  26975. */
  26976. subdivide(count: number): void;
  26977. /**
  26978. * Copy a FloatArray into a specific associated vertex buffer
  26979. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26980. * - BABYLON.VertexBuffer.PositionKind
  26981. * - BABYLON.VertexBuffer.UVKind
  26982. * - BABYLON.VertexBuffer.UV2Kind
  26983. * - BABYLON.VertexBuffer.UV3Kind
  26984. * - BABYLON.VertexBuffer.UV4Kind
  26985. * - BABYLON.VertexBuffer.UV5Kind
  26986. * - BABYLON.VertexBuffer.UV6Kind
  26987. * - BABYLON.VertexBuffer.ColorKind
  26988. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26989. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26990. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26991. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26992. * @param data defines the data source
  26993. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26994. * @param stride defines the data stride size (can be null)
  26995. * @returns the current mesh
  26996. */
  26997. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26998. /**
  26999. * Flags an associated vertex buffer as updatable
  27000. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27001. * - BABYLON.VertexBuffer.PositionKind
  27002. * - BABYLON.VertexBuffer.UVKind
  27003. * - BABYLON.VertexBuffer.UV2Kind
  27004. * - BABYLON.VertexBuffer.UV3Kind
  27005. * - BABYLON.VertexBuffer.UV4Kind
  27006. * - BABYLON.VertexBuffer.UV5Kind
  27007. * - BABYLON.VertexBuffer.UV6Kind
  27008. * - BABYLON.VertexBuffer.ColorKind
  27009. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27010. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27011. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27012. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27013. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27014. */
  27015. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27016. /**
  27017. * Sets the mesh global Vertex Buffer
  27018. * @param buffer defines the buffer to use
  27019. * @returns the current mesh
  27020. */
  27021. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27022. /**
  27023. * Update a specific associated vertex buffer
  27024. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27025. * - BABYLON.VertexBuffer.PositionKind
  27026. * - BABYLON.VertexBuffer.UVKind
  27027. * - BABYLON.VertexBuffer.UV2Kind
  27028. * - BABYLON.VertexBuffer.UV3Kind
  27029. * - BABYLON.VertexBuffer.UV4Kind
  27030. * - BABYLON.VertexBuffer.UV5Kind
  27031. * - BABYLON.VertexBuffer.UV6Kind
  27032. * - BABYLON.VertexBuffer.ColorKind
  27033. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27034. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27035. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27036. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27037. * @param data defines the data source
  27038. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27039. * @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)
  27040. * @returns the current mesh
  27041. */
  27042. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27043. /**
  27044. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27045. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27046. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27047. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27048. * @returns the current mesh
  27049. */
  27050. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27051. /**
  27052. * Creates a un-shared specific occurence of the geometry for the mesh.
  27053. * @returns the current mesh
  27054. */
  27055. makeGeometryUnique(): Mesh;
  27056. /**
  27057. * Set the index buffer of this mesh
  27058. * @param indices defines the source data
  27059. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27060. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27061. * @returns the current mesh
  27062. */
  27063. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27064. /**
  27065. * Update the current index buffer
  27066. * @param indices defines the source data
  27067. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27068. * @returns the current mesh
  27069. */
  27070. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27071. /**
  27072. * Invert the geometry to move from a right handed system to a left handed one.
  27073. * @returns the current mesh
  27074. */
  27075. toLeftHanded(): Mesh;
  27076. /** @hidden */
  27077. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27078. /** @hidden */
  27079. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27080. /**
  27081. * Registers for this mesh a javascript function called just before the rendering process
  27082. * @param func defines the function to call before rendering this mesh
  27083. * @returns the current mesh
  27084. */
  27085. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27086. /**
  27087. * Disposes a previously registered javascript function called before the rendering
  27088. * @param func defines the function to remove
  27089. * @returns the current mesh
  27090. */
  27091. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27092. /**
  27093. * Registers for this mesh a javascript function called just after the rendering is complete
  27094. * @param func defines the function to call after rendering this mesh
  27095. * @returns the current mesh
  27096. */
  27097. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27098. /**
  27099. * Disposes a previously registered javascript function called after the rendering.
  27100. * @param func defines the function to remove
  27101. * @returns the current mesh
  27102. */
  27103. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27104. /** @hidden */
  27105. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27106. /** @hidden */
  27107. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27108. /** @hidden */
  27109. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27110. /**
  27111. * 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
  27112. * @param subMesh defines the subMesh to render
  27113. * @param enableAlphaMode defines if alpha mode can be changed
  27114. * @returns the current mesh
  27115. */
  27116. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27117. private _onBeforeDraw;
  27118. /**
  27119. * Renormalize the mesh and patch it up if there are no weights
  27120. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27121. * However in the case of zero weights then we set just a single influence to 1.
  27122. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27123. */
  27124. cleanMatrixWeights(): void;
  27125. private normalizeSkinFourWeights;
  27126. private normalizeSkinWeightsAndExtra;
  27127. /**
  27128. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27129. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27130. * the user know there was an issue with importing the mesh
  27131. * @returns a validation object with skinned, valid and report string
  27132. */
  27133. validateSkinning(): {
  27134. skinned: boolean;
  27135. valid: boolean;
  27136. report: string;
  27137. };
  27138. /** @hidden */
  27139. _checkDelayState(): Mesh;
  27140. private _queueLoad;
  27141. /**
  27142. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27143. * A mesh is in the frustum if its bounding box intersects the frustum
  27144. * @param frustumPlanes defines the frustum to test
  27145. * @returns true if the mesh is in the frustum planes
  27146. */
  27147. isInFrustum(frustumPlanes: Plane[]): boolean;
  27148. /**
  27149. * Sets the mesh material by the material or multiMaterial `id` property
  27150. * @param id is a string identifying the material or the multiMaterial
  27151. * @returns the current mesh
  27152. */
  27153. setMaterialByID(id: string): Mesh;
  27154. /**
  27155. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27156. * @returns an array of IAnimatable
  27157. */
  27158. getAnimatables(): IAnimatable[];
  27159. /**
  27160. * Modifies the mesh geometry according to the passed transformation matrix.
  27161. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27162. * The mesh normals are modified using the same transformation.
  27163. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27164. * @param transform defines the transform matrix to use
  27165. * @see http://doc.babylonjs.com/resources/baking_transformations
  27166. * @returns the current mesh
  27167. */
  27168. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27169. /**
  27170. * Modifies the mesh geometry according to its own current World Matrix.
  27171. * The mesh World Matrix is then reset.
  27172. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27173. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27174. * @see http://doc.babylonjs.com/resources/baking_transformations
  27175. * @returns the current mesh
  27176. */
  27177. bakeCurrentTransformIntoVertices(): Mesh;
  27178. /** @hidden */
  27179. readonly _positions: Nullable<Vector3[]>;
  27180. /** @hidden */
  27181. _resetPointsArrayCache(): Mesh;
  27182. /** @hidden */
  27183. _generatePointsArray(): boolean;
  27184. /**
  27185. * Returns a new Mesh object generated from the current mesh properties.
  27186. * This method must not get confused with createInstance()
  27187. * @param name is a string, the name given to the new mesh
  27188. * @param newParent can be any Node object (default `null`)
  27189. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27190. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27191. * @returns a new mesh
  27192. */
  27193. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27194. /**
  27195. * Releases resources associated with this mesh.
  27196. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27197. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27198. */
  27199. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27200. /**
  27201. * Modifies the mesh geometry according to a displacement map.
  27202. * 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.
  27203. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27204. * @param url is a string, the URL from the image file is to be downloaded.
  27205. * @param minHeight is the lower limit of the displacement.
  27206. * @param maxHeight is the upper limit of the displacement.
  27207. * @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.
  27208. * @param uvOffset is an optional vector2 used to offset UV.
  27209. * @param uvScale is an optional vector2 used to scale UV.
  27210. * @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.
  27211. * @returns the Mesh.
  27212. */
  27213. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27214. /**
  27215. * Modifies the mesh geometry according to a displacementMap buffer.
  27216. * 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.
  27217. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27218. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27219. * @param heightMapWidth is the width of the buffer image.
  27220. * @param heightMapHeight is the height of the buffer image.
  27221. * @param minHeight is the lower limit of the displacement.
  27222. * @param maxHeight is the upper limit of the displacement.
  27223. * @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.
  27224. * @param uvOffset is an optional vector2 used to offset UV.
  27225. * @param uvScale is an optional vector2 used to scale UV.
  27226. * @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.
  27227. * @returns the Mesh.
  27228. */
  27229. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27230. /**
  27231. * Modify the mesh to get a flat shading rendering.
  27232. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27233. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27234. * @returns current mesh
  27235. */
  27236. convertToFlatShadedMesh(): Mesh;
  27237. /**
  27238. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27239. * In other words, more vertices, no more indices and a single bigger VBO.
  27240. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27241. * @returns current mesh
  27242. */
  27243. convertToUnIndexedMesh(): Mesh;
  27244. /**
  27245. * Inverses facet orientations.
  27246. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27247. * @param flipNormals will also inverts the normals
  27248. * @returns current mesh
  27249. */
  27250. flipFaces(flipNormals?: boolean): Mesh;
  27251. /**
  27252. * Creates a new InstancedMesh object from the mesh model.
  27253. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27254. * @param name defines the name of the new instance
  27255. * @returns a new InstancedMesh
  27256. */
  27257. createInstance(name: string): InstancedMesh;
  27258. /**
  27259. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27260. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27261. * @returns the current mesh
  27262. */
  27263. synchronizeInstances(): Mesh;
  27264. /**
  27265. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27266. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27267. * This should be used together with the simplification to avoid disappearing triangles.
  27268. * @param successCallback an optional success callback to be called after the optimization finished.
  27269. * @returns the current mesh
  27270. */
  27271. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27272. /**
  27273. * Serialize current mesh
  27274. * @param serializationObject defines the object which will receive the serialization data
  27275. */
  27276. serialize(serializationObject: any): void;
  27277. /** @hidden */
  27278. _syncGeometryWithMorphTargetManager(): void;
  27279. /**
  27280. * Returns a new Mesh object parsed from the source provided.
  27281. * @param parsedMesh is the source
  27282. * @param scene defines the hosting scene
  27283. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27284. * @returns a new Mesh
  27285. */
  27286. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27287. /**
  27288. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27289. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27290. * @param name defines the name of the mesh to create
  27291. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27292. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27293. * @param closePath creates a seam between the first and the last points of each path of the path array
  27294. * @param offset is taken in account only if the `pathArray` is containing a single path
  27295. * @param scene defines the hosting scene
  27296. * @param updatable defines if the mesh must be flagged as updatable
  27297. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27298. * @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)
  27299. * @returns a new Mesh
  27300. */
  27301. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27302. /**
  27303. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27304. * @param name defines the name of the mesh to create
  27305. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27306. * @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
  27307. * @param scene defines the hosting scene
  27308. * @param updatable defines if the mesh must be flagged as updatable
  27309. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27310. * @returns a new Mesh
  27311. */
  27312. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27313. /**
  27314. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27315. * @param name defines the name of the mesh to create
  27316. * @param size sets the size (float) of each box side (default 1)
  27317. * @param scene defines the hosting scene
  27318. * @param updatable defines if the mesh must be flagged as updatable
  27319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27320. * @returns a new Mesh
  27321. */
  27322. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27323. /**
  27324. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27325. * @param name defines the name of the mesh to create
  27326. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27327. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27328. * @param scene defines the hosting scene
  27329. * @param updatable defines if the mesh must be flagged as updatable
  27330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27331. * @returns a new Mesh
  27332. */
  27333. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27334. /**
  27335. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27336. * @param name defines the name of the mesh to create
  27337. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27338. * @param diameterTop set the top cap diameter (floats, default 1)
  27339. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27340. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27341. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27342. * @param scene defines the hosting scene
  27343. * @param updatable defines if the mesh must be flagged as updatable
  27344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27345. * @returns a new Mesh
  27346. */
  27347. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27348. /**
  27349. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27350. * @param name defines the name of the mesh to create
  27351. * @param diameter sets the diameter size (float) of the torus (default 1)
  27352. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27353. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27354. * @param scene defines the hosting scene
  27355. * @param updatable defines if the mesh must be flagged as updatable
  27356. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27357. * @returns a new Mesh
  27358. */
  27359. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27360. /**
  27361. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27362. * @param name defines the name of the mesh to create
  27363. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27364. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27365. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27366. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27367. * @param p the number of windings on X axis (positive integers, default 2)
  27368. * @param q the number of windings on Y axis (positive integers, default 3)
  27369. * @param scene defines the hosting scene
  27370. * @param updatable defines if the mesh must be flagged as updatable
  27371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27372. * @returns a new Mesh
  27373. */
  27374. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27375. /**
  27376. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27377. * @param name defines the name of the mesh to create
  27378. * @param points is an array successive Vector3
  27379. * @param scene defines the hosting scene
  27380. * @param updatable defines if the mesh must be flagged as updatable
  27381. * @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).
  27382. * @returns a new Mesh
  27383. */
  27384. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27385. /**
  27386. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27387. * @param name defines the name of the mesh to create
  27388. * @param points is an array successive Vector3
  27389. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27390. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27391. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27392. * @param scene defines the hosting scene
  27393. * @param updatable defines if the mesh must be flagged as updatable
  27394. * @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)
  27395. * @returns a new Mesh
  27396. */
  27397. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27398. /**
  27399. * Creates a polygon mesh.
  27400. * Please consider using the same method from the MeshBuilder class instead.
  27401. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27402. * 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.
  27403. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27404. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27405. * Remember you can only change the shape positions, not their number when updating a polygon.
  27406. */
  27407. /**
  27408. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27409. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27410. * @param name defines the name of the mesh to create
  27411. * @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
  27412. * @param scene defines the hosting scene
  27413. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27414. * @param updatable defines if the mesh must be flagged as updatable
  27415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27416. * @returns a new Mesh
  27417. */
  27418. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27419. /**
  27420. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27421. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27422. * @param name defines the name of the mesh to create
  27423. * @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
  27424. * @param depth defines the height of extrusion
  27425. * @param scene defines the hosting scene
  27426. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27427. * @param updatable defines if the mesh must be flagged as updatable
  27428. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27429. * @returns a new Mesh
  27430. */
  27431. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27432. /**
  27433. * Creates an extruded shape mesh.
  27434. * 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
  27435. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27436. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27437. * @param name defines the name of the mesh to create
  27438. * @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
  27439. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27440. * @param scale is the value to scale the shape
  27441. * @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
  27442. * @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
  27443. * @param scene defines the hosting scene
  27444. * @param updatable defines if the mesh must be flagged as updatable
  27445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27446. * @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)
  27447. * @returns a new Mesh
  27448. */
  27449. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27450. /**
  27451. * Creates an custom extruded shape mesh.
  27452. * The custom extrusion is a parametric shape.
  27453. * It has no predefined shape. Its final shape will depend on the input parameters.
  27454. * Please consider using the same method from the MeshBuilder class instead
  27455. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27456. * @param name defines the name of the mesh to create
  27457. * @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
  27458. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27459. * @param scaleFunction is a custom Javascript function called on each path point
  27460. * @param rotationFunction is a custom Javascript function called on each path point
  27461. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27462. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27463. * @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
  27464. * @param scene defines the hosting scene
  27465. * @param updatable defines if the mesh must be flagged as updatable
  27466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27467. * @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)
  27468. * @returns a new Mesh
  27469. */
  27470. 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;
  27471. /**
  27472. * Creates lathe mesh.
  27473. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27474. * Please consider using the same method from the MeshBuilder class instead
  27475. * @param name defines the name of the mesh to create
  27476. * @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
  27477. * @param radius is the radius value of the lathe
  27478. * @param tessellation is the side number of the lathe.
  27479. * @param scene defines the hosting scene
  27480. * @param updatable defines if the mesh must be flagged as updatable
  27481. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27482. * @returns a new Mesh
  27483. */
  27484. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27485. /**
  27486. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27487. * @param name defines the name of the mesh to create
  27488. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27489. * @param scene defines the hosting scene
  27490. * @param updatable defines if the mesh must be flagged as updatable
  27491. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27492. * @returns a new Mesh
  27493. */
  27494. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27495. /**
  27496. * Creates a ground mesh.
  27497. * Please consider using the same method from the MeshBuilder class instead
  27498. * @param name defines the name of the mesh to create
  27499. * @param width set the width of the ground
  27500. * @param height set the height of the ground
  27501. * @param subdivisions sets the number of subdivisions per side
  27502. * @param scene defines the hosting scene
  27503. * @param updatable defines if the mesh must be flagged as updatable
  27504. * @returns a new Mesh
  27505. */
  27506. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27507. /**
  27508. * Creates a tiled ground mesh.
  27509. * Please consider using the same method from the MeshBuilder class instead
  27510. * @param name defines the name of the mesh to create
  27511. * @param xmin set the ground minimum X coordinate
  27512. * @param zmin set the ground minimum Y coordinate
  27513. * @param xmax set the ground maximum X coordinate
  27514. * @param zmax set the ground maximum Z coordinate
  27515. * @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
  27516. * @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
  27517. * @param scene defines the hosting scene
  27518. * @param updatable defines if the mesh must be flagged as updatable
  27519. * @returns a new Mesh
  27520. */
  27521. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27522. w: number;
  27523. h: number;
  27524. }, precision: {
  27525. w: number;
  27526. h: number;
  27527. }, scene: Scene, updatable?: boolean): Mesh;
  27528. /**
  27529. * Creates a ground mesh from a height map.
  27530. * Please consider using the same method from the MeshBuilder class instead
  27531. * @see http://doc.babylonjs.com/babylon101/height_map
  27532. * @param name defines the name of the mesh to create
  27533. * @param url sets the URL of the height map image resource
  27534. * @param width set the ground width size
  27535. * @param height set the ground height size
  27536. * @param subdivisions sets the number of subdivision per side
  27537. * @param minHeight is the minimum altitude on the ground
  27538. * @param maxHeight is the maximum altitude on the ground
  27539. * @param scene defines the hosting scene
  27540. * @param updatable defines if the mesh must be flagged as updatable
  27541. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27542. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27543. * @returns a new Mesh
  27544. */
  27545. 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;
  27546. /**
  27547. * Creates a tube mesh.
  27548. * The tube is a parametric shape.
  27549. * It has no predefined shape. Its final shape will depend on the input parameters.
  27550. * Please consider using the same method from the MeshBuilder class instead
  27551. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27552. * @param name defines the name of the mesh to create
  27553. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27554. * @param radius sets the tube radius size
  27555. * @param tessellation is the number of sides on the tubular surface
  27556. * @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
  27557. * @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
  27558. * @param scene defines the hosting scene
  27559. * @param updatable defines if the mesh must be flagged as updatable
  27560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27561. * @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)
  27562. * @returns a new Mesh
  27563. */
  27564. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27565. (i: number, distance: number): number;
  27566. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27567. /**
  27568. * Creates a polyhedron mesh.
  27569. * Please consider using the same method from the MeshBuilder class instead.
  27570. * * 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
  27571. * * The parameter `size` (positive float, default 1) sets the polygon size
  27572. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27573. * * 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`
  27574. * * 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
  27575. * * 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)`)
  27576. * * 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
  27577. * * 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
  27578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27579. * * 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
  27580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27581. * @param name defines the name of the mesh to create
  27582. * @param options defines the options used to create the mesh
  27583. * @param scene defines the hosting scene
  27584. * @returns a new Mesh
  27585. */
  27586. static CreatePolyhedron(name: string, options: {
  27587. type?: number;
  27588. size?: number;
  27589. sizeX?: number;
  27590. sizeY?: number;
  27591. sizeZ?: number;
  27592. custom?: any;
  27593. faceUV?: Vector4[];
  27594. faceColors?: Color4[];
  27595. updatable?: boolean;
  27596. sideOrientation?: number;
  27597. }, scene: Scene): Mesh;
  27598. /**
  27599. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27600. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27601. * * 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`)
  27602. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27603. * * 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
  27604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27605. * * 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
  27606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27607. * @param name defines the name of the mesh
  27608. * @param options defines the options used to create the mesh
  27609. * @param scene defines the hosting scene
  27610. * @returns a new Mesh
  27611. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27612. */
  27613. static CreateIcoSphere(name: string, options: {
  27614. radius?: number;
  27615. flat?: boolean;
  27616. subdivisions?: number;
  27617. sideOrientation?: number;
  27618. updatable?: boolean;
  27619. }, scene: Scene): Mesh;
  27620. /**
  27621. * Creates a decal mesh.
  27622. * Please consider using the same method from the MeshBuilder class instead.
  27623. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27624. * @param name defines the name of the mesh
  27625. * @param sourceMesh defines the mesh receiving the decal
  27626. * @param position sets the position of the decal in world coordinates
  27627. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27628. * @param size sets the decal scaling
  27629. * @param angle sets the angle to rotate the decal
  27630. * @returns a new Mesh
  27631. */
  27632. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27633. /**
  27634. * Prepare internal position array for software CPU skinning
  27635. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27636. */
  27637. setPositionsForCPUSkinning(): Float32Array;
  27638. /**
  27639. * Prepare internal normal array for software CPU skinning
  27640. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27641. */
  27642. setNormalsForCPUSkinning(): Float32Array;
  27643. /**
  27644. * Updates the vertex buffer by applying transformation from the bones
  27645. * @param skeleton defines the skeleton to apply to current mesh
  27646. * @returns the current mesh
  27647. */
  27648. applySkeleton(skeleton: Skeleton): Mesh;
  27649. /**
  27650. * 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
  27651. * @param meshes defines the list of meshes to scan
  27652. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27653. */
  27654. static MinMax(meshes: AbstractMesh[]): {
  27655. min: Vector3;
  27656. max: Vector3;
  27657. };
  27658. /**
  27659. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27660. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27661. * @returns a vector3
  27662. */
  27663. static Center(meshesOrMinMaxVector: {
  27664. min: Vector3;
  27665. max: Vector3;
  27666. } | AbstractMesh[]): Vector3;
  27667. /**
  27668. * Merge the array of meshes into a single mesh for performance reasons.
  27669. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27670. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27671. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27672. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27673. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27674. * @returns a new mesh
  27675. */
  27676. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27677. /** @hidden */
  27678. addInstance(instance: InstancedMesh): void;
  27679. /** @hidden */
  27680. removeInstance(instance: InstancedMesh): void;
  27681. }
  27682. }
  27683. declare module BABYLON {
  27684. /**
  27685. * Define an interface for all classes that will get and set the data on vertices
  27686. */
  27687. interface IGetSetVerticesData {
  27688. /**
  27689. * Gets a boolean indicating if specific vertex data is present
  27690. * @param kind defines the vertex data kind to use
  27691. * @returns true is data kind is present
  27692. */
  27693. isVerticesDataPresent(kind: string): boolean;
  27694. /**
  27695. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27696. * @param kind defines the data kind (Position, normal, etc...)
  27697. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27698. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27699. * @returns a float array containing vertex data
  27700. */
  27701. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27702. /**
  27703. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27704. * @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.
  27705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27706. * @returns the indices array or an empty array if the mesh has no geometry
  27707. */
  27708. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27709. /**
  27710. * Set specific vertex data
  27711. * @param kind defines the data kind (Position, normal, etc...)
  27712. * @param data defines the vertex data to use
  27713. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27714. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27715. */
  27716. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27717. /**
  27718. * Update a specific associated vertex buffer
  27719. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27720. * - BABYLON.VertexBuffer.PositionKind
  27721. * - BABYLON.VertexBuffer.UVKind
  27722. * - BABYLON.VertexBuffer.UV2Kind
  27723. * - BABYLON.VertexBuffer.UV3Kind
  27724. * - BABYLON.VertexBuffer.UV4Kind
  27725. * - BABYLON.VertexBuffer.UV5Kind
  27726. * - BABYLON.VertexBuffer.UV6Kind
  27727. * - BABYLON.VertexBuffer.ColorKind
  27728. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27729. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27730. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27731. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27732. * @param data defines the data source
  27733. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27734. * @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)
  27735. */
  27736. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27737. /**
  27738. * Creates a new index buffer
  27739. * @param indices defines the indices to store in the index buffer
  27740. * @param totalVertices defines the total number of vertices (could be null)
  27741. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27742. */
  27743. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27744. }
  27745. /**
  27746. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27747. */
  27748. class VertexData {
  27749. /**
  27750. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27751. */
  27752. positions: Nullable<FloatArray>;
  27753. /**
  27754. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27755. */
  27756. normals: Nullable<FloatArray>;
  27757. /**
  27758. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27759. */
  27760. tangents: Nullable<FloatArray>;
  27761. /**
  27762. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27763. */
  27764. uvs: Nullable<FloatArray>;
  27765. /**
  27766. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27767. */
  27768. uvs2: Nullable<FloatArray>;
  27769. /**
  27770. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27771. */
  27772. uvs3: Nullable<FloatArray>;
  27773. /**
  27774. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27775. */
  27776. uvs4: Nullable<FloatArray>;
  27777. /**
  27778. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27779. */
  27780. uvs5: Nullable<FloatArray>;
  27781. /**
  27782. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27783. */
  27784. uvs6: Nullable<FloatArray>;
  27785. /**
  27786. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27787. */
  27788. colors: Nullable<FloatArray>;
  27789. /**
  27790. * 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).
  27791. */
  27792. matricesIndices: Nullable<FloatArray>;
  27793. /**
  27794. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27795. */
  27796. matricesWeights: Nullable<FloatArray>;
  27797. /**
  27798. * An array extending the number of possible indices
  27799. */
  27800. matricesIndicesExtra: Nullable<FloatArray>;
  27801. /**
  27802. * An array extending the number of possible weights when the number of indices is extended
  27803. */
  27804. matricesWeightsExtra: Nullable<FloatArray>;
  27805. /**
  27806. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27807. */
  27808. indices: Nullable<IndicesArray>;
  27809. /**
  27810. * Uses the passed data array to set the set the values for the specified kind of data
  27811. * @param data a linear array of floating numbers
  27812. * @param kind the type of data that is being set, eg positions, colors etc
  27813. */
  27814. set(data: FloatArray, kind: string): void;
  27815. /**
  27816. * Associates the vertexData to the passed Mesh.
  27817. * Sets it as updatable or not (default `false`)
  27818. * @param mesh the mesh the vertexData is applied to
  27819. * @param updatable when used and having the value true allows new data to update the vertexData
  27820. * @returns the VertexData
  27821. */
  27822. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27823. /**
  27824. * Associates the vertexData to the passed Geometry.
  27825. * Sets it as updatable or not (default `false`)
  27826. * @param geometry the geometry the vertexData is applied to
  27827. * @param updatable when used and having the value true allows new data to update the vertexData
  27828. * @returns VertexData
  27829. */
  27830. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27831. /**
  27832. * Updates the associated mesh
  27833. * @param mesh the mesh to be updated
  27834. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27835. * @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
  27836. * @returns VertexData
  27837. */
  27838. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27839. /**
  27840. * Updates the associated geometry
  27841. * @param geometry the geometry to be updated
  27842. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27843. * @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
  27844. * @returns VertexData.
  27845. */
  27846. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27847. private _applyTo;
  27848. private _update;
  27849. /**
  27850. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27851. * @param matrix the transforming matrix
  27852. * @returns the VertexData
  27853. */
  27854. transform(matrix: Matrix): VertexData;
  27855. /**
  27856. * Merges the passed VertexData into the current one
  27857. * @param other the VertexData to be merged into the current one
  27858. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27859. * @returns the modified VertexData
  27860. */
  27861. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27862. private _mergeElement;
  27863. private _validate;
  27864. /**
  27865. * Serializes the VertexData
  27866. * @returns a serialized object
  27867. */
  27868. serialize(): any;
  27869. /**
  27870. * Extracts the vertexData from a mesh
  27871. * @param mesh the mesh from which to extract the VertexData
  27872. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27873. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27874. * @returns the object VertexData associated to the passed mesh
  27875. */
  27876. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27877. /**
  27878. * Extracts the vertexData from the geometry
  27879. * @param geometry the geometry from which to extract the VertexData
  27880. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27881. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27882. * @returns the object VertexData associated to the passed mesh
  27883. */
  27884. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27885. private static _ExtractFrom;
  27886. /**
  27887. * Creates the VertexData for a Ribbon
  27888. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27889. * * pathArray array of paths, each of which an array of successive Vector3
  27890. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27891. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27892. * * 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
  27893. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27894. * * 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)
  27895. * * 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)
  27896. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27897. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27898. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27899. * @returns the VertexData of the ribbon
  27900. */
  27901. static CreateRibbon(options: {
  27902. pathArray: Vector3[][];
  27903. closeArray?: boolean;
  27904. closePath?: boolean;
  27905. offset?: number;
  27906. sideOrientation?: number;
  27907. frontUVs?: Vector4;
  27908. backUVs?: Vector4;
  27909. invertUV?: boolean;
  27910. uvs?: Vector2[];
  27911. colors?: Color4[];
  27912. }): VertexData;
  27913. /**
  27914. * Creates the VertexData for a box
  27915. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27916. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27917. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27918. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27919. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27920. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27921. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27922. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27923. * * 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)
  27924. * * 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)
  27925. * @returns the VertexData of the box
  27926. */
  27927. static CreateBox(options: {
  27928. size?: number;
  27929. width?: number;
  27930. height?: number;
  27931. depth?: number;
  27932. faceUV?: Vector4[];
  27933. faceColors?: Color4[];
  27934. sideOrientation?: number;
  27935. frontUVs?: Vector4;
  27936. backUVs?: Vector4;
  27937. }): VertexData;
  27938. /**
  27939. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27940. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27941. * * segments sets the number of horizontal strips optional, default 32
  27942. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27943. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27944. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27945. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27946. * * 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
  27947. * * 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
  27948. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27949. * * 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)
  27950. * * 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)
  27951. * @returns the VertexData of the ellipsoid
  27952. */
  27953. static CreateSphere(options: {
  27954. segments?: number;
  27955. diameter?: number;
  27956. diameterX?: number;
  27957. diameterY?: number;
  27958. diameterZ?: number;
  27959. arc?: number;
  27960. slice?: number;
  27961. sideOrientation?: number;
  27962. frontUVs?: Vector4;
  27963. backUVs?: Vector4;
  27964. }): VertexData;
  27965. /**
  27966. * Creates the VertexData for a cylinder, cone or prism
  27967. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27968. * * height sets the height (y direction) of the cylinder, optional, default 2
  27969. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27970. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27971. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27972. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27973. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27974. * * 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
  27975. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27976. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27977. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27978. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27979. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27980. * * 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)
  27981. * * 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)
  27982. * @returns the VertexData of the cylinder, cone or prism
  27983. */
  27984. static CreateCylinder(options: {
  27985. height?: number;
  27986. diameterTop?: number;
  27987. diameterBottom?: number;
  27988. diameter?: number;
  27989. tessellation?: number;
  27990. subdivisions?: number;
  27991. arc?: number;
  27992. faceColors?: Color4[];
  27993. faceUV?: Vector4[];
  27994. hasRings?: boolean;
  27995. enclose?: boolean;
  27996. sideOrientation?: number;
  27997. frontUVs?: Vector4;
  27998. backUVs?: Vector4;
  27999. }): VertexData;
  28000. /**
  28001. * Creates the VertexData for a torus
  28002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28003. * * diameter the diameter of the torus, optional default 1
  28004. * * thickness the diameter of the tube forming the torus, optional default 0.5
  28005. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28006. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28007. * * 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)
  28008. * * 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)
  28009. * @returns the VertexData of the torus
  28010. */
  28011. static CreateTorus(options: {
  28012. diameter?: number;
  28013. thickness?: number;
  28014. tessellation?: number;
  28015. sideOrientation?: number;
  28016. frontUVs?: Vector4;
  28017. backUVs?: Vector4;
  28018. }): VertexData;
  28019. /**
  28020. * Creates the VertexData of the LineSystem
  28021. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  28022. * - lines an array of lines, each line being an array of successive Vector3
  28023. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  28024. * @returns the VertexData of the LineSystem
  28025. */
  28026. static CreateLineSystem(options: {
  28027. lines: Vector3[][];
  28028. colors?: Nullable<Color4[][]>;
  28029. }): VertexData;
  28030. /**
  28031. * Create the VertexData for a DashedLines
  28032. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  28033. * - points an array successive Vector3
  28034. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  28035. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  28036. * - dashNb the intended total number of dashes, optional, default 200
  28037. * @returns the VertexData for the DashedLines
  28038. */
  28039. static CreateDashedLines(options: {
  28040. points: Vector3[];
  28041. dashSize?: number;
  28042. gapSize?: number;
  28043. dashNb?: number;
  28044. }): VertexData;
  28045. /**
  28046. * Creates the VertexData for a Ground
  28047. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28048. * - width the width (x direction) of the ground, optional, default 1
  28049. * - height the height (z direction) of the ground, optional, default 1
  28050. * - subdivisions the number of subdivisions per side, optional, default 1
  28051. * @returns the VertexData of the Ground
  28052. */
  28053. static CreateGround(options: {
  28054. width?: number;
  28055. height?: number;
  28056. subdivisions?: number;
  28057. subdivisionsX?: number;
  28058. subdivisionsY?: number;
  28059. }): VertexData;
  28060. /**
  28061. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28062. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28063. * * xmin the ground minimum X coordinate, optional, default -1
  28064. * * zmin the ground minimum Z coordinate, optional, default -1
  28065. * * xmax the ground maximum X coordinate, optional, default 1
  28066. * * zmax the ground maximum Z coordinate, optional, default 1
  28067. * * 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}
  28068. * * 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}
  28069. * @returns the VertexData of the TiledGround
  28070. */
  28071. static CreateTiledGround(options: {
  28072. xmin: number;
  28073. zmin: number;
  28074. xmax: number;
  28075. zmax: number;
  28076. subdivisions?: {
  28077. w: number;
  28078. h: number;
  28079. };
  28080. precision?: {
  28081. w: number;
  28082. h: number;
  28083. };
  28084. }): VertexData;
  28085. /**
  28086. * Creates the VertexData of the Ground designed from a heightmap
  28087. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28088. * * width the width (x direction) of the ground
  28089. * * height the height (z direction) of the ground
  28090. * * subdivisions the number of subdivisions per side
  28091. * * minHeight the minimum altitude on the ground, optional, default 0
  28092. * * maxHeight the maximum altitude on the ground, optional default 1
  28093. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28094. * * buffer the array holding the image color data
  28095. * * bufferWidth the width of image
  28096. * * bufferHeight the height of image
  28097. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28098. * @returns the VertexData of the Ground designed from a heightmap
  28099. */
  28100. static CreateGroundFromHeightMap(options: {
  28101. width: number;
  28102. height: number;
  28103. subdivisions: number;
  28104. minHeight: number;
  28105. maxHeight: number;
  28106. colorFilter: Color3;
  28107. buffer: Uint8Array;
  28108. bufferWidth: number;
  28109. bufferHeight: number;
  28110. alphaFilter: number;
  28111. }): VertexData;
  28112. /**
  28113. * Creates the VertexData for a Plane
  28114. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28115. * * size sets the width and height of the plane to the value of size, optional default 1
  28116. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28117. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28118. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28119. * * 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)
  28120. * * 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)
  28121. * @returns the VertexData of the box
  28122. */
  28123. static CreatePlane(options: {
  28124. size?: number;
  28125. width?: number;
  28126. height?: number;
  28127. sideOrientation?: number;
  28128. frontUVs?: Vector4;
  28129. backUVs?: Vector4;
  28130. }): VertexData;
  28131. /**
  28132. * Creates the VertexData of the Disc or regular Polygon
  28133. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28134. * * radius the radius of the disc, optional default 0.5
  28135. * * tessellation the number of polygon sides, optional, default 64
  28136. * * 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
  28137. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28138. * * 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)
  28139. * * 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)
  28140. * @returns the VertexData of the box
  28141. */
  28142. static CreateDisc(options: {
  28143. radius?: number;
  28144. tessellation?: number;
  28145. arc?: number;
  28146. sideOrientation?: number;
  28147. frontUVs?: Vector4;
  28148. backUVs?: Vector4;
  28149. }): VertexData;
  28150. /**
  28151. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28152. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28153. * @param polygon a mesh built from polygonTriangulation.build()
  28154. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28155. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28156. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28157. * @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)
  28158. * @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)
  28159. * @returns the VertexData of the Polygon
  28160. */
  28161. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28162. /**
  28163. * Creates the VertexData of the IcoSphere
  28164. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28165. * * radius the radius of the IcoSphere, optional default 1
  28166. * * radiusX allows stretching in the x direction, optional, default radius
  28167. * * radiusY allows stretching in the y direction, optional, default radius
  28168. * * radiusZ allows stretching in the z direction, optional, default radius
  28169. * * flat when true creates a flat shaded mesh, optional, default true
  28170. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28171. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28172. * * 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)
  28173. * * 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)
  28174. * @returns the VertexData of the IcoSphere
  28175. */
  28176. static CreateIcoSphere(options: {
  28177. radius?: number;
  28178. radiusX?: number;
  28179. radiusY?: number;
  28180. radiusZ?: number;
  28181. flat?: boolean;
  28182. subdivisions?: number;
  28183. sideOrientation?: number;
  28184. frontUVs?: Vector4;
  28185. backUVs?: Vector4;
  28186. }): VertexData;
  28187. /**
  28188. * Creates the VertexData for a Polyhedron
  28189. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28190. * * type provided types are:
  28191. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28192. * * 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)
  28193. * * size the size of the IcoSphere, optional default 1
  28194. * * sizeX allows stretching in the x direction, optional, default size
  28195. * * sizeY allows stretching in the y direction, optional, default size
  28196. * * sizeZ allows stretching in the z direction, optional, default size
  28197. * * 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
  28198. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28199. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28200. * * flat when true creates a flat shaded mesh, optional, default true
  28201. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28202. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28203. * * 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)
  28204. * * 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)
  28205. * @returns the VertexData of the Polyhedron
  28206. */
  28207. static CreatePolyhedron(options: {
  28208. type?: number;
  28209. size?: number;
  28210. sizeX?: number;
  28211. sizeY?: number;
  28212. sizeZ?: number;
  28213. custom?: any;
  28214. faceUV?: Vector4[];
  28215. faceColors?: Color4[];
  28216. flat?: boolean;
  28217. sideOrientation?: number;
  28218. frontUVs?: Vector4;
  28219. backUVs?: Vector4;
  28220. }): VertexData;
  28221. /**
  28222. * Creates the VertexData for a TorusKnot
  28223. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28224. * * radius the radius of the torus knot, optional, default 2
  28225. * * tube the thickness of the tube, optional, default 0.5
  28226. * * radialSegments the number of sides on each tube segments, optional, default 32
  28227. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28228. * * p the number of windings around the z axis, optional, default 2
  28229. * * q the number of windings around the x axis, optional, default 3
  28230. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28231. * * 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)
  28232. * * 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)
  28233. * @returns the VertexData of the Torus Knot
  28234. */
  28235. static CreateTorusKnot(options: {
  28236. radius?: number;
  28237. tube?: number;
  28238. radialSegments?: number;
  28239. tubularSegments?: number;
  28240. p?: number;
  28241. q?: number;
  28242. sideOrientation?: number;
  28243. frontUVs?: Vector4;
  28244. backUVs?: Vector4;
  28245. }): VertexData;
  28246. /**
  28247. * Compute normals for given positions and indices
  28248. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28249. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28250. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28251. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28252. * * facetNormals : optional array of facet normals (vector3)
  28253. * * facetPositions : optional array of facet positions (vector3)
  28254. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28255. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28256. * * bInfo : optional bounding info, required for facetPartitioning computation
  28257. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28258. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28259. * * useRightHandedSystem: optional boolean to for right handed system computation
  28260. * * depthSort : optional boolean to enable the facet depth sort computation
  28261. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28262. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28263. */
  28264. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28265. facetNormals?: any;
  28266. facetPositions?: any;
  28267. facetPartitioning?: any;
  28268. ratio?: number;
  28269. bInfo?: any;
  28270. bbSize?: Vector3;
  28271. subDiv?: any;
  28272. useRightHandedSystem?: boolean;
  28273. depthSort?: boolean;
  28274. distanceTo?: Vector3;
  28275. depthSortedFacets?: any;
  28276. }): void;
  28277. private static _ComputeSides;
  28278. /**
  28279. * Applies VertexData created from the imported parameters to the geometry
  28280. * @param parsedVertexData the parsed data from an imported file
  28281. * @param geometry the geometry to apply the VertexData to
  28282. */
  28283. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28284. }
  28285. }
  28286. declare module BABYLON {
  28287. /**
  28288. * Class containing static functions to help procedurally build meshes
  28289. */
  28290. class MeshBuilder {
  28291. private static _UpdateSideOrientation;
  28292. /**
  28293. * Creates a box mesh
  28294. * * The parameter `size` sets the size (float) of each box side (default 1)
  28295. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28296. * * 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)
  28297. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28299. * * 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
  28300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28301. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28302. * @param name defines the name of the mesh
  28303. * @param options defines the options used to create the mesh
  28304. * @param scene defines the hosting scene
  28305. * @returns the box mesh
  28306. */
  28307. static CreateBox(name: string, options: {
  28308. size?: number;
  28309. width?: number;
  28310. height?: number;
  28311. depth?: number;
  28312. faceUV?: Vector4[];
  28313. faceColors?: Color4[];
  28314. sideOrientation?: number;
  28315. frontUVs?: Vector4;
  28316. backUVs?: Vector4;
  28317. updatable?: boolean;
  28318. }, scene?: Nullable<Scene>): Mesh;
  28319. /**
  28320. * Creates a sphere mesh
  28321. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28322. * * 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`)
  28323. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28324. * * 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
  28325. * * 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)
  28326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28327. * * 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
  28328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28329. * @param name defines the name of the mesh
  28330. * @param options defines the options used to create the mesh
  28331. * @param scene defines the hosting scene
  28332. * @returns the sphere mesh
  28333. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28334. */
  28335. static CreateSphere(name: string, options: {
  28336. segments?: number;
  28337. diameter?: number;
  28338. diameterX?: number;
  28339. diameterY?: number;
  28340. diameterZ?: number;
  28341. arc?: number;
  28342. slice?: number;
  28343. sideOrientation?: number;
  28344. frontUVs?: Vector4;
  28345. backUVs?: Vector4;
  28346. updatable?: boolean;
  28347. }, scene: any): Mesh;
  28348. /**
  28349. * Creates a plane polygonal mesh. By default, this is a disc
  28350. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28351. * * 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
  28352. * * 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
  28353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28354. * * 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
  28355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28356. * @param name defines the name of the mesh
  28357. * @param options defines the options used to create the mesh
  28358. * @param scene defines the hosting scene
  28359. * @returns the plane polygonal mesh
  28360. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28361. */
  28362. static CreateDisc(name: string, options: {
  28363. radius?: number;
  28364. tessellation?: number;
  28365. arc?: number;
  28366. updatable?: boolean;
  28367. sideOrientation?: number;
  28368. frontUVs?: Vector4;
  28369. backUVs?: Vector4;
  28370. }, scene?: Nullable<Scene>): Mesh;
  28371. /**
  28372. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28373. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28374. * * 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`)
  28375. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28376. * * 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
  28377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28378. * * 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
  28379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28380. * @param name defines the name of the mesh
  28381. * @param options defines the options used to create the mesh
  28382. * @param scene defines the hosting scene
  28383. * @returns the icosahedron mesh
  28384. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28385. */
  28386. static CreateIcoSphere(name: string, options: {
  28387. radius?: number;
  28388. radiusX?: number;
  28389. radiusY?: number;
  28390. radiusZ?: number;
  28391. flat?: boolean;
  28392. subdivisions?: number;
  28393. sideOrientation?: number;
  28394. frontUVs?: Vector4;
  28395. backUVs?: Vector4;
  28396. updatable?: boolean;
  28397. }, scene: Scene): Mesh;
  28398. /**
  28399. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28400. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28401. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28402. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28403. * * 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
  28404. * * 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
  28405. * * 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
  28406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28407. * * 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
  28408. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28409. * * 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
  28410. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28411. * * 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
  28412. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28414. * @param name defines the name of the mesh
  28415. * @param options defines the options used to create the mesh
  28416. * @param scene defines the hosting scene
  28417. * @returns the ribbon mesh
  28418. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28420. */
  28421. static CreateRibbon(name: string, options: {
  28422. pathArray: Vector3[][];
  28423. closeArray?: boolean;
  28424. closePath?: boolean;
  28425. offset?: number;
  28426. updatable?: boolean;
  28427. sideOrientation?: number;
  28428. frontUVs?: Vector4;
  28429. backUVs?: Vector4;
  28430. instance?: Mesh;
  28431. invertUV?: boolean;
  28432. uvs?: Vector2[];
  28433. colors?: Color4[];
  28434. }, scene?: Nullable<Scene>): Mesh;
  28435. /**
  28436. * Creates a cylinder or a cone mesh
  28437. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28438. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28439. * * 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.
  28440. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28441. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28442. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28443. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28444. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28445. * * 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).
  28446. * * 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
  28447. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28448. * * 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
  28449. * * 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.
  28450. * * If `enclose` is false, a ring surface is one element.
  28451. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28452. * * 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
  28453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28454. * * 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
  28455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28456. * @param name defines the name of the mesh
  28457. * @param options defines the options used to create the mesh
  28458. * @param scene defines the hosting scene
  28459. * @returns the cylinder mesh
  28460. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28461. */
  28462. static CreateCylinder(name: string, options: {
  28463. height?: number;
  28464. diameterTop?: number;
  28465. diameterBottom?: number;
  28466. diameter?: number;
  28467. tessellation?: number;
  28468. subdivisions?: number;
  28469. arc?: number;
  28470. faceColors?: Color4[];
  28471. faceUV?: Vector4[];
  28472. updatable?: boolean;
  28473. hasRings?: boolean;
  28474. enclose?: boolean;
  28475. sideOrientation?: number;
  28476. frontUVs?: Vector4;
  28477. backUVs?: Vector4;
  28478. }, scene: any): Mesh;
  28479. /**
  28480. * Creates a torus mesh
  28481. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28482. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28483. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28485. * * 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
  28486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28487. * @param name defines the name of the mesh
  28488. * @param options defines the options used to create the mesh
  28489. * @param scene defines the hosting scene
  28490. * @returns the torus mesh
  28491. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28492. */
  28493. static CreateTorus(name: string, options: {
  28494. diameter?: number;
  28495. thickness?: number;
  28496. tessellation?: number;
  28497. updatable?: boolean;
  28498. sideOrientation?: number;
  28499. frontUVs?: Vector4;
  28500. backUVs?: Vector4;
  28501. }, scene: any): Mesh;
  28502. /**
  28503. * Creates a torus knot mesh
  28504. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28505. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28506. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28507. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28509. * * 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
  28510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28511. * @param name defines the name of the mesh
  28512. * @param options defines the options used to create the mesh
  28513. * @param scene defines the hosting scene
  28514. * @returns the torus knot mesh
  28515. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28516. */
  28517. static CreateTorusKnot(name: string, options: {
  28518. radius?: number;
  28519. tube?: number;
  28520. radialSegments?: number;
  28521. tubularSegments?: number;
  28522. p?: number;
  28523. q?: number;
  28524. updatable?: boolean;
  28525. sideOrientation?: number;
  28526. frontUVs?: Vector4;
  28527. backUVs?: Vector4;
  28528. }, scene: any): Mesh;
  28529. /**
  28530. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28531. * * 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
  28532. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28533. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28534. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28535. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28536. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28537. * * 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
  28538. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28541. * @param name defines the name of the new line system
  28542. * @param options defines the options used to create the line system
  28543. * @param scene defines the hosting scene
  28544. * @returns a new line system mesh
  28545. */
  28546. static CreateLineSystem(name: string, options: {
  28547. lines: Vector3[][];
  28548. updatable?: boolean;
  28549. instance?: Nullable<LinesMesh>;
  28550. colors?: Nullable<Color4[][]>;
  28551. useVertexAlpha?: boolean;
  28552. }, scene: Nullable<Scene>): LinesMesh;
  28553. /**
  28554. * Creates a line mesh
  28555. * 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
  28556. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28557. * * The parameter `points` is an array successive Vector3
  28558. * * 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
  28559. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28560. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28561. * * When updating an instance, remember that only point positions can change, not the number of points
  28562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28564. * @param name defines the name of the new line system
  28565. * @param options defines the options used to create the line system
  28566. * @param scene defines the hosting scene
  28567. * @returns a new line mesh
  28568. */
  28569. static CreateLines(name: string, options: {
  28570. points: Vector3[];
  28571. updatable?: boolean;
  28572. instance?: Nullable<LinesMesh>;
  28573. colors?: Color4[];
  28574. useVertexAlpha?: boolean;
  28575. }, scene?: Nullable<Scene>): LinesMesh;
  28576. /**
  28577. * Creates a dashed line mesh
  28578. * * 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
  28579. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28580. * * The parameter `points` is an array successive Vector3
  28581. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28582. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28583. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28584. * * 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
  28585. * * When updating an instance, remember that only point positions can change, not the number of points
  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 dashed line mesh
  28591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28592. */
  28593. static CreateDashedLines(name: string, options: {
  28594. points: Vector3[];
  28595. dashSize?: number;
  28596. gapSize?: number;
  28597. dashNb?: number;
  28598. updatable?: boolean;
  28599. instance?: LinesMesh;
  28600. }, scene?: Nullable<Scene>): LinesMesh;
  28601. /**
  28602. * 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.
  28603. * * 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.
  28604. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28605. * * 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.
  28606. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28607. * * 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
  28608. * * 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
  28609. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28611. * * 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
  28612. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28614. * @param name defines the name of the mesh
  28615. * @param options defines the options used to create the mesh
  28616. * @param scene defines the hosting scene
  28617. * @returns the extruded shape mesh
  28618. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28620. */
  28621. static ExtrudeShape(name: string, options: {
  28622. shape: Vector3[];
  28623. path: Vector3[];
  28624. scale?: number;
  28625. rotation?: number;
  28626. cap?: number;
  28627. updatable?: boolean;
  28628. sideOrientation?: number;
  28629. frontUVs?: Vector4;
  28630. backUVs?: Vector4;
  28631. instance?: Mesh;
  28632. invertUV?: boolean;
  28633. }, scene?: Nullable<Scene>): Mesh;
  28634. /**
  28635. * Creates an custom extruded shape mesh.
  28636. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28637. * * 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.
  28638. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28639. * * 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
  28640. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28641. * * 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
  28642. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28643. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28644. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28645. * * 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
  28646. * * 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
  28647. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28652. * @param name defines the name of the mesh
  28653. * @param options defines the options used to create the mesh
  28654. * @param scene defines the hosting scene
  28655. * @returns the custom extruded shape mesh
  28656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28657. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28659. */
  28660. static ExtrudeShapeCustom(name: string, options: {
  28661. shape: Vector3[];
  28662. path: Vector3[];
  28663. scaleFunction?: any;
  28664. rotationFunction?: any;
  28665. ribbonCloseArray?: boolean;
  28666. ribbonClosePath?: boolean;
  28667. cap?: number;
  28668. updatable?: boolean;
  28669. sideOrientation?: number;
  28670. frontUVs?: Vector4;
  28671. backUVs?: Vector4;
  28672. instance?: Mesh;
  28673. invertUV?: boolean;
  28674. }, scene: Scene): Mesh;
  28675. /**
  28676. * Creates lathe mesh.
  28677. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28678. * * 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
  28679. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28680. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28681. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28682. * * 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
  28683. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28684. * * 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
  28685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28686. * * 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
  28687. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28689. * @param name defines the name of the mesh
  28690. * @param options defines the options used to create the mesh
  28691. * @param scene defines the hosting scene
  28692. * @returns the lathe mesh
  28693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28694. */
  28695. static CreateLathe(name: string, options: {
  28696. shape: Vector3[];
  28697. radius?: number;
  28698. tessellation?: number;
  28699. clip?: number;
  28700. arc?: number;
  28701. closed?: boolean;
  28702. updatable?: boolean;
  28703. sideOrientation?: number;
  28704. frontUVs?: Vector4;
  28705. backUVs?: Vector4;
  28706. cap?: number;
  28707. invertUV?: boolean;
  28708. }, scene: Scene): Mesh;
  28709. /**
  28710. * Creates a plane mesh
  28711. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28712. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28713. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28715. * * 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
  28716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28717. * @param name defines the name of the mesh
  28718. * @param options defines the options used to create the mesh
  28719. * @param scene defines the hosting scene
  28720. * @returns the plane mesh
  28721. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28722. */
  28723. static CreatePlane(name: string, options: {
  28724. size?: number;
  28725. width?: number;
  28726. height?: number;
  28727. sideOrientation?: number;
  28728. frontUVs?: Vector4;
  28729. backUVs?: Vector4;
  28730. updatable?: boolean;
  28731. sourcePlane?: Plane;
  28732. }, scene: Scene): Mesh;
  28733. /**
  28734. * Creates a ground mesh
  28735. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28736. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28738. * @param name defines the name of the mesh
  28739. * @param options defines the options used to create the mesh
  28740. * @param scene defines the hosting scene
  28741. * @returns the ground mesh
  28742. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28743. */
  28744. static CreateGround(name: string, options: {
  28745. width?: number;
  28746. height?: number;
  28747. subdivisions?: number;
  28748. subdivisionsX?: number;
  28749. subdivisionsY?: number;
  28750. updatable?: boolean;
  28751. }, scene: any): Mesh;
  28752. /**
  28753. * Creates a tiled ground mesh
  28754. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28755. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28756. * * 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
  28757. * * 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
  28758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28759. * @param name defines the name of the mesh
  28760. * @param options defines the options used to create the mesh
  28761. * @param scene defines the hosting scene
  28762. * @returns the tiled ground mesh
  28763. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28764. */
  28765. static CreateTiledGround(name: string, options: {
  28766. xmin: number;
  28767. zmin: number;
  28768. xmax: number;
  28769. zmax: number;
  28770. subdivisions?: {
  28771. w: number;
  28772. h: number;
  28773. };
  28774. precision?: {
  28775. w: number;
  28776. h: number;
  28777. };
  28778. updatable?: boolean;
  28779. }, scene: Scene): Mesh;
  28780. /**
  28781. * Creates a ground mesh from a height map
  28782. * * The parameter `url` sets the URL of the height map image resource.
  28783. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28784. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28785. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28786. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28787. * * 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.
  28788. * * 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).
  28789. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28791. * @param name defines the name of the mesh
  28792. * @param url defines the url to the height map
  28793. * @param options defines the options used to create the mesh
  28794. * @param scene defines the hosting scene
  28795. * @returns the ground mesh
  28796. * @see https://doc.babylonjs.com/babylon101/height_map
  28797. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28798. */
  28799. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28800. width?: number;
  28801. height?: number;
  28802. subdivisions?: number;
  28803. minHeight?: number;
  28804. maxHeight?: number;
  28805. colorFilter?: Color3;
  28806. alphaFilter?: number;
  28807. updatable?: boolean;
  28808. onReady?: (mesh: GroundMesh) => void;
  28809. }, scene: Scene): GroundMesh;
  28810. /**
  28811. * Creates a polygon mesh
  28812. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28813. * * 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
  28814. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28816. * * 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)
  28817. * * Remember you can only change the shape positions, not their number when updating a polygon
  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 polygon mesh
  28822. */
  28823. static CreatePolygon(name: string, options: {
  28824. shape: Vector3[];
  28825. holes?: Vector3[][];
  28826. depth?: number;
  28827. faceUV?: Vector4[];
  28828. faceColors?: Color4[];
  28829. updatable?: boolean;
  28830. sideOrientation?: number;
  28831. frontUVs?: Vector4;
  28832. backUVs?: Vector4;
  28833. }, scene: Scene): Mesh;
  28834. /**
  28835. * Creates an extruded polygon mesh, with depth in the Y direction.
  28836. * * 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)
  28837. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28838. * @param name defines the name of the mesh
  28839. * @param options defines the options used to create the mesh
  28840. * @param scene defines the hosting scene
  28841. * @returns the polygon mesh
  28842. */
  28843. static ExtrudePolygon(name: string, options: {
  28844. shape: Vector3[];
  28845. holes?: Vector3[][];
  28846. depth?: number;
  28847. faceUV?: Vector4[];
  28848. faceColors?: Color4[];
  28849. updatable?: boolean;
  28850. sideOrientation?: number;
  28851. frontUVs?: Vector4;
  28852. backUVs?: Vector4;
  28853. }, scene: Scene): Mesh;
  28854. /**
  28855. * Creates a tube mesh.
  28856. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28857. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28858. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28859. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28860. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28861. * * 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)
  28862. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28863. * * 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
  28864. * * 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
  28865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28866. * * 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
  28867. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28869. * @param name defines the name of the mesh
  28870. * @param options defines the options used to create the mesh
  28871. * @param scene defines the hosting scene
  28872. * @returns the tube mesh
  28873. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28874. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28875. */
  28876. static CreateTube(name: string, options: {
  28877. path: Vector3[];
  28878. radius?: number;
  28879. tessellation?: number;
  28880. radiusFunction?: {
  28881. (i: number, distance: number): number;
  28882. };
  28883. cap?: number;
  28884. arc?: number;
  28885. updatable?: boolean;
  28886. sideOrientation?: number;
  28887. frontUVs?: Vector4;
  28888. backUVs?: Vector4;
  28889. instance?: Mesh;
  28890. invertUV?: boolean;
  28891. }, scene: Scene): Mesh;
  28892. /**
  28893. * Creates a polyhedron mesh
  28894. * * 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
  28895. * * The parameter `size` (positive float, default 1) sets the polygon size
  28896. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28897. * * 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`
  28898. * * 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
  28899. * * 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)`)
  28900. * * 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
  28901. * * 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
  28902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28903. * * 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
  28904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28905. * @param name defines the name of the mesh
  28906. * @param options defines the options used to create the mesh
  28907. * @param scene defines the hosting scene
  28908. * @returns the polyhedron mesh
  28909. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28910. */
  28911. static CreatePolyhedron(name: string, options: {
  28912. type?: number;
  28913. size?: number;
  28914. sizeX?: number;
  28915. sizeY?: number;
  28916. sizeZ?: number;
  28917. custom?: any;
  28918. faceUV?: Vector4[];
  28919. faceColors?: Color4[];
  28920. flat?: boolean;
  28921. updatable?: boolean;
  28922. sideOrientation?: number;
  28923. frontUVs?: Vector4;
  28924. backUVs?: Vector4;
  28925. }, scene: Scene): Mesh;
  28926. /**
  28927. * Creates a decal mesh.
  28928. * 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
  28929. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28930. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28931. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28932. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28933. * @param name defines the name of the mesh
  28934. * @param sourceMesh defines the mesh where the decal must be applied
  28935. * @param options defines the options used to create the mesh
  28936. * @param scene defines the hosting scene
  28937. * @returns the decal mesh
  28938. * @see https://doc.babylonjs.com/how_to/decals
  28939. */
  28940. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28941. position?: Vector3;
  28942. normal?: Vector3;
  28943. size?: Vector3;
  28944. angle?: number;
  28945. }): Mesh;
  28946. private static _ExtrudeShapeGeneric;
  28947. }
  28948. }
  28949. declare module BABYLON {
  28950. /**
  28951. * Class used to represent a specific level of detail of a mesh
  28952. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28953. */
  28954. class MeshLODLevel {
  28955. /** Defines the distance where this level should star being displayed */
  28956. distance: number;
  28957. /** Defines the mesh to use to render this level */
  28958. mesh: Nullable<Mesh>;
  28959. /**
  28960. * Creates a new LOD level
  28961. * @param distance defines the distance where this level should star being displayed
  28962. * @param mesh defines the mesh to use to render this level
  28963. */
  28964. constructor(
  28965. /** Defines the distance where this level should star being displayed */
  28966. distance: number,
  28967. /** Defines the mesh to use to render this level */
  28968. mesh: Nullable<Mesh>);
  28969. }
  28970. }
  28971. declare module BABYLON {
  28972. /**
  28973. * A simplifier interface for future simplification implementations
  28974. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28975. */
  28976. interface ISimplifier {
  28977. /**
  28978. * Simplification of a given mesh according to the given settings.
  28979. * Since this requires computation, it is assumed that the function runs async.
  28980. * @param settings The settings of the simplification, including quality and distance
  28981. * @param successCallback A callback that will be called after the mesh was simplified.
  28982. * @param errorCallback in case of an error, this callback will be called. optional.
  28983. */
  28984. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28985. }
  28986. /**
  28987. * Expected simplification settings.
  28988. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28990. */
  28991. interface ISimplificationSettings {
  28992. /**
  28993. * Gets or sets the expected quality
  28994. */
  28995. quality: number;
  28996. /**
  28997. * Gets or sets the distance when this optimized version should be used
  28998. */
  28999. distance: number;
  29000. /**
  29001. * Gets an already optimized mesh
  29002. */
  29003. optimizeMesh?: boolean;
  29004. }
  29005. /**
  29006. * Class used to specify simplification options
  29007. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29008. */
  29009. class SimplificationSettings implements ISimplificationSettings {
  29010. /** expected quality */
  29011. quality: number;
  29012. /** distance when this optimized version should be used */
  29013. distance: number;
  29014. /** already optimized mesh */
  29015. optimizeMesh?: boolean | undefined;
  29016. /**
  29017. * Creates a SimplificationSettings
  29018. * @param quality expected quality
  29019. * @param distance distance when this optimized version should be used
  29020. * @param optimizeMesh already optimized mesh
  29021. */
  29022. constructor(
  29023. /** expected quality */
  29024. quality: number,
  29025. /** distance when this optimized version should be used */
  29026. distance: number,
  29027. /** already optimized mesh */
  29028. optimizeMesh?: boolean | undefined);
  29029. }
  29030. /**
  29031. * Interface used to define a simplification task
  29032. */
  29033. interface ISimplificationTask {
  29034. /**
  29035. * Array of settings
  29036. */
  29037. settings: Array<ISimplificationSettings>;
  29038. /**
  29039. * Simplification type
  29040. */
  29041. simplificationType: SimplificationType;
  29042. /**
  29043. * Mesh to simplify
  29044. */
  29045. mesh: Mesh;
  29046. /**
  29047. * Callback called on success
  29048. */
  29049. successCallback?: () => void;
  29050. /**
  29051. * Defines if parallel processing can be used
  29052. */
  29053. parallelProcessing: boolean;
  29054. }
  29055. /**
  29056. * Queue used to order the simplification tasks
  29057. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29058. */
  29059. class SimplificationQueue {
  29060. private _simplificationArray;
  29061. /**
  29062. * Gets a boolean indicating that the process is still running
  29063. */
  29064. running: boolean;
  29065. /**
  29066. * Creates a new queue
  29067. */
  29068. constructor();
  29069. /**
  29070. * Adds a new simplification task
  29071. * @param task defines a task to add
  29072. */
  29073. addTask(task: ISimplificationTask): void;
  29074. /**
  29075. * Execute next task
  29076. */
  29077. executeNext(): void;
  29078. /**
  29079. * Execute a simplification task
  29080. * @param task defines the task to run
  29081. */
  29082. runSimplification(task: ISimplificationTask): void;
  29083. private getSimplifier;
  29084. }
  29085. /**
  29086. * The implemented types of simplification
  29087. * At the moment only Quadratic Error Decimation is implemented
  29088. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29089. */
  29090. enum SimplificationType {
  29091. /** Quadratic error decimation */
  29092. QUADRATIC = 0
  29093. }
  29094. }
  29095. declare module BABYLON {
  29096. interface Scene {
  29097. /** @hidden (Backing field) */
  29098. _simplificationQueue: SimplificationQueue;
  29099. /**
  29100. * Gets or sets the simplification queue attached to the scene
  29101. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29102. */
  29103. simplificationQueue: SimplificationQueue;
  29104. }
  29105. interface Mesh {
  29106. /**
  29107. * Simplify the mesh according to the given array of settings.
  29108. * Function will return immediately and will simplify async
  29109. * @param settings a collection of simplification settings
  29110. * @param parallelProcessing should all levels calculate parallel or one after the other
  29111. * @param simplificationType the type of simplification to run
  29112. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29113. * @returns the current mesh
  29114. */
  29115. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29116. }
  29117. /**
  29118. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29119. * created in a scene
  29120. */
  29121. class SimplicationQueueSceneComponent implements ISceneComponent {
  29122. /**
  29123. * The component name helpfull to identify the component in the list of scene components.
  29124. */
  29125. readonly name: string;
  29126. /**
  29127. * The scene the component belongs to.
  29128. */
  29129. scene: Scene;
  29130. /**
  29131. * Creates a new instance of the component for the given scene
  29132. * @param scene Defines the scene to register the component in
  29133. */
  29134. constructor(scene: Scene);
  29135. /**
  29136. * Registers the component in a given scene
  29137. */
  29138. register(): void;
  29139. /**
  29140. * Rebuilds the elements related to this component in case of
  29141. * context lost for instance.
  29142. */
  29143. rebuild(): void;
  29144. /**
  29145. * Disposes the component and the associated ressources
  29146. */
  29147. dispose(): void;
  29148. private _beforeCameraUpdate;
  29149. }
  29150. }
  29151. declare module BABYLON {
  29152. /**
  29153. * Polygon
  29154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29155. */
  29156. class Polygon {
  29157. /**
  29158. * Creates a rectangle
  29159. * @param xmin bottom X coord
  29160. * @param ymin bottom Y coord
  29161. * @param xmax top X coord
  29162. * @param ymax top Y coord
  29163. * @returns points that make the resulting rectation
  29164. */
  29165. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29166. /**
  29167. * Creates a circle
  29168. * @param radius radius of circle
  29169. * @param cx scale in x
  29170. * @param cy scale in y
  29171. * @param numberOfSides number of sides that make up the circle
  29172. * @returns points that make the resulting circle
  29173. */
  29174. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29175. /**
  29176. * Creates a polygon from input string
  29177. * @param input Input polygon data
  29178. * @returns the parsed points
  29179. */
  29180. static Parse(input: string): Vector2[];
  29181. /**
  29182. * Starts building a polygon from x and y coordinates
  29183. * @param x x coordinate
  29184. * @param y y coordinate
  29185. * @returns the started path2
  29186. */
  29187. static StartingAt(x: number, y: number): Path2;
  29188. }
  29189. /**
  29190. * Builds a polygon
  29191. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29192. */
  29193. class PolygonMeshBuilder {
  29194. private _points;
  29195. private _outlinepoints;
  29196. private _holes;
  29197. private _name;
  29198. private _scene;
  29199. private _epoints;
  29200. private _eholes;
  29201. private _addToepoint;
  29202. /**
  29203. * Creates a PolygonMeshBuilder
  29204. * @param name name of the builder
  29205. * @param contours Path of the polygon
  29206. * @param scene scene to add to
  29207. */
  29208. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29209. /**
  29210. * Adds a whole within the polygon
  29211. * @param hole Array of points defining the hole
  29212. * @returns this
  29213. */
  29214. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29215. /**
  29216. * Creates the polygon
  29217. * @param updatable If the mesh should be updatable
  29218. * @param depth The depth of the mesh created
  29219. * @returns the created mesh
  29220. */
  29221. build(updatable?: boolean, depth?: number): Mesh;
  29222. /**
  29223. * Adds a side to the polygon
  29224. * @param positions points that make the polygon
  29225. * @param normals normals of the polygon
  29226. * @param uvs uvs of the polygon
  29227. * @param indices indices of the polygon
  29228. * @param bounds bounds of the polygon
  29229. * @param points points of the polygon
  29230. * @param depth depth of the polygon
  29231. * @param flip flip of the polygon
  29232. */
  29233. private addSide;
  29234. }
  29235. }
  29236. declare module BABYLON {
  29237. /**
  29238. * Base class for submeshes
  29239. */
  29240. class BaseSubMesh {
  29241. /** @hidden */
  29242. _materialDefines: Nullable<MaterialDefines>;
  29243. /** @hidden */
  29244. _materialEffect: Nullable<Effect>;
  29245. /**
  29246. * Gets associated effect
  29247. */
  29248. readonly effect: Nullable<Effect>;
  29249. /**
  29250. * Sets associated effect (effect used to render this submesh)
  29251. * @param effect defines the effect to associate with
  29252. * @param defines defines the set of defines used to compile this effect
  29253. */
  29254. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29255. }
  29256. /**
  29257. * Defines a subdivision inside a mesh
  29258. */
  29259. class SubMesh extends BaseSubMesh implements ICullable {
  29260. /** the material index to use */
  29261. materialIndex: number;
  29262. /** vertex index start */
  29263. verticesStart: number;
  29264. /** vertices count */
  29265. verticesCount: number;
  29266. /** index start */
  29267. indexStart: number;
  29268. /** indices count */
  29269. indexCount: number;
  29270. /** @hidden */
  29271. _linesIndexCount: number;
  29272. private _mesh;
  29273. private _renderingMesh;
  29274. private _boundingInfo;
  29275. private _linesIndexBuffer;
  29276. /** @hidden */
  29277. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29278. /** @hidden */
  29279. _trianglePlanes: Plane[];
  29280. /** @hidden */
  29281. _lastColliderTransformMatrix: Matrix;
  29282. /** @hidden */
  29283. _renderId: number;
  29284. /** @hidden */
  29285. _alphaIndex: number;
  29286. /** @hidden */
  29287. _distanceToCamera: number;
  29288. /** @hidden */
  29289. _id: number;
  29290. private _currentMaterial;
  29291. /**
  29292. * Add a new submesh to a mesh
  29293. * @param materialIndex defines the material index to use
  29294. * @param verticesStart defines vertex index start
  29295. * @param verticesCount defines vertices count
  29296. * @param indexStart defines index start
  29297. * @param indexCount defines indices count
  29298. * @param mesh defines the parent mesh
  29299. * @param renderingMesh defines an optional rendering mesh
  29300. * @param createBoundingBox defines if bounding box should be created for this submesh
  29301. * @returns the new submesh
  29302. */
  29303. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29304. /**
  29305. * Creates a new submesh
  29306. * @param materialIndex defines the material index to use
  29307. * @param verticesStart defines vertex index start
  29308. * @param verticesCount defines vertices count
  29309. * @param indexStart defines index start
  29310. * @param indexCount defines indices count
  29311. * @param mesh defines the parent mesh
  29312. * @param renderingMesh defines an optional rendering mesh
  29313. * @param createBoundingBox defines if bounding box should be created for this submesh
  29314. */
  29315. constructor(
  29316. /** the material index to use */
  29317. materialIndex: number,
  29318. /** vertex index start */
  29319. verticesStart: number,
  29320. /** vertices count */
  29321. verticesCount: number,
  29322. /** index start */
  29323. indexStart: number,
  29324. /** indices count */
  29325. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29326. /**
  29327. * Returns true if this submesh covers the entire parent mesh
  29328. * @ignorenaming
  29329. */
  29330. readonly IsGlobal: boolean;
  29331. /**
  29332. * Returns the submesh BoudingInfo object
  29333. * @returns current bounding info (or mesh's one if the submesh is global)
  29334. */
  29335. getBoundingInfo(): BoundingInfo;
  29336. /**
  29337. * Sets the submesh BoundingInfo
  29338. * @param boundingInfo defines the new bounding info to use
  29339. * @returns the SubMesh
  29340. */
  29341. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29342. /**
  29343. * Returns the mesh of the current submesh
  29344. * @return the parent mesh
  29345. */
  29346. getMesh(): AbstractMesh;
  29347. /**
  29348. * Returns the rendering mesh of the submesh
  29349. * @returns the rendering mesh (could be different from parent mesh)
  29350. */
  29351. getRenderingMesh(): Mesh;
  29352. /**
  29353. * Returns the submesh material
  29354. * @returns null or the current material
  29355. */
  29356. getMaterial(): Nullable<Material>;
  29357. /**
  29358. * Sets a new updated BoundingInfo object to the submesh
  29359. * @returns the SubMesh
  29360. */
  29361. refreshBoundingInfo(): SubMesh;
  29362. /** @hidden */
  29363. _checkCollision(collider: Collider): boolean;
  29364. /**
  29365. * Updates the submesh BoundingInfo
  29366. * @param world defines the world matrix to use to update the bounding info
  29367. * @returns the submesh
  29368. */
  29369. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29370. /**
  29371. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29372. * @param frustumPlanes defines the frustum planes
  29373. * @returns true if the submesh is intersecting with the frustum
  29374. */
  29375. isInFrustum(frustumPlanes: Plane[]): boolean;
  29376. /**
  29377. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29378. * @param frustumPlanes defines the frustum planes
  29379. * @returns true if the submesh is inside the frustum
  29380. */
  29381. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29382. /**
  29383. * Renders the submesh
  29384. * @param enableAlphaMode defines if alpha needs to be used
  29385. * @returns the submesh
  29386. */
  29387. render(enableAlphaMode: boolean): SubMesh;
  29388. /**
  29389. * @hidden
  29390. */
  29391. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29392. /**
  29393. * Checks if the submesh intersects with a ray
  29394. * @param ray defines the ray to test
  29395. * @returns true is the passed ray intersects the submesh bounding box
  29396. */
  29397. canIntersects(ray: Ray): boolean;
  29398. /**
  29399. * Intersects current submesh with a ray
  29400. * @param ray defines the ray to test
  29401. * @param positions defines mesh's positions array
  29402. * @param indices defines mesh's indices array
  29403. * @param fastCheck defines if only bounding info should be used
  29404. * @returns intersection info or null if no intersection
  29405. */
  29406. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29407. /** @hidden */
  29408. private _intersectLines;
  29409. /** @hidden */
  29410. private _intersectTriangles;
  29411. /** @hidden */
  29412. _rebuild(): void;
  29413. /**
  29414. * Creates a new submesh from the passed mesh
  29415. * @param newMesh defines the new hosting mesh
  29416. * @param newRenderingMesh defines an optional rendering mesh
  29417. * @returns the new submesh
  29418. */
  29419. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29420. /**
  29421. * Release associated resources
  29422. */
  29423. dispose(): void;
  29424. /**
  29425. * Creates a new submesh from indices data
  29426. * @param materialIndex the index of the main mesh material
  29427. * @param startIndex the index where to start the copy in the mesh indices array
  29428. * @param indexCount the number of indices to copy then from the startIndex
  29429. * @param mesh the main mesh to create the submesh from
  29430. * @param renderingMesh the optional rendering mesh
  29431. * @returns a new submesh
  29432. */
  29433. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29434. }
  29435. }
  29436. declare module BABYLON {
  29437. /**
  29438. * 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.
  29439. * @see https://doc.babylonjs.com/how_to/transformnode
  29440. */
  29441. class TransformNode extends Node {
  29442. /**
  29443. * Object will not rotate to face the camera
  29444. */
  29445. static BILLBOARDMODE_NONE: number;
  29446. /**
  29447. * Object will rotate to face the camera but only on the x axis
  29448. */
  29449. static BILLBOARDMODE_X: number;
  29450. /**
  29451. * Object will rotate to face the camera but only on the y axis
  29452. */
  29453. static BILLBOARDMODE_Y: number;
  29454. /**
  29455. * Object will rotate to face the camera but only on the z axis
  29456. */
  29457. static BILLBOARDMODE_Z: number;
  29458. /**
  29459. * Object will rotate to face the camera
  29460. */
  29461. static BILLBOARDMODE_ALL: number;
  29462. private _forward;
  29463. private _forwardInverted;
  29464. private _up;
  29465. private _right;
  29466. private _rightInverted;
  29467. private _position;
  29468. private _rotation;
  29469. private _rotationQuaternion;
  29470. protected _scaling: Vector3;
  29471. protected _isDirty: boolean;
  29472. private _transformToBoneReferal;
  29473. /**
  29474. * Set the billboard mode. Default is 0.
  29475. *
  29476. * | Value | Type | Description |
  29477. * | --- | --- | --- |
  29478. * | 0 | BILLBOARDMODE_NONE | |
  29479. * | 1 | BILLBOARDMODE_X | |
  29480. * | 2 | BILLBOARDMODE_Y | |
  29481. * | 4 | BILLBOARDMODE_Z | |
  29482. * | 7 | BILLBOARDMODE_ALL | |
  29483. *
  29484. */
  29485. billboardMode: number;
  29486. /**
  29487. * 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
  29488. */
  29489. scalingDeterminant: number;
  29490. /**
  29491. * Sets the distance of the object to max, often used by skybox
  29492. */
  29493. infiniteDistance: boolean;
  29494. /**
  29495. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29496. * By default the system will update normals to compensate
  29497. */
  29498. ignoreNonUniformScaling: boolean;
  29499. /** @hidden */
  29500. _poseMatrix: Matrix;
  29501. /** @hidden */
  29502. _localMatrix: Matrix;
  29503. private _absolutePosition;
  29504. private _pivotMatrix;
  29505. private _pivotMatrixInverse;
  29506. protected _postMultiplyPivotMatrix: boolean;
  29507. protected _isWorldMatrixFrozen: boolean;
  29508. /** @hidden */
  29509. _indexInSceneTransformNodesArray: number;
  29510. /**
  29511. * An event triggered after the world matrix is updated
  29512. */
  29513. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29514. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29515. /**
  29516. * Gets a string identifying the name of the class
  29517. * @returns "TransformNode" string
  29518. */
  29519. getClassName(): string;
  29520. /**
  29521. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29522. */
  29523. position: Vector3;
  29524. /**
  29525. * 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)).
  29526. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29527. */
  29528. rotation: Vector3;
  29529. /**
  29530. * 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)).
  29531. */
  29532. scaling: Vector3;
  29533. /**
  29534. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29535. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29536. */
  29537. rotationQuaternion: Nullable<Quaternion>;
  29538. /**
  29539. * The forward direction of that transform in world space.
  29540. */
  29541. readonly forward: Vector3;
  29542. /**
  29543. * The up direction of that transform in world space.
  29544. */
  29545. readonly up: Vector3;
  29546. /**
  29547. * The right direction of that transform in world space.
  29548. */
  29549. readonly right: Vector3;
  29550. /**
  29551. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29552. * @param matrix the matrix to copy the pose from
  29553. * @returns this TransformNode.
  29554. */
  29555. updatePoseMatrix(matrix: Matrix): TransformNode;
  29556. /**
  29557. * Returns the mesh Pose matrix.
  29558. * @returns the pose matrix
  29559. */
  29560. getPoseMatrix(): Matrix;
  29561. /** @hidden */
  29562. _isSynchronized(): boolean;
  29563. /** @hidden */
  29564. _initCache(): void;
  29565. /**
  29566. * Flag the transform node as dirty (Forcing it to update everything)
  29567. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29568. * @returns this transform node
  29569. */
  29570. markAsDirty(property: string): TransformNode;
  29571. /**
  29572. * Returns the current mesh absolute position.
  29573. * Returns a Vector3.
  29574. */
  29575. readonly absolutePosition: Vector3;
  29576. /**
  29577. * Sets a new matrix to apply before all other transformation
  29578. * @param matrix defines the transform matrix
  29579. * @returns the current TransformNode
  29580. */
  29581. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29582. /**
  29583. * Sets a new pivot matrix to the current node
  29584. * @param matrix defines the new pivot matrix to use
  29585. * @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
  29586. * @returns the current TransformNode
  29587. */
  29588. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29589. /**
  29590. * Returns the mesh pivot matrix.
  29591. * Default : Identity.
  29592. * @returns the matrix
  29593. */
  29594. getPivotMatrix(): Matrix;
  29595. /**
  29596. * Prevents the World matrix to be computed any longer.
  29597. * @returns the TransformNode.
  29598. */
  29599. freezeWorldMatrix(): TransformNode;
  29600. /**
  29601. * Allows back the World matrix computation.
  29602. * @returns the TransformNode.
  29603. */
  29604. unfreezeWorldMatrix(): this;
  29605. /**
  29606. * True if the World matrix has been frozen.
  29607. */
  29608. readonly isWorldMatrixFrozen: boolean;
  29609. /**
  29610. * Retuns the mesh absolute position in the World.
  29611. * @returns a Vector3.
  29612. */
  29613. getAbsolutePosition(): Vector3;
  29614. /**
  29615. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29616. * @param absolutePosition the absolute position to set
  29617. * @returns the TransformNode.
  29618. */
  29619. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29620. /**
  29621. * Sets the mesh position in its local space.
  29622. * @param vector3 the position to set in localspace
  29623. * @returns the TransformNode.
  29624. */
  29625. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29626. /**
  29627. * Returns the mesh position in the local space from the current World matrix values.
  29628. * @returns a new Vector3.
  29629. */
  29630. getPositionExpressedInLocalSpace(): Vector3;
  29631. /**
  29632. * Translates the mesh along the passed Vector3 in its local space.
  29633. * @param vector3 the distance to translate in localspace
  29634. * @returns the TransformNode.
  29635. */
  29636. locallyTranslate(vector3: Vector3): TransformNode;
  29637. private static _lookAtVectorCache;
  29638. /**
  29639. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29640. * @param targetPoint the position (must be in same space as current mesh) to look at
  29641. * @param yawCor optional yaw (y-axis) correction in radians
  29642. * @param pitchCor optional pitch (x-axis) correction in radians
  29643. * @param rollCor optional roll (z-axis) correction in radians
  29644. * @param space the choosen space of the target
  29645. * @returns the TransformNode.
  29646. */
  29647. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29648. /**
  29649. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29650. * This Vector3 is expressed in the World space.
  29651. * @param localAxis axis to rotate
  29652. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29653. */
  29654. getDirection(localAxis: Vector3): Vector3;
  29655. /**
  29656. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29657. * localAxis is expressed in the mesh local space.
  29658. * result is computed in the Wordl space from the mesh World matrix.
  29659. * @param localAxis axis to rotate
  29660. * @param result the resulting transformnode
  29661. * @returns this TransformNode.
  29662. */
  29663. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29664. /**
  29665. * Sets this transform node rotation to the given local axis.
  29666. * @param localAxis the axis in local space
  29667. * @param yawCor optional yaw (y-axis) correction in radians
  29668. * @param pitchCor optional pitch (x-axis) correction in radians
  29669. * @param rollCor optional roll (z-axis) correction in radians
  29670. * @returns this TransformNode
  29671. */
  29672. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29673. /**
  29674. * Sets a new pivot point to the current node
  29675. * @param point defines the new pivot point to use
  29676. * @param space defines if the point is in world or local space (local by default)
  29677. * @returns the current TransformNode
  29678. */
  29679. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29680. /**
  29681. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29682. * @returns the pivot point
  29683. */
  29684. getPivotPoint(): Vector3;
  29685. /**
  29686. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29687. * @param result the vector3 to store the result
  29688. * @returns this TransformNode.
  29689. */
  29690. getPivotPointToRef(result: Vector3): TransformNode;
  29691. /**
  29692. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29693. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29694. */
  29695. getAbsolutePivotPoint(): Vector3;
  29696. /**
  29697. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29698. * @param result vector3 to store the result
  29699. * @returns this TransformNode.
  29700. */
  29701. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29702. /**
  29703. * Defines the passed node as the parent of the current node.
  29704. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29705. * @param node the node ot set as the parent
  29706. * @returns this TransformNode.
  29707. */
  29708. setParent(node: Nullable<Node>): TransformNode;
  29709. private _nonUniformScaling;
  29710. /**
  29711. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29712. */
  29713. readonly nonUniformScaling: boolean;
  29714. /** @hidden */
  29715. _updateNonUniformScalingState(value: boolean): boolean;
  29716. /**
  29717. * Attach the current TransformNode to another TransformNode associated with a bone
  29718. * @param bone Bone affecting the TransformNode
  29719. * @param affectedTransformNode TransformNode associated with the bone
  29720. * @returns this object
  29721. */
  29722. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29723. /**
  29724. * Detach the transform node if its associated with a bone
  29725. * @returns this object
  29726. */
  29727. detachFromBone(): TransformNode;
  29728. private static _rotationAxisCache;
  29729. /**
  29730. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29731. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29732. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29733. * The passed axis is also normalized.
  29734. * @param axis the axis to rotate around
  29735. * @param amount the amount to rotate in radians
  29736. * @param space Space to rotate in (Default: local)
  29737. * @returns the TransformNode.
  29738. */
  29739. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29740. /**
  29741. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29742. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29743. * The passed axis is also normalized. .
  29744. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29745. * @param point the point to rotate around
  29746. * @param axis the axis to rotate around
  29747. * @param amount the amount to rotate in radians
  29748. * @returns the TransformNode
  29749. */
  29750. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29751. /**
  29752. * Translates the mesh along the axis vector for the passed distance in the given space.
  29753. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29754. * @param axis the axis to translate in
  29755. * @param distance the distance to translate
  29756. * @param space Space to rotate in (Default: local)
  29757. * @returns the TransformNode.
  29758. */
  29759. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29760. /**
  29761. * Adds a rotation step to the mesh current rotation.
  29762. * x, y, z are Euler angles expressed in radians.
  29763. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29764. * This means this rotation is made in the mesh local space only.
  29765. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29766. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29767. * ```javascript
  29768. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29769. * ```
  29770. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29771. * 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.
  29772. * @param x Rotation to add
  29773. * @param y Rotation to add
  29774. * @param z Rotation to add
  29775. * @returns the TransformNode.
  29776. */
  29777. addRotation(x: number, y: number, z: number): TransformNode;
  29778. /**
  29779. * Computes the world matrix of the node
  29780. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29781. * @returns the world matrix
  29782. */
  29783. computeWorldMatrix(force?: boolean): Matrix;
  29784. protected _afterComputeWorldMatrix(): void;
  29785. /**
  29786. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29787. * @param func callback function to add
  29788. *
  29789. * @returns the TransformNode.
  29790. */
  29791. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29792. /**
  29793. * Removes a registered callback function.
  29794. * @param func callback function to remove
  29795. * @returns the TransformNode.
  29796. */
  29797. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29798. /**
  29799. * Gets the position of the current mesh in camera space
  29800. * @param camera defines the camera to use
  29801. * @returns a position
  29802. */
  29803. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29804. /**
  29805. * Returns the distance from the mesh to the active camera
  29806. * @param camera defines the camera to use
  29807. * @returns the distance
  29808. */
  29809. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29810. /**
  29811. * Clone the current transform node
  29812. * @param name Name of the new clone
  29813. * @param newParent New parent for the clone
  29814. * @param doNotCloneChildren Do not clone children hierarchy
  29815. * @returns the new transform node
  29816. */
  29817. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29818. /**
  29819. * Serializes the objects information.
  29820. * @param currentSerializationObject defines the object to serialize in
  29821. * @returns the serialized object
  29822. */
  29823. serialize(currentSerializationObject?: any): any;
  29824. /**
  29825. * Returns a new TransformNode object parsed from the source provided.
  29826. * @param parsedTransformNode is the source.
  29827. * @param scene the scne the object belongs to
  29828. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29829. * @returns a new TransformNode object parsed from the source provided.
  29830. */
  29831. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29832. /**
  29833. * Releases resources associated with this transform node.
  29834. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29835. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29836. */
  29837. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29838. }
  29839. }
  29840. declare module BABYLON {
  29841. /**
  29842. * Specialized buffer used to store vertex data
  29843. */
  29844. class VertexBuffer {
  29845. /** @hidden */
  29846. _buffer: Buffer;
  29847. private _kind;
  29848. private _size;
  29849. private _ownsBuffer;
  29850. private _instanced;
  29851. private _instanceDivisor;
  29852. /**
  29853. * The byte type.
  29854. */
  29855. static readonly BYTE: number;
  29856. /**
  29857. * The unsigned byte type.
  29858. */
  29859. static readonly UNSIGNED_BYTE: number;
  29860. /**
  29861. * The short type.
  29862. */
  29863. static readonly SHORT: number;
  29864. /**
  29865. * The unsigned short type.
  29866. */
  29867. static readonly UNSIGNED_SHORT: number;
  29868. /**
  29869. * The integer type.
  29870. */
  29871. static readonly INT: number;
  29872. /**
  29873. * The unsigned integer type.
  29874. */
  29875. static readonly UNSIGNED_INT: number;
  29876. /**
  29877. * The float type.
  29878. */
  29879. static readonly FLOAT: number;
  29880. /**
  29881. * Gets or sets the instance divisor when in instanced mode
  29882. */
  29883. instanceDivisor: number;
  29884. /**
  29885. * Gets the byte stride.
  29886. */
  29887. readonly byteStride: number;
  29888. /**
  29889. * Gets the byte offset.
  29890. */
  29891. readonly byteOffset: number;
  29892. /**
  29893. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29894. */
  29895. readonly normalized: boolean;
  29896. /**
  29897. * Gets the data type of each component in the array.
  29898. */
  29899. readonly type: number;
  29900. /**
  29901. * Constructor
  29902. * @param engine the engine
  29903. * @param data the data to use for this vertex buffer
  29904. * @param kind the vertex buffer kind
  29905. * @param updatable whether the data is updatable
  29906. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29907. * @param stride the stride (optional)
  29908. * @param instanced whether the buffer is instanced (optional)
  29909. * @param offset the offset of the data (optional)
  29910. * @param size the number of components (optional)
  29911. * @param type the type of the component (optional)
  29912. * @param normalized whether the data contains normalized data (optional)
  29913. * @param useBytes set to true if stride and offset are in bytes (optional)
  29914. */
  29915. 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);
  29916. /** @hidden */
  29917. _rebuild(): void;
  29918. /**
  29919. * Returns the kind of the VertexBuffer (string)
  29920. * @returns a string
  29921. */
  29922. getKind(): string;
  29923. /**
  29924. * Gets a boolean indicating if the VertexBuffer is updatable?
  29925. * @returns true if the buffer is updatable
  29926. */
  29927. isUpdatable(): boolean;
  29928. /**
  29929. * Gets current buffer's data
  29930. * @returns a DataArray or null
  29931. */
  29932. getData(): Nullable<DataArray>;
  29933. /**
  29934. * Gets underlying native buffer
  29935. * @returns underlying native buffer
  29936. */
  29937. getBuffer(): Nullable<WebGLBuffer>;
  29938. /**
  29939. * Gets the stride in float32 units (i.e. byte stride / 4).
  29940. * May not be an integer if the byte stride is not divisible by 4.
  29941. * DEPRECATED. Use byteStride instead.
  29942. * @returns the stride in float32 units
  29943. */
  29944. getStrideSize(): number;
  29945. /**
  29946. * Returns the offset as a multiple of the type byte length.
  29947. * DEPRECATED. Use byteOffset instead.
  29948. * @returns the offset in bytes
  29949. */
  29950. getOffset(): number;
  29951. /**
  29952. * Returns the number of components per vertex attribute (integer)
  29953. * @returns the size in float
  29954. */
  29955. getSize(): number;
  29956. /**
  29957. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29958. * @returns true if this buffer is instanced
  29959. */
  29960. getIsInstanced(): boolean;
  29961. /**
  29962. * Returns the instancing divisor, zero for non-instanced (integer).
  29963. * @returns a number
  29964. */
  29965. getInstanceDivisor(): number;
  29966. /**
  29967. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29968. * @param data defines the data to store
  29969. */
  29970. create(data?: DataArray): void;
  29971. /**
  29972. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29973. * This function will create a new buffer if the current one is not updatable
  29974. * @param data defines the data to store
  29975. */
  29976. update(data: DataArray): void;
  29977. /**
  29978. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29979. * Returns the directly updated WebGLBuffer.
  29980. * @param data the new data
  29981. * @param offset the new offset
  29982. * @param useBytes set to true if the offset is in bytes
  29983. */
  29984. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29985. /**
  29986. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29987. */
  29988. dispose(): void;
  29989. /**
  29990. * Enumerates each value of this vertex buffer as numbers.
  29991. * @param count the number of values to enumerate
  29992. * @param callback the callback function called for each value
  29993. */
  29994. forEach(count: number, callback: (value: number, index: number) => void): void;
  29995. /**
  29996. * Positions
  29997. */
  29998. static readonly PositionKind: string;
  29999. /**
  30000. * Normals
  30001. */
  30002. static readonly NormalKind: string;
  30003. /**
  30004. * Tangents
  30005. */
  30006. static readonly TangentKind: string;
  30007. /**
  30008. * Texture coordinates
  30009. */
  30010. static readonly UVKind: string;
  30011. /**
  30012. * Texture coordinates 2
  30013. */
  30014. static readonly UV2Kind: string;
  30015. /**
  30016. * Texture coordinates 3
  30017. */
  30018. static readonly UV3Kind: string;
  30019. /**
  30020. * Texture coordinates 4
  30021. */
  30022. static readonly UV4Kind: string;
  30023. /**
  30024. * Texture coordinates 5
  30025. */
  30026. static readonly UV5Kind: string;
  30027. /**
  30028. * Texture coordinates 6
  30029. */
  30030. static readonly UV6Kind: string;
  30031. /**
  30032. * Colors
  30033. */
  30034. static readonly ColorKind: string;
  30035. /**
  30036. * Matrix indices (for bones)
  30037. */
  30038. static readonly MatricesIndicesKind: string;
  30039. /**
  30040. * Matrix weights (for bones)
  30041. */
  30042. static readonly MatricesWeightsKind: string;
  30043. /**
  30044. * Additional matrix indices (for bones)
  30045. */
  30046. static readonly MatricesIndicesExtraKind: string;
  30047. /**
  30048. * Additional matrix weights (for bones)
  30049. */
  30050. static readonly MatricesWeightsExtraKind: string;
  30051. /**
  30052. * Deduces the stride given a kind.
  30053. * @param kind The kind string to deduce
  30054. * @returns The deduced stride
  30055. */
  30056. static DeduceStride(kind: string): number;
  30057. /**
  30058. * Gets the byte length of the given type.
  30059. * @param type the type
  30060. * @returns the number of bytes
  30061. */
  30062. static GetTypeByteLength(type: number): number;
  30063. /**
  30064. * Enumerates each value of the given parameters as numbers.
  30065. * @param data the data to enumerate
  30066. * @param byteOffset the byte offset of the data
  30067. * @param byteStride the byte stride of the data
  30068. * @param componentCount the number of components per element
  30069. * @param componentType the type of the component
  30070. * @param count the total number of components
  30071. * @param normalized whether the data is normalized
  30072. * @param callback the callback function called for each value
  30073. */
  30074. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30075. private static _GetFloatValue;
  30076. }
  30077. }
  30078. declare module BABYLON {
  30079. /**
  30080. * Defines a target to use with MorphTargetManager
  30081. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30082. */
  30083. class MorphTarget implements IAnimatable {
  30084. /** defines the name of the target */
  30085. name: string;
  30086. /**
  30087. * Gets or sets the list of animations
  30088. */
  30089. animations: Animation[];
  30090. private _scene;
  30091. private _positions;
  30092. private _normals;
  30093. private _tangents;
  30094. private _influence;
  30095. /**
  30096. * Observable raised when the influence changes
  30097. */
  30098. onInfluenceChanged: Observable<boolean>;
  30099. /** @hidden */
  30100. _onDataLayoutChanged: Observable<void>;
  30101. /**
  30102. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30103. */
  30104. influence: number;
  30105. /**
  30106. * Gets or sets the id of the morph Target
  30107. */
  30108. id: string;
  30109. private _animationPropertiesOverride;
  30110. /**
  30111. * Gets or sets the animation properties override
  30112. */
  30113. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30114. /**
  30115. * Creates a new MorphTarget
  30116. * @param name defines the name of the target
  30117. * @param influence defines the influence to use
  30118. */
  30119. constructor(
  30120. /** defines the name of the target */
  30121. name: string, influence?: number, scene?: Nullable<Scene>);
  30122. /**
  30123. * Gets a boolean defining if the target contains position data
  30124. */
  30125. readonly hasPositions: boolean;
  30126. /**
  30127. * Gets a boolean defining if the target contains normal data
  30128. */
  30129. readonly hasNormals: boolean;
  30130. /**
  30131. * Gets a boolean defining if the target contains tangent data
  30132. */
  30133. readonly hasTangents: boolean;
  30134. /**
  30135. * Affects position data to this target
  30136. * @param data defines the position data to use
  30137. */
  30138. setPositions(data: Nullable<FloatArray>): void;
  30139. /**
  30140. * Gets the position data stored in this target
  30141. * @returns a FloatArray containing the position data (or null if not present)
  30142. */
  30143. getPositions(): Nullable<FloatArray>;
  30144. /**
  30145. * Affects normal data to this target
  30146. * @param data defines the normal data to use
  30147. */
  30148. setNormals(data: Nullable<FloatArray>): void;
  30149. /**
  30150. * Gets the normal data stored in this target
  30151. * @returns a FloatArray containing the normal data (or null if not present)
  30152. */
  30153. getNormals(): Nullable<FloatArray>;
  30154. /**
  30155. * Affects tangent data to this target
  30156. * @param data defines the tangent data to use
  30157. */
  30158. setTangents(data: Nullable<FloatArray>): void;
  30159. /**
  30160. * Gets the tangent data stored in this target
  30161. * @returns a FloatArray containing the tangent data (or null if not present)
  30162. */
  30163. getTangents(): Nullable<FloatArray>;
  30164. /**
  30165. * Serializes the current target into a Serialization object
  30166. * @returns the serialized object
  30167. */
  30168. serialize(): any;
  30169. /**
  30170. * Returns the string "MorphTarget"
  30171. * @returns "MorphTarget"
  30172. */
  30173. getClassName(): string;
  30174. /**
  30175. * Creates a new target from serialized data
  30176. * @param serializationObject defines the serialized data to use
  30177. * @returns a new MorphTarget
  30178. */
  30179. static Parse(serializationObject: any): MorphTarget;
  30180. /**
  30181. * Creates a MorphTarget from mesh data
  30182. * @param mesh defines the source mesh
  30183. * @param name defines the name to use for the new target
  30184. * @param influence defines the influence to attach to the target
  30185. * @returns a new MorphTarget
  30186. */
  30187. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30188. }
  30189. }
  30190. declare module BABYLON {
  30191. /**
  30192. * This class is used to deform meshes using morphing between different targets
  30193. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30194. */
  30195. class MorphTargetManager {
  30196. private _targets;
  30197. private _targetInfluenceChangedObservers;
  30198. private _targetDataLayoutChangedObservers;
  30199. private _activeTargets;
  30200. private _scene;
  30201. private _influences;
  30202. private _supportsNormals;
  30203. private _supportsTangents;
  30204. private _vertexCount;
  30205. private _uniqueId;
  30206. private _tempInfluences;
  30207. /**
  30208. * Creates a new MorphTargetManager
  30209. * @param scene defines the current scene
  30210. */
  30211. constructor(scene?: Nullable<Scene>);
  30212. /**
  30213. * Gets the unique ID of this manager
  30214. */
  30215. readonly uniqueId: number;
  30216. /**
  30217. * Gets the number of vertices handled by this manager
  30218. */
  30219. readonly vertexCount: number;
  30220. /**
  30221. * Gets a boolean indicating if this manager supports morphing of normals
  30222. */
  30223. readonly supportsNormals: boolean;
  30224. /**
  30225. * Gets a boolean indicating if this manager supports morphing of tangents
  30226. */
  30227. readonly supportsTangents: boolean;
  30228. /**
  30229. * Gets the number of targets stored in this manager
  30230. */
  30231. readonly numTargets: number;
  30232. /**
  30233. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30234. */
  30235. readonly numInfluencers: number;
  30236. /**
  30237. * Gets the list of influences (one per target)
  30238. */
  30239. readonly influences: Float32Array;
  30240. /**
  30241. * Gets the active target at specified index. An active target is a target with an influence > 0
  30242. * @param index defines the index to check
  30243. * @returns the requested target
  30244. */
  30245. getActiveTarget(index: number): MorphTarget;
  30246. /**
  30247. * Gets the target at specified index
  30248. * @param index defines the index to check
  30249. * @returns the requested target
  30250. */
  30251. getTarget(index: number): MorphTarget;
  30252. /**
  30253. * Add a new target to this manager
  30254. * @param target defines the target to add
  30255. */
  30256. addTarget(target: MorphTarget): void;
  30257. /**
  30258. * Removes a target from the manager
  30259. * @param target defines the target to remove
  30260. */
  30261. removeTarget(target: MorphTarget): void;
  30262. /**
  30263. * Serializes the current manager into a Serialization object
  30264. * @returns the serialized object
  30265. */
  30266. serialize(): any;
  30267. private _syncActiveTargets;
  30268. /**
  30269. * Syncrhonize the targets with all the meshes using this morph target manager
  30270. */
  30271. synchronize(): void;
  30272. /**
  30273. * Creates a new MorphTargetManager from serialized data
  30274. * @param serializationObject defines the serialized data
  30275. * @param scene defines the hosting scene
  30276. * @returns the new MorphTargetManager
  30277. */
  30278. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30279. }
  30280. }
  30281. declare module BABYLON {
  30282. /**
  30283. * Class used to enable access to IndexedDB
  30284. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30285. */
  30286. class Database implements IOfflineProvider {
  30287. private _callbackManifestChecked;
  30288. private _currentSceneUrl;
  30289. private _db;
  30290. private _enableSceneOffline;
  30291. private _enableTexturesOffline;
  30292. private _manifestVersionFound;
  30293. private _mustUpdateRessources;
  30294. private _hasReachedQuota;
  30295. private _isSupported;
  30296. private _idbFactory;
  30297. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30298. private static IsUASupportingBlobStorage;
  30299. /**
  30300. * Gets a boolean indicating if Database storate is enabled (off by default)
  30301. */
  30302. static IDBStorageEnabled: boolean;
  30303. /**
  30304. * Gets a boolean indicating if scene must be saved in the database
  30305. */
  30306. readonly enableSceneOffline: boolean;
  30307. /**
  30308. * Gets a boolean indicating if textures must be saved in the database
  30309. */
  30310. readonly enableTexturesOffline: boolean;
  30311. /**
  30312. * Creates a new Database
  30313. * @param urlToScene defines the url to load the scene
  30314. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30315. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30316. */
  30317. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30318. private static _ParseURL;
  30319. private static _ReturnFullUrlLocation;
  30320. private _checkManifestFile;
  30321. /**
  30322. * Open the database and make it available
  30323. * @param successCallback defines the callback to call on success
  30324. * @param errorCallback defines the callback to call on error
  30325. */
  30326. open(successCallback: () => void, errorCallback: () => void): void;
  30327. /**
  30328. * Loads an image from the database
  30329. * @param url defines the url to load from
  30330. * @param image defines the target DOM image
  30331. */
  30332. loadImage(url: string, image: HTMLImageElement): void;
  30333. private _loadImageFromDBAsync;
  30334. private _saveImageIntoDBAsync;
  30335. private _checkVersionFromDB;
  30336. private _loadVersionFromDBAsync;
  30337. private _saveVersionIntoDBAsync;
  30338. /**
  30339. * Loads a file from database
  30340. * @param url defines the URL to load from
  30341. * @param sceneLoaded defines a callback to call on success
  30342. * @param progressCallBack defines a callback to call when progress changed
  30343. * @param errorCallback defines a callback to call on error
  30344. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30345. */
  30346. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30347. private _loadFileAsync;
  30348. private _saveFileAsync;
  30349. }
  30350. }
  30351. declare module BABYLON {
  30352. /**
  30353. * Class used to enable access to offline support
  30354. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30355. */
  30356. interface IOfflineProvider {
  30357. /**
  30358. * Gets a boolean indicating if scene must be saved in the database
  30359. */
  30360. enableSceneOffline: boolean;
  30361. /**
  30362. * Gets a boolean indicating if textures must be saved in the database
  30363. */
  30364. enableTexturesOffline: boolean;
  30365. /**
  30366. * Open the offline support and make it available
  30367. * @param successCallback defines the callback to call on success
  30368. * @param errorCallback defines the callback to call on error
  30369. */
  30370. open(successCallback: () => void, errorCallback: () => void): void;
  30371. /**
  30372. * Loads an image from the offline support
  30373. * @param url defines the url to load from
  30374. * @param image defines the target DOM image
  30375. */
  30376. loadImage(url: string, image: HTMLImageElement): void;
  30377. /**
  30378. * Loads a file from offline support
  30379. * @param url defines the URL to load from
  30380. * @param sceneLoaded defines a callback to call on success
  30381. * @param progressCallBack defines a callback to call when progress changed
  30382. * @param errorCallback defines a callback to call on error
  30383. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30384. */
  30385. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30386. }
  30387. }
  30388. declare module BABYLON {
  30389. /**
  30390. * Interface used to describe a physics joint
  30391. */
  30392. interface PhysicsImpostorJoint {
  30393. /** Defines the main impostor to which the joint is linked */
  30394. mainImpostor: PhysicsImpostor;
  30395. /** Defines the impostor that is connected to the main impostor using this joint */
  30396. connectedImpostor: PhysicsImpostor;
  30397. /** Defines the joint itself */
  30398. joint: PhysicsJoint;
  30399. }
  30400. /** @hidden */
  30401. interface IPhysicsEnginePlugin {
  30402. world: any;
  30403. name: string;
  30404. setGravity(gravity: Vector3): void;
  30405. setTimeStep(timeStep: number): void;
  30406. getTimeStep(): number;
  30407. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  30408. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30409. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30410. generatePhysicsBody(impostor: PhysicsImpostor): void;
  30411. removePhysicsBody(impostor: PhysicsImpostor): void;
  30412. generateJoint(joint: PhysicsImpostorJoint): void;
  30413. removeJoint(joint: PhysicsImpostorJoint): void;
  30414. isSupported(): boolean;
  30415. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  30416. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  30417. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30418. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30419. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30420. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30421. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  30422. getBodyMass(impostor: PhysicsImpostor): number;
  30423. getBodyFriction(impostor: PhysicsImpostor): number;
  30424. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  30425. getBodyRestitution(impostor: PhysicsImpostor): number;
  30426. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  30427. sleepBody(impostor: PhysicsImpostor): void;
  30428. wakeUpBody(impostor: PhysicsImpostor): void;
  30429. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  30430. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  30431. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30432. getRadius(impostor: PhysicsImpostor): number;
  30433. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  30434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  30435. dispose(): void;
  30436. }
  30437. /**
  30438. * Interface used to define a physics engine
  30439. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30440. */
  30441. interface IPhysicsEngine {
  30442. /**
  30443. * Gets the gravity vector used by the simulation
  30444. */
  30445. gravity: Vector3;
  30446. /**
  30447. * Sets the gravity vector used by the simulation
  30448. * @param gravity defines the gravity vector to use
  30449. */
  30450. setGravity(gravity: Vector3): void;
  30451. /**
  30452. * Set the time step of the physics engine.
  30453. * Default is 1/60.
  30454. * To slow it down, enter 1/600 for example.
  30455. * To speed it up, 1/30
  30456. * @param newTimeStep the new timestep to apply to this world.
  30457. */
  30458. setTimeStep(newTimeStep: number): void;
  30459. /**
  30460. * Get the time step of the physics engine.
  30461. * @returns the current time step
  30462. */
  30463. getTimeStep(): number;
  30464. /**
  30465. * Release all resources
  30466. */
  30467. dispose(): void;
  30468. /**
  30469. * Gets the name of the current physics plugin
  30470. * @returns the name of the plugin
  30471. */
  30472. getPhysicsPluginName(): string;
  30473. /**
  30474. * Adding a new impostor for the impostor tracking.
  30475. * This will be done by the impostor itself.
  30476. * @param impostor the impostor to add
  30477. */
  30478. addImpostor(impostor: PhysicsImpostor): void;
  30479. /**
  30480. * Remove an impostor from the engine.
  30481. * This impostor and its mesh will not longer be updated by the physics engine.
  30482. * @param impostor the impostor to remove
  30483. */
  30484. removeImpostor(impostor: PhysicsImpostor): void;
  30485. /**
  30486. * Add a joint to the physics engine
  30487. * @param mainImpostor defines the main impostor to which the joint is added.
  30488. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30489. * @param joint defines the joint that will connect both impostors.
  30490. */
  30491. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30492. /**
  30493. * Removes a joint from the simulation
  30494. * @param mainImpostor defines the impostor used with the joint
  30495. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30496. * @param joint defines the joint to remove
  30497. */
  30498. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30499. /**
  30500. * Gets the current plugin used to run the simulation
  30501. * @returns current plugin
  30502. */
  30503. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30504. /**
  30505. * Gets the list of physic impostors
  30506. * @returns an array of PhysicsImpostor
  30507. */
  30508. getImpostors(): Array<PhysicsImpostor>;
  30509. /**
  30510. * Gets the impostor for a physics enabled object
  30511. * @param object defines the object impersonated by the impostor
  30512. * @returns the PhysicsImpostor or null if not found
  30513. */
  30514. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30515. /**
  30516. * Gets the impostor for a physics body object
  30517. * @param body defines physics body used by the impostor
  30518. * @returns the PhysicsImpostor or null if not found
  30519. */
  30520. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30521. /**
  30522. * Called by the scene. No need to call it.
  30523. * @param delta defines the timespam between frames
  30524. */
  30525. _step(delta: number): void;
  30526. }
  30527. }
  30528. declare module BABYLON {
  30529. /**
  30530. * Class used to control physics engine
  30531. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30532. */
  30533. class PhysicsEngine implements IPhysicsEngine {
  30534. private _physicsPlugin;
  30535. /**
  30536. * Global value used to control the smallest number supported by the simulation
  30537. */
  30538. static Epsilon: number;
  30539. private _impostors;
  30540. private _joints;
  30541. /**
  30542. * Gets the gravity vector used by the simulation
  30543. */
  30544. gravity: Vector3;
  30545. /**
  30546. * Creates a new Physics Engine
  30547. * @param gravity defines the gravity vector used by the simulation
  30548. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  30549. */
  30550. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  30551. /**
  30552. * Sets the gravity vector used by the simulation
  30553. * @param gravity defines the gravity vector to use
  30554. */
  30555. setGravity(gravity: Vector3): void;
  30556. /**
  30557. * Set the time step of the physics engine.
  30558. * Default is 1/60.
  30559. * To slow it down, enter 1/600 for example.
  30560. * To speed it up, 1/30
  30561. * @param newTimeStep defines the new timestep to apply to this world.
  30562. */
  30563. setTimeStep(newTimeStep?: number): void;
  30564. /**
  30565. * Get the time step of the physics engine.
  30566. * @returns the current time step
  30567. */
  30568. getTimeStep(): number;
  30569. /**
  30570. * Release all resources
  30571. */
  30572. dispose(): void;
  30573. /**
  30574. * Gets the name of the current physics plugin
  30575. * @returns the name of the plugin
  30576. */
  30577. getPhysicsPluginName(): string;
  30578. /**
  30579. * Adding a new impostor for the impostor tracking.
  30580. * This will be done by the impostor itself.
  30581. * @param impostor the impostor to add
  30582. */
  30583. addImpostor(impostor: PhysicsImpostor): void;
  30584. /**
  30585. * Remove an impostor from the engine.
  30586. * This impostor and its mesh will not longer be updated by the physics engine.
  30587. * @param impostor the impostor to remove
  30588. */
  30589. removeImpostor(impostor: PhysicsImpostor): void;
  30590. /**
  30591. * Add a joint to the physics engine
  30592. * @param mainImpostor defines the main impostor to which the joint is added.
  30593. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30594. * @param joint defines the joint that will connect both impostors.
  30595. */
  30596. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30597. /**
  30598. * Removes a joint from the simulation
  30599. * @param mainImpostor defines the impostor used with the joint
  30600. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30601. * @param joint defines the joint to remove
  30602. */
  30603. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30604. /**
  30605. * Called by the scene. No need to call it.
  30606. * @param delta defines the timespam between frames
  30607. */
  30608. _step(delta: number): void;
  30609. /**
  30610. * Gets the current plugin used to run the simulation
  30611. * @returns current plugin
  30612. */
  30613. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30614. /**
  30615. * Gets the list of physic impostors
  30616. * @returns an array of PhysicsImpostor
  30617. */
  30618. getImpostors(): Array<PhysicsImpostor>;
  30619. /**
  30620. * Gets the impostor for a physics enabled object
  30621. * @param object defines the object impersonated by the impostor
  30622. * @returns the PhysicsImpostor or null if not found
  30623. */
  30624. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30625. /**
  30626. * Gets the impostor for a physics body object
  30627. * @param body defines physics body used by the impostor
  30628. * @returns the PhysicsImpostor or null if not found
  30629. */
  30630. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30631. }
  30632. }
  30633. declare module BABYLON {
  30634. interface Scene {
  30635. /** @hidden (Backing field) */
  30636. _physicsEngine: Nullable<IPhysicsEngine>;
  30637. /**
  30638. * Gets the current physics engine
  30639. * @returns a IPhysicsEngine or null if none attached
  30640. */
  30641. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  30642. /**
  30643. * Enables physics to the current scene
  30644. * @param gravity defines the scene's gravity for the physics engine
  30645. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  30646. * @return a boolean indicating if the physics engine was initialized
  30647. */
  30648. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  30649. /**
  30650. * Disables and disposes the physics engine associated with the scene
  30651. */
  30652. disablePhysicsEngine(): void;
  30653. /**
  30654. * Gets a boolean indicating if there is an active physics engine
  30655. * @returns a boolean indicating if there is an active physics engine
  30656. */
  30657. isPhysicsEnabled(): boolean;
  30658. /**
  30659. * Deletes a physics compound impostor
  30660. * @param compound defines the compound to delete
  30661. */
  30662. deleteCompoundImpostor(compound: any): void;
  30663. /**
  30664. * An event triggered when physic simulation is about to be run
  30665. */
  30666. onBeforePhysicsObservable: Observable<Scene>;
  30667. /**
  30668. * An event triggered when physic simulation has been done
  30669. */
  30670. onAfterPhysicsObservable: Observable<Scene>;
  30671. }
  30672. interface AbstractMesh {
  30673. /** @hidden */
  30674. _physicsImpostor: Nullable<PhysicsImpostor>;
  30675. /**
  30676. * Gets or sets impostor used for physic simulation
  30677. * @see http://doc.babylonjs.com/features/physics_engine
  30678. */
  30679. physicsImpostor: Nullable<PhysicsImpostor>;
  30680. /**
  30681. * Gets the current physics impostor
  30682. * @see http://doc.babylonjs.com/features/physics_engine
  30683. * @returns a physics impostor or null
  30684. */
  30685. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  30686. /** Apply a physic impulse to the mesh
  30687. * @param force defines the force to apply
  30688. * @param contactPoint defines where to apply the force
  30689. * @returns the current mesh
  30690. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30691. */
  30692. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  30693. /**
  30694. * Creates a physic joint between two meshes
  30695. * @param otherMesh defines the other mesh to use
  30696. * @param pivot1 defines the pivot to use on this mesh
  30697. * @param pivot2 defines the pivot to use on the other mesh
  30698. * @param options defines additional options (can be plugin dependent)
  30699. * @returns the current mesh
  30700. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  30701. */
  30702. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  30703. /** @hidden */
  30704. _disposePhysicsObserver: Nullable<Observer<Node>>;
  30705. }
  30706. /**
  30707. * Defines the physics engine scene component responsible to manage a physics engine
  30708. */
  30709. class PhysicsEngineSceneComponent implements ISceneComponent {
  30710. /**
  30711. * The component name helpful to identify the component in the list of scene components.
  30712. */
  30713. readonly name: string;
  30714. /**
  30715. * The scene the component belongs to.
  30716. */
  30717. scene: Scene;
  30718. /**
  30719. * Creates a new instance of the component for the given scene
  30720. * @param scene Defines the scene to register the component in
  30721. */
  30722. constructor(scene: Scene);
  30723. /**
  30724. * Registers the component in a given scene
  30725. */
  30726. register(): void;
  30727. /**
  30728. * Rebuilds the elements related to this component in case of
  30729. * context lost for instance.
  30730. */
  30731. rebuild(): void;
  30732. /**
  30733. * Disposes the component and the associated ressources
  30734. */
  30735. dispose(): void;
  30736. }
  30737. }
  30738. declare module BABYLON {
  30739. /**
  30740. * A helper for physics simulations
  30741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30742. */
  30743. class PhysicsHelper {
  30744. private _scene;
  30745. private _physicsEngine;
  30746. /**
  30747. * Initializes the Physics helper
  30748. * @param scene Babylon.js scene
  30749. */
  30750. constructor(scene: Scene);
  30751. /**
  30752. * Applies a radial explosion impulse
  30753. * @param origin the origin of the explosion
  30754. * @param radius the explosion radius
  30755. * @param strength the explosion strength
  30756. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30757. * @returns A physics radial explosion event, or null
  30758. */
  30759. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30760. /**
  30761. * Applies a radial explosion force
  30762. * @param origin the origin of the explosion
  30763. * @param radius the explosion radius
  30764. * @param strength the explosion strength
  30765. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30766. * @returns A physics radial explosion event, or null
  30767. */
  30768. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30769. /**
  30770. * Creates a gravitational field
  30771. * @param origin the origin of the explosion
  30772. * @param radius the explosion radius
  30773. * @param strength the explosion strength
  30774. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30775. * @returns A physics gravitational field event, or null
  30776. */
  30777. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30778. /**
  30779. * Creates a physics updraft event
  30780. * @param origin the origin of the updraft
  30781. * @param radius the radius of the updraft
  30782. * @param strength the strength of the updraft
  30783. * @param height the height of the updraft
  30784. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  30785. * @returns A physics updraft event, or null
  30786. */
  30787. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30788. /**
  30789. * Creates a physics vortex event
  30790. * @param origin the of the vortex
  30791. * @param radius the radius of the vortex
  30792. * @param strength the strength of the vortex
  30793. * @param height the height of the vortex
  30794. * @returns a Physics vortex event, or null
  30795. * A physics vortex event or null
  30796. */
  30797. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30798. }
  30799. /**
  30800. * Represents a physics radial explosion event
  30801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30802. */
  30803. class PhysicsRadialExplosionEvent {
  30804. private _scene;
  30805. private _sphere;
  30806. private _sphereOptions;
  30807. private _rays;
  30808. private _dataFetched;
  30809. /**
  30810. * Initializes a radial explosioin event
  30811. * @param scene BabylonJS scene
  30812. */
  30813. constructor(scene: Scene);
  30814. /**
  30815. * Returns the data related to the radial explosion event (sphere & rays).
  30816. * @returns The radial explosion event data
  30817. */
  30818. getData(): PhysicsRadialExplosionEventData;
  30819. /**
  30820. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30821. * @param impostor A physics imposter
  30822. * @param origin the origin of the explosion
  30823. * @param radius the explosion radius
  30824. * @param strength the explosion strength
  30825. * @param falloff possible options: Constant & Linear
  30826. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  30827. */
  30828. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30829. /**
  30830. * Disposes the sphere.
  30831. * @param force Specifies if the sphere should be disposed by force
  30832. */
  30833. dispose(force?: boolean): void;
  30834. /*** Helpers ***/
  30835. private _prepareSphere;
  30836. private _intersectsWithSphere;
  30837. }
  30838. /**
  30839. * Represents a gravitational field event
  30840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30841. */
  30842. class PhysicsGravitationalFieldEvent {
  30843. private _physicsHelper;
  30844. private _scene;
  30845. private _origin;
  30846. private _radius;
  30847. private _strength;
  30848. private _falloff;
  30849. private _tickCallback;
  30850. private _sphere;
  30851. private _dataFetched;
  30852. /**
  30853. * Initializes the physics gravitational field event
  30854. * @param physicsHelper A physics helper
  30855. * @param scene BabylonJS scene
  30856. * @param origin The origin position of the gravitational field event
  30857. * @param radius The radius of the gravitational field event
  30858. * @param strength The strength of the gravitational field event
  30859. * @param falloff The falloff for the gravitational field event
  30860. */
  30861. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30862. /**
  30863. * Returns the data related to the gravitational field event (sphere).
  30864. * @returns A gravitational field event
  30865. */
  30866. getData(): PhysicsGravitationalFieldEventData;
  30867. /**
  30868. * Enables the gravitational field.
  30869. */
  30870. enable(): void;
  30871. /**
  30872. * Disables the gravitational field.
  30873. */
  30874. disable(): void;
  30875. /**
  30876. * Disposes the sphere.
  30877. * @param force The force to dispose from the gravitational field event
  30878. */
  30879. dispose(force?: boolean): void;
  30880. private _tick;
  30881. }
  30882. /**
  30883. * Represents a physics updraft event
  30884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30885. */
  30886. class PhysicsUpdraftEvent {
  30887. private _scene;
  30888. private _origin;
  30889. private _radius;
  30890. private _strength;
  30891. private _height;
  30892. private _updraftMode;
  30893. private _physicsEngine;
  30894. private _originTop;
  30895. private _originDirection;
  30896. private _tickCallback;
  30897. private _cylinder;
  30898. private _cylinderPosition;
  30899. private _dataFetched;
  30900. /**
  30901. * Initializes the physics updraft event
  30902. * @param _scene BabylonJS scene
  30903. * @param _origin The origin position of the updraft
  30904. * @param _radius The radius of the updraft
  30905. * @param _strength The strength of the updraft
  30906. * @param _height The height of the updraft
  30907. * @param _updraftMode The mode of the updraft
  30908. */
  30909. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30910. /**
  30911. * Returns the data related to the updraft event (cylinder).
  30912. * @returns A physics updraft event
  30913. */
  30914. getData(): PhysicsUpdraftEventData;
  30915. /**
  30916. * Enables the updraft.
  30917. */
  30918. enable(): void;
  30919. /**
  30920. * Disables the cortex.
  30921. */
  30922. disable(): void;
  30923. /**
  30924. * Disposes the sphere.
  30925. * @param force Specifies if the updraft should be disposed by force
  30926. */
  30927. dispose(force?: boolean): void;
  30928. private getImpostorForceAndContactPoint;
  30929. private _tick;
  30930. /*** Helpers ***/
  30931. private _prepareCylinder;
  30932. private _intersectsWithCylinder;
  30933. }
  30934. /**
  30935. * Represents a physics vortex event
  30936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30937. */
  30938. class PhysicsVortexEvent {
  30939. private _scene;
  30940. private _origin;
  30941. private _radius;
  30942. private _strength;
  30943. private _height;
  30944. private _physicsEngine;
  30945. private _originTop;
  30946. private _centripetalForceThreshold;
  30947. private _updraftMultiplier;
  30948. private _tickCallback;
  30949. private _cylinder;
  30950. private _cylinderPosition;
  30951. private _dataFetched;
  30952. /**
  30953. * Initializes the physics vortex event
  30954. * @param _scene The BabylonJS scene
  30955. * @param _origin The origin position of the vortex
  30956. * @param _radius The radius of the vortex
  30957. * @param _strength The strength of the vortex
  30958. * @param _height The height of the vortex
  30959. */
  30960. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30961. /**
  30962. * Returns the data related to the vortex event (cylinder).
  30963. * @returns The physics vortex event data
  30964. */
  30965. getData(): PhysicsVortexEventData;
  30966. /**
  30967. * Enables the vortex.
  30968. */
  30969. enable(): void;
  30970. /**
  30971. * Disables the cortex.
  30972. */
  30973. disable(): void;
  30974. /**
  30975. * Disposes the sphere.
  30976. * @param force
  30977. */
  30978. dispose(force?: boolean): void;
  30979. private getImpostorForceAndContactPoint;
  30980. private _tick;
  30981. /*** Helpers ***/
  30982. private _prepareCylinder;
  30983. private _intersectsWithCylinder;
  30984. }
  30985. /**
  30986. * The strenght of the force in correspondence to the distance of the affected object
  30987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30988. */
  30989. enum PhysicsRadialImpulseFalloff {
  30990. /** Defines that impulse is constant in strength across it's whole radius */
  30991. Constant = 0,
  30992. /** DEfines that impulse gets weaker if it's further from the origin */
  30993. Linear = 1
  30994. }
  30995. /**
  30996. * The strength of the force in correspondence to the distance of the affected object
  30997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30998. */
  30999. enum PhysicsUpdraftMode {
  31000. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  31001. Center = 0,
  31002. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  31003. Perpendicular = 1
  31004. }
  31005. /**
  31006. * Interface for a physics force and contact point
  31007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31008. */
  31009. interface PhysicsForceAndContactPoint {
  31010. /**
  31011. * The force applied at the contact point
  31012. */
  31013. force: Vector3;
  31014. /**
  31015. * The contact point
  31016. */
  31017. contactPoint: Vector3;
  31018. }
  31019. /**
  31020. * Interface for radial explosion event data
  31021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31022. */
  31023. interface PhysicsRadialExplosionEventData {
  31024. /**
  31025. * A sphere used for the radial explosion event
  31026. */
  31027. sphere: Mesh;
  31028. /**
  31029. * An array of rays for the radial explosion event
  31030. */
  31031. rays: Array<Ray>;
  31032. }
  31033. /**
  31034. * Interface for gravitational field event data
  31035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31036. */
  31037. interface PhysicsGravitationalFieldEventData {
  31038. /**
  31039. * A sphere mesh used for the gravitational field event
  31040. */
  31041. sphere: Mesh;
  31042. }
  31043. /**
  31044. * Interface for updraft event data
  31045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31046. */
  31047. interface PhysicsUpdraftEventData {
  31048. /**
  31049. * A cylinder used for the updraft event
  31050. */
  31051. cylinder: Mesh;
  31052. }
  31053. /**
  31054. * Interface for vortex event data
  31055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31056. */
  31057. interface PhysicsVortexEventData {
  31058. /**
  31059. * A cylinder used for the vortex event
  31060. */
  31061. cylinder: Mesh;
  31062. }
  31063. }
  31064. declare module BABYLON {
  31065. /**
  31066. * The interface for the physics imposter parameters
  31067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31068. */
  31069. interface PhysicsImpostorParameters {
  31070. /**
  31071. * The mass of the physics imposter
  31072. */
  31073. mass: number;
  31074. /**
  31075. * The friction of the physics imposter
  31076. */
  31077. friction?: number;
  31078. /**
  31079. * The coefficient of restitution of the physics imposter
  31080. */
  31081. restitution?: number;
  31082. /**
  31083. * The native options of the physics imposter
  31084. */
  31085. nativeOptions?: any;
  31086. /**
  31087. * Specifies if the parent should be ignored
  31088. */
  31089. ignoreParent?: boolean;
  31090. /**
  31091. * Specifies if bi-directional transformations should be disabled
  31092. */
  31093. disableBidirectionalTransformation?: boolean;
  31094. }
  31095. /**
  31096. * Interface for a physics-enabled object
  31097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31098. */
  31099. interface IPhysicsEnabledObject {
  31100. /**
  31101. * The position of the physics-enabled object
  31102. */
  31103. position: Vector3;
  31104. /**
  31105. * The rotation of the physics-enabled object
  31106. */
  31107. rotationQuaternion: Nullable<Quaternion>;
  31108. /**
  31109. * The scale of the physics-enabled object
  31110. */
  31111. scaling: Vector3;
  31112. /**
  31113. * The rotation of the physics-enabled object
  31114. */
  31115. rotation?: Vector3;
  31116. /**
  31117. * The parent of the physics-enabled object
  31118. */
  31119. parent?: any;
  31120. /**
  31121. * The bounding info of the physics-enabled object
  31122. * @returns The bounding info of the physics-enabled object
  31123. */
  31124. getBoundingInfo(): BoundingInfo;
  31125. /**
  31126. * Computes the world matrix
  31127. * @param force Specifies if the world matrix should be computed by force
  31128. * @returns A world matrix
  31129. */
  31130. computeWorldMatrix(force: boolean): Matrix;
  31131. /**
  31132. * Gets the world matrix
  31133. * @returns A world matrix
  31134. */
  31135. getWorldMatrix?(): Matrix;
  31136. /**
  31137. * Gets the child meshes
  31138. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31139. * @returns An array of abstract meshes
  31140. */
  31141. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31142. /**
  31143. * Gets the vertex data
  31144. * @param kind The type of vertex data
  31145. * @returns A nullable array of numbers, or a float32 array
  31146. */
  31147. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31148. /**
  31149. * Gets the indices from the mesh
  31150. * @returns A nullable array of index arrays
  31151. */
  31152. getIndices?(): Nullable<IndicesArray>;
  31153. /**
  31154. * Gets the scene from the mesh
  31155. * @returns the indices array or null
  31156. */
  31157. getScene?(): Scene;
  31158. /**
  31159. * Gets the absolute position from the mesh
  31160. * @returns the absolute position
  31161. */
  31162. getAbsolutePosition(): Vector3;
  31163. /**
  31164. * Gets the absolute pivot point from the mesh
  31165. * @returns the absolute pivot point
  31166. */
  31167. getAbsolutePivotPoint(): Vector3;
  31168. /**
  31169. * Rotates the mesh
  31170. * @param axis The axis of rotation
  31171. * @param amount The amount of rotation
  31172. * @param space The space of the rotation
  31173. * @returns The rotation transform node
  31174. */
  31175. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31176. /**
  31177. * Translates the mesh
  31178. * @param axis The axis of translation
  31179. * @param distance The distance of translation
  31180. * @param space The space of the translation
  31181. * @returns The transform node
  31182. */
  31183. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31184. /**
  31185. * Sets the absolute position of the mesh
  31186. * @param absolutePosition The absolute position of the mesh
  31187. * @returns The transform node
  31188. */
  31189. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31190. /**
  31191. * Gets the class name of the mesh
  31192. * @returns The class name
  31193. */
  31194. getClassName(): string;
  31195. }
  31196. /**
  31197. * Represents a physics imposter
  31198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31199. */
  31200. class PhysicsImpostor {
  31201. /**
  31202. * The physics-enabled object used as the physics imposter
  31203. */
  31204. object: IPhysicsEnabledObject;
  31205. /**
  31206. * The type of the physics imposter
  31207. */
  31208. type: number;
  31209. private _options;
  31210. private _scene?;
  31211. /**
  31212. * The default object size of the imposter
  31213. */
  31214. static DEFAULT_OBJECT_SIZE: Vector3;
  31215. /**
  31216. * The identity quaternion of the imposter
  31217. */
  31218. static IDENTITY_QUATERNION: Quaternion;
  31219. /** @hidden */
  31220. _pluginData: any;
  31221. private _physicsEngine;
  31222. private _physicsBody;
  31223. private _bodyUpdateRequired;
  31224. private _onBeforePhysicsStepCallbacks;
  31225. private _onAfterPhysicsStepCallbacks;
  31226. /** @hidden */
  31227. _onPhysicsCollideCallbacks: Array<{
  31228. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  31229. otherImpostors: Array<PhysicsImpostor>;
  31230. }>;
  31231. private _deltaPosition;
  31232. private _deltaRotation;
  31233. private _deltaRotationConjugated;
  31234. private _parent;
  31235. private _isDisposed;
  31236. private static _tmpVecs;
  31237. private static _tmpQuat;
  31238. /**
  31239. * Specifies if the physics imposter is disposed
  31240. */
  31241. readonly isDisposed: boolean;
  31242. /**
  31243. * Gets the mass of the physics imposter
  31244. */
  31245. mass: number;
  31246. /**
  31247. * Gets the coefficient of friction
  31248. */
  31249. /**
  31250. * Sets the coefficient of friction
  31251. */
  31252. friction: number;
  31253. /**
  31254. * Gets the coefficient of restitution
  31255. */
  31256. /**
  31257. * Sets the coefficient of restitution
  31258. */
  31259. restitution: number;
  31260. /**
  31261. * The unique id of the physics imposter
  31262. * set by the physics engine when adding this impostor to the array
  31263. */
  31264. uniqueId: number;
  31265. private _joints;
  31266. /**
  31267. * Initializes the physics imposter
  31268. * @param object The physics-enabled object used as the physics imposter
  31269. * @param type The type of the physics imposter
  31270. * @param _options The options for the physics imposter
  31271. * @param _scene The Babylon scene
  31272. */
  31273. constructor(
  31274. /**
  31275. * The physics-enabled object used as the physics imposter
  31276. */
  31277. object: IPhysicsEnabledObject,
  31278. /**
  31279. * The type of the physics imposter
  31280. */
  31281. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31282. /**
  31283. * This function will completly initialize this impostor.
  31284. * It will create a new body - but only if this mesh has no parent.
  31285. * If it has, this impostor will not be used other than to define the impostor
  31286. * of the child mesh.
  31287. * @hidden
  31288. */
  31289. _init(): void;
  31290. private _getPhysicsParent;
  31291. /**
  31292. * Should a new body be generated.
  31293. * @returns boolean specifying if body initialization is required
  31294. */
  31295. isBodyInitRequired(): boolean;
  31296. /**
  31297. * Sets the updated scaling
  31298. * @param updated Specifies if the scaling is updated
  31299. */
  31300. setScalingUpdated(updated: boolean): void;
  31301. /**
  31302. * Force a regeneration of this or the parent's impostor's body.
  31303. * Use under cautious - This will remove all joints already implemented.
  31304. */
  31305. forceUpdate(): void;
  31306. /**
  31307. * Gets the body that holds this impostor. Either its own, or its parent.
  31308. */
  31309. /**
  31310. * Set the physics body. Used mainly by the physics engine/plugin
  31311. */
  31312. physicsBody: any;
  31313. /**
  31314. * Get the parent of the physics imposter
  31315. * @returns Physics imposter or null
  31316. */
  31317. /**
  31318. * Sets the parent of the physics imposter
  31319. */
  31320. parent: Nullable<PhysicsImpostor>;
  31321. /**
  31322. * Resets the update flags
  31323. */
  31324. resetUpdateFlags(): void;
  31325. /**
  31326. * Gets the object extend size
  31327. * @returns the object extend size
  31328. */
  31329. getObjectExtendSize(): Vector3;
  31330. /**
  31331. * Gets the object center
  31332. * @returns The object center
  31333. */
  31334. getObjectCenter(): Vector3;
  31335. /**
  31336. * Get a specific parametes from the options parameter
  31337. * @param paramName The object parameter name
  31338. * @returns The object parameter
  31339. */
  31340. getParam(paramName: string): any;
  31341. /**
  31342. * Sets a specific parameter in the options given to the physics plugin
  31343. * @param paramName The parameter name
  31344. * @param value The value of the parameter
  31345. */
  31346. setParam(paramName: string, value: number): void;
  31347. /**
  31348. * Specifically change the body's mass option. Won't recreate the physics body object
  31349. * @param mass The mass of the physics imposter
  31350. */
  31351. setMass(mass: number): void;
  31352. /**
  31353. * Gets the linear velocity
  31354. * @returns linear velocity or null
  31355. */
  31356. getLinearVelocity(): Nullable<Vector3>;
  31357. /**
  31358. * Sets the linear velocity
  31359. * @param velocity linear velocity or null
  31360. */
  31361. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31362. /**
  31363. * Gets the angular velocity
  31364. * @returns angular velocity or null
  31365. */
  31366. getAngularVelocity(): Nullable<Vector3>;
  31367. /**
  31368. * Sets the angular velocity
  31369. * @param velocity The velocity or null
  31370. */
  31371. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31372. /**
  31373. * Execute a function with the physics plugin native code
  31374. * Provide a function the will have two variables - the world object and the physics body object
  31375. * @param func The function to execute with the physics plugin native code
  31376. */
  31377. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31378. /**
  31379. * Register a function that will be executed before the physics world is stepping forward
  31380. * @param func The function to execute before the physics world is stepped forward
  31381. */
  31382. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31383. /**
  31384. * Unregister a function that will be executed before the physics world is stepping forward
  31385. * @param func The function to execute before the physics world is stepped forward
  31386. */
  31387. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31388. /**
  31389. * Register a function that will be executed after the physics step
  31390. * @param func The function to execute after physics step
  31391. */
  31392. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31393. /**
  31394. * Unregisters a function that will be executed after the physics step
  31395. * @param func The function to execute after physics step
  31396. */
  31397. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31398. /**
  31399. * register a function that will be executed when this impostor collides against a different body
  31400. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31401. * @param func Callback that is executed on collision
  31402. */
  31403. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31404. /**
  31405. * Unregisters the physics imposter on contact
  31406. * @param collideAgainst The physics object to collide against
  31407. * @param func Callback to execute on collision
  31408. */
  31409. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31410. private _tmpQuat;
  31411. private _tmpQuat2;
  31412. /**
  31413. * Get the parent rotation
  31414. * @returns The parent rotation
  31415. */
  31416. getParentsRotation(): Quaternion;
  31417. /**
  31418. * this function is executed by the physics engine.
  31419. */
  31420. beforeStep: () => void;
  31421. /**
  31422. * this function is executed by the physics engine
  31423. */
  31424. afterStep: () => void;
  31425. /**
  31426. * Legacy collision detection event support
  31427. */
  31428. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31429. /**
  31430. * event and body object due to cannon's event-based architecture.
  31431. */
  31432. onCollide: (e: {
  31433. body: any;
  31434. }) => void;
  31435. /**
  31436. * Apply a force
  31437. * @param force The force to apply
  31438. * @param contactPoint The contact point for the force
  31439. * @returns The physics imposter
  31440. */
  31441. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31442. /**
  31443. * Apply an impulse
  31444. * @param force The impulse force
  31445. * @param contactPoint The contact point for the impulse force
  31446. * @returns The physics imposter
  31447. */
  31448. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31449. /**
  31450. * A help function to create a joint
  31451. * @param otherImpostor A physics imposter used to create a joint
  31452. * @param jointType The type of joint
  31453. * @param jointData The data for the joint
  31454. * @returns The physics imposter
  31455. */
  31456. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  31457. /**
  31458. * Add a joint to this impostor with a different impostor
  31459. * @param otherImpostor A physics imposter used to add a joint
  31460. * @param joint The joint to add
  31461. * @returns The physics imposter
  31462. */
  31463. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  31464. /**
  31465. * Will keep this body still, in a sleep mode.
  31466. * @returns the physics imposter
  31467. */
  31468. sleep(): PhysicsImpostor;
  31469. /**
  31470. * Wake the body up.
  31471. * @returns The physics imposter
  31472. */
  31473. wakeUp(): PhysicsImpostor;
  31474. /**
  31475. * Clones the physics imposter
  31476. * @param newObject The physics imposter clones to this physics-enabled object
  31477. * @returns A nullable physics imposter
  31478. */
  31479. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31480. /**
  31481. * Disposes the physics imposter
  31482. */
  31483. dispose(): void;
  31484. /**
  31485. * Sets the delta position
  31486. * @param position The delta position amount
  31487. */
  31488. setDeltaPosition(position: Vector3): void;
  31489. /**
  31490. * Sets the delta rotation
  31491. * @param rotation The delta rotation amount
  31492. */
  31493. setDeltaRotation(rotation: Quaternion): void;
  31494. /**
  31495. * Gets the box size of the physics imposter and stores the result in the input parameter
  31496. * @param result Stores the box size
  31497. * @returns The physics imposter
  31498. */
  31499. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  31500. /**
  31501. * Gets the radius of the physics imposter
  31502. * @returns Radius of the physics imposter
  31503. */
  31504. getRadius(): number;
  31505. /**
  31506. * Sync a bone with this impostor
  31507. * @param bone The bone to sync to the impostor.
  31508. * @param boneMesh The mesh that the bone is influencing.
  31509. * @param jointPivot The pivot of the joint / bone in local space.
  31510. * @param distToJoint Optional distance from the impostor to the joint.
  31511. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31512. */
  31513. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  31514. /**
  31515. * Sync impostor to a bone
  31516. * @param bone The bone that the impostor will be synced to.
  31517. * @param boneMesh The mesh that the bone is influencing.
  31518. * @param jointPivot The pivot of the joint / bone in local space.
  31519. * @param distToJoint Optional distance from the impostor to the joint.
  31520. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31521. * @param boneAxis Optional vector3 axis the bone is aligned with
  31522. */
  31523. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  31524. /**
  31525. * No-Imposter type
  31526. */
  31527. static NoImpostor: number;
  31528. /**
  31529. * Sphere-Imposter type
  31530. */
  31531. static SphereImpostor: number;
  31532. /**
  31533. * Box-Imposter type
  31534. */
  31535. static BoxImpostor: number;
  31536. /**
  31537. * Plane-Imposter type
  31538. */
  31539. static PlaneImpostor: number;
  31540. /**
  31541. * Mesh-imposter type
  31542. */
  31543. static MeshImpostor: number;
  31544. /**
  31545. * Cylinder-Imposter type
  31546. */
  31547. static CylinderImpostor: number;
  31548. /**
  31549. * Particle-Imposter type
  31550. */
  31551. static ParticleImpostor: number;
  31552. /**
  31553. * Heightmap-Imposter type
  31554. */
  31555. static HeightmapImpostor: number;
  31556. }
  31557. }
  31558. declare module BABYLON {
  31559. /**
  31560. * Interface for Physics-Joint data
  31561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31562. */
  31563. interface PhysicsJointData {
  31564. /**
  31565. * The main pivot of the joint
  31566. */
  31567. mainPivot?: Vector3;
  31568. /**
  31569. * The connected pivot of the joint
  31570. */
  31571. connectedPivot?: Vector3;
  31572. /**
  31573. * The main axis of the joint
  31574. */
  31575. mainAxis?: Vector3;
  31576. /**
  31577. * The connected axis of the joint
  31578. */
  31579. connectedAxis?: Vector3;
  31580. /**
  31581. * The collision of the joint
  31582. */
  31583. collision?: boolean;
  31584. /**
  31585. * Native Oimo/Cannon/Energy data
  31586. */
  31587. nativeParams?: any;
  31588. }
  31589. /**
  31590. * This is a holder class for the physics joint created by the physics plugin
  31591. * It holds a set of functions to control the underlying joint
  31592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31593. */
  31594. class PhysicsJoint {
  31595. /**
  31596. * The type of the physics joint
  31597. */
  31598. type: number;
  31599. /**
  31600. * The data for the physics joint
  31601. */
  31602. jointData: PhysicsJointData;
  31603. private _physicsJoint;
  31604. protected _physicsPlugin: IPhysicsEnginePlugin;
  31605. /**
  31606. * Initializes the physics joint
  31607. * @param type The type of the physics joint
  31608. * @param jointData The data for the physics joint
  31609. */
  31610. constructor(
  31611. /**
  31612. * The type of the physics joint
  31613. */
  31614. type: number,
  31615. /**
  31616. * The data for the physics joint
  31617. */
  31618. jointData: PhysicsJointData);
  31619. /**
  31620. * Gets the physics joint
  31621. */
  31622. /**
  31623. * Sets the physics joint
  31624. */
  31625. physicsJoint: any;
  31626. /**
  31627. * Sets the physics plugin
  31628. */
  31629. physicsPlugin: IPhysicsEnginePlugin;
  31630. /**
  31631. * Execute a function that is physics-plugin specific.
  31632. * @param {Function} func the function that will be executed.
  31633. * It accepts two parameters: the physics world and the physics joint
  31634. */
  31635. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31636. /**
  31637. * Distance-Joint type
  31638. */
  31639. static DistanceJoint: number;
  31640. /**
  31641. * Hinge-Joint type
  31642. */
  31643. static HingeJoint: number;
  31644. /**
  31645. * Ball-and-Socket joint type
  31646. */
  31647. static BallAndSocketJoint: number;
  31648. /**
  31649. * Wheel-Joint type
  31650. */
  31651. static WheelJoint: number;
  31652. /**
  31653. * Slider-Joint type
  31654. */
  31655. static SliderJoint: number;
  31656. /**
  31657. * Prismatic-Joint type
  31658. */
  31659. static PrismaticJoint: number;
  31660. /**
  31661. * Universal-Joint type
  31662. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31663. */
  31664. static UniversalJoint: number;
  31665. /**
  31666. * Hinge-Joint 2 type
  31667. */
  31668. static Hinge2Joint: number;
  31669. /**
  31670. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31671. */
  31672. static PointToPointJoint: number;
  31673. /**
  31674. * Spring-Joint type
  31675. */
  31676. static SpringJoint: number;
  31677. /**
  31678. * Lock-Joint type
  31679. */
  31680. static LockJoint: number;
  31681. }
  31682. /**
  31683. * A class representing a physics distance joint
  31684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31685. */
  31686. class DistanceJoint extends PhysicsJoint {
  31687. /**
  31688. *
  31689. * @param jointData The data for the Distance-Joint
  31690. */
  31691. constructor(jointData: DistanceJointData);
  31692. /**
  31693. * Update the predefined distance.
  31694. * @param maxDistance The maximum preferred distance
  31695. * @param minDistance The minimum preferred distance
  31696. */
  31697. updateDistance(maxDistance: number, minDistance?: number): void;
  31698. }
  31699. /**
  31700. * Represents a Motor-Enabled Joint
  31701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31702. */
  31703. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31704. /**
  31705. * Initializes the Motor-Enabled Joint
  31706. * @param type The type of the joint
  31707. * @param jointData The physica joint data for the joint
  31708. */
  31709. constructor(type: number, jointData: PhysicsJointData);
  31710. /**
  31711. * Set the motor values.
  31712. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31713. * @param force the force to apply
  31714. * @param maxForce max force for this motor.
  31715. */
  31716. setMotor(force?: number, maxForce?: number): void;
  31717. /**
  31718. * Set the motor's limits.
  31719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31720. * @param upperLimit The upper limit of the motor
  31721. * @param lowerLimit The lower limit of the motor
  31722. */
  31723. setLimit(upperLimit: number, lowerLimit?: number): void;
  31724. }
  31725. /**
  31726. * This class represents a single physics Hinge-Joint
  31727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31728. */
  31729. class HingeJoint extends MotorEnabledJoint {
  31730. /**
  31731. * Initializes the Hinge-Joint
  31732. * @param jointData The joint data for the Hinge-Joint
  31733. */
  31734. constructor(jointData: PhysicsJointData);
  31735. /**
  31736. * Set the motor values.
  31737. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31738. * @param {number} force the force to apply
  31739. * @param {number} maxForce max force for this motor.
  31740. */
  31741. setMotor(force?: number, maxForce?: number): void;
  31742. /**
  31743. * Set the motor's limits.
  31744. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31745. * @param upperLimit The upper limit of the motor
  31746. * @param lowerLimit The lower limit of the motor
  31747. */
  31748. setLimit(upperLimit: number, lowerLimit?: number): void;
  31749. }
  31750. /**
  31751. * This class represents a dual hinge physics joint (same as wheel joint)
  31752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31753. */
  31754. class Hinge2Joint extends MotorEnabledJoint {
  31755. /**
  31756. * Initializes the Hinge2-Joint
  31757. * @param jointData The joint data for the Hinge2-Joint
  31758. */
  31759. constructor(jointData: PhysicsJointData);
  31760. /**
  31761. * Set the motor values.
  31762. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31763. * @param {number} force the force to apply
  31764. * @param {number} maxForce max force for this motor.
  31765. * @param {motorIndex} the motor's index, 0 or 1.
  31766. */
  31767. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31768. /**
  31769. * Set the motor limits.
  31770. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31771. * @param {number} upperLimit the upper limit
  31772. * @param {number} lowerLimit lower limit
  31773. * @param {motorIndex} the motor's index, 0 or 1.
  31774. */
  31775. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31776. }
  31777. /**
  31778. * Interface for a motor enabled joint
  31779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31780. */
  31781. interface IMotorEnabledJoint {
  31782. /**
  31783. * Physics joint
  31784. */
  31785. physicsJoint: any;
  31786. /**
  31787. * Sets the motor of the motor-enabled joint
  31788. * @param force The force of the motor
  31789. * @param maxForce The maximum force of the motor
  31790. * @param motorIndex The index of the motor
  31791. */
  31792. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31793. /**
  31794. * Sets the limit of the motor
  31795. * @param upperLimit The upper limit of the motor
  31796. * @param lowerLimit The lower limit of the motor
  31797. * @param motorIndex The index of the motor
  31798. */
  31799. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31800. }
  31801. /**
  31802. * Joint data for a Distance-Joint
  31803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31804. */
  31805. interface DistanceJointData extends PhysicsJointData {
  31806. /**
  31807. * Max distance the 2 joint objects can be apart
  31808. */
  31809. maxDistance: number;
  31810. }
  31811. /**
  31812. * Joint data from a spring joint
  31813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31814. */
  31815. interface SpringJointData extends PhysicsJointData {
  31816. /**
  31817. * Length of the spring
  31818. */
  31819. length: number;
  31820. /**
  31821. * Stiffness of the spring
  31822. */
  31823. stiffness: number;
  31824. /**
  31825. * Damping of the spring
  31826. */
  31827. damping: number;
  31828. /** this callback will be called when applying the force to the impostors. */
  31829. forceApplicationCallback: () => void;
  31830. }
  31831. }
  31832. declare module BABYLON {
  31833. interface AbstractScene {
  31834. /**
  31835. * The list of reflection probes added to the scene
  31836. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  31837. */
  31838. reflectionProbes: Array<ReflectionProbe>;
  31839. /**
  31840. * Removes the given reflection probe from this scene.
  31841. * @param toRemove The reflection probe to remove
  31842. * @returns The index of the removed reflection probe
  31843. */
  31844. removeReflectionProbe(toRemove: ReflectionProbe): number;
  31845. /**
  31846. * Adds the given reflection probe to this scene.
  31847. * @param newReflectionProbe The reflection probe to add
  31848. */
  31849. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  31850. }
  31851. /**
  31852. * Class used to generate realtime reflection / refraction cube textures
  31853. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  31854. */
  31855. class ReflectionProbe {
  31856. /** defines the name of the probe */
  31857. name: string;
  31858. private _scene;
  31859. private _renderTargetTexture;
  31860. private _projectionMatrix;
  31861. private _viewMatrix;
  31862. private _target;
  31863. private _add;
  31864. private _attachedMesh;
  31865. private _invertYAxis;
  31866. /** Gets or sets probe position (center of the cube map) */
  31867. position: Vector3;
  31868. /**
  31869. * Creates a new reflection probe
  31870. * @param name defines the name of the probe
  31871. * @param size defines the texture resolution (for each face)
  31872. * @param scene defines the hosting scene
  31873. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  31874. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  31875. */
  31876. constructor(
  31877. /** defines the name of the probe */
  31878. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  31879. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  31880. samples: number;
  31881. /** Gets or sets the refresh rate to use (on every frame by default) */
  31882. refreshRate: number;
  31883. /**
  31884. * Gets the hosting scene
  31885. * @returns a Scene
  31886. */
  31887. getScene(): Scene;
  31888. /** Gets the internal CubeTexture used to render to */
  31889. readonly cubeTexture: RenderTargetTexture;
  31890. /** Gets the list of meshes to render */
  31891. readonly renderList: Nullable<AbstractMesh[]>;
  31892. /**
  31893. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  31894. * @param mesh defines the mesh to attach to
  31895. */
  31896. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  31897. /**
  31898. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  31899. * @param renderingGroupId The rendering group id corresponding to its index
  31900. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  31901. */
  31902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  31903. /**
  31904. * Clean all associated resources
  31905. */
  31906. dispose(): void;
  31907. /**
  31908. * Converts the reflection probe information to a readable string for debug purpose.
  31909. * @param fullDetails Supports for multiple levels of logging within scene loading
  31910. * @returns the human readable reflection probe info
  31911. */
  31912. toString(fullDetails?: boolean): string;
  31913. /**
  31914. * Get the class name of the relfection probe.
  31915. * @returns "ReflectionProbe"
  31916. */
  31917. getClassName(): string;
  31918. /**
  31919. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  31920. * @returns The JSON representation of the texture
  31921. */
  31922. serialize(): any;
  31923. /**
  31924. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  31925. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  31926. * @param scene Define the scene the parsed reflection probe should be instantiated in
  31927. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  31928. * @returns The parsed reflection probe if successful
  31929. */
  31930. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  31931. }
  31932. }
  31933. declare module BABYLON {
  31934. /**
  31935. * This represents the base class for particle system in Babylon.
  31936. * 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.
  31937. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31938. * @example https://doc.babylonjs.com/babylon101/particles
  31939. */
  31940. class BaseParticleSystem {
  31941. /**
  31942. * Source color is added to the destination color without alpha affecting the result
  31943. */
  31944. static BLENDMODE_ONEONE: number;
  31945. /**
  31946. * Blend current color and particle color using particle’s alpha
  31947. */
  31948. static BLENDMODE_STANDARD: number;
  31949. /**
  31950. * Add current color and particle color multiplied by particle’s alpha
  31951. */
  31952. static BLENDMODE_ADD: number;
  31953. /**
  31954. * Multiply current color with particle color
  31955. */
  31956. static BLENDMODE_MULTIPLY: number;
  31957. /**
  31958. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  31959. */
  31960. static BLENDMODE_MULTIPLYADD: number;
  31961. /**
  31962. * List of animations used by the particle system.
  31963. */
  31964. animations: Animation[];
  31965. /**
  31966. * The id of the Particle system.
  31967. */
  31968. id: string;
  31969. /**
  31970. * The friendly name of the Particle system.
  31971. */
  31972. name: string;
  31973. /**
  31974. * The rendering group used by the Particle system to chose when to render.
  31975. */
  31976. renderingGroupId: number;
  31977. /**
  31978. * The emitter represents the Mesh or position we are attaching the particle system to.
  31979. */
  31980. emitter: Nullable<AbstractMesh | Vector3>;
  31981. /**
  31982. * The maximum number of particles to emit per frame
  31983. */
  31984. emitRate: number;
  31985. /**
  31986. * If you want to launch only a few particles at once, that can be done, as well.
  31987. */
  31988. manualEmitCount: number;
  31989. /**
  31990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31991. */
  31992. updateSpeed: number;
  31993. /**
  31994. * The amount of time the particle system is running (depends of the overall update speed).
  31995. */
  31996. targetStopDuration: number;
  31997. /**
  31998. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31999. */
  32000. disposeOnStop: boolean;
  32001. /**
  32002. * Minimum power of emitting particles.
  32003. */
  32004. minEmitPower: number;
  32005. /**
  32006. * Maximum power of emitting particles.
  32007. */
  32008. maxEmitPower: number;
  32009. /**
  32010. * Minimum life time of emitting particles.
  32011. */
  32012. minLifeTime: number;
  32013. /**
  32014. * Maximum life time of emitting particles.
  32015. */
  32016. maxLifeTime: number;
  32017. /**
  32018. * Minimum Size of emitting particles.
  32019. */
  32020. minSize: number;
  32021. /**
  32022. * Maximum Size of emitting particles.
  32023. */
  32024. maxSize: number;
  32025. /**
  32026. * Minimum scale of emitting particles on X axis.
  32027. */
  32028. minScaleX: number;
  32029. /**
  32030. * Maximum scale of emitting particles on X axis.
  32031. */
  32032. maxScaleX: number;
  32033. /**
  32034. * Minimum scale of emitting particles on Y axis.
  32035. */
  32036. minScaleY: number;
  32037. /**
  32038. * Maximum scale of emitting particles on Y axis.
  32039. */
  32040. maxScaleY: number;
  32041. /**
  32042. * Gets or sets the minimal initial rotation in radians.
  32043. */
  32044. minInitialRotation: number;
  32045. /**
  32046. * Gets or sets the maximal initial rotation in radians.
  32047. */
  32048. maxInitialRotation: number;
  32049. /**
  32050. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  32051. */
  32052. minAngularSpeed: number;
  32053. /**
  32054. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  32055. */
  32056. maxAngularSpeed: number;
  32057. /**
  32058. * The texture used to render each particle. (this can be a spritesheet)
  32059. */
  32060. particleTexture: Nullable<Texture>;
  32061. /**
  32062. * The layer mask we are rendering the particles through.
  32063. */
  32064. layerMask: number;
  32065. /**
  32066. * This can help using your own shader to render the particle system.
  32067. * The according effect will be created
  32068. */
  32069. customShader: any;
  32070. /**
  32071. * By default particle system starts as soon as they are created. This prevents the
  32072. * automatic start to happen and let you decide when to start emitting particles.
  32073. */
  32074. preventAutoStart: boolean;
  32075. private _noiseTexture;
  32076. /**
  32077. * Gets or sets a texture used to add random noise to particle positions
  32078. */
  32079. noiseTexture: Nullable<ProceduralTexture>;
  32080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32081. noiseStrength: Vector3;
  32082. /**
  32083. * Callback triggered when the particle animation is ending.
  32084. */
  32085. onAnimationEnd: Nullable<() => void>;
  32086. /**
  32087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  32088. */
  32089. blendMode: number;
  32090. /**
  32091. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  32092. * to override the particles.
  32093. */
  32094. forceDepthWrite: boolean;
  32095. /** 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 */
  32096. preWarmCycles: number;
  32097. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  32098. preWarmStepOffset: number;
  32099. /**
  32100. * 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)
  32101. */
  32102. spriteCellChangeSpeed: number;
  32103. /**
  32104. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32105. */
  32106. startSpriteCellID: number;
  32107. /**
  32108. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32109. */
  32110. endSpriteCellID: number;
  32111. /**
  32112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32113. */
  32114. spriteCellWidth: number;
  32115. /**
  32116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32117. */
  32118. spriteCellHeight: number;
  32119. /**
  32120. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32121. */
  32122. spriteRandomStartCell: boolean;
  32123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32124. translationPivot: Vector2;
  32125. /** @hidden */
  32126. protected _isAnimationSheetEnabled: boolean;
  32127. /**
  32128. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32129. */
  32130. beginAnimationOnStart: boolean;
  32131. /**
  32132. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32133. */
  32134. beginAnimationFrom: number;
  32135. /**
  32136. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32137. */
  32138. beginAnimationTo: number;
  32139. /**
  32140. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32141. */
  32142. beginAnimationLoop: boolean;
  32143. /**
  32144. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  32145. */
  32146. isAnimationSheetEnabled: boolean;
  32147. /**
  32148. * Get hosting scene
  32149. * @returns the scene
  32150. */
  32151. getScene(): Scene;
  32152. /**
  32153. * You can use gravity if you want to give an orientation to your particles.
  32154. */
  32155. gravity: Vector3;
  32156. protected _colorGradients: Nullable<Array<ColorGradient>>;
  32157. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  32158. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  32159. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  32160. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  32161. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  32162. protected _dragGradients: Nullable<Array<FactorGradient>>;
  32163. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  32164. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  32165. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  32166. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  32167. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  32168. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  32169. /**
  32170. * Defines the delay in milliseconds before starting the system (0 by default)
  32171. */
  32172. startDelay: number;
  32173. /**
  32174. * Gets the current list of drag gradients.
  32175. * You must use addDragGradient and removeDragGradient to udpate this list
  32176. * @returns the list of drag gradients
  32177. */
  32178. getDragGradients(): Nullable<Array<FactorGradient>>;
  32179. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32180. limitVelocityDamping: number;
  32181. /**
  32182. * Gets the current list of limit velocity gradients.
  32183. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32184. * @returns the list of limit velocity gradients
  32185. */
  32186. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32187. /**
  32188. * Gets the current list of color gradients.
  32189. * You must use addColorGradient and removeColorGradient to udpate this list
  32190. * @returns the list of color gradients
  32191. */
  32192. getColorGradients(): Nullable<Array<ColorGradient>>;
  32193. /**
  32194. * Gets the current list of size gradients.
  32195. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32196. * @returns the list of size gradients
  32197. */
  32198. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32199. /**
  32200. * Gets the current list of color remap gradients.
  32201. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  32202. * @returns the list of color remap gradients
  32203. */
  32204. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  32205. /**
  32206. * Gets the current list of alpha remap gradients.
  32207. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  32208. * @returns the list of alpha remap gradients
  32209. */
  32210. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  32211. /**
  32212. * Gets the current list of life time gradients.
  32213. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  32214. * @returns the list of life time gradients
  32215. */
  32216. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  32217. /**
  32218. * Gets the current list of angular speed gradients.
  32219. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32220. * @returns the list of angular speed gradients
  32221. */
  32222. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32223. /**
  32224. * Gets the current list of velocity gradients.
  32225. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32226. * @returns the list of velocity gradients
  32227. */
  32228. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32229. /**
  32230. * Gets the current list of start size gradients.
  32231. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32232. * @returns the list of start size gradients
  32233. */
  32234. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32235. /**
  32236. * Gets the current list of emit rate gradients.
  32237. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32238. * @returns the list of emit rate gradients
  32239. */
  32240. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32241. /**
  32242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32243. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32244. */
  32245. direction1: Vector3;
  32246. /**
  32247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32248. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32249. */
  32250. direction2: Vector3;
  32251. /**
  32252. * 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.
  32253. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32254. */
  32255. minEmitBox: Vector3;
  32256. /**
  32257. * 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.
  32258. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32259. */
  32260. maxEmitBox: Vector3;
  32261. /**
  32262. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  32263. */
  32264. color1: Color4;
  32265. /**
  32266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  32267. */
  32268. color2: Color4;
  32269. /**
  32270. * Color the particle will have at the end of its lifetime
  32271. */
  32272. colorDead: Color4;
  32273. /**
  32274. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  32275. */
  32276. textureMask: Color4;
  32277. /**
  32278. * The particle emitter type defines the emitter used by the particle system.
  32279. * It can be for example box, sphere, or cone...
  32280. */
  32281. particleEmitterType: IParticleEmitterType;
  32282. /** @hidden */
  32283. _isSubEmitter: boolean;
  32284. /**
  32285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32287. */
  32288. billboardMode: number;
  32289. protected _isBillboardBased: boolean;
  32290. /**
  32291. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32292. */
  32293. isBillboardBased: boolean;
  32294. /**
  32295. * The scene the particle system belongs to.
  32296. */
  32297. protected _scene: Scene;
  32298. /**
  32299. * Local cache of defines for image processing.
  32300. */
  32301. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  32302. /**
  32303. * Default configuration related to image processing available in the standard Material.
  32304. */
  32305. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32306. /**
  32307. * Gets the image processing configuration used either in this material.
  32308. */
  32309. /**
  32310. * Sets the Default image processing configuration used either in the this material.
  32311. *
  32312. * If sets to null, the scene one is in use.
  32313. */
  32314. imageProcessingConfiguration: ImageProcessingConfiguration;
  32315. /**
  32316. * Attaches a new image processing configuration to the Standard Material.
  32317. * @param configuration
  32318. */
  32319. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32320. /** @hidden */
  32321. protected _reset(): void;
  32322. /** @hidden */
  32323. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  32324. /**
  32325. * Instantiates a particle system.
  32326. * 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.
  32327. * @param name The name of the particle system
  32328. */
  32329. constructor(name: string);
  32330. /**
  32331. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  32332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32334. * @returns the emitter
  32335. */
  32336. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  32337. /**
  32338. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  32339. * @param radius The radius of the hemisphere to emit from
  32340. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32341. * @returns the emitter
  32342. */
  32343. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  32344. /**
  32345. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  32346. * @param radius The radius of the sphere to emit from
  32347. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32348. * @returns the emitter
  32349. */
  32350. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  32351. /**
  32352. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  32353. * @param radius The radius of the sphere to emit from
  32354. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  32355. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  32356. * @returns the emitter
  32357. */
  32358. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  32359. /**
  32360. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  32361. * @param radius The radius of the emission cylinder
  32362. * @param height The height of the emission cylinder
  32363. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  32364. * @param directionRandomizer How much to randomize the particle direction [0-1]
  32365. * @returns the emitter
  32366. */
  32367. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  32368. /**
  32369. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  32370. * @param radius The radius of the cylinder to emit from
  32371. * @param height The height of the emission cylinder
  32372. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  32373. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  32374. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  32375. * @returns the emitter
  32376. */
  32377. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  32378. /**
  32379. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  32380. * @param radius The radius of the cone to emit from
  32381. * @param angle The base angle of the cone
  32382. * @returns the emitter
  32383. */
  32384. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  32385. /**
  32386. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  32387. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32388. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32389. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32390. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32391. * @returns the emitter
  32392. */
  32393. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  32394. }
  32395. }
  32396. declare module BABYLON {
  32397. /**
  32398. * This represents a GPU particle system in Babylon
  32399. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  32400. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  32401. */
  32402. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  32403. /**
  32404. * The layer mask we are rendering the particles through.
  32405. */
  32406. layerMask: number;
  32407. private _capacity;
  32408. private _activeCount;
  32409. private _currentActiveCount;
  32410. private _accumulatedCount;
  32411. private _renderEffect;
  32412. private _updateEffect;
  32413. private _buffer0;
  32414. private _buffer1;
  32415. private _spriteBuffer;
  32416. private _updateVAO;
  32417. private _renderVAO;
  32418. private _targetIndex;
  32419. private _sourceBuffer;
  32420. private _targetBuffer;
  32421. private _engine;
  32422. private _currentRenderId;
  32423. private _started;
  32424. private _stopped;
  32425. private _timeDelta;
  32426. private _randomTexture;
  32427. private _randomTexture2;
  32428. private _attributesStrideSize;
  32429. private _updateEffectOptions;
  32430. private _randomTextureSize;
  32431. private _actualFrame;
  32432. private readonly _rawTextureWidth;
  32433. /**
  32434. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  32435. */
  32436. static readonly IsSupported: boolean;
  32437. /**
  32438. * An event triggered when the system is disposed.
  32439. */
  32440. onDisposeObservable: Observable<GPUParticleSystem>;
  32441. /**
  32442. * Gets the maximum number of particles active at the same time.
  32443. * @returns The max number of active particles.
  32444. */
  32445. getCapacity(): number;
  32446. /**
  32447. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  32448. * to override the particles.
  32449. */
  32450. forceDepthWrite: boolean;
  32451. /**
  32452. * Gets or set the number of active particles
  32453. */
  32454. activeParticleCount: number;
  32455. private _preWarmDone;
  32456. /**
  32457. * Is this system ready to be used/rendered
  32458. * @return true if the system is ready
  32459. */
  32460. isReady(): boolean;
  32461. /**
  32462. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32463. * @returns True if it has been started, otherwise false.
  32464. */
  32465. isStarted(): boolean;
  32466. /**
  32467. * Starts the particle system and begins to emit
  32468. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32469. */
  32470. start(delay?: number): void;
  32471. /**
  32472. * Stops the particle system.
  32473. */
  32474. stop(): void;
  32475. /**
  32476. * Remove all active particles
  32477. */
  32478. reset(): void;
  32479. /**
  32480. * Returns the string "GPUParticleSystem"
  32481. * @returns a string containing the class name
  32482. */
  32483. getClassName(): string;
  32484. private _colorGradientsTexture;
  32485. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  32486. /**
  32487. * Adds a new color gradient
  32488. * @param gradient defines the gradient to use (between 0 and 1)
  32489. * @param color1 defines the color to affect to the specified gradient
  32490. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32491. * @returns the current particle system
  32492. */
  32493. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  32494. /**
  32495. * Remove a specific color gradient
  32496. * @param gradient defines the gradient to remove
  32497. * @returns the current particle system
  32498. */
  32499. removeColorGradient(gradient: number): GPUParticleSystem;
  32500. private _angularSpeedGradientsTexture;
  32501. private _sizeGradientsTexture;
  32502. private _velocityGradientsTexture;
  32503. private _limitVelocityGradientsTexture;
  32504. private _dragGradientsTexture;
  32505. private _addFactorGradient;
  32506. /**
  32507. * Adds a new size gradient
  32508. * @param gradient defines the gradient to use (between 0 and 1)
  32509. * @param factor defines the size factor to affect to the specified gradient
  32510. * @returns the current particle system
  32511. */
  32512. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  32513. /**
  32514. * Remove a specific size gradient
  32515. * @param gradient defines the gradient to remove
  32516. * @returns the current particle system
  32517. */
  32518. removeSizeGradient(gradient: number): GPUParticleSystem;
  32519. /**
  32520. * Adds a new angular speed gradient
  32521. * @param gradient defines the gradient to use (between 0 and 1)
  32522. * @param factor defines the angular speed to affect to the specified gradient
  32523. * @returns the current particle system
  32524. */
  32525. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  32526. /**
  32527. * Remove a specific angular speed gradient
  32528. * @param gradient defines the gradient to remove
  32529. * @returns the current particle system
  32530. */
  32531. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  32532. /**
  32533. * Adds a new velocity gradient
  32534. * @param gradient defines the gradient to use (between 0 and 1)
  32535. * @param factor defines the velocity to affect to the specified gradient
  32536. * @returns the current particle system
  32537. */
  32538. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  32539. /**
  32540. * Remove a specific velocity gradient
  32541. * @param gradient defines the gradient to remove
  32542. * @returns the current particle system
  32543. */
  32544. removeVelocityGradient(gradient: number): GPUParticleSystem;
  32545. /**
  32546. * Adds a new limit velocity gradient
  32547. * @param gradient defines the gradient to use (between 0 and 1)
  32548. * @param factor defines the limit velocity value to affect to the specified gradient
  32549. * @returns the current particle system
  32550. */
  32551. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  32552. /**
  32553. * Remove a specific limit velocity gradient
  32554. * @param gradient defines the gradient to remove
  32555. * @returns the current particle system
  32556. */
  32557. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  32558. /**
  32559. * Adds a new drag gradient
  32560. * @param gradient defines the gradient to use (between 0 and 1)
  32561. * @param factor defines the drag value to affect to the specified gradient
  32562. * @returns the current particle system
  32563. */
  32564. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  32565. /**
  32566. * Remove a specific drag gradient
  32567. * @param gradient defines the gradient to remove
  32568. * @returns the current particle system
  32569. */
  32570. removeDragGradient(gradient: number): GPUParticleSystem;
  32571. /**
  32572. * Not supported by GPUParticleSystem
  32573. * @param gradient defines the gradient to use (between 0 and 1)
  32574. * @param factor defines the emit rate value to affect to the specified gradient
  32575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32576. * @returns the current particle system
  32577. */
  32578. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32579. /**
  32580. * Not supported by GPUParticleSystem
  32581. * @param gradient defines the gradient to remove
  32582. * @returns the current particle system
  32583. */
  32584. removeEmitRateGradient(gradient: number): IParticleSystem;
  32585. /**
  32586. * Not supported by GPUParticleSystem
  32587. * @param gradient defines the gradient to use (between 0 and 1)
  32588. * @param factor defines the start size value to affect to the specified gradient
  32589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32590. * @returns the current particle system
  32591. */
  32592. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32593. /**
  32594. * Not supported by GPUParticleSystem
  32595. * @param gradient defines the gradient to remove
  32596. * @returns the current particle system
  32597. */
  32598. removeStartSizeGradient(gradient: number): IParticleSystem;
  32599. /**
  32600. * Not supported by GPUParticleSystem
  32601. * @param gradient defines the gradient to use (between 0 and 1)
  32602. * @param min defines the color remap minimal range
  32603. * @param max defines the color remap maximal range
  32604. * @returns the current particle system
  32605. */
  32606. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32607. /**
  32608. * Not supported by GPUParticleSystem
  32609. * @param gradient defines the gradient to remove
  32610. * @returns the current particle system
  32611. */
  32612. removeColorRemapGradient(gradient: number): IParticleSystem;
  32613. /**
  32614. * Not supported by GPUParticleSystem
  32615. * @param gradient defines the gradient to use (between 0 and 1)
  32616. * @param min defines the alpha remap minimal range
  32617. * @param max defines the alpha remap maximal range
  32618. * @returns the current particle system
  32619. */
  32620. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32621. /**
  32622. * Not supported by GPUParticleSystem
  32623. * @param gradient defines the gradient to remove
  32624. * @returns the current particle system
  32625. */
  32626. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32627. /**
  32628. * Not supported by GPUParticleSystem
  32629. * @param gradient defines the gradient to use (between 0 and 1)
  32630. * @param color defines the color to affect to the specified gradient
  32631. * @returns the current particle system
  32632. */
  32633. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32634. /**
  32635. * Not supported by GPUParticleSystem
  32636. * @param gradient defines the gradient to remove
  32637. * @returns the current particle system
  32638. */
  32639. removeRampGradient(gradient: number): IParticleSystem;
  32640. /**
  32641. * Not supported by GPUParticleSystem
  32642. * @returns the list of ramp gradients
  32643. */
  32644. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32645. /**
  32646. * Not supported by GPUParticleSystem
  32647. * Gets or sets a boolean indicating that ramp gradients must be used
  32648. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32649. */
  32650. useRampGradients: boolean;
  32651. /**
  32652. * Not supported by GPUParticleSystem
  32653. * @param gradient defines the gradient to use (between 0 and 1)
  32654. * @param factor defines the life time factor to affect to the specified gradient
  32655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32656. * @returns the current particle system
  32657. */
  32658. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32659. /**
  32660. * Not supported by GPUParticleSystem
  32661. * @param gradient defines the gradient to remove
  32662. * @returns the current particle system
  32663. */
  32664. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32665. /**
  32666. * Instantiates a GPU particle system.
  32667. * 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.
  32668. * @param name The name of the particle system
  32669. * @param options The options used to create the system
  32670. * @param scene The scene the particle system belongs to
  32671. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32672. */
  32673. constructor(name: string, options: Partial<{
  32674. capacity: number;
  32675. randomTextureSize: number;
  32676. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  32677. protected _reset(): void;
  32678. private _createUpdateVAO;
  32679. private _createRenderVAO;
  32680. private _initialize;
  32681. /** @hidden */
  32682. _recreateUpdateEffect(): void;
  32683. /** @hidden */
  32684. _recreateRenderEffect(): void;
  32685. /**
  32686. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32687. * @param preWarm defines if we are in the pre-warmimg phase
  32688. */
  32689. animate(preWarm?: boolean): void;
  32690. private _createFactorGradientTexture;
  32691. private _createSizeGradientTexture;
  32692. private _createAngularSpeedGradientTexture;
  32693. private _createVelocityGradientTexture;
  32694. private _createLimitVelocityGradientTexture;
  32695. private _createDragGradientTexture;
  32696. private _createColorGradientTexture;
  32697. /**
  32698. * Renders the particle system in its current state
  32699. * @param preWarm defines if the system should only update the particles but not render them
  32700. * @returns the current number of particles
  32701. */
  32702. render(preWarm?: boolean): number;
  32703. /**
  32704. * Rebuilds the particle system
  32705. */
  32706. rebuild(): void;
  32707. private _releaseBuffers;
  32708. private _releaseVAOs;
  32709. /**
  32710. * Disposes the particle system and free the associated resources
  32711. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32712. */
  32713. dispose(disposeTexture?: boolean): void;
  32714. /**
  32715. * Clones the particle system.
  32716. * @param name The name of the cloned object
  32717. * @param newEmitter The new emitter to use
  32718. * @returns the cloned particle system
  32719. */
  32720. clone(name: string, newEmitter: any): GPUParticleSystem;
  32721. /**
  32722. * Serializes the particle system to a JSON object.
  32723. * @returns the JSON object
  32724. */
  32725. serialize(): any;
  32726. /**
  32727. * Parses a JSON object to create a GPU particle system.
  32728. * @param parsedParticleSystem The JSON object to parse
  32729. * @param scene The scene to create the particle system in
  32730. * @param rootUrl The root url to use to load external dependencies like texture
  32731. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32732. * @returns the parsed GPU particle system
  32733. */
  32734. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  32735. }
  32736. }
  32737. declare module BABYLON {
  32738. /**
  32739. * Interface representing a particle system in Babylon.js.
  32740. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  32741. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  32742. */
  32743. interface IParticleSystem {
  32744. /**
  32745. * List of animations used by the particle system.
  32746. */
  32747. animations: Animation[];
  32748. /**
  32749. * The id of the Particle system.
  32750. */
  32751. id: string;
  32752. /**
  32753. * The name of the Particle system.
  32754. */
  32755. name: string;
  32756. /**
  32757. * The emitter represents the Mesh or position we are attaching the particle system to.
  32758. */
  32759. emitter: Nullable<AbstractMesh | Vector3>;
  32760. /**
  32761. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32762. */
  32763. isBillboardBased: boolean;
  32764. /**
  32765. * The rendering group used by the Particle system to chose when to render.
  32766. */
  32767. renderingGroupId: number;
  32768. /**
  32769. * The layer mask we are rendering the particles through.
  32770. */
  32771. layerMask: number;
  32772. /**
  32773. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  32774. */
  32775. updateSpeed: number;
  32776. /**
  32777. * The amount of time the particle system is running (depends of the overall update speed).
  32778. */
  32779. targetStopDuration: number;
  32780. /**
  32781. * The texture used to render each particle. (this can be a spritesheet)
  32782. */
  32783. particleTexture: Nullable<Texture>;
  32784. /**
  32785. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  32786. */
  32787. blendMode: number;
  32788. /**
  32789. * Minimum life time of emitting particles.
  32790. */
  32791. minLifeTime: number;
  32792. /**
  32793. * Maximum life time of emitting particles.
  32794. */
  32795. maxLifeTime: number;
  32796. /**
  32797. * Minimum Size of emitting particles.
  32798. */
  32799. minSize: number;
  32800. /**
  32801. * Maximum Size of emitting particles.
  32802. */
  32803. maxSize: number;
  32804. /**
  32805. * Minimum scale of emitting particles on X axis.
  32806. */
  32807. minScaleX: number;
  32808. /**
  32809. * Maximum scale of emitting particles on X axis.
  32810. */
  32811. maxScaleX: number;
  32812. /**
  32813. * Minimum scale of emitting particles on Y axis.
  32814. */
  32815. minScaleY: number;
  32816. /**
  32817. * Maximum scale of emitting particles on Y axis.
  32818. */
  32819. maxScaleY: number;
  32820. /**
  32821. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32822. */
  32823. color1: Color4;
  32824. /**
  32825. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32826. */
  32827. color2: Color4;
  32828. /**
  32829. * Color the particle will have at the end of its lifetime.
  32830. */
  32831. colorDead: Color4;
  32832. /**
  32833. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  32834. */
  32835. emitRate: number;
  32836. /**
  32837. * You can use gravity if you want to give an orientation to your particles.
  32838. */
  32839. gravity: Vector3;
  32840. /**
  32841. * Minimum power of emitting particles.
  32842. */
  32843. minEmitPower: number;
  32844. /**
  32845. * Maximum power of emitting particles.
  32846. */
  32847. maxEmitPower: number;
  32848. /**
  32849. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  32850. */
  32851. minAngularSpeed: number;
  32852. /**
  32853. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  32854. */
  32855. maxAngularSpeed: number;
  32856. /**
  32857. * Gets or sets the minimal initial rotation in radians.
  32858. */
  32859. minInitialRotation: number;
  32860. /**
  32861. * Gets or sets the maximal initial rotation in radians.
  32862. */
  32863. maxInitialRotation: number;
  32864. /**
  32865. * The particle emitter type defines the emitter used by the particle system.
  32866. * It can be for example box, sphere, or cone...
  32867. */
  32868. particleEmitterType: Nullable<IParticleEmitterType>;
  32869. /**
  32870. * Defines the delay in milliseconds before starting the system (0 by default)
  32871. */
  32872. startDelay: number;
  32873. /**
  32874. * 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
  32875. */
  32876. preWarmCycles: number;
  32877. /**
  32878. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  32879. */
  32880. preWarmStepOffset: number;
  32881. /**
  32882. * 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)
  32883. */
  32884. spriteCellChangeSpeed: number;
  32885. /**
  32886. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32887. */
  32888. startSpriteCellID: number;
  32889. /**
  32890. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32891. */
  32892. endSpriteCellID: number;
  32893. /**
  32894. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32895. */
  32896. spriteCellWidth: number;
  32897. /**
  32898. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32899. */
  32900. spriteCellHeight: number;
  32901. /**
  32902. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32903. */
  32904. spriteRandomStartCell: boolean;
  32905. /**
  32906. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  32907. */
  32908. isAnimationSheetEnabled: boolean;
  32909. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32910. translationPivot: Vector2;
  32911. /**
  32912. * Gets or sets a texture used to add random noise to particle positions
  32913. */
  32914. noiseTexture: Nullable<BaseTexture>;
  32915. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32916. noiseStrength: Vector3;
  32917. /**
  32918. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32919. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32920. */
  32921. billboardMode: number;
  32922. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32923. limitVelocityDamping: number;
  32924. /**
  32925. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32926. */
  32927. beginAnimationOnStart: boolean;
  32928. /**
  32929. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32930. */
  32931. beginAnimationFrom: number;
  32932. /**
  32933. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32934. */
  32935. beginAnimationTo: number;
  32936. /**
  32937. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32938. */
  32939. beginAnimationLoop: boolean;
  32940. /**
  32941. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  32942. */
  32943. disposeOnStop: boolean;
  32944. /**
  32945. * Gets the maximum number of particles active at the same time.
  32946. * @returns The max number of active particles.
  32947. */
  32948. getCapacity(): number;
  32949. /**
  32950. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32951. * @returns True if it has been started, otherwise false.
  32952. */
  32953. isStarted(): boolean;
  32954. /**
  32955. * Animates the particle system for this frame.
  32956. */
  32957. animate(): void;
  32958. /**
  32959. * Renders the particle system in its current state.
  32960. * @returns the current number of particles
  32961. */
  32962. render(): number;
  32963. /**
  32964. * Dispose the particle system and frees its associated resources.
  32965. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32966. */
  32967. dispose(disposeTexture?: boolean): void;
  32968. /**
  32969. * Clones the particle system.
  32970. * @param name The name of the cloned object
  32971. * @param newEmitter The new emitter to use
  32972. * @returns the cloned particle system
  32973. */
  32974. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  32975. /**
  32976. * Serializes the particle system to a JSON object.
  32977. * @returns the JSON object
  32978. */
  32979. serialize(): any;
  32980. /**
  32981. * Rebuild the particle system
  32982. */
  32983. rebuild(): void;
  32984. /**
  32985. * Starts the particle system and begins to emit
  32986. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  32987. */
  32988. start(delay?: number): void;
  32989. /**
  32990. * Stops the particle system.
  32991. */
  32992. stop(): void;
  32993. /**
  32994. * Remove all active particles
  32995. */
  32996. reset(): void;
  32997. /**
  32998. * Is this system ready to be used/rendered
  32999. * @return true if the system is ready
  33000. */
  33001. isReady(): boolean;
  33002. /**
  33003. * Adds a new color gradient
  33004. * @param gradient defines the gradient to use (between 0 and 1)
  33005. * @param color1 defines the color to affect to the specified gradient
  33006. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  33007. * @returns the current particle system
  33008. */
  33009. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  33010. /**
  33011. * Remove a specific color gradient
  33012. * @param gradient defines the gradient to remove
  33013. * @returns the current particle system
  33014. */
  33015. removeColorGradient(gradient: number): IParticleSystem;
  33016. /**
  33017. * Adds a new size gradient
  33018. * @param gradient defines the gradient to use (between 0 and 1)
  33019. * @param factor defines the size factor to affect to the specified gradient
  33020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33021. * @returns the current particle system
  33022. */
  33023. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33024. /**
  33025. * Remove a specific size gradient
  33026. * @param gradient defines the gradient to remove
  33027. * @returns the current particle system
  33028. */
  33029. removeSizeGradient(gradient: number): IParticleSystem;
  33030. /**
  33031. * Gets the current list of color gradients.
  33032. * You must use addColorGradient and removeColorGradient to udpate this list
  33033. * @returns the list of color gradients
  33034. */
  33035. getColorGradients(): Nullable<Array<ColorGradient>>;
  33036. /**
  33037. * Gets the current list of size gradients.
  33038. * You must use addSizeGradient and removeSizeGradient to udpate this list
  33039. * @returns the list of size gradients
  33040. */
  33041. getSizeGradients(): Nullable<Array<FactorGradient>>;
  33042. /**
  33043. * Gets the current list of angular speed gradients.
  33044. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  33045. * @returns the list of angular speed gradients
  33046. */
  33047. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  33048. /**
  33049. * Adds a new angular speed gradient
  33050. * @param gradient defines the gradient to use (between 0 and 1)
  33051. * @param factor defines the angular speed to affect to the specified gradient
  33052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33053. * @returns the current particle system
  33054. */
  33055. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33056. /**
  33057. * Remove a specific angular speed gradient
  33058. * @param gradient defines the gradient to remove
  33059. * @returns the current particle system
  33060. */
  33061. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  33062. /**
  33063. * Gets the current list of velocity gradients.
  33064. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  33065. * @returns the list of velocity gradients
  33066. */
  33067. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  33068. /**
  33069. * Adds a new velocity gradient
  33070. * @param gradient defines the gradient to use (between 0 and 1)
  33071. * @param factor defines the velocity to affect to the specified gradient
  33072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33073. * @returns the current particle system
  33074. */
  33075. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33076. /**
  33077. * Remove a specific velocity gradient
  33078. * @param gradient defines the gradient to remove
  33079. * @returns the current particle system
  33080. */
  33081. removeVelocityGradient(gradient: number): IParticleSystem;
  33082. /**
  33083. * Gets the current list of limit velocity gradients.
  33084. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  33085. * @returns the list of limit velocity gradients
  33086. */
  33087. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  33088. /**
  33089. * Adds a new limit velocity gradient
  33090. * @param gradient defines the gradient to use (between 0 and 1)
  33091. * @param factor defines the limit velocity to affect to the specified gradient
  33092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33093. * @returns the current particle system
  33094. */
  33095. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33096. /**
  33097. * Remove a specific limit velocity gradient
  33098. * @param gradient defines the gradient to remove
  33099. * @returns the current particle system
  33100. */
  33101. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33102. /**
  33103. * Adds a new drag gradient
  33104. * @param gradient defines the gradient to use (between 0 and 1)
  33105. * @param factor defines the drag to affect to the specified gradient
  33106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33107. * @returns the current particle system
  33108. */
  33109. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33110. /**
  33111. * Remove a specific drag gradient
  33112. * @param gradient defines the gradient to remove
  33113. * @returns the current particle system
  33114. */
  33115. removeDragGradient(gradient: number): IParticleSystem;
  33116. /**
  33117. * Gets the current list of drag gradients.
  33118. * You must use addDragGradient and removeDragGradient to udpate this list
  33119. * @returns the list of drag gradients
  33120. */
  33121. getDragGradients(): Nullable<Array<FactorGradient>>;
  33122. /**
  33123. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33124. * @param gradient defines the gradient to use (between 0 and 1)
  33125. * @param factor defines the emit rate to affect to the specified gradient
  33126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33127. * @returns the current particle system
  33128. */
  33129. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33130. /**
  33131. * Remove a specific emit rate gradient
  33132. * @param gradient defines the gradient to remove
  33133. * @returns the current particle system
  33134. */
  33135. removeEmitRateGradient(gradient: number): IParticleSystem;
  33136. /**
  33137. * Gets the current list of emit rate gradients.
  33138. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  33139. * @returns the list of emit rate gradients
  33140. */
  33141. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  33142. /**
  33143. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33144. * @param gradient defines the gradient to use (between 0 and 1)
  33145. * @param factor defines the start size to affect to the specified gradient
  33146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33147. * @returns the current particle system
  33148. */
  33149. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33150. /**
  33151. * Remove a specific start size gradient
  33152. * @param gradient defines the gradient to remove
  33153. * @returns the current particle system
  33154. */
  33155. removeStartSizeGradient(gradient: number): IParticleSystem;
  33156. /**
  33157. * Gets the current list of start size gradients.
  33158. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  33159. * @returns the list of start size gradients
  33160. */
  33161. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  33162. /**
  33163. * Adds a new life time gradient
  33164. * @param gradient defines the gradient to use (between 0 and 1)
  33165. * @param factor defines the life time factor to affect to the specified gradient
  33166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33167. * @returns the current particle system
  33168. */
  33169. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33170. /**
  33171. * Remove a specific life time gradient
  33172. * @param gradient defines the gradient to remove
  33173. * @returns the current particle system
  33174. */
  33175. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33176. /**
  33177. * Gets the current list of life time gradients.
  33178. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  33179. * @returns the list of life time gradients
  33180. */
  33181. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  33182. /**
  33183. * Gets the current list of color gradients.
  33184. * You must use addColorGradient and removeColorGradient to udpate this list
  33185. * @returns the list of color gradients
  33186. */
  33187. getColorGradients(): Nullable<Array<ColorGradient>>;
  33188. /**
  33189. * Adds a new ramp gradient used to remap particle colors
  33190. * @param gradient defines the gradient to use (between 0 and 1)
  33191. * @param color defines the color to affect to the specified gradient
  33192. * @returns the current particle system
  33193. */
  33194. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  33195. /**
  33196. * Gets the current list of ramp gradients.
  33197. * You must use addRampGradient and removeRampGradient to udpate this list
  33198. * @returns the list of ramp gradients
  33199. */
  33200. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33201. /** Gets or sets a boolean indicating that ramp gradients must be used
  33202. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  33203. */
  33204. useRampGradients: boolean;
  33205. /**
  33206. * Adds a new color remap gradient
  33207. * @param gradient defines the gradient to use (between 0 and 1)
  33208. * @param min defines the color remap minimal range
  33209. * @param max defines the color remap maximal range
  33210. * @returns the current particle system
  33211. */
  33212. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33213. /**
  33214. * Gets the current list of color remap gradients.
  33215. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  33216. * @returns the list of color remap gradients
  33217. */
  33218. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  33219. /**
  33220. * Adds a new alpha remap gradient
  33221. * @param gradient defines the gradient to use (between 0 and 1)
  33222. * @param min defines the alpha remap minimal range
  33223. * @param max defines the alpha remap maximal range
  33224. * @returns the current particle system
  33225. */
  33226. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33227. /**
  33228. * Gets the current list of alpha remap gradients.
  33229. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  33230. * @returns the list of alpha remap gradients
  33231. */
  33232. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  33233. /**
  33234. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  33235. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  33236. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  33237. * @returns the emitter
  33238. */
  33239. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  33240. /**
  33241. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  33242. * @param radius The radius of the hemisphere to emit from
  33243. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  33244. * @returns the emitter
  33245. */
  33246. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  33247. /**
  33248. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  33249. * @param radius The radius of the sphere to emit from
  33250. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  33251. * @returns the emitter
  33252. */
  33253. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  33254. /**
  33255. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  33256. * @param radius The radius of the sphere to emit from
  33257. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  33258. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  33259. * @returns the emitter
  33260. */
  33261. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  33262. /**
  33263. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  33264. * @param radius The radius of the emission cylinder
  33265. * @param height The height of the emission cylinder
  33266. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  33267. * @param directionRandomizer How much to randomize the particle direction [0-1]
  33268. * @returns the emitter
  33269. */
  33270. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  33271. /**
  33272. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  33273. * @param radius The radius of the cylinder to emit from
  33274. * @param height The height of the emission cylinder
  33275. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  33276. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  33277. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  33278. * @returns the emitter
  33279. */
  33280. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  33281. /**
  33282. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  33283. * @param radius The radius of the cone to emit from
  33284. * @param angle The base angle of the cone
  33285. * @returns the emitter
  33286. */
  33287. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  33288. /**
  33289. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  33290. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  33291. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  33292. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  33293. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  33294. * @returns the emitter
  33295. */
  33296. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  33297. /**
  33298. * Get hosting scene
  33299. * @returns the scene
  33300. */
  33301. getScene(): Scene;
  33302. }
  33303. }
  33304. declare module BABYLON {
  33305. /**
  33306. * A particle represents one of the element emitted by a particle system.
  33307. * This is mainly define by its coordinates, direction, velocity and age.
  33308. */
  33309. class Particle {
  33310. /**
  33311. * The particle system the particle belongs to.
  33312. */
  33313. particleSystem: ParticleSystem;
  33314. private static _Count;
  33315. /**
  33316. * Unique ID of the particle
  33317. */
  33318. id: number;
  33319. /**
  33320. * The world position of the particle in the scene.
  33321. */
  33322. position: Vector3;
  33323. /**
  33324. * The world direction of the particle in the scene.
  33325. */
  33326. direction: Vector3;
  33327. /**
  33328. * The color of the particle.
  33329. */
  33330. color: Color4;
  33331. /**
  33332. * The color change of the particle per step.
  33333. */
  33334. colorStep: Color4;
  33335. /**
  33336. * Defines how long will the life of the particle be.
  33337. */
  33338. lifeTime: number;
  33339. /**
  33340. * The current age of the particle.
  33341. */
  33342. age: number;
  33343. /**
  33344. * The current size of the particle.
  33345. */
  33346. size: number;
  33347. /**
  33348. * The current scale of the particle.
  33349. */
  33350. scale: Vector2;
  33351. /**
  33352. * The current angle of the particle.
  33353. */
  33354. angle: number;
  33355. /**
  33356. * Defines how fast is the angle changing.
  33357. */
  33358. angularSpeed: number;
  33359. /**
  33360. * Defines the cell index used by the particle to be rendered from a sprite.
  33361. */
  33362. cellIndex: number;
  33363. /**
  33364. * The information required to support color remapping
  33365. */
  33366. remapData: Vector4;
  33367. /** @hidden */
  33368. _randomCellOffset?: number;
  33369. /** @hidden */
  33370. _initialDirection: Nullable<Vector3>;
  33371. /** @hidden */
  33372. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  33373. /** @hidden */
  33374. _initialStartSpriteCellID: number;
  33375. /** @hidden */
  33376. _initialEndSpriteCellID: number;
  33377. /** @hidden */
  33378. _currentColorGradient: Nullable<ColorGradient>;
  33379. /** @hidden */
  33380. _currentColor1: Color4;
  33381. /** @hidden */
  33382. _currentColor2: Color4;
  33383. /** @hidden */
  33384. _currentSizeGradient: Nullable<FactorGradient>;
  33385. /** @hidden */
  33386. _currentSize1: number;
  33387. /** @hidden */
  33388. _currentSize2: number;
  33389. /** @hidden */
  33390. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  33391. /** @hidden */
  33392. _currentAngularSpeed1: number;
  33393. /** @hidden */
  33394. _currentAngularSpeed2: number;
  33395. /** @hidden */
  33396. _currentVelocityGradient: Nullable<FactorGradient>;
  33397. /** @hidden */
  33398. _currentVelocity1: number;
  33399. /** @hidden */
  33400. _currentVelocity2: number;
  33401. /** @hidden */
  33402. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  33403. /** @hidden */
  33404. _currentLimitVelocity1: number;
  33405. /** @hidden */
  33406. _currentLimitVelocity2: number;
  33407. /** @hidden */
  33408. _currentDragGradient: Nullable<FactorGradient>;
  33409. /** @hidden */
  33410. _currentDrag1: number;
  33411. /** @hidden */
  33412. _currentDrag2: number;
  33413. /** @hidden */
  33414. _randomNoiseCoordinates1: Vector3;
  33415. /** @hidden */
  33416. _randomNoiseCoordinates2: Vector3;
  33417. /**
  33418. * Creates a new instance Particle
  33419. * @param particleSystem the particle system the particle belongs to
  33420. */
  33421. constructor(
  33422. /**
  33423. * The particle system the particle belongs to.
  33424. */
  33425. particleSystem: ParticleSystem);
  33426. private updateCellInfoFromSystem;
  33427. /**
  33428. * Defines how the sprite cell index is updated for the particle
  33429. */
  33430. updateCellIndex(): void;
  33431. /** @hidden */
  33432. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  33433. /** @hidden */
  33434. _inheritParticleInfoToSubEmitters(): void;
  33435. /** @hidden */
  33436. _reset(): void;
  33437. /**
  33438. * Copy the properties of particle to another one.
  33439. * @param other the particle to copy the information to.
  33440. */
  33441. copyTo(other: Particle): void;
  33442. }
  33443. }
  33444. declare module BABYLON {
  33445. /**
  33446. * This class is made for on one-liner static method to help creating particle system set.
  33447. */
  33448. class ParticleHelper {
  33449. /**
  33450. * Gets or sets base Assets URL
  33451. */
  33452. static BaseAssetsUrl: string;
  33453. /**
  33454. * Create a default particle system that you can tweak
  33455. * @param emitter defines the emitter to use
  33456. * @param capacity defines the system capacity (default is 500 particles)
  33457. * @param scene defines the hosting scene
  33458. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  33459. * @returns the new Particle system
  33460. */
  33461. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  33462. /**
  33463. * This is the main static method (one-liner) of this helper to create different particle systems
  33464. * @param type This string represents the type to the particle system to create
  33465. * @param scene The scene where the particle system should live
  33466. * @param gpu If the system will use gpu
  33467. * @returns the ParticleSystemSet created
  33468. */
  33469. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  33470. /**
  33471. * Static function used to export a particle system to a ParticleSystemSet variable.
  33472. * Please note that the emitter shape is not exported
  33473. * @param systems defines the particle systems to export
  33474. * @returns the created particle system set
  33475. */
  33476. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  33477. }
  33478. }
  33479. declare module BABYLON {
  33480. /**
  33481. * This represents a particle system in Babylon.
  33482. * 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.
  33483. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  33484. * @example https://doc.babylonjs.com/babylon101/particles
  33485. */
  33486. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  33487. /**
  33488. * Billboard mode will only apply to Y axis
  33489. */
  33490. static readonly BILLBOARDMODE_Y: number;
  33491. /**
  33492. * Billboard mode will apply to all axes
  33493. */
  33494. static readonly BILLBOARDMODE_ALL: number;
  33495. /**
  33496. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  33497. */
  33498. static readonly BILLBOARDMODE_STRETCHED: number;
  33499. /**
  33500. * This function can be defined to provide custom update for active particles.
  33501. * This function will be called instead of regular update (age, position, color, etc.).
  33502. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  33503. */
  33504. updateFunction: (particles: Particle[]) => void;
  33505. private _emitterWorldMatrix;
  33506. /**
  33507. * This function can be defined to specify initial direction for every new particle.
  33508. * It by default use the emitterType defined function
  33509. */
  33510. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  33511. /**
  33512. * This function can be defined to specify initial position for every new particle.
  33513. * It by default use the emitterType defined function
  33514. */
  33515. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  33516. /**
  33517. * @hidden
  33518. */
  33519. _inheritedVelocityOffset: Vector3;
  33520. /**
  33521. * An event triggered when the system is disposed
  33522. */
  33523. onDisposeObservable: Observable<ParticleSystem>;
  33524. private _onDisposeObserver;
  33525. /**
  33526. * Sets a callback that will be triggered when the system is disposed
  33527. */
  33528. onDispose: () => void;
  33529. private _particles;
  33530. private _epsilon;
  33531. private _capacity;
  33532. private _stockParticles;
  33533. private _newPartsExcess;
  33534. private _vertexData;
  33535. private _vertexBuffer;
  33536. private _vertexBuffers;
  33537. private _spriteBuffer;
  33538. private _indexBuffer;
  33539. private _effect;
  33540. private _customEffect;
  33541. private _cachedDefines;
  33542. private _scaledColorStep;
  33543. private _colorDiff;
  33544. private _scaledDirection;
  33545. private _scaledGravity;
  33546. private _currentRenderId;
  33547. private _alive;
  33548. private _useInstancing;
  33549. private _started;
  33550. private _stopped;
  33551. private _actualFrame;
  33552. private _scaledUpdateSpeed;
  33553. private _vertexBufferSize;
  33554. /** @hidden */
  33555. _currentEmitRateGradient: Nullable<FactorGradient>;
  33556. /** @hidden */
  33557. _currentEmitRate1: number;
  33558. /** @hidden */
  33559. _currentEmitRate2: number;
  33560. /** @hidden */
  33561. _currentStartSizeGradient: Nullable<FactorGradient>;
  33562. /** @hidden */
  33563. _currentStartSize1: number;
  33564. /** @hidden */
  33565. _currentStartSize2: number;
  33566. private readonly _rawTextureWidth;
  33567. private _rampGradientsTexture;
  33568. private _useRampGradients;
  33569. /** Gets or sets a boolean indicating that ramp gradients must be used
  33570. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  33571. */
  33572. useRampGradients: boolean;
  33573. /**
  33574. * 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.
  33575. * 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: [])
  33576. */
  33577. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  33578. private _subEmitters;
  33579. /**
  33580. * @hidden
  33581. * If the particle systems emitter should be disposed when the particle system is disposed
  33582. */
  33583. _disposeEmitterOnDispose: boolean;
  33584. /**
  33585. * The current active Sub-systems, this property is used by the root particle system only.
  33586. */
  33587. activeSubSystems: Array<ParticleSystem>;
  33588. private _rootParticleSystem;
  33589. /**
  33590. * Gets the current list of active particles
  33591. */
  33592. readonly particles: Particle[];
  33593. /**
  33594. * Returns the string "ParticleSystem"
  33595. * @returns a string containing the class name
  33596. */
  33597. getClassName(): string;
  33598. /**
  33599. * Instantiates a particle system.
  33600. * 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.
  33601. * @param name The name of the particle system
  33602. * @param capacity The max number of particles alive at the same time
  33603. * @param scene The scene the particle system belongs to
  33604. * @param customEffect a custom effect used to change the way particles are rendered by default
  33605. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  33606. * @param epsilon Offset used to render the particles
  33607. */
  33608. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  33609. private _addFactorGradient;
  33610. private _removeFactorGradient;
  33611. /**
  33612. * Adds a new life time gradient
  33613. * @param gradient defines the gradient to use (between 0 and 1)
  33614. * @param factor defines the life time factor to affect to the specified gradient
  33615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33616. * @returns the current particle system
  33617. */
  33618. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33619. /**
  33620. * Remove a specific life time gradient
  33621. * @param gradient defines the gradient to remove
  33622. * @returns the current particle system
  33623. */
  33624. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33625. /**
  33626. * Adds a new size gradient
  33627. * @param gradient defines the gradient to use (between 0 and 1)
  33628. * @param factor defines the size factor to affect to the specified gradient
  33629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33630. * @returns the current particle system
  33631. */
  33632. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33633. /**
  33634. * Remove a specific size gradient
  33635. * @param gradient defines the gradient to remove
  33636. * @returns the current particle system
  33637. */
  33638. removeSizeGradient(gradient: number): IParticleSystem;
  33639. /**
  33640. * Adds a new color remap gradient
  33641. * @param gradient defines the gradient to use (between 0 and 1)
  33642. * @param min defines the color remap minimal range
  33643. * @param max defines the color remap maximal range
  33644. * @returns the current particle system
  33645. */
  33646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33647. /**
  33648. * Remove a specific color remap gradient
  33649. * @param gradient defines the gradient to remove
  33650. * @returns the current particle system
  33651. */
  33652. removeColorRemapGradient(gradient: number): IParticleSystem;
  33653. /**
  33654. * Adds a new alpha remap gradient
  33655. * @param gradient defines the gradient to use (between 0 and 1)
  33656. * @param min defines the alpha remap minimal range
  33657. * @param max defines the alpha remap maximal range
  33658. * @returns the current particle system
  33659. */
  33660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33661. /**
  33662. * Remove a specific alpha remap gradient
  33663. * @param gradient defines the gradient to remove
  33664. * @returns the current particle system
  33665. */
  33666. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  33667. /**
  33668. * Adds a new angular speed gradient
  33669. * @param gradient defines the gradient to use (between 0 and 1)
  33670. * @param factor defines the angular speed to affect to the specified gradient
  33671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33672. * @returns the current particle system
  33673. */
  33674. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33675. /**
  33676. * Remove a specific angular speed gradient
  33677. * @param gradient defines the gradient to remove
  33678. * @returns the current particle system
  33679. */
  33680. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  33681. /**
  33682. * Adds a new velocity gradient
  33683. * @param gradient defines the gradient to use (between 0 and 1)
  33684. * @param factor defines the velocity to affect to the specified gradient
  33685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33686. * @returns the current particle system
  33687. */
  33688. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33689. /**
  33690. * Remove a specific velocity gradient
  33691. * @param gradient defines the gradient to remove
  33692. * @returns the current particle system
  33693. */
  33694. removeVelocityGradient(gradient: number): IParticleSystem;
  33695. /**
  33696. * Adds a new limit velocity gradient
  33697. * @param gradient defines the gradient to use (between 0 and 1)
  33698. * @param factor defines the limit velocity value to affect to the specified gradient
  33699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33700. * @returns the current particle system
  33701. */
  33702. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33703. /**
  33704. * Remove a specific limit velocity gradient
  33705. * @param gradient defines the gradient to remove
  33706. * @returns the current particle system
  33707. */
  33708. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33709. /**
  33710. * Adds a new drag gradient
  33711. * @param gradient defines the gradient to use (between 0 and 1)
  33712. * @param factor defines the drag value to affect to the specified gradient
  33713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33714. * @returns the current particle system
  33715. */
  33716. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33717. /**
  33718. * Remove a specific drag gradient
  33719. * @param gradient defines the gradient to remove
  33720. * @returns the current particle system
  33721. */
  33722. removeDragGradient(gradient: number): IParticleSystem;
  33723. /**
  33724. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33725. * @param gradient defines the gradient to use (between 0 and 1)
  33726. * @param factor defines the emit rate value to affect to the specified gradient
  33727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33728. * @returns the current particle system
  33729. */
  33730. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33731. /**
  33732. * Remove a specific emit rate gradient
  33733. * @param gradient defines the gradient to remove
  33734. * @returns the current particle system
  33735. */
  33736. removeEmitRateGradient(gradient: number): IParticleSystem;
  33737. /**
  33738. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33739. * @param gradient defines the gradient to use (between 0 and 1)
  33740. * @param factor defines the start size value to affect to the specified gradient
  33741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33742. * @returns the current particle system
  33743. */
  33744. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33745. /**
  33746. * Remove a specific start size gradient
  33747. * @param gradient defines the gradient to remove
  33748. * @returns the current particle system
  33749. */
  33750. removeStartSizeGradient(gradient: number): IParticleSystem;
  33751. private _createRampGradientTexture;
  33752. /**
  33753. * Gets the current list of ramp gradients.
  33754. * You must use addRampGradient and removeRampGradient to udpate this list
  33755. * @returns the list of ramp gradients
  33756. */
  33757. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33758. /**
  33759. * Adds a new ramp gradient used to remap particle colors
  33760. * @param gradient defines the gradient to use (between 0 and 1)
  33761. * @param color defines the color to affect to the specified gradient
  33762. * @returns the current particle system
  33763. */
  33764. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  33765. /**
  33766. * Remove a specific ramp gradient
  33767. * @param gradient defines the gradient to remove
  33768. * @returns the current particle system
  33769. */
  33770. removeRampGradient(gradient: number): ParticleSystem;
  33771. /**
  33772. * Adds a new color gradient
  33773. * @param gradient defines the gradient to use (between 0 and 1)
  33774. * @param color1 defines the color to affect to the specified gradient
  33775. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  33776. * @returns this particle system
  33777. */
  33778. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  33779. /**
  33780. * Remove a specific color gradient
  33781. * @param gradient defines the gradient to remove
  33782. * @returns this particle system
  33783. */
  33784. removeColorGradient(gradient: number): IParticleSystem;
  33785. private _fetchR;
  33786. protected _reset(): void;
  33787. private _resetEffect;
  33788. private _createVertexBuffers;
  33789. private _createIndexBuffer;
  33790. /**
  33791. * Gets the maximum number of particles active at the same time.
  33792. * @returns The max number of active particles.
  33793. */
  33794. getCapacity(): number;
  33795. /**
  33796. * Gets whether there are still active particles in the system.
  33797. * @returns True if it is alive, otherwise false.
  33798. */
  33799. isAlive(): boolean;
  33800. /**
  33801. * Gets if the system has been started. (Note: this will still be true after stop is called)
  33802. * @returns True if it has been started, otherwise false.
  33803. */
  33804. isStarted(): boolean;
  33805. private _prepareSubEmitterInternalArray;
  33806. /**
  33807. * Starts the particle system and begins to emit
  33808. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  33809. */
  33810. start(delay?: number): void;
  33811. /**
  33812. * Stops the particle system.
  33813. * @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.
  33814. */
  33815. stop(stopSubEmitters?: boolean): void;
  33816. /**
  33817. * Remove all active particles
  33818. */
  33819. reset(): void;
  33820. /**
  33821. * @hidden (for internal use only)
  33822. */
  33823. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  33824. /**
  33825. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  33826. * Its lifetime will start back at 0.
  33827. */
  33828. recycleParticle: (particle: Particle) => void;
  33829. private _stopSubEmitters;
  33830. private _createParticle;
  33831. private _removeFromRoot;
  33832. private _emitFromParticle;
  33833. private _update;
  33834. /** @hidden */
  33835. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  33836. /** @hidden */
  33837. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  33838. /** @hidden */
  33839. private _getEffect;
  33840. /**
  33841. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  33842. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  33843. */
  33844. animate(preWarmOnly?: boolean): void;
  33845. private _appendParticleVertices;
  33846. /**
  33847. * Rebuilds the particle system.
  33848. */
  33849. rebuild(): void;
  33850. /**
  33851. * Is this system ready to be used/rendered
  33852. * @return true if the system is ready
  33853. */
  33854. isReady(): boolean;
  33855. private _render;
  33856. /**
  33857. * Renders the particle system in its current state.
  33858. * @returns the current number of particles
  33859. */
  33860. render(): number;
  33861. /**
  33862. * Disposes the particle system and free the associated resources
  33863. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  33864. */
  33865. dispose(disposeTexture?: boolean): void;
  33866. /**
  33867. * Clones the particle system.
  33868. * @param name The name of the cloned object
  33869. * @param newEmitter The new emitter to use
  33870. * @returns the cloned particle system
  33871. */
  33872. clone(name: string, newEmitter: any): ParticleSystem;
  33873. /**
  33874. * Serializes the particle system to a JSON object.
  33875. * @returns the JSON object
  33876. */
  33877. serialize(): any;
  33878. /** @hidden */
  33879. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  33880. /** @hidden */
  33881. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  33882. /**
  33883. * Parses a JSON object to create a particle system.
  33884. * @param parsedParticleSystem The JSON object to parse
  33885. * @param scene The scene to create the particle system in
  33886. * @param rootUrl The root url to use to load external dependencies like texture
  33887. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  33888. * @returns the Parsed particle system
  33889. */
  33890. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  33891. }
  33892. }
  33893. declare module BABYLON {
  33894. interface Engine {
  33895. /**
  33896. * Create an effect to use with particle systems.
  33897. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  33898. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  33899. * @param uniformsNames defines a list of attribute names
  33900. * @param samplers defines an array of string used to represent textures
  33901. * @param defines defines the string containing the defines to use to compile the shaders
  33902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33903. * @param onCompiled defines a function to call when the effect creation is successful
  33904. * @param onError defines a function to call when the effect creation has failed
  33905. * @returns the new Effect
  33906. */
  33907. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  33908. }
  33909. interface Mesh {
  33910. /**
  33911. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  33912. * @returns an array of IParticleSystem
  33913. */
  33914. getEmittedParticleSystems(): IParticleSystem[];
  33915. /**
  33916. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  33917. * @returns an array of IParticleSystem
  33918. */
  33919. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  33920. }
  33921. }
  33922. declare module BABYLON {
  33923. /**
  33924. * Represents a set of particle systems working together to create a specific effect
  33925. */
  33926. class ParticleSystemSet implements IDisposable {
  33927. private _emitterCreationOptions;
  33928. private _emitterNode;
  33929. /**
  33930. * Gets the particle system list
  33931. */
  33932. systems: IParticleSystem[];
  33933. /**
  33934. * Gets the emitter node used with this set
  33935. */
  33936. readonly emitterNode: Nullable<TransformNode>;
  33937. /**
  33938. * Creates a new emitter mesh as a sphere
  33939. * @param options defines the options used to create the sphere
  33940. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  33941. * @param scene defines the hosting scene
  33942. */
  33943. setEmitterAsSphere(options: {
  33944. diameter: number;
  33945. segments: number;
  33946. color: Color3;
  33947. }, renderingGroupId: number, scene: Scene): void;
  33948. /**
  33949. * Starts all particle systems of the set
  33950. * @param emitter defines an optional mesh to use as emitter for the particle systems
  33951. */
  33952. start(emitter?: AbstractMesh): void;
  33953. /**
  33954. * Release all associated resources
  33955. */
  33956. dispose(): void;
  33957. /**
  33958. * Serialize the set into a JSON compatible object
  33959. * @returns a JSON compatible representation of the set
  33960. */
  33961. serialize(): any;
  33962. /**
  33963. * Parse a new ParticleSystemSet from a serialized source
  33964. * @param data defines a JSON compatible representation of the set
  33965. * @param scene defines the hosting scene
  33966. * @param gpu defines if we want GPU particles or CPU particles
  33967. * @returns a new ParticleSystemSet
  33968. */
  33969. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  33970. }
  33971. }
  33972. declare module BABYLON {
  33973. /**
  33974. * Represents one particle of a solid particle system.
  33975. */
  33976. class SolidParticle {
  33977. /**
  33978. * particle global index
  33979. */
  33980. idx: number;
  33981. /**
  33982. * The color of the particle
  33983. */
  33984. color: Nullable<Color4>;
  33985. /**
  33986. * The world space position of the particle.
  33987. */
  33988. position: Vector3;
  33989. /**
  33990. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  33991. */
  33992. rotation: Vector3;
  33993. /**
  33994. * The world space rotation quaternion of the particle.
  33995. */
  33996. rotationQuaternion: Nullable<Quaternion>;
  33997. /**
  33998. * The scaling of the particle.
  33999. */
  34000. scaling: Vector3;
  34001. /**
  34002. * The uvs of the particle.
  34003. */
  34004. uvs: Vector4;
  34005. /**
  34006. * The current speed of the particle.
  34007. */
  34008. velocity: Vector3;
  34009. /**
  34010. * The pivot point in the particle local space.
  34011. */
  34012. pivot: Vector3;
  34013. /**
  34014. * Must the particle be translated from its pivot point in its local space ?
  34015. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34016. * Default : false
  34017. */
  34018. translateFromPivot: boolean;
  34019. /**
  34020. * Is the particle active or not ?
  34021. */
  34022. alive: boolean;
  34023. /**
  34024. * Is the particle visible or not ?
  34025. */
  34026. isVisible: boolean;
  34027. /**
  34028. * Index of this particle in the global "positions" array (Internal use)
  34029. * @hidden
  34030. */
  34031. _pos: number;
  34032. /**
  34033. * @hidden Index of this particle in the global "indices" array (Internal use)
  34034. */
  34035. _ind: number;
  34036. /**
  34037. * @hidden ModelShape of this particle (Internal use)
  34038. */
  34039. _model: ModelShape;
  34040. /**
  34041. * ModelShape id of this particle
  34042. */
  34043. shapeId: number;
  34044. /**
  34045. * Index of the particle in its shape id (Internal use)
  34046. */
  34047. idxInShape: number;
  34048. /**
  34049. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34050. */
  34051. _modelBoundingInfo: BoundingInfo;
  34052. /**
  34053. * @hidden Particle BoundingInfo object (Internal use)
  34054. */
  34055. _boundingInfo: BoundingInfo;
  34056. /**
  34057. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34058. */
  34059. _sps: SolidParticleSystem;
  34060. /**
  34061. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34062. */
  34063. _stillInvisible: boolean;
  34064. /**
  34065. * @hidden Last computed particle rotation matrix
  34066. */
  34067. _rotationMatrix: number[];
  34068. /**
  34069. * Parent particle Id, if any.
  34070. * Default null.
  34071. */
  34072. parentId: Nullable<number>;
  34073. /**
  34074. * @hidden Internal global position in the SPS.
  34075. */
  34076. _globalPosition: Vector3;
  34077. /**
  34078. * Creates a Solid Particle object.
  34079. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34080. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  34081. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34082. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34083. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34084. * @param shapeId (integer) is the model shape identifier in the SPS.
  34085. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34086. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34087. */
  34088. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  34089. /**
  34090. * Legacy support, changed scale to scaling
  34091. */
  34092. /**
  34093. * Legacy support, changed scale to scaling
  34094. */
  34095. scale: Vector3;
  34096. /**
  34097. * Legacy support, changed quaternion to rotationQuaternion
  34098. */
  34099. /**
  34100. * Legacy support, changed quaternion to rotationQuaternion
  34101. */
  34102. quaternion: Nullable<Quaternion>;
  34103. /**
  34104. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34105. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34106. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34107. * @returns true if it intersects
  34108. */
  34109. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34110. /**
  34111. * get the rotation matrix of the particle
  34112. * @hidden
  34113. */
  34114. getRotationMatrix(m: Matrix): void;
  34115. }
  34116. /**
  34117. * Represents the shape of the model used by one particle of a solid particle system.
  34118. * SPS internal tool, don't use it manually.
  34119. */
  34120. class ModelShape {
  34121. /**
  34122. * The shape id
  34123. * @hidden
  34124. */
  34125. shapeID: number;
  34126. /**
  34127. * flat array of model positions (internal use)
  34128. * @hidden
  34129. */
  34130. _shape: Vector3[];
  34131. /**
  34132. * flat array of model UVs (internal use)
  34133. * @hidden
  34134. */
  34135. _shapeUV: number[];
  34136. /**
  34137. * length of the shape in the model indices array (internal use)
  34138. * @hidden
  34139. */
  34140. _indicesLength: number;
  34141. /**
  34142. * Custom position function (internal use)
  34143. * @hidden
  34144. */
  34145. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34146. /**
  34147. * Custom vertex function (internal use)
  34148. * @hidden
  34149. */
  34150. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34151. /**
  34152. * 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.
  34153. * SPS internal tool, don't use it manually.
  34154. * @hidden
  34155. */
  34156. 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>);
  34157. }
  34158. /**
  34159. * Represents a Depth Sorted Particle in the solid particle system.
  34160. */
  34161. class DepthSortedParticle {
  34162. /**
  34163. * Index of the particle in the "indices" array
  34164. */
  34165. ind: number;
  34166. /**
  34167. * Length of the particle shape in the "indices" array
  34168. */
  34169. indicesLength: number;
  34170. /**
  34171. * Squared distance from the particle to the camera
  34172. */
  34173. sqDistance: number;
  34174. }
  34175. }
  34176. declare module BABYLON {
  34177. /**
  34178. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34179. *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.
  34180. * The SPS is also a particle system. It provides some methods to manage the particles.
  34181. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34182. *
  34183. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  34184. */
  34185. class SolidParticleSystem implements IDisposable {
  34186. /**
  34187. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34188. * Example : var p = SPS.particles[i];
  34189. */
  34190. particles: SolidParticle[];
  34191. /**
  34192. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34193. */
  34194. nbParticles: number;
  34195. /**
  34196. * If the particles must ever face the camera (default false). Useful for planar particles.
  34197. */
  34198. billboard: boolean;
  34199. /**
  34200. * Recompute normals when adding a shape
  34201. */
  34202. recomputeNormals: boolean;
  34203. /**
  34204. * This a counter ofr your own usage. It's not set by any SPS functions.
  34205. */
  34206. counter: number;
  34207. /**
  34208. * The SPS name. This name is also given to the underlying mesh.
  34209. */
  34210. name: string;
  34211. /**
  34212. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34213. */
  34214. mesh: Mesh;
  34215. /**
  34216. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34217. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  34218. */
  34219. vars: any;
  34220. /**
  34221. * This array is populated when the SPS is set as 'pickable'.
  34222. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34223. * Each element of this array is an object `{idx: int, faceId: int}`.
  34224. * `idx` is the picked particle index in the `SPS.particles` array
  34225. * `faceId` is the picked face index counted within this particle.
  34226. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  34227. */
  34228. pickedParticles: {
  34229. idx: number;
  34230. faceId: number;
  34231. }[];
  34232. /**
  34233. * This array is populated when `enableDepthSort` is set to true.
  34234. * Each element of this array is an instance of the class DepthSortedParticle.
  34235. */
  34236. depthSortedParticles: DepthSortedParticle[];
  34237. /**
  34238. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34239. * @hidden
  34240. */
  34241. _bSphereOnly: boolean;
  34242. /**
  34243. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34244. * @hidden
  34245. */
  34246. _bSphereRadiusFactor: number;
  34247. private _scene;
  34248. private _positions;
  34249. private _indices;
  34250. private _normals;
  34251. private _colors;
  34252. private _uvs;
  34253. private _indices32;
  34254. private _positions32;
  34255. private _normals32;
  34256. private _fixedNormal32;
  34257. private _colors32;
  34258. private _uvs32;
  34259. private _index;
  34260. private _updatable;
  34261. private _pickable;
  34262. private _isVisibilityBoxLocked;
  34263. private _alwaysVisible;
  34264. private _depthSort;
  34265. private _shapeCounter;
  34266. private _copy;
  34267. private _color;
  34268. private _computeParticleColor;
  34269. private _computeParticleTexture;
  34270. private _computeParticleRotation;
  34271. private _computeParticleVertex;
  34272. private _computeBoundingBox;
  34273. private _depthSortParticles;
  34274. private _camera;
  34275. private _mustUnrotateFixedNormals;
  34276. private _particlesIntersect;
  34277. private _needs32Bits;
  34278. /**
  34279. * Creates a SPS (Solid Particle System) object.
  34280. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34281. * @param scene (Scene) is the scene in which the SPS is added.
  34282. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34283. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34284. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34285. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34286. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34287. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34288. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34289. */
  34290. constructor(name: string, scene: Scene, options?: {
  34291. updatable?: boolean;
  34292. isPickable?: boolean;
  34293. enableDepthSort?: boolean;
  34294. particleIntersection?: boolean;
  34295. boundingSphereOnly?: boolean;
  34296. bSphereRadiusFactor?: number;
  34297. });
  34298. /**
  34299. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34300. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34301. * @returns the created mesh
  34302. */
  34303. buildMesh(): Mesh;
  34304. /**
  34305. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34306. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34307. * Thus the particles generated from `digest()` have their property `position` set yet.
  34308. * @param mesh ( Mesh ) is the mesh to be digested
  34309. * @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
  34310. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34311. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34312. * @returns the current SPS
  34313. */
  34314. digest(mesh: Mesh, options?: {
  34315. facetNb?: number;
  34316. number?: number;
  34317. delta?: number;
  34318. }): SolidParticleSystem;
  34319. private _unrotateFixedNormals;
  34320. private _resetCopy;
  34321. private _meshBuilder;
  34322. private _posToShape;
  34323. private _uvsToShapeUV;
  34324. private _addParticle;
  34325. /**
  34326. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34327. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  34328. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34329. * @param nb (positive integer) the number of particles to be created from this model
  34330. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34331. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34332. * @returns the number of shapes in the system
  34333. */
  34334. addShape(mesh: Mesh, nb: number, options?: {
  34335. positionFunction?: any;
  34336. vertexFunction?: any;
  34337. }): number;
  34338. private _rebuildParticle;
  34339. /**
  34340. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34341. * @returns the SPS.
  34342. */
  34343. rebuildMesh(): SolidParticleSystem;
  34344. /**
  34345. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34346. * This method calls `updateParticle()` for each particle of the SPS.
  34347. * For an animated SPS, it is usually called within the render loop.
  34348. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34349. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34350. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34351. * @returns the SPS.
  34352. */
  34353. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34354. /**
  34355. * Disposes the SPS.
  34356. */
  34357. dispose(): void;
  34358. /**
  34359. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34360. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34361. * @returns the SPS.
  34362. */
  34363. refreshVisibleSize(): SolidParticleSystem;
  34364. /**
  34365. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34366. * @param size the size (float) of the visibility box
  34367. * note : this doesn't lock the SPS mesh bounding box.
  34368. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34369. */
  34370. setVisibilityBox(size: number): void;
  34371. /**
  34372. * Gets whether the SPS as always visible or not
  34373. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34374. */
  34375. /**
  34376. * Sets the SPS as always visible or not
  34377. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34378. */
  34379. isAlwaysVisible: boolean;
  34380. /**
  34381. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34382. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34383. */
  34384. /**
  34385. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34386. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34387. */
  34388. isVisibilityBoxLocked: boolean;
  34389. /**
  34390. * Tells to `setParticles()` to compute the particle rotations or not.
  34391. * Default value : true. The SPS is faster when it's set to false.
  34392. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34393. */
  34394. /**
  34395. * Gets if `setParticles()` computes the particle rotations or not.
  34396. * Default value : true. The SPS is faster when it's set to false.
  34397. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34398. */
  34399. computeParticleRotation: boolean;
  34400. /**
  34401. * Tells to `setParticles()` to compute the particle colors or not.
  34402. * Default value : true. The SPS is faster when it's set to false.
  34403. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34404. */
  34405. /**
  34406. * Gets if `setParticles()` computes the particle colors or not.
  34407. * Default value : true. The SPS is faster when it's set to false.
  34408. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34409. */
  34410. computeParticleColor: boolean;
  34411. /**
  34412. * Gets if `setParticles()` computes the particle textures or not.
  34413. * Default value : true. The SPS is faster when it's set to false.
  34414. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34415. */
  34416. computeParticleTexture: boolean;
  34417. /**
  34418. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34419. * Default value : false. The SPS is faster when it's set to false.
  34420. * Note : the particle custom vertex positions aren't stored values.
  34421. */
  34422. /**
  34423. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34424. * Default value : false. The SPS is faster when it's set to false.
  34425. * Note : the particle custom vertex positions aren't stored values.
  34426. */
  34427. computeParticleVertex: boolean;
  34428. /**
  34429. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34430. */
  34431. /**
  34432. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34433. */
  34434. computeBoundingBox: boolean;
  34435. /**
  34436. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34437. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34438. * Default : `true`
  34439. */
  34440. /**
  34441. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34442. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34443. * Default : `true`
  34444. */
  34445. depthSortParticles: boolean;
  34446. /**
  34447. * This function does nothing. It may be overwritten to set all the particle first values.
  34448. * The SPS doesn't call this function, you may have to call it by your own.
  34449. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34450. */
  34451. initParticles(): void;
  34452. /**
  34453. * This function does nothing. It may be overwritten to recycle a particle.
  34454. * The SPS doesn't call this function, you may have to call it by your own.
  34455. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34456. * @param particle The particle to recycle
  34457. * @returns the recycled particle
  34458. */
  34459. recycleParticle(particle: SolidParticle): SolidParticle;
  34460. /**
  34461. * Updates a particle : this function should be overwritten by the user.
  34462. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34463. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34464. * @example : just set a particle position or velocity and recycle conditions
  34465. * @param particle The particle to update
  34466. * @returns the updated particle
  34467. */
  34468. updateParticle(particle: SolidParticle): SolidParticle;
  34469. /**
  34470. * Updates a vertex of a particle : it can be overwritten by the user.
  34471. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34472. * @param particle the current particle
  34473. * @param vertex the current index of the current particle
  34474. * @param pt the index of the current vertex in the particle shape
  34475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  34476. * @example : just set a vertex particle position
  34477. * @returns the updated vertex
  34478. */
  34479. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  34480. /**
  34481. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34482. * This does nothing and may be overwritten by the user.
  34483. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34484. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34485. * @param update the boolean update value actually passed to setParticles()
  34486. */
  34487. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34488. /**
  34489. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34490. * This will be passed three parameters.
  34491. * This does nothing and may be overwritten by the user.
  34492. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34493. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34494. * @param update the boolean update value actually passed to setParticles()
  34495. */
  34496. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34497. }
  34498. }
  34499. declare module BABYLON {
  34500. /**
  34501. * Type of sub emitter
  34502. */
  34503. enum SubEmitterType {
  34504. /**
  34505. * Attached to the particle over it's lifetime
  34506. */
  34507. ATTACHED = 0,
  34508. /**
  34509. * Created when the particle dies
  34510. */
  34511. END = 1
  34512. }
  34513. /**
  34514. * Sub emitter class used to emit particles from an existing particle
  34515. */
  34516. class SubEmitter {
  34517. /**
  34518. * the particle system to be used by the sub emitter
  34519. */
  34520. particleSystem: ParticleSystem;
  34521. /**
  34522. * Type of the submitter (Default: END)
  34523. */
  34524. type: SubEmitterType;
  34525. /**
  34526. * 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)
  34527. * Note: This only is supported when using an emitter of type Mesh
  34528. */
  34529. inheritDirection: boolean;
  34530. /**
  34531. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  34532. */
  34533. inheritedVelocityAmount: number;
  34534. /**
  34535. * Creates a sub emitter
  34536. * @param particleSystem the particle system to be used by the sub emitter
  34537. */
  34538. constructor(
  34539. /**
  34540. * the particle system to be used by the sub emitter
  34541. */
  34542. particleSystem: ParticleSystem);
  34543. /**
  34544. * Clones the sub emitter
  34545. * @returns the cloned sub emitter
  34546. */
  34547. clone(): SubEmitter;
  34548. /**
  34549. * Serialize current object to a JSON object
  34550. * @returns the serialized object
  34551. */
  34552. serialize(): any;
  34553. /**
  34554. * Creates a new SubEmitter from a serialized JSON version
  34555. * @param serializationObject defines the JSON object to read from
  34556. * @param scene defines the hosting scene
  34557. * @param rootUrl defines the rootUrl for data loading
  34558. * @returns a new SubEmitter
  34559. */
  34560. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  34561. /** Release associated resources */
  34562. dispose(): void;
  34563. }
  34564. }
  34565. declare module BABYLON {
  34566. interface Scene {
  34567. /** @hidden (Backing field) */
  34568. _boundingBoxRenderer: BoundingBoxRenderer;
  34569. /** @hidden (Backing field) */
  34570. _forceShowBoundingBoxes: boolean;
  34571. /**
  34572. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34573. */
  34574. forceShowBoundingBoxes: boolean;
  34575. /**
  34576. * Gets the bounding box renderer associated with the scene
  34577. * @returns a BoundingBoxRenderer
  34578. */
  34579. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34580. }
  34581. interface AbstractMesh {
  34582. /** @hidden (Backing field) */
  34583. _showBoundingBox: boolean;
  34584. /**
  34585. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34586. */
  34587. showBoundingBox: boolean;
  34588. }
  34589. /**
  34590. * Component responsible of rendering the bounding box of the meshes in a scene.
  34591. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34592. */
  34593. class BoundingBoxRenderer implements ISceneComponent {
  34594. /**
  34595. * The component name helpfull to identify the component in the list of scene components.
  34596. */
  34597. readonly name: string;
  34598. /**
  34599. * The scene the component belongs to.
  34600. */
  34601. scene: Scene;
  34602. /**
  34603. * Color of the bounding box lines placed in front of an object
  34604. */
  34605. frontColor: Color3;
  34606. /**
  34607. * Color of the bounding box lines placed behind an object
  34608. */
  34609. backColor: Color3;
  34610. /**
  34611. * Defines if the renderer should show the back lines or not
  34612. */
  34613. showBackLines: boolean;
  34614. /**
  34615. * @hidden
  34616. */
  34617. renderList: SmartArray<BoundingBox>;
  34618. private _colorShader;
  34619. private _vertexBuffers;
  34620. private _indexBuffer;
  34621. /**
  34622. * Instantiates a new bounding box renderer in a scene.
  34623. * @param scene the scene the renderer renders in
  34624. */
  34625. constructor(scene: Scene);
  34626. /**
  34627. * Registers the component in a given scene
  34628. */
  34629. register(): void;
  34630. private _evaluateSubMesh;
  34631. private _activeMesh;
  34632. private _prepareRessources;
  34633. private _createIndexBuffer;
  34634. /**
  34635. * Rebuilds the elements related to this component in case of
  34636. * context lost for instance.
  34637. */
  34638. rebuild(): void;
  34639. /**
  34640. * @hidden
  34641. */
  34642. reset(): void;
  34643. /**
  34644. * Render the bounding boxes of a specific rendering group
  34645. * @param renderingGroupId defines the rendering group to render
  34646. */
  34647. render(renderingGroupId: number): void;
  34648. /**
  34649. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34650. * @param mesh Define the mesh to render the occlusion bounding box for
  34651. */
  34652. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34653. /**
  34654. * Dispose and release the resources attached to this renderer.
  34655. */
  34656. dispose(): void;
  34657. }
  34658. }
  34659. declare module BABYLON {
  34660. /**
  34661. * This represents a depth renderer in Babylon.
  34662. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34663. */
  34664. class DepthRenderer {
  34665. private _scene;
  34666. private _depthMap;
  34667. private _effect;
  34668. private _cachedDefines;
  34669. private _camera;
  34670. /**
  34671. * Specifiess that the depth renderer will only be used within
  34672. * the camera it is created for.
  34673. * This can help forcing its rendering during the camera processing.
  34674. */
  34675. useOnlyInActiveCamera: boolean;
  34676. /**
  34677. * Instantiates a depth renderer
  34678. * @param scene The scene the renderer belongs to
  34679. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34680. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34681. */
  34682. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34683. /**
  34684. * Creates the depth rendering effect and checks if the effect is ready.
  34685. * @param subMesh The submesh to be used to render the depth map of
  34686. * @param useInstances If multiple world instances should be used
  34687. * @returns if the depth renderer is ready to render the depth map
  34688. */
  34689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34690. /**
  34691. * Gets the texture which the depth map will be written to.
  34692. * @returns The depth map texture
  34693. */
  34694. getDepthMap(): RenderTargetTexture;
  34695. /**
  34696. * Disposes of the depth renderer.
  34697. */
  34698. dispose(): void;
  34699. }
  34700. }
  34701. declare module BABYLON {
  34702. interface Scene {
  34703. /** @hidden (Backing field) */
  34704. _depthRenderer: {
  34705. [id: string]: DepthRenderer;
  34706. };
  34707. /**
  34708. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34709. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34710. * @returns the created depth renderer
  34711. */
  34712. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34713. /**
  34714. * Disables a depth renderer for a given camera
  34715. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34716. */
  34717. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34718. }
  34719. /**
  34720. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  34721. * in several rendering techniques.
  34722. */
  34723. class DepthRendererSceneComponent implements ISceneComponent {
  34724. /**
  34725. * The component name helpfull to identify the component in the list of scene components.
  34726. */
  34727. readonly name: string;
  34728. /**
  34729. * The scene the component belongs to.
  34730. */
  34731. scene: Scene;
  34732. /**
  34733. * Creates a new instance of the component for the given scene
  34734. * @param scene Defines the scene to register the component in
  34735. */
  34736. constructor(scene: Scene);
  34737. /**
  34738. * Registers the component in a given scene
  34739. */
  34740. register(): void;
  34741. /**
  34742. * Rebuilds the elements related to this component in case of
  34743. * context lost for instance.
  34744. */
  34745. rebuild(): void;
  34746. /**
  34747. * Disposes the component and the associated ressources
  34748. */
  34749. dispose(): void;
  34750. private _gatherRenderTargets;
  34751. private _gatherActiveCameraRenderTargets;
  34752. }
  34753. }
  34754. declare module BABYLON {
  34755. interface AbstractMesh {
  34756. /**
  34757. * Disables the mesh edge rendering mode
  34758. * @returns the currentAbstractMesh
  34759. */
  34760. disableEdgesRendering(): AbstractMesh;
  34761. /**
  34762. * Enables the edge rendering mode on the mesh.
  34763. * This mode makes the mesh edges visible
  34764. * @param epsilon defines the maximal distance between two angles to detect a face
  34765. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34766. * @returns the currentAbstractMesh
  34767. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34768. */
  34769. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34770. /**
  34771. * Gets the edgesRenderer associated with the mesh
  34772. */
  34773. edgesRenderer: Nullable<EdgesRenderer>;
  34774. }
  34775. interface LinesMesh {
  34776. /**
  34777. * Enables the edge rendering mode on the mesh.
  34778. * This mode makes the mesh edges visible
  34779. * @param epsilon defines the maximal distance between two angles to detect a face
  34780. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34781. * @returns the currentAbstractMesh
  34782. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34783. */
  34784. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34785. }
  34786. interface InstancedLinesMesh {
  34787. /**
  34788. * Enables the edge rendering mode on the mesh.
  34789. * This mode makes the mesh edges visible
  34790. * @param epsilon defines the maximal distance between two angles to detect a face
  34791. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34792. * @returns the current InstancedLinesMesh
  34793. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34794. */
  34795. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34796. }
  34797. /**
  34798. * Defines the minimum contract an Edges renderer should follow.
  34799. */
  34800. interface IEdgesRenderer extends IDisposable {
  34801. /**
  34802. * Gets or sets a boolean indicating if the edgesRenderer is active
  34803. */
  34804. isEnabled: boolean;
  34805. /**
  34806. * Renders the edges of the attached mesh,
  34807. */
  34808. render(): void;
  34809. /**
  34810. * Checks wether or not the edges renderer is ready to render.
  34811. * @return true if ready, otherwise false.
  34812. */
  34813. isReady(): boolean;
  34814. }
  34815. /**
  34816. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34817. */
  34818. class EdgesRenderer implements IEdgesRenderer {
  34819. /**
  34820. * Define the size of the edges with an orthographic camera
  34821. */
  34822. edgesWidthScalerForOrthographic: number;
  34823. /**
  34824. * Define the size of the edges with a perspective camera
  34825. */
  34826. edgesWidthScalerForPerspective: number;
  34827. protected _source: AbstractMesh;
  34828. protected _linesPositions: number[];
  34829. protected _linesNormals: number[];
  34830. protected _linesIndices: number[];
  34831. protected _epsilon: number;
  34832. protected _indicesCount: number;
  34833. protected _lineShader: ShaderMaterial;
  34834. protected _ib: WebGLBuffer;
  34835. protected _buffers: {
  34836. [key: string]: Nullable<VertexBuffer>;
  34837. };
  34838. protected _checkVerticesInsteadOfIndices: boolean;
  34839. private _meshRebuildObserver;
  34840. private _meshDisposeObserver;
  34841. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34842. isEnabled: boolean;
  34843. /**
  34844. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34845. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34846. * @param source Mesh used to create edges
  34847. * @param epsilon sum of angles in adjacency to check for edge
  34848. * @param checkVerticesInsteadOfIndices
  34849. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34850. */
  34851. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34852. protected _prepareRessources(): void;
  34853. /** @hidden */
  34854. _rebuild(): void;
  34855. /**
  34856. * Releases the required resources for the edges renderer
  34857. */
  34858. dispose(): void;
  34859. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34860. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34861. /**
  34862. * Checks if the pair of p0 and p1 is en edge
  34863. * @param faceIndex
  34864. * @param edge
  34865. * @param faceNormals
  34866. * @param p0
  34867. * @param p1
  34868. * @private
  34869. */
  34870. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34871. /**
  34872. * push line into the position, normal and index buffer
  34873. * @protected
  34874. */
  34875. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34876. /**
  34877. * Generates lines edges from adjacencjes
  34878. * @private
  34879. */
  34880. _generateEdgesLines(): void;
  34881. /**
  34882. * Checks wether or not the edges renderer is ready to render.
  34883. * @return true if ready, otherwise false.
  34884. */
  34885. isReady(): boolean;
  34886. /**
  34887. * Renders the edges of the attached mesh,
  34888. */
  34889. render(): void;
  34890. }
  34891. }
  34892. declare module BABYLON {
  34893. /**
  34894. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34895. */
  34896. class GeometryBufferRenderer {
  34897. /**
  34898. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34899. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34900. */
  34901. static readonly POSITION_TEXTURE_TYPE: number;
  34902. /**
  34903. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34904. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34905. */
  34906. static readonly VELOCITY_TEXTURE_TYPE: number;
  34907. /**
  34908. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34909. * in order to compute objects velocities when enableVelocity is set to "true"
  34910. * @hidden
  34911. */
  34912. _previousTransformationMatrices: {
  34913. [index: number]: Matrix;
  34914. };
  34915. private _scene;
  34916. private _multiRenderTarget;
  34917. private _ratio;
  34918. private _enablePosition;
  34919. private _enableVelocity;
  34920. private _positionIndex;
  34921. private _velocityIndex;
  34922. protected _effect: Effect;
  34923. protected _cachedDefines: string;
  34924. /**
  34925. * Set the render list (meshes to be rendered) used in the G buffer.
  34926. */
  34927. renderList: Mesh[];
  34928. /**
  34929. * Gets wether or not G buffer are supported by the running hardware.
  34930. * This requires draw buffer supports
  34931. */
  34932. readonly isSupported: boolean;
  34933. /**
  34934. * Returns the index of the given texture type in the G-Buffer textures array
  34935. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34936. * @returns the index of the given texture type in the G-Buffer textures array
  34937. */
  34938. getTextureIndex(textureType: number): number;
  34939. /**
  34940. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34941. */
  34942. /**
  34943. * Sets whether or not objects positions are enabled for the G buffer.
  34944. */
  34945. enablePosition: boolean;
  34946. /**
  34947. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34948. */
  34949. /**
  34950. * Sets wether or not objects velocities are enabled for the G buffer.
  34951. */
  34952. enableVelocity: boolean;
  34953. /**
  34954. * Gets the scene associated with the buffer.
  34955. */
  34956. readonly scene: Scene;
  34957. /**
  34958. * Gets the ratio used by the buffer during its creation.
  34959. * How big is the buffer related to the main canvas.
  34960. */
  34961. readonly ratio: number;
  34962. /**
  34963. * Creates a new G Buffer for the scene
  34964. * @param scene The scene the buffer belongs to
  34965. * @param ratio How big is the buffer related to the main canvas.
  34966. */
  34967. constructor(scene: Scene, ratio?: number);
  34968. /**
  34969. * Checks wether everything is ready to render a submesh to the G buffer.
  34970. * @param subMesh the submesh to check readiness for
  34971. * @param useInstances is the mesh drawn using instance or not
  34972. * @returns true if ready otherwise false
  34973. */
  34974. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34975. /**
  34976. * Gets the current underlying G Buffer.
  34977. * @returns the buffer
  34978. */
  34979. getGBuffer(): MultiRenderTarget;
  34980. /**
  34981. * Gets the number of samples used to render the buffer (anti aliasing).
  34982. */
  34983. /**
  34984. * Sets the number of samples used to render the buffer (anti aliasing).
  34985. */
  34986. samples: number;
  34987. /**
  34988. * Disposes the renderer and frees up associated resources.
  34989. */
  34990. dispose(): void;
  34991. protected _createRenderTargets(): void;
  34992. }
  34993. }
  34994. declare module BABYLON {
  34995. interface Scene {
  34996. /** @hidden (Backing field) */
  34997. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34998. /**
  34999. * Gets or Sets the current geometry buffer associated to the scene.
  35000. */
  35001. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35002. /**
  35003. * Enables a GeometryBufferRender and associates it with the scene
  35004. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35005. * @returns the GeometryBufferRenderer
  35006. */
  35007. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35008. /**
  35009. * Disables the GeometryBufferRender associated with the scene
  35010. */
  35011. disableGeometryBufferRenderer(): void;
  35012. }
  35013. /**
  35014. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35015. * in several rendering techniques.
  35016. */
  35017. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35018. /**
  35019. * The component name helpful to identify the component in the list of scene components.
  35020. */
  35021. readonly name: string;
  35022. /**
  35023. * The scene the component belongs to.
  35024. */
  35025. scene: Scene;
  35026. /**
  35027. * Creates a new instance of the component for the given scene
  35028. * @param scene Defines the scene to register the component in
  35029. */
  35030. constructor(scene: Scene);
  35031. /**
  35032. * Registers the component in a given scene
  35033. */
  35034. register(): void;
  35035. /**
  35036. * Rebuilds the elements related to this component in case of
  35037. * context lost for instance.
  35038. */
  35039. rebuild(): void;
  35040. /**
  35041. * Disposes the component and the associated ressources
  35042. */
  35043. dispose(): void;
  35044. private _gatherRenderTargets;
  35045. }
  35046. }
  35047. declare module BABYLON {
  35048. /**
  35049. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35050. */
  35051. class LineEdgesRenderer extends EdgesRenderer {
  35052. /**
  35053. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35054. * @param source LineMesh used to generate edges
  35055. * @param epsilon not important (specified angle for edge detection)
  35056. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35057. */
  35058. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35059. /**
  35060. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35061. */
  35062. _generateEdgesLines(): void;
  35063. }
  35064. }
  35065. declare module BABYLON {
  35066. interface Scene {
  35067. /** @hidden */
  35068. _outlineRenderer: OutlineRenderer;
  35069. /**
  35070. * Gets the outline renderer associated with the scene
  35071. * @returns a OutlineRenderer
  35072. */
  35073. getOutlineRenderer(): OutlineRenderer;
  35074. }
  35075. interface AbstractMesh {
  35076. /** @hidden (Backing field) */
  35077. _renderOutline: boolean;
  35078. /**
  35079. * Gets or sets a boolean indicating if the outline must be rendered as well
  35080. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35081. */
  35082. renderOutline: boolean;
  35083. /** @hidden (Backing field) */
  35084. _renderOverlay: boolean;
  35085. /**
  35086. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35087. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35088. */
  35089. renderOverlay: boolean;
  35090. }
  35091. /**
  35092. * This class is responsible to draw bothe outline/overlay of meshes.
  35093. * It should not be used directly but through the available method on mesh.
  35094. */
  35095. class OutlineRenderer implements ISceneComponent {
  35096. /**
  35097. * The name of the component. Each component must have a unique name.
  35098. */
  35099. name: string;
  35100. /**
  35101. * The scene the component belongs to.
  35102. */
  35103. scene: Scene;
  35104. /**
  35105. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35106. */
  35107. zOffset: number;
  35108. private _engine;
  35109. private _effect;
  35110. private _cachedDefines;
  35111. private _savedDepthWrite;
  35112. /**
  35113. * Instantiates a new outline renderer. (There could be only one per scene).
  35114. * @param scene Defines the scene it belongs to
  35115. */
  35116. constructor(scene: Scene);
  35117. /**
  35118. * Register the component to one instance of a scene.
  35119. */
  35120. register(): void;
  35121. /**
  35122. * Rebuilds the elements related to this component in case of
  35123. * context lost for instance.
  35124. */
  35125. rebuild(): void;
  35126. /**
  35127. * Disposes the component and the associated ressources.
  35128. */
  35129. dispose(): void;
  35130. /**
  35131. * Renders the outline in the canvas.
  35132. * @param subMesh Defines the sumesh to render
  35133. * @param batch Defines the batch of meshes in case of instances
  35134. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35135. */
  35136. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35137. /**
  35138. * Returns whether or not the outline renderer is ready for a given submesh.
  35139. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35140. * @param subMesh Defines the submesh to check readyness for
  35141. * @param useInstances Defines wheter wee are trying to render instances or not
  35142. * @returns true if ready otherwise false
  35143. */
  35144. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35145. private _beforeRenderingMesh;
  35146. private _afterRenderingMesh;
  35147. }
  35148. }
  35149. declare module BABYLON {
  35150. /**
  35151. * This represents the object necessary to create a rendering group.
  35152. * This is exclusively used and created by the rendering manager.
  35153. * To modify the behavior, you use the available helpers in your scene or meshes.
  35154. * @hidden
  35155. */
  35156. class RenderingGroup {
  35157. index: number;
  35158. private _scene;
  35159. private _opaqueSubMeshes;
  35160. private _transparentSubMeshes;
  35161. private _alphaTestSubMeshes;
  35162. private _depthOnlySubMeshes;
  35163. private _particleSystems;
  35164. private _spriteManagers;
  35165. private _opaqueSortCompareFn;
  35166. private _alphaTestSortCompareFn;
  35167. private _transparentSortCompareFn;
  35168. private _renderOpaque;
  35169. private _renderAlphaTest;
  35170. private _renderTransparent;
  35171. private _edgesRenderers;
  35172. onBeforeTransparentRendering: () => void;
  35173. /**
  35174. * Set the opaque sort comparison function.
  35175. * If null the sub meshes will be render in the order they were created
  35176. */
  35177. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35178. /**
  35179. * Set the alpha test sort comparison function.
  35180. * If null the sub meshes will be render in the order they were created
  35181. */
  35182. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35183. /**
  35184. * Set the transparent sort comparison function.
  35185. * If null the sub meshes will be render in the order they were created
  35186. */
  35187. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35188. /**
  35189. * Creates a new rendering group.
  35190. * @param index The rendering group index
  35191. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35192. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35193. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35194. */
  35195. 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>);
  35196. /**
  35197. * Render all the sub meshes contained in the group.
  35198. * @param customRenderFunction Used to override the default render behaviour of the group.
  35199. * @returns true if rendered some submeshes.
  35200. */
  35201. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35202. /**
  35203. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35204. * @param subMeshes The submeshes to render
  35205. */
  35206. private renderOpaqueSorted;
  35207. /**
  35208. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35209. * @param subMeshes The submeshes to render
  35210. */
  35211. private renderAlphaTestSorted;
  35212. /**
  35213. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35214. * @param subMeshes The submeshes to render
  35215. */
  35216. private renderTransparentSorted;
  35217. /**
  35218. * Renders the submeshes in a specified order.
  35219. * @param subMeshes The submeshes to sort before render
  35220. * @param sortCompareFn The comparison function use to sort
  35221. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35222. * @param transparent Specifies to activate blending if true
  35223. */
  35224. private static renderSorted;
  35225. /**
  35226. * Renders the submeshes in the order they were dispatched (no sort applied).
  35227. * @param subMeshes The submeshes to render
  35228. */
  35229. private static renderUnsorted;
  35230. /**
  35231. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35232. * are rendered back to front if in the same alpha index.
  35233. *
  35234. * @param a The first submesh
  35235. * @param b The second submesh
  35236. * @returns The result of the comparison
  35237. */
  35238. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35239. /**
  35240. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35241. * are rendered back to front.
  35242. *
  35243. * @param a The first submesh
  35244. * @param b The second submesh
  35245. * @returns The result of the comparison
  35246. */
  35247. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35248. /**
  35249. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35250. * are rendered front to back (prevent overdraw).
  35251. *
  35252. * @param a The first submesh
  35253. * @param b The second submesh
  35254. * @returns The result of the comparison
  35255. */
  35256. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35257. /**
  35258. * Resets the different lists of submeshes to prepare a new frame.
  35259. */
  35260. prepare(): void;
  35261. dispose(): void;
  35262. /**
  35263. * Inserts the submesh in its correct queue depending on its material.
  35264. * @param subMesh The submesh to dispatch
  35265. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35266. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35267. */
  35268. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35269. dispatchSprites(spriteManager: ISpriteManager): void;
  35270. dispatchParticles(particleSystem: IParticleSystem): void;
  35271. private _renderParticles;
  35272. private _renderSprites;
  35273. }
  35274. }
  35275. declare module BABYLON {
  35276. /**
  35277. * Interface describing the different options available in the rendering manager
  35278. * regarding Auto Clear between groups.
  35279. */
  35280. interface IRenderingManagerAutoClearSetup {
  35281. /**
  35282. * Defines whether or not autoclear is enable.
  35283. */
  35284. autoClear: boolean;
  35285. /**
  35286. * Defines whether or not to autoclear the depth buffer.
  35287. */
  35288. depth: boolean;
  35289. /**
  35290. * Defines whether or not to autoclear the stencil buffer.
  35291. */
  35292. stencil: boolean;
  35293. }
  35294. /**
  35295. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35296. * It is enable to manage the different groups as well as the different necessary sort functions.
  35297. * This should not be used directly aside of the few static configurations
  35298. */
  35299. class RenderingManager {
  35300. /**
  35301. * The max id used for rendering groups (not included)
  35302. */
  35303. static MAX_RENDERINGGROUPS: number;
  35304. /**
  35305. * The min id used for rendering groups (included)
  35306. */
  35307. static MIN_RENDERINGGROUPS: number;
  35308. /**
  35309. * Used to globally prevent autoclearing scenes.
  35310. */
  35311. static AUTOCLEAR: boolean;
  35312. /**
  35313. * @hidden
  35314. */
  35315. _useSceneAutoClearSetup: boolean;
  35316. private _scene;
  35317. private _renderingGroups;
  35318. private _depthStencilBufferAlreadyCleaned;
  35319. private _autoClearDepthStencil;
  35320. private _customOpaqueSortCompareFn;
  35321. private _customAlphaTestSortCompareFn;
  35322. private _customTransparentSortCompareFn;
  35323. private _renderingGroupInfo;
  35324. /**
  35325. * Instantiates a new rendering group for a particular scene
  35326. * @param scene Defines the scene the groups belongs to
  35327. */
  35328. constructor(scene: Scene);
  35329. private _clearDepthStencilBuffer;
  35330. /**
  35331. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35332. * @hidden
  35333. */
  35334. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35335. /**
  35336. * Resets the different information of the group to prepare a new frame
  35337. * @hidden
  35338. */
  35339. reset(): void;
  35340. /**
  35341. * Dispose and release the group and its associated resources.
  35342. * @hidden
  35343. */
  35344. dispose(): void;
  35345. /**
  35346. * Clear the info related to rendering groups preventing retention points during dispose.
  35347. */
  35348. freeRenderingGroups(): void;
  35349. private _prepareRenderingGroup;
  35350. /**
  35351. * Add a sprite manager to the rendering manager in order to render it this frame.
  35352. * @param spriteManager Define the sprite manager to render
  35353. */
  35354. dispatchSprites(spriteManager: ISpriteManager): void;
  35355. /**
  35356. * Add a particle system to the rendering manager in order to render it this frame.
  35357. * @param particleSystem Define the particle system to render
  35358. */
  35359. dispatchParticles(particleSystem: IParticleSystem): void;
  35360. /**
  35361. * Add a submesh to the manager in order to render it this frame
  35362. * @param subMesh The submesh to dispatch
  35363. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35364. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35365. */
  35366. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35367. /**
  35368. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35369. * This allowed control for front to back rendering or reversly depending of the special needs.
  35370. *
  35371. * @param renderingGroupId The rendering group id corresponding to its index
  35372. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35373. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35374. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35375. */
  35376. 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;
  35377. /**
  35378. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35379. *
  35380. * @param renderingGroupId The rendering group id corresponding to its index
  35381. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35382. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35383. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35384. */
  35385. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35386. /**
  35387. * Gets the current auto clear configuration for one rendering group of the rendering
  35388. * manager.
  35389. * @param index the rendering group index to get the information for
  35390. * @returns The auto clear setup for the requested rendering group
  35391. */
  35392. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35393. }
  35394. }
  35395. declare module BABYLON {
  35396. /**
  35397. * Renders a layer on top of an existing scene
  35398. */
  35399. class UtilityLayerRenderer implements IDisposable {
  35400. /** the original scene that will be rendered on top of */
  35401. originalScene: Scene;
  35402. private _pointerCaptures;
  35403. private _lastPointerEvents;
  35404. private static _DefaultUtilityLayer;
  35405. private static _DefaultKeepDepthUtilityLayer;
  35406. /**
  35407. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35408. */
  35409. pickUtilitySceneFirst: boolean;
  35410. /**
  35411. * 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)
  35412. */
  35413. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35414. /**
  35415. * 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)
  35416. */
  35417. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35418. /**
  35419. * The scene that is rendered on top of the original scene
  35420. */
  35421. utilityLayerScene: Scene;
  35422. /**
  35423. * If the utility layer should automatically be rendered on top of existing scene
  35424. */
  35425. shouldRender: boolean;
  35426. /**
  35427. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35428. */
  35429. onlyCheckPointerDownEvents: boolean;
  35430. /**
  35431. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35432. */
  35433. processAllEvents: boolean;
  35434. /**
  35435. * Observable raised when the pointer move from the utility layer scene to the main scene
  35436. */
  35437. onPointerOutObservable: Observable<number>;
  35438. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35439. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35440. private _afterRenderObserver;
  35441. private _sceneDisposeObserver;
  35442. private _originalPointerObserver;
  35443. /**
  35444. * Instantiates a UtilityLayerRenderer
  35445. * @param originalScene the original scene that will be rendered on top of
  35446. * @param handleEvents boolean indicating if the utility layer should handle events
  35447. */
  35448. constructor(
  35449. /** the original scene that will be rendered on top of */
  35450. originalScene: Scene, handleEvents?: boolean);
  35451. private _notifyObservers;
  35452. /**
  35453. * Renders the utility layers scene on top of the original scene
  35454. */
  35455. render(): void;
  35456. /**
  35457. * Disposes of the renderer
  35458. */
  35459. dispose(): void;
  35460. private _updateCamera;
  35461. }
  35462. }
  35463. declare module BABYLON {
  35464. /**
  35465. * Postprocess used to generate anaglyphic rendering
  35466. */
  35467. class AnaglyphPostProcess extends PostProcess {
  35468. private _passedProcess;
  35469. /**
  35470. * Creates a new AnaglyphPostProcess
  35471. * @param name defines postprocess name
  35472. * @param options defines creation options or target ratio scale
  35473. * @param rigCameras defines cameras using this postprocess
  35474. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35475. * @param engine defines hosting engine
  35476. * @param reusable defines if the postprocess will be reused multiple times per frame
  35477. */
  35478. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35479. }
  35480. }
  35481. declare module BABYLON {
  35482. /**
  35483. * Post process used to render in black and white
  35484. */
  35485. class BlackAndWhitePostProcess extends PostProcess {
  35486. /**
  35487. * Linear about to convert he result to black and white (default: 1)
  35488. */
  35489. degree: number;
  35490. /**
  35491. * Creates a black and white post process
  35492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35493. * @param name The name of the effect.
  35494. * @param options The required width/height ratio to downsize to before computing the render pass.
  35495. * @param camera The camera to apply the render pass to.
  35496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35497. * @param engine The engine which the post process will be applied. (default: current engine)
  35498. * @param reusable If the post process can be reused on the same frame. (default: false)
  35499. */
  35500. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35501. }
  35502. }
  35503. declare module BABYLON {
  35504. /**
  35505. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35506. */
  35507. class BloomEffect extends PostProcessRenderEffect {
  35508. private bloomScale;
  35509. /**
  35510. * @hidden Internal
  35511. */
  35512. _effects: Array<PostProcess>;
  35513. /**
  35514. * @hidden Internal
  35515. */
  35516. _downscale: ExtractHighlightsPostProcess;
  35517. private _blurX;
  35518. private _blurY;
  35519. private _merge;
  35520. /**
  35521. * The luminance threshold to find bright areas of the image to bloom.
  35522. */
  35523. threshold: number;
  35524. /**
  35525. * The strength of the bloom.
  35526. */
  35527. weight: number;
  35528. /**
  35529. * Specifies the size of the bloom blur kernel, relative to the final output size
  35530. */
  35531. kernel: number;
  35532. /**
  35533. * Creates a new instance of @see BloomEffect
  35534. * @param scene The scene the effect belongs to.
  35535. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35536. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35537. * @param bloomWeight The the strength of bloom.
  35538. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35539. * @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)
  35540. */
  35541. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35542. /**
  35543. * Disposes each of the internal effects for a given camera.
  35544. * @param camera The camera to dispose the effect on.
  35545. */
  35546. disposeEffects(camera: Camera): void;
  35547. /**
  35548. * @hidden Internal
  35549. */
  35550. _updateEffects(): void;
  35551. /**
  35552. * Internal
  35553. * @returns if all the contained post processes are ready.
  35554. * @hidden
  35555. */
  35556. _isReady(): boolean;
  35557. }
  35558. }
  35559. declare module BABYLON {
  35560. /**
  35561. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35562. */
  35563. class BloomMergePostProcess extends PostProcess {
  35564. /** Weight of the bloom to be added to the original input. */
  35565. weight: number;
  35566. /**
  35567. * Creates a new instance of @see BloomMergePostProcess
  35568. * @param name The name of the effect.
  35569. * @param originalFromInput Post process which's input will be used for the merge.
  35570. * @param blurred Blurred highlights post process which's output will be used.
  35571. * @param weight Weight of the bloom to be added to the original input.
  35572. * @param options The required width/height ratio to downsize to before computing the render pass.
  35573. * @param camera The camera to apply the render pass to.
  35574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35575. * @param engine The engine which the post process will be applied. (default: current engine)
  35576. * @param reusable If the post process can be reused on the same frame. (default: false)
  35577. * @param textureType Type of textures used when performing the post process. (default: 0)
  35578. * @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)
  35579. */
  35580. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35581. /** Weight of the bloom to be added to the original input. */
  35582. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35583. }
  35584. }
  35585. declare module BABYLON {
  35586. /**
  35587. * The Blur Post Process which blurs an image based on a kernel and direction.
  35588. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35589. */
  35590. class BlurPostProcess extends PostProcess {
  35591. /** The direction in which to blur the image. */
  35592. direction: Vector2;
  35593. private blockCompilation;
  35594. protected _kernel: number;
  35595. protected _idealKernel: number;
  35596. protected _packedFloat: boolean;
  35597. private _staticDefines;
  35598. /**
  35599. * Sets the length in pixels of the blur sample region
  35600. */
  35601. /**
  35602. * Gets the length in pixels of the blur sample region
  35603. */
  35604. kernel: number;
  35605. /**
  35606. * Sets wether or not the blur needs to unpack/repack floats
  35607. */
  35608. /**
  35609. * Gets wether or not the blur is unpacking/repacking floats
  35610. */
  35611. packedFloat: boolean;
  35612. /**
  35613. * Creates a new instance BlurPostProcess
  35614. * @param name The name of the effect.
  35615. * @param direction The direction in which to blur the image.
  35616. * @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.
  35617. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35618. * @param camera The camera to apply the render pass to.
  35619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35620. * @param engine The engine which the post process will be applied. (default: current engine)
  35621. * @param reusable If the post process can be reused on the same frame. (default: false)
  35622. * @param textureType Type of textures used when performing the post process. (default: 0)
  35623. * @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)
  35624. */
  35625. constructor(name: string,
  35626. /** The direction in which to blur the image. */
  35627. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35628. /**
  35629. * Updates the effect with the current post process compile time values and recompiles the shader.
  35630. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35631. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35632. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35633. * @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
  35634. * @param onCompiled Called when the shader has been compiled.
  35635. * @param onError Called if there is an error when compiling a shader.
  35636. */
  35637. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35638. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35639. /**
  35640. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35641. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35642. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35643. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35644. * The gaps between physical kernels are compensated for in the weighting of the samples
  35645. * @param idealKernel Ideal blur kernel.
  35646. * @return Nearest best kernel.
  35647. */
  35648. protected _nearestBestKernel(idealKernel: number): number;
  35649. /**
  35650. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35651. * @param x The point on the Gaussian distribution to sample.
  35652. * @return the value of the Gaussian function at x.
  35653. */
  35654. protected _gaussianWeight(x: number): number;
  35655. /**
  35656. * Generates a string that can be used as a floating point number in GLSL.
  35657. * @param x Value to print.
  35658. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35659. * @return GLSL float string.
  35660. */
  35661. protected _glslFloat(x: number, decimalFigures?: number): string;
  35662. }
  35663. }
  35664. declare module BABYLON {
  35665. /**
  35666. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35667. */
  35668. class ChromaticAberrationPostProcess extends PostProcess {
  35669. /**
  35670. * The amount of seperation of rgb channels (default: 30)
  35671. */
  35672. aberrationAmount: number;
  35673. /**
  35674. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35675. */
  35676. radialIntensity: number;
  35677. /**
  35678. * 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))
  35679. */
  35680. direction: Vector2;
  35681. /**
  35682. * 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))
  35683. */
  35684. centerPosition: Vector2;
  35685. /**
  35686. * Creates a new instance ChromaticAberrationPostProcess
  35687. * @param name The name of the effect.
  35688. * @param screenWidth The width of the screen to apply the effect on.
  35689. * @param screenHeight The height of the screen to apply the effect on.
  35690. * @param options The required width/height ratio to downsize to before computing the render pass.
  35691. * @param camera The camera to apply the render pass to.
  35692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35693. * @param engine The engine which the post process will be applied. (default: current engine)
  35694. * @param reusable If the post process can be reused on the same frame. (default: false)
  35695. * @param textureType Type of textures used when performing the post process. (default: 0)
  35696. * @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)
  35697. */
  35698. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35699. }
  35700. }
  35701. declare module BABYLON {
  35702. /**
  35703. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35704. */
  35705. class CircleOfConfusionPostProcess extends PostProcess {
  35706. /**
  35707. * 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.
  35708. */
  35709. lensSize: number;
  35710. /**
  35711. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35712. */
  35713. fStop: number;
  35714. /**
  35715. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35716. */
  35717. focusDistance: number;
  35718. /**
  35719. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35720. */
  35721. focalLength: number;
  35722. private _depthTexture;
  35723. /**
  35724. * Creates a new instance CircleOfConfusionPostProcess
  35725. * @param name The name of the effect.
  35726. * @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.
  35727. * @param options The required width/height ratio to downsize to before computing the render pass.
  35728. * @param camera The camera to apply the render pass to.
  35729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35730. * @param engine The engine which the post process will be applied. (default: current engine)
  35731. * @param reusable If the post process can be reused on the same frame. (default: false)
  35732. * @param textureType Type of textures used when performing the post process. (default: 0)
  35733. * @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)
  35734. */
  35735. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35736. /**
  35737. * 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.
  35738. */
  35739. depthTexture: RenderTargetTexture;
  35740. }
  35741. }
  35742. declare module BABYLON {
  35743. /**
  35744. *
  35745. * This post-process allows the modification of rendered colors by using
  35746. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35747. *
  35748. * The object needs to be provided an url to a texture containing the color
  35749. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35750. * Use an image editing software to tweak the LUT to match your needs.
  35751. *
  35752. * For an example of a color LUT, see here:
  35753. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35754. * For explanations on color grading, see here:
  35755. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35756. *
  35757. */
  35758. class ColorCorrectionPostProcess extends PostProcess {
  35759. private _colorTableTexture;
  35760. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35761. }
  35762. }
  35763. declare module BABYLON {
  35764. /**
  35765. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35766. * input texture to perform effects such as edge detection or sharpening
  35767. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35768. */
  35769. class ConvolutionPostProcess extends PostProcess {
  35770. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35771. kernel: number[];
  35772. /**
  35773. * Creates a new instance ConvolutionPostProcess
  35774. * @param name The name of the effect.
  35775. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35776. * @param options The required width/height ratio to downsize to before computing the render pass.
  35777. * @param camera The camera to apply the render pass to.
  35778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35779. * @param engine The engine which the post process will be applied. (default: current engine)
  35780. * @param reusable If the post process can be reused on the same frame. (default: false)
  35781. * @param textureType Type of textures used when performing the post process. (default: 0)
  35782. */
  35783. constructor(name: string,
  35784. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35785. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35786. /**
  35787. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35788. */
  35789. static EdgeDetect0Kernel: number[];
  35790. /**
  35791. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35792. */
  35793. static EdgeDetect1Kernel: number[];
  35794. /**
  35795. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35796. */
  35797. static EdgeDetect2Kernel: number[];
  35798. /**
  35799. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35800. */
  35801. static SharpenKernel: number[];
  35802. /**
  35803. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35804. */
  35805. static EmbossKernel: number[];
  35806. /**
  35807. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35808. */
  35809. static GaussianKernel: number[];
  35810. }
  35811. }
  35812. declare module BABYLON {
  35813. /**
  35814. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  35815. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  35816. * based on samples that have a large difference in distance than the center pixel.
  35817. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  35818. */
  35819. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  35820. direction: Vector2;
  35821. /**
  35822. * Creates a new instance CircleOfConfusionPostProcess
  35823. * @param name The name of the effect.
  35824. * @param scene The scene the effect belongs to.
  35825. * @param direction The direction the blur should be applied.
  35826. * @param kernel The size of the kernel used to blur.
  35827. * @param options The required width/height ratio to downsize to before computing the render pass.
  35828. * @param camera The camera to apply the render pass to.
  35829. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  35830. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  35831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35832. * @param engine The engine which the post process will be applied. (default: current engine)
  35833. * @param reusable If the post process can be reused on the same frame. (default: false)
  35834. * @param textureType Type of textures used when performing the post process. (default: 0)
  35835. * @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)
  35836. */
  35837. 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);
  35838. }
  35839. }
  35840. declare module BABYLON {
  35841. /**
  35842. * Specifies the level of max blur that should be applied when using the depth of field effect
  35843. */
  35844. enum DepthOfFieldEffectBlurLevel {
  35845. /**
  35846. * Subtle blur
  35847. */
  35848. Low = 0,
  35849. /**
  35850. * Medium blur
  35851. */
  35852. Medium = 1,
  35853. /**
  35854. * Large blur
  35855. */
  35856. High = 2
  35857. }
  35858. /**
  35859. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  35860. */
  35861. class DepthOfFieldEffect extends PostProcessRenderEffect {
  35862. private _circleOfConfusion;
  35863. /**
  35864. * @hidden Internal, blurs from high to low
  35865. */
  35866. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  35867. private _depthOfFieldBlurY;
  35868. private _dofMerge;
  35869. /**
  35870. * @hidden Internal post processes in depth of field effect
  35871. */
  35872. _effects: Array<PostProcess>;
  35873. /**
  35874. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  35875. */
  35876. focalLength: number;
  35877. /**
  35878. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35879. */
  35880. fStop: number;
  35881. /**
  35882. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35883. */
  35884. focusDistance: number;
  35885. /**
  35886. * 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.
  35887. */
  35888. lensSize: number;
  35889. /**
  35890. * Creates a new instance DepthOfFieldEffect
  35891. * @param scene The scene the effect belongs to.
  35892. * @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.
  35893. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35894. * @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)
  35895. */
  35896. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35897. /**
  35898. * 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.
  35899. */
  35900. depthTexture: RenderTargetTexture;
  35901. /**
  35902. * Disposes each of the internal effects for a given camera.
  35903. * @param camera The camera to dispose the effect on.
  35904. */
  35905. disposeEffects(camera: Camera): void;
  35906. /**
  35907. * @hidden Internal
  35908. */
  35909. _updateEffects(): void;
  35910. /**
  35911. * Internal
  35912. * @returns if all the contained post processes are ready.
  35913. * @hidden
  35914. */
  35915. _isReady(): boolean;
  35916. }
  35917. }
  35918. declare module BABYLON {
  35919. /**
  35920. * Options to be set when merging outputs from the default pipeline.
  35921. */
  35922. class DepthOfFieldMergePostProcessOptions {
  35923. /**
  35924. * The original image to merge on top of
  35925. */
  35926. originalFromInput: PostProcess;
  35927. /**
  35928. * Parameters to perform the merge of the depth of field effect
  35929. */
  35930. depthOfField?: {
  35931. circleOfConfusion: PostProcess;
  35932. blurSteps: Array<PostProcess>;
  35933. };
  35934. /**
  35935. * Parameters to perform the merge of bloom effect
  35936. */
  35937. bloom?: {
  35938. blurred: PostProcess;
  35939. weight: number;
  35940. };
  35941. }
  35942. /**
  35943. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35944. */
  35945. class DepthOfFieldMergePostProcess extends PostProcess {
  35946. private blurSteps;
  35947. /**
  35948. * Creates a new instance of DepthOfFieldMergePostProcess
  35949. * @param name The name of the effect.
  35950. * @param originalFromInput Post process which's input will be used for the merge.
  35951. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35952. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35953. * @param options The required width/height ratio to downsize to before computing the render pass.
  35954. * @param camera The camera to apply the render pass to.
  35955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35956. * @param engine The engine which the post process will be applied. (default: current engine)
  35957. * @param reusable If the post process can be reused on the same frame. (default: false)
  35958. * @param textureType Type of textures used when performing the post process. (default: 0)
  35959. * @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)
  35960. */
  35961. 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);
  35962. /**
  35963. * Updates the effect with the current post process compile time values and recompiles the shader.
  35964. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35965. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35966. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35967. * @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
  35968. * @param onCompiled Called when the shader has been compiled.
  35969. * @param onError Called if there is an error when compiling a shader.
  35970. */
  35971. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35972. }
  35973. }
  35974. declare module BABYLON {
  35975. /**
  35976. * DisplayPassPostProcess which produces an output the same as it's input
  35977. */
  35978. class DisplayPassPostProcess extends PostProcess {
  35979. /**
  35980. * Creates the DisplayPassPostProcess
  35981. * @param name The name of the effect.
  35982. * @param options The required width/height ratio to downsize to before computing the render pass.
  35983. * @param camera The camera to apply the render pass to.
  35984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35985. * @param engine The engine which the post process will be applied. (default: current engine)
  35986. * @param reusable If the post process can be reused on the same frame. (default: false)
  35987. */
  35988. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35989. }
  35990. }
  35991. declare module BABYLON {
  35992. /**
  35993. * 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.
  35994. */
  35995. class ExtractHighlightsPostProcess extends PostProcess {
  35996. /**
  35997. * The luminance threshold, pixels below this value will be set to black.
  35998. */
  35999. threshold: number;
  36000. /** @hidden */
  36001. _exposure: number;
  36002. /**
  36003. * Post process which has the input texture to be used when performing highlight extraction
  36004. * @hidden
  36005. */
  36006. _inputPostProcess: Nullable<PostProcess>;
  36007. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36008. }
  36009. }
  36010. declare module BABYLON {
  36011. /**
  36012. * Applies a kernel filter to the image
  36013. */
  36014. class FilterPostProcess extends PostProcess {
  36015. /** The matrix to be applied to the image */
  36016. kernelMatrix: Matrix;
  36017. /**
  36018. *
  36019. * @param name The name of the effect.
  36020. * @param kernelMatrix The matrix to be applied to the image
  36021. * @param options The required width/height ratio to downsize to before computing the render pass.
  36022. * @param camera The camera to apply the render pass to.
  36023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36024. * @param engine The engine which the post process will be applied. (default: current engine)
  36025. * @param reusable If the post process can be reused on the same frame. (default: false)
  36026. */
  36027. constructor(name: string,
  36028. /** The matrix to be applied to the image */
  36029. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36030. }
  36031. }
  36032. declare module BABYLON {
  36033. /**
  36034. * Fxaa post process
  36035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  36036. */
  36037. class FxaaPostProcess extends PostProcess {
  36038. /** @hidden */
  36039. texelWidth: number;
  36040. /** @hidden */
  36041. texelHeight: number;
  36042. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36043. private _getDefines;
  36044. }
  36045. }
  36046. declare module BABYLON {
  36047. /**
  36048. * The GrainPostProcess adds noise to the image at mid luminance levels
  36049. */
  36050. class GrainPostProcess extends PostProcess {
  36051. /**
  36052. * The intensity of the grain added (default: 30)
  36053. */
  36054. intensity: number;
  36055. /**
  36056. * If the grain should be randomized on every frame
  36057. */
  36058. animated: boolean;
  36059. /**
  36060. * Creates a new instance of @see GrainPostProcess
  36061. * @param name The name of the effect.
  36062. * @param options The required width/height ratio to downsize to before computing the render pass.
  36063. * @param camera The camera to apply the render pass to.
  36064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36065. * @param engine The engine which the post process will be applied. (default: current engine)
  36066. * @param reusable If the post process can be reused on the same frame. (default: false)
  36067. * @param textureType Type of textures used when performing the post process. (default: 0)
  36068. * @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)
  36069. */
  36070. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36071. }
  36072. }
  36073. declare module BABYLON {
  36074. /**
  36075. * Extracts highlights from the image
  36076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36077. */
  36078. class HighlightsPostProcess extends PostProcess {
  36079. /**
  36080. * Extracts highlights from the image
  36081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36082. * @param name The name of the effect.
  36083. * @param options The required width/height ratio to downsize to before computing the render pass.
  36084. * @param camera The camera to apply the render pass to.
  36085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36086. * @param engine The engine which the post process will be applied. (default: current engine)
  36087. * @param reusable If the post process can be reused on the same frame. (default: false)
  36088. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  36089. */
  36090. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36091. }
  36092. }
  36093. declare module BABYLON {
  36094. /**
  36095. * ImageProcessingPostProcess
  36096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  36097. */
  36098. class ImageProcessingPostProcess extends PostProcess {
  36099. /**
  36100. * Default configuration related to image processing available in the PBR Material.
  36101. */
  36102. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36103. /**
  36104. * Gets the image processing configuration used either in this material.
  36105. */
  36106. /**
  36107. * Sets the Default image processing configuration used either in the this material.
  36108. *
  36109. * If sets to null, the scene one is in use.
  36110. */
  36111. imageProcessingConfiguration: ImageProcessingConfiguration;
  36112. /**
  36113. * Keep track of the image processing observer to allow dispose and replace.
  36114. */
  36115. private _imageProcessingObserver;
  36116. /**
  36117. * Attaches a new image processing configuration to the PBR Material.
  36118. * @param configuration
  36119. */
  36120. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  36121. /**
  36122. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36123. */
  36124. /**
  36125. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36126. */
  36127. colorCurves: Nullable<ColorCurves>;
  36128. /**
  36129. * Gets wether the color curves effect is enabled.
  36130. */
  36131. /**
  36132. * Sets wether the color curves effect is enabled.
  36133. */
  36134. colorCurvesEnabled: boolean;
  36135. /**
  36136. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36137. */
  36138. /**
  36139. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36140. */
  36141. colorGradingTexture: Nullable<BaseTexture>;
  36142. /**
  36143. * Gets wether the color grading effect is enabled.
  36144. */
  36145. /**
  36146. * Gets wether the color grading effect is enabled.
  36147. */
  36148. colorGradingEnabled: boolean;
  36149. /**
  36150. * Gets exposure used in the effect.
  36151. */
  36152. /**
  36153. * Sets exposure used in the effect.
  36154. */
  36155. exposure: number;
  36156. /**
  36157. * Gets wether tonemapping is enabled or not.
  36158. */
  36159. /**
  36160. * Sets wether tonemapping is enabled or not
  36161. */
  36162. toneMappingEnabled: boolean;
  36163. /**
  36164. * Gets contrast used in the effect.
  36165. */
  36166. /**
  36167. * Sets contrast used in the effect.
  36168. */
  36169. contrast: number;
  36170. /**
  36171. * Gets Vignette stretch size.
  36172. */
  36173. /**
  36174. * Sets Vignette stretch size.
  36175. */
  36176. vignetteStretch: number;
  36177. /**
  36178. * Gets Vignette centre X Offset.
  36179. */
  36180. /**
  36181. * Sets Vignette centre X Offset.
  36182. */
  36183. vignetteCentreX: number;
  36184. /**
  36185. * Gets Vignette centre Y Offset.
  36186. */
  36187. /**
  36188. * Sets Vignette centre Y Offset.
  36189. */
  36190. vignetteCentreY: number;
  36191. /**
  36192. * Gets Vignette weight or intensity of the vignette effect.
  36193. */
  36194. /**
  36195. * Sets Vignette weight or intensity of the vignette effect.
  36196. */
  36197. vignetteWeight: number;
  36198. /**
  36199. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36200. * if vignetteEnabled is set to true.
  36201. */
  36202. /**
  36203. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36204. * if vignetteEnabled is set to true.
  36205. */
  36206. vignetteColor: Color4;
  36207. /**
  36208. * Gets Camera field of view used by the Vignette effect.
  36209. */
  36210. /**
  36211. * Sets Camera field of view used by the Vignette effect.
  36212. */
  36213. vignetteCameraFov: number;
  36214. /**
  36215. * Gets the vignette blend mode allowing different kind of effect.
  36216. */
  36217. /**
  36218. * Sets the vignette blend mode allowing different kind of effect.
  36219. */
  36220. vignetteBlendMode: number;
  36221. /**
  36222. * Gets wether the vignette effect is enabled.
  36223. */
  36224. /**
  36225. * Sets wether the vignette effect is enabled.
  36226. */
  36227. vignetteEnabled: boolean;
  36228. private _fromLinearSpace;
  36229. /**
  36230. * Gets wether the input of the processing is in Gamma or Linear Space.
  36231. */
  36232. /**
  36233. * Sets wether the input of the processing is in Gamma or Linear Space.
  36234. */
  36235. fromLinearSpace: boolean;
  36236. /**
  36237. * Defines cache preventing GC.
  36238. */
  36239. private _defines;
  36240. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  36241. /**
  36242. * "ImageProcessingPostProcess"
  36243. * @returns "ImageProcessingPostProcess"
  36244. */
  36245. getClassName(): string;
  36246. protected _updateParameters(): void;
  36247. dispose(camera?: Camera): void;
  36248. }
  36249. }
  36250. declare module BABYLON {
  36251. /**
  36252. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  36253. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  36254. * As an example, all you have to do is to create the post-process:
  36255. * var mb = new BABYLON.MotionBlurPostProcess(
  36256. * 'mb', // The name of the effect.
  36257. * scene, // The scene containing the objects to blur according to their velocity.
  36258. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36259. * camera // The camera to apply the render pass to.
  36260. * );
  36261. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36262. */
  36263. class MotionBlurPostProcess extends PostProcess {
  36264. /**
  36265. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36266. */
  36267. motionStrength: number;
  36268. /**
  36269. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36270. */
  36271. /**
  36272. * Sets the number of iterations to be used for motion blur quality
  36273. */
  36274. motionBlurSamples: number;
  36275. private _motionBlurSamples;
  36276. private _geometryBufferRenderer;
  36277. /**
  36278. * Creates a new instance MotionBlurPostProcess
  36279. * @param name The name of the effect.
  36280. * @param scene The scene containing the objects to blur according to their velocity.
  36281. * @param options The required width/height ratio to downsize to before computing the render pass.
  36282. * @param camera The camera to apply the render pass to.
  36283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36284. * @param engine The engine which the post process will be applied. (default: current engine)
  36285. * @param reusable If the post process can be reused on the same frame. (default: false)
  36286. * @param textureType Type of textures used when performing the post process. (default: 0)
  36287. * @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)
  36288. */
  36289. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36290. /**
  36291. * Disposes the post process.
  36292. * @param camera The camera to dispose the post process on.
  36293. */
  36294. dispose(camera?: Camera): void;
  36295. }
  36296. }
  36297. declare module BABYLON {
  36298. /**
  36299. * PassPostProcess which produces an output the same as it's input
  36300. */
  36301. class PassPostProcess extends PostProcess {
  36302. /**
  36303. * Creates the PassPostProcess
  36304. * @param name The name of the effect.
  36305. * @param options The required width/height ratio to downsize to before computing the render pass.
  36306. * @param camera The camera to apply the render pass to.
  36307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36308. * @param engine The engine which the post process will be applied. (default: current engine)
  36309. * @param reusable If the post process can be reused on the same frame. (default: false)
  36310. * @param textureType The type of texture to be used when performing the post processing.
  36311. * @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)
  36312. */
  36313. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36314. }
  36315. /**
  36316. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36317. */
  36318. class PassCubePostProcess extends PostProcess {
  36319. private _face;
  36320. /**
  36321. * Gets or sets the cube face to display.
  36322. * * 0 is +X
  36323. * * 1 is -X
  36324. * * 2 is +Y
  36325. * * 3 is -Y
  36326. * * 4 is +Z
  36327. * * 5 is -Z
  36328. */
  36329. face: number;
  36330. /**
  36331. * Creates the PassCubePostProcess
  36332. * @param name The name of the effect.
  36333. * @param options The required width/height ratio to downsize to before computing the render pass.
  36334. * @param camera The camera to apply the render pass to.
  36335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36336. * @param engine The engine which the post process will be applied. (default: current engine)
  36337. * @param reusable If the post process can be reused on the same frame. (default: false)
  36338. * @param textureType The type of texture to be used when performing the post processing.
  36339. * @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)
  36340. */
  36341. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36342. }
  36343. }
  36344. declare module BABYLON {
  36345. /**
  36346. * Size options for a post process
  36347. */
  36348. type PostProcessOptions = {
  36349. width: number;
  36350. height: number;
  36351. };
  36352. /**
  36353. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36354. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36355. */
  36356. class PostProcess {
  36357. /** Name of the PostProcess. */
  36358. name: string;
  36359. /**
  36360. * Width of the texture to apply the post process on
  36361. */
  36362. width: number;
  36363. /**
  36364. * Height of the texture to apply the post process on
  36365. */
  36366. height: number;
  36367. /**
  36368. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36369. * @hidden
  36370. */
  36371. _outputTexture: Nullable<InternalTexture>;
  36372. /**
  36373. * Sampling mode used by the shader
  36374. * See https://doc.babylonjs.com/classes/3.1/texture
  36375. */
  36376. renderTargetSamplingMode: number;
  36377. /**
  36378. * Clear color to use when screen clearing
  36379. */
  36380. clearColor: Color4;
  36381. /**
  36382. * If the buffer needs to be cleared before applying the post process. (default: true)
  36383. * Should be set to false if shader will overwrite all previous pixels.
  36384. */
  36385. autoClear: boolean;
  36386. /**
  36387. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36388. */
  36389. alphaMode: number;
  36390. /**
  36391. * Sets the setAlphaBlendConstants of the babylon engine
  36392. */
  36393. alphaConstants: Color4;
  36394. /**
  36395. * Animations to be used for the post processing
  36396. */
  36397. animations: Animation[];
  36398. /**
  36399. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36400. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36401. */
  36402. enablePixelPerfectMode: boolean;
  36403. /**
  36404. * Force the postprocess to be applied without taking in account viewport
  36405. */
  36406. forceFullscreenViewport: boolean;
  36407. /**
  36408. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36409. *
  36410. * | Value | Type | Description |
  36411. * | ----- | ----------------------------------- | ----------- |
  36412. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36413. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36414. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36415. *
  36416. */
  36417. scaleMode: number;
  36418. /**
  36419. * Force textures to be a power of two (default: false)
  36420. */
  36421. alwaysForcePOT: boolean;
  36422. private _samples;
  36423. /**
  36424. * Number of sample textures (default: 1)
  36425. */
  36426. samples: number;
  36427. /**
  36428. * Modify the scale of the post process to be the same as the viewport (default: false)
  36429. */
  36430. adaptScaleToCurrentViewport: boolean;
  36431. private _camera;
  36432. private _scene;
  36433. private _engine;
  36434. private _options;
  36435. private _reusable;
  36436. private _textureType;
  36437. /**
  36438. * Smart array of input and output textures for the post process.
  36439. * @hidden
  36440. */
  36441. _textures: SmartArray<InternalTexture>;
  36442. /**
  36443. * The index in _textures that corresponds to the output texture.
  36444. * @hidden
  36445. */
  36446. _currentRenderTextureInd: number;
  36447. private _effect;
  36448. private _samplers;
  36449. private _fragmentUrl;
  36450. private _vertexUrl;
  36451. private _parameters;
  36452. private _scaleRatio;
  36453. protected _indexParameters: any;
  36454. private _shareOutputWithPostProcess;
  36455. private _texelSize;
  36456. private _forcedOutputTexture;
  36457. /**
  36458. * An event triggered when the postprocess is activated.
  36459. */
  36460. onActivateObservable: Observable<Camera>;
  36461. private _onActivateObserver;
  36462. /**
  36463. * A function that is added to the onActivateObservable
  36464. */
  36465. onActivate: Nullable<(camera: Camera) => void>;
  36466. /**
  36467. * An event triggered when the postprocess changes its size.
  36468. */
  36469. onSizeChangedObservable: Observable<PostProcess>;
  36470. private _onSizeChangedObserver;
  36471. /**
  36472. * A function that is added to the onSizeChangedObservable
  36473. */
  36474. onSizeChanged: (postProcess: PostProcess) => void;
  36475. /**
  36476. * An event triggered when the postprocess applies its effect.
  36477. */
  36478. onApplyObservable: Observable<Effect>;
  36479. private _onApplyObserver;
  36480. /**
  36481. * A function that is added to the onApplyObservable
  36482. */
  36483. onApply: (effect: Effect) => void;
  36484. /**
  36485. * An event triggered before rendering the postprocess
  36486. */
  36487. onBeforeRenderObservable: Observable<Effect>;
  36488. private _onBeforeRenderObserver;
  36489. /**
  36490. * A function that is added to the onBeforeRenderObservable
  36491. */
  36492. onBeforeRender: (effect: Effect) => void;
  36493. /**
  36494. * An event triggered after rendering the postprocess
  36495. */
  36496. onAfterRenderObservable: Observable<Effect>;
  36497. private _onAfterRenderObserver;
  36498. /**
  36499. * A function that is added to the onAfterRenderObservable
  36500. */
  36501. onAfterRender: (efect: Effect) => void;
  36502. /**
  36503. * 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
  36504. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36505. */
  36506. inputTexture: InternalTexture;
  36507. /**
  36508. * Gets the camera which post process is applied to.
  36509. * @returns The camera the post process is applied to.
  36510. */
  36511. getCamera(): Camera;
  36512. /**
  36513. * Gets the texel size of the postprocess.
  36514. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36515. */
  36516. readonly texelSize: Vector2;
  36517. /**
  36518. * Creates a new instance PostProcess
  36519. * @param name The name of the PostProcess.
  36520. * @param fragmentUrl The url of the fragment shader to be used.
  36521. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36522. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36523. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36524. * @param camera The camera to apply the render pass to.
  36525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36526. * @param engine The engine which the post process will be applied. (default: current engine)
  36527. * @param reusable If the post process can be reused on the same frame. (default: false)
  36528. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36529. * @param textureType Type of textures used when performing the post process. (default: 0)
  36530. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36531. * @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
  36532. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36533. */
  36534. constructor(
  36535. /** Name of the PostProcess. */
  36536. 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);
  36537. /**
  36538. * Gets the engine which this post process belongs to.
  36539. * @returns The engine the post process was enabled with.
  36540. */
  36541. getEngine(): Engine;
  36542. /**
  36543. * The effect that is created when initializing the post process.
  36544. * @returns The created effect corrisponding the the postprocess.
  36545. */
  36546. getEffect(): Effect;
  36547. /**
  36548. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36549. * @param postProcess The post process to share the output with.
  36550. * @returns This post process.
  36551. */
  36552. shareOutputWith(postProcess: PostProcess): PostProcess;
  36553. /**
  36554. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36555. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36556. */
  36557. useOwnOutput(): void;
  36558. /**
  36559. * Updates the effect with the current post process compile time values and recompiles the shader.
  36560. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36561. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36562. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36563. * @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
  36564. * @param onCompiled Called when the shader has been compiled.
  36565. * @param onError Called if there is an error when compiling a shader.
  36566. */
  36567. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36568. /**
  36569. * The post process is reusable if it can be used multiple times within one frame.
  36570. * @returns If the post process is reusable
  36571. */
  36572. isReusable(): boolean;
  36573. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36574. markTextureDirty(): void;
  36575. /**
  36576. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36577. * 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.
  36578. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36579. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36580. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36581. * @returns The target texture that was bound to be written to.
  36582. */
  36583. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36584. /**
  36585. * If the post process is supported.
  36586. */
  36587. readonly isSupported: boolean;
  36588. /**
  36589. * The aspect ratio of the output texture.
  36590. */
  36591. readonly aspectRatio: number;
  36592. /**
  36593. * Get a value indicating if the post-process is ready to be used
  36594. * @returns true if the post-process is ready (shader is compiled)
  36595. */
  36596. isReady(): boolean;
  36597. /**
  36598. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36599. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36600. */
  36601. apply(): Nullable<Effect>;
  36602. private _disposeTextures;
  36603. /**
  36604. * Disposes the post process.
  36605. * @param camera The camera to dispose the post process on.
  36606. */
  36607. dispose(camera?: Camera): void;
  36608. }
  36609. }
  36610. declare module BABYLON {
  36611. /**
  36612. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36613. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36614. */
  36615. class PostProcessManager {
  36616. private _scene;
  36617. private _indexBuffer;
  36618. private _vertexBuffers;
  36619. /**
  36620. * Creates a new instance PostProcess
  36621. * @param scene The scene that the post process is associated with.
  36622. */
  36623. constructor(scene: Scene);
  36624. private _prepareBuffers;
  36625. private _buildIndexBuffer;
  36626. /**
  36627. * Rebuilds the vertex buffers of the manager.
  36628. * @hidden
  36629. */
  36630. _rebuild(): void;
  36631. /**
  36632. * Prepares a frame to be run through a post process.
  36633. * @param sourceTexture The input texture to the post procesess. (default: null)
  36634. * @param postProcesses An array of post processes to be run. (default: null)
  36635. * @returns True if the post processes were able to be run.
  36636. * @hidden
  36637. */
  36638. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36639. /**
  36640. * Manually render a set of post processes to a texture.
  36641. * @param postProcesses An array of post processes to be run.
  36642. * @param targetTexture The target texture to render to.
  36643. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36644. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36645. * @param lodLevel defines which lod of the texture to render to
  36646. */
  36647. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36648. /**
  36649. * Finalize the result of the output of the postprocesses.
  36650. * @param doNotPresent If true the result will not be displayed to the screen.
  36651. * @param targetTexture The target texture to render to.
  36652. * @param faceIndex The index of the face to bind the target texture to.
  36653. * @param postProcesses The array of post processes to render.
  36654. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36655. * @hidden
  36656. */
  36657. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36658. /**
  36659. * Disposes of the post process manager.
  36660. */
  36661. dispose(): void;
  36662. }
  36663. }
  36664. declare module BABYLON {
  36665. /**
  36666. * Post process which applies a refractin texture
  36667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36668. */
  36669. class RefractionPostProcess extends PostProcess {
  36670. /** the base color of the refraction (used to taint the rendering) */
  36671. color: Color3;
  36672. /** simulated refraction depth */
  36673. depth: number;
  36674. /** the coefficient of the base color (0 to remove base color tainting) */
  36675. colorLevel: number;
  36676. private _refTexture;
  36677. private _ownRefractionTexture;
  36678. /**
  36679. * Gets or sets the refraction texture
  36680. * Please note that you are responsible for disposing the texture if you set it manually
  36681. */
  36682. refractionTexture: Texture;
  36683. /**
  36684. * Initializes the RefractionPostProcess
  36685. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36686. * @param name The name of the effect.
  36687. * @param refractionTextureUrl Url of the refraction texture to use
  36688. * @param color the base color of the refraction (used to taint the rendering)
  36689. * @param depth simulated refraction depth
  36690. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36691. * @param camera The camera to apply the render pass to.
  36692. * @param options The required width/height ratio to downsize to before computing the render pass.
  36693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36694. * @param engine The engine which the post process will be applied. (default: current engine)
  36695. * @param reusable If the post process can be reused on the same frame. (default: false)
  36696. */
  36697. constructor(name: string, refractionTextureUrl: string,
  36698. /** the base color of the refraction (used to taint the rendering) */
  36699. color: Color3,
  36700. /** simulated refraction depth */
  36701. depth: number,
  36702. /** the coefficient of the base color (0 to remove base color tainting) */
  36703. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36704. /**
  36705. * Disposes of the post process
  36706. * @param camera Camera to dispose post process on
  36707. */
  36708. dispose(camera: Camera): void;
  36709. }
  36710. }
  36711. declare module BABYLON {
  36712. /**
  36713. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36714. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36715. */
  36716. class SharpenPostProcess extends PostProcess {
  36717. /**
  36718. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36719. */
  36720. colorAmount: number;
  36721. /**
  36722. * How much sharpness should be applied (default: 0.3)
  36723. */
  36724. edgeAmount: number;
  36725. /**
  36726. * Creates a new instance ConvolutionPostProcess
  36727. * @param name The name of the effect.
  36728. * @param options The required width/height ratio to downsize to before computing the render pass.
  36729. * @param camera The camera to apply the render pass to.
  36730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36731. * @param engine The engine which the post process will be applied. (default: current engine)
  36732. * @param reusable If the post process can be reused on the same frame. (default: false)
  36733. * @param textureType Type of textures used when performing the post process. (default: 0)
  36734. * @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)
  36735. */
  36736. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36737. }
  36738. }
  36739. declare module BABYLON {
  36740. /**
  36741. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36742. */
  36743. class StereoscopicInterlacePostProcess extends PostProcess {
  36744. private _stepSize;
  36745. private _passedProcess;
  36746. /**
  36747. * Initializes a StereoscopicInterlacePostProcess
  36748. * @param name The name of the effect.
  36749. * @param rigCameras The rig cameras to be appled to the post process
  36750. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36752. * @param engine The engine which the post process will be applied. (default: current engine)
  36753. * @param reusable If the post process can be reused on the same frame. (default: false)
  36754. */
  36755. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36756. }
  36757. }
  36758. declare module BABYLON {
  36759. /** Defines operator used for tonemapping */
  36760. enum TonemappingOperator {
  36761. /** Hable */
  36762. Hable = 0,
  36763. /** Reinhard */
  36764. Reinhard = 1,
  36765. /** HejiDawson */
  36766. HejiDawson = 2,
  36767. /** Photographic */
  36768. Photographic = 3
  36769. }
  36770. /**
  36771. * Defines a post process to apply tone mapping
  36772. */
  36773. class TonemapPostProcess extends PostProcess {
  36774. private _operator;
  36775. /** Defines the required exposure adjustement */
  36776. exposureAdjustment: number;
  36777. /**
  36778. * Creates a new TonemapPostProcess
  36779. * @param name defines the name of the postprocess
  36780. * @param _operator defines the operator to use
  36781. * @param exposureAdjustment defines the required exposure adjustement
  36782. * @param camera defines the camera to use (can be null)
  36783. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36784. * @param engine defines the hosting engine (can be ignore if camera is set)
  36785. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36786. */
  36787. constructor(name: string, _operator: TonemappingOperator,
  36788. /** Defines the required exposure adjustement */
  36789. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36790. }
  36791. }
  36792. declare module BABYLON {
  36793. /**
  36794. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36795. */
  36796. class VolumetricLightScatteringPostProcess extends PostProcess {
  36797. private _volumetricLightScatteringPass;
  36798. private _volumetricLightScatteringRTT;
  36799. private _viewPort;
  36800. private _screenCoordinates;
  36801. private _cachedDefines;
  36802. /**
  36803. * If not undefined, the mesh position is computed from the attached node position
  36804. */
  36805. attachedNode: {
  36806. position: Vector3;
  36807. };
  36808. /**
  36809. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  36810. */
  36811. customMeshPosition: Vector3;
  36812. /**
  36813. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  36814. */
  36815. useCustomMeshPosition: boolean;
  36816. /**
  36817. * If the post-process should inverse the light scattering direction
  36818. */
  36819. invert: boolean;
  36820. /**
  36821. * The internal mesh used by the post-process
  36822. */
  36823. mesh: Mesh;
  36824. /**
  36825. * @hidden
  36826. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  36827. */
  36828. useDiffuseColor: boolean;
  36829. /**
  36830. * Array containing the excluded meshes not rendered in the internal pass
  36831. */
  36832. excludedMeshes: AbstractMesh[];
  36833. /**
  36834. * Controls the overall intensity of the post-process
  36835. */
  36836. exposure: number;
  36837. /**
  36838. * Dissipates each sample's contribution in range [0, 1]
  36839. */
  36840. decay: number;
  36841. /**
  36842. * Controls the overall intensity of each sample
  36843. */
  36844. weight: number;
  36845. /**
  36846. * Controls the density of each sample
  36847. */
  36848. density: number;
  36849. /**
  36850. * @constructor
  36851. * @param name The post-process name
  36852. * @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)
  36853. * @param camera The camera that the post-process will be attached to
  36854. * @param mesh The mesh used to create the light scattering
  36855. * @param samples The post-process quality, default 100
  36856. * @param samplingModeThe post-process filtering mode
  36857. * @param engine The babylon engine
  36858. * @param reusable If the post-process is reusable
  36859. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  36860. */
  36861. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  36862. /**
  36863. * Returns the string "VolumetricLightScatteringPostProcess"
  36864. * @returns "VolumetricLightScatteringPostProcess"
  36865. */
  36866. getClassName(): string;
  36867. private _isReady;
  36868. /**
  36869. * Sets the new light position for light scattering effect
  36870. * @param position The new custom light position
  36871. */
  36872. setCustomMeshPosition(position: Vector3): void;
  36873. /**
  36874. * Returns the light position for light scattering effect
  36875. * @return Vector3 The custom light position
  36876. */
  36877. getCustomMeshPosition(): Vector3;
  36878. /**
  36879. * Disposes the internal assets and detaches the post-process from the camera
  36880. */
  36881. dispose(camera: Camera): void;
  36882. /**
  36883. * Returns the render target texture used by the post-process
  36884. * @return the render target texture used by the post-process
  36885. */
  36886. getPass(): RenderTargetTexture;
  36887. private _meshExcluded;
  36888. private _createPass;
  36889. private _updateMeshScreenCoordinates;
  36890. /**
  36891. * Creates a default mesh for the Volumeric Light Scattering post-process
  36892. * @param name The mesh name
  36893. * @param scene The scene where to create the mesh
  36894. * @return the default mesh
  36895. */
  36896. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36897. }
  36898. }
  36899. declare module BABYLON {
  36900. /**
  36901. * VRDistortionCorrectionPostProcess used for mobile VR
  36902. */
  36903. class VRDistortionCorrectionPostProcess extends PostProcess {
  36904. private _isRightEye;
  36905. private _distortionFactors;
  36906. private _postProcessScaleFactor;
  36907. private _lensCenterOffset;
  36908. private _scaleIn;
  36909. private _scaleFactor;
  36910. private _lensCenter;
  36911. /**
  36912. * Initializes the VRDistortionCorrectionPostProcess
  36913. * @param name The name of the effect.
  36914. * @param camera The camera to apply the render pass to.
  36915. * @param isRightEye If this is for the right eye distortion
  36916. * @param vrMetrics All the required metrics for the VR camera
  36917. */
  36918. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. /**
  36923. * Class used to represent a sprite
  36924. * @see http://doc.babylonjs.com/babylon101/sprites
  36925. */
  36926. class Sprite {
  36927. /** defines the name */
  36928. name: string;
  36929. /** Gets or sets the current world position */
  36930. position: Vector3;
  36931. /** Gets or sets the main color */
  36932. color: Color4;
  36933. /** Gets or sets the width */
  36934. width: number;
  36935. /** Gets or sets the height */
  36936. height: number;
  36937. /** Gets or sets rotation angle */
  36938. angle: number;
  36939. /** Gets or sets the cell index in the sprite sheet */
  36940. cellIndex: number;
  36941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36942. invertU: number;
  36943. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36944. invertV: number;
  36945. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36946. disposeWhenFinishedAnimating: boolean;
  36947. /** Gets the list of attached animations */
  36948. animations: Animation[];
  36949. /** Gets or sets a boolean indicating if the sprite can be picked */
  36950. isPickable: boolean;
  36951. /**
  36952. * Gets or sets the associated action manager
  36953. */
  36954. actionManager: Nullable<ActionManager>;
  36955. private _animationStarted;
  36956. private _loopAnimation;
  36957. private _fromIndex;
  36958. private _toIndex;
  36959. private _delay;
  36960. private _direction;
  36961. private _manager;
  36962. private _time;
  36963. private _onAnimationEnd;
  36964. /**
  36965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36966. */
  36967. isVisible: boolean;
  36968. /**
  36969. * Gets or sets the sprite size
  36970. */
  36971. size: number;
  36972. /**
  36973. * Creates a new Sprite
  36974. * @param name defines the name
  36975. * @param manager defines the manager
  36976. */
  36977. constructor(
  36978. /** defines the name */
  36979. name: string, manager: ISpriteManager);
  36980. /**
  36981. * Starts an animation
  36982. * @param from defines the initial key
  36983. * @param to defines the end key
  36984. * @param loop defines if the animation must loop
  36985. * @param delay defines the start delay (in ms)
  36986. * @param onAnimationEnd defines a callback to call when animation ends
  36987. */
  36988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36989. /** Stops current animation (if any) */
  36990. stopAnimation(): void;
  36991. /** @hidden */
  36992. _animate(deltaTime: number): void;
  36993. /** Release associated resources */
  36994. dispose(): void;
  36995. }
  36996. }
  36997. declare module BABYLON {
  36998. /**
  36999. * Defines the minimum interface to fullfil in order to be a sprite manager.
  37000. */
  37001. interface ISpriteManager extends IDisposable {
  37002. /**
  37003. * Restricts the camera to viewing objects with the same layerMask.
  37004. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  37005. */
  37006. layerMask: number;
  37007. /**
  37008. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37009. */
  37010. isPickable: boolean;
  37011. /**
  37012. * Specifies the rendering group id for this mesh (0 by default)
  37013. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37014. */
  37015. renderingGroupId: number;
  37016. /**
  37017. * Defines the list of sprites managed by the manager.
  37018. */
  37019. sprites: Array<Sprite>;
  37020. /**
  37021. * Tests the intersection of a sprite with a specific ray.
  37022. * @param ray The ray we are sending to test the collision
  37023. * @param camera The camera space we are sending rays in
  37024. * @param predicate A predicate allowing excluding sprites from the list of object to test
  37025. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  37026. * @returns picking info or null.
  37027. */
  37028. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37029. /**
  37030. * Renders the list of sprites on screen.
  37031. */
  37032. render(): void;
  37033. }
  37034. /**
  37035. * Class used to manage multiple sprites on the same spritesheet
  37036. * @see http://doc.babylonjs.com/babylon101/sprites
  37037. */
  37038. class SpriteManager implements ISpriteManager {
  37039. /** defines the manager's name */
  37040. name: string;
  37041. /** Gets the list of sprites */
  37042. sprites: Sprite[];
  37043. /** Gets or sets the rendering group id (0 by default) */
  37044. renderingGroupId: number;
  37045. /** Gets or sets camera layer mask */
  37046. layerMask: number;
  37047. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  37048. fogEnabled: boolean;
  37049. /** Gets or sets a boolean indicating if the sprites are pickable */
  37050. isPickable: boolean;
  37051. /** Defines the default width of a cell in the spritesheet */
  37052. cellWidth: number;
  37053. /** Defines the default height of a cell in the spritesheet */
  37054. cellHeight: number;
  37055. /**
  37056. * An event triggered when the manager is disposed.
  37057. */
  37058. onDisposeObservable: Observable<SpriteManager>;
  37059. private _onDisposeObserver;
  37060. /**
  37061. * Callback called when the manager is disposed
  37062. */
  37063. onDispose: () => void;
  37064. private _capacity;
  37065. private _spriteTexture;
  37066. private _epsilon;
  37067. private _scene;
  37068. private _vertexData;
  37069. private _buffer;
  37070. private _vertexBuffers;
  37071. private _indexBuffer;
  37072. private _effectBase;
  37073. private _effectFog;
  37074. /**
  37075. * Gets or sets the spritesheet texture
  37076. */
  37077. texture: Texture;
  37078. /**
  37079. * Creates a new sprite manager
  37080. * @param name defines the manager's name
  37081. * @param imgUrl defines the sprite sheet url
  37082. * @param capacity defines the maximum allowed number of sprites
  37083. * @param cellSize defines the size of a sprite cell
  37084. * @param scene defines the hosting scene
  37085. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  37086. * @param samplingMode defines the smapling mode to use with spritesheet
  37087. */
  37088. constructor(
  37089. /** defines the manager's name */
  37090. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  37091. private _appendSpriteVertex;
  37092. /**
  37093. * Intersects the sprites with a ray
  37094. * @param ray defines the ray to intersect with
  37095. * @param camera defines the current active camera
  37096. * @param predicate defines a predicate used to select candidate sprites
  37097. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  37098. * @returns null if no hit or a PickingInfo
  37099. */
  37100. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37101. /**
  37102. * Render all child sprites
  37103. */
  37104. render(): void;
  37105. /**
  37106. * Release associated resources
  37107. */
  37108. dispose(): void;
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. interface Scene {
  37113. /** @hidden */
  37114. _pointerOverSprite: Nullable<Sprite>;
  37115. /** @hidden */
  37116. _pickedDownSprite: Nullable<Sprite>;
  37117. /** @hidden */
  37118. _tempSpritePickingRay: Nullable<Ray>;
  37119. /**
  37120. * All of the sprite managers added to this scene
  37121. * @see http://doc.babylonjs.com/babylon101/sprites
  37122. */
  37123. spriteManagers: Array<ISpriteManager>;
  37124. /**
  37125. * An event triggered when sprites rendering is about to start
  37126. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37127. */
  37128. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37129. /**
  37130. * An event triggered when sprites rendering is done
  37131. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37132. */
  37133. onAfterSpritesRenderingObservable: Observable<Scene>;
  37134. /** @hidden */
  37135. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37136. /** Launch a ray to try to pick a sprite in the scene
  37137. * @param x position on screen
  37138. * @param y position on screen
  37139. * @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
  37140. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37141. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37142. * @returns a PickingInfo
  37143. */
  37144. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37145. /** Use the given ray to pick a sprite in the scene
  37146. * @param ray The ray (in world space) to use to pick meshes
  37147. * @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
  37148. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37149. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37150. * @returns a PickingInfo
  37151. */
  37152. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37153. /**
  37154. * Force the sprite under the pointer
  37155. * @param sprite defines the sprite to use
  37156. */
  37157. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37158. /**
  37159. * Gets the sprite under the pointer
  37160. * @returns a Sprite or null if no sprite is under the pointer
  37161. */
  37162. getPointerOverSprite(): Nullable<Sprite>;
  37163. }
  37164. /**
  37165. * Defines the sprite scene component responsible to manage sprites
  37166. * in a given scene.
  37167. */
  37168. class SpriteSceneComponent implements ISceneComponent {
  37169. /**
  37170. * The component name helpfull to identify the component in the list of scene components.
  37171. */
  37172. readonly name: string;
  37173. /**
  37174. * The scene the component belongs to.
  37175. */
  37176. scene: Scene;
  37177. /** @hidden */
  37178. private _spritePredicate;
  37179. /**
  37180. * Creates a new instance of the component for the given scene
  37181. * @param scene Defines the scene to register the component in
  37182. */
  37183. constructor(scene: Scene);
  37184. /**
  37185. * Registers the component in a given scene
  37186. */
  37187. register(): void;
  37188. /**
  37189. * Rebuilds the elements related to this component in case of
  37190. * context lost for instance.
  37191. */
  37192. rebuild(): void;
  37193. /**
  37194. * Disposes the component and the associated ressources.
  37195. */
  37196. dispose(): void;
  37197. private _pickSpriteButKeepRay;
  37198. private _pointerMove;
  37199. private _pointerDown;
  37200. private _pointerUp;
  37201. }
  37202. }
  37203. declare module BABYLON {
  37204. /**
  37205. * @hidden
  37206. **/
  37207. class _AlphaState {
  37208. private _isAlphaBlendDirty;
  37209. private _isBlendFunctionParametersDirty;
  37210. private _isBlendEquationParametersDirty;
  37211. private _isBlendConstantsDirty;
  37212. private _alphaBlend;
  37213. private _blendFunctionParameters;
  37214. private _blendEquationParameters;
  37215. private _blendConstants;
  37216. /**
  37217. * Initializes the state.
  37218. */
  37219. constructor();
  37220. readonly isDirty: boolean;
  37221. alphaBlend: boolean;
  37222. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37223. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37224. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37225. reset(): void;
  37226. apply(gl: WebGLRenderingContext): void;
  37227. }
  37228. }
  37229. declare module BABYLON {
  37230. /**
  37231. * @hidden
  37232. **/
  37233. class _DepthCullingState {
  37234. private _isDepthTestDirty;
  37235. private _isDepthMaskDirty;
  37236. private _isDepthFuncDirty;
  37237. private _isCullFaceDirty;
  37238. private _isCullDirty;
  37239. private _isZOffsetDirty;
  37240. private _isFrontFaceDirty;
  37241. private _depthTest;
  37242. private _depthMask;
  37243. private _depthFunc;
  37244. private _cull;
  37245. private _cullFace;
  37246. private _zOffset;
  37247. private _frontFace;
  37248. /**
  37249. * Initializes the state.
  37250. */
  37251. constructor();
  37252. readonly isDirty: boolean;
  37253. zOffset: number;
  37254. cullFace: Nullable<number>;
  37255. cull: Nullable<boolean>;
  37256. depthFunc: Nullable<number>;
  37257. depthMask: boolean;
  37258. depthTest: boolean;
  37259. frontFace: Nullable<number>;
  37260. reset(): void;
  37261. apply(gl: WebGLRenderingContext): void;
  37262. }
  37263. }
  37264. declare module BABYLON {
  37265. /**
  37266. * @hidden
  37267. **/
  37268. class _StencilState {
  37269. private _isStencilTestDirty;
  37270. private _isStencilMaskDirty;
  37271. private _isStencilFuncDirty;
  37272. private _isStencilOpDirty;
  37273. private _stencilTest;
  37274. private _stencilMask;
  37275. private _stencilFunc;
  37276. private _stencilFuncRef;
  37277. private _stencilFuncMask;
  37278. private _stencilOpStencilFail;
  37279. private _stencilOpDepthFail;
  37280. private _stencilOpStencilDepthPass;
  37281. readonly isDirty: boolean;
  37282. stencilFunc: number;
  37283. stencilFuncRef: number;
  37284. stencilFuncMask: number;
  37285. stencilOpStencilFail: number;
  37286. stencilOpDepthFail: number;
  37287. stencilOpStencilDepthPass: number;
  37288. stencilMask: number;
  37289. stencilTest: boolean;
  37290. constructor();
  37291. reset(): void;
  37292. apply(gl: WebGLRenderingContext): void;
  37293. }
  37294. }
  37295. declare module BABYLON {
  37296. /**
  37297. * Class used to evalaute queries containing `and` and `or` operators
  37298. */
  37299. class AndOrNotEvaluator {
  37300. /**
  37301. * Evaluate a query
  37302. * @param query defines the query to evaluate
  37303. * @param evaluateCallback defines the callback used to filter result
  37304. * @returns true if the query matches
  37305. */
  37306. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37307. private static _HandleParenthesisContent;
  37308. private static _SimplifyNegation;
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. /**
  37313. * Defines the list of states available for a task inside a AssetsManager
  37314. */
  37315. enum AssetTaskState {
  37316. /**
  37317. * Initialization
  37318. */
  37319. INIT = 0,
  37320. /**
  37321. * Running
  37322. */
  37323. RUNNING = 1,
  37324. /**
  37325. * Done
  37326. */
  37327. DONE = 2,
  37328. /**
  37329. * Error
  37330. */
  37331. ERROR = 3
  37332. }
  37333. /**
  37334. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37335. */
  37336. abstract class AbstractAssetTask {
  37337. /**
  37338. * Task name
  37339. */ name: string;
  37340. /**
  37341. * Callback called when the task is successful
  37342. */
  37343. onSuccess: (task: any) => void;
  37344. /**
  37345. * Callback called when the task is not successful
  37346. */
  37347. onError: (task: any, message?: string, exception?: any) => void;
  37348. /**
  37349. * Creates a new AssetsManager
  37350. * @param name defines the name of the task
  37351. */
  37352. constructor(
  37353. /**
  37354. * Task name
  37355. */ name: string);
  37356. private _isCompleted;
  37357. private _taskState;
  37358. private _errorObject;
  37359. /**
  37360. * Get if the task is completed
  37361. */
  37362. readonly isCompleted: boolean;
  37363. /**
  37364. * Gets the current state of the task
  37365. */
  37366. readonly taskState: AssetTaskState;
  37367. /**
  37368. * Gets the current error object (if task is in error)
  37369. */
  37370. readonly errorObject: {
  37371. message?: string;
  37372. exception?: any;
  37373. };
  37374. /**
  37375. * Internal only
  37376. * @hidden
  37377. */
  37378. _setErrorObject(message?: string, exception?: any): void;
  37379. /**
  37380. * Execute the current task
  37381. * @param scene defines the scene where you want your assets to be loaded
  37382. * @param onSuccess is a callback called when the task is successfully executed
  37383. * @param onError is a callback called if an error occurs
  37384. */
  37385. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37386. /**
  37387. * Execute the current task
  37388. * @param scene defines the scene where you want your assets to be loaded
  37389. * @param onSuccess is a callback called when the task is successfully executed
  37390. * @param onError is a callback called if an error occurs
  37391. */
  37392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37393. /**
  37394. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37395. * This can be used with failed tasks that have the reason for failure fixed.
  37396. */
  37397. reset(): void;
  37398. private onErrorCallback;
  37399. private onDoneCallback;
  37400. }
  37401. /**
  37402. * Define the interface used by progress events raised during assets loading
  37403. */
  37404. interface IAssetsProgressEvent {
  37405. /**
  37406. * Defines the number of remaining tasks to process
  37407. */
  37408. remainingCount: number;
  37409. /**
  37410. * Defines the total number of tasks
  37411. */
  37412. totalCount: number;
  37413. /**
  37414. * Defines the task that was just processed
  37415. */
  37416. task: AbstractAssetTask;
  37417. }
  37418. /**
  37419. * Class used to share progress information about assets loading
  37420. */
  37421. class AssetsProgressEvent implements IAssetsProgressEvent {
  37422. /**
  37423. * Defines the number of remaining tasks to process
  37424. */
  37425. remainingCount: number;
  37426. /**
  37427. * Defines the total number of tasks
  37428. */
  37429. totalCount: number;
  37430. /**
  37431. * Defines the task that was just processed
  37432. */
  37433. task: AbstractAssetTask;
  37434. /**
  37435. * Creates a AssetsProgressEvent
  37436. * @param remainingCount defines the number of remaining tasks to process
  37437. * @param totalCount defines the total number of tasks
  37438. * @param task defines the task that was just processed
  37439. */
  37440. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37441. }
  37442. /**
  37443. * Define a task used by AssetsManager to load meshes
  37444. */
  37445. class MeshAssetTask extends AbstractAssetTask {
  37446. /**
  37447. * Defines the name of the task
  37448. */
  37449. name: string;
  37450. /**
  37451. * Defines the list of mesh's names you want to load
  37452. */
  37453. meshesNames: any;
  37454. /**
  37455. * Defines the root url to use as a base to load your meshes and associated resources
  37456. */
  37457. rootUrl: string;
  37458. /**
  37459. * Defines the filename of the scene to load from
  37460. */
  37461. sceneFilename: string;
  37462. /**
  37463. * Gets the list of loaded meshes
  37464. */
  37465. loadedMeshes: Array<AbstractMesh>;
  37466. /**
  37467. * Gets the list of loaded particle systems
  37468. */
  37469. loadedParticleSystems: Array<IParticleSystem>;
  37470. /**
  37471. * Gets the list of loaded skeletons
  37472. */
  37473. loadedSkeletons: Array<Skeleton>;
  37474. /**
  37475. * Callback called when the task is successful
  37476. */
  37477. onSuccess: (task: MeshAssetTask) => void;
  37478. /**
  37479. * Callback called when the task is successful
  37480. */
  37481. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37482. /**
  37483. * Creates a new MeshAssetTask
  37484. * @param name defines the name of the task
  37485. * @param meshesNames defines the list of mesh's names you want to load
  37486. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37487. * @param sceneFilename defines the filename of the scene to load from
  37488. */
  37489. constructor(
  37490. /**
  37491. * Defines the name of the task
  37492. */
  37493. name: string,
  37494. /**
  37495. * Defines the list of mesh's names you want to load
  37496. */
  37497. meshesNames: any,
  37498. /**
  37499. * Defines the root url to use as a base to load your meshes and associated resources
  37500. */
  37501. rootUrl: string,
  37502. /**
  37503. * Defines the filename of the scene to load from
  37504. */
  37505. sceneFilename: string);
  37506. /**
  37507. * Execute the current task
  37508. * @param scene defines the scene where you want your assets to be loaded
  37509. * @param onSuccess is a callback called when the task is successfully executed
  37510. * @param onError is a callback called if an error occurs
  37511. */
  37512. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37513. }
  37514. /**
  37515. * Define a task used by AssetsManager to load text content
  37516. */
  37517. class TextFileAssetTask extends AbstractAssetTask {
  37518. /**
  37519. * Defines the name of the task
  37520. */
  37521. name: string;
  37522. /**
  37523. * Defines the location of the file to load
  37524. */
  37525. url: string;
  37526. /**
  37527. * Gets the loaded text string
  37528. */
  37529. text: string;
  37530. /**
  37531. * Callback called when the task is successful
  37532. */
  37533. onSuccess: (task: TextFileAssetTask) => void;
  37534. /**
  37535. * Callback called when the task is successful
  37536. */
  37537. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37538. /**
  37539. * Creates a new TextFileAssetTask object
  37540. * @param name defines the name of the task
  37541. * @param url defines the location of the file to load
  37542. */
  37543. constructor(
  37544. /**
  37545. * Defines the name of the task
  37546. */
  37547. name: string,
  37548. /**
  37549. * Defines the location of the file to load
  37550. */
  37551. url: string);
  37552. /**
  37553. * Execute the current task
  37554. * @param scene defines the scene where you want your assets to be loaded
  37555. * @param onSuccess is a callback called when the task is successfully executed
  37556. * @param onError is a callback called if an error occurs
  37557. */
  37558. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37559. }
  37560. /**
  37561. * Define a task used by AssetsManager to load binary data
  37562. */
  37563. class BinaryFileAssetTask extends AbstractAssetTask {
  37564. /**
  37565. * Defines the name of the task
  37566. */
  37567. name: string;
  37568. /**
  37569. * Defines the location of the file to load
  37570. */
  37571. url: string;
  37572. /**
  37573. * Gets the lodaded data (as an array buffer)
  37574. */
  37575. data: ArrayBuffer;
  37576. /**
  37577. * Callback called when the task is successful
  37578. */
  37579. onSuccess: (task: BinaryFileAssetTask) => void;
  37580. /**
  37581. * Callback called when the task is successful
  37582. */
  37583. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37584. /**
  37585. * Creates a new BinaryFileAssetTask object
  37586. * @param name defines the name of the new task
  37587. * @param url defines the location of the file to load
  37588. */
  37589. constructor(
  37590. /**
  37591. * Defines the name of the task
  37592. */
  37593. name: string,
  37594. /**
  37595. * Defines the location of the file to load
  37596. */
  37597. url: string);
  37598. /**
  37599. * Execute the current task
  37600. * @param scene defines the scene where you want your assets to be loaded
  37601. * @param onSuccess is a callback called when the task is successfully executed
  37602. * @param onError is a callback called if an error occurs
  37603. */
  37604. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37605. }
  37606. /**
  37607. * Define a task used by AssetsManager to load images
  37608. */
  37609. class ImageAssetTask extends AbstractAssetTask {
  37610. /**
  37611. * Defines the name of the task
  37612. */
  37613. name: string;
  37614. /**
  37615. * Defines the location of the image to load
  37616. */
  37617. url: string;
  37618. /**
  37619. * Gets the loaded images
  37620. */
  37621. image: HTMLImageElement;
  37622. /**
  37623. * Callback called when the task is successful
  37624. */
  37625. onSuccess: (task: ImageAssetTask) => void;
  37626. /**
  37627. * Callback called when the task is successful
  37628. */
  37629. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37630. /**
  37631. * Creates a new ImageAssetTask
  37632. * @param name defines the name of the task
  37633. * @param url defines the location of the image to load
  37634. */
  37635. constructor(
  37636. /**
  37637. * Defines the name of the task
  37638. */
  37639. name: string,
  37640. /**
  37641. * Defines the location of the image to load
  37642. */
  37643. url: string);
  37644. /**
  37645. * Execute the current task
  37646. * @param scene defines the scene where you want your assets to be loaded
  37647. * @param onSuccess is a callback called when the task is successfully executed
  37648. * @param onError is a callback called if an error occurs
  37649. */
  37650. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37651. }
  37652. /**
  37653. * Defines the interface used by texture loading tasks
  37654. */
  37655. interface ITextureAssetTask<TEX extends BaseTexture> {
  37656. /**
  37657. * Gets the loaded texture
  37658. */
  37659. texture: TEX;
  37660. }
  37661. /**
  37662. * Define a task used by AssetsManager to load 2D textures
  37663. */
  37664. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37665. /**
  37666. * Defines the name of the task
  37667. */
  37668. name: string;
  37669. /**
  37670. * Defines the location of the file to load
  37671. */
  37672. url: string;
  37673. /**
  37674. * Defines if mipmap should not be generated (default is false)
  37675. */
  37676. noMipmap?: boolean | undefined;
  37677. /**
  37678. * Defines if texture must be inverted on Y axis (default is false)
  37679. */
  37680. invertY?: boolean | undefined;
  37681. /**
  37682. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37683. */
  37684. samplingMode: number;
  37685. /**
  37686. * Gets the loaded texture
  37687. */
  37688. texture: Texture;
  37689. /**
  37690. * Callback called when the task is successful
  37691. */
  37692. onSuccess: (task: TextureAssetTask) => void;
  37693. /**
  37694. * Callback called when the task is successful
  37695. */
  37696. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37697. /**
  37698. * Creates a new TextureAssetTask object
  37699. * @param name defines the name of the task
  37700. * @param url defines the location of the file to load
  37701. * @param noMipmap defines if mipmap should not be generated (default is false)
  37702. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37703. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37704. */
  37705. constructor(
  37706. /**
  37707. * Defines the name of the task
  37708. */
  37709. name: string,
  37710. /**
  37711. * Defines the location of the file to load
  37712. */
  37713. url: string,
  37714. /**
  37715. * Defines if mipmap should not be generated (default is false)
  37716. */
  37717. noMipmap?: boolean | undefined,
  37718. /**
  37719. * Defines if texture must be inverted on Y axis (default is false)
  37720. */
  37721. invertY?: boolean | undefined,
  37722. /**
  37723. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37724. */
  37725. samplingMode?: number);
  37726. /**
  37727. * Execute the current task
  37728. * @param scene defines the scene where you want your assets to be loaded
  37729. * @param onSuccess is a callback called when the task is successfully executed
  37730. * @param onError is a callback called if an error occurs
  37731. */
  37732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37733. }
  37734. /**
  37735. * Define a task used by AssetsManager to load cube textures
  37736. */
  37737. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37738. /**
  37739. * Defines the name of the task
  37740. */
  37741. name: string;
  37742. /**
  37743. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37744. */
  37745. url: string;
  37746. /**
  37747. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37748. */
  37749. extensions?: string[] | undefined;
  37750. /**
  37751. * Defines if mipmaps should not be generated (default is false)
  37752. */
  37753. noMipmap?: boolean | undefined;
  37754. /**
  37755. * Defines the explicit list of files (undefined by default)
  37756. */
  37757. files?: string[] | undefined;
  37758. /**
  37759. * Gets the loaded texture
  37760. */
  37761. texture: CubeTexture;
  37762. /**
  37763. * Callback called when the task is successful
  37764. */
  37765. onSuccess: (task: CubeTextureAssetTask) => void;
  37766. /**
  37767. * Callback called when the task is successful
  37768. */
  37769. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37770. /**
  37771. * Creates a new CubeTextureAssetTask
  37772. * @param name defines the name of the task
  37773. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37774. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37775. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37776. * @param files defines the explicit list of files (undefined by default)
  37777. */
  37778. constructor(
  37779. /**
  37780. * Defines the name of the task
  37781. */
  37782. name: string,
  37783. /**
  37784. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37785. */
  37786. url: string,
  37787. /**
  37788. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37789. */
  37790. extensions?: string[] | undefined,
  37791. /**
  37792. * Defines if mipmaps should not be generated (default is false)
  37793. */
  37794. noMipmap?: boolean | undefined,
  37795. /**
  37796. * Defines the explicit list of files (undefined by default)
  37797. */
  37798. files?: string[] | undefined);
  37799. /**
  37800. * Execute the current task
  37801. * @param scene defines the scene where you want your assets to be loaded
  37802. * @param onSuccess is a callback called when the task is successfully executed
  37803. * @param onError is a callback called if an error occurs
  37804. */
  37805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37806. }
  37807. /**
  37808. * Define a task used by AssetsManager to load HDR cube textures
  37809. */
  37810. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37811. /**
  37812. * Defines the name of the task
  37813. */
  37814. name: string;
  37815. /**
  37816. * Defines the location of the file to load
  37817. */
  37818. url: string;
  37819. /**
  37820. * Defines the desired size (the more it increases the longer the generation will be)
  37821. */
  37822. size: number;
  37823. /**
  37824. * Defines if mipmaps should not be generated (default is false)
  37825. */
  37826. noMipmap: boolean;
  37827. /**
  37828. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37829. */
  37830. generateHarmonics: boolean;
  37831. /**
  37832. * 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)
  37833. */
  37834. gammaSpace: boolean;
  37835. /**
  37836. * Internal Use Only
  37837. */
  37838. reserved: boolean;
  37839. /**
  37840. * Gets the loaded texture
  37841. */
  37842. texture: HDRCubeTexture;
  37843. /**
  37844. * Callback called when the task is successful
  37845. */
  37846. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37847. /**
  37848. * Callback called when the task is successful
  37849. */
  37850. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37851. /**
  37852. * Creates a new HDRCubeTextureAssetTask object
  37853. * @param name defines the name of the task
  37854. * @param url defines the location of the file to load
  37855. * @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.
  37856. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37857. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37858. * @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)
  37859. * @param reserved Internal use only
  37860. */
  37861. constructor(
  37862. /**
  37863. * Defines the name of the task
  37864. */
  37865. name: string,
  37866. /**
  37867. * Defines the location of the file to load
  37868. */
  37869. url: string,
  37870. /**
  37871. * Defines the desired size (the more it increases the longer the generation will be)
  37872. */
  37873. size: number,
  37874. /**
  37875. * Defines if mipmaps should not be generated (default is false)
  37876. */
  37877. noMipmap?: boolean,
  37878. /**
  37879. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37880. */
  37881. generateHarmonics?: boolean,
  37882. /**
  37883. * 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)
  37884. */
  37885. gammaSpace?: boolean,
  37886. /**
  37887. * Internal Use Only
  37888. */
  37889. reserved?: boolean);
  37890. /**
  37891. * Execute the current task
  37892. * @param scene defines the scene where you want your assets to be loaded
  37893. * @param onSuccess is a callback called when the task is successfully executed
  37894. * @param onError is a callback called if an error occurs
  37895. */
  37896. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37897. }
  37898. /**
  37899. * This class can be used to easily import assets into a scene
  37900. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37901. */
  37902. class AssetsManager {
  37903. private _scene;
  37904. private _isLoading;
  37905. protected _tasks: AbstractAssetTask[];
  37906. protected _waitingTasksCount: number;
  37907. protected _totalTasksCount: number;
  37908. /**
  37909. * Callback called when all tasks are processed
  37910. */
  37911. onFinish: (tasks: AbstractAssetTask[]) => void;
  37912. /**
  37913. * Callback called when a task is successful
  37914. */
  37915. onTaskSuccess: (task: AbstractAssetTask) => void;
  37916. /**
  37917. * Callback called when a task had an error
  37918. */
  37919. onTaskError: (task: AbstractAssetTask) => void;
  37920. /**
  37921. * Callback called when a task is done (whatever the result is)
  37922. */
  37923. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37924. /**
  37925. * Observable called when all tasks are processed
  37926. */
  37927. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37928. /**
  37929. * Observable called when a task had an error
  37930. */
  37931. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37932. /**
  37933. * Observable called when a task is successful
  37934. */
  37935. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37936. /**
  37937. * Observable called when a task is done (whatever the result is)
  37938. */
  37939. onProgressObservable: Observable<IAssetsProgressEvent>;
  37940. /**
  37941. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37943. */
  37944. useDefaultLoadingScreen: boolean;
  37945. /**
  37946. * Creates a new AssetsManager
  37947. * @param scene defines the scene to work on
  37948. */
  37949. constructor(scene: Scene);
  37950. /**
  37951. * Add a MeshAssetTask to the list of active tasks
  37952. * @param taskName defines the name of the new task
  37953. * @param meshesNames defines the name of meshes to load
  37954. * @param rootUrl defines the root url to use to locate files
  37955. * @param sceneFilename defines the filename of the scene file
  37956. * @returns a new MeshAssetTask object
  37957. */
  37958. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37959. /**
  37960. * Add a TextFileAssetTask to the list of active tasks
  37961. * @param taskName defines the name of the new task
  37962. * @param url defines the url of the file to load
  37963. * @returns a new TextFileAssetTask object
  37964. */
  37965. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37966. /**
  37967. * Add a BinaryFileAssetTask to the list of active tasks
  37968. * @param taskName defines the name of the new task
  37969. * @param url defines the url of the file to load
  37970. * @returns a new BinaryFileAssetTask object
  37971. */
  37972. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37973. /**
  37974. * Add a ImageAssetTask to the list of active tasks
  37975. * @param taskName defines the name of the new task
  37976. * @param url defines the url of the file to load
  37977. * @returns a new ImageAssetTask object
  37978. */
  37979. addImageTask(taskName: string, url: string): ImageAssetTask;
  37980. /**
  37981. * Add a TextureAssetTask to the list of active tasks
  37982. * @param taskName defines the name of the new task
  37983. * @param url defines the url of the file to load
  37984. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37985. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37986. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37987. * @returns a new TextureAssetTask object
  37988. */
  37989. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37990. /**
  37991. * Add a CubeTextureAssetTask to the list of active tasks
  37992. * @param taskName defines the name of the new task
  37993. * @param url defines the url of the file to load
  37994. * @param extensions defines the extension to use to load the cube map (can be null)
  37995. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37996. * @param files defines the list of files to load (can be null)
  37997. * @returns a new CubeTextureAssetTask object
  37998. */
  37999. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  38000. /**
  38001. *
  38002. * Add a HDRCubeTextureAssetTask to the list of active tasks
  38003. * @param taskName defines the name of the new task
  38004. * @param url defines the url of the file to load
  38005. * @param size defines the size you want for the cubemap (can be null)
  38006. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38007. * @param generateHarmonics defines if you want to automatically generate (true by default)
  38008. * @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)
  38009. * @param reserved Internal use only
  38010. * @returns a new HDRCubeTextureAssetTask object
  38011. */
  38012. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  38013. /**
  38014. * Remove a task from the assets manager.
  38015. * @param task the task to remove
  38016. */
  38017. removeTask(task: AbstractAssetTask): void;
  38018. private _decreaseWaitingTasksCount;
  38019. private _runTask;
  38020. /**
  38021. * Reset the AssetsManager and remove all tasks
  38022. * @return the current instance of the AssetsManager
  38023. */
  38024. reset(): AssetsManager;
  38025. /**
  38026. * Start the loading process
  38027. * @return the current instance of the AssetsManager
  38028. */
  38029. load(): AssetsManager;
  38030. }
  38031. }
  38032. declare module BABYLON {
  38033. /**
  38034. * Direct draw surface info
  38035. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  38036. */
  38037. interface DDSInfo {
  38038. /**
  38039. * Width of the texture
  38040. */
  38041. width: number;
  38042. /**
  38043. * Width of the texture
  38044. */
  38045. height: number;
  38046. /**
  38047. * Number of Mipmaps for the texture
  38048. * @see https://en.wikipedia.org/wiki/Mipmap
  38049. */
  38050. mipmapCount: number;
  38051. /**
  38052. * If the textures format is a known fourCC format
  38053. * @see https://www.fourcc.org/
  38054. */
  38055. isFourCC: boolean;
  38056. /**
  38057. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  38058. */
  38059. isRGB: boolean;
  38060. /**
  38061. * If the texture is a lumincance format
  38062. */
  38063. isLuminance: boolean;
  38064. /**
  38065. * If this is a cube texture
  38066. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  38067. */
  38068. isCube: boolean;
  38069. /**
  38070. * If the texture is a compressed format eg. FOURCC_DXT1
  38071. */
  38072. isCompressed: boolean;
  38073. /**
  38074. * The dxgiFormat of the texture
  38075. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38076. */
  38077. dxgiFormat: number;
  38078. /**
  38079. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38080. */
  38081. textureType: number;
  38082. /**
  38083. * Sphericle polynomial created for the dds texture
  38084. */
  38085. sphericalPolynomial?: SphericalPolynomial;
  38086. }
  38087. /**
  38088. * Class used to provide DDS decompression tools
  38089. */
  38090. class DDSTools {
  38091. /**
  38092. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38093. */
  38094. static StoreLODInAlphaChannel: boolean;
  38095. /**
  38096. * Gets DDS information from an array buffer
  38097. * @param arrayBuffer defines the array buffer to read data from
  38098. * @returns the DDS information
  38099. */
  38100. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38101. private static _FloatView;
  38102. private static _Int32View;
  38103. private static _ToHalfFloat;
  38104. private static _FromHalfFloat;
  38105. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38106. private static _GetHalfFloatRGBAArrayBuffer;
  38107. private static _GetFloatRGBAArrayBuffer;
  38108. private static _GetFloatAsUIntRGBAArrayBuffer;
  38109. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38110. private static _GetRGBAArrayBuffer;
  38111. private static _ExtractLongWordOrder;
  38112. private static _GetRGBArrayBuffer;
  38113. private static _GetLuminanceArrayBuffer;
  38114. /**
  38115. * Uploads DDS Levels to a Babylon Texture
  38116. * @hidden
  38117. */
  38118. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38119. }
  38120. }
  38121. declare module BABYLON {
  38122. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38123. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38124. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38125. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38126. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38127. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38128. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38129. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38130. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38131. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38132. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38133. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38134. /**
  38135. * Decorator used to define property that can be serialized as reference to a camera
  38136. * @param sourceName defines the name of the property to decorate
  38137. */
  38138. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38139. /**
  38140. * Class used to help serialization objects
  38141. */
  38142. class SerializationHelper {
  38143. /**
  38144. * Static function used to serialized a specific entity
  38145. * @param entity defines the entity to serialize
  38146. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38147. * @returns a JSON compatible object representing the serialization of the entity
  38148. */
  38149. static Serialize<T>(entity: T, serializationObject?: any): any;
  38150. /**
  38151. * Creates a new entity from a serialization data object
  38152. * @param creationFunction defines a function used to instanciated the new entity
  38153. * @param source defines the source serialization data
  38154. * @param scene defines the hosting scene
  38155. * @param rootUrl defines the root url for resources
  38156. * @returns a new entity
  38157. */
  38158. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38159. /**
  38160. * Clones an object
  38161. * @param creationFunction defines the function used to instanciate the new object
  38162. * @param source defines the source object
  38163. * @returns the cloned object
  38164. */
  38165. static Clone<T>(creationFunction: () => T, source: T): T;
  38166. /**
  38167. * Instanciates a new object based on a source one (some data will be shared between both object)
  38168. * @param creationFunction defines the function used to instanciate the new object
  38169. * @param source defines the source object
  38170. * @returns the new object
  38171. */
  38172. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38173. }
  38174. }
  38175. declare module BABYLON {
  38176. /**
  38177. * Wrapper class for promise with external resolve and reject.
  38178. */
  38179. class Deferred<T> {
  38180. /**
  38181. * The promise associated with this deferred object.
  38182. */
  38183. readonly promise: Promise<T>;
  38184. private _resolve;
  38185. private _reject;
  38186. /**
  38187. * The resolve method of the promise associated with this deferred object.
  38188. */
  38189. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38190. /**
  38191. * The reject method of the promise associated with this deferred object.
  38192. */
  38193. readonly reject: (reason?: any) => void;
  38194. /**
  38195. * Constructor for this deferred object.
  38196. */
  38197. constructor();
  38198. }
  38199. }
  38200. declare module BABYLON {
  38201. /**
  38202. * Raw texture data and descriptor sufficient for WebGL texture upload
  38203. */
  38204. interface EnvironmentTextureInfo {
  38205. /**
  38206. * Version of the environment map
  38207. */
  38208. version: number;
  38209. /**
  38210. * Width of image
  38211. */
  38212. width: number;
  38213. /**
  38214. * Irradiance information stored in the file.
  38215. */
  38216. irradiance: any;
  38217. /**
  38218. * Specular information stored in the file.
  38219. */
  38220. specular: any;
  38221. }
  38222. /**
  38223. * Sets of helpers addressing the serialization and deserialization of environment texture
  38224. * stored in a BabylonJS env file.
  38225. * Those files are usually stored as .env files.
  38226. */
  38227. class EnvironmentTextureTools {
  38228. /**
  38229. * Magic number identifying the env file.
  38230. */
  38231. private static _MagicBytes;
  38232. /**
  38233. * Gets the environment info from an env file.
  38234. * @param data The array buffer containing the .env bytes.
  38235. * @returns the environment file info (the json header) if successfully parsed.
  38236. */
  38237. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38238. /**
  38239. * Creates an environment texture from a loaded cube texture.
  38240. * @param texture defines the cube texture to convert in env file
  38241. * @return a promise containing the environment data if succesfull.
  38242. */
  38243. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38244. /**
  38245. * Creates a JSON representation of the spherical data.
  38246. * @param texture defines the texture containing the polynomials
  38247. * @return the JSON representation of the spherical info
  38248. */
  38249. private static _CreateEnvTextureIrradiance;
  38250. /**
  38251. * Uploads the texture info contained in the env file to the GPU.
  38252. * @param texture defines the internal texture to upload to
  38253. * @param arrayBuffer defines the buffer cotaining the data to load
  38254. * @param info defines the texture info retrieved through the GetEnvInfo method
  38255. * @returns a promise
  38256. */
  38257. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38258. /**
  38259. * Uploads the levels of image data to the GPU.
  38260. * @param texture defines the internal texture to upload to
  38261. * @param imageData defines the array buffer views of image data [mipmap][face]
  38262. * @returns a promise
  38263. */
  38264. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38265. /**
  38266. * Uploads spherical polynomials information to the texture.
  38267. * @param texture defines the texture we are trying to upload the information to
  38268. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38269. */
  38270. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38271. }
  38272. }
  38273. declare module BABYLON {
  38274. /**
  38275. * Class used to help managing file picking and drag'n'drop
  38276. */
  38277. class FilesInput {
  38278. /**
  38279. * List of files ready to be loaded
  38280. */
  38281. static FilesToLoad: {
  38282. [key: string]: File;
  38283. };
  38284. /**
  38285. * Callback called when a file is processed
  38286. */
  38287. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38288. private _engine;
  38289. private _currentScene;
  38290. private _sceneLoadedCallback;
  38291. private _progressCallback;
  38292. private _additionalRenderLoopLogicCallback;
  38293. private _textureLoadingCallback;
  38294. private _startingProcessingFilesCallback;
  38295. private _onReloadCallback;
  38296. private _errorCallback;
  38297. private _elementToMonitor;
  38298. private _sceneFileToLoad;
  38299. private _filesToLoad;
  38300. /**
  38301. * Creates a new FilesInput
  38302. * @param engine defines the rendering engine
  38303. * @param scene defines the hosting scene
  38304. * @param sceneLoadedCallback callback called when scene is loaded
  38305. * @param progressCallback callback called to track progress
  38306. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38307. * @param textureLoadingCallback callback called when a texture is loading
  38308. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38309. * @param onReloadCallback callback called when a reload is requested
  38310. * @param errorCallback callback call if an error occurs
  38311. */
  38312. 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);
  38313. private _dragEnterHandler;
  38314. private _dragOverHandler;
  38315. private _dropHandler;
  38316. /**
  38317. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38318. * @param elementToMonitor defines the DOM element to track
  38319. */
  38320. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38321. /**
  38322. * Release all associated resources
  38323. */
  38324. dispose(): void;
  38325. private renderFunction;
  38326. private drag;
  38327. private drop;
  38328. private _traverseFolder;
  38329. private _processFiles;
  38330. /**
  38331. * Load files from a drop event
  38332. * @param event defines the drop event to use as source
  38333. */
  38334. loadFiles(event: any): void;
  38335. private _processReload;
  38336. /**
  38337. * Reload the current scene from the loaded files
  38338. */
  38339. reload(): void;
  38340. }
  38341. }
  38342. declare module BABYLON {
  38343. /**
  38344. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38345. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38346. */
  38347. class KhronosTextureContainer {
  38348. /** contents of the KTX container file */
  38349. arrayBuffer: any;
  38350. private static HEADER_LEN;
  38351. private static COMPRESSED_2D;
  38352. private static COMPRESSED_3D;
  38353. private static TEX_2D;
  38354. private static TEX_3D;
  38355. /**
  38356. * Gets the openGL type
  38357. */
  38358. glType: number;
  38359. /**
  38360. * Gets the openGL type size
  38361. */
  38362. glTypeSize: number;
  38363. /**
  38364. * Gets the openGL format
  38365. */
  38366. glFormat: number;
  38367. /**
  38368. * Gets the openGL internal format
  38369. */
  38370. glInternalFormat: number;
  38371. /**
  38372. * Gets the base internal format
  38373. */
  38374. glBaseInternalFormat: number;
  38375. /**
  38376. * Gets image width in pixel
  38377. */
  38378. pixelWidth: number;
  38379. /**
  38380. * Gets image height in pixel
  38381. */
  38382. pixelHeight: number;
  38383. /**
  38384. * Gets image depth in pixels
  38385. */
  38386. pixelDepth: number;
  38387. /**
  38388. * Gets the number of array elements
  38389. */
  38390. numberOfArrayElements: number;
  38391. /**
  38392. * Gets the number of faces
  38393. */
  38394. numberOfFaces: number;
  38395. /**
  38396. * Gets the number of mipmap levels
  38397. */
  38398. numberOfMipmapLevels: number;
  38399. /**
  38400. * Gets the bytes of key value data
  38401. */
  38402. bytesOfKeyValueData: number;
  38403. /**
  38404. * Gets the load type
  38405. */
  38406. loadType: number;
  38407. /**
  38408. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38409. */
  38410. isInvalid: boolean;
  38411. /**
  38412. * Creates a new KhronosTextureContainer
  38413. * @param arrayBuffer contents of the KTX container file
  38414. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38415. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38416. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38417. */
  38418. constructor(
  38419. /** contents of the KTX container file */
  38420. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38421. /**
  38422. * Uploads KTX content to a Babylon Texture.
  38423. * It is assumed that the texture has already been created & is currently bound
  38424. * @hidden
  38425. */
  38426. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38427. private _upload2DCompressedLevels;
  38428. }
  38429. }
  38430. declare module BABYLON {
  38431. /**
  38432. * A class serves as a medium between the observable and its observers
  38433. */
  38434. class EventState {
  38435. /**
  38436. * Create a new EventState
  38437. * @param mask defines the mask associated with this state
  38438. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38439. * @param target defines the original target of the state
  38440. * @param currentTarget defines the current target of the state
  38441. */
  38442. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38443. /**
  38444. * Initialize the current event state
  38445. * @param mask defines the mask associated with this state
  38446. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38447. * @param target defines the original target of the state
  38448. * @param currentTarget defines the current target of the state
  38449. * @returns the current event state
  38450. */
  38451. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38452. /**
  38453. * An Observer can set this property to true to prevent subsequent observers of being notified
  38454. */
  38455. skipNextObservers: boolean;
  38456. /**
  38457. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38458. */
  38459. mask: number;
  38460. /**
  38461. * The object that originally notified the event
  38462. */
  38463. target?: any;
  38464. /**
  38465. * The current object in the bubbling phase
  38466. */
  38467. currentTarget?: any;
  38468. /**
  38469. * This will be populated with the return value of the last function that was executed.
  38470. * If it is the first function in the callback chain it will be the event data.
  38471. */
  38472. lastReturnValue?: any;
  38473. }
  38474. /**
  38475. * Represent an Observer registered to a given Observable object.
  38476. */
  38477. class Observer<T> {
  38478. /**
  38479. * Defines the callback to call when the observer is notified
  38480. */
  38481. callback: (eventData: T, eventState: EventState) => void;
  38482. /**
  38483. * Defines the mask of the observer (used to filter notifications)
  38484. */
  38485. mask: number;
  38486. /**
  38487. * Defines the current scope used to restore the JS context
  38488. */
  38489. scope: any;
  38490. /** @hidden */
  38491. _willBeUnregistered: boolean;
  38492. /**
  38493. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38494. */
  38495. unregisterOnNextCall: boolean;
  38496. /**
  38497. * Creates a new observer
  38498. * @param callback defines the callback to call when the observer is notified
  38499. * @param mask defines the mask of the observer (used to filter notifications)
  38500. * @param scope defines the current scope used to restore the JS context
  38501. */
  38502. constructor(
  38503. /**
  38504. * Defines the callback to call when the observer is notified
  38505. */
  38506. callback: (eventData: T, eventState: EventState) => void,
  38507. /**
  38508. * Defines the mask of the observer (used to filter notifications)
  38509. */
  38510. mask: number,
  38511. /**
  38512. * Defines the current scope used to restore the JS context
  38513. */
  38514. scope?: any);
  38515. }
  38516. /**
  38517. * Represent a list of observers registered to multiple Observables object.
  38518. */
  38519. class MultiObserver<T> {
  38520. private _observers;
  38521. private _observables;
  38522. /**
  38523. * Release associated resources
  38524. */
  38525. dispose(): void;
  38526. /**
  38527. * Raise a callback when one of the observable will notify
  38528. * @param observables defines a list of observables to watch
  38529. * @param callback defines the callback to call on notification
  38530. * @param mask defines the mask used to filter notifications
  38531. * @param scope defines the current scope used to restore the JS context
  38532. * @returns the new MultiObserver
  38533. */
  38534. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38535. }
  38536. /**
  38537. * The Observable class is a simple implementation of the Observable pattern.
  38538. *
  38539. * 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.
  38540. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38541. * 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).
  38542. * 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.
  38543. */
  38544. class Observable<T> {
  38545. private _observers;
  38546. private _eventState;
  38547. private _onObserverAdded;
  38548. /**
  38549. * Creates a new observable
  38550. * @param onObserverAdded defines a callback to call when a new observer is added
  38551. */
  38552. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38553. /**
  38554. * Create a new Observer with the specified callback
  38555. * @param callback the callback that will be executed for that Observer
  38556. * @param mask the mask used to filter observers
  38557. * @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.
  38558. * @param scope optional scope for the callback to be called from
  38559. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38560. * @returns the new observer created for the callback
  38561. */
  38562. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38563. /**
  38564. * Create a new Observer with the specified callback and unregisters after the next notification
  38565. * @param callback the callback that will be executed for that Observer
  38566. * @returns the new observer created for the callback
  38567. */
  38568. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38569. /**
  38570. * Remove an Observer from the Observable object
  38571. * @param observer the instance of the Observer to remove
  38572. * @returns false if it doesn't belong to this Observable
  38573. */
  38574. remove(observer: Nullable<Observer<T>>): boolean;
  38575. /**
  38576. * Remove a callback from the Observable object
  38577. * @param callback the callback to remove
  38578. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38579. * @returns false if it doesn't belong to this Observable
  38580. */
  38581. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38582. private _deferUnregister;
  38583. private _remove;
  38584. /**
  38585. * Notify all Observers by calling their respective callback with the given data
  38586. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38587. * @param eventData defines the data to send to all observers
  38588. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38589. * @param target defines the original target of the state
  38590. * @param currentTarget defines the current target of the state
  38591. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38592. */
  38593. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38594. /**
  38595. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38596. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38597. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38598. * and it is crucial that all callbacks will be executed.
  38599. * The order of the callbacks is kept, callbacks are not executed parallel.
  38600. *
  38601. * @param eventData The data to be sent to each callback
  38602. * @param mask is used to filter observers defaults to -1
  38603. * @param target defines the callback target (see EventState)
  38604. * @param currentTarget defines he current object in the bubbling phase
  38605. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38606. */
  38607. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38608. /**
  38609. * Notify a specific observer
  38610. * @param observer defines the observer to notify
  38611. * @param eventData defines the data to be sent to each callback
  38612. * @param mask is used to filter observers defaults to -1
  38613. */
  38614. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38615. /**
  38616. * Gets a boolean indicating if the observable has at least one observer
  38617. * @returns true is the Observable has at least one Observer registered
  38618. */
  38619. hasObservers(): boolean;
  38620. /**
  38621. * Clear the list of observers
  38622. */
  38623. clear(): void;
  38624. /**
  38625. * Clone the current observable
  38626. * @returns a new observable
  38627. */
  38628. clone(): Observable<T>;
  38629. /**
  38630. * Does this observable handles observer registered with a given mask
  38631. * @param mask defines the mask to be tested
  38632. * @return whether or not one observer registered with the given mask is handeled
  38633. **/
  38634. hasSpecificMask(mask?: number): boolean;
  38635. }
  38636. }
  38637. declare module BABYLON {
  38638. /**
  38639. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38640. */
  38641. class PerformanceMonitor {
  38642. private _enabled;
  38643. private _rollingFrameTime;
  38644. private _lastFrameTimeMs;
  38645. /**
  38646. * constructor
  38647. * @param frameSampleSize The number of samples required to saturate the sliding window
  38648. */
  38649. constructor(frameSampleSize?: number);
  38650. /**
  38651. * Samples current frame
  38652. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38653. */
  38654. sampleFrame(timeMs?: number): void;
  38655. /**
  38656. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38657. */
  38658. readonly averageFrameTime: number;
  38659. /**
  38660. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38661. */
  38662. readonly averageFrameTimeVariance: number;
  38663. /**
  38664. * Returns the frame time of the most recent frame
  38665. */
  38666. readonly instantaneousFrameTime: number;
  38667. /**
  38668. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38669. */
  38670. readonly averageFPS: number;
  38671. /**
  38672. * Returns the average framerate in frames per second using the most recent frame time
  38673. */
  38674. readonly instantaneousFPS: number;
  38675. /**
  38676. * Returns true if enough samples have been taken to completely fill the sliding window
  38677. */
  38678. readonly isSaturated: boolean;
  38679. /**
  38680. * Enables contributions to the sliding window sample set
  38681. */
  38682. enable(): void;
  38683. /**
  38684. * Disables contributions to the sliding window sample set
  38685. * Samples will not be interpolated over the disabled period
  38686. */
  38687. disable(): void;
  38688. /**
  38689. * Returns true if sampling is enabled
  38690. */
  38691. readonly isEnabled: boolean;
  38692. /**
  38693. * Resets performance monitor
  38694. */
  38695. reset(): void;
  38696. }
  38697. /**
  38698. * RollingAverage
  38699. *
  38700. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38701. */
  38702. class RollingAverage {
  38703. /**
  38704. * Current average
  38705. */
  38706. average: number;
  38707. /**
  38708. * Current variance
  38709. */
  38710. variance: number;
  38711. protected _samples: Array<number>;
  38712. protected _sampleCount: number;
  38713. protected _pos: number;
  38714. protected _m2: number;
  38715. /**
  38716. * constructor
  38717. * @param length The number of samples required to saturate the sliding window
  38718. */
  38719. constructor(length: number);
  38720. /**
  38721. * Adds a sample to the sample set
  38722. * @param v The sample value
  38723. */
  38724. add(v: number): void;
  38725. /**
  38726. * Returns previously added values or null if outside of history or outside the sliding window domain
  38727. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38728. * @return Value previously recorded with add() or null if outside of range
  38729. */
  38730. history(i: number): number;
  38731. /**
  38732. * Returns true if enough samples have been taken to completely fill the sliding window
  38733. * @return true if sample-set saturated
  38734. */
  38735. isSaturated(): boolean;
  38736. /**
  38737. * Resets the rolling average (equivalent to 0 samples taken so far)
  38738. */
  38739. reset(): void;
  38740. /**
  38741. * Wraps a value around the sample range boundaries
  38742. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38743. * @return Wrapped position in sample range
  38744. */
  38745. protected _wrapPosition(i: number): number;
  38746. }
  38747. }
  38748. declare module BABYLON {
  38749. /**
  38750. * Helper class that provides a small promise polyfill
  38751. */
  38752. class PromisePolyfill {
  38753. /**
  38754. * Static function used to check if the polyfill is required
  38755. * If this is the case then the function will inject the polyfill to window.Promise
  38756. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38757. */
  38758. static Apply(force?: boolean): void;
  38759. }
  38760. }
  38761. declare module BABYLON {
  38762. /**
  38763. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38765. */
  38766. class SceneOptimization {
  38767. /**
  38768. * Defines the priority of this optimization (0 by default which means first in the list)
  38769. */
  38770. priority: number;
  38771. /**
  38772. * Gets a string describing the action executed by the current optimization
  38773. * @returns description string
  38774. */
  38775. getDescription(): string;
  38776. /**
  38777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38778. * @param scene defines the current scene where to apply this optimization
  38779. * @param optimizer defines the current optimizer
  38780. * @returns true if everything that can be done was applied
  38781. */
  38782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38783. /**
  38784. * Creates the SceneOptimization object
  38785. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38786. * @param desc defines the description associated with the optimization
  38787. */
  38788. constructor(
  38789. /**
  38790. * Defines the priority of this optimization (0 by default which means first in the list)
  38791. */
  38792. priority?: number);
  38793. }
  38794. /**
  38795. * Defines an optimization used to reduce the size of render target textures
  38796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38797. */
  38798. class TextureOptimization extends SceneOptimization {
  38799. /**
  38800. * Defines the priority of this optimization (0 by default which means first in the list)
  38801. */
  38802. priority: number;
  38803. /**
  38804. * 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
  38805. */
  38806. maximumSize: number;
  38807. /**
  38808. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38809. */
  38810. step: number;
  38811. /**
  38812. * Gets a string describing the action executed by the current optimization
  38813. * @returns description string
  38814. */
  38815. getDescription(): string;
  38816. /**
  38817. * Creates the TextureOptimization object
  38818. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38819. * @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
  38820. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38821. */
  38822. constructor(
  38823. /**
  38824. * Defines the priority of this optimization (0 by default which means first in the list)
  38825. */
  38826. priority?: number,
  38827. /**
  38828. * 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
  38829. */
  38830. maximumSize?: number,
  38831. /**
  38832. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38833. */
  38834. step?: number);
  38835. /**
  38836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38837. * @param scene defines the current scene where to apply this optimization
  38838. * @param optimizer defines the current optimizer
  38839. * @returns true if everything that can be done was applied
  38840. */
  38841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38842. }
  38843. /**
  38844. * Defines an optimization used to increase or decrease the rendering resolution
  38845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38846. */
  38847. class HardwareScalingOptimization extends SceneOptimization {
  38848. /**
  38849. * Defines the priority of this optimization (0 by default which means first in the list)
  38850. */
  38851. priority: number;
  38852. /**
  38853. * Defines the maximum scale to use (2 by default)
  38854. */
  38855. maximumScale: number;
  38856. /**
  38857. * Defines the step to use between two passes (0.5 by default)
  38858. */
  38859. step: number;
  38860. private _currentScale;
  38861. private _directionOffset;
  38862. /**
  38863. * Gets a string describing the action executed by the current optimization
  38864. * @return description string
  38865. */
  38866. getDescription(): string;
  38867. /**
  38868. * Creates the HardwareScalingOptimization object
  38869. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38870. * @param maximumScale defines the maximum scale to use (2 by default)
  38871. * @param step defines the step to use between two passes (0.5 by default)
  38872. */
  38873. constructor(
  38874. /**
  38875. * Defines the priority of this optimization (0 by default which means first in the list)
  38876. */
  38877. priority?: number,
  38878. /**
  38879. * Defines the maximum scale to use (2 by default)
  38880. */
  38881. maximumScale?: number,
  38882. /**
  38883. * Defines the step to use between two passes (0.5 by default)
  38884. */
  38885. step?: number);
  38886. /**
  38887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38888. * @param scene defines the current scene where to apply this optimization
  38889. * @param optimizer defines the current optimizer
  38890. * @returns true if everything that can be done was applied
  38891. */
  38892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38893. }
  38894. /**
  38895. * Defines an optimization used to remove shadows
  38896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38897. */
  38898. class ShadowsOptimization extends SceneOptimization {
  38899. /**
  38900. * Gets a string describing the action executed by the current optimization
  38901. * @return description string
  38902. */
  38903. getDescription(): string;
  38904. /**
  38905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38906. * @param scene defines the current scene where to apply this optimization
  38907. * @param optimizer defines the current optimizer
  38908. * @returns true if everything that can be done was applied
  38909. */
  38910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38911. }
  38912. /**
  38913. * Defines an optimization used to turn post-processes off
  38914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38915. */
  38916. class PostProcessesOptimization extends SceneOptimization {
  38917. /**
  38918. * Gets a string describing the action executed by the current optimization
  38919. * @return description string
  38920. */
  38921. getDescription(): string;
  38922. /**
  38923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38924. * @param scene defines the current scene where to apply this optimization
  38925. * @param optimizer defines the current optimizer
  38926. * @returns true if everything that can be done was applied
  38927. */
  38928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38929. }
  38930. /**
  38931. * Defines an optimization used to turn lens flares off
  38932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38933. */
  38934. class LensFlaresOptimization extends SceneOptimization {
  38935. /**
  38936. * Gets a string describing the action executed by the current optimization
  38937. * @return description string
  38938. */
  38939. getDescription(): string;
  38940. /**
  38941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38942. * @param scene defines the current scene where to apply this optimization
  38943. * @param optimizer defines the current optimizer
  38944. * @returns true if everything that can be done was applied
  38945. */
  38946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38947. }
  38948. /**
  38949. * Defines an optimization based on user defined callback.
  38950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38951. */
  38952. class CustomOptimization extends SceneOptimization {
  38953. /**
  38954. * Callback called to apply the custom optimization.
  38955. */
  38956. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38957. /**
  38958. * Callback called to get custom description
  38959. */
  38960. onGetDescription: () => string;
  38961. /**
  38962. * Gets a string describing the action executed by the current optimization
  38963. * @returns description string
  38964. */
  38965. getDescription(): string;
  38966. /**
  38967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38968. * @param scene defines the current scene where to apply this optimization
  38969. * @param optimizer defines the current optimizer
  38970. * @returns true if everything that can be done was applied
  38971. */
  38972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38973. }
  38974. /**
  38975. * Defines an optimization used to turn particles off
  38976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38977. */
  38978. class ParticlesOptimization extends SceneOptimization {
  38979. /**
  38980. * Gets a string describing the action executed by the current optimization
  38981. * @return description string
  38982. */
  38983. getDescription(): string;
  38984. /**
  38985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38986. * @param scene defines the current scene where to apply this optimization
  38987. * @param optimizer defines the current optimizer
  38988. * @returns true if everything that can be done was applied
  38989. */
  38990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38991. }
  38992. /**
  38993. * Defines an optimization used to turn render targets off
  38994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38995. */
  38996. class RenderTargetsOptimization extends SceneOptimization {
  38997. /**
  38998. * Gets a string describing the action executed by the current optimization
  38999. * @return description string
  39000. */
  39001. getDescription(): string;
  39002. /**
  39003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39004. * @param scene defines the current scene where to apply this optimization
  39005. * @param optimizer defines the current optimizer
  39006. * @returns true if everything that can be done was applied
  39007. */
  39008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39009. }
  39010. /**
  39011. * Defines an optimization used to merge meshes with compatible materials
  39012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39013. */
  39014. class MergeMeshesOptimization extends SceneOptimization {
  39015. private static _UpdateSelectionTree;
  39016. /**
  39017. * Gets or sets a boolean which defines if optimization octree has to be updated
  39018. */
  39019. /**
  39020. * Gets or sets a boolean which defines if optimization octree has to be updated
  39021. */
  39022. static UpdateSelectionTree: boolean;
  39023. /**
  39024. * Gets a string describing the action executed by the current optimization
  39025. * @return description string
  39026. */
  39027. getDescription(): string;
  39028. private _canBeMerged;
  39029. /**
  39030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39031. * @param scene defines the current scene where to apply this optimization
  39032. * @param optimizer defines the current optimizer
  39033. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  39034. * @returns true if everything that can be done was applied
  39035. */
  39036. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  39037. }
  39038. /**
  39039. * Defines a list of options used by SceneOptimizer
  39040. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39041. */
  39042. class SceneOptimizerOptions {
  39043. /**
  39044. * Defines the target frame rate to reach (60 by default)
  39045. */
  39046. targetFrameRate: number;
  39047. /**
  39048. * Defines the interval between two checkes (2000ms by default)
  39049. */
  39050. trackerDuration: number;
  39051. /**
  39052. * Gets the list of optimizations to apply
  39053. */
  39054. optimizations: SceneOptimization[];
  39055. /**
  39056. * Creates a new list of options used by SceneOptimizer
  39057. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  39058. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  39059. */
  39060. constructor(
  39061. /**
  39062. * Defines the target frame rate to reach (60 by default)
  39063. */
  39064. targetFrameRate?: number,
  39065. /**
  39066. * Defines the interval between two checkes (2000ms by default)
  39067. */
  39068. trackerDuration?: number);
  39069. /**
  39070. * Add a new optimization
  39071. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39072. * @returns the current SceneOptimizerOptions
  39073. */
  39074. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39075. /**
  39076. * Add a new custom optimization
  39077. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39078. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39079. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39080. * @returns the current SceneOptimizerOptions
  39081. */
  39082. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39083. /**
  39084. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39085. * @param targetFrameRate defines the target frame rate (60 by default)
  39086. * @returns a SceneOptimizerOptions object
  39087. */
  39088. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39089. /**
  39090. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39091. * @param targetFrameRate defines the target frame rate (60 by default)
  39092. * @returns a SceneOptimizerOptions object
  39093. */
  39094. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39095. /**
  39096. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39097. * @param targetFrameRate defines the target frame rate (60 by default)
  39098. * @returns a SceneOptimizerOptions object
  39099. */
  39100. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39101. }
  39102. /**
  39103. * Class used to run optimizations in order to reach a target frame rate
  39104. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39105. */
  39106. class SceneOptimizer implements IDisposable {
  39107. private _isRunning;
  39108. private _options;
  39109. private _scene;
  39110. private _currentPriorityLevel;
  39111. private _targetFrameRate;
  39112. private _trackerDuration;
  39113. private _currentFrameRate;
  39114. private _sceneDisposeObserver;
  39115. private _improvementMode;
  39116. /**
  39117. * Defines an observable called when the optimizer reaches the target frame rate
  39118. */
  39119. onSuccessObservable: Observable<SceneOptimizer>;
  39120. /**
  39121. * Defines an observable called when the optimizer enables an optimization
  39122. */
  39123. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39124. /**
  39125. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39126. */
  39127. onFailureObservable: Observable<SceneOptimizer>;
  39128. /**
  39129. * Gets a boolean indicating if the optimizer is in improvement mode
  39130. */
  39131. readonly isInImprovementMode: boolean;
  39132. /**
  39133. * Gets the current priority level (0 at start)
  39134. */
  39135. readonly currentPriorityLevel: number;
  39136. /**
  39137. * Gets the current frame rate checked by the SceneOptimizer
  39138. */
  39139. readonly currentFrameRate: number;
  39140. /**
  39141. * Gets or sets the current target frame rate (60 by default)
  39142. */
  39143. /**
  39144. * Gets or sets the current target frame rate (60 by default)
  39145. */
  39146. targetFrameRate: number;
  39147. /**
  39148. * Gets or sets the current interval between two checks (every 2000ms by default)
  39149. */
  39150. /**
  39151. * Gets or sets the current interval between two checks (every 2000ms by default)
  39152. */
  39153. trackerDuration: number;
  39154. /**
  39155. * Gets the list of active optimizations
  39156. */
  39157. readonly optimizations: SceneOptimization[];
  39158. /**
  39159. * Creates a new SceneOptimizer
  39160. * @param scene defines the scene to work on
  39161. * @param options defines the options to use with the SceneOptimizer
  39162. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39163. * @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)
  39164. */
  39165. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39166. /**
  39167. * Stops the current optimizer
  39168. */
  39169. stop(): void;
  39170. /**
  39171. * Reset the optimizer to initial step (current priority level = 0)
  39172. */
  39173. reset(): void;
  39174. /**
  39175. * Start the optimizer. By default it will try to reach a specific framerate
  39176. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39177. */
  39178. start(): void;
  39179. private _checkCurrentState;
  39180. /**
  39181. * Release all resources
  39182. */
  39183. dispose(): void;
  39184. /**
  39185. * Helper function to create a SceneOptimizer with one single line of code
  39186. * @param scene defines the scene to work on
  39187. * @param options defines the options to use with the SceneOptimizer
  39188. * @param onSuccess defines a callback to call on success
  39189. * @param onFailure defines a callback to call on failure
  39190. * @returns the new SceneOptimizer object
  39191. */
  39192. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39193. }
  39194. }
  39195. declare module BABYLON {
  39196. /**
  39197. * Class used to serialize a scene into a string
  39198. */
  39199. class SceneSerializer {
  39200. /**
  39201. * Clear cache used by a previous serialization
  39202. */
  39203. static ClearCache(): void;
  39204. /**
  39205. * Serialize a scene into a JSON compatible object
  39206. * @param scene defines the scene to serialize
  39207. * @returns a JSON compatible object
  39208. */
  39209. static Serialize(scene: Scene): any;
  39210. /**
  39211. * Serialize a mesh into a JSON compatible object
  39212. * @param toSerialize defines the mesh to serialize
  39213. * @param withParents defines if parents must be serialized as well
  39214. * @param withChildren defines if children must be serialized as well
  39215. * @returns a JSON compatible object
  39216. */
  39217. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39218. }
  39219. }
  39220. declare module BABYLON {
  39221. /**
  39222. * Defines an array and its length.
  39223. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39224. */
  39225. interface ISmartArrayLike<T> {
  39226. /**
  39227. * The data of the array.
  39228. */
  39229. data: Array<T>;
  39230. /**
  39231. * The active length of the array.
  39232. */
  39233. length: number;
  39234. }
  39235. /**
  39236. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39237. */
  39238. class SmartArray<T> implements ISmartArrayLike<T> {
  39239. /**
  39240. * The full set of data from the array.
  39241. */
  39242. data: Array<T>;
  39243. /**
  39244. * The active length of the array.
  39245. */
  39246. length: number;
  39247. protected _id: number;
  39248. /**
  39249. * Instantiates a Smart Array.
  39250. * @param capacity defines the default capacity of the array.
  39251. */
  39252. constructor(capacity: number);
  39253. /**
  39254. * Pushes a value at the end of the active data.
  39255. * @param value defines the object to push in the array.
  39256. */
  39257. push(value: T): void;
  39258. /**
  39259. * Iterates over the active data and apply the lambda to them.
  39260. * @param func defines the action to apply on each value.
  39261. */
  39262. forEach(func: (content: T) => void): void;
  39263. /**
  39264. * Sorts the full sets of data.
  39265. * @param compareFn defines the comparison function to apply.
  39266. */
  39267. sort(compareFn: (a: T, b: T) => number): void;
  39268. /**
  39269. * Resets the active data to an empty array.
  39270. */
  39271. reset(): void;
  39272. /**
  39273. * Releases all the data from the array as well as the array.
  39274. */
  39275. dispose(): void;
  39276. /**
  39277. * Concats the active data with a given array.
  39278. * @param array defines the data to concatenate with.
  39279. */
  39280. concat(array: any): void;
  39281. /**
  39282. * Returns the position of a value in the active data.
  39283. * @param value defines the value to find the index for
  39284. * @returns the index if found in the active data otherwise -1
  39285. */
  39286. indexOf(value: T): number;
  39287. /**
  39288. * Returns whether an element is part of the active data.
  39289. * @param value defines the value to look for
  39290. * @returns true if found in the active data otherwise false
  39291. */
  39292. contains(value: T): boolean;
  39293. private static _GlobalId;
  39294. }
  39295. /**
  39296. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39297. * The data in this array can only be present once
  39298. */
  39299. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39300. private _duplicateId;
  39301. /**
  39302. * Pushes a value at the end of the active data.
  39303. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39304. * @param value defines the object to push in the array.
  39305. */
  39306. push(value: T): void;
  39307. /**
  39308. * Pushes a value at the end of the active data.
  39309. * If the data is already present, it won t be added again
  39310. * @param value defines the object to push in the array.
  39311. * @returns true if added false if it was already present
  39312. */
  39313. pushNoDuplicate(value: T): boolean;
  39314. /**
  39315. * Resets the active data to an empty array.
  39316. */
  39317. reset(): void;
  39318. /**
  39319. * Concats the active data with a given array.
  39320. * This ensures no dupplicate will be present in the result.
  39321. * @param array defines the data to concatenate with.
  39322. */
  39323. concatWithNoDuplicate(array: any): void;
  39324. }
  39325. }
  39326. declare module BABYLON {
  39327. /**
  39328. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39329. * The underlying implementation relies on an associative array to ensure the best performances.
  39330. * The value can be anything including 'null' but except 'undefined'
  39331. */
  39332. class StringDictionary<T> {
  39333. /**
  39334. * This will clear this dictionary and copy the content from the 'source' one.
  39335. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39336. * @param source the dictionary to take the content from and copy to this dictionary
  39337. */
  39338. copyFrom(source: StringDictionary<T>): void;
  39339. /**
  39340. * Get a value based from its key
  39341. * @param key the given key to get the matching value from
  39342. * @return the value if found, otherwise undefined is returned
  39343. */
  39344. get(key: string): T | undefined;
  39345. /**
  39346. * Get a value from its key or add it if it doesn't exist.
  39347. * This method will ensure you that a given key/data will be present in the dictionary.
  39348. * @param key the given key to get the matching value from
  39349. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39350. * The factory will only be invoked if there's no data for the given key.
  39351. * @return the value corresponding to the key.
  39352. */
  39353. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39354. /**
  39355. * Get a value from its key if present in the dictionary otherwise add it
  39356. * @param key the key to get the value from
  39357. * @param val if there's no such key/value pair in the dictionary add it with this value
  39358. * @return the value corresponding to the key
  39359. */
  39360. getOrAdd(key: string, val: T): T;
  39361. /**
  39362. * Check if there's a given key in the dictionary
  39363. * @param key the key to check for
  39364. * @return true if the key is present, false otherwise
  39365. */
  39366. contains(key: string): boolean;
  39367. /**
  39368. * Add a new key and its corresponding value
  39369. * @param key the key to add
  39370. * @param value the value corresponding to the key
  39371. * @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
  39372. */
  39373. add(key: string, value: T): boolean;
  39374. /**
  39375. * Update a specific value associated to a key
  39376. * @param key defines the key to use
  39377. * @param value defines the value to store
  39378. * @returns true if the value was updated (or false if the key was not found)
  39379. */
  39380. set(key: string, value: T): boolean;
  39381. /**
  39382. * Get the element of the given key and remove it from the dictionary
  39383. * @param key defines the key to search
  39384. * @returns the value associated with the key or null if not found
  39385. */
  39386. getAndRemove(key: string): Nullable<T>;
  39387. /**
  39388. * Remove a key/value from the dictionary.
  39389. * @param key the key to remove
  39390. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39391. */
  39392. remove(key: string): boolean;
  39393. /**
  39394. * Clear the whole content of the dictionary
  39395. */
  39396. clear(): void;
  39397. /**
  39398. * Gets the current count
  39399. */
  39400. readonly count: number;
  39401. /**
  39402. * Execute a callback on each key/val of the dictionary.
  39403. * Note that you can remove any element in this dictionary in the callback implementation
  39404. * @param callback the callback to execute on a given key/value pair
  39405. */
  39406. forEach(callback: (key: string, val: T) => void): void;
  39407. /**
  39408. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39409. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39410. * Note that you can remove any element in this dictionary in the callback implementation
  39411. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39412. * @returns the first item
  39413. */
  39414. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39415. private _count;
  39416. private _data;
  39417. }
  39418. }
  39419. declare module BABYLON {
  39420. /**
  39421. * Class used to store custom tags
  39422. */
  39423. class Tags {
  39424. /**
  39425. * Adds support for tags on the given object
  39426. * @param obj defines the object to use
  39427. */
  39428. static EnableFor(obj: any): void;
  39429. /**
  39430. * Removes tags support
  39431. * @param obj defines the object to use
  39432. */
  39433. static DisableFor(obj: any): void;
  39434. /**
  39435. * Gets a boolean indicating if the given object has tags
  39436. * @param obj defines the object to use
  39437. * @returns a boolean
  39438. */
  39439. static HasTags(obj: any): boolean;
  39440. /**
  39441. * Gets the tags available on a given object
  39442. * @param obj defines the object to use
  39443. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39444. * @returns the tags
  39445. */
  39446. static GetTags(obj: any, asString?: boolean): any;
  39447. /**
  39448. * Adds tags to an object
  39449. * @param obj defines the object to use
  39450. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39451. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39452. */
  39453. static AddTagsTo(obj: any, tagsString: string): void;
  39454. /**
  39455. * @hidden
  39456. */
  39457. static _AddTagTo(obj: any, tag: string): void;
  39458. /**
  39459. * Removes specific tags from a specific object
  39460. * @param obj defines the object to use
  39461. * @param tagsString defines the tags to remove
  39462. */
  39463. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39464. /**
  39465. * @hidden
  39466. */
  39467. static _RemoveTagFrom(obj: any, tag: string): void;
  39468. /**
  39469. * Defines if tags hosted on an object match a given query
  39470. * @param obj defines the object to use
  39471. * @param tagsQuery defines the tag query
  39472. * @returns a boolean
  39473. */
  39474. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39475. }
  39476. }
  39477. declare module BABYLON {
  39478. /**
  39479. * Class used to host texture specific utilities
  39480. */
  39481. class TextureTools {
  39482. /**
  39483. * Uses the GPU to create a copy texture rescaled at a given size
  39484. * @param texture Texture to copy from
  39485. * @param width defines the desired width
  39486. * @param height defines the desired height
  39487. * @param useBilinearMode defines if bilinear mode has to be used
  39488. * @return the generated texture
  39489. */
  39490. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39491. /**
  39492. * Gets an environment BRDF texture for a given scene
  39493. * @param scene defines the hosting scene
  39494. * @returns the environment BRDF texture
  39495. */
  39496. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39497. private static _environmentBRDFBase64Texture;
  39498. }
  39499. }
  39500. declare module BABYLON {
  39501. /**
  39502. * Based on jsTGALoader - Javascript loader for TGA file
  39503. * By Vincent Thibault
  39504. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39505. */
  39506. class TGATools {
  39507. private static _TYPE_INDEXED;
  39508. private static _TYPE_RGB;
  39509. private static _TYPE_GREY;
  39510. private static _TYPE_RLE_INDEXED;
  39511. private static _TYPE_RLE_RGB;
  39512. private static _TYPE_RLE_GREY;
  39513. private static _ORIGIN_MASK;
  39514. private static _ORIGIN_SHIFT;
  39515. private static _ORIGIN_BL;
  39516. private static _ORIGIN_BR;
  39517. private static _ORIGIN_UL;
  39518. private static _ORIGIN_UR;
  39519. /**
  39520. * Gets the header of a TGA file
  39521. * @param data defines the TGA data
  39522. * @returns the header
  39523. */
  39524. static GetTGAHeader(data: Uint8Array): any;
  39525. /**
  39526. * Uploads TGA content to a Babylon Texture
  39527. * @hidden
  39528. */
  39529. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39530. /** @hidden */
  39531. 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;
  39532. /** @hidden */
  39533. 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;
  39534. /** @hidden */
  39535. 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;
  39536. /** @hidden */
  39537. 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;
  39538. /** @hidden */
  39539. 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;
  39540. /** @hidden */
  39541. 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;
  39542. }
  39543. }
  39544. declare module BABYLON {
  39545. /**
  39546. * Interface for any object that can request an animation frame
  39547. */
  39548. interface ICustomAnimationFrameRequester {
  39549. /**
  39550. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39551. */
  39552. renderFunction?: Function;
  39553. /**
  39554. * Called to request the next frame to render to
  39555. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39556. */
  39557. requestAnimationFrame: Function;
  39558. /**
  39559. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39560. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39561. */
  39562. requestID?: number;
  39563. }
  39564. /**
  39565. * Interface containing an array of animations
  39566. */
  39567. interface IAnimatable {
  39568. /**
  39569. * Array of animations
  39570. */
  39571. animations: Array<Animation>;
  39572. }
  39573. /** Interface used by value gradients (color, factor, ...) */
  39574. interface IValueGradient {
  39575. /**
  39576. * Gets or sets the gradient value (between 0 and 1)
  39577. */
  39578. gradient: number;
  39579. }
  39580. /** Class used to store color4 gradient */
  39581. class ColorGradient implements IValueGradient {
  39582. /**
  39583. * Gets or sets the gradient value (between 0 and 1)
  39584. */
  39585. gradient: number;
  39586. /**
  39587. * Gets or sets first associated color
  39588. */
  39589. color1: Color4;
  39590. /**
  39591. * Gets or sets second associated color
  39592. */
  39593. color2?: Color4;
  39594. /**
  39595. * Will get a color picked randomly between color1 and color2.
  39596. * If color2 is undefined then color1 will be used
  39597. * @param result defines the target Color4 to store the result in
  39598. */
  39599. getColorToRef(result: Color4): void;
  39600. }
  39601. /** Class used to store color 3 gradient */
  39602. class Color3Gradient implements IValueGradient {
  39603. /**
  39604. * Gets or sets the gradient value (between 0 and 1)
  39605. */
  39606. gradient: number;
  39607. /**
  39608. * Gets or sets the associated color
  39609. */
  39610. color: Color3;
  39611. }
  39612. /** Class used to store factor gradient */
  39613. class FactorGradient 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 factor
  39620. */
  39621. factor1: number;
  39622. /**
  39623. * Gets or sets second associated factor
  39624. */
  39625. factor2?: number;
  39626. /**
  39627. * Will get a number picked randomly between factor1 and factor2.
  39628. * If factor2 is undefined then factor1 will be used
  39629. * @returns the picked number
  39630. */
  39631. getFactor(): number;
  39632. }
  39633. /**
  39634. * @ignore
  39635. * Application error to support additional information when loading a file
  39636. */
  39637. class LoadFileError extends Error {
  39638. /** defines the optional XHR request */
  39639. request?: XMLHttpRequest | undefined;
  39640. private static _setPrototypeOf;
  39641. /**
  39642. * Creates a new LoadFileError
  39643. * @param message defines the message of the error
  39644. * @param request defines the optional XHR request
  39645. */
  39646. constructor(message: string,
  39647. /** defines the optional XHR request */
  39648. request?: XMLHttpRequest | undefined);
  39649. }
  39650. /**
  39651. * Class used to define a retry strategy when error happens while loading assets
  39652. */
  39653. class RetryStrategy {
  39654. /**
  39655. * Function used to defines an exponential back off strategy
  39656. * @param maxRetries defines the maximum number of retries (3 by default)
  39657. * @param baseInterval defines the interval between retries
  39658. * @returns the strategy function to use
  39659. */
  39660. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39661. }
  39662. /**
  39663. * File request interface
  39664. */
  39665. interface IFileRequest {
  39666. /**
  39667. * Raised when the request is complete (success or error).
  39668. */
  39669. onCompleteObservable: Observable<IFileRequest>;
  39670. /**
  39671. * Aborts the request for a file.
  39672. */
  39673. abort: () => void;
  39674. }
  39675. /**
  39676. * Class containing a set of static utilities functions
  39677. */
  39678. class Tools {
  39679. /**
  39680. * Gets or sets the base URL to use to load assets
  39681. */
  39682. static BaseUrl: string;
  39683. /**
  39684. * Enable/Disable Custom HTTP Request Headers globally.
  39685. * default = false
  39686. * @see CustomRequestHeaders
  39687. */
  39688. static UseCustomRequestHeaders: boolean;
  39689. /**
  39690. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39691. * i.e. when loading files, where the server/service expects an Authorization header.
  39692. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39693. */
  39694. static CustomRequestHeaders: {
  39695. [key: string]: string;
  39696. };
  39697. /**
  39698. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39699. */
  39700. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39701. /**
  39702. * Default behaviour for cors in the application.
  39703. * It can be a string if the expected behavior is identical in the entire app.
  39704. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39705. */
  39706. static CorsBehavior: string | ((url: string | string[]) => string);
  39707. /**
  39708. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39709. * @ignorenaming
  39710. */
  39711. static UseFallbackTexture: boolean;
  39712. /**
  39713. * Use this object to register external classes like custom textures or material
  39714. * to allow the laoders to instantiate them
  39715. */
  39716. static RegisteredExternalClasses: {
  39717. [key: string]: Object;
  39718. };
  39719. /**
  39720. * Texture content used if a texture cannot loaded
  39721. * @ignorenaming
  39722. */
  39723. static fallbackTexture: string;
  39724. /**
  39725. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39726. * @param u defines the coordinate on X axis
  39727. * @param v defines the coordinate on Y axis
  39728. * @param width defines the width of the source data
  39729. * @param height defines the height of the source data
  39730. * @param pixels defines the source byte array
  39731. * @param color defines the output color
  39732. */
  39733. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39734. /**
  39735. * Interpolates between a and b via alpha
  39736. * @param a The lower value (returned when alpha = 0)
  39737. * @param b The upper value (returned when alpha = 1)
  39738. * @param alpha The interpolation-factor
  39739. * @return The mixed value
  39740. */
  39741. static Mix(a: number, b: number, alpha: number): number;
  39742. /**
  39743. * Tries to instantiate a new object from a given class name
  39744. * @param className defines the class name to instantiate
  39745. * @returns the new object or null if the system was not able to do the instantiation
  39746. */
  39747. static Instantiate(className: string): any;
  39748. /**
  39749. * Provides a slice function that will work even on IE
  39750. * @param data defines the array to slice
  39751. * @param start defines the start of the data (optional)
  39752. * @param end defines the end of the data (optional)
  39753. * @returns the new sliced array
  39754. */
  39755. static Slice<T>(data: T, start?: number, end?: number): T;
  39756. /**
  39757. * Polyfill for setImmediate
  39758. * @param action defines the action to execute after the current execution block
  39759. */
  39760. static SetImmediate(action: () => void): void;
  39761. /**
  39762. * Function indicating if a number is an exponent of 2
  39763. * @param value defines the value to test
  39764. * @returns true if the value is an exponent of 2
  39765. */
  39766. static IsExponentOfTwo(value: number): boolean;
  39767. private static _tmpFloatArray;
  39768. /**
  39769. * Returns the nearest 32-bit single precision float representation of a Number
  39770. * @param value A Number. If the parameter is of a different type, it will get converted
  39771. * to a number or to NaN if it cannot be converted
  39772. * @returns number
  39773. */
  39774. static FloatRound(value: number): number;
  39775. /**
  39776. * Find the next highest power of two.
  39777. * @param x Number to start search from.
  39778. * @return Next highest power of two.
  39779. */
  39780. static CeilingPOT(x: number): number;
  39781. /**
  39782. * Find the next lowest power of two.
  39783. * @param x Number to start search from.
  39784. * @return Next lowest power of two.
  39785. */
  39786. static FloorPOT(x: number): number;
  39787. /**
  39788. * Find the nearest power of two.
  39789. * @param x Number to start search from.
  39790. * @return Next nearest power of two.
  39791. */
  39792. static NearestPOT(x: number): number;
  39793. /**
  39794. * Get the closest exponent of two
  39795. * @param value defines the value to approximate
  39796. * @param max defines the maximum value to return
  39797. * @param mode defines how to define the closest value
  39798. * @returns closest exponent of two of the given value
  39799. */
  39800. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39801. /**
  39802. * Extracts the filename from a path
  39803. * @param path defines the path to use
  39804. * @returns the filename
  39805. */
  39806. static GetFilename(path: string): string;
  39807. /**
  39808. * Extracts the "folder" part of a path (everything before the filename).
  39809. * @param uri The URI to extract the info from
  39810. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39811. * @returns The "folder" part of the path
  39812. */
  39813. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39814. /**
  39815. * Extracts text content from a DOM element hierarchy
  39816. * @param element defines the root element
  39817. * @returns a string
  39818. */
  39819. static GetDOMTextContent(element: HTMLElement): string;
  39820. /**
  39821. * Convert an angle in radians to degrees
  39822. * @param angle defines the angle to convert
  39823. * @returns the angle in degrees
  39824. */
  39825. static ToDegrees(angle: number): number;
  39826. /**
  39827. * Convert an angle in degrees to radians
  39828. * @param angle defines the angle to convert
  39829. * @returns the angle in radians
  39830. */
  39831. static ToRadians(angle: number): number;
  39832. /**
  39833. * Encode a buffer to a base64 string
  39834. * @param buffer defines the buffer to encode
  39835. * @returns the encoded string
  39836. */
  39837. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39838. /**
  39839. * Extracts minimum and maximum values from a list of indexed positions
  39840. * @param positions defines the positions to use
  39841. * @param indices defines the indices to the positions
  39842. * @param indexStart defines the start index
  39843. * @param indexCount defines the end index
  39844. * @param bias defines bias value to add to the result
  39845. * @return minimum and maximum values
  39846. */
  39847. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39848. minimum: Vector3;
  39849. maximum: Vector3;
  39850. };
  39851. /**
  39852. * Extracts minimum and maximum values from a list of positions
  39853. * @param positions defines the positions to use
  39854. * @param start defines the start index in the positions array
  39855. * @param count defines the number of positions to handle
  39856. * @param bias defines bias value to add to the result
  39857. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39858. * @return minimum and maximum values
  39859. */
  39860. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39861. minimum: Vector3;
  39862. maximum: Vector3;
  39863. };
  39864. /**
  39865. * Returns an array if obj is not an array
  39866. * @param obj defines the object to evaluate as an array
  39867. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39868. * @returns either obj directly if obj is an array or a new array containing obj
  39869. */
  39870. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39871. /**
  39872. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39873. * @param size the number of element to construct and put in the array
  39874. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39875. * @returns a new array filled with new objects
  39876. */
  39877. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39878. /**
  39879. * Gets the pointer prefix to use
  39880. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39881. */
  39882. static GetPointerPrefix(): string;
  39883. /**
  39884. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39885. * @param func - the function to be called
  39886. * @param requester - the object that will request the next frame. Falls back to window.
  39887. * @returns frame number
  39888. */
  39889. static QueueNewFrame(func: () => void, requester?: any): number;
  39890. /**
  39891. * Ask the browser to promote the current element to fullscreen rendering mode
  39892. * @param element defines the DOM element to promote
  39893. */
  39894. static RequestFullscreen(element: HTMLElement): void;
  39895. /**
  39896. * Asks the browser to exit fullscreen mode
  39897. */
  39898. static ExitFullscreen(): void;
  39899. /**
  39900. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39901. * @param url define the url we are trying
  39902. * @param element define the dom element where to configure the cors policy
  39903. */
  39904. static SetCorsBehavior(url: string | string[], element: {
  39905. crossOrigin: string | null;
  39906. }): void;
  39907. /**
  39908. * Removes unwanted characters from an url
  39909. * @param url defines the url to clean
  39910. * @returns the cleaned url
  39911. */
  39912. static CleanUrl(url: string): string;
  39913. /**
  39914. * Gets or sets a function used to pre-process url before using them to load assets
  39915. */
  39916. static PreprocessUrl: (url: string) => string;
  39917. /**
  39918. * Loads an image as an HTMLImageElement.
  39919. * @param input url string, ArrayBuffer, or Blob to load
  39920. * @param onLoad callback called when the image successfully loads
  39921. * @param onError callback called when the image fails to load
  39922. * @param offlineProvider offline provider for caching
  39923. * @returns the HTMLImageElement of the loaded image
  39924. */
  39925. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39926. /**
  39927. * Loads a file
  39928. * @param url url string, ArrayBuffer, or Blob to load
  39929. * @param onSuccess callback called when the file successfully loads
  39930. * @param onProgress callback called while file is loading (if the server supports this mode)
  39931. * @param offlineProvider defines the offline provider for caching
  39932. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39933. * @param onError callback called when the file fails to load
  39934. * @returns a file request object
  39935. */
  39936. 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;
  39937. /**
  39938. * Load a script (identified by an url). When the url returns, the
  39939. * content of this file is added into a new script element, attached to the DOM (body element)
  39940. * @param scriptUrl defines the url of the script to laod
  39941. * @param onSuccess defines the callback called when the script is loaded
  39942. * @param onError defines the callback to call if an error occurs
  39943. */
  39944. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39945. /**
  39946. * Loads a file from a blob
  39947. * @param fileToLoad defines the blob to use
  39948. * @param callback defines the callback to call when data is loaded
  39949. * @param progressCallback defines the callback to call during loading process
  39950. * @returns a file request object
  39951. */
  39952. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39953. /**
  39954. * Loads a file
  39955. * @param fileToLoad defines the file to load
  39956. * @param callback defines the callback to call when data is loaded
  39957. * @param progressCallBack defines the callback to call during loading process
  39958. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39959. * @returns a file request object
  39960. */
  39961. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39962. /**
  39963. * Creates a data url from a given string content
  39964. * @param content defines the content to convert
  39965. * @returns the new data url link
  39966. */
  39967. static FileAsURL(content: string): string;
  39968. /**
  39969. * Format the given number to a specific decimal format
  39970. * @param value defines the number to format
  39971. * @param decimals defines the number of decimals to use
  39972. * @returns the formatted string
  39973. */
  39974. static Format(value: number, decimals?: number): string;
  39975. /**
  39976. * Checks if a given vector is inside a specific range
  39977. * @param v defines the vector to test
  39978. * @param min defines the minimum range
  39979. * @param max defines the maximum range
  39980. */
  39981. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39982. /**
  39983. * Tries to copy an object by duplicating every property
  39984. * @param source defines the source object
  39985. * @param destination defines the target object
  39986. * @param doNotCopyList defines a list of properties to avoid
  39987. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39988. */
  39989. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39990. /**
  39991. * Gets a boolean indicating if the given object has no own property
  39992. * @param obj defines the object to test
  39993. * @returns true if object has no own property
  39994. */
  39995. static IsEmpty(obj: any): boolean;
  39996. /**
  39997. * Function used to register events at window level
  39998. * @param events defines the events to register
  39999. */
  40000. static RegisterTopRootEvents(events: {
  40001. name: string;
  40002. handler: Nullable<(e: FocusEvent) => any>;
  40003. }[]): void;
  40004. /**
  40005. * Function used to unregister events from window level
  40006. * @param events defines the events to unregister
  40007. */
  40008. static UnregisterTopRootEvents(events: {
  40009. name: string;
  40010. handler: Nullable<(e: FocusEvent) => any>;
  40011. }[]): void;
  40012. /**
  40013. * Dumps the current bound framebuffer
  40014. * @param width defines the rendering width
  40015. * @param height defines the rendering height
  40016. * @param engine defines the hosting engine
  40017. * @param successCallback defines the callback triggered once the data are available
  40018. * @param mimeType defines the mime type of the result
  40019. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40020. */
  40021. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40022. /**
  40023. * Converts the canvas data to blob.
  40024. * This acts as a polyfill for browsers not supporting the to blob function.
  40025. * @param canvas Defines the canvas to extract the data from
  40026. * @param successCallback Defines the callback triggered once the data are available
  40027. * @param mimeType Defines the mime type of the result
  40028. */
  40029. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40030. /**
  40031. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40032. * @param successCallback defines the callback triggered once the data are available
  40033. * @param mimeType defines the mime type of the result
  40034. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40035. */
  40036. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40037. /**
  40038. * Downloads a blob in the browser
  40039. * @param blob defines the blob to download
  40040. * @param fileName defines the name of the downloaded file
  40041. */
  40042. static Download(blob: Blob, fileName: string): void;
  40043. /**
  40044. * Captures a screenshot of the current rendering
  40045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40046. * @param engine defines the rendering engine
  40047. * @param camera defines the source camera
  40048. * @param size This parameter can be set to a single number or to an object with the
  40049. * following (optional) properties: precision, width, height. If a single number is passed,
  40050. * it will be used for both width and height. If an object is passed, the screenshot size
  40051. * will be derived from the parameters. The precision property is a multiplier allowing
  40052. * rendering at a higher or lower resolution
  40053. * @param successCallback defines the callback receives a single parameter which contains the
  40054. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40055. * src parameter of an <img> to display it
  40056. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40057. * Check your browser for supported MIME types
  40058. */
  40059. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  40060. /**
  40061. * Generates an image screenshot from the specified camera.
  40062. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40063. * @param engine The engine to use for rendering
  40064. * @param camera The camera to use for rendering
  40065. * @param size This parameter can be set to a single number or to an object with the
  40066. * following (optional) properties: precision, width, height. If a single number is passed,
  40067. * it will be used for both width and height. If an object is passed, the screenshot size
  40068. * will be derived from the parameters. The precision property is a multiplier allowing
  40069. * rendering at a higher or lower resolution
  40070. * @param successCallback The callback receives a single parameter which contains the
  40071. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40072. * src parameter of an <img> to display it
  40073. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40074. * Check your browser for supported MIME types
  40075. * @param samples Texture samples (default: 1)
  40076. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40077. * @param fileName A name for for the downloaded file.
  40078. */
  40079. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40080. /**
  40081. * Validates if xhr data is correct
  40082. * @param xhr defines the request to validate
  40083. * @param dataType defines the expected data type
  40084. * @returns true if data is correct
  40085. */
  40086. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40087. /**
  40088. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40089. * Be aware Math.random() could cause collisions, but:
  40090. * "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"
  40091. * @returns a pseudo random id
  40092. */
  40093. static RandomId(): string;
  40094. /**
  40095. * Test if the given uri is a base64 string
  40096. * @param uri The uri to test
  40097. * @return True if the uri is a base64 string or false otherwise
  40098. */
  40099. static IsBase64(uri: string): boolean;
  40100. /**
  40101. * Decode the given base64 uri.
  40102. * @param uri The uri to decode
  40103. * @return The decoded base64 data.
  40104. */
  40105. static DecodeBase64(uri: string): ArrayBuffer;
  40106. /**
  40107. * No log
  40108. */
  40109. static readonly NoneLogLevel: number;
  40110. /**
  40111. * Only message logs
  40112. */
  40113. static readonly MessageLogLevel: number;
  40114. /**
  40115. * Only warning logs
  40116. */
  40117. static readonly WarningLogLevel: number;
  40118. /**
  40119. * Only error logs
  40120. */
  40121. static readonly ErrorLogLevel: number;
  40122. /**
  40123. * All logs
  40124. */
  40125. static readonly AllLogLevel: number;
  40126. private static _LogCache;
  40127. /**
  40128. * Gets a value indicating the number of loading errors
  40129. * @ignorenaming
  40130. */
  40131. static errorsCount: number;
  40132. /**
  40133. * Callback called when a new log is added
  40134. */
  40135. static OnNewCacheEntry: (entry: string) => void;
  40136. private static _AddLogEntry;
  40137. private static _FormatMessage;
  40138. private static _LogDisabled;
  40139. private static _LogEnabled;
  40140. private static _WarnDisabled;
  40141. private static _WarnEnabled;
  40142. private static _ErrorDisabled;
  40143. private static _ErrorEnabled;
  40144. /**
  40145. * Log a message to the console
  40146. */
  40147. static Log: (message: string) => void;
  40148. /**
  40149. * Write a warning message to the console
  40150. */
  40151. static Warn: (message: string) => void;
  40152. /**
  40153. * Write an error message to the console
  40154. */
  40155. static Error: (message: string) => void;
  40156. /**
  40157. * Gets current log cache (list of logs)
  40158. */
  40159. static readonly LogCache: string;
  40160. /**
  40161. * Clears the log cache
  40162. */
  40163. static ClearLogCache(): void;
  40164. /**
  40165. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40166. */
  40167. static LogLevels: number;
  40168. /**
  40169. * Checks if the loaded document was accessed via `file:`-Protocol.
  40170. * @returns boolean
  40171. */
  40172. static IsFileURL(): boolean;
  40173. /**
  40174. * Checks if the window object exists
  40175. * @returns true if the window object exists
  40176. */
  40177. static IsWindowObjectExist(): boolean;
  40178. /**
  40179. * No performance log
  40180. */
  40181. static readonly PerformanceNoneLogLevel: number;
  40182. /**
  40183. * Use user marks to log performance
  40184. */
  40185. static readonly PerformanceUserMarkLogLevel: number;
  40186. /**
  40187. * Log performance to the console
  40188. */
  40189. static readonly PerformanceConsoleLogLevel: number;
  40190. private static _performance;
  40191. /**
  40192. * Sets the current performance log level
  40193. */
  40194. static PerformanceLogLevel: number;
  40195. private static _StartPerformanceCounterDisabled;
  40196. private static _EndPerformanceCounterDisabled;
  40197. private static _StartUserMark;
  40198. private static _EndUserMark;
  40199. private static _StartPerformanceConsole;
  40200. private static _EndPerformanceConsole;
  40201. /**
  40202. * Injects the @see CustomRequestHeaders into the given request
  40203. * @param request the request that should be used for injection
  40204. */
  40205. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40206. /**
  40207. * Starts a performance counter
  40208. */
  40209. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40210. /**
  40211. * Ends a specific performance coutner
  40212. */
  40213. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40214. /**
  40215. * Gets either window.performance.now() if supported or Date.now() else
  40216. */
  40217. static readonly Now: number;
  40218. /**
  40219. * This method will return the name of the class used to create the instance of the given object.
  40220. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40221. * @param object the object to get the class name from
  40222. * @param isType defines if the object is actually a type
  40223. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40224. */
  40225. static GetClassName(object: any, isType?: boolean): string;
  40226. /**
  40227. * Gets the first element of an array satisfying a given predicate
  40228. * @param array defines the array to browse
  40229. * @param predicate defines the predicate to use
  40230. * @returns null if not found or the element
  40231. */
  40232. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40233. /**
  40234. * This method will return the name of the full name of the class, including its owning module (if any).
  40235. * 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).
  40236. * @param object the object to get the class name from
  40237. * @param isType defines if the object is actually a type
  40238. * @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.
  40239. * @ignorenaming
  40240. */
  40241. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40242. /**
  40243. * Returns a promise that resolves after the given amount of time.
  40244. * @param delay Number of milliseconds to delay
  40245. * @returns Promise that resolves after the given amount of time
  40246. */
  40247. static DelayAsync(delay: number): Promise<void>;
  40248. /**
  40249. * Gets the current gradient from an array of IValueGradient
  40250. * @param ratio defines the current ratio to get
  40251. * @param gradients defines the array of IValueGradient
  40252. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40253. */
  40254. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40255. }
  40256. /**
  40257. * This class is used to track a performance counter which is number based.
  40258. * The user has access to many properties which give statistics of different nature.
  40259. *
  40260. * The implementer can track two kinds of Performance Counter: time and count.
  40261. * 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.
  40262. * 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.
  40263. */
  40264. class PerfCounter {
  40265. /**
  40266. * Gets or sets a global boolean to turn on and off all the counters
  40267. */
  40268. static Enabled: boolean;
  40269. /**
  40270. * Returns the smallest value ever
  40271. */
  40272. readonly min: number;
  40273. /**
  40274. * Returns the biggest value ever
  40275. */
  40276. readonly max: number;
  40277. /**
  40278. * Returns the average value since the performance counter is running
  40279. */
  40280. readonly average: number;
  40281. /**
  40282. * Returns the average value of the last second the counter was monitored
  40283. */
  40284. readonly lastSecAverage: number;
  40285. /**
  40286. * Returns the current value
  40287. */
  40288. readonly current: number;
  40289. /**
  40290. * Gets the accumulated total
  40291. */
  40292. readonly total: number;
  40293. /**
  40294. * Gets the total value count
  40295. */
  40296. readonly count: number;
  40297. /**
  40298. * Creates a new counter
  40299. */
  40300. constructor();
  40301. /**
  40302. * Call this method to start monitoring a new frame.
  40303. * 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.
  40304. */
  40305. fetchNewFrame(): void;
  40306. /**
  40307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40308. * @param newCount the count value to add to the monitored count
  40309. * @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.
  40310. */
  40311. addCount(newCount: number, fetchResult: boolean): void;
  40312. /**
  40313. * Start monitoring this performance counter
  40314. */
  40315. beginMonitoring(): void;
  40316. /**
  40317. * Compute the time lapsed since the previous beginMonitoring() call.
  40318. * @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
  40319. */
  40320. endMonitoring(newFrame?: boolean): void;
  40321. private _fetchResult;
  40322. private _startMonitoringTime;
  40323. private _min;
  40324. private _max;
  40325. private _average;
  40326. private _current;
  40327. private _totalValueCount;
  40328. private _totalAccumulated;
  40329. private _lastSecAverage;
  40330. private _lastSecAccumulated;
  40331. private _lastSecTime;
  40332. private _lastSecValueCount;
  40333. }
  40334. /**
  40335. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40336. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40337. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40338. * @param name The name of the class, case should be preserved
  40339. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40340. */
  40341. function className(name: string, module?: string): (target: Object) => void;
  40342. /**
  40343. * An implementation of a loop for asynchronous functions.
  40344. */
  40345. class AsyncLoop {
  40346. /**
  40347. * Defines the number of iterations for the loop
  40348. */
  40349. iterations: number;
  40350. /**
  40351. * Defines the current index of the loop.
  40352. */
  40353. index: number;
  40354. private _done;
  40355. private _fn;
  40356. private _successCallback;
  40357. /**
  40358. * Constructor.
  40359. * @param iterations the number of iterations.
  40360. * @param func the function to run each iteration
  40361. * @param successCallback the callback that will be called upon succesful execution
  40362. * @param offset starting offset.
  40363. */
  40364. constructor(
  40365. /**
  40366. * Defines the number of iterations for the loop
  40367. */
  40368. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40369. /**
  40370. * Execute the next iteration. Must be called after the last iteration was finished.
  40371. */
  40372. executeNext(): void;
  40373. /**
  40374. * Break the loop and run the success callback.
  40375. */
  40376. breakLoop(): void;
  40377. /**
  40378. * Create and run an async loop.
  40379. * @param iterations the number of iterations.
  40380. * @param fn the function to run each iteration
  40381. * @param successCallback the callback that will be called upon succesful execution
  40382. * @param offset starting offset.
  40383. * @returns the created async loop object
  40384. */
  40385. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40386. /**
  40387. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40388. * @param iterations total number of iterations
  40389. * @param syncedIterations number of synchronous iterations in each async iteration.
  40390. * @param fn the function to call each iteration.
  40391. * @param callback a success call back that will be called when iterating stops.
  40392. * @param breakFunction a break condition (optional)
  40393. * @param timeout timeout settings for the setTimeout function. default - 0.
  40394. * @returns the created async loop object
  40395. */
  40396. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40397. }
  40398. }
  40399. interface HTMLCanvasElement {
  40400. /** Track wether a record is in progress */
  40401. isRecording: boolean;
  40402. /** Capture Stream method defined by some browsers */
  40403. captureStream(fps?: number): MediaStream;
  40404. }
  40405. interface MediaRecorder {
  40406. /** Starts recording */
  40407. start(timeSlice: number): void;
  40408. /** Stops recording */
  40409. stop(): void;
  40410. /** Event raised when an error arised. */
  40411. onerror: (event: ErrorEvent) => void;
  40412. /** Event raised when the recording stops. */
  40413. onstop: (event: Event) => void;
  40414. /** Event raised when a new chunk of data is available and should be tracked. */
  40415. ondataavailable: (event: Event) => void;
  40416. }
  40417. interface MediaRecorderOptions {
  40418. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40419. mimeType?: string;
  40420. /** The chosen bitrate for the audio component of the media. */
  40421. audioBitsPerSecond?: number;
  40422. /** The chosen bitrate for the video component of the media. */
  40423. videoBitsPerSecond?: number;
  40424. /** 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. */
  40425. bitsPerSecond?: number;
  40426. }
  40427. interface MediaRecorderConstructor {
  40428. /**
  40429. * A reference to the prototype.
  40430. */
  40431. readonly prototype: MediaRecorder;
  40432. /**
  40433. * Creates a new MediaRecorder.
  40434. * @param stream Defines the stream to record.
  40435. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40436. */
  40437. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40438. }
  40439. /**
  40440. * MediaRecoreder object available in some browsers.
  40441. */
  40442. declare var MediaRecorder: MediaRecorderConstructor;
  40443. declare module BABYLON {
  40444. /**
  40445. * This represents the different options avilable for the video capture.
  40446. */
  40447. interface VideoRecorderOptions {
  40448. /** Defines the mime type of the video */
  40449. mimeType: string;
  40450. /** Defines the video the video should be recorded at */
  40451. fps: number;
  40452. /** Defines the chunk size for the recording data */
  40453. recordChunckSize: number;
  40454. }
  40455. /**
  40456. * This can helps recording videos from BabylonJS.
  40457. * This is based on the available WebRTC functionalities of the browser.
  40458. *
  40459. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40460. */
  40461. class VideoRecorder {
  40462. private static readonly _defaultOptions;
  40463. /**
  40464. * Returns wehther or not the VideoRecorder is available in your browser.
  40465. * @param engine Defines the Babylon Engine to check the support for
  40466. * @returns true if supported otherwise false
  40467. */
  40468. static IsSupported(engine: Engine): boolean;
  40469. private readonly _options;
  40470. private _canvas;
  40471. private _mediaRecorder;
  40472. private _recordedChunks;
  40473. private _fileName;
  40474. private _resolve;
  40475. private _reject;
  40476. /**
  40477. * True wether a recording is already in progress.
  40478. */
  40479. readonly isRecording: boolean;
  40480. /**
  40481. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40482. * a video file.
  40483. * @param engine Defines the BabylonJS Engine you wish to record
  40484. * @param options Defines options that can be used to customized the capture
  40485. */
  40486. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40487. /**
  40488. * Stops the current recording before the default capture timeout passed in the startRecording
  40489. * functions.
  40490. */
  40491. stopRecording(): void;
  40492. /**
  40493. * Starts recording the canvas for a max duration specified in parameters.
  40494. * @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.
  40495. * @param maxDuration Defines the maximum recording time in seconds.
  40496. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40497. * @return a promise callback at the end of the recording with the video data in Blob.
  40498. */
  40499. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40500. /**
  40501. * Releases internal resources used during the recording.
  40502. */
  40503. dispose(): void;
  40504. private _handleDataAvailable;
  40505. private _handleError;
  40506. private _handleStop;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * Defines the potential axis of a Joystick
  40512. */
  40513. enum JoystickAxis {
  40514. /** X axis */
  40515. X = 0,
  40516. /** Y axis */
  40517. Y = 1,
  40518. /** Z axis */
  40519. Z = 2
  40520. }
  40521. /**
  40522. * Class used to define virtual joystick (used in touch mode)
  40523. */
  40524. class VirtualJoystick {
  40525. /**
  40526. * Gets or sets a boolean indicating that left and right values must be inverted
  40527. */
  40528. reverseLeftRight: boolean;
  40529. /**
  40530. * Gets or sets a boolean indicating that up and down values must be inverted
  40531. */
  40532. reverseUpDown: boolean;
  40533. /**
  40534. * Gets the offset value for the position (ie. the change of the position value)
  40535. */
  40536. deltaPosition: Vector3;
  40537. /**
  40538. * Gets a boolean indicating if the virtual joystick was pressed
  40539. */
  40540. pressed: boolean;
  40541. /**
  40542. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40543. */
  40544. static Canvas: Nullable<HTMLCanvasElement>;
  40545. private static _globalJoystickIndex;
  40546. private static vjCanvasContext;
  40547. private static vjCanvasWidth;
  40548. private static vjCanvasHeight;
  40549. private static halfWidth;
  40550. private _action;
  40551. private _axisTargetedByLeftAndRight;
  40552. private _axisTargetedByUpAndDown;
  40553. private _joystickSensibility;
  40554. private _inversedSensibility;
  40555. private _joystickPointerID;
  40556. private _joystickColor;
  40557. private _joystickPointerPos;
  40558. private _joystickPreviousPointerPos;
  40559. private _joystickPointerStartPos;
  40560. private _deltaJoystickVector;
  40561. private _leftJoystick;
  40562. private _touches;
  40563. private _onPointerDownHandlerRef;
  40564. private _onPointerMoveHandlerRef;
  40565. private _onPointerUpHandlerRef;
  40566. private _onResize;
  40567. /**
  40568. * Creates a new virtual joystick
  40569. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40570. */
  40571. constructor(leftJoystick?: boolean);
  40572. /**
  40573. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40574. * @param newJoystickSensibility defines the new sensibility
  40575. */
  40576. setJoystickSensibility(newJoystickSensibility: number): void;
  40577. private _onPointerDown;
  40578. private _onPointerMove;
  40579. private _onPointerUp;
  40580. /**
  40581. * Change the color of the virtual joystick
  40582. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40583. */
  40584. setJoystickColor(newColor: string): void;
  40585. /**
  40586. * Defines a callback to call when the joystick is touched
  40587. * @param action defines the callback
  40588. */
  40589. setActionOnTouch(action: () => any): void;
  40590. /**
  40591. * Defines which axis you'd like to control for left & right
  40592. * @param axis defines the axis to use
  40593. */
  40594. setAxisForLeftRight(axis: JoystickAxis): void;
  40595. /**
  40596. * Defines which axis you'd like to control for up & down
  40597. * @param axis defines the axis to use
  40598. */
  40599. setAxisForUpDown(axis: JoystickAxis): void;
  40600. private _drawVirtualJoystick;
  40601. /**
  40602. * Release internal HTML canvas
  40603. */
  40604. releaseCanvas(): void;
  40605. }
  40606. }
  40607. declare module BABYLON {
  40608. /**
  40609. * Helper class to push actions to a pool of workers.
  40610. */
  40611. class WorkerPool implements IDisposable {
  40612. private _workerInfos;
  40613. private _pendingActions;
  40614. /**
  40615. * Constructor
  40616. * @param workers Array of workers to use for actions
  40617. */
  40618. constructor(workers: Array<Worker>);
  40619. /**
  40620. * Terminates all workers and clears any pending actions.
  40621. */
  40622. dispose(): void;
  40623. /**
  40624. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40625. * pended until a worker has completed its action.
  40626. * @param action The action to perform. Call onComplete when the action is complete.
  40627. */
  40628. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40629. private _execute;
  40630. }
  40631. }
  40632. declare module BABYLON {
  40633. /**
  40634. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40636. */
  40637. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40638. /**
  40639. * Gets the name of the behavior.
  40640. */
  40641. readonly name: string;
  40642. private _zoomStopsAnimation;
  40643. private _idleRotationSpeed;
  40644. private _idleRotationWaitTime;
  40645. private _idleRotationSpinupTime;
  40646. /**
  40647. * Sets the flag that indicates if user zooming should stop animation.
  40648. */
  40649. /**
  40650. * Gets the flag that indicates if user zooming should stop animation.
  40651. */
  40652. zoomStopsAnimation: boolean;
  40653. /**
  40654. * Sets the default speed at which the camera rotates around the model.
  40655. */
  40656. /**
  40657. * Gets the default speed at which the camera rotates around the model.
  40658. */
  40659. idleRotationSpeed: number;
  40660. /**
  40661. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40662. */
  40663. /**
  40664. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40665. */
  40666. idleRotationWaitTime: number;
  40667. /**
  40668. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40669. */
  40670. /**
  40671. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40672. */
  40673. idleRotationSpinupTime: number;
  40674. /**
  40675. * Gets a value indicating if the camera is currently rotating because of this behavior
  40676. */
  40677. readonly rotationInProgress: boolean;
  40678. private _onPrePointerObservableObserver;
  40679. private _onAfterCheckInputsObserver;
  40680. private _attachedCamera;
  40681. private _isPointerDown;
  40682. private _lastFrameTime;
  40683. private _lastInteractionTime;
  40684. private _cameraRotationSpeed;
  40685. /**
  40686. * Initializes the behavior.
  40687. */
  40688. init(): void;
  40689. /**
  40690. * Attaches the behavior to its arc rotate camera.
  40691. * @param camera Defines the camera to attach the behavior to
  40692. */
  40693. attach(camera: ArcRotateCamera): void;
  40694. /**
  40695. * Detaches the behavior from its current arc rotate camera.
  40696. */
  40697. detach(): void;
  40698. /**
  40699. * Returns true if user is scrolling.
  40700. * @return true if user is scrolling.
  40701. */
  40702. private _userIsZooming;
  40703. private _lastFrameRadius;
  40704. private _shouldAnimationStopForInteraction;
  40705. /**
  40706. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40707. */
  40708. private _applyUserInteraction;
  40709. private _userIsMoving;
  40710. }
  40711. }
  40712. declare module BABYLON {
  40713. /**
  40714. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40716. */
  40717. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40718. /**
  40719. * Gets the name of the behavior.
  40720. */
  40721. readonly name: string;
  40722. /**
  40723. * The easing function used by animations
  40724. */
  40725. static EasingFunction: BackEase;
  40726. /**
  40727. * The easing mode used by animations
  40728. */
  40729. static EasingMode: number;
  40730. /**
  40731. * The duration of the animation, in milliseconds
  40732. */
  40733. transitionDuration: number;
  40734. /**
  40735. * Length of the distance animated by the transition when lower radius is reached
  40736. */
  40737. lowerRadiusTransitionRange: number;
  40738. /**
  40739. * Length of the distance animated by the transition when upper radius is reached
  40740. */
  40741. upperRadiusTransitionRange: number;
  40742. private _autoTransitionRange;
  40743. /**
  40744. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40745. */
  40746. /**
  40747. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40748. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40749. */
  40750. autoTransitionRange: boolean;
  40751. private _attachedCamera;
  40752. private _onAfterCheckInputsObserver;
  40753. private _onMeshTargetChangedObserver;
  40754. /**
  40755. * Initializes the behavior.
  40756. */
  40757. init(): void;
  40758. /**
  40759. * Attaches the behavior to its arc rotate camera.
  40760. * @param camera Defines the camera to attach the behavior to
  40761. */
  40762. attach(camera: ArcRotateCamera): void;
  40763. /**
  40764. * Detaches the behavior from its current arc rotate camera.
  40765. */
  40766. detach(): void;
  40767. private _radiusIsAnimating;
  40768. private _radiusBounceTransition;
  40769. private _animatables;
  40770. private _cachedWheelPrecision;
  40771. /**
  40772. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40773. * @param radiusLimit The limit to check against.
  40774. * @return Bool to indicate if at limit.
  40775. */
  40776. private _isRadiusAtLimit;
  40777. /**
  40778. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40779. * @param radiusDelta The delta by which to animate to. Can be negative.
  40780. */
  40781. private _applyBoundRadiusAnimation;
  40782. /**
  40783. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40784. */
  40785. protected _clearAnimationLocks(): void;
  40786. /**
  40787. * Stops and removes all animations that have been applied to the camera
  40788. */
  40789. stopAllAnimations(): void;
  40790. }
  40791. }
  40792. declare module BABYLON {
  40793. /**
  40794. * 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.
  40795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40796. */
  40797. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40798. /**
  40799. * Gets the name of the behavior.
  40800. */
  40801. readonly name: string;
  40802. private _mode;
  40803. private _radiusScale;
  40804. private _positionScale;
  40805. private _defaultElevation;
  40806. private _elevationReturnTime;
  40807. private _elevationReturnWaitTime;
  40808. private _zoomStopsAnimation;
  40809. private _framingTime;
  40810. /**
  40811. * The easing function used by animations
  40812. */
  40813. static EasingFunction: ExponentialEase;
  40814. /**
  40815. * The easing mode used by animations
  40816. */
  40817. static EasingMode: number;
  40818. /**
  40819. * Sets the current mode used by the behavior
  40820. */
  40821. /**
  40822. * Gets current mode used by the behavior.
  40823. */
  40824. mode: number;
  40825. /**
  40826. * Sets the scale applied to the radius (1 by default)
  40827. */
  40828. /**
  40829. * Gets the scale applied to the radius
  40830. */
  40831. radiusScale: number;
  40832. /**
  40833. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40834. */
  40835. /**
  40836. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40837. */
  40838. positionScale: number;
  40839. /**
  40840. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40841. * behaviour is triggered, in radians.
  40842. */
  40843. /**
  40844. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40845. * behaviour is triggered, in radians.
  40846. */
  40847. defaultElevation: number;
  40848. /**
  40849. * Sets the time (in milliseconds) taken to return to the default beta position.
  40850. * Negative value indicates camera should not return to default.
  40851. */
  40852. /**
  40853. * Gets the time (in milliseconds) taken to return to the default beta position.
  40854. * Negative value indicates camera should not return to default.
  40855. */
  40856. elevationReturnTime: number;
  40857. /**
  40858. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40859. */
  40860. /**
  40861. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40862. */
  40863. elevationReturnWaitTime: number;
  40864. /**
  40865. * Sets the flag that indicates if user zooming should stop animation.
  40866. */
  40867. /**
  40868. * Gets the flag that indicates if user zooming should stop animation.
  40869. */
  40870. zoomStopsAnimation: boolean;
  40871. /**
  40872. * Sets the transition time when framing the mesh, in milliseconds
  40873. */
  40874. /**
  40875. * Gets the transition time when framing the mesh, in milliseconds
  40876. */
  40877. framingTime: number;
  40878. /**
  40879. * Define if the behavior should automatically change the configured
  40880. * camera limits and sensibilities.
  40881. */
  40882. autoCorrectCameraLimitsAndSensibility: boolean;
  40883. private _onPrePointerObservableObserver;
  40884. private _onAfterCheckInputsObserver;
  40885. private _onMeshTargetChangedObserver;
  40886. private _attachedCamera;
  40887. private _isPointerDown;
  40888. private _lastInteractionTime;
  40889. /**
  40890. * Initializes the behavior.
  40891. */
  40892. init(): void;
  40893. /**
  40894. * Attaches the behavior to its arc rotate camera.
  40895. * @param camera Defines the camera to attach the behavior to
  40896. */
  40897. attach(camera: ArcRotateCamera): void;
  40898. /**
  40899. * Detaches the behavior from its current arc rotate camera.
  40900. */
  40901. detach(): void;
  40902. private _animatables;
  40903. private _betaIsAnimating;
  40904. private _betaTransition;
  40905. private _radiusTransition;
  40906. private _vectorTransition;
  40907. /**
  40908. * Targets the given mesh and updates zoom level accordingly.
  40909. * @param mesh The mesh to target.
  40910. * @param radius Optional. If a cached radius position already exists, overrides default.
  40911. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40912. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40913. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40914. */
  40915. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40916. /**
  40917. * Targets the given mesh with its children and updates zoom level accordingly.
  40918. * @param mesh The mesh to target.
  40919. * @param radius Optional. If a cached radius position already exists, overrides default.
  40920. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40921. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40922. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40923. */
  40924. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40925. /**
  40926. * Targets the given meshes with their children and updates zoom level accordingly.
  40927. * @param meshes The mesh to target.
  40928. * @param radius Optional. If a cached radius position already exists, overrides default.
  40929. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40930. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40931. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40932. */
  40933. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40934. /**
  40935. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40936. * @param minimumWorld Determines the smaller position of the bounding box extend
  40937. * @param maximumWorld Determines the bigger position of the bounding box extend
  40938. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40939. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40940. */
  40941. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40942. /**
  40943. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40944. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40945. * frustum width.
  40946. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40947. * to fully enclose the mesh in the viewing frustum.
  40948. */
  40949. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40950. /**
  40951. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40952. * is automatically returned to its default position (expected to be above ground plane).
  40953. */
  40954. private _maintainCameraAboveGround;
  40955. /**
  40956. * Returns the frustum slope based on the canvas ratio and camera FOV
  40957. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40958. */
  40959. private _getFrustumSlope;
  40960. /**
  40961. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40962. */
  40963. private _clearAnimationLocks;
  40964. /**
  40965. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40966. */
  40967. private _applyUserInteraction;
  40968. /**
  40969. * Stops and removes all animations that have been applied to the camera
  40970. */
  40971. stopAllAnimations(): void;
  40972. /**
  40973. * Gets a value indicating if the user is moving the camera
  40974. */
  40975. readonly isUserIsMoving: boolean;
  40976. /**
  40977. * The camera can move all the way towards the mesh.
  40978. */
  40979. static IgnoreBoundsSizeMode: number;
  40980. /**
  40981. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40982. */
  40983. static FitFrustumSidesMode: number;
  40984. }
  40985. }
  40986. declare module BABYLON {
  40987. /**
  40988. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40989. */
  40990. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40991. private ui;
  40992. /**
  40993. * The name of the behavior
  40994. */
  40995. name: string;
  40996. /**
  40997. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40998. */
  40999. distanceAwayFromFace: number;
  41000. /**
  41001. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  41002. */
  41003. distanceAwayFromBottomOfFace: number;
  41004. private _faceVectors;
  41005. private _target;
  41006. private _scene;
  41007. private _onRenderObserver;
  41008. private _tmpMatrix;
  41009. private _tmpVector;
  41010. /**
  41011. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  41012. * @param ui The transform node that should be attched to the mesh
  41013. */
  41014. constructor(ui: BABYLON.TransformNode);
  41015. /**
  41016. * Initializes the behavior
  41017. */
  41018. init(): void;
  41019. private _closestFace;
  41020. private _zeroVector;
  41021. private _lookAtTmpMatrix;
  41022. private _lookAtToRef;
  41023. /**
  41024. * Attaches the AttachToBoxBehavior to the passed in mesh
  41025. * @param target The mesh that the specified node will be attached to
  41026. */
  41027. attach(target: BABYLON.Mesh): void;
  41028. /**
  41029. * Detaches the behavior from the mesh
  41030. */
  41031. detach(): void;
  41032. }
  41033. }
  41034. declare module BABYLON {
  41035. /**
  41036. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  41037. */
  41038. class FadeInOutBehavior implements Behavior<Mesh> {
  41039. /**
  41040. * Time in milliseconds to delay before fading in (Default: 0)
  41041. */
  41042. delay: number;
  41043. /**
  41044. * Time in milliseconds for the mesh to fade in (Default: 300)
  41045. */
  41046. fadeInTime: number;
  41047. private _millisecondsPerFrame;
  41048. private _hovered;
  41049. private _hoverValue;
  41050. private _ownerNode;
  41051. /**
  41052. * Instatiates the FadeInOutBehavior
  41053. */
  41054. constructor();
  41055. /**
  41056. * The name of the behavior
  41057. */
  41058. readonly name: string;
  41059. /**
  41060. * Initializes the behavior
  41061. */
  41062. init(): void;
  41063. /**
  41064. * Attaches the fade behavior on the passed in mesh
  41065. * @param ownerNode The mesh that will be faded in/out once attached
  41066. */
  41067. attach(ownerNode: Mesh): void;
  41068. /**
  41069. * Detaches the behavior from the mesh
  41070. */
  41071. detach(): void;
  41072. /**
  41073. * Triggers the mesh to begin fading in or out
  41074. * @param value if the object should fade in or out (true to fade in)
  41075. */
  41076. fadeIn(value: boolean): void;
  41077. private _update;
  41078. private _setAllVisibility;
  41079. }
  41080. }
  41081. declare module BABYLON {
  41082. /**
  41083. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41084. */
  41085. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41086. private _dragBehaviorA;
  41087. private _dragBehaviorB;
  41088. private _startDistance;
  41089. private _initialScale;
  41090. private _targetScale;
  41091. private _ownerNode;
  41092. private _sceneRenderObserver;
  41093. /**
  41094. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41095. */
  41096. constructor();
  41097. /**
  41098. * The name of the behavior
  41099. */
  41100. readonly name: string;
  41101. /**
  41102. * Initializes the behavior
  41103. */
  41104. init(): void;
  41105. private _getCurrentDistance;
  41106. /**
  41107. * Attaches the scale behavior the passed in mesh
  41108. * @param ownerNode The mesh that will be scaled around once attached
  41109. */
  41110. attach(ownerNode: Mesh): void;
  41111. /**
  41112. * Detaches the behavior from the mesh
  41113. */
  41114. detach(): void;
  41115. }
  41116. }
  41117. declare module BABYLON {
  41118. /**
  41119. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41120. */
  41121. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41122. private static _AnyMouseID;
  41123. private _attachedNode;
  41124. private _dragPlane;
  41125. private _scene;
  41126. private _pointerObserver;
  41127. private _beforeRenderObserver;
  41128. private static _planeScene;
  41129. /**
  41130. * 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)
  41131. */
  41132. maxDragAngle: number;
  41133. /**
  41134. * @hidden
  41135. */
  41136. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41137. /**
  41138. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41139. */
  41140. currentDraggingPointerID: number;
  41141. /**
  41142. * The last position where the pointer hit the drag plane in world space
  41143. */
  41144. lastDragPosition: Vector3;
  41145. /**
  41146. * If the behavior is currently in a dragging state
  41147. */
  41148. dragging: boolean;
  41149. /**
  41150. * 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)
  41151. */
  41152. dragDeltaRatio: number;
  41153. /**
  41154. * If the drag plane orientation should be updated during the dragging (Default: true)
  41155. */
  41156. updateDragPlane: boolean;
  41157. private _debugMode;
  41158. private _moving;
  41159. /**
  41160. * Fires each time the attached mesh is dragged with the pointer
  41161. * * delta between last drag position and current drag position in world space
  41162. * * dragDistance along the drag axis
  41163. * * dragPlaneNormal normal of the current drag plane used during the drag
  41164. * * dragPlanePoint in world space where the drag intersects the drag plane
  41165. */
  41166. onDragObservable: Observable<{
  41167. delta: Vector3;
  41168. dragPlanePoint: Vector3;
  41169. dragPlaneNormal: Vector3;
  41170. dragDistance: number;
  41171. pointerId: number;
  41172. }>;
  41173. /**
  41174. * Fires each time a drag begins (eg. mouse down on mesh)
  41175. */
  41176. onDragStartObservable: Observable<{
  41177. dragPlanePoint: Vector3;
  41178. pointerId: number;
  41179. }>;
  41180. /**
  41181. * Fires each time a drag ends (eg. mouse release after drag)
  41182. */
  41183. onDragEndObservable: Observable<{
  41184. dragPlanePoint: Vector3;
  41185. pointerId: number;
  41186. }>;
  41187. /**
  41188. * If the attached mesh should be moved when dragged
  41189. */
  41190. moveAttached: boolean;
  41191. /**
  41192. * If the drag behavior will react to drag events (Default: true)
  41193. */
  41194. enabled: boolean;
  41195. /**
  41196. * If camera controls should be detached during the drag
  41197. */
  41198. detachCameraControls: boolean;
  41199. /**
  41200. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41201. */
  41202. useObjectOrienationForDragging: boolean;
  41203. private _options;
  41204. /**
  41205. * Creates a pointer drag behavior that can be attached to a mesh
  41206. * @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)
  41207. */
  41208. constructor(options?: {
  41209. dragAxis?: Vector3;
  41210. dragPlaneNormal?: Vector3;
  41211. });
  41212. /**
  41213. * The name of the behavior
  41214. */
  41215. readonly name: string;
  41216. /**
  41217. * Initializes the behavior
  41218. */
  41219. init(): void;
  41220. private _tmpVector;
  41221. private _alternatePickedPoint;
  41222. private _worldDragAxis;
  41223. private _targetPosition;
  41224. private _attachedElement;
  41225. /**
  41226. * Attaches the drag behavior the passed in mesh
  41227. * @param ownerNode The mesh that will be dragged around once attached
  41228. */
  41229. attach(ownerNode: AbstractMesh): void;
  41230. /**
  41231. * Force relase the drag action by code.
  41232. */
  41233. releaseDrag(): void;
  41234. private _startDragRay;
  41235. private _lastPointerRay;
  41236. /**
  41237. * Simulates the start of a pointer drag event on the behavior
  41238. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41239. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41240. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41241. */
  41242. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41243. private _startDrag;
  41244. private _dragDelta;
  41245. private _moveDrag;
  41246. private _pickWithRayOnDragPlane;
  41247. private _pointA;
  41248. private _pointB;
  41249. private _pointC;
  41250. private _lineA;
  41251. private _lineB;
  41252. private _localAxis;
  41253. private _lookAt;
  41254. private _updateDragPlanePosition;
  41255. /**
  41256. * Detaches the behavior from the mesh
  41257. */
  41258. detach(): void;
  41259. }
  41260. }
  41261. declare module BABYLON {
  41262. /**
  41263. * 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
  41264. */
  41265. class SixDofDragBehavior implements Behavior<Mesh> {
  41266. private static _virtualScene;
  41267. private _ownerNode;
  41268. private _sceneRenderObserver;
  41269. private _scene;
  41270. private _targetPosition;
  41271. private _virtualOriginMesh;
  41272. private _virtualDragMesh;
  41273. private _pointerObserver;
  41274. private _moving;
  41275. private _startingOrientation;
  41276. /**
  41277. * 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)
  41278. */
  41279. private zDragFactor;
  41280. /**
  41281. * If the object should rotate to face the drag origin
  41282. */
  41283. rotateDraggedObject: boolean;
  41284. /**
  41285. * If the behavior is currently in a dragging state
  41286. */
  41287. dragging: boolean;
  41288. /**
  41289. * 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)
  41290. */
  41291. dragDeltaRatio: number;
  41292. /**
  41293. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41294. */
  41295. currentDraggingPointerID: number;
  41296. /**
  41297. * If camera controls should be detached during the drag
  41298. */
  41299. detachCameraControls: boolean;
  41300. /**
  41301. * Fires each time a drag starts
  41302. */
  41303. onDragStartObservable: Observable<{}>;
  41304. /**
  41305. * Fires each time a drag ends (eg. mouse release after drag)
  41306. */
  41307. onDragEndObservable: Observable<{}>;
  41308. /**
  41309. * 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
  41310. */
  41311. constructor();
  41312. /**
  41313. * The name of the behavior
  41314. */
  41315. readonly name: string;
  41316. /**
  41317. * Initializes the behavior
  41318. */
  41319. init(): void;
  41320. /**
  41321. * Attaches the scale behavior the passed in mesh
  41322. * @param ownerNode The mesh that will be scaled around once attached
  41323. */
  41324. attach(ownerNode: Mesh): void;
  41325. /**
  41326. * Detaches the behavior from the mesh
  41327. */
  41328. detach(): void;
  41329. }
  41330. }
  41331. declare module BABYLON {
  41332. /**
  41333. * Contains an array of blocks representing the octree
  41334. */
  41335. interface IOctreeContainer<T> {
  41336. /**
  41337. * Blocks within the octree
  41338. */
  41339. blocks: Array<OctreeBlock<T>>;
  41340. }
  41341. /**
  41342. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41343. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41344. */
  41345. class Octree<T> {
  41346. /** 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.) */
  41347. maxDepth: number;
  41348. /**
  41349. * Blocks within the octree containing objects
  41350. */
  41351. blocks: Array<OctreeBlock<T>>;
  41352. /**
  41353. * Content stored in the octree
  41354. */
  41355. dynamicContent: T[];
  41356. private _maxBlockCapacity;
  41357. private _selectionContent;
  41358. private _creationFunc;
  41359. /**
  41360. * Creates a octree
  41361. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41362. * @param creationFunc function to be used to instatiate the octree
  41363. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41364. * @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.)
  41365. */
  41366. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41367. /** 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.) */
  41368. maxDepth?: number);
  41369. /**
  41370. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41371. * @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);
  41372. * @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);
  41373. * @param entries meshes to be added to the octree blocks
  41374. */
  41375. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41376. /**
  41377. * Adds a mesh to the octree
  41378. * @param entry Mesh to add to the octree
  41379. */
  41380. addMesh(entry: T): void;
  41381. /**
  41382. * Selects an array of meshes within the frustum
  41383. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41384. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41385. * @returns array of meshes within the frustum
  41386. */
  41387. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41388. /**
  41389. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41390. * @param sphereCenter defines the bounding sphere center
  41391. * @param sphereRadius defines the bounding sphere radius
  41392. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41393. * @returns an array of objects that intersect the sphere
  41394. */
  41395. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41396. /**
  41397. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41398. * @param ray defines the ray to test with
  41399. * @returns array of intersected objects
  41400. */
  41401. intersectsRay(ray: Ray): SmartArray<T>;
  41402. /**
  41403. * @hidden
  41404. */
  41405. 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;
  41406. /**
  41407. * Adds a mesh into the octree block if it intersects the block
  41408. */
  41409. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41410. /**
  41411. * Adds a submesh into the octree block if it intersects the block
  41412. */
  41413. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41414. }
  41415. }
  41416. declare module BABYLON {
  41417. /**
  41418. * Class used to store a cell in an octree
  41419. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41420. */
  41421. class OctreeBlock<T> {
  41422. /**
  41423. * Gets the content of the current block
  41424. */
  41425. entries: T[];
  41426. /**
  41427. * Gets the list of block children
  41428. */
  41429. blocks: Array<OctreeBlock<T>>;
  41430. private _depth;
  41431. private _maxDepth;
  41432. private _capacity;
  41433. private _minPoint;
  41434. private _maxPoint;
  41435. private _boundingVectors;
  41436. private _creationFunc;
  41437. /**
  41438. * Creates a new block
  41439. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41440. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41441. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41442. * @param depth defines the current depth of this block in the octree
  41443. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41444. * @param creationFunc defines a callback to call when an element is added to the block
  41445. */
  41446. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41447. /**
  41448. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41449. */
  41450. readonly capacity: number;
  41451. /**
  41452. * Gets the minimum vector (in world space) of the block's bounding box
  41453. */
  41454. readonly minPoint: Vector3;
  41455. /**
  41456. * Gets the maximum vector (in world space) of the block's bounding box
  41457. */
  41458. readonly maxPoint: Vector3;
  41459. /**
  41460. * Add a new element to this block
  41461. * @param entry defines the element to add
  41462. */
  41463. addEntry(entry: T): void;
  41464. /**
  41465. * Add an array of elements to this block
  41466. * @param entries defines the array of elements to add
  41467. */
  41468. addEntries(entries: T[]): void;
  41469. /**
  41470. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41471. * @param frustumPlanes defines the frustum planes to test
  41472. * @param selection defines the array to store current content if selection is positive
  41473. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41474. */
  41475. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41476. /**
  41477. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41478. * @param sphereCenter defines the bounding sphere center
  41479. * @param sphereRadius defines the bounding sphere radius
  41480. * @param selection defines the array to store current content if selection is positive
  41481. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41482. */
  41483. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41484. /**
  41485. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41486. * @param ray defines the ray to test with
  41487. * @param selection defines the array to store current content if selection is positive
  41488. */
  41489. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41490. /**
  41491. * Subdivide the content into child blocks (this block will then be empty)
  41492. */
  41493. createInnerBlocks(): void;
  41494. }
  41495. }
  41496. declare module BABYLON {
  41497. interface Scene {
  41498. /**
  41499. * @hidden
  41500. * Backing Filed
  41501. */
  41502. _selectionOctree: Octree<AbstractMesh>;
  41503. /**
  41504. * Gets the octree used to boost mesh selection (picking)
  41505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41506. */
  41507. selectionOctree: Octree<AbstractMesh>;
  41508. /**
  41509. * Creates or updates the octree used to boost selection (picking)
  41510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41511. * @param maxCapacity defines the maximum capacity per leaf
  41512. * @param maxDepth defines the maximum depth of the octree
  41513. * @returns an octree of AbstractMesh
  41514. */
  41515. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41516. }
  41517. interface AbstractMesh {
  41518. /**
  41519. * @hidden
  41520. * Backing Field
  41521. */
  41522. _submeshesOctree: Octree<SubMesh>;
  41523. /**
  41524. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41525. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41526. * @param maxCapacity defines the maximum size of each block (64 by default)
  41527. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41528. * @returns the new octree
  41529. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41531. */
  41532. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41533. }
  41534. /**
  41535. * Defines the octree scene component responsible to manage any octrees
  41536. * in a given scene.
  41537. */
  41538. class OctreeSceneComponent {
  41539. /**
  41540. * The component name helpfull to identify the component in the list of scene components.
  41541. */
  41542. readonly name: string;
  41543. /**
  41544. * The scene the component belongs to.
  41545. */
  41546. scene: Scene;
  41547. /**
  41548. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41549. */
  41550. readonly checksIsEnabled: boolean;
  41551. /**
  41552. * Creates a new instance of the component for the given scene
  41553. * @param scene Defines the scene to register the component in
  41554. */
  41555. constructor(scene: Scene);
  41556. /**
  41557. * Registers the component in a given scene
  41558. */
  41559. register(): void;
  41560. /**
  41561. * Return the list of active meshes
  41562. * @returns the list of active meshes
  41563. */
  41564. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41565. /**
  41566. * Return the list of active sub meshes
  41567. * @param mesh The mesh to get the candidates sub meshes from
  41568. * @returns the list of active sub meshes
  41569. */
  41570. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41571. private _tempRay;
  41572. /**
  41573. * Return the list of sub meshes intersecting with a given local ray
  41574. * @param mesh defines the mesh to find the submesh for
  41575. * @param localRay defines the ray in local space
  41576. * @returns the list of intersecting sub meshes
  41577. */
  41578. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41579. /**
  41580. * Return the list of sub meshes colliding with a collider
  41581. * @param mesh defines the mesh to find the submesh for
  41582. * @param collider defines the collider to evaluate the collision against
  41583. * @returns the list of colliding sub meshes
  41584. */
  41585. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41586. /**
  41587. * Rebuilds the elements related to this component in case of
  41588. * context lost for instance.
  41589. */
  41590. rebuild(): void;
  41591. /**
  41592. * Disposes the component and the associated ressources.
  41593. */
  41594. dispose(): void;
  41595. }
  41596. }
  41597. declare module BABYLON {
  41598. /**
  41599. * Manage the gamepad inputs to control an arc rotate camera.
  41600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41601. */
  41602. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41603. /**
  41604. * Defines the camera the input is attached to.
  41605. */
  41606. camera: ArcRotateCamera;
  41607. /**
  41608. * Defines the gamepad the input is gathering event from.
  41609. */
  41610. gamepad: Nullable<Gamepad>;
  41611. /**
  41612. * Defines the gamepad rotation sensiblity.
  41613. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41614. */
  41615. gamepadRotationSensibility: number;
  41616. /**
  41617. * Defines the gamepad move sensiblity.
  41618. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41619. */
  41620. gamepadMoveSensibility: number;
  41621. private _onGamepadConnectedObserver;
  41622. private _onGamepadDisconnectedObserver;
  41623. /**
  41624. * Attach the input controls to a specific dom element to get the input from.
  41625. * @param element Defines the element the controls should be listened from
  41626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41627. */
  41628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41629. /**
  41630. * Detach the current controls from the specified dom element.
  41631. * @param element Defines the element to stop listening the inputs from
  41632. */
  41633. detachControl(element: Nullable<HTMLElement>): void;
  41634. /**
  41635. * Update the current camera state depending on the inputs that have been used this frame.
  41636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41637. */
  41638. checkInputs(): void;
  41639. /**
  41640. * Gets the class name of the current intput.
  41641. * @returns the class name
  41642. */
  41643. getClassName(): string;
  41644. /**
  41645. * Get the friendly name associated with the input class.
  41646. * @returns the input friendly name
  41647. */
  41648. getSimpleName(): string;
  41649. }
  41650. }
  41651. declare module BABYLON {
  41652. /**
  41653. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41655. */
  41656. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41657. /**
  41658. * Defines the camera the input is attached to.
  41659. */
  41660. camera: ArcRotateCamera;
  41661. /**
  41662. * Defines the list of key codes associated with the up action (increase alpha)
  41663. */
  41664. keysUp: number[];
  41665. /**
  41666. * Defines the list of key codes associated with the down action (decrease alpha)
  41667. */
  41668. keysDown: number[];
  41669. /**
  41670. * Defines the list of key codes associated with the left action (increase beta)
  41671. */
  41672. keysLeft: number[];
  41673. /**
  41674. * Defines the list of key codes associated with the right action (decrease beta)
  41675. */
  41676. keysRight: number[];
  41677. /**
  41678. * Defines the list of key codes associated with the reset action.
  41679. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41680. */
  41681. keysReset: number[];
  41682. /**
  41683. * Defines the panning sensibility of the inputs.
  41684. * (How fast is the camera paning)
  41685. */
  41686. panningSensibility: number;
  41687. /**
  41688. * Defines the zooming sensibility of the inputs.
  41689. * (How fast is the camera zooming)
  41690. */
  41691. zoomingSensibility: number;
  41692. /**
  41693. * Defines wether maintaining the alt key down switch the movement mode from
  41694. * orientation to zoom.
  41695. */
  41696. useAltToZoom: boolean;
  41697. /**
  41698. * Rotation speed of the camera
  41699. */
  41700. angularSpeed: number;
  41701. private _keys;
  41702. private _ctrlPressed;
  41703. private _altPressed;
  41704. private _onCanvasBlurObserver;
  41705. private _onKeyboardObserver;
  41706. private _engine;
  41707. private _scene;
  41708. /**
  41709. * Attach the input controls to a specific dom element to get the input from.
  41710. * @param element Defines the element the controls should be listened from
  41711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41712. */
  41713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41714. /**
  41715. * Detach the current controls from the specified dom element.
  41716. * @param element Defines the element to stop listening the inputs from
  41717. */
  41718. detachControl(element: Nullable<HTMLElement>): void;
  41719. /**
  41720. * Update the current camera state depending on the inputs that have been used this frame.
  41721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41722. */
  41723. checkInputs(): void;
  41724. /**
  41725. * Gets the class name of the current intput.
  41726. * @returns the class name
  41727. */
  41728. getClassName(): string;
  41729. /**
  41730. * Get the friendly name associated with the input class.
  41731. * @returns the input friendly name
  41732. */
  41733. getSimpleName(): string;
  41734. }
  41735. }
  41736. declare module BABYLON {
  41737. /**
  41738. * Manage the mouse wheel inputs to control an arc rotate camera.
  41739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41740. */
  41741. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41742. /**
  41743. * Defines the camera the input is attached to.
  41744. */
  41745. camera: ArcRotateCamera;
  41746. /**
  41747. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41748. */
  41749. wheelPrecision: number;
  41750. /**
  41751. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41752. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41753. */
  41754. wheelDeltaPercentage: number;
  41755. private _wheel;
  41756. private _observer;
  41757. /**
  41758. * Attach the input controls to a specific dom element to get the input from.
  41759. * @param element Defines the element the controls should be listened from
  41760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41761. */
  41762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41763. /**
  41764. * Detach the current controls from the specified dom element.
  41765. * @param element Defines the element to stop listening the inputs from
  41766. */
  41767. detachControl(element: Nullable<HTMLElement>): void;
  41768. /**
  41769. * Gets the class name of the current intput.
  41770. * @returns the class name
  41771. */
  41772. getClassName(): string;
  41773. /**
  41774. * Get the friendly name associated with the input class.
  41775. * @returns the input friendly name
  41776. */
  41777. getSimpleName(): string;
  41778. }
  41779. }
  41780. declare module BABYLON {
  41781. /**
  41782. * Manage the pointers inputs to control an arc rotate camera.
  41783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41784. */
  41785. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41786. /**
  41787. * Defines the camera the input is attached to.
  41788. */
  41789. camera: ArcRotateCamera;
  41790. /**
  41791. * Defines the buttons associated with the input to handle camera move.
  41792. */
  41793. buttons: number[];
  41794. /**
  41795. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41796. */
  41797. angularSensibilityX: number;
  41798. /**
  41799. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41800. */
  41801. angularSensibilityY: number;
  41802. /**
  41803. * Defines the pointer pinch precision or how fast is the camera zooming.
  41804. */
  41805. pinchPrecision: number;
  41806. /**
  41807. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41808. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41809. */
  41810. pinchDeltaPercentage: number;
  41811. /**
  41812. * Defines the pointer panning sensibility or how fast is the camera moving.
  41813. */
  41814. panningSensibility: number;
  41815. /**
  41816. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41817. */
  41818. multiTouchPanning: boolean;
  41819. /**
  41820. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41821. */
  41822. multiTouchPanAndZoom: boolean;
  41823. /**
  41824. * Revers pinch action direction.
  41825. */
  41826. pinchInwards: boolean;
  41827. private _isPanClick;
  41828. private _pointerInput;
  41829. private _observer;
  41830. private _onMouseMove;
  41831. private _onGestureStart;
  41832. private _onGesture;
  41833. private _MSGestureHandler;
  41834. private _onLostFocus;
  41835. private _onContextMenu;
  41836. /**
  41837. * Attach the input controls to a specific dom element to get the input from.
  41838. * @param element Defines the element the controls should be listened from
  41839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41840. */
  41841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41842. /**
  41843. * Detach the current controls from the specified dom element.
  41844. * @param element Defines the element to stop listening the inputs from
  41845. */
  41846. detachControl(element: Nullable<HTMLElement>): void;
  41847. /**
  41848. * Gets the class name of the current intput.
  41849. * @returns the class name
  41850. */
  41851. getClassName(): string;
  41852. /**
  41853. * Get the friendly name associated with the input class.
  41854. * @returns the input friendly name
  41855. */
  41856. getSimpleName(): string;
  41857. }
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41863. */
  41864. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41865. /**
  41866. * Defines the camera the input is attached to.
  41867. */
  41868. camera: ArcRotateCamera;
  41869. /**
  41870. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41871. */
  41872. alphaCorrection: number;
  41873. /**
  41874. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41875. */
  41876. gammaCorrection: number;
  41877. private _alpha;
  41878. private _gamma;
  41879. private _dirty;
  41880. private _deviceOrientationHandler;
  41881. /**
  41882. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41883. */
  41884. constructor();
  41885. /**
  41886. * Attach the input controls to a specific dom element to get the input from.
  41887. * @param element Defines the element the controls should be listened from
  41888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41889. */
  41890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41891. /** @hidden */
  41892. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41893. /**
  41894. * Update the current camera state depending on the inputs that have been used this frame.
  41895. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41896. */
  41897. checkInputs(): void;
  41898. /**
  41899. * Detach the current controls from the specified dom element.
  41900. * @param element Defines the element to stop listening the inputs from
  41901. */
  41902. detachControl(element: Nullable<HTMLElement>): void;
  41903. /**
  41904. * Gets the class name of the current intput.
  41905. * @returns the class name
  41906. */
  41907. getClassName(): string;
  41908. /**
  41909. * Get the friendly name associated with the input class.
  41910. * @returns the input friendly name
  41911. */
  41912. getSimpleName(): string;
  41913. }
  41914. }
  41915. declare module BABYLON {
  41916. /**
  41917. * Listen to keyboard events to control the camera.
  41918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41919. */
  41920. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41921. /**
  41922. * Defines the camera the input is attached to.
  41923. */
  41924. camera: FlyCamera;
  41925. /**
  41926. * The list of keyboard keys used to control the forward move of the camera.
  41927. */
  41928. keysForward: number[];
  41929. /**
  41930. * The list of keyboard keys used to control the backward move of the camera.
  41931. */
  41932. keysBackward: number[];
  41933. /**
  41934. * The list of keyboard keys used to control the forward move of the camera.
  41935. */
  41936. keysUp: number[];
  41937. /**
  41938. * The list of keyboard keys used to control the backward move of the camera.
  41939. */
  41940. keysDown: number[];
  41941. /**
  41942. * The list of keyboard keys used to control the right strafe move of the camera.
  41943. */
  41944. keysRight: number[];
  41945. /**
  41946. * The list of keyboard keys used to control the left strafe move of the camera.
  41947. */
  41948. keysLeft: number[];
  41949. private _keys;
  41950. private _onCanvasBlurObserver;
  41951. private _onKeyboardObserver;
  41952. private _engine;
  41953. private _scene;
  41954. /**
  41955. * Attach the input controls to a specific dom element to get the input from.
  41956. * @param element Defines the element the controls should be listened from
  41957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41958. */
  41959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41960. /**
  41961. * Detach the current controls from the specified dom element.
  41962. * @param element Defines the element to stop listening the inputs from
  41963. */
  41964. detachControl(element: Nullable<HTMLElement>): void;
  41965. /**
  41966. * Gets the class name of the current intput.
  41967. * @returns the class name
  41968. */
  41969. getClassName(): string;
  41970. /** @hidden */
  41971. _onLostFocus(e: FocusEvent): void;
  41972. /**
  41973. * Get the friendly name associated with the input class.
  41974. * @returns the input friendly name
  41975. */
  41976. getSimpleName(): string;
  41977. /**
  41978. * Update the current camera state depending on the inputs that have been used this frame.
  41979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41980. */
  41981. checkInputs(): void;
  41982. }
  41983. }
  41984. declare module BABYLON {
  41985. /**
  41986. * Listen to mouse events to control the camera.
  41987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41988. */
  41989. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41990. /**
  41991. * Defines the camera the input is attached to.
  41992. */
  41993. camera: FlyCamera;
  41994. /**
  41995. * Defines if touch is enabled. (Default is true.)
  41996. */
  41997. touchEnabled: boolean;
  41998. /**
  41999. * Defines the buttons associated with the input to handle camera rotation.
  42000. */
  42001. buttons: number[];
  42002. /**
  42003. * Assign buttons for Yaw control.
  42004. */
  42005. buttonsYaw: number[];
  42006. /**
  42007. * Assign buttons for Pitch control.
  42008. */
  42009. buttonsPitch: number[];
  42010. /**
  42011. * Assign buttons for Roll control.
  42012. */
  42013. buttonsRoll: number[];
  42014. /**
  42015. * Detect if any button is being pressed while mouse is moved.
  42016. * -1 = Mouse locked.
  42017. * 0 = Left button.
  42018. * 1 = Middle Button.
  42019. * 2 = Right Button.
  42020. */
  42021. activeButton: number;
  42022. /**
  42023. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42024. * Higher values reduce its sensitivity.
  42025. */
  42026. angularSensibility: number;
  42027. private _mousemoveCallback;
  42028. private _observer;
  42029. private _rollObserver;
  42030. private previousPosition;
  42031. private noPreventDefault;
  42032. private element;
  42033. /**
  42034. * Listen to mouse events to control the camera.
  42035. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42037. */
  42038. constructor(touchEnabled?: boolean);
  42039. /**
  42040. * Attach the mouse control to the HTML DOM element.
  42041. * @param element Defines the element that listens to the input events.
  42042. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42043. */
  42044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42045. /**
  42046. * Detach the current controls from the specified dom element.
  42047. * @param element Defines the element to stop listening the inputs from
  42048. */
  42049. detachControl(element: Nullable<HTMLElement>): void;
  42050. /**
  42051. * Gets the class name of the current input.
  42052. * @returns the class name.
  42053. */
  42054. getClassName(): string;
  42055. /**
  42056. * Get the friendly name associated with the input class.
  42057. * @returns the input's friendly name.
  42058. */
  42059. getSimpleName(): string;
  42060. private _pointerInput;
  42061. private _onMouseMove;
  42062. /**
  42063. * Rotate camera by mouse offset.
  42064. */
  42065. private rotateCamera;
  42066. }
  42067. }
  42068. declare module BABYLON {
  42069. /**
  42070. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42071. * Screen rotation is taken into account.
  42072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42073. */
  42074. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42075. private _camera;
  42076. private _screenOrientationAngle;
  42077. private _constantTranform;
  42078. private _screenQuaternion;
  42079. private _alpha;
  42080. private _beta;
  42081. private _gamma;
  42082. /**
  42083. * Instantiates a new input
  42084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42085. */
  42086. constructor();
  42087. /**
  42088. * Define the camera controlled by the input.
  42089. */
  42090. camera: FreeCamera;
  42091. /**
  42092. * Attach the input controls to a specific dom element to get the input from.
  42093. * @param element Defines the element the controls should be listened from
  42094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42095. */
  42096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42097. private _orientationChanged;
  42098. private _deviceOrientation;
  42099. /**
  42100. * Detach the current controls from the specified dom element.
  42101. * @param element Defines the element to stop listening the inputs from
  42102. */
  42103. detachControl(element: Nullable<HTMLElement>): void;
  42104. /**
  42105. * Update the current camera state depending on the inputs that have been used this frame.
  42106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42107. */
  42108. checkInputs(): void;
  42109. /**
  42110. * Gets the class name of the current intput.
  42111. * @returns the class name
  42112. */
  42113. getClassName(): string;
  42114. /**
  42115. * Get the friendly name associated with the input class.
  42116. * @returns the input friendly name
  42117. */
  42118. getSimpleName(): string;
  42119. }
  42120. }
  42121. declare module BABYLON {
  42122. /**
  42123. * Manage the gamepad inputs to control a free camera.
  42124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42125. */
  42126. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42127. /**
  42128. * Define the camera the input is attached to.
  42129. */
  42130. camera: FreeCamera;
  42131. /**
  42132. * Define the Gamepad controlling the input
  42133. */
  42134. gamepad: Nullable<Gamepad>;
  42135. /**
  42136. * Defines the gamepad rotation sensiblity.
  42137. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42138. */
  42139. gamepadAngularSensibility: number;
  42140. /**
  42141. * Defines the gamepad move sensiblity.
  42142. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42143. */
  42144. gamepadMoveSensibility: number;
  42145. private _onGamepadConnectedObserver;
  42146. private _onGamepadDisconnectedObserver;
  42147. private _cameraTransform;
  42148. private _deltaTransform;
  42149. private _vector3;
  42150. private _vector2;
  42151. /**
  42152. * Attach the input controls to a specific dom element to get the input from.
  42153. * @param element Defines the element the controls should be listened from
  42154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42155. */
  42156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42157. /**
  42158. * Detach the current controls from the specified dom element.
  42159. * @param element Defines the element to stop listening the inputs from
  42160. */
  42161. detachControl(element: Nullable<HTMLElement>): void;
  42162. /**
  42163. * Update the current camera state depending on the inputs that have been used this frame.
  42164. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42165. */
  42166. checkInputs(): void;
  42167. /**
  42168. * Gets the class name of the current intput.
  42169. * @returns the class name
  42170. */
  42171. getClassName(): string;
  42172. /**
  42173. * Get the friendly name associated with the input class.
  42174. * @returns the input friendly name
  42175. */
  42176. getSimpleName(): string;
  42177. }
  42178. }
  42179. declare module BABYLON {
  42180. /**
  42181. * Manage the keyboard inputs to control the movement of a free camera.
  42182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42183. */
  42184. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42185. /**
  42186. * Defines the camera the input is attached to.
  42187. */
  42188. camera: FreeCamera;
  42189. /**
  42190. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42191. */
  42192. keysUp: number[];
  42193. /**
  42194. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42195. */
  42196. keysDown: number[];
  42197. /**
  42198. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42199. */
  42200. keysLeft: number[];
  42201. /**
  42202. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42203. */
  42204. keysRight: number[];
  42205. private _keys;
  42206. private _onCanvasBlurObserver;
  42207. private _onKeyboardObserver;
  42208. private _engine;
  42209. private _scene;
  42210. /**
  42211. * Attach the input controls to a specific dom element to get the input from.
  42212. * @param element Defines the element the controls should be listened from
  42213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42214. */
  42215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42216. /**
  42217. * Detach the current controls from the specified dom element.
  42218. * @param element Defines the element to stop listening the inputs from
  42219. */
  42220. detachControl(element: Nullable<HTMLElement>): void;
  42221. /**
  42222. * Update the current camera state depending on the inputs that have been used this frame.
  42223. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42224. */
  42225. checkInputs(): void;
  42226. /**
  42227. * Gets the class name of the current intput.
  42228. * @returns the class name
  42229. */
  42230. getClassName(): string;
  42231. /** @hidden */
  42232. _onLostFocus(e: FocusEvent): void;
  42233. /**
  42234. * Get the friendly name associated with the input class.
  42235. * @returns the input friendly name
  42236. */
  42237. getSimpleName(): string;
  42238. }
  42239. }
  42240. declare module BABYLON {
  42241. /**
  42242. * Manage the mouse inputs to control the movement of a free camera.
  42243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42244. */
  42245. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42246. /**
  42247. * Define if touch is enabled in the mouse input
  42248. */
  42249. touchEnabled: boolean;
  42250. /**
  42251. * Defines the camera the input is attached to.
  42252. */
  42253. camera: FreeCamera;
  42254. /**
  42255. * Defines the buttons associated with the input to handle camera move.
  42256. */
  42257. buttons: number[];
  42258. /**
  42259. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42260. */
  42261. angularSensibility: number;
  42262. private _pointerInput;
  42263. private _onMouseMove;
  42264. private _observer;
  42265. private previousPosition;
  42266. /**
  42267. * Manage the mouse inputs to control the movement of a free camera.
  42268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42269. * @param touchEnabled Defines if touch is enabled or not
  42270. */
  42271. constructor(
  42272. /**
  42273. * Define if touch is enabled in the mouse input
  42274. */
  42275. touchEnabled?: boolean);
  42276. /**
  42277. * Attach the input controls to a specific dom element to get the input from.
  42278. * @param element Defines the element the controls should be listened from
  42279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42280. */
  42281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42282. /**
  42283. * Detach the current controls from the specified dom element.
  42284. * @param element Defines the element to stop listening the inputs from
  42285. */
  42286. detachControl(element: Nullable<HTMLElement>): void;
  42287. /**
  42288. * Gets the class name of the current intput.
  42289. * @returns the class name
  42290. */
  42291. getClassName(): string;
  42292. /**
  42293. * Get the friendly name associated with the input class.
  42294. * @returns the input friendly name
  42295. */
  42296. getSimpleName(): string;
  42297. }
  42298. }
  42299. declare module BABYLON {
  42300. /**
  42301. * Manage the touch inputs to control the movement of a free camera.
  42302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42303. */
  42304. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42305. /**
  42306. * Defines the camera the input is attached to.
  42307. */
  42308. camera: FreeCamera;
  42309. /**
  42310. * Defines the touch sensibility for rotation.
  42311. * The higher the faster.
  42312. */
  42313. touchAngularSensibility: number;
  42314. /**
  42315. * Defines the touch sensibility for move.
  42316. * The higher the faster.
  42317. */
  42318. touchMoveSensibility: number;
  42319. private _offsetX;
  42320. private _offsetY;
  42321. private _pointerPressed;
  42322. private _pointerInput;
  42323. private _observer;
  42324. private _onLostFocus;
  42325. /**
  42326. * Attach the input controls to a specific dom element to get the input from.
  42327. * @param element Defines the element the controls should be listened from
  42328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42329. */
  42330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42331. /**
  42332. * Detach the current controls from the specified dom element.
  42333. * @param element Defines the element to stop listening the inputs from
  42334. */
  42335. detachControl(element: Nullable<HTMLElement>): void;
  42336. /**
  42337. * Update the current camera state depending on the inputs that have been used this frame.
  42338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42339. */
  42340. checkInputs(): void;
  42341. /**
  42342. * Gets the class name of the current intput.
  42343. * @returns the class name
  42344. */
  42345. getClassName(): string;
  42346. /**
  42347. * Get the friendly name associated with the input class.
  42348. * @returns the input friendly name
  42349. */
  42350. getSimpleName(): string;
  42351. }
  42352. }
  42353. declare module BABYLON {
  42354. /**
  42355. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42357. */
  42358. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42359. /**
  42360. * Defines the camera the input is attached to.
  42361. */
  42362. camera: FreeCamera;
  42363. private _leftjoystick;
  42364. private _rightjoystick;
  42365. /**
  42366. * Gets the left stick of the virtual joystick.
  42367. * @returns The virtual Joystick
  42368. */
  42369. getLeftJoystick(): VirtualJoystick;
  42370. /**
  42371. * Gets the right stick of the virtual joystick.
  42372. * @returns The virtual Joystick
  42373. */
  42374. getRightJoystick(): VirtualJoystick;
  42375. /**
  42376. * Update the current camera state depending on the inputs that have been used this frame.
  42377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42378. */
  42379. checkInputs(): void;
  42380. /**
  42381. * Attach the input controls to a specific dom element to get the input from.
  42382. * @param element Defines the element the controls should be listened from
  42383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42384. */
  42385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42386. /**
  42387. * Detach the current controls from the specified dom element.
  42388. * @param element Defines the element to stop listening the inputs from
  42389. */
  42390. detachControl(element: Nullable<HTMLElement>): void;
  42391. /**
  42392. * Gets the class name of the current intput.
  42393. * @returns the class name
  42394. */
  42395. getClassName(): string;
  42396. /**
  42397. * Get the friendly name associated with the input class.
  42398. * @returns the input friendly name
  42399. */
  42400. getSimpleName(): string;
  42401. }
  42402. }
  42403. declare module BABYLON {
  42404. /**
  42405. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42406. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42407. */
  42408. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42409. /**
  42410. * Creates a new AnaglyphArcRotateCamera
  42411. * @param name defines camera name
  42412. * @param alpha defines alpha angle (in radians)
  42413. * @param beta defines beta angle (in radians)
  42414. * @param radius defines radius
  42415. * @param target defines camera target
  42416. * @param interaxialDistance defines distance between each color axis
  42417. * @param scene defines the hosting scene
  42418. */
  42419. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42420. /**
  42421. * Gets camera class name
  42422. * @returns AnaglyphArcRotateCamera
  42423. */
  42424. getClassName(): string;
  42425. }
  42426. }
  42427. declare module BABYLON {
  42428. /**
  42429. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42430. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42431. */
  42432. class AnaglyphFreeCamera extends FreeCamera {
  42433. /**
  42434. * Creates a new AnaglyphFreeCamera
  42435. * @param name defines camera name
  42436. * @param position defines initial position
  42437. * @param interaxialDistance defines distance between each color axis
  42438. * @param scene defines the hosting scene
  42439. */
  42440. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42441. /**
  42442. * Gets camera class name
  42443. * @returns AnaglyphFreeCamera
  42444. */
  42445. getClassName(): string;
  42446. }
  42447. }
  42448. declare module BABYLON {
  42449. /**
  42450. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42451. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42452. */
  42453. class AnaglyphGamepadCamera extends GamepadCamera {
  42454. /**
  42455. * Creates a new AnaglyphGamepadCamera
  42456. * @param name defines camera name
  42457. * @param position defines initial position
  42458. * @param interaxialDistance defines distance between each color axis
  42459. * @param scene defines the hosting scene
  42460. */
  42461. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42462. /**
  42463. * Gets camera class name
  42464. * @returns AnaglyphGamepadCamera
  42465. */
  42466. getClassName(): string;
  42467. }
  42468. }
  42469. declare module BABYLON {
  42470. /**
  42471. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42472. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42473. */
  42474. class AnaglyphUniversalCamera extends UniversalCamera {
  42475. /**
  42476. * Creates a new AnaglyphUniversalCamera
  42477. * @param name defines camera name
  42478. * @param position defines initial position
  42479. * @param interaxialDistance defines distance between each color axis
  42480. * @param scene defines the hosting scene
  42481. */
  42482. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42483. /**
  42484. * Gets camera class name
  42485. * @returns AnaglyphUniversalCamera
  42486. */
  42487. getClassName(): string;
  42488. }
  42489. }
  42490. declare module BABYLON {
  42491. /**
  42492. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42493. * @see http://doc.babylonjs.com/features/cameras
  42494. */
  42495. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42496. /**
  42497. * Creates a new StereoscopicArcRotateCamera
  42498. * @param name defines camera name
  42499. * @param alpha defines alpha angle (in radians)
  42500. * @param beta defines beta angle (in radians)
  42501. * @param radius defines radius
  42502. * @param target defines camera target
  42503. * @param interaxialDistance defines distance between each color axis
  42504. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42505. * @param scene defines the hosting scene
  42506. */
  42507. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42508. /**
  42509. * Gets camera class name
  42510. * @returns StereoscopicArcRotateCamera
  42511. */
  42512. getClassName(): string;
  42513. }
  42514. }
  42515. declare module BABYLON {
  42516. /**
  42517. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42518. * @see http://doc.babylonjs.com/features/cameras
  42519. */
  42520. class StereoscopicFreeCamera extends FreeCamera {
  42521. /**
  42522. * Creates a new StereoscopicFreeCamera
  42523. * @param name defines camera name
  42524. * @param position defines initial position
  42525. * @param interaxialDistance defines distance between each color axis
  42526. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42527. * @param scene defines the hosting scene
  42528. */
  42529. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42530. /**
  42531. * Gets camera class name
  42532. * @returns StereoscopicFreeCamera
  42533. */
  42534. getClassName(): string;
  42535. }
  42536. }
  42537. declare module BABYLON {
  42538. /**
  42539. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42540. * @see http://doc.babylonjs.com/features/cameras
  42541. */
  42542. class StereoscopicGamepadCamera extends GamepadCamera {
  42543. /**
  42544. * Creates a new StereoscopicGamepadCamera
  42545. * @param name defines camera name
  42546. * @param position defines initial position
  42547. * @param interaxialDistance defines distance between each color axis
  42548. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42549. * @param scene defines the hosting scene
  42550. */
  42551. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42552. /**
  42553. * Gets camera class name
  42554. * @returns StereoscopicGamepadCamera
  42555. */
  42556. getClassName(): string;
  42557. }
  42558. }
  42559. declare module BABYLON {
  42560. /**
  42561. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42562. * @see http://doc.babylonjs.com/features/cameras
  42563. */
  42564. class StereoscopicUniversalCamera extends UniversalCamera {
  42565. /**
  42566. * Creates a new StereoscopicUniversalCamera
  42567. * @param name defines camera name
  42568. * @param position defines initial position
  42569. * @param interaxialDistance defines distance between each color axis
  42570. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42571. * @param scene defines the hosting scene
  42572. */
  42573. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42574. /**
  42575. * Gets camera class name
  42576. * @returns StereoscopicUniversalCamera
  42577. */
  42578. getClassName(): string;
  42579. }
  42580. }
  42581. declare module BABYLON {
  42582. /**
  42583. * This represents all the required metrics to create a VR camera.
  42584. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42585. */
  42586. class VRCameraMetrics {
  42587. /**
  42588. * Define the horizontal resolution off the screen.
  42589. */
  42590. hResolution: number;
  42591. /**
  42592. * Define the vertical resolution off the screen.
  42593. */
  42594. vResolution: number;
  42595. /**
  42596. * Define the horizontal screen size.
  42597. */
  42598. hScreenSize: number;
  42599. /**
  42600. * Define the vertical screen size.
  42601. */
  42602. vScreenSize: number;
  42603. /**
  42604. * Define the vertical screen center position.
  42605. */
  42606. vScreenCenter: number;
  42607. /**
  42608. * Define the distance of the eyes to the screen.
  42609. */
  42610. eyeToScreenDistance: number;
  42611. /**
  42612. * Define the distance between both lenses
  42613. */
  42614. lensSeparationDistance: number;
  42615. /**
  42616. * Define the distance between both viewer's eyes.
  42617. */
  42618. interpupillaryDistance: number;
  42619. /**
  42620. * Define the distortion factor of the VR postprocess.
  42621. * Please, touch with care.
  42622. */
  42623. distortionK: number[];
  42624. /**
  42625. * Define the chromatic aberration correction factors for the VR post process.
  42626. */
  42627. chromaAbCorrection: number[];
  42628. /**
  42629. * Define the scale factor of the post process.
  42630. * The smaller the better but the slower.
  42631. */
  42632. postProcessScaleFactor: number;
  42633. /**
  42634. * Define an offset for the lens center.
  42635. */
  42636. lensCenterOffset: number;
  42637. /**
  42638. * Define if the current vr camera should compensate the distortion of the lense or not.
  42639. */
  42640. compensateDistortion: boolean;
  42641. /**
  42642. * Gets the rendering aspect ratio based on the provided resolutions.
  42643. */
  42644. readonly aspectRatio: number;
  42645. /**
  42646. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42647. */
  42648. readonly aspectRatioFov: number;
  42649. /**
  42650. * @hidden
  42651. */
  42652. readonly leftHMatrix: Matrix;
  42653. /**
  42654. * @hidden
  42655. */
  42656. readonly rightHMatrix: Matrix;
  42657. /**
  42658. * @hidden
  42659. */
  42660. readonly leftPreViewMatrix: Matrix;
  42661. /**
  42662. * @hidden
  42663. */
  42664. readonly rightPreViewMatrix: Matrix;
  42665. /**
  42666. * Get the default VRMetrics based on the most generic setup.
  42667. * @returns the default vr metrics
  42668. */
  42669. static GetDefault(): VRCameraMetrics;
  42670. }
  42671. }
  42672. declare module BABYLON {
  42673. /**
  42674. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42675. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42676. */
  42677. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42678. /**
  42679. * Creates a new VRDeviceOrientationArcRotateCamera
  42680. * @param name defines camera name
  42681. * @param alpha defines the camera rotation along the logitudinal axis
  42682. * @param beta defines the camera rotation along the latitudinal axis
  42683. * @param radius defines the camera distance from its target
  42684. * @param target defines the camera target
  42685. * @param scene defines the scene the camera belongs to
  42686. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42687. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42688. */
  42689. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42690. /**
  42691. * Gets camera class name
  42692. * @returns VRDeviceOrientationArcRotateCamera
  42693. */
  42694. getClassName(): string;
  42695. }
  42696. }
  42697. declare module BABYLON {
  42698. /**
  42699. * Camera used to simulate VR rendering (based on FreeCamera)
  42700. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42701. */
  42702. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42703. /**
  42704. * Creates a new VRDeviceOrientationFreeCamera
  42705. * @param name defines camera name
  42706. * @param position defines the start position of the camera
  42707. * @param scene defines the scene the camera belongs to
  42708. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42709. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42710. */
  42711. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42712. /**
  42713. * Gets camera class name
  42714. * @returns VRDeviceOrientationFreeCamera
  42715. */
  42716. getClassName(): string;
  42717. }
  42718. }
  42719. declare module BABYLON {
  42720. /**
  42721. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42722. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42723. */
  42724. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42725. /**
  42726. * Creates a new VRDeviceOrientationGamepadCamera
  42727. * @param name defines camera name
  42728. * @param position defines the start position of the camera
  42729. * @param scene defines the scene the camera belongs to
  42730. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42731. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42732. */
  42733. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42734. /**
  42735. * Gets camera class name
  42736. * @returns VRDeviceOrientationGamepadCamera
  42737. */
  42738. getClassName(): string;
  42739. }
  42740. }
  42741. declare module BABYLON {
  42742. /**
  42743. * Options to modify the vr teleportation behavior.
  42744. */
  42745. interface VRTeleportationOptions {
  42746. /**
  42747. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42748. */
  42749. floorMeshName?: string;
  42750. /**
  42751. * A list of meshes to be used as the teleportation floor. (default: empty)
  42752. */
  42753. floorMeshes?: Mesh[];
  42754. }
  42755. /**
  42756. * Options to modify the vr experience helper's behavior.
  42757. */
  42758. interface VRExperienceHelperOptions extends WebVROptions {
  42759. /**
  42760. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42761. */
  42762. createDeviceOrientationCamera?: boolean;
  42763. /**
  42764. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42765. */
  42766. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42767. /**
  42768. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42769. */
  42770. laserToggle?: boolean;
  42771. /**
  42772. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42773. */
  42774. floorMeshes?: Mesh[];
  42775. }
  42776. /**
  42777. * Helps to quickly add VR support to an existing scene.
  42778. * See http://doc.babylonjs.com/how_to/webvr_helper
  42779. */
  42780. class VRExperienceHelper {
  42781. /** Options to modify the vr experience helper's behavior. */
  42782. webVROptions: VRExperienceHelperOptions;
  42783. private _scene;
  42784. private _position;
  42785. private _btnVR;
  42786. private _btnVRDisplayed;
  42787. private _webVRsupported;
  42788. private _webVRready;
  42789. private _webVRrequesting;
  42790. private _webVRpresenting;
  42791. private _hasEnteredVR;
  42792. private _fullscreenVRpresenting;
  42793. private _canvas;
  42794. private _webVRCamera;
  42795. private _vrDeviceOrientationCamera;
  42796. private _deviceOrientationCamera;
  42797. private _existingCamera;
  42798. private _onKeyDown;
  42799. private _onVrDisplayPresentChange;
  42800. private _onVRDisplayChanged;
  42801. private _onVRRequestPresentStart;
  42802. private _onVRRequestPresentComplete;
  42803. /**
  42804. * Observable raised when entering VR.
  42805. */
  42806. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42807. /**
  42808. * Observable raised when exiting VR.
  42809. */
  42810. onExitingVRObservable: Observable<VRExperienceHelper>;
  42811. /**
  42812. * Observable raised when controller mesh is loaded.
  42813. */
  42814. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42815. /** Return this.onEnteringVRObservable
  42816. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42817. */
  42818. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42819. /** Return this.onExitingVRObservable
  42820. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42821. */
  42822. readonly onExitingVR: Observable<VRExperienceHelper>;
  42823. /** Return this.onControllerMeshLoadedObservable
  42824. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42825. */
  42826. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42827. private _rayLength;
  42828. private _useCustomVRButton;
  42829. private _teleportationRequested;
  42830. private _teleportActive;
  42831. private _floorMeshName;
  42832. private _floorMeshesCollection;
  42833. private _rotationAllowed;
  42834. private _teleportBackwardsVector;
  42835. private _teleportationTarget;
  42836. private _isDefaultTeleportationTarget;
  42837. private _postProcessMove;
  42838. private _teleportationFillColor;
  42839. private _teleportationBorderColor;
  42840. private _rotationAngle;
  42841. private _haloCenter;
  42842. private _cameraGazer;
  42843. private _padSensibilityUp;
  42844. private _padSensibilityDown;
  42845. private _leftController;
  42846. private _rightController;
  42847. /**
  42848. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42849. */
  42850. onNewMeshSelected: Observable<AbstractMesh>;
  42851. /**
  42852. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42853. */
  42854. onNewMeshPicked: Observable<PickingInfo>;
  42855. private _circleEase;
  42856. /**
  42857. * Observable raised before camera teleportation
  42858. */
  42859. onBeforeCameraTeleport: Observable<Vector3>;
  42860. /**
  42861. * Observable raised after camera teleportation
  42862. */
  42863. onAfterCameraTeleport: Observable<Vector3>;
  42864. /**
  42865. * Observable raised when current selected mesh gets unselected
  42866. */
  42867. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42868. private _raySelectionPredicate;
  42869. /**
  42870. * To be optionaly changed by user to define custom ray selection
  42871. */
  42872. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42873. /**
  42874. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42875. */
  42876. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42877. /**
  42878. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42879. */
  42880. teleportationEnabled: boolean;
  42881. private _defaultHeight;
  42882. private _teleportationInitialized;
  42883. private _interactionsEnabled;
  42884. private _interactionsRequested;
  42885. private _displayGaze;
  42886. private _displayLaserPointer;
  42887. /**
  42888. * The mesh used to display where the user is going to teleport.
  42889. */
  42890. /**
  42891. * Sets the mesh to be used to display where the user is going to teleport.
  42892. */
  42893. teleportationTarget: Mesh;
  42894. /**
  42895. * 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
  42896. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42897. * See http://doc.babylonjs.com/resources/baking_transformations
  42898. */
  42899. gazeTrackerMesh: Mesh;
  42900. /**
  42901. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42902. */
  42903. updateGazeTrackerScale: boolean;
  42904. /**
  42905. * The gaze tracking mesh corresponding to the left controller
  42906. */
  42907. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42908. /**
  42909. * The gaze tracking mesh corresponding to the right controller
  42910. */
  42911. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42912. /**
  42913. * If the ray of the gaze should be displayed.
  42914. */
  42915. /**
  42916. * Sets if the ray of the gaze should be displayed.
  42917. */
  42918. displayGaze: boolean;
  42919. /**
  42920. * If the ray of the LaserPointer should be displayed.
  42921. */
  42922. /**
  42923. * Sets if the ray of the LaserPointer should be displayed.
  42924. */
  42925. displayLaserPointer: boolean;
  42926. /**
  42927. * The deviceOrientationCamera used as the camera when not in VR.
  42928. */
  42929. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42930. /**
  42931. * Based on the current WebVR support, returns the current VR camera used.
  42932. */
  42933. readonly currentVRCamera: Nullable<Camera>;
  42934. /**
  42935. * The webVRCamera which is used when in VR.
  42936. */
  42937. readonly webVRCamera: WebVRFreeCamera;
  42938. /**
  42939. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42940. */
  42941. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42942. private readonly _teleportationRequestInitiated;
  42943. /**
  42944. * Instantiates a VRExperienceHelper.
  42945. * Helps to quickly add VR support to an existing scene.
  42946. * @param scene The scene the VRExperienceHelper belongs to.
  42947. * @param webVROptions Options to modify the vr experience helper's behavior.
  42948. */
  42949. constructor(scene: Scene,
  42950. /** Options to modify the vr experience helper's behavior. */
  42951. webVROptions?: VRExperienceHelperOptions);
  42952. private _onDefaultMeshLoaded;
  42953. private _onResize;
  42954. private _onFullscreenChange;
  42955. /**
  42956. * Gets a value indicating if we are currently in VR mode.
  42957. */
  42958. readonly isInVRMode: boolean;
  42959. private onVrDisplayPresentChange;
  42960. private onVRDisplayChanged;
  42961. private moveButtonToBottomRight;
  42962. private displayVRButton;
  42963. private updateButtonVisibility;
  42964. private _cachedAngularSensibility;
  42965. /**
  42966. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42967. * Otherwise, will use the fullscreen API.
  42968. */
  42969. enterVR(): void;
  42970. /**
  42971. * Attempt to exit VR, or fullscreen.
  42972. */
  42973. exitVR(): void;
  42974. /**
  42975. * The position of the vr experience helper.
  42976. */
  42977. /**
  42978. * Sets the position of the vr experience helper.
  42979. */
  42980. position: Vector3;
  42981. /**
  42982. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42983. */
  42984. enableInteractions(): void;
  42985. private readonly _noControllerIsActive;
  42986. private beforeRender;
  42987. private _isTeleportationFloor;
  42988. /**
  42989. * Adds a floor mesh to be used for teleportation.
  42990. * @param floorMesh the mesh to be used for teleportation.
  42991. */
  42992. addFloorMesh(floorMesh: Mesh): void;
  42993. /**
  42994. * Removes a floor mesh from being used for teleportation.
  42995. * @param floorMesh the mesh to be removed.
  42996. */
  42997. removeFloorMesh(floorMesh: Mesh): void;
  42998. /**
  42999. * Enables interactions and teleportation using the VR controllers and gaze.
  43000. * @param vrTeleportationOptions options to modify teleportation behavior.
  43001. */
  43002. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43003. private _onNewGamepadConnected;
  43004. private _tryEnableInteractionOnController;
  43005. private _onNewGamepadDisconnected;
  43006. private _enableInteractionOnController;
  43007. private _checkTeleportWithRay;
  43008. private _checkRotate;
  43009. private _checkTeleportBackwards;
  43010. private _enableTeleportationOnController;
  43011. private _createTeleportationCircles;
  43012. private _displayTeleportationTarget;
  43013. private _hideTeleportationTarget;
  43014. private _rotateCamera;
  43015. private _moveTeleportationSelectorTo;
  43016. private _workingVector;
  43017. private _workingQuaternion;
  43018. private _workingMatrix;
  43019. /**
  43020. * Teleports the users feet to the desired location
  43021. * @param location The location where the user's feet should be placed
  43022. */
  43023. teleportCamera(location: Vector3): void;
  43024. private _convertNormalToDirectionOfRay;
  43025. private _castRayAndSelectObject;
  43026. private _notifySelectedMeshUnselected;
  43027. /**
  43028. * Sets the color of the laser ray from the vr controllers.
  43029. * @param color new color for the ray.
  43030. */
  43031. changeLaserColor(color: Color3): void;
  43032. /**
  43033. * Sets the color of the ray from the vr headsets gaze.
  43034. * @param color new color for the ray.
  43035. */
  43036. changeGazeColor(color: Color3): void;
  43037. /**
  43038. * Exits VR and disposes of the vr experience helper
  43039. */
  43040. dispose(): void;
  43041. /**
  43042. * Gets the name of the VRExperienceHelper class
  43043. * @returns "VRExperienceHelper"
  43044. */
  43045. getClassName(): string;
  43046. }
  43047. }
  43048. declare module BABYLON {
  43049. /**
  43050. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  43051. * IMPORTANT!! The data is right-hand data.
  43052. * @export
  43053. * @interface DevicePose
  43054. */
  43055. interface DevicePose {
  43056. /**
  43057. * The position of the device, values in array are [x,y,z].
  43058. */
  43059. readonly position: Nullable<Float32Array>;
  43060. /**
  43061. * The linearVelocity of the device, values in array are [x,y,z].
  43062. */
  43063. readonly linearVelocity: Nullable<Float32Array>;
  43064. /**
  43065. * The linearAcceleration of the device, values in array are [x,y,z].
  43066. */
  43067. readonly linearAcceleration: Nullable<Float32Array>;
  43068. /**
  43069. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  43070. */
  43071. readonly orientation: Nullable<Float32Array>;
  43072. /**
  43073. * The angularVelocity of the device, values in array are [x,y,z].
  43074. */
  43075. readonly angularVelocity: Nullable<Float32Array>;
  43076. /**
  43077. * The angularAcceleration of the device, values in array are [x,y,z].
  43078. */
  43079. readonly angularAcceleration: Nullable<Float32Array>;
  43080. }
  43081. /**
  43082. * Interface representing a pose controlled object in Babylon.
  43083. * A pose controlled object has both regular pose values as well as pose values
  43084. * from an external device such as a VR head mounted display
  43085. */
  43086. interface PoseControlled {
  43087. /**
  43088. * The position of the object in babylon space.
  43089. */
  43090. position: Vector3;
  43091. /**
  43092. * The rotation quaternion of the object in babylon space.
  43093. */
  43094. rotationQuaternion: Quaternion;
  43095. /**
  43096. * The position of the device in babylon space.
  43097. */
  43098. devicePosition?: Vector3;
  43099. /**
  43100. * The rotation quaternion of the device in babylon space.
  43101. */
  43102. deviceRotationQuaternion: Quaternion;
  43103. /**
  43104. * The raw pose coming from the device.
  43105. */
  43106. rawPose: Nullable<DevicePose>;
  43107. /**
  43108. * The scale of the device to be used when translating from device space to babylon space.
  43109. */
  43110. deviceScaleFactor: number;
  43111. /**
  43112. * Updates the poseControlled values based on the input device pose.
  43113. * @param poseData the pose data to update the object with
  43114. */
  43115. updateFromDevice(poseData: DevicePose): void;
  43116. }
  43117. /**
  43118. * Set of options to customize the webVRCamera
  43119. */
  43120. interface WebVROptions {
  43121. /**
  43122. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  43123. */
  43124. trackPosition?: boolean;
  43125. /**
  43126. * Sets the scale of the vrDevice in babylon space. (default: 1)
  43127. */
  43128. positionScale?: number;
  43129. /**
  43130. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43131. */
  43132. displayName?: string;
  43133. /**
  43134. * Should the native controller meshes be initialized. (default: true)
  43135. */
  43136. controllerMeshes?: boolean;
  43137. /**
  43138. * Creating a default HemiLight only on controllers. (default: true)
  43139. */
  43140. defaultLightingOnControllers?: boolean;
  43141. /**
  43142. * If you don't want to use the default VR button of the helper. (default: false)
  43143. */
  43144. useCustomVRButton?: boolean;
  43145. /**
  43146. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43147. */
  43148. customVRButton?: HTMLButtonElement;
  43149. /**
  43150. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43151. */
  43152. rayLength?: number;
  43153. /**
  43154. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43155. */
  43156. defaultHeight?: number;
  43157. }
  43158. /**
  43159. * This represents a WebVR camera.
  43160. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43161. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43162. */
  43163. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43164. private webVROptions;
  43165. /**
  43166. * @hidden
  43167. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43168. */
  43169. _vrDevice: any;
  43170. /**
  43171. * The rawPose of the vrDevice.
  43172. */
  43173. rawPose: Nullable<DevicePose>;
  43174. private _onVREnabled;
  43175. private _specsVersion;
  43176. private _attached;
  43177. private _frameData;
  43178. protected _descendants: Array<Node>;
  43179. private _deviceRoomPosition;
  43180. /** @hidden */
  43181. _deviceRoomRotationQuaternion: Quaternion;
  43182. private _standingMatrix;
  43183. /**
  43184. * Represents device position in babylon space.
  43185. */
  43186. devicePosition: Vector3;
  43187. /**
  43188. * Represents device rotation in babylon space.
  43189. */
  43190. deviceRotationQuaternion: Quaternion;
  43191. /**
  43192. * The scale of the device to be used when translating from device space to babylon space.
  43193. */
  43194. deviceScaleFactor: number;
  43195. private _deviceToWorld;
  43196. private _worldToDevice;
  43197. /**
  43198. * References to the webVR controllers for the vrDevice.
  43199. */
  43200. controllers: Array<WebVRController>;
  43201. /**
  43202. * Emits an event when a controller is attached.
  43203. */
  43204. onControllersAttachedObservable: Observable<WebVRController[]>;
  43205. /**
  43206. * Emits an event when a controller's mesh has been loaded;
  43207. */
  43208. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43209. /**
  43210. * Emits an event when the HMD's pose has been updated.
  43211. */
  43212. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43213. private _poseSet;
  43214. /**
  43215. * If the rig cameras be used as parent instead of this camera.
  43216. */
  43217. rigParenting: boolean;
  43218. private _lightOnControllers;
  43219. private _defaultHeight?;
  43220. /**
  43221. * Instantiates a WebVRFreeCamera.
  43222. * @param name The name of the WebVRFreeCamera
  43223. * @param position The starting anchor position for the camera
  43224. * @param scene The scene the camera belongs to
  43225. * @param webVROptions a set of customizable options for the webVRCamera
  43226. */
  43227. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43228. /**
  43229. * Gets the device distance from the ground in meters.
  43230. * @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.
  43231. */
  43232. deviceDistanceToRoomGround(): number;
  43233. /**
  43234. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43235. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43236. */
  43237. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43238. /**
  43239. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43240. * @returns A promise with a boolean set to if the standing matrix is supported.
  43241. */
  43242. useStandingMatrixAsync(): Promise<boolean>;
  43243. /**
  43244. * Disposes the camera
  43245. */
  43246. dispose(): void;
  43247. /**
  43248. * Gets a vrController by name.
  43249. * @param name The name of the controller to retreive
  43250. * @returns the controller matching the name specified or null if not found
  43251. */
  43252. getControllerByName(name: string): Nullable<WebVRController>;
  43253. private _leftController;
  43254. /**
  43255. * The controller corrisponding to the users left hand.
  43256. */
  43257. readonly leftController: Nullable<WebVRController>;
  43258. private _rightController;
  43259. /**
  43260. * The controller corrisponding to the users right hand.
  43261. */
  43262. readonly rightController: Nullable<WebVRController>;
  43263. /**
  43264. * Casts a ray forward from the vrCamera's gaze.
  43265. * @param length Length of the ray (default: 100)
  43266. * @returns the ray corrisponding to the gaze
  43267. */
  43268. getForwardRay(length?: number): Ray;
  43269. /**
  43270. * @hidden
  43271. * Updates the camera based on device's frame data
  43272. */
  43273. _checkInputs(): void;
  43274. /**
  43275. * Updates the poseControlled values based on the input device pose.
  43276. * @param poseData Pose coming from the device
  43277. */
  43278. updateFromDevice(poseData: DevicePose): void;
  43279. private _htmlElementAttached;
  43280. private _detachIfAttached;
  43281. /**
  43282. * WebVR's attach control will start broadcasting frames to the device.
  43283. * Note that in certain browsers (chrome for example) this function must be called
  43284. * within a user-interaction callback. Example:
  43285. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43286. *
  43287. * @param element html element to attach the vrDevice to
  43288. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43289. */
  43290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43291. /**
  43292. * Detaches the camera from the html element and disables VR
  43293. *
  43294. * @param element html element to detach from
  43295. */
  43296. detachControl(element: HTMLElement): void;
  43297. /**
  43298. * @returns the name of this class
  43299. */
  43300. getClassName(): string;
  43301. /**
  43302. * Calls resetPose on the vrDisplay
  43303. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43304. */
  43305. resetToCurrentRotation(): void;
  43306. /**
  43307. * @hidden
  43308. * Updates the rig cameras (left and right eye)
  43309. */
  43310. _updateRigCameras(): void;
  43311. private _workingVector;
  43312. private _oneVector;
  43313. private _workingMatrix;
  43314. private updateCacheCalled;
  43315. private _correctPositionIfNotTrackPosition;
  43316. /**
  43317. * @hidden
  43318. * Updates the cached values of the camera
  43319. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43320. */
  43321. _updateCache(ignoreParentClass?: boolean): void;
  43322. /**
  43323. * @hidden
  43324. * Get current device position in babylon world
  43325. */
  43326. _computeDevicePosition(): void;
  43327. /**
  43328. * Updates the current device position and rotation in the babylon world
  43329. */
  43330. update(): void;
  43331. /**
  43332. * @hidden
  43333. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43334. * @returns an identity matrix
  43335. */
  43336. _getViewMatrix(): Matrix;
  43337. private _tmpMatrix;
  43338. /**
  43339. * This function is called by the two RIG cameras.
  43340. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43341. */
  43342. protected _getWebVRViewMatrix(): Matrix;
  43343. protected _getWebVRProjectionMatrix(): Matrix;
  43344. private _onGamepadConnectedObserver;
  43345. private _onGamepadDisconnectedObserver;
  43346. private _updateCacheWhenTrackingDisabledObserver;
  43347. /**
  43348. * Initializes the controllers and their meshes
  43349. */
  43350. initControllers(): void;
  43351. }
  43352. }
  43353. declare module BABYLON {
  43354. /**
  43355. * WebXR Camera which holds the views for the xrSession
  43356. * @see https://doc.babylonjs.com/how_to/webxr
  43357. */
  43358. class WebXRCamera extends FreeCamera {
  43359. private static _TmpMatrix;
  43360. /**
  43361. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43362. * @param name the name of the camera
  43363. * @param scene the scene to add the camera to
  43364. */
  43365. constructor(name: string, scene: BABYLON.Scene);
  43366. private _updateNumberOfRigCameras;
  43367. /** @hidden */
  43368. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43369. /**
  43370. * Updates the cameras position from the current pose information of the XR session
  43371. * @param xrSessionManager the session containing pose information
  43372. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43373. */
  43374. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43375. }
  43376. }
  43377. declare module BABYLON {
  43378. /**
  43379. * Button which can be used to enter a different mode of XR
  43380. */
  43381. class WebXREnterExitUIButton {
  43382. /** button element */
  43383. element: HTMLElement;
  43384. /** XR initialization options for the button */
  43385. initializationOptions: XRSessionCreationOptions;
  43386. /**
  43387. * Creates a WebXREnterExitUIButton
  43388. * @param element button element
  43389. * @param initializationOptions XR initialization options for the button
  43390. */
  43391. constructor(
  43392. /** button element */
  43393. element: HTMLElement,
  43394. /** XR initialization options for the button */
  43395. initializationOptions: XRSessionCreationOptions);
  43396. /**
  43397. * Overwritable function which can be used to update the button's visuals when the state changes
  43398. * @param activeButton the current active button in the UI
  43399. */
  43400. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43401. }
  43402. /**
  43403. * Options to create the webXR UI
  43404. */
  43405. class WebXREnterExitUIOptions {
  43406. /**
  43407. * Context to enter xr with
  43408. */
  43409. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43410. /**
  43411. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43412. */
  43413. customButtons?: Array<WebXREnterExitUIButton>;
  43414. }
  43415. /**
  43416. * UI to allow the user to enter/exit XR mode
  43417. */
  43418. class WebXREnterExitUI implements IDisposable {
  43419. private scene;
  43420. private _overlay;
  43421. private _buttons;
  43422. private _activeButton;
  43423. /**
  43424. * Fired every time the active button is changed.
  43425. *
  43426. * When xr is entered via a button that launches xr that button will be the callback parameter
  43427. *
  43428. * When exiting xr the callback parameter will be null)
  43429. */
  43430. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43431. /**
  43432. * Creates UI to allow the user to enter/exit XR mode
  43433. * @param scene the scene to add the ui to
  43434. * @param helper the xr experience helper to enter/exit xr with
  43435. * @param options options to configure the UI
  43436. * @returns the created ui
  43437. */
  43438. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43439. private constructor();
  43440. private _updateButtons;
  43441. /**
  43442. * Disposes of the object
  43443. */
  43444. dispose(): void;
  43445. }
  43446. }
  43447. declare module BABYLON {
  43448. /**
  43449. * States of the webXR experience
  43450. */
  43451. enum WebXRState {
  43452. /**
  43453. * Transitioning to being in XR mode
  43454. */
  43455. ENTERING_XR = 0,
  43456. /**
  43457. * Transitioning to non XR mode
  43458. */
  43459. EXITING_XR = 1,
  43460. /**
  43461. * In XR mode and presenting
  43462. */
  43463. IN_XR = 2,
  43464. /**
  43465. * Not entered XR mode
  43466. */
  43467. NOT_IN_XR = 3
  43468. }
  43469. /**
  43470. * Helper class used to enable XR
  43471. * @see https://doc.babylonjs.com/how_to/webxr
  43472. */
  43473. class WebXRExperienceHelper implements IDisposable {
  43474. private scene;
  43475. /**
  43476. * 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
  43477. */
  43478. container: AbstractMesh;
  43479. /**
  43480. * Camera used to render xr content
  43481. */
  43482. camera: WebXRCamera;
  43483. /**
  43484. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43485. */
  43486. state: WebXRState;
  43487. private _setState;
  43488. private static _TmpVector;
  43489. /**
  43490. * Fires when the state of the experience helper has changed
  43491. */
  43492. onStateChangedObservable: Observable<WebXRState>;
  43493. /** @hidden */
  43494. _sessionManager: WebXRSessionManager;
  43495. private _nonVRCamera;
  43496. private _originalSceneAutoClear;
  43497. private _supported;
  43498. /**
  43499. * Creates the experience helper
  43500. * @param scene the scene to attach the experience helper to
  43501. * @returns a promise for the experience helper
  43502. */
  43503. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43504. /**
  43505. * Creates a WebXRExperienceHelper
  43506. * @param scene The scene the helper should be created in
  43507. */
  43508. private constructor();
  43509. /**
  43510. * Exits XR mode and returns the scene to its original state
  43511. * @returns promise that resolves after xr mode has exited
  43512. */
  43513. exitXRAsync(): Promise<void>;
  43514. /**
  43515. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43516. * @param sessionCreationOptions options for the XR session
  43517. * @param frameOfReference frame of reference of the XR session
  43518. * @returns promise that resolves after xr mode has entered
  43519. */
  43520. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43521. /**
  43522. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43523. * @param ray ray to cast into the environment
  43524. * @returns Promise which resolves with a collision point in the environment if it exists
  43525. */
  43526. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43527. /**
  43528. * Updates the global position of the camera by moving the camera's container
  43529. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43530. * @param position The desired global position of the camera
  43531. */
  43532. setPositionOfCameraUsingContainer(position: Vector3): void;
  43533. /**
  43534. * Rotates the xr camera by rotating the camera's container around the camera's position
  43535. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43536. * @param rotation the desired quaternion rotation to apply to the camera
  43537. */
  43538. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43539. /**
  43540. * Checks if the creation options are supported by the xr session
  43541. * @param options creation options
  43542. * @returns true if supported
  43543. */
  43544. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43545. /**
  43546. * Disposes of the experience helper
  43547. */
  43548. dispose(): void;
  43549. }
  43550. }
  43551. declare module BABYLON {
  43552. /**
  43553. * Represents an XR input
  43554. */
  43555. class WebXRController {
  43556. /**
  43557. * 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
  43558. */
  43559. grip?: BABYLON.AbstractMesh;
  43560. /**
  43561. * Pointer which can be used to select objects or attach a visible laser to
  43562. */
  43563. pointer: BABYLON.AbstractMesh;
  43564. /**
  43565. * Creates the controller
  43566. * @see https://doc.babylonjs.com/how_to/webxr
  43567. * @param scene the scene which the controller should be associated to
  43568. */
  43569. constructor(scene: BABYLON.Scene);
  43570. /**
  43571. * Disposes of the object
  43572. */
  43573. dispose(): void;
  43574. }
  43575. /**
  43576. * XR input used to track XR inputs such as controllers/rays
  43577. */
  43578. class WebXRInput implements IDisposable {
  43579. private helper;
  43580. /**
  43581. * XR controllers being tracked
  43582. */
  43583. controllers: Array<WebXRController>;
  43584. private _tmpMatrix;
  43585. private _frameObserver;
  43586. /**
  43587. * Initializes the WebXRInput
  43588. * @param helper experience helper which the input should be created for
  43589. */
  43590. constructor(helper: WebXRExperienceHelper);
  43591. /**
  43592. * Disposes of the object
  43593. */
  43594. dispose(): void;
  43595. }
  43596. }
  43597. declare module BABYLON {
  43598. /**
  43599. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43600. */
  43601. class WebXRManagedOutputCanvas implements IDisposable {
  43602. private _canvas;
  43603. /**
  43604. * xrpresent context of the canvas which can be used to display/mirror xr content
  43605. */
  43606. canvasContext: Nullable<WebGLRenderingContext>;
  43607. /**
  43608. * Initializes the canvas to be added/removed upon entering/exiting xr
  43609. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43610. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43611. */
  43612. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43613. /**
  43614. * Disposes of the object
  43615. */
  43616. dispose(): void;
  43617. private _setManagedOutputCanvas;
  43618. private _addCanvas;
  43619. private _removeCanvas;
  43620. }
  43621. }
  43622. declare module BABYLON {
  43623. /**
  43624. * Manages an XRSession
  43625. * @see https://doc.babylonjs.com/how_to/webxr
  43626. */
  43627. class WebXRSessionManager implements IDisposable {
  43628. private scene;
  43629. /**
  43630. * Fires every time a new xrFrame arrives which can be used to update the camera
  43631. */
  43632. onXRFrameObservable: Observable<any>;
  43633. /**
  43634. * Fires when the xr session is ended either by the device or manually done
  43635. */
  43636. onXRSessionEnded: Observable<any>;
  43637. /** @hidden */
  43638. _xrSession: XRSession;
  43639. /** @hidden */
  43640. _frameOfReference: XRFrameOfReference;
  43641. /** @hidden */
  43642. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43643. /** @hidden */
  43644. _currentXRFrame: Nullable<XRFrame>;
  43645. private _xrNavigator;
  43646. private _xrDevice;
  43647. private _tmpMatrix;
  43648. /**
  43649. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43650. * @param scene The scene which the session should be created for
  43651. */
  43652. constructor(scene: BABYLON.Scene);
  43653. /**
  43654. * Initializes the manager
  43655. * After initialization enterXR can be called to start an XR session
  43656. * @returns Promise which resolves after it is initialized
  43657. */
  43658. initializeAsync(): Promise<void>;
  43659. /**
  43660. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43661. * @param sessionCreationOptions xr options to create the session with
  43662. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43663. * @returns Promise which resolves after it enters XR
  43664. */
  43665. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43666. /**
  43667. * Stops the xrSession and restores the renderloop
  43668. * @returns Promise which resolves after it exits XR
  43669. */
  43670. exitXRAsync(): Promise<void>;
  43671. /**
  43672. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43673. * @param ray ray to cast into the environment
  43674. * @returns Promise which resolves with a collision point in the environment if it exists
  43675. */
  43676. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43677. /**
  43678. * Checks if a session would be supported for the creation options specified
  43679. * @param options creation options to check if they are supported
  43680. * @returns true if supported
  43681. */
  43682. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43683. /**
  43684. * @hidden
  43685. * Converts the render layer of xrSession to a render target
  43686. * @param session session to create render target for
  43687. * @param scene scene the new render target should be created for
  43688. */
  43689. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43690. /**
  43691. * Disposes of the session manager
  43692. */
  43693. dispose(): void;
  43694. }
  43695. }
  43696. declare module BABYLON {
  43697. /** @hidden */
  43698. class _OcclusionDataStorage {
  43699. /** @hidden */
  43700. occlusionInternalRetryCounter: number;
  43701. /** @hidden */
  43702. isOcclusionQueryInProgress: boolean;
  43703. /** @hidden */
  43704. isOccluded: boolean;
  43705. /** @hidden */
  43706. occlusionRetryCount: number;
  43707. /** @hidden */
  43708. occlusionType: number;
  43709. /** @hidden */
  43710. occlusionQueryAlgorithmType: number;
  43711. }
  43712. interface Engine {
  43713. /**
  43714. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43715. * @return the new query
  43716. */
  43717. createQuery(): WebGLQuery;
  43718. /**
  43719. * Delete and release a webGL query
  43720. * @param query defines the query to delete
  43721. * @return the current engine
  43722. */
  43723. deleteQuery(query: WebGLQuery): Engine;
  43724. /**
  43725. * Check if a given query has resolved and got its value
  43726. * @param query defines the query to check
  43727. * @returns true if the query got its value
  43728. */
  43729. isQueryResultAvailable(query: WebGLQuery): boolean;
  43730. /**
  43731. * Gets the value of a given query
  43732. * @param query defines the query to check
  43733. * @returns the value of the query
  43734. */
  43735. getQueryResult(query: WebGLQuery): number;
  43736. /**
  43737. * Initiates an occlusion query
  43738. * @param algorithmType defines the algorithm to use
  43739. * @param query defines the query to use
  43740. * @returns the current engine
  43741. * @see http://doc.babylonjs.com/features/occlusionquery
  43742. */
  43743. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43744. /**
  43745. * Ends an occlusion query
  43746. * @see http://doc.babylonjs.com/features/occlusionquery
  43747. * @param algorithmType defines the algorithm to use
  43748. * @returns the current engine
  43749. */
  43750. endOcclusionQuery(algorithmType: number): Engine;
  43751. /**
  43752. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43753. * Please note that only one query can be issued at a time
  43754. * @returns a time token used to track the time span
  43755. */
  43756. startTimeQuery(): Nullable<_TimeToken>;
  43757. /**
  43758. * Ends a time query
  43759. * @param token defines the token used to measure the time span
  43760. * @returns the time spent (in ns)
  43761. */
  43762. endTimeQuery(token: _TimeToken): int;
  43763. /** @hidden */
  43764. _currentNonTimestampToken: Nullable<_TimeToken>;
  43765. /** @hidden */
  43766. _createTimeQuery(): WebGLQuery;
  43767. /** @hidden */
  43768. _deleteTimeQuery(query: WebGLQuery): void;
  43769. /** @hidden */
  43770. _getGlAlgorithmType(algorithmType: number): number;
  43771. /** @hidden */
  43772. _getTimeQueryResult(query: WebGLQuery): any;
  43773. /** @hidden */
  43774. _getTimeQueryAvailability(query: WebGLQuery): any;
  43775. }
  43776. interface AbstractMesh {
  43777. /**
  43778. * Backing filed
  43779. * @hidden
  43780. */
  43781. __occlusionDataStorage: _OcclusionDataStorage;
  43782. /**
  43783. * Access property
  43784. * @hidden
  43785. */
  43786. _occlusionDataStorage: _OcclusionDataStorage;
  43787. /**
  43788. * 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.
  43789. * The default value is -1 which means don't break the query and wait till the result
  43790. * @see http://doc.babylonjs.com/features/occlusionquery
  43791. */
  43792. occlusionRetryCount: number;
  43793. /**
  43794. * 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:
  43795. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43796. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43797. * * 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.
  43798. * @see http://doc.babylonjs.com/features/occlusionquery
  43799. */
  43800. occlusionType: number;
  43801. /**
  43802. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43803. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43804. * * 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.
  43805. * @see http://doc.babylonjs.com/features/occlusionquery
  43806. */
  43807. occlusionQueryAlgorithmType: number;
  43808. /**
  43809. * 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
  43810. * @see http://doc.babylonjs.com/features/occlusionquery
  43811. */
  43812. isOccluded: boolean;
  43813. /**
  43814. * Flag to check the progress status of the query
  43815. * @see http://doc.babylonjs.com/features/occlusionquery
  43816. */
  43817. isOcclusionQueryInProgress: boolean;
  43818. }
  43819. }
  43820. declare module BABYLON {
  43821. interface Engine {
  43822. /**
  43823. * Creates a webGL transform feedback object
  43824. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43825. * @returns the webGL transform feedback object
  43826. */
  43827. createTransformFeedback(): WebGLTransformFeedback;
  43828. /**
  43829. * Delete a webGL transform feedback object
  43830. * @param value defines the webGL transform feedback object to delete
  43831. */
  43832. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43833. /**
  43834. * Bind a webGL transform feedback object to the webgl context
  43835. * @param value defines the webGL transform feedback object to bind
  43836. */
  43837. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43838. /**
  43839. * Begins a transform feedback operation
  43840. * @param usePoints defines if points or triangles must be used
  43841. */
  43842. beginTransformFeedback(usePoints: boolean): void;
  43843. /**
  43844. * Ends a transform feedback operation
  43845. */
  43846. endTransformFeedback(): void;
  43847. /**
  43848. * Specify the varyings to use with transform feedback
  43849. * @param program defines the associated webGL program
  43850. * @param value defines the list of strings representing the varying names
  43851. */
  43852. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43853. /**
  43854. * Bind a webGL buffer for a transform feedback operation
  43855. * @param value defines the webGL buffer to bind
  43856. */
  43857. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43858. }
  43859. }
  43860. declare module BABYLON {
  43861. /**
  43862. * Google Daydream controller
  43863. */
  43864. class DaydreamController extends WebVRController {
  43865. /**
  43866. * Base Url for the controller model.
  43867. */
  43868. static MODEL_BASE_URL: string;
  43869. /**
  43870. * File name for the controller model.
  43871. */
  43872. static MODEL_FILENAME: string;
  43873. /**
  43874. * Gamepad Id prefix used to identify Daydream Controller.
  43875. */
  43876. static readonly GAMEPAD_ID_PREFIX: string;
  43877. /**
  43878. * Creates a new DaydreamController from a gamepad
  43879. * @param vrGamepad the gamepad that the controller should be created from
  43880. */
  43881. constructor(vrGamepad: any);
  43882. /**
  43883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43884. * @param scene scene in which to add meshes
  43885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43886. */
  43887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43888. /**
  43889. * Called once for each button that changed state since the last frame
  43890. * @param buttonIdx Which button index changed
  43891. * @param state New state of the button
  43892. * @param changes Which properties on the state changed since last frame
  43893. */
  43894. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43895. }
  43896. }
  43897. declare module BABYLON {
  43898. /**
  43899. * Gear VR Controller
  43900. */
  43901. class GearVRController extends WebVRController {
  43902. /**
  43903. * Base Url for the controller model.
  43904. */
  43905. static MODEL_BASE_URL: string;
  43906. /**
  43907. * File name for the controller model.
  43908. */
  43909. static MODEL_FILENAME: string;
  43910. /**
  43911. * Gamepad Id prefix used to identify this controller.
  43912. */
  43913. static readonly GAMEPAD_ID_PREFIX: string;
  43914. private readonly _buttonIndexToObservableNameMap;
  43915. /**
  43916. * Creates a new GearVRController from a gamepad
  43917. * @param vrGamepad the gamepad that the controller should be created from
  43918. */
  43919. constructor(vrGamepad: any);
  43920. /**
  43921. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43922. * @param scene scene in which to add meshes
  43923. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43924. */
  43925. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43926. /**
  43927. * Called once for each button that changed state since the last frame
  43928. * @param buttonIdx Which button index changed
  43929. * @param state New state of the button
  43930. * @param changes Which properties on the state changed since last frame
  43931. */
  43932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43933. }
  43934. }
  43935. declare module BABYLON {
  43936. /**
  43937. * Generic Controller
  43938. */
  43939. class GenericController extends WebVRController {
  43940. /**
  43941. * Base Url for the controller model.
  43942. */
  43943. static readonly MODEL_BASE_URL: string;
  43944. /**
  43945. * File name for the controller model.
  43946. */
  43947. static readonly MODEL_FILENAME: string;
  43948. /**
  43949. * Creates a new GenericController from a gamepad
  43950. * @param vrGamepad the gamepad that the controller should be created from
  43951. */
  43952. constructor(vrGamepad: any);
  43953. /**
  43954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43955. * @param scene scene in which to add meshes
  43956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43957. */
  43958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43959. /**
  43960. * Called once for each button that changed state since the last frame
  43961. * @param buttonIdx Which button index changed
  43962. * @param state New state of the button
  43963. * @param changes Which properties on the state changed since last frame
  43964. */
  43965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43966. }
  43967. }
  43968. declare module BABYLON {
  43969. /**
  43970. * Oculus Touch Controller
  43971. */
  43972. class OculusTouchController extends WebVRController {
  43973. /**
  43974. * Base Url for the controller model.
  43975. */
  43976. static MODEL_BASE_URL: string;
  43977. /**
  43978. * File name for the left controller model.
  43979. */
  43980. static MODEL_LEFT_FILENAME: string;
  43981. /**
  43982. * File name for the right controller model.
  43983. */
  43984. static MODEL_RIGHT_FILENAME: string;
  43985. /**
  43986. * Fired when the secondary trigger on this controller is modified
  43987. */
  43988. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43989. /**
  43990. * Fired when the thumb rest on this controller is modified
  43991. */
  43992. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43993. /**
  43994. * Creates a new OculusTouchController from a gamepad
  43995. * @param vrGamepad the gamepad that the controller should be created from
  43996. */
  43997. constructor(vrGamepad: any);
  43998. /**
  43999. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44000. * @param scene scene in which to add meshes
  44001. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44002. */
  44003. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44004. /**
  44005. * Fired when the A button on this controller is modified
  44006. */
  44007. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44008. /**
  44009. * Fired when the B button on this controller is modified
  44010. */
  44011. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44012. /**
  44013. * Fired when the X button on this controller is modified
  44014. */
  44015. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44016. /**
  44017. * Fired when the Y button on this controller is modified
  44018. */
  44019. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44020. /**
  44021. * Called once for each button that changed state since the last frame
  44022. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44023. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44024. * 2) secondary trigger (same)
  44025. * 3) A (right) X (left), touch, pressed = value
  44026. * 4) B / Y
  44027. * 5) thumb rest
  44028. * @param buttonIdx Which button index changed
  44029. * @param state New state of the button
  44030. * @param changes Which properties on the state changed since last frame
  44031. */
  44032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44033. }
  44034. }
  44035. declare module BABYLON {
  44036. /**
  44037. * Defines the types of pose enabled controllers that are supported
  44038. */
  44039. enum PoseEnabledControllerType {
  44040. /**
  44041. * HTC Vive
  44042. */
  44043. VIVE = 0,
  44044. /**
  44045. * Oculus Rift
  44046. */
  44047. OCULUS = 1,
  44048. /**
  44049. * Windows mixed reality
  44050. */
  44051. WINDOWS = 2,
  44052. /**
  44053. * Samsung gear VR
  44054. */
  44055. GEAR_VR = 3,
  44056. /**
  44057. * Google Daydream
  44058. */
  44059. DAYDREAM = 4,
  44060. /**
  44061. * Generic
  44062. */
  44063. GENERIC = 5
  44064. }
  44065. /**
  44066. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44067. */
  44068. interface MutableGamepadButton {
  44069. /**
  44070. * Value of the button/trigger
  44071. */
  44072. value: number;
  44073. /**
  44074. * If the button/trigger is currently touched
  44075. */
  44076. touched: boolean;
  44077. /**
  44078. * If the button/trigger is currently pressed
  44079. */
  44080. pressed: boolean;
  44081. }
  44082. /**
  44083. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44084. * @hidden
  44085. */
  44086. interface ExtendedGamepadButton extends GamepadButton {
  44087. /**
  44088. * If the button/trigger is currently pressed
  44089. */
  44090. readonly pressed: boolean;
  44091. /**
  44092. * If the button/trigger is currently touched
  44093. */
  44094. readonly touched: boolean;
  44095. /**
  44096. * Value of the button/trigger
  44097. */
  44098. readonly value: number;
  44099. }
  44100. /**
  44101. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44102. */
  44103. class PoseEnabledControllerHelper {
  44104. /**
  44105. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44106. * @param vrGamepad the gamepad to initialized
  44107. * @returns a vr controller of the type the gamepad identified as
  44108. */
  44109. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44110. }
  44111. /**
  44112. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44113. */
  44114. class PoseEnabledController extends Gamepad implements PoseControlled {
  44115. private _deviceRoomPosition;
  44116. private _deviceRoomRotationQuaternion;
  44117. /**
  44118. * The device position in babylon space
  44119. */
  44120. devicePosition: Vector3;
  44121. /**
  44122. * The device rotation in babylon space
  44123. */
  44124. deviceRotationQuaternion: Quaternion;
  44125. /**
  44126. * The scale factor of the device in babylon space
  44127. */
  44128. deviceScaleFactor: number;
  44129. /**
  44130. * (Likely devicePosition should be used instead) The device position in its room space
  44131. */
  44132. position: Vector3;
  44133. /**
  44134. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44135. */
  44136. rotationQuaternion: Quaternion;
  44137. /**
  44138. * The type of controller (Eg. Windows mixed reality)
  44139. */
  44140. controllerType: PoseEnabledControllerType;
  44141. protected _calculatedPosition: Vector3;
  44142. private _calculatedRotation;
  44143. /**
  44144. * The raw pose from the device
  44145. */
  44146. rawPose: DevicePose;
  44147. private _trackPosition;
  44148. private _maxRotationDistFromHeadset;
  44149. private _draggedRoomRotation;
  44150. /**
  44151. * @hidden
  44152. */
  44153. _disableTrackPosition(fixedPosition: Vector3): void;
  44154. /**
  44155. * Internal, the mesh attached to the controller
  44156. * @hidden
  44157. */
  44158. _mesh: Nullable<AbstractMesh>;
  44159. private _poseControlledCamera;
  44160. private _leftHandSystemQuaternion;
  44161. /**
  44162. * Internal, matrix used to convert room space to babylon space
  44163. * @hidden
  44164. */
  44165. _deviceToWorld: Matrix;
  44166. /**
  44167. * Node to be used when casting a ray from the controller
  44168. * @hidden
  44169. */
  44170. _pointingPoseNode: Nullable<TransformNode>;
  44171. /**
  44172. * Name of the child mesh that can be used to cast a ray from the controller
  44173. */
  44174. static readonly POINTING_POSE: string;
  44175. /**
  44176. * Creates a new PoseEnabledController from a gamepad
  44177. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44178. */
  44179. constructor(browserGamepad: any);
  44180. private _workingMatrix;
  44181. /**
  44182. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44183. */
  44184. update(): void;
  44185. /**
  44186. * Updates only the pose device and mesh without doing any button event checking
  44187. */
  44188. protected _updatePoseAndMesh(): void;
  44189. /**
  44190. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44191. * @param poseData raw pose fromthe device
  44192. */
  44193. updateFromDevice(poseData: DevicePose): void;
  44194. /**
  44195. * @hidden
  44196. */
  44197. _meshAttachedObservable: Observable<AbstractMesh>;
  44198. /**
  44199. * Attaches a mesh to the controller
  44200. * @param mesh the mesh to be attached
  44201. */
  44202. attachToMesh(mesh: AbstractMesh): void;
  44203. /**
  44204. * Attaches the controllers mesh to a camera
  44205. * @param camera the camera the mesh should be attached to
  44206. */
  44207. attachToPoseControlledCamera(camera: TargetCamera): void;
  44208. /**
  44209. * Disposes of the controller
  44210. */
  44211. dispose(): void;
  44212. /**
  44213. * The mesh that is attached to the controller
  44214. */
  44215. readonly mesh: Nullable<AbstractMesh>;
  44216. /**
  44217. * Gets the ray of the controller in the direction the controller is pointing
  44218. * @param length the length the resulting ray should be
  44219. * @returns a ray in the direction the controller is pointing
  44220. */
  44221. getForwardRay(length?: number): Ray;
  44222. }
  44223. }
  44224. declare module BABYLON {
  44225. /**
  44226. * Vive Controller
  44227. */
  44228. class ViveController extends WebVRController {
  44229. /**
  44230. * Base Url for the controller model.
  44231. */
  44232. static MODEL_BASE_URL: string;
  44233. /**
  44234. * File name for the controller model.
  44235. */
  44236. static MODEL_FILENAME: string;
  44237. /**
  44238. * Creates a new ViveController from a gamepad
  44239. * @param vrGamepad the gamepad that the controller should be created from
  44240. */
  44241. constructor(vrGamepad: any);
  44242. /**
  44243. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44244. * @param scene scene in which to add meshes
  44245. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44246. */
  44247. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44248. /**
  44249. * Fired when the left button on this controller is modified
  44250. */
  44251. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44252. /**
  44253. * Fired when the right button on this controller is modified
  44254. */
  44255. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44256. /**
  44257. * Fired when the menu button on this controller is modified
  44258. */
  44259. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44260. /**
  44261. * Called once for each button that changed state since the last frame
  44262. * Vive mapping:
  44263. * 0: touchpad
  44264. * 1: trigger
  44265. * 2: left AND right buttons
  44266. * 3: menu button
  44267. * @param buttonIdx Which button index changed
  44268. * @param state New state of the button
  44269. * @param changes Which properties on the state changed since last frame
  44270. */
  44271. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44272. }
  44273. }
  44274. declare module BABYLON {
  44275. /**
  44276. * Defines the WebVRController object that represents controllers tracked in 3D space
  44277. */
  44278. abstract class WebVRController extends PoseEnabledController {
  44279. /**
  44280. * Internal, the default controller model for the controller
  44281. */
  44282. protected _defaultModel: AbstractMesh;
  44283. /**
  44284. * Fired when the trigger state has changed
  44285. */
  44286. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44287. /**
  44288. * Fired when the main button state has changed
  44289. */
  44290. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44291. /**
  44292. * Fired when the secondary button state has changed
  44293. */
  44294. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44295. /**
  44296. * Fired when the pad state has changed
  44297. */
  44298. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44299. /**
  44300. * Fired when controllers stick values have changed
  44301. */
  44302. onPadValuesChangedObservable: Observable<StickValues>;
  44303. /**
  44304. * Array of button availible on the controller
  44305. */
  44306. protected _buttons: Array<MutableGamepadButton>;
  44307. private _onButtonStateChange;
  44308. /**
  44309. * Fired when a controller button's state has changed
  44310. * @param callback the callback containing the button that was modified
  44311. */
  44312. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44313. /**
  44314. * X and Y axis corrisponding to the controllers joystick
  44315. */
  44316. pad: StickValues;
  44317. /**
  44318. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44319. */
  44320. hand: string;
  44321. /**
  44322. * The default controller model for the controller
  44323. */
  44324. readonly defaultModel: AbstractMesh;
  44325. /**
  44326. * Creates a new WebVRController from a gamepad
  44327. * @param vrGamepad the gamepad that the WebVRController should be created from
  44328. */
  44329. constructor(vrGamepad: any);
  44330. /**
  44331. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44332. */
  44333. update(): void;
  44334. /**
  44335. * Function to be called when a button is modified
  44336. */
  44337. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44338. /**
  44339. * Loads a mesh and attaches it to the controller
  44340. * @param scene the scene the mesh should be added to
  44341. * @param meshLoaded callback for when the mesh has been loaded
  44342. */
  44343. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44344. private _setButtonValue;
  44345. private _changes;
  44346. private _checkChanges;
  44347. /**
  44348. * Disposes of th webVRCOntroller
  44349. */
  44350. dispose(): void;
  44351. }
  44352. }
  44353. declare module BABYLON {
  44354. /**
  44355. * Defines the WindowsMotionController object that the state of the windows motion controller
  44356. */
  44357. class WindowsMotionController extends WebVRController {
  44358. /**
  44359. * The base url used to load the left and right controller models
  44360. */
  44361. static MODEL_BASE_URL: string;
  44362. /**
  44363. * The name of the left controller model file
  44364. */
  44365. static MODEL_LEFT_FILENAME: string;
  44366. /**
  44367. * The name of the right controller model file
  44368. */
  44369. static MODEL_RIGHT_FILENAME: string;
  44370. /**
  44371. * The controller name prefix for this controller type
  44372. */
  44373. static readonly GAMEPAD_ID_PREFIX: string;
  44374. /**
  44375. * The controller id pattern for this controller type
  44376. */
  44377. private static readonly GAMEPAD_ID_PATTERN;
  44378. private _loadedMeshInfo;
  44379. private readonly _mapping;
  44380. /**
  44381. * Fired when the trackpad on this controller is clicked
  44382. */
  44383. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44384. /**
  44385. * Fired when the trackpad on this controller is modified
  44386. */
  44387. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44388. /**
  44389. * The current x and y values of this controller's trackpad
  44390. */
  44391. trackpad: StickValues;
  44392. /**
  44393. * Creates a new WindowsMotionController from a gamepad
  44394. * @param vrGamepad the gamepad that the controller should be created from
  44395. */
  44396. constructor(vrGamepad: any);
  44397. /**
  44398. * Fired when the trigger on this controller is modified
  44399. */
  44400. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44401. /**
  44402. * Fired when the menu button on this controller is modified
  44403. */
  44404. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44405. /**
  44406. * Fired when the grip button on this controller is modified
  44407. */
  44408. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44409. /**
  44410. * Fired when the thumbstick button on this controller is modified
  44411. */
  44412. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44413. /**
  44414. * Fired when the touchpad button on this controller is modified
  44415. */
  44416. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44417. /**
  44418. * Fired when the touchpad values on this controller are modified
  44419. */
  44420. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44421. private _updateTrackpad;
  44422. /**
  44423. * Called once per frame by the engine.
  44424. */
  44425. update(): void;
  44426. /**
  44427. * Called once for each button that changed state since the last frame
  44428. * @param buttonIdx Which button index changed
  44429. * @param state New state of the button
  44430. * @param changes Which properties on the state changed since last frame
  44431. */
  44432. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44433. /**
  44434. * Moves the buttons on the controller mesh based on their current state
  44435. * @param buttonName the name of the button to move
  44436. * @param buttonValue the value of the button which determines the buttons new position
  44437. */
  44438. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44439. /**
  44440. * Moves the axis on the controller mesh based on its current state
  44441. * @param axis the index of the axis
  44442. * @param axisValue the value of the axis which determines the meshes new position
  44443. * @hidden
  44444. */
  44445. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44446. /**
  44447. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44448. * @param scene scene in which to add meshes
  44449. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44450. */
  44451. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44452. /**
  44453. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44454. * can be transformed by button presses and axes values, based on this._mapping.
  44455. *
  44456. * @param scene scene in which the meshes exist
  44457. * @param meshes list of meshes that make up the controller model to process
  44458. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44459. */
  44460. private processModel;
  44461. private createMeshInfo;
  44462. /**
  44463. * Gets the ray of the controller in the direction the controller is pointing
  44464. * @param length the length the resulting ray should be
  44465. * @returns a ray in the direction the controller is pointing
  44466. */
  44467. getForwardRay(length?: number): Ray;
  44468. /**
  44469. * Disposes of the controller
  44470. */
  44471. dispose(): void;
  44472. }
  44473. }
  44474. declare module BABYLON {
  44475. /**
  44476. * Interface to implement to create a shadow generator compatible with BJS.
  44477. */
  44478. interface IShadowGenerator {
  44479. /**
  44480. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44481. * @returns The render target texture if present otherwise, null
  44482. */
  44483. getShadowMap(): Nullable<RenderTargetTexture>;
  44484. /**
  44485. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44486. * @returns The render target texture if the shadow map is present otherwise, null
  44487. */
  44488. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44489. /**
  44490. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44491. * @param subMesh The submesh we want to render in the shadow map
  44492. * @param useInstances Defines wether will draw in the map using instances
  44493. * @returns true if ready otherwise, false
  44494. */
  44495. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44496. /**
  44497. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44498. * @param defines Defines of the material we want to update
  44499. * @param lightIndex Index of the light in the enabled light list of the material
  44500. */
  44501. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44502. /**
  44503. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44504. * defined in the generator but impacting the effect).
  44505. * It implies the unifroms available on the materials are the standard BJS ones.
  44506. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44507. * @param effect The effect we are binfing the information for
  44508. */
  44509. bindShadowLight(lightIndex: string, effect: Effect): void;
  44510. /**
  44511. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44512. * (eq to shadow prjection matrix * light transform matrix)
  44513. * @returns The transform matrix used to create the shadow map
  44514. */
  44515. getTransformMatrix(): Matrix;
  44516. /**
  44517. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44518. * Cube and 2D textures for instance.
  44519. */
  44520. recreateShadowMap(): void;
  44521. /**
  44522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44523. * @param onCompiled Callback triggered at the and of the effects compilation
  44524. * @param options Sets of optional options forcing the compilation with different modes
  44525. */
  44526. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44527. useInstances: boolean;
  44528. }>): void;
  44529. /**
  44530. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44531. * @param options Sets of optional options forcing the compilation with different modes
  44532. * @returns A promise that resolves when the compilation completes
  44533. */
  44534. forceCompilationAsync(options?: Partial<{
  44535. useInstances: boolean;
  44536. }>): Promise<void>;
  44537. /**
  44538. * Serializes the shadow generator setup to a json object.
  44539. * @returns The serialized JSON object
  44540. */
  44541. serialize(): any;
  44542. /**
  44543. * Disposes the Shadow map and related Textures and effects.
  44544. */
  44545. dispose(): void;
  44546. }
  44547. /**
  44548. * Default implementation IShadowGenerator.
  44549. * This is the main object responsible of generating shadows in the framework.
  44550. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44551. */
  44552. class ShadowGenerator implements IShadowGenerator {
  44553. /**
  44554. * Shadow generator mode None: no filtering applied.
  44555. */
  44556. static readonly FILTER_NONE: number;
  44557. /**
  44558. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44559. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44560. */
  44561. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44562. /**
  44563. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44564. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44565. */
  44566. static readonly FILTER_POISSONSAMPLING: number;
  44567. /**
  44568. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44569. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44570. */
  44571. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44572. /**
  44573. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44574. * edge artifacts on steep falloff.
  44575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44576. */
  44577. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44578. /**
  44579. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44580. * edge artifacts on steep falloff.
  44581. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44582. */
  44583. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44584. /**
  44585. * Shadow generator mode PCF: Percentage Closer Filtering
  44586. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44587. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44588. */
  44589. static readonly FILTER_PCF: number;
  44590. /**
  44591. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44592. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44593. * Contact Hardening
  44594. */
  44595. static readonly FILTER_PCSS: number;
  44596. /**
  44597. * Reserved for PCF and PCSS
  44598. * Highest Quality.
  44599. *
  44600. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44601. *
  44602. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44603. */
  44604. static readonly QUALITY_HIGH: number;
  44605. /**
  44606. * Reserved for PCF and PCSS
  44607. * Good tradeoff for quality/perf cross devices
  44608. *
  44609. * Execute PCF on a 3*3 kernel.
  44610. *
  44611. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44612. */
  44613. static readonly QUALITY_MEDIUM: number;
  44614. /**
  44615. * Reserved for PCF and PCSS
  44616. * The lowest quality but the fastest.
  44617. *
  44618. * Execute PCF on a 1*1 kernel.
  44619. *
  44620. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44621. */
  44622. static readonly QUALITY_LOW: number;
  44623. private _bias;
  44624. /**
  44625. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44626. */
  44627. /**
  44628. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44629. */
  44630. bias: number;
  44631. private _normalBias;
  44632. /**
  44633. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44634. */
  44635. /**
  44636. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44637. */
  44638. normalBias: number;
  44639. private _blurBoxOffset;
  44640. /**
  44641. * Gets the blur box offset: offset applied during the blur pass.
  44642. * Only useful if useKernelBlur = false
  44643. */
  44644. /**
  44645. * Sets the blur box offset: offset applied during the blur pass.
  44646. * Only useful if useKernelBlur = false
  44647. */
  44648. blurBoxOffset: number;
  44649. private _blurScale;
  44650. /**
  44651. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44652. * 2 means half of the size.
  44653. */
  44654. /**
  44655. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44656. * 2 means half of the size.
  44657. */
  44658. blurScale: number;
  44659. private _blurKernel;
  44660. /**
  44661. * Gets the blur kernel: kernel size of the blur pass.
  44662. * Only useful if useKernelBlur = true
  44663. */
  44664. /**
  44665. * Sets the blur kernel: kernel size of the blur pass.
  44666. * Only useful if useKernelBlur = true
  44667. */
  44668. blurKernel: number;
  44669. private _useKernelBlur;
  44670. /**
  44671. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44672. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44673. */
  44674. /**
  44675. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44676. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44677. */
  44678. useKernelBlur: boolean;
  44679. private _depthScale;
  44680. /**
  44681. * Gets the depth scale used in ESM mode.
  44682. */
  44683. /**
  44684. * Sets the depth scale used in ESM mode.
  44685. * This can override the scale stored on the light.
  44686. */
  44687. depthScale: number;
  44688. private _filter;
  44689. /**
  44690. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44691. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44692. */
  44693. /**
  44694. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44695. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44696. */
  44697. filter: number;
  44698. /**
  44699. * Gets if the current filter is set to Poisson Sampling.
  44700. */
  44701. /**
  44702. * Sets the current filter to Poisson Sampling.
  44703. */
  44704. usePoissonSampling: boolean;
  44705. /**
  44706. * Gets if the current filter is set to ESM.
  44707. */
  44708. /**
  44709. * Sets the current filter is to ESM.
  44710. */
  44711. useExponentialShadowMap: boolean;
  44712. /**
  44713. * Gets if the current filter is set to filtered ESM.
  44714. */
  44715. /**
  44716. * Gets if the current filter is set to filtered ESM.
  44717. */
  44718. useBlurExponentialShadowMap: boolean;
  44719. /**
  44720. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44721. * exponential to prevent steep falloff artifacts).
  44722. */
  44723. /**
  44724. * Sets the current filter to "close ESM" (using the inverse of the
  44725. * exponential to prevent steep falloff artifacts).
  44726. */
  44727. useCloseExponentialShadowMap: boolean;
  44728. /**
  44729. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44730. * exponential to prevent steep falloff artifacts).
  44731. */
  44732. /**
  44733. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44734. * exponential to prevent steep falloff artifacts).
  44735. */
  44736. useBlurCloseExponentialShadowMap: boolean;
  44737. /**
  44738. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44739. */
  44740. /**
  44741. * Sets the current filter to "PCF" (percentage closer filtering).
  44742. */
  44743. usePercentageCloserFiltering: boolean;
  44744. private _filteringQuality;
  44745. /**
  44746. * Gets the PCF or PCSS Quality.
  44747. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44748. */
  44749. /**
  44750. * Sets the PCF or PCSS Quality.
  44751. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44752. */
  44753. filteringQuality: number;
  44754. /**
  44755. * Gets if the current filter is set to "PCSS" (contact hardening).
  44756. */
  44757. /**
  44758. * Sets the current filter to "PCSS" (contact hardening).
  44759. */
  44760. useContactHardeningShadow: boolean;
  44761. private _contactHardeningLightSizeUVRatio;
  44762. /**
  44763. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44764. * Using a ratio helps keeping shape stability independently of the map size.
  44765. *
  44766. * It does not account for the light projection as it was having too much
  44767. * instability during the light setup or during light position changes.
  44768. *
  44769. * Only valid if useContactHardeningShadow is true.
  44770. */
  44771. /**
  44772. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44773. * Using a ratio helps keeping shape stability independently of the map size.
  44774. *
  44775. * It does not account for the light projection as it was having too much
  44776. * instability during the light setup or during light position changes.
  44777. *
  44778. * Only valid if useContactHardeningShadow is true.
  44779. */
  44780. contactHardeningLightSizeUVRatio: number;
  44781. private _darkness;
  44782. /**
  44783. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44784. * 0 means strongest and 1 would means no shadow.
  44785. * @returns the darkness.
  44786. */
  44787. getDarkness(): number;
  44788. /**
  44789. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44790. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44791. * @returns the shadow generator allowing fluent coding.
  44792. */
  44793. setDarkness(darkness: number): ShadowGenerator;
  44794. private _transparencyShadow;
  44795. /**
  44796. * Sets the ability to have transparent shadow (boolean).
  44797. * @param transparent True if transparent else False
  44798. * @returns the shadow generator allowing fluent coding
  44799. */
  44800. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44801. private _shadowMap;
  44802. private _shadowMap2;
  44803. /**
  44804. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44805. * @returns The render target texture if present otherwise, null
  44806. */
  44807. getShadowMap(): Nullable<RenderTargetTexture>;
  44808. /**
  44809. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44810. * @returns The render target texture if the shadow map is present otherwise, null
  44811. */
  44812. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44813. /**
  44814. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44815. * @param mesh Mesh to add
  44816. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44817. * @returns the Shadow Generator itself
  44818. */
  44819. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44820. /**
  44821. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44822. * @param mesh Mesh to remove
  44823. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44824. * @returns the Shadow Generator itself
  44825. */
  44826. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44827. /**
  44828. * Controls the extent to which the shadows fade out at the edge of the frustum
  44829. * Used only by directionals and spots
  44830. */
  44831. frustumEdgeFalloff: number;
  44832. private _light;
  44833. /**
  44834. * Returns the associated light object.
  44835. * @returns the light generating the shadow
  44836. */
  44837. getLight(): IShadowLight;
  44838. /**
  44839. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44840. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44841. * It might on the other hand introduce peter panning.
  44842. */
  44843. forceBackFacesOnly: boolean;
  44844. private _scene;
  44845. private _lightDirection;
  44846. private _effect;
  44847. private _viewMatrix;
  44848. private _projectionMatrix;
  44849. private _transformMatrix;
  44850. private _cachedPosition;
  44851. private _cachedDirection;
  44852. private _cachedDefines;
  44853. private _currentRenderID;
  44854. private _boxBlurPostprocess;
  44855. private _kernelBlurXPostprocess;
  44856. private _kernelBlurYPostprocess;
  44857. private _blurPostProcesses;
  44858. private _mapSize;
  44859. private _currentFaceIndex;
  44860. private _currentFaceIndexCache;
  44861. private _textureType;
  44862. private _defaultTextureMatrix;
  44863. /**
  44864. * Creates a ShadowGenerator object.
  44865. * A ShadowGenerator is the required tool to use the shadows.
  44866. * Each light casting shadows needs to use its own ShadowGenerator.
  44867. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44868. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44869. * @param light The light object generating the shadows.
  44870. * @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.
  44871. */
  44872. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44873. private _initializeGenerator;
  44874. private _initializeShadowMap;
  44875. private _initializeBlurRTTAndPostProcesses;
  44876. private _renderForShadowMap;
  44877. private _renderSubMeshForShadowMap;
  44878. private _applyFilterValues;
  44879. /**
  44880. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44881. * @param onCompiled Callback triggered at the and of the effects compilation
  44882. * @param options Sets of optional options forcing the compilation with different modes
  44883. */
  44884. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44885. useInstances: boolean;
  44886. }>): void;
  44887. /**
  44888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44889. * @param options Sets of optional options forcing the compilation with different modes
  44890. * @returns A promise that resolves when the compilation completes
  44891. */
  44892. forceCompilationAsync(options?: Partial<{
  44893. useInstances: boolean;
  44894. }>): Promise<void>;
  44895. /**
  44896. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44897. * @param subMesh The submesh we want to render in the shadow map
  44898. * @param useInstances Defines wether will draw in the map using instances
  44899. * @returns true if ready otherwise, false
  44900. */
  44901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44902. /**
  44903. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44904. * @param defines Defines of the material we want to update
  44905. * @param lightIndex Index of the light in the enabled light list of the material
  44906. */
  44907. prepareDefines(defines: any, lightIndex: number): void;
  44908. /**
  44909. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44910. * defined in the generator but impacting the effect).
  44911. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44912. * @param effect The effect we are binfing the information for
  44913. */
  44914. bindShadowLight(lightIndex: string, effect: Effect): void;
  44915. /**
  44916. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44917. * (eq to shadow prjection matrix * light transform matrix)
  44918. * @returns The transform matrix used to create the shadow map
  44919. */
  44920. getTransformMatrix(): Matrix;
  44921. /**
  44922. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44923. * Cube and 2D textures for instance.
  44924. */
  44925. recreateShadowMap(): void;
  44926. private _disposeBlurPostProcesses;
  44927. private _disposeRTTandPostProcesses;
  44928. /**
  44929. * Disposes the ShadowGenerator.
  44930. * Returns nothing.
  44931. */
  44932. dispose(): void;
  44933. /**
  44934. * Serializes the shadow generator setup to a json object.
  44935. * @returns The serialized JSON object
  44936. */
  44937. serialize(): any;
  44938. /**
  44939. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44940. * @param parsedShadowGenerator The JSON object to parse
  44941. * @param scene The scene to create the shadow map for
  44942. * @returns The parsed shadow generator
  44943. */
  44944. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44945. }
  44946. }
  44947. declare module BABYLON {
  44948. /**
  44949. * Defines the shadow generator component responsible to manage any shadow generators
  44950. * in a given scene.
  44951. */
  44952. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44953. /**
  44954. * The component name helpfull to identify the component in the list of scene components.
  44955. */
  44956. readonly name: string;
  44957. /**
  44958. * The scene the component belongs to.
  44959. */
  44960. scene: Scene;
  44961. /**
  44962. * Creates a new instance of the component for the given scene
  44963. * @param scene Defines the scene to register the component in
  44964. */
  44965. constructor(scene: Scene);
  44966. /**
  44967. * Registers the component in a given scene
  44968. */
  44969. register(): void;
  44970. /**
  44971. * Rebuilds the elements related to this component in case of
  44972. * context lost for instance.
  44973. */
  44974. rebuild(): void;
  44975. /**
  44976. * Serializes the component data to the specified json object
  44977. * @param serializationObject The object to serialize to
  44978. */
  44979. serialize(serializationObject: any): void;
  44980. /**
  44981. * Adds all the element from the container to the scene
  44982. * @param container the container holding the elements
  44983. */
  44984. addFromContainer(container: AbstractScene): void;
  44985. /**
  44986. * Removes all the elements in the container from the scene
  44987. * @param container contains the elements to remove
  44988. */
  44989. removeFromContainer(container: AbstractScene): void;
  44990. /**
  44991. * Rebuilds the elements related to this component in case of
  44992. * context lost for instance.
  44993. */
  44994. dispose(): void;
  44995. private _gatherRenderTargets;
  44996. }
  44997. }
  44998. declare module BABYLON {
  44999. }
  45000. declare module BABYLON {
  45001. /**
  45002. * Background material used to create an efficient environement around your scene.
  45003. */
  45004. class BackgroundMaterial extends PushMaterial {
  45005. /**
  45006. * Standard reflectance value at parallel view angle.
  45007. */
  45008. static StandardReflectance0: number;
  45009. /**
  45010. * Standard reflectance value at grazing angle.
  45011. */
  45012. static StandardReflectance90: number;
  45013. protected _primaryColor: Color3;
  45014. /**
  45015. * Key light Color (multiply against the environement texture)
  45016. */
  45017. primaryColor: Color3;
  45018. protected __perceptualColor: Nullable<Color3>;
  45019. /**
  45020. * Experimental Internal Use Only.
  45021. *
  45022. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45023. * This acts as a helper to set the primary color to a more "human friendly" value.
  45024. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45025. * output color as close as possible from the chosen value.
  45026. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45027. * part of lighting setup.)
  45028. */
  45029. _perceptualColor: Nullable<Color3>;
  45030. protected _primaryColorShadowLevel: float;
  45031. /**
  45032. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45033. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45034. */
  45035. primaryColorShadowLevel: float;
  45036. protected _primaryColorHighlightLevel: float;
  45037. /**
  45038. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45039. * The primary color is used at the level chosen to define what the white area would look.
  45040. */
  45041. primaryColorHighlightLevel: float;
  45042. protected _reflectionTexture: Nullable<BaseTexture>;
  45043. /**
  45044. * Reflection Texture used in the material.
  45045. * Should be author in a specific way for the best result (refer to the documentation).
  45046. */
  45047. reflectionTexture: Nullable<BaseTexture>;
  45048. protected _reflectionBlur: float;
  45049. /**
  45050. * Reflection Texture level of blur.
  45051. *
  45052. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45053. * texture twice.
  45054. */
  45055. reflectionBlur: float;
  45056. protected _diffuseTexture: Nullable<BaseTexture>;
  45057. /**
  45058. * Diffuse Texture used in the material.
  45059. * Should be author in a specific way for the best result (refer to the documentation).
  45060. */
  45061. diffuseTexture: Nullable<BaseTexture>;
  45062. protected _shadowLights: Nullable<IShadowLight[]>;
  45063. /**
  45064. * Specify the list of lights casting shadow on the material.
  45065. * All scene shadow lights will be included if null.
  45066. */
  45067. shadowLights: Nullable<IShadowLight[]>;
  45068. protected _shadowLevel: float;
  45069. /**
  45070. * Helps adjusting the shadow to a softer level if required.
  45071. * 0 means black shadows and 1 means no shadows.
  45072. */
  45073. shadowLevel: float;
  45074. protected _sceneCenter: Vector3;
  45075. /**
  45076. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45077. * It is usually zero but might be interesting to modify according to your setup.
  45078. */
  45079. sceneCenter: Vector3;
  45080. protected _opacityFresnel: boolean;
  45081. /**
  45082. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45083. * This helps ensuring a nice transition when the camera goes under the ground.
  45084. */
  45085. opacityFresnel: boolean;
  45086. protected _reflectionFresnel: boolean;
  45087. /**
  45088. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45089. * This helps adding a mirror texture on the ground.
  45090. */
  45091. reflectionFresnel: boolean;
  45092. protected _reflectionFalloffDistance: number;
  45093. /**
  45094. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45095. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45096. */
  45097. reflectionFalloffDistance: number;
  45098. protected _reflectionAmount: number;
  45099. /**
  45100. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45101. */
  45102. reflectionAmount: number;
  45103. protected _reflectionReflectance0: number;
  45104. /**
  45105. * This specifies the weight of the reflection at grazing angle.
  45106. */
  45107. reflectionReflectance0: number;
  45108. protected _reflectionReflectance90: number;
  45109. /**
  45110. * This specifies the weight of the reflection at a perpendicular point of view.
  45111. */
  45112. reflectionReflectance90: number;
  45113. /**
  45114. * Sets the reflection reflectance fresnel values according to the default standard
  45115. * empirically know to work well :-)
  45116. */
  45117. reflectionStandardFresnelWeight: number;
  45118. protected _useRGBColor: boolean;
  45119. /**
  45120. * Helps to directly use the maps channels instead of their level.
  45121. */
  45122. useRGBColor: boolean;
  45123. protected _enableNoise: boolean;
  45124. /**
  45125. * This helps reducing the banding effect that could occur on the background.
  45126. */
  45127. enableNoise: boolean;
  45128. /**
  45129. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45130. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45131. * Recommended to be keep at 1.0 except for special cases.
  45132. */
  45133. fovMultiplier: number;
  45134. private _fovMultiplier;
  45135. /**
  45136. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45137. */
  45138. useEquirectangularFOV: boolean;
  45139. private _maxSimultaneousLights;
  45140. /**
  45141. * Number of Simultaneous lights allowed on the material.
  45142. */
  45143. maxSimultaneousLights: int;
  45144. /**
  45145. * Default configuration related to image processing available in the Background Material.
  45146. */
  45147. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45148. /**
  45149. * Keep track of the image processing observer to allow dispose and replace.
  45150. */
  45151. private _imageProcessingObserver;
  45152. /**
  45153. * Attaches a new image processing configuration to the PBR Material.
  45154. * @param configuration (if null the scene configuration will be use)
  45155. */
  45156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45157. /**
  45158. * Gets the image processing configuration used either in this material.
  45159. */
  45160. /**
  45161. * Sets the Default image processing configuration used either in the this material.
  45162. *
  45163. * If sets to null, the scene one is in use.
  45164. */
  45165. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45166. /**
  45167. * Gets wether the color curves effect is enabled.
  45168. */
  45169. /**
  45170. * Sets wether the color curves effect is enabled.
  45171. */
  45172. cameraColorCurvesEnabled: boolean;
  45173. /**
  45174. * Gets wether the color grading effect is enabled.
  45175. */
  45176. /**
  45177. * Gets wether the color grading effect is enabled.
  45178. */
  45179. cameraColorGradingEnabled: boolean;
  45180. /**
  45181. * Gets wether tonemapping is enabled or not.
  45182. */
  45183. /**
  45184. * Sets wether tonemapping is enabled or not
  45185. */
  45186. cameraToneMappingEnabled: boolean;
  45187. /**
  45188. * The camera exposure used on this material.
  45189. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45190. * This corresponds to a photographic exposure.
  45191. */
  45192. /**
  45193. * The camera exposure used on this material.
  45194. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45195. * This corresponds to a photographic exposure.
  45196. */
  45197. cameraExposure: float;
  45198. /**
  45199. * Gets The camera contrast used on this material.
  45200. */
  45201. /**
  45202. * Sets The camera contrast used on this material.
  45203. */
  45204. cameraContrast: float;
  45205. /**
  45206. * Gets the Color Grading 2D Lookup Texture.
  45207. */
  45208. /**
  45209. * Sets the Color Grading 2D Lookup Texture.
  45210. */
  45211. cameraColorGradingTexture: Nullable<BaseTexture>;
  45212. /**
  45213. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45214. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45215. * 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;
  45216. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45217. */
  45218. /**
  45219. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45220. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45221. * 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;
  45222. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45223. */
  45224. cameraColorCurves: Nullable<ColorCurves>;
  45225. /**
  45226. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45227. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45228. */
  45229. switchToBGR: boolean;
  45230. private _renderTargets;
  45231. private _reflectionControls;
  45232. private _white;
  45233. private _primaryShadowColor;
  45234. private _primaryHighlightColor;
  45235. /**
  45236. * Instantiates a Background Material in the given scene
  45237. * @param name The friendly name of the material
  45238. * @param scene The scene to add the material to
  45239. */
  45240. constructor(name: string, scene: Scene);
  45241. /**
  45242. * Gets a boolean indicating that current material needs to register RTT
  45243. */
  45244. readonly hasRenderTargetTextures: boolean;
  45245. /**
  45246. * The entire material has been created in order to prevent overdraw.
  45247. * @returns false
  45248. */
  45249. needAlphaTesting(): boolean;
  45250. /**
  45251. * The entire material has been created in order to prevent overdraw.
  45252. * @returns true if blending is enable
  45253. */
  45254. needAlphaBlending(): boolean;
  45255. /**
  45256. * Checks wether the material is ready to be rendered for a given mesh.
  45257. * @param mesh The mesh to render
  45258. * @param subMesh The submesh to check against
  45259. * @param useInstances Specify wether or not the material is used with instances
  45260. * @returns true if all the dependencies are ready (Textures, Effects...)
  45261. */
  45262. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45263. /**
  45264. * Compute the primary color according to the chosen perceptual color.
  45265. */
  45266. private _computePrimaryColorFromPerceptualColor;
  45267. /**
  45268. * Compute the highlights and shadow colors according to their chosen levels.
  45269. */
  45270. private _computePrimaryColors;
  45271. /**
  45272. * Build the uniform buffer used in the material.
  45273. */
  45274. buildUniformLayout(): void;
  45275. /**
  45276. * Unbind the material.
  45277. */
  45278. unbind(): void;
  45279. /**
  45280. * Bind only the world matrix to the material.
  45281. * @param world The world matrix to bind.
  45282. */
  45283. bindOnlyWorldMatrix(world: Matrix): void;
  45284. /**
  45285. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45286. * @param world The world matrix to bind.
  45287. * @param subMesh The submesh to bind for.
  45288. */
  45289. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45290. /**
  45291. * Dispose the material.
  45292. * @param forceDisposeEffect Force disposal of the associated effect.
  45293. * @param forceDisposeTextures Force disposal of the associated textures.
  45294. */
  45295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45296. /**
  45297. * Clones the material.
  45298. * @param name The cloned name.
  45299. * @returns The cloned material.
  45300. */
  45301. clone(name: string): BackgroundMaterial;
  45302. /**
  45303. * Serializes the current material to its JSON representation.
  45304. * @returns The JSON representation.
  45305. */
  45306. serialize(): any;
  45307. /**
  45308. * Gets the class name of the material
  45309. * @returns "BackgroundMaterial"
  45310. */
  45311. getClassName(): string;
  45312. /**
  45313. * Parse a JSON input to create back a background material.
  45314. * @param source The JSON data to parse
  45315. * @param scene The scene to create the parsed material in
  45316. * @param rootUrl The root url of the assets the material depends upon
  45317. * @returns the instantiated BackgroundMaterial.
  45318. */
  45319. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45320. }
  45321. }
  45322. declare module BABYLON {
  45323. /**
  45324. * The Physically based material base class of BJS.
  45325. *
  45326. * This offers the main features of a standard PBR material.
  45327. * For more information, please refer to the documentation :
  45328. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45329. */
  45330. abstract class PBRBaseMaterial extends PushMaterial {
  45331. /**
  45332. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45333. */
  45334. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45335. /**
  45336. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45337. * to enhance interoperability with other engines.
  45338. */
  45339. static readonly LIGHTFALLOFF_GLTF: number;
  45340. /**
  45341. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45342. * to enhance interoperability with other materials.
  45343. */
  45344. static readonly LIGHTFALLOFF_STANDARD: number;
  45345. /**
  45346. * Intensity of the direct lights e.g. the four lights available in your scene.
  45347. * This impacts both the direct diffuse and specular highlights.
  45348. */
  45349. protected _directIntensity: number;
  45350. /**
  45351. * Intensity of the emissive part of the material.
  45352. * This helps controlling the emissive effect without modifying the emissive color.
  45353. */
  45354. protected _emissiveIntensity: number;
  45355. /**
  45356. * Intensity of the environment e.g. how much the environment will light the object
  45357. * either through harmonics for rough material or through the refelction for shiny ones.
  45358. */
  45359. protected _environmentIntensity: number;
  45360. /**
  45361. * This is a special control allowing the reduction of the specular highlights coming from the
  45362. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45363. */
  45364. protected _specularIntensity: number;
  45365. /**
  45366. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45367. */
  45368. private _lightingInfos;
  45369. /**
  45370. * Debug Control allowing disabling the bump map on this material.
  45371. */
  45372. protected _disableBumpMap: boolean;
  45373. /**
  45374. * AKA Diffuse Texture in standard nomenclature.
  45375. */
  45376. protected _albedoTexture: BaseTexture;
  45377. /**
  45378. * AKA Occlusion Texture in other nomenclature.
  45379. */
  45380. protected _ambientTexture: BaseTexture;
  45381. /**
  45382. * AKA Occlusion Texture Intensity in other nomenclature.
  45383. */
  45384. protected _ambientTextureStrength: number;
  45385. /**
  45386. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45387. * 1 means it completely occludes it
  45388. * 0 mean it has no impact
  45389. */
  45390. protected _ambientTextureImpactOnAnalyticalLights: number;
  45391. /**
  45392. * Stores the alpha values in a texture.
  45393. */
  45394. protected _opacityTexture: BaseTexture;
  45395. /**
  45396. * Stores the reflection values in a texture.
  45397. */
  45398. protected _reflectionTexture: BaseTexture;
  45399. /**
  45400. * Stores the refraction values in a texture.
  45401. */
  45402. protected _refractionTexture: BaseTexture;
  45403. /**
  45404. * Stores the emissive values in a texture.
  45405. */
  45406. protected _emissiveTexture: BaseTexture;
  45407. /**
  45408. * AKA Specular texture in other nomenclature.
  45409. */
  45410. protected _reflectivityTexture: BaseTexture;
  45411. /**
  45412. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45413. */
  45414. protected _metallicTexture: BaseTexture;
  45415. /**
  45416. * Specifies the metallic scalar of the metallic/roughness workflow.
  45417. * Can also be used to scale the metalness values of the metallic texture.
  45418. */
  45419. protected _metallic: Nullable<number>;
  45420. /**
  45421. * Specifies the roughness scalar of the metallic/roughness workflow.
  45422. * Can also be used to scale the roughness values of the metallic texture.
  45423. */
  45424. protected _roughness: Nullable<number>;
  45425. /**
  45426. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45427. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45428. */
  45429. protected _microSurfaceTexture: BaseTexture;
  45430. /**
  45431. * Stores surface normal data used to displace a mesh in a texture.
  45432. */
  45433. protected _bumpTexture: BaseTexture;
  45434. /**
  45435. * Stores the pre-calculated light information of a mesh in a texture.
  45436. */
  45437. protected _lightmapTexture: BaseTexture;
  45438. /**
  45439. * The color of a material in ambient lighting.
  45440. */
  45441. protected _ambientColor: Color3;
  45442. /**
  45443. * AKA Diffuse Color in other nomenclature.
  45444. */
  45445. protected _albedoColor: Color3;
  45446. /**
  45447. * AKA Specular Color in other nomenclature.
  45448. */
  45449. protected _reflectivityColor: Color3;
  45450. /**
  45451. * The color applied when light is reflected from a material.
  45452. */
  45453. protected _reflectionColor: Color3;
  45454. /**
  45455. * The color applied when light is emitted from a material.
  45456. */
  45457. protected _emissiveColor: Color3;
  45458. /**
  45459. * AKA Glossiness in other nomenclature.
  45460. */
  45461. protected _microSurface: number;
  45462. /**
  45463. * source material index of refraction (IOR)' / 'destination material IOR.
  45464. */
  45465. protected _indexOfRefraction: number;
  45466. /**
  45467. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45468. */
  45469. protected _invertRefractionY: boolean;
  45470. /**
  45471. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45472. * Materials half opaque for instance using refraction could benefit from this control.
  45473. */
  45474. protected _linkRefractionWithTransparency: boolean;
  45475. /**
  45476. * Specifies that the material will use the light map as a show map.
  45477. */
  45478. protected _useLightmapAsShadowmap: boolean;
  45479. /**
  45480. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45481. * makes the reflect vector face the model (under horizon).
  45482. */
  45483. protected _useHorizonOcclusion: boolean;
  45484. /**
  45485. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45486. * too much the area relying on ambient texture to define their ambient occlusion.
  45487. */
  45488. protected _useRadianceOcclusion: boolean;
  45489. /**
  45490. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45491. */
  45492. protected _useAlphaFromAlbedoTexture: boolean;
  45493. /**
  45494. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45495. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45496. */
  45497. protected _useSpecularOverAlpha: boolean;
  45498. /**
  45499. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45500. */
  45501. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45502. /**
  45503. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45504. */
  45505. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45506. /**
  45507. * Specifies if the metallic texture contains the roughness information in its green channel.
  45508. */
  45509. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45510. /**
  45511. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45512. */
  45513. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45514. /**
  45515. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45516. */
  45517. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45518. /**
  45519. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45520. */
  45521. protected _useAmbientInGrayScale: boolean;
  45522. /**
  45523. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45524. * The material will try to infer what glossiness each pixel should be.
  45525. */
  45526. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45527. /**
  45528. * Defines the falloff type used in this material.
  45529. * It by default is Physical.
  45530. */
  45531. protected _lightFalloff: number;
  45532. /**
  45533. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45534. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45535. */
  45536. protected _useRadianceOverAlpha: boolean;
  45537. /**
  45538. * Allows using an object space normal map (instead of tangent space).
  45539. */
  45540. protected _useObjectSpaceNormalMap: boolean;
  45541. /**
  45542. * Allows using the bump map in parallax mode.
  45543. */
  45544. protected _useParallax: boolean;
  45545. /**
  45546. * Allows using the bump map in parallax occlusion mode.
  45547. */
  45548. protected _useParallaxOcclusion: boolean;
  45549. /**
  45550. * Controls the scale bias of the parallax mode.
  45551. */
  45552. protected _parallaxScaleBias: number;
  45553. /**
  45554. * If sets to true, disables all the lights affecting the material.
  45555. */
  45556. protected _disableLighting: boolean;
  45557. /**
  45558. * Number of Simultaneous lights allowed on the material.
  45559. */
  45560. protected _maxSimultaneousLights: number;
  45561. /**
  45562. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45563. */
  45564. protected _invertNormalMapX: boolean;
  45565. /**
  45566. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45567. */
  45568. protected _invertNormalMapY: boolean;
  45569. /**
  45570. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45571. */
  45572. protected _twoSidedLighting: boolean;
  45573. /**
  45574. * Defines the alpha limits in alpha test mode.
  45575. */
  45576. protected _alphaCutOff: number;
  45577. /**
  45578. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45579. */
  45580. protected _forceAlphaTest: boolean;
  45581. /**
  45582. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45583. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45584. */
  45585. protected _useAlphaFresnel: boolean;
  45586. /**
  45587. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45588. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45589. */
  45590. protected _useLinearAlphaFresnel: boolean;
  45591. /**
  45592. * The transparency mode of the material.
  45593. */
  45594. protected _transparencyMode: Nullable<number>;
  45595. /**
  45596. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45597. * from cos thetav and roughness:
  45598. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45599. */
  45600. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45601. /**
  45602. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45603. */
  45604. protected _forceIrradianceInFragment: boolean;
  45605. /**
  45606. * Force normal to face away from face.
  45607. */
  45608. protected _forceNormalForward: boolean;
  45609. /**
  45610. * Enables specular anti aliasing in the PBR shader.
  45611. * It will both interacts on the Geometry for analytical and IBL lighting.
  45612. * It also prefilter the roughness map based on the bump values.
  45613. */
  45614. protected _enableSpecularAntiAliasing: boolean;
  45615. /**
  45616. * Default configuration related to image processing available in the PBR Material.
  45617. */
  45618. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45619. /**
  45620. * Keep track of the image processing observer to allow dispose and replace.
  45621. */
  45622. private _imageProcessingObserver;
  45623. /**
  45624. * Attaches a new image processing configuration to the PBR Material.
  45625. * @param configuration
  45626. */
  45627. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45628. /**
  45629. * Stores the available render targets.
  45630. */
  45631. private _renderTargets;
  45632. /**
  45633. * Sets the global ambient color for the material used in lighting calculations.
  45634. */
  45635. private _globalAmbientColor;
  45636. /**
  45637. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45638. */
  45639. private _useLogarithmicDepth;
  45640. /**
  45641. * If set to true, no lighting calculations will be applied.
  45642. */
  45643. private _unlit;
  45644. /**
  45645. * Instantiates a new PBRMaterial instance.
  45646. *
  45647. * @param name The material name
  45648. * @param scene The scene the material will be use in.
  45649. */
  45650. constructor(name: string, scene: Scene);
  45651. /**
  45652. * Gets a boolean indicating that current material needs to register RTT
  45653. */
  45654. readonly hasRenderTargetTextures: boolean;
  45655. /**
  45656. * Gets the name of the material class.
  45657. */
  45658. getClassName(): string;
  45659. /**
  45660. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45661. */
  45662. /**
  45663. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45664. */
  45665. useLogarithmicDepth: boolean;
  45666. /**
  45667. * Gets the current transparency mode.
  45668. */
  45669. /**
  45670. * Sets the transparency mode of the material.
  45671. *
  45672. * | Value | Type | Description |
  45673. * | ----- | ----------------------------------- | ----------- |
  45674. * | 0 | OPAQUE | |
  45675. * | 1 | ALPHATEST | |
  45676. * | 2 | ALPHABLEND | |
  45677. * | 3 | ALPHATESTANDBLEND | |
  45678. *
  45679. */
  45680. transparencyMode: Nullable<number>;
  45681. /**
  45682. * Returns true if alpha blending should be disabled.
  45683. */
  45684. private readonly _disableAlphaBlending;
  45685. /**
  45686. * Specifies whether or not this material should be rendered in alpha blend mode.
  45687. */
  45688. needAlphaBlending(): boolean;
  45689. /**
  45690. * Specifies if the mesh will require alpha blending.
  45691. * @param mesh - BJS mesh.
  45692. */
  45693. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45694. /**
  45695. * Specifies whether or not this material should be rendered in alpha test mode.
  45696. */
  45697. needAlphaTesting(): boolean;
  45698. /**
  45699. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45700. */
  45701. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45702. /**
  45703. * Gets the texture used for the alpha test.
  45704. */
  45705. getAlphaTestTexture(): BaseTexture;
  45706. /**
  45707. * Stores the reflectivity values based on metallic roughness workflow.
  45708. */
  45709. private static _scaledReflectivity;
  45710. /**
  45711. * Specifies that the submesh is ready to be used.
  45712. * @param mesh - BJS mesh.
  45713. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45714. * @param useInstances - Specifies that instances should be used.
  45715. * @returns - boolean indicating that the submesh is ready or not.
  45716. */
  45717. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45718. /**
  45719. * Specifies if the material uses metallic roughness workflow.
  45720. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45721. */
  45722. isMetallicWorkflow(): boolean;
  45723. private _prepareEffect;
  45724. private _prepareDefines;
  45725. /**
  45726. * Force shader compilation
  45727. */
  45728. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45729. clipPlane: boolean;
  45730. }>): void;
  45731. /**
  45732. * Initializes the uniform buffer layout for the shader.
  45733. */
  45734. buildUniformLayout(): void;
  45735. /**
  45736. * Unbinds the textures.
  45737. */
  45738. unbind(): void;
  45739. /**
  45740. * Binds the submesh data.
  45741. * @param world - The world matrix.
  45742. * @param mesh - The BJS mesh.
  45743. * @param subMesh - A submesh of the BJS mesh.
  45744. */
  45745. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45746. /**
  45747. * Returns the animatable textures.
  45748. * @returns - Array of animatable textures.
  45749. */
  45750. getAnimatables(): IAnimatable[];
  45751. /**
  45752. * Returns the texture used for reflections.
  45753. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45754. */
  45755. private _getReflectionTexture;
  45756. /**
  45757. * Returns the texture used for refraction or null if none is used.
  45758. * @returns - Refection texture if present. If no refraction texture and refraction
  45759. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45760. */
  45761. private _getRefractionTexture;
  45762. /**
  45763. * Disposes the resources of the material.
  45764. * @param forceDisposeEffect - Forces the disposal of effects.
  45765. * @param forceDisposeTextures - Forces the disposal of all textures.
  45766. */
  45767. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45768. }
  45769. }
  45770. declare module BABYLON {
  45771. /**
  45772. * The Physically based simple base material of BJS.
  45773. *
  45774. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45775. * It is used as the base class for both the specGloss and metalRough conventions.
  45776. */
  45777. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45778. /**
  45779. * Number of Simultaneous lights allowed on the material.
  45780. */
  45781. maxSimultaneousLights: number;
  45782. /**
  45783. * If sets to true, disables all the lights affecting the material.
  45784. */
  45785. disableLighting: boolean;
  45786. /**
  45787. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45788. */
  45789. environmentTexture: BaseTexture;
  45790. /**
  45791. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45792. */
  45793. invertNormalMapX: boolean;
  45794. /**
  45795. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45796. */
  45797. invertNormalMapY: boolean;
  45798. /**
  45799. * Normal map used in the model.
  45800. */
  45801. normalTexture: BaseTexture;
  45802. /**
  45803. * Emissivie color used to self-illuminate the model.
  45804. */
  45805. emissiveColor: Color3;
  45806. /**
  45807. * Emissivie texture used to self-illuminate the model.
  45808. */
  45809. emissiveTexture: BaseTexture;
  45810. /**
  45811. * Occlusion Channel Strenght.
  45812. */
  45813. occlusionStrength: number;
  45814. /**
  45815. * Occlusion Texture of the material (adding extra occlusion effects).
  45816. */
  45817. occlusionTexture: BaseTexture;
  45818. /**
  45819. * Defines the alpha limits in alpha test mode.
  45820. */
  45821. alphaCutOff: number;
  45822. /**
  45823. * Gets the current double sided mode.
  45824. */
  45825. /**
  45826. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45827. */
  45828. doubleSided: boolean;
  45829. /**
  45830. * Stores the pre-calculated light information of a mesh in a texture.
  45831. */
  45832. lightmapTexture: BaseTexture;
  45833. /**
  45834. * If true, the light map contains occlusion information instead of lighting info.
  45835. */
  45836. useLightmapAsShadowmap: boolean;
  45837. /**
  45838. * Return the active textures of the material.
  45839. */
  45840. getActiveTextures(): BaseTexture[];
  45841. hasTexture(texture: BaseTexture): boolean;
  45842. /**
  45843. * Instantiates a new PBRMaterial instance.
  45844. *
  45845. * @param name The material name
  45846. * @param scene The scene the material will be use in.
  45847. */
  45848. constructor(name: string, scene: Scene);
  45849. getClassName(): string;
  45850. }
  45851. }
  45852. declare module BABYLON {
  45853. /**
  45854. * The Physically based material of BJS.
  45855. *
  45856. * This offers the main features of a standard PBR material.
  45857. * For more information, please refer to the documentation :
  45858. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45859. */
  45860. class PBRMaterial extends PBRBaseMaterial {
  45861. /**
  45862. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45863. */
  45864. static readonly PBRMATERIAL_OPAQUE: number;
  45865. /**
  45866. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45867. */
  45868. static readonly PBRMATERIAL_ALPHATEST: number;
  45869. /**
  45870. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45871. */
  45872. static readonly PBRMATERIAL_ALPHABLEND: number;
  45873. /**
  45874. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45875. * They are also discarded below the alpha cutoff threshold to improve performances.
  45876. */
  45877. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45878. /**
  45879. * Defines the default value of how much AO map is occluding the analytical lights
  45880. * (point spot...).
  45881. */
  45882. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45883. /**
  45884. * Intensity of the direct lights e.g. the four lights available in your scene.
  45885. * This impacts both the direct diffuse and specular highlights.
  45886. */
  45887. directIntensity: number;
  45888. /**
  45889. * Intensity of the emissive part of the material.
  45890. * This helps controlling the emissive effect without modifying the emissive color.
  45891. */
  45892. emissiveIntensity: number;
  45893. /**
  45894. * Intensity of the environment e.g. how much the environment will light the object
  45895. * either through harmonics for rough material or through the refelction for shiny ones.
  45896. */
  45897. environmentIntensity: number;
  45898. /**
  45899. * This is a special control allowing the reduction of the specular highlights coming from the
  45900. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45901. */
  45902. specularIntensity: number;
  45903. /**
  45904. * Debug Control allowing disabling the bump map on this material.
  45905. */
  45906. disableBumpMap: boolean;
  45907. /**
  45908. * AKA Diffuse Texture in standard nomenclature.
  45909. */
  45910. albedoTexture: BaseTexture;
  45911. /**
  45912. * AKA Occlusion Texture in other nomenclature.
  45913. */
  45914. ambientTexture: BaseTexture;
  45915. /**
  45916. * AKA Occlusion Texture Intensity in other nomenclature.
  45917. */
  45918. ambientTextureStrength: number;
  45919. /**
  45920. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45921. * 1 means it completely occludes it
  45922. * 0 mean it has no impact
  45923. */
  45924. ambientTextureImpactOnAnalyticalLights: number;
  45925. /**
  45926. * Stores the alpha values in a texture.
  45927. */
  45928. opacityTexture: BaseTexture;
  45929. /**
  45930. * Stores the reflection values in a texture.
  45931. */
  45932. reflectionTexture: Nullable<BaseTexture>;
  45933. /**
  45934. * Stores the emissive values in a texture.
  45935. */
  45936. emissiveTexture: BaseTexture;
  45937. /**
  45938. * AKA Specular texture in other nomenclature.
  45939. */
  45940. reflectivityTexture: BaseTexture;
  45941. /**
  45942. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45943. */
  45944. metallicTexture: BaseTexture;
  45945. /**
  45946. * Specifies the metallic scalar of the metallic/roughness workflow.
  45947. * Can also be used to scale the metalness values of the metallic texture.
  45948. */
  45949. metallic: Nullable<number>;
  45950. /**
  45951. * Specifies the roughness scalar of the metallic/roughness workflow.
  45952. * Can also be used to scale the roughness values of the metallic texture.
  45953. */
  45954. roughness: Nullable<number>;
  45955. /**
  45956. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45957. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45958. */
  45959. microSurfaceTexture: BaseTexture;
  45960. /**
  45961. * Stores surface normal data used to displace a mesh in a texture.
  45962. */
  45963. bumpTexture: BaseTexture;
  45964. /**
  45965. * Stores the pre-calculated light information of a mesh in a texture.
  45966. */
  45967. lightmapTexture: BaseTexture;
  45968. /**
  45969. * Stores the refracted light information in a texture.
  45970. */
  45971. refractionTexture: BaseTexture;
  45972. /**
  45973. * The color of a material in ambient lighting.
  45974. */
  45975. ambientColor: Color3;
  45976. /**
  45977. * AKA Diffuse Color in other nomenclature.
  45978. */
  45979. albedoColor: Color3;
  45980. /**
  45981. * AKA Specular Color in other nomenclature.
  45982. */
  45983. reflectivityColor: Color3;
  45984. /**
  45985. * The color reflected from the material.
  45986. */
  45987. reflectionColor: Color3;
  45988. /**
  45989. * The color emitted from the material.
  45990. */
  45991. emissiveColor: Color3;
  45992. /**
  45993. * AKA Glossiness in other nomenclature.
  45994. */
  45995. microSurface: number;
  45996. /**
  45997. * source material index of refraction (IOR)' / 'destination material IOR.
  45998. */
  45999. indexOfRefraction: number;
  46000. /**
  46001. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46002. */
  46003. invertRefractionY: boolean;
  46004. /**
  46005. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46006. * Materials half opaque for instance using refraction could benefit from this control.
  46007. */
  46008. linkRefractionWithTransparency: boolean;
  46009. /**
  46010. * If true, the light map contains occlusion information instead of lighting info.
  46011. */
  46012. useLightmapAsShadowmap: boolean;
  46013. /**
  46014. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46015. */
  46016. useAlphaFromAlbedoTexture: boolean;
  46017. /**
  46018. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46019. */
  46020. forceAlphaTest: boolean;
  46021. /**
  46022. * Defines the alpha limits in alpha test mode.
  46023. */
  46024. alphaCutOff: number;
  46025. /**
  46026. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46027. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46028. */
  46029. useSpecularOverAlpha: boolean;
  46030. /**
  46031. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46032. */
  46033. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46034. /**
  46035. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46036. */
  46037. useRoughnessFromMetallicTextureAlpha: boolean;
  46038. /**
  46039. * Specifies if the metallic texture contains the roughness information in its green channel.
  46040. */
  46041. useRoughnessFromMetallicTextureGreen: boolean;
  46042. /**
  46043. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46044. */
  46045. useMetallnessFromMetallicTextureBlue: boolean;
  46046. /**
  46047. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46048. */
  46049. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46050. /**
  46051. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46052. */
  46053. useAmbientInGrayScale: boolean;
  46054. /**
  46055. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46056. * The material will try to infer what glossiness each pixel should be.
  46057. */
  46058. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46059. /**
  46060. * BJS is using an harcoded light falloff based on a manually sets up range.
  46061. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46062. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46063. */
  46064. /**
  46065. * BJS is using an harcoded light falloff based on a manually sets up range.
  46066. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46067. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46068. */
  46069. usePhysicalLightFalloff: boolean;
  46070. /**
  46071. * In order to support the falloff compatibility with gltf, a special mode has been added
  46072. * to reproduce the gltf light falloff.
  46073. */
  46074. /**
  46075. * In order to support the falloff compatibility with gltf, a special mode has been added
  46076. * to reproduce the gltf light falloff.
  46077. */
  46078. useGLTFLightFalloff: boolean;
  46079. /**
  46080. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46081. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46082. */
  46083. useRadianceOverAlpha: boolean;
  46084. /**
  46085. * Allows using an object space normal map (instead of tangent space).
  46086. */
  46087. useObjectSpaceNormalMap: boolean;
  46088. /**
  46089. * Allows using the bump map in parallax mode.
  46090. */
  46091. useParallax: boolean;
  46092. /**
  46093. * Allows using the bump map in parallax occlusion mode.
  46094. */
  46095. useParallaxOcclusion: boolean;
  46096. /**
  46097. * Controls the scale bias of the parallax mode.
  46098. */
  46099. parallaxScaleBias: number;
  46100. /**
  46101. * If sets to true, disables all the lights affecting the material.
  46102. */
  46103. disableLighting: boolean;
  46104. /**
  46105. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46106. */
  46107. forceIrradianceInFragment: boolean;
  46108. /**
  46109. * Number of Simultaneous lights allowed on the material.
  46110. */
  46111. maxSimultaneousLights: number;
  46112. /**
  46113. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46114. */
  46115. invertNormalMapX: boolean;
  46116. /**
  46117. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46118. */
  46119. invertNormalMapY: boolean;
  46120. /**
  46121. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46122. */
  46123. twoSidedLighting: boolean;
  46124. /**
  46125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46126. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46127. */
  46128. useAlphaFresnel: boolean;
  46129. /**
  46130. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46131. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46132. */
  46133. useLinearAlphaFresnel: boolean;
  46134. /**
  46135. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46136. * And/Or occlude the blended part.
  46137. */
  46138. environmentBRDFTexture: Nullable<BaseTexture>;
  46139. /**
  46140. * Force normal to face away from face.
  46141. */
  46142. forceNormalForward: boolean;
  46143. /**
  46144. * Enables specular anti aliasing in the PBR shader.
  46145. * It will both interacts on the Geometry for analytical and IBL lighting.
  46146. * It also prefilter the roughness map based on the bump values.
  46147. */
  46148. enableSpecularAntiAliasing: boolean;
  46149. /**
  46150. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46151. * makes the reflect vector face the model (under horizon).
  46152. */
  46153. useHorizonOcclusion: boolean;
  46154. /**
  46155. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46156. * too much the area relying on ambient texture to define their ambient occlusion.
  46157. */
  46158. useRadianceOcclusion: boolean;
  46159. /**
  46160. * If set to true, no lighting calculations will be applied.
  46161. */
  46162. unlit: boolean;
  46163. /**
  46164. * Gets the image processing configuration used either in this material.
  46165. */
  46166. /**
  46167. * Sets the Default image processing configuration used either in the this material.
  46168. *
  46169. * If sets to null, the scene one is in use.
  46170. */
  46171. imageProcessingConfiguration: ImageProcessingConfiguration;
  46172. /**
  46173. * Gets wether the color curves effect is enabled.
  46174. */
  46175. /**
  46176. * Sets wether the color curves effect is enabled.
  46177. */
  46178. cameraColorCurvesEnabled: boolean;
  46179. /**
  46180. * Gets wether the color grading effect is enabled.
  46181. */
  46182. /**
  46183. * Gets wether the color grading effect is enabled.
  46184. */
  46185. cameraColorGradingEnabled: boolean;
  46186. /**
  46187. * Gets wether tonemapping is enabled or not.
  46188. */
  46189. /**
  46190. * Sets wether tonemapping is enabled or not
  46191. */
  46192. cameraToneMappingEnabled: boolean;
  46193. /**
  46194. * The camera exposure used on this material.
  46195. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46196. * This corresponds to a photographic exposure.
  46197. */
  46198. /**
  46199. * The camera exposure used on this material.
  46200. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46201. * This corresponds to a photographic exposure.
  46202. */
  46203. cameraExposure: number;
  46204. /**
  46205. * Gets The camera contrast used on this material.
  46206. */
  46207. /**
  46208. * Sets The camera contrast used on this material.
  46209. */
  46210. cameraContrast: number;
  46211. /**
  46212. * Gets the Color Grading 2D Lookup Texture.
  46213. */
  46214. /**
  46215. * Sets the Color Grading 2D Lookup Texture.
  46216. */
  46217. cameraColorGradingTexture: Nullable<BaseTexture>;
  46218. /**
  46219. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46220. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46221. * 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;
  46222. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46223. */
  46224. /**
  46225. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46226. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46227. * 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;
  46228. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46229. */
  46230. cameraColorCurves: Nullable<ColorCurves>;
  46231. /**
  46232. * Instantiates a new PBRMaterial instance.
  46233. *
  46234. * @param name The material name
  46235. * @param scene The scene the material will be use in.
  46236. */
  46237. constructor(name: string, scene: Scene);
  46238. /**
  46239. * Returns the name of this material class.
  46240. */
  46241. getClassName(): string;
  46242. /**
  46243. * Returns an array of the actively used textures.
  46244. * @returns - Array of BaseTextures
  46245. */
  46246. getActiveTextures(): BaseTexture[];
  46247. /**
  46248. * Checks to see if a texture is used in the material.
  46249. * @param texture - Base texture to use.
  46250. * @returns - Boolean specifying if a texture is used in the material.
  46251. */
  46252. hasTexture(texture: BaseTexture): boolean;
  46253. /**
  46254. * Makes a duplicate of the current material.
  46255. * @param name - name to use for the new material.
  46256. */
  46257. clone(name: string): PBRMaterial;
  46258. /**
  46259. * Serializes this PBR Material.
  46260. * @returns - An object with the serialized material.
  46261. */
  46262. serialize(): any;
  46263. /**
  46264. * Parses a PBR Material from a serialized object.
  46265. * @param source - Serialized object.
  46266. * @param scene - BJS scene instance.
  46267. * @param rootUrl - url for the scene object
  46268. * @returns - PBRMaterial
  46269. */
  46270. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46271. }
  46272. }
  46273. declare module BABYLON {
  46274. /**
  46275. * The PBR material of BJS following the metal roughness convention.
  46276. *
  46277. * This fits to the PBR convention in the GLTF definition:
  46278. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46279. */
  46280. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46281. /**
  46282. * The base color has two different interpretations depending on the value of metalness.
  46283. * When the material is a metal, the base color is the specific measured reflectance value
  46284. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46285. * of the material.
  46286. */
  46287. baseColor: Color3;
  46288. /**
  46289. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46290. * well as opacity information in the alpha channel.
  46291. */
  46292. baseTexture: BaseTexture;
  46293. /**
  46294. * Specifies the metallic scalar value of the material.
  46295. * Can also be used to scale the metalness values of the metallic texture.
  46296. */
  46297. metallic: number;
  46298. /**
  46299. * Specifies the roughness scalar value of the material.
  46300. * Can also be used to scale the roughness values of the metallic texture.
  46301. */
  46302. roughness: number;
  46303. /**
  46304. * Texture containing both the metallic value in the B channel and the
  46305. * roughness value in the G channel to keep better precision.
  46306. */
  46307. metallicRoughnessTexture: BaseTexture;
  46308. /**
  46309. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46310. *
  46311. * @param name The material name
  46312. * @param scene The scene the material will be use in.
  46313. */
  46314. constructor(name: string, scene: Scene);
  46315. /**
  46316. * Return the currrent class name of the material.
  46317. */
  46318. getClassName(): string;
  46319. /**
  46320. * Return the active textures of the material.
  46321. */
  46322. getActiveTextures(): BaseTexture[];
  46323. /**
  46324. * Checks to see if a texture is used in the material.
  46325. * @param texture - Base texture to use.
  46326. * @returns - Boolean specifying if a texture is used in the material.
  46327. */
  46328. hasTexture(texture: BaseTexture): boolean;
  46329. /**
  46330. * Makes a duplicate of the current material.
  46331. * @param name - name to use for the new material.
  46332. */
  46333. clone(name: string): PBRMetallicRoughnessMaterial;
  46334. /**
  46335. * Serialize the material to a parsable JSON object.
  46336. */
  46337. serialize(): any;
  46338. /**
  46339. * Parses a JSON object correponding to the serialize function.
  46340. */
  46341. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46342. }
  46343. }
  46344. declare module BABYLON {
  46345. /**
  46346. * The PBR material of BJS following the specular glossiness convention.
  46347. *
  46348. * This fits to the PBR convention in the GLTF definition:
  46349. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46350. */
  46351. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46352. /**
  46353. * Specifies the diffuse color of the material.
  46354. */
  46355. diffuseColor: Color3;
  46356. /**
  46357. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46358. * channel.
  46359. */
  46360. diffuseTexture: BaseTexture;
  46361. /**
  46362. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46363. */
  46364. specularColor: Color3;
  46365. /**
  46366. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46367. */
  46368. glossiness: number;
  46369. /**
  46370. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46371. */
  46372. specularGlossinessTexture: BaseTexture;
  46373. /**
  46374. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46375. *
  46376. * @param name The material name
  46377. * @param scene The scene the material will be use in.
  46378. */
  46379. constructor(name: string, scene: Scene);
  46380. /**
  46381. * Return the currrent class name of the material.
  46382. */
  46383. getClassName(): string;
  46384. /**
  46385. * Return the active textures of the material.
  46386. */
  46387. getActiveTextures(): BaseTexture[];
  46388. /**
  46389. * Checks to see if a texture is used in the material.
  46390. * @param texture - Base texture to use.
  46391. * @returns - Boolean specifying if a texture is used in the material.
  46392. */
  46393. hasTexture(texture: BaseTexture): boolean;
  46394. /**
  46395. * Makes a duplicate of the current material.
  46396. * @param name - name to use for the new material.
  46397. */
  46398. clone(name: string): PBRSpecularGlossinessMaterial;
  46399. /**
  46400. * Serialize the material to a parsable JSON object.
  46401. */
  46402. serialize(): any;
  46403. /**
  46404. * Parses a JSON object correponding to the serialize function.
  46405. */
  46406. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46407. }
  46408. }
  46409. declare module BABYLON {
  46410. /**
  46411. * Base class of all the textures in babylon.
  46412. * It groups all the common properties the materials, post process, lights... might need
  46413. * in order to make a correct use of the texture.
  46414. */
  46415. class BaseTexture {
  46416. /**
  46417. * Default anisotropic filtering level for the application.
  46418. * It is set to 4 as a good tradeoff between perf and quality.
  46419. */
  46420. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46421. /**
  46422. * Gets or sets the unique id of the texture
  46423. */
  46424. uniqueId: number;
  46425. /**
  46426. * Define the name of the texture.
  46427. */
  46428. name: string;
  46429. /**
  46430. * Gets or sets an object used to store user defined information.
  46431. */
  46432. metadata: any;
  46433. /**
  46434. * For internal use only. Please do not use.
  46435. */
  46436. reservedDataStore: any;
  46437. private _hasAlpha;
  46438. /**
  46439. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46440. */
  46441. hasAlpha: boolean;
  46442. /**
  46443. * Defines if the alpha value should be determined via the rgb values.
  46444. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46445. */
  46446. getAlphaFromRGB: boolean;
  46447. /**
  46448. * Intensity or strength of the texture.
  46449. * It is commonly used by materials to fine tune the intensity of the texture
  46450. */
  46451. level: number;
  46452. /**
  46453. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46454. * This is part of the texture as textures usually maps to one uv set.
  46455. */
  46456. coordinatesIndex: number;
  46457. private _coordinatesMode;
  46458. /**
  46459. * How a texture is mapped.
  46460. *
  46461. * | Value | Type | Description |
  46462. * | ----- | ----------------------------------- | ----------- |
  46463. * | 0 | EXPLICIT_MODE | |
  46464. * | 1 | SPHERICAL_MODE | |
  46465. * | 2 | PLANAR_MODE | |
  46466. * | 3 | CUBIC_MODE | |
  46467. * | 4 | PROJECTION_MODE | |
  46468. * | 5 | SKYBOX_MODE | |
  46469. * | 6 | INVCUBIC_MODE | |
  46470. * | 7 | EQUIRECTANGULAR_MODE | |
  46471. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46472. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46473. */
  46474. coordinatesMode: number;
  46475. /**
  46476. * | Value | Type | Description |
  46477. * | ----- | ------------------ | ----------- |
  46478. * | 0 | CLAMP_ADDRESSMODE | |
  46479. * | 1 | WRAP_ADDRESSMODE | |
  46480. * | 2 | MIRROR_ADDRESSMODE | |
  46481. */
  46482. wrapU: number;
  46483. /**
  46484. * | Value | Type | Description |
  46485. * | ----- | ------------------ | ----------- |
  46486. * | 0 | CLAMP_ADDRESSMODE | |
  46487. * | 1 | WRAP_ADDRESSMODE | |
  46488. * | 2 | MIRROR_ADDRESSMODE | |
  46489. */
  46490. wrapV: number;
  46491. /**
  46492. * | Value | Type | Description |
  46493. * | ----- | ------------------ | ----------- |
  46494. * | 0 | CLAMP_ADDRESSMODE | |
  46495. * | 1 | WRAP_ADDRESSMODE | |
  46496. * | 2 | MIRROR_ADDRESSMODE | |
  46497. */
  46498. wrapR: number;
  46499. /**
  46500. * With compliant hardware and browser (supporting anisotropic filtering)
  46501. * this defines the level of anisotropic filtering in the texture.
  46502. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46503. */
  46504. anisotropicFilteringLevel: number;
  46505. /**
  46506. * Define if the texture is a cube texture or if false a 2d texture.
  46507. */
  46508. isCube: boolean;
  46509. /**
  46510. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46511. */
  46512. is3D: boolean;
  46513. /**
  46514. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46515. * HDR texture are usually stored in linear space.
  46516. * This only impacts the PBR and Background materials
  46517. */
  46518. gammaSpace: boolean;
  46519. /**
  46520. * Gets whether or not the texture contains RGBD data.
  46521. */
  46522. readonly isRGBD: boolean;
  46523. /**
  46524. * Is Z inverted in the texture (useful in a cube texture).
  46525. */
  46526. invertZ: boolean;
  46527. /**
  46528. * Are mip maps generated for this texture or not.
  46529. */
  46530. readonly noMipmap: boolean;
  46531. /**
  46532. * @hidden
  46533. */
  46534. lodLevelInAlpha: boolean;
  46535. /**
  46536. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46537. */
  46538. lodGenerationOffset: number;
  46539. /**
  46540. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46541. */
  46542. lodGenerationScale: number;
  46543. /**
  46544. * Define if the texture is a render target.
  46545. */
  46546. isRenderTarget: boolean;
  46547. /**
  46548. * Define the unique id of the texture in the scene.
  46549. */
  46550. readonly uid: string;
  46551. /**
  46552. * Return a string representation of the texture.
  46553. * @returns the texture as a string
  46554. */
  46555. toString(): string;
  46556. /**
  46557. * Get the class name of the texture.
  46558. * @returns "BaseTexture"
  46559. */
  46560. getClassName(): string;
  46561. /**
  46562. * Define the list of animation attached to the texture.
  46563. */
  46564. animations: Animation[];
  46565. /**
  46566. * An event triggered when the texture is disposed.
  46567. */
  46568. onDisposeObservable: Observable<BaseTexture>;
  46569. private _onDisposeObserver;
  46570. /**
  46571. * Callback triggered when the texture has been disposed.
  46572. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46573. */
  46574. onDispose: () => void;
  46575. /**
  46576. * Define the current state of the loading sequence when in delayed load mode.
  46577. */
  46578. delayLoadState: number;
  46579. private _scene;
  46580. /** @hidden */
  46581. _texture: Nullable<InternalTexture>;
  46582. private _uid;
  46583. /**
  46584. * Define if the texture is preventinga material to render or not.
  46585. * If not and the texture is not ready, the engine will use a default black texture instead.
  46586. */
  46587. readonly isBlocking: boolean;
  46588. /**
  46589. * Instantiates a new BaseTexture.
  46590. * Base class of all the textures in babylon.
  46591. * It groups all the common properties the materials, post process, lights... might need
  46592. * in order to make a correct use of the texture.
  46593. * @param scene Define the scene the texture blongs to
  46594. */
  46595. constructor(scene: Nullable<Scene>);
  46596. /**
  46597. * Get the scene the texture belongs to.
  46598. * @returns the scene or null if undefined
  46599. */
  46600. getScene(): Nullable<Scene>;
  46601. /**
  46602. * Get the texture transform matrix used to offset tile the texture for istance.
  46603. * @returns the transformation matrix
  46604. */
  46605. getTextureMatrix(): Matrix;
  46606. /**
  46607. * Get the texture reflection matrix used to rotate/transform the reflection.
  46608. * @returns the reflection matrix
  46609. */
  46610. getReflectionTextureMatrix(): Matrix;
  46611. /**
  46612. * Get the underlying lower level texture from Babylon.
  46613. * @returns the insternal texture
  46614. */
  46615. getInternalTexture(): Nullable<InternalTexture>;
  46616. /**
  46617. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46618. * @returns true if ready or not blocking
  46619. */
  46620. isReadyOrNotBlocking(): boolean;
  46621. /**
  46622. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46623. * @returns true if fully ready
  46624. */
  46625. isReady(): boolean;
  46626. private _cachedSize;
  46627. /**
  46628. * Get the size of the texture.
  46629. * @returns the texture size.
  46630. */
  46631. getSize(): ISize;
  46632. /**
  46633. * Get the base size of the texture.
  46634. * It can be different from the size if the texture has been resized for POT for instance
  46635. * @returns the base size
  46636. */
  46637. getBaseSize(): ISize;
  46638. /**
  46639. * Update the sampling mode of the texture.
  46640. * Default is Trilinear mode.
  46641. *
  46642. * | Value | Type | Description |
  46643. * | ----- | ------------------ | ----------- |
  46644. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46645. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46646. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46647. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46648. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46649. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46650. * | 7 | NEAREST_LINEAR | |
  46651. * | 8 | NEAREST_NEAREST | |
  46652. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46653. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46654. * | 11 | LINEAR_LINEAR | |
  46655. * | 12 | LINEAR_NEAREST | |
  46656. *
  46657. * > _mag_: magnification filter (close to the viewer)
  46658. * > _min_: minification filter (far from the viewer)
  46659. * > _mip_: filter used between mip map levels
  46660. *@param samplingMode Define the new sampling mode of the texture
  46661. */
  46662. updateSamplingMode(samplingMode: number): void;
  46663. /**
  46664. * Scales the texture if is `canRescale()`
  46665. * @param ratio the resize factor we want to use to rescale
  46666. */
  46667. scale(ratio: number): void;
  46668. /**
  46669. * Get if the texture can rescale.
  46670. */
  46671. readonly canRescale: boolean;
  46672. /** @hidden */
  46673. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46674. /** @hidden */
  46675. _rebuild(): void;
  46676. /**
  46677. * Triggers the load sequence in delayed load mode.
  46678. */
  46679. delayLoad(): void;
  46680. /**
  46681. * Clones the texture.
  46682. * @returns the cloned texture
  46683. */
  46684. clone(): Nullable<BaseTexture>;
  46685. /**
  46686. * Get the texture underlying type (INT, FLOAT...)
  46687. */
  46688. readonly textureType: number;
  46689. /**
  46690. * Get the texture underlying format (RGB, RGBA...)
  46691. */
  46692. readonly textureFormat: number;
  46693. /**
  46694. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46695. * This will returns an RGBA array buffer containing either in values (0-255) or
  46696. * float values (0-1) depending of the underlying buffer type.
  46697. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46698. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46699. * @param buffer defines a user defined buffer to fill with data (can be null)
  46700. * @returns The Array buffer containing the pixels data.
  46701. */
  46702. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46703. /**
  46704. * Release and destroy the underlying lower level texture aka internalTexture.
  46705. */
  46706. releaseInternalTexture(): void;
  46707. /**
  46708. * Get the polynomial representation of the texture data.
  46709. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46710. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46711. */
  46712. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46713. /** @hidden */
  46714. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46715. /** @hidden */
  46716. readonly _lodTextureMid: Nullable<BaseTexture>;
  46717. /** @hidden */
  46718. readonly _lodTextureLow: Nullable<BaseTexture>;
  46719. /**
  46720. * Dispose the texture and release its associated resources.
  46721. */
  46722. dispose(): void;
  46723. /**
  46724. * Serialize the texture into a JSON representation that can be parsed later on.
  46725. * @returns the JSON representation of the texture
  46726. */
  46727. serialize(): any;
  46728. /**
  46729. * Helper function to be called back once a list of texture contains only ready textures.
  46730. * @param textures Define the list of textures to wait for
  46731. * @param callback Define the callback triggered once the entire list will be ready
  46732. */
  46733. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46734. }
  46735. }
  46736. declare module BABYLON {
  46737. /**
  46738. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46739. * It can help converting any input color in a desired output one. This can then be used to create effects
  46740. * from sepia, black and white to sixties or futuristic rendering...
  46741. *
  46742. * The only supported format is currently 3dl.
  46743. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46744. */
  46745. class ColorGradingTexture extends BaseTexture {
  46746. /**
  46747. * The current texture matrix. (will always be identity in color grading texture)
  46748. */
  46749. private _textureMatrix;
  46750. /**
  46751. * The texture URL.
  46752. */
  46753. url: string;
  46754. /**
  46755. * Empty line regex stored for GC.
  46756. */
  46757. private static _noneEmptyLineRegex;
  46758. private _engine;
  46759. /**
  46760. * Instantiates a ColorGradingTexture from the following parameters.
  46761. *
  46762. * @param url The location of the color gradind data (currently only supporting 3dl)
  46763. * @param scene The scene the texture will be used in
  46764. */
  46765. constructor(url: string, scene: Scene);
  46766. /**
  46767. * Returns the texture matrix used in most of the material.
  46768. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46769. */
  46770. getTextureMatrix(): Matrix;
  46771. /**
  46772. * Occurs when the file being loaded is a .3dl LUT file.
  46773. */
  46774. private load3dlTexture;
  46775. /**
  46776. * Starts the loading process of the texture.
  46777. */
  46778. private loadTexture;
  46779. /**
  46780. * Clones the color gradind texture.
  46781. */
  46782. clone(): ColorGradingTexture;
  46783. /**
  46784. * Called during delayed load for textures.
  46785. */
  46786. delayLoad(): void;
  46787. /**
  46788. * Parses a color grading texture serialized by Babylon.
  46789. * @param parsedTexture The texture information being parsedTexture
  46790. * @param scene The scene to load the texture in
  46791. * @param rootUrl The root url of the data assets to load
  46792. * @return A color gradind texture
  46793. */
  46794. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46795. /**
  46796. * Serializes the LUT texture to json format.
  46797. */
  46798. serialize(): any;
  46799. }
  46800. }
  46801. declare module BABYLON {
  46802. /**
  46803. * Class for creating a cube texture
  46804. */
  46805. class CubeTexture extends BaseTexture {
  46806. private _delayedOnLoad;
  46807. /**
  46808. * The url of the texture
  46809. */
  46810. url: string;
  46811. /**
  46812. * Gets or sets the center of the bounding box associated with the cube texture.
  46813. * It must define where the camera used to render the texture was set
  46814. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46815. */
  46816. boundingBoxPosition: Vector3;
  46817. private _boundingBoxSize;
  46818. /**
  46819. * Gets or sets the size of the bounding box associated with the cube texture
  46820. * When defined, the cubemap will switch to local mode
  46821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46822. * @example https://www.babylonjs-playground.com/#RNASML
  46823. */
  46824. /**
  46825. * Returns the bounding box size
  46826. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46827. */
  46828. boundingBoxSize: Vector3;
  46829. protected _rotationY: number;
  46830. /**
  46831. * Sets texture matrix rotation angle around Y axis in radians.
  46832. */
  46833. /**
  46834. * Gets texture matrix rotation angle around Y axis radians.
  46835. */
  46836. rotationY: number;
  46837. /**
  46838. * Are mip maps generated for this texture or not.
  46839. */
  46840. readonly noMipmap: boolean;
  46841. private _noMipmap;
  46842. private _files;
  46843. private _extensions;
  46844. private _textureMatrix;
  46845. private _format;
  46846. private _createPolynomials;
  46847. /** @hidden */
  46848. _prefiltered: boolean;
  46849. /**
  46850. * Creates a cube texture from an array of image urls
  46851. * @param files defines an array of image urls
  46852. * @param scene defines the hosting scene
  46853. * @param noMipmap specifies if mip maps are not used
  46854. * @returns a cube texture
  46855. */
  46856. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46857. /**
  46858. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46859. * @param url defines the url of the prefiltered texture
  46860. * @param scene defines the scene the texture is attached to
  46861. * @param forcedExtension defines the extension of the file if different from the url
  46862. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46863. * @return the prefiltered texture
  46864. */
  46865. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46866. /**
  46867. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46868. * as prefiltered data.
  46869. * @param rootUrl defines the url of the texture or the root name of the six images
  46870. * @param scene defines the scene the texture is attached to
  46871. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46872. * @param noMipmap defines if mipmaps should be created or not
  46873. * @param files defines the six files to load for the different faces
  46874. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46875. * @param onError defines a callback triggered in case of error during load
  46876. * @param format defines the internal format to use for the texture once loaded
  46877. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46878. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46879. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46880. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46881. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46882. * @return the cube texture
  46883. */
  46884. 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);
  46885. /**
  46886. * Get the current class name of the texture useful for serialization or dynamic coding.
  46887. * @returns "CubeTexture"
  46888. */
  46889. getClassName(): string;
  46890. /**
  46891. * Update the url (and optional buffer) of this texture if url was null during construction.
  46892. * @param url the url of the texture
  46893. * @param forcedExtension defines the extension to use
  46894. * @param onLoad callback called when the texture is loaded (defaults to null)
  46895. */
  46896. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46897. /**
  46898. * Delays loading of the cube texture
  46899. * @param forcedExtension defines the extension to use
  46900. */
  46901. delayLoad(forcedExtension?: string): void;
  46902. /**
  46903. * Returns the reflection texture matrix
  46904. * @returns the reflection texture matrix
  46905. */
  46906. getReflectionTextureMatrix(): Matrix;
  46907. /**
  46908. * Sets the reflection texture matrix
  46909. * @param value Reflection texture matrix
  46910. */
  46911. setReflectionTextureMatrix(value: Matrix): void;
  46912. /**
  46913. * Parses text to create a cube texture
  46914. * @param parsedTexture define the serialized text to read from
  46915. * @param scene defines the hosting scene
  46916. * @param rootUrl defines the root url of the cube texture
  46917. * @returns a cube texture
  46918. */
  46919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46920. /**
  46921. * Makes a clone, or deep copy, of the cube texture
  46922. * @returns a new cube texture
  46923. */
  46924. clone(): CubeTexture;
  46925. }
  46926. }
  46927. declare module BABYLON {
  46928. /**
  46929. * A class extending Texture allowing drawing on a texture
  46930. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46931. */
  46932. class DynamicTexture extends Texture {
  46933. private _generateMipMaps;
  46934. private _canvas;
  46935. private _context;
  46936. private _engine;
  46937. /**
  46938. * Creates a DynamicTexture
  46939. * @param name defines the name of the texture
  46940. * @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
  46941. * @param scene defines the scene where you want the texture
  46942. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46943. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46944. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46945. */
  46946. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46947. /**
  46948. * Get the current class name of the texture useful for serialization or dynamic coding.
  46949. * @returns "DynamicTexture"
  46950. */
  46951. getClassName(): string;
  46952. /**
  46953. * Gets the current state of canRescale
  46954. */
  46955. readonly canRescale: boolean;
  46956. private _recreate;
  46957. /**
  46958. * Scales the texture
  46959. * @param ratio the scale factor to apply to both width and height
  46960. */
  46961. scale(ratio: number): void;
  46962. /**
  46963. * Resizes the texture
  46964. * @param width the new width
  46965. * @param height the new height
  46966. */
  46967. scaleTo(width: number, height: number): void;
  46968. /**
  46969. * Gets the context of the canvas used by the texture
  46970. * @returns the canvas context of the dynamic texture
  46971. */
  46972. getContext(): CanvasRenderingContext2D;
  46973. /**
  46974. * Clears the texture
  46975. */
  46976. clear(): void;
  46977. /**
  46978. * Updates the texture
  46979. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46980. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46981. */
  46982. update(invertY?: boolean, premulAlpha?: boolean): void;
  46983. /**
  46984. * Draws text onto the texture
  46985. * @param text defines the text to be drawn
  46986. * @param x defines the placement of the text from the left
  46987. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46988. * @param font defines the font to be used with font-style, font-size, font-name
  46989. * @param color defines the color used for the text
  46990. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46991. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46992. * @param update defines whether texture is immediately update (default is true)
  46993. */
  46994. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46995. /**
  46996. * Clones the texture
  46997. * @returns the clone of the texture.
  46998. */
  46999. clone(): DynamicTexture;
  47000. /**
  47001. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47002. * @returns a serialized dynamic texture object
  47003. */
  47004. serialize(): any;
  47005. /** @hidden */
  47006. _rebuild(): void;
  47007. }
  47008. }
  47009. declare module BABYLON {
  47010. /**
  47011. * This represents a texture coming from an HDR input.
  47012. *
  47013. * The only supported format is currently panorama picture stored in RGBE format.
  47014. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47015. */
  47016. class HDRCubeTexture extends BaseTexture {
  47017. private static _facesMapping;
  47018. private _generateHarmonics;
  47019. private _noMipmap;
  47020. private _textureMatrix;
  47021. private _size;
  47022. private _onLoad;
  47023. private _onError;
  47024. /**
  47025. * The texture URL.
  47026. */
  47027. url: string;
  47028. /**
  47029. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47030. */
  47031. coordinatesMode: number;
  47032. protected _isBlocking: boolean;
  47033. /**
  47034. * Sets wether or not the texture is blocking during loading.
  47035. */
  47036. /**
  47037. * Gets wether or not the texture is blocking during loading.
  47038. */
  47039. isBlocking: boolean;
  47040. protected _rotationY: number;
  47041. /**
  47042. * Sets texture matrix rotation angle around Y axis in radians.
  47043. */
  47044. /**
  47045. * Gets texture matrix rotation angle around Y axis radians.
  47046. */
  47047. rotationY: number;
  47048. /**
  47049. * Gets or sets the center of the bounding box associated with the cube texture
  47050. * It must define where the camera used to render the texture was set
  47051. */
  47052. boundingBoxPosition: Vector3;
  47053. private _boundingBoxSize;
  47054. /**
  47055. * Gets or sets the size of the bounding box associated with the cube texture
  47056. * When defined, the cubemap will switch to local mode
  47057. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47058. * @example https://www.babylonjs-playground.com/#RNASML
  47059. */
  47060. boundingBoxSize: Vector3;
  47061. /**
  47062. * Instantiates an HDRTexture from the following parameters.
  47063. *
  47064. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47065. * @param scene The scene the texture will be used in
  47066. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47067. * @param noMipmap Forces to not generate the mipmap if true
  47068. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47069. * @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)
  47070. * @param reserved Reserved flag for internal use.
  47071. */
  47072. 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>);
  47073. /**
  47074. * Get the current class name of the texture useful for serialization or dynamic coding.
  47075. * @returns "HDRCubeTexture"
  47076. */
  47077. getClassName(): string;
  47078. /**
  47079. * Occurs when the file is raw .hdr file.
  47080. */
  47081. private loadTexture;
  47082. clone(): HDRCubeTexture;
  47083. delayLoad(): void;
  47084. /**
  47085. * Get the texture reflection matrix used to rotate/transform the reflection.
  47086. * @returns the reflection matrix
  47087. */
  47088. getReflectionTextureMatrix(): Matrix;
  47089. /**
  47090. * Set the texture reflection matrix used to rotate/transform the reflection.
  47091. * @param value Define the reflection matrix to set
  47092. */
  47093. setReflectionTextureMatrix(value: Matrix): void;
  47094. /**
  47095. * Parses a JSON representation of an HDR Texture in order to create the texture
  47096. * @param parsedTexture Define the JSON representation
  47097. * @param scene Define the scene the texture should be created in
  47098. * @param rootUrl Define the root url in case we need to load relative dependencies
  47099. * @returns the newly created texture after parsing
  47100. */
  47101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47102. serialize(): any;
  47103. }
  47104. }
  47105. declare module BABYLON {
  47106. /**
  47107. * Class used to store data associated with WebGL texture data for the engine
  47108. * This class should not be used directly
  47109. */
  47110. class InternalTexture implements IInternalTextureTracker {
  47111. /**
  47112. * The source of the texture data is unknown
  47113. */
  47114. static DATASOURCE_UNKNOWN: number;
  47115. /**
  47116. * Texture data comes from an URL
  47117. */
  47118. static DATASOURCE_URL: number;
  47119. /**
  47120. * Texture data is only used for temporary storage
  47121. */
  47122. static DATASOURCE_TEMP: number;
  47123. /**
  47124. * Texture data comes from raw data (ArrayBuffer)
  47125. */
  47126. static DATASOURCE_RAW: number;
  47127. /**
  47128. * Texture content is dynamic (video or dynamic texture)
  47129. */
  47130. static DATASOURCE_DYNAMIC: number;
  47131. /**
  47132. * Texture content is generated by rendering to it
  47133. */
  47134. static DATASOURCE_RENDERTARGET: number;
  47135. /**
  47136. * Texture content is part of a multi render target process
  47137. */
  47138. static DATASOURCE_MULTIRENDERTARGET: number;
  47139. /**
  47140. * Texture data comes from a cube data file
  47141. */
  47142. static DATASOURCE_CUBE: number;
  47143. /**
  47144. * Texture data comes from a raw cube data
  47145. */
  47146. static DATASOURCE_CUBERAW: number;
  47147. /**
  47148. * Texture data come from a prefiltered cube data file
  47149. */
  47150. static DATASOURCE_CUBEPREFILTERED: number;
  47151. /**
  47152. * Texture content is raw 3D data
  47153. */
  47154. static DATASOURCE_RAW3D: number;
  47155. /**
  47156. * Texture content is a depth texture
  47157. */
  47158. static DATASOURCE_DEPTHTEXTURE: number;
  47159. /**
  47160. * Texture data comes from a raw cube data encoded with RGBD
  47161. */
  47162. static DATASOURCE_CUBERAW_RGBD: number;
  47163. /**
  47164. * Defines if the texture is ready
  47165. */
  47166. isReady: boolean;
  47167. /**
  47168. * Defines if the texture is a cube texture
  47169. */
  47170. isCube: boolean;
  47171. /**
  47172. * Defines if the texture contains 3D data
  47173. */
  47174. is3D: boolean;
  47175. /**
  47176. * Gets the URL used to load this texture
  47177. */
  47178. url: string;
  47179. /**
  47180. * Gets the sampling mode of the texture
  47181. */
  47182. samplingMode: number;
  47183. /**
  47184. * Gets a boolean indicating if the texture needs mipmaps generation
  47185. */
  47186. generateMipMaps: boolean;
  47187. /**
  47188. * Gets the number of samples used by the texture (WebGL2+ only)
  47189. */
  47190. samples: number;
  47191. /**
  47192. * Gets the type of the texture (int, float...)
  47193. */
  47194. type: number;
  47195. /**
  47196. * Gets the format of the texture (RGB, RGBA...)
  47197. */
  47198. format: number;
  47199. /**
  47200. * Observable called when the texture is loaded
  47201. */
  47202. onLoadedObservable: Observable<InternalTexture>;
  47203. /**
  47204. * Gets the width of the texture
  47205. */
  47206. width: number;
  47207. /**
  47208. * Gets the height of the texture
  47209. */
  47210. height: number;
  47211. /**
  47212. * Gets the depth of the texture
  47213. */
  47214. depth: number;
  47215. /**
  47216. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47217. */
  47218. baseWidth: number;
  47219. /**
  47220. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47221. */
  47222. baseHeight: number;
  47223. /**
  47224. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47225. */
  47226. baseDepth: number;
  47227. /**
  47228. * Gets a boolean indicating if the texture is inverted on Y axis
  47229. */
  47230. invertY: boolean;
  47231. /**
  47232. * Gets or set the previous tracker in the list
  47233. */
  47234. previous: Nullable<IInternalTextureTracker>;
  47235. /**
  47236. * Gets or set the next tracker in the list
  47237. */
  47238. next: Nullable<IInternalTextureTracker>;
  47239. /** @hidden */
  47240. _invertVScale: boolean;
  47241. /** @hidden */
  47242. _initialSlot: number;
  47243. /** @hidden */
  47244. _designatedSlot: number;
  47245. /** @hidden */
  47246. _dataSource: number;
  47247. /** @hidden */
  47248. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47249. /** @hidden */
  47250. _bufferView: Nullable<ArrayBufferView>;
  47251. /** @hidden */
  47252. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47253. /** @hidden */
  47254. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47255. /** @hidden */
  47256. _size: number;
  47257. /** @hidden */
  47258. _extension: string;
  47259. /** @hidden */
  47260. _files: Nullable<string[]>;
  47261. /** @hidden */
  47262. _workingCanvas: HTMLCanvasElement;
  47263. /** @hidden */
  47264. _workingContext: CanvasRenderingContext2D;
  47265. /** @hidden */
  47266. _framebuffer: Nullable<WebGLFramebuffer>;
  47267. /** @hidden */
  47268. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47269. /** @hidden */
  47270. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47271. /** @hidden */
  47272. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47273. /** @hidden */
  47274. _attachments: Nullable<number[]>;
  47275. /** @hidden */
  47276. _cachedCoordinatesMode: Nullable<number>;
  47277. /** @hidden */
  47278. _cachedWrapU: Nullable<number>;
  47279. /** @hidden */
  47280. _cachedWrapV: Nullable<number>;
  47281. /** @hidden */
  47282. _cachedWrapR: Nullable<number>;
  47283. /** @hidden */
  47284. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47285. /** @hidden */
  47286. _isDisabled: boolean;
  47287. /** @hidden */
  47288. _compression: Nullable<string>;
  47289. /** @hidden */
  47290. _generateStencilBuffer: boolean;
  47291. /** @hidden */
  47292. _generateDepthBuffer: boolean;
  47293. /** @hidden */
  47294. _comparisonFunction: number;
  47295. /** @hidden */
  47296. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47297. /** @hidden */
  47298. _lodGenerationScale: number;
  47299. /** @hidden */
  47300. _lodGenerationOffset: number;
  47301. /** @hidden */
  47302. _lodTextureHigh: BaseTexture;
  47303. /** @hidden */
  47304. _lodTextureMid: BaseTexture;
  47305. /** @hidden */
  47306. _lodTextureLow: BaseTexture;
  47307. /** @hidden */
  47308. _isRGBD: boolean;
  47309. /** @hidden */
  47310. _webGLTexture: Nullable<WebGLTexture>;
  47311. /** @hidden */
  47312. _references: number;
  47313. private _engine;
  47314. /**
  47315. * Gets the Engine the texture belongs to.
  47316. * @returns The babylon engine
  47317. */
  47318. getEngine(): Engine;
  47319. /**
  47320. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47321. */
  47322. readonly dataSource: number;
  47323. /**
  47324. * Creates a new InternalTexture
  47325. * @param engine defines the engine to use
  47326. * @param dataSource defines the type of data that will be used
  47327. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47328. */
  47329. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47330. /**
  47331. * Increments the number of references (ie. the number of Texture that point to it)
  47332. */
  47333. incrementReferences(): void;
  47334. /**
  47335. * Change the size of the texture (not the size of the content)
  47336. * @param width defines the new width
  47337. * @param height defines the new height
  47338. * @param depth defines the new depth (1 by default)
  47339. */
  47340. updateSize(width: int, height: int, depth?: int): void;
  47341. /** @hidden */
  47342. _rebuild(): void;
  47343. /** @hidden */
  47344. _swapAndDie(target: InternalTexture): void;
  47345. /**
  47346. * Dispose the current allocated resources
  47347. */
  47348. dispose(): void;
  47349. }
  47350. }
  47351. declare module BABYLON {
  47352. /**
  47353. * This represents the required contract to create a new type of texture loader.
  47354. */
  47355. interface IInternalTextureLoader {
  47356. /**
  47357. * Defines wether the loader supports cascade loading the different faces.
  47358. */
  47359. supportCascades: boolean;
  47360. /**
  47361. * This returns if the loader support the current file information.
  47362. * @param extension defines the file extension of the file being loaded
  47363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47364. * @param fallback defines the fallback internal texture if any
  47365. * @param isBase64 defines whether the texture is encoded as a base64
  47366. * @param isBuffer defines whether the texture data are stored as a buffer
  47367. * @returns true if the loader can load the specified file
  47368. */
  47369. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47370. /**
  47371. * Transform the url before loading if required.
  47372. * @param rootUrl the url of the texture
  47373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47374. * @returns the transformed texture
  47375. */
  47376. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47377. /**
  47378. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47379. * @param rootUrl the url of the texture
  47380. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47381. * @returns the fallback texture
  47382. */
  47383. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47384. /**
  47385. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47386. * @param data contains the texture data
  47387. * @param texture defines the BabylonJS internal texture
  47388. * @param createPolynomials will be true if polynomials have been requested
  47389. * @param onLoad defines the callback to trigger once the texture is ready
  47390. * @param onError defines the callback to trigger in case of error
  47391. */
  47392. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47393. /**
  47394. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47395. * @param data contains the texture data
  47396. * @param texture defines the BabylonJS internal texture
  47397. * @param callback defines the method to call once ready to upload
  47398. */
  47399. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47400. }
  47401. }
  47402. declare module BABYLON {
  47403. /**
  47404. * Internal interface used to track InternalTexture already bound to the GL context
  47405. */
  47406. interface IInternalTextureTracker {
  47407. /**
  47408. * Gets or set the previous tracker in the list
  47409. */
  47410. previous: Nullable<IInternalTextureTracker>;
  47411. /**
  47412. * Gets or set the next tracker in the list
  47413. */
  47414. next: Nullable<IInternalTextureTracker>;
  47415. }
  47416. /**
  47417. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47418. */
  47419. class DummyInternalTextureTracker {
  47420. /**
  47421. * Gets or set the previous tracker in the list
  47422. */
  47423. previous: Nullable<IInternalTextureTracker>;
  47424. /**
  47425. * Gets or set the next tracker in the list
  47426. */
  47427. next: Nullable<IInternalTextureTracker>;
  47428. }
  47429. }
  47430. declare module BABYLON {
  47431. /**
  47432. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47433. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47434. * You can then easily use it as a reflectionTexture on a flat surface.
  47435. * In case the surface is not a plane, please consider relying on reflection probes.
  47436. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47437. */
  47438. class MirrorTexture extends RenderTargetTexture {
  47439. private scene;
  47440. /**
  47441. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47442. * 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.
  47443. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47444. */
  47445. mirrorPlane: Plane;
  47446. /**
  47447. * Define the blur ratio used to blur the reflection if needed.
  47448. */
  47449. blurRatio: number;
  47450. /**
  47451. * Define the adaptive blur kernel used to blur the reflection if needed.
  47452. * This will autocompute the closest best match for the `blurKernel`
  47453. */
  47454. adaptiveBlurKernel: number;
  47455. /**
  47456. * Define the blur kernel used to blur the reflection if needed.
  47457. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47458. */
  47459. blurKernel: number;
  47460. /**
  47461. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47462. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47463. */
  47464. blurKernelX: number;
  47465. /**
  47466. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47467. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47468. */
  47469. blurKernelY: number;
  47470. private _autoComputeBlurKernel;
  47471. protected _onRatioRescale(): void;
  47472. private _updateGammaSpace;
  47473. private _imageProcessingConfigChangeObserver;
  47474. private _transformMatrix;
  47475. private _mirrorMatrix;
  47476. private _savedViewMatrix;
  47477. private _blurX;
  47478. private _blurY;
  47479. private _adaptiveBlurKernel;
  47480. private _blurKernelX;
  47481. private _blurKernelY;
  47482. private _blurRatio;
  47483. /**
  47484. * Instantiates a Mirror Texture.
  47485. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47486. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47487. * You can then easily use it as a reflectionTexture on a flat surface.
  47488. * In case the surface is not a plane, please consider relying on reflection probes.
  47489. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47490. * @param name
  47491. * @param size
  47492. * @param scene
  47493. * @param generateMipMaps
  47494. * @param type
  47495. * @param samplingMode
  47496. * @param generateDepthBuffer
  47497. */
  47498. constructor(name: string, size: number | {
  47499. width: number;
  47500. height: number;
  47501. } | {
  47502. ratio: number;
  47503. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47504. private _preparePostProcesses;
  47505. /**
  47506. * Clone the mirror texture.
  47507. * @returns the cloned texture
  47508. */
  47509. clone(): MirrorTexture;
  47510. /**
  47511. * Serialize the texture to a JSON representation you could use in Parse later on
  47512. * @returns the serialized JSON representation
  47513. */
  47514. serialize(): any;
  47515. /**
  47516. * Dispose the texture and release its associated resources.
  47517. */
  47518. dispose(): void;
  47519. }
  47520. }
  47521. declare module BABYLON {
  47522. /**
  47523. * Creation options of the multi render target texture.
  47524. */
  47525. interface IMultiRenderTargetOptions {
  47526. /**
  47527. * Define if the texture needs to create mip maps after render.
  47528. */
  47529. generateMipMaps?: boolean;
  47530. /**
  47531. * Define the types of all the draw buffers we want to create
  47532. */
  47533. types?: number[];
  47534. /**
  47535. * Define the sampling modes of all the draw buffers we want to create
  47536. */
  47537. samplingModes?: number[];
  47538. /**
  47539. * Define if a depth buffer is required
  47540. */
  47541. generateDepthBuffer?: boolean;
  47542. /**
  47543. * Define if a stencil buffer is required
  47544. */
  47545. generateStencilBuffer?: boolean;
  47546. /**
  47547. * Define if a depth texture is required instead of a depth buffer
  47548. */
  47549. generateDepthTexture?: boolean;
  47550. /**
  47551. * Define the number of desired draw buffers
  47552. */
  47553. textureCount?: number;
  47554. /**
  47555. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47556. */
  47557. doNotChangeAspectRatio?: boolean;
  47558. /**
  47559. * Define the default type of the buffers we are creating
  47560. */
  47561. defaultType?: number;
  47562. }
  47563. /**
  47564. * A multi render target, like a render target provides the ability to render to a texture.
  47565. * Unlike the render target, it can render to several draw buffers in one draw.
  47566. * This is specially interesting in deferred rendering or for any effects requiring more than
  47567. * just one color from a single pass.
  47568. */
  47569. class MultiRenderTarget extends RenderTargetTexture {
  47570. private _internalTextures;
  47571. private _textures;
  47572. private _multiRenderTargetOptions;
  47573. /**
  47574. * Get if draw buffers are currently supported by the used hardware and browser.
  47575. */
  47576. readonly isSupported: boolean;
  47577. /**
  47578. * Get the list of textures generated by the multi render target.
  47579. */
  47580. readonly textures: Texture[];
  47581. /**
  47582. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47583. */
  47584. readonly depthTexture: Texture;
  47585. /**
  47586. * Set the wrapping mode on U of all the textures we are rendering to.
  47587. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47588. */
  47589. wrapU: number;
  47590. /**
  47591. * Set the wrapping mode on V of all the textures we are rendering to.
  47592. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47593. */
  47594. wrapV: number;
  47595. /**
  47596. * Instantiate a new multi render target texture.
  47597. * A multi render target, like a render target provides the ability to render to a texture.
  47598. * Unlike the render target, it can render to several draw buffers in one draw.
  47599. * This is specially interesting in deferred rendering or for any effects requiring more than
  47600. * just one color from a single pass.
  47601. * @param name Define the name of the texture
  47602. * @param size Define the size of the buffers to render to
  47603. * @param count Define the number of target we are rendering into
  47604. * @param scene Define the scene the texture belongs to
  47605. * @param options Define the options used to create the multi render target
  47606. */
  47607. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47608. /** @hidden */
  47609. _rebuild(): void;
  47610. private _createInternalTextures;
  47611. private _createTextures;
  47612. /**
  47613. * Define the number of samples used if MSAA is enabled.
  47614. */
  47615. samples: number;
  47616. /**
  47617. * Resize all the textures in the multi render target.
  47618. * Be carrefull as it will recreate all the data in the new texture.
  47619. * @param size Define the new size
  47620. */
  47621. resize(size: any): void;
  47622. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47623. /**
  47624. * Dispose the render targets and their associated resources
  47625. */
  47626. dispose(): void;
  47627. /**
  47628. * Release all the underlying texture used as draw buffers.
  47629. */
  47630. releaseInternalTextures(): void;
  47631. }
  47632. }
  47633. declare module BABYLON {
  47634. /**
  47635. * Raw cube texture where the raw buffers are passed in
  47636. */
  47637. class RawCubeTexture extends CubeTexture {
  47638. /**
  47639. * Creates a cube texture where the raw buffers are passed in.
  47640. * @param scene defines the scene the texture is attached to
  47641. * @param data defines the array of data to use to create each face
  47642. * @param size defines the size of the textures
  47643. * @param format defines the format of the data
  47644. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47645. * @param generateMipMaps defines if the engine should generate the mip levels
  47646. * @param invertY defines if data must be stored with Y axis inverted
  47647. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47648. * @param compression defines the compression used (null by default)
  47649. */
  47650. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47651. /**
  47652. * Updates the raw cube texture.
  47653. * @param data defines the data to store
  47654. * @param format defines the data format
  47655. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47656. * @param invertY defines if data must be stored with Y axis inverted
  47657. * @param compression defines the compression used (null by default)
  47658. * @param level defines which level of the texture to update
  47659. */
  47660. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47661. /**
  47662. * Updates a raw cube texture with RGBD encoded data.
  47663. * @param data defines the array of data [mipmap][face] to use to create each face
  47664. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47665. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47666. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47667. * @returns a promsie that resolves when the operation is complete
  47668. */
  47669. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47670. /**
  47671. * Clones the raw cube texture.
  47672. * @return a new cube texture
  47673. */
  47674. clone(): CubeTexture;
  47675. /** @hidden */
  47676. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47677. }
  47678. }
  47679. declare module BABYLON {
  47680. /**
  47681. * Raw texture can help creating a texture directly from an array of data.
  47682. * This can be super useful if you either get the data from an uncompressed source or
  47683. * if you wish to create your texture pixel by pixel.
  47684. */
  47685. class RawTexture extends Texture {
  47686. /**
  47687. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47688. */
  47689. format: number;
  47690. private _engine;
  47691. /**
  47692. * Instantiates a new RawTexture.
  47693. * Raw texture can help creating a texture directly from an array of data.
  47694. * This can be super useful if you either get the data from an uncompressed source or
  47695. * if you wish to create your texture pixel by pixel.
  47696. * @param data define the array of data to use to create the texture
  47697. * @param width define the width of the texture
  47698. * @param height define the height of the texture
  47699. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47700. * @param scene define the scene the texture belongs to
  47701. * @param generateMipMaps define whether mip maps should be generated or not
  47702. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47703. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47704. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47705. */
  47706. constructor(data: ArrayBufferView, width: number, height: number,
  47707. /**
  47708. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47709. */
  47710. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47711. /**
  47712. * Updates the texture underlying data.
  47713. * @param data Define the new data of the texture
  47714. */
  47715. update(data: ArrayBufferView): void;
  47716. /**
  47717. * Creates a luminance texture from some data.
  47718. * @param data Define the texture data
  47719. * @param width Define the width of the texture
  47720. * @param height Define the height of the texture
  47721. * @param scene Define the scene the texture belongs to
  47722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47725. * @returns the luminance texture
  47726. */
  47727. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47728. /**
  47729. * Creates a luminance alpha texture from some data.
  47730. * @param data Define the texture data
  47731. * @param width Define the width of the texture
  47732. * @param height Define the height of the texture
  47733. * @param scene Define the scene the texture belongs to
  47734. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47735. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47736. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47737. * @returns the luminance alpha texture
  47738. */
  47739. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47740. /**
  47741. * Creates an alpha texture from some data.
  47742. * @param data Define the texture data
  47743. * @param width Define the width of the texture
  47744. * @param height Define the height of the texture
  47745. * @param scene Define the scene the texture belongs to
  47746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47749. * @returns the alpha texture
  47750. */
  47751. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47752. /**
  47753. * Creates a RGB texture from some data.
  47754. * @param data Define the texture data
  47755. * @param width Define the width of the texture
  47756. * @param height Define the height of the texture
  47757. * @param scene Define the scene the texture belongs to
  47758. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47759. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47760. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47761. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47762. * @returns the RGB alpha texture
  47763. */
  47764. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47765. /**
  47766. * Creates a RGBA texture from some data.
  47767. * @param data Define the texture data
  47768. * @param width Define the width of the texture
  47769. * @param height Define the height of the texture
  47770. * @param scene Define the scene the texture belongs to
  47771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47774. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47775. * @returns the RGBA texture
  47776. */
  47777. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47778. /**
  47779. * Creates a R 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47788. * @returns the R texture
  47789. */
  47790. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47791. }
  47792. }
  47793. declare module BABYLON {
  47794. /**
  47795. * Class used to store 3D textures containing user data
  47796. */
  47797. class RawTexture3D extends Texture {
  47798. /** Gets or sets the texture format to use */
  47799. format: number;
  47800. private _engine;
  47801. /**
  47802. * Create a new RawTexture3D
  47803. * @param data defines the data of the texture
  47804. * @param width defines the width of the texture
  47805. * @param height defines the height of the texture
  47806. * @param depth defines the depth of the texture
  47807. * @param format defines the texture format to use
  47808. * @param scene defines the hosting scene
  47809. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47810. * @param invertY defines if texture must be stored with Y axis inverted
  47811. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47812. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47813. */
  47814. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47815. /** Gets or sets the texture format to use */
  47816. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47817. /**
  47818. * Update the texture with new data
  47819. * @param data defines the data to store in the texture
  47820. */
  47821. update(data: ArrayBufferView): void;
  47822. }
  47823. }
  47824. declare module BABYLON {
  47825. /**
  47826. * Creates a refraction texture used by refraction channel of the standard material.
  47827. * It is like a mirror but to see through a material.
  47828. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47829. */
  47830. class RefractionTexture extends RenderTargetTexture {
  47831. /**
  47832. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47833. * 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.
  47834. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47835. */
  47836. refractionPlane: Plane;
  47837. /**
  47838. * Define how deep under the surface we should see.
  47839. */
  47840. depth: number;
  47841. /**
  47842. * Creates a refraction texture used by refraction channel of the standard material.
  47843. * It is like a mirror but to see through a material.
  47844. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47845. * @param name Define the texture name
  47846. * @param size Define the size of the underlying texture
  47847. * @param scene Define the scene the refraction belongs to
  47848. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47849. */
  47850. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47851. /**
  47852. * Clone the refraction texture.
  47853. * @returns the cloned texture
  47854. */
  47855. clone(): RefractionTexture;
  47856. /**
  47857. * Serialize the texture to a JSON representation you could use in Parse later on
  47858. * @returns the serialized JSON representation
  47859. */
  47860. serialize(): any;
  47861. }
  47862. }
  47863. declare module BABYLON {
  47864. /**
  47865. * This Helps creating a texture that will be created from a camera in your scene.
  47866. * It is basically a dynamic texture that could be used to create special effects for instance.
  47867. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47868. */
  47869. class RenderTargetTexture extends Texture {
  47870. isCube: boolean;
  47871. /**
  47872. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47873. */
  47874. static readonly REFRESHRATE_RENDER_ONCE: number;
  47875. /**
  47876. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47877. */
  47878. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47879. /**
  47880. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47881. * the central point of your effect and can save a lot of performances.
  47882. */
  47883. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47884. /**
  47885. * Use this predicate to dynamically define the list of mesh you want to render.
  47886. * If set, the renderList property will be overwritten.
  47887. */
  47888. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47889. private _renderList;
  47890. /**
  47891. * Use this list to define the list of mesh you want to render.
  47892. */
  47893. renderList: Nullable<Array<AbstractMesh>>;
  47894. private _hookArray;
  47895. /**
  47896. * Define if particles should be rendered in your texture.
  47897. */
  47898. renderParticles: boolean;
  47899. /**
  47900. * Define if sprites should be rendered in your texture.
  47901. */
  47902. renderSprites: boolean;
  47903. /**
  47904. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47905. */
  47906. coordinatesMode: number;
  47907. /**
  47908. * Define the camera used to render the texture.
  47909. */
  47910. activeCamera: Nullable<Camera>;
  47911. /**
  47912. * Override the render function of the texture with your own one.
  47913. */
  47914. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47915. /**
  47916. * Define if camera post processes should be use while rendering the texture.
  47917. */
  47918. useCameraPostProcesses: boolean;
  47919. /**
  47920. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47921. */
  47922. ignoreCameraViewport: boolean;
  47923. private _postProcessManager;
  47924. private _postProcesses;
  47925. private _resizeObserver;
  47926. /**
  47927. * An event triggered when the texture is unbind.
  47928. */
  47929. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47930. /**
  47931. * An event triggered when the texture is unbind.
  47932. */
  47933. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47934. private _onAfterUnbindObserver;
  47935. /**
  47936. * Set a after unbind callback in the texture.
  47937. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47938. */
  47939. onAfterUnbind: () => void;
  47940. /**
  47941. * An event triggered before rendering the texture
  47942. */
  47943. onBeforeRenderObservable: Observable<number>;
  47944. private _onBeforeRenderObserver;
  47945. /**
  47946. * Set a before render callback in the texture.
  47947. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47948. */
  47949. onBeforeRender: (faceIndex: number) => void;
  47950. /**
  47951. * An event triggered after rendering the texture
  47952. */
  47953. onAfterRenderObservable: Observable<number>;
  47954. private _onAfterRenderObserver;
  47955. /**
  47956. * Set a after render callback in the texture.
  47957. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47958. */
  47959. onAfterRender: (faceIndex: number) => void;
  47960. /**
  47961. * An event triggered after the texture clear
  47962. */
  47963. onClearObservable: Observable<Engine>;
  47964. private _onClearObserver;
  47965. /**
  47966. * Set a clear callback in the texture.
  47967. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47968. */
  47969. onClear: (Engine: Engine) => void;
  47970. /**
  47971. * Define the clear color of the Render Target if it should be different from the scene.
  47972. */
  47973. clearColor: Color4;
  47974. protected _size: number | {
  47975. width: number;
  47976. height: number;
  47977. };
  47978. protected _initialSizeParameter: number | {
  47979. width: number;
  47980. height: number;
  47981. } | {
  47982. ratio: number;
  47983. };
  47984. protected _sizeRatio: Nullable<number>;
  47985. /** @hidden */
  47986. _generateMipMaps: boolean;
  47987. protected _renderingManager: RenderingManager;
  47988. /** @hidden */
  47989. _waitingRenderList: string[];
  47990. protected _doNotChangeAspectRatio: boolean;
  47991. protected _currentRefreshId: number;
  47992. protected _refreshRate: number;
  47993. protected _textureMatrix: Matrix;
  47994. protected _samples: number;
  47995. protected _renderTargetOptions: RenderTargetCreationOptions;
  47996. /**
  47997. * Gets render target creation options that were used.
  47998. */
  47999. readonly renderTargetOptions: RenderTargetCreationOptions;
  48000. protected _engine: Engine;
  48001. protected _onRatioRescale(): void;
  48002. /**
  48003. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  48004. * It must define where the camera used to render the texture is set
  48005. */
  48006. boundingBoxPosition: Vector3;
  48007. private _boundingBoxSize;
  48008. /**
  48009. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  48010. * When defined, the cubemap will switch to local mode
  48011. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48012. * @example https://www.babylonjs-playground.com/#RNASML
  48013. */
  48014. boundingBoxSize: Vector3;
  48015. /**
  48016. * In case the RTT has been created with a depth texture, get the associated
  48017. * depth texture.
  48018. * Otherwise, return null.
  48019. */
  48020. depthStencilTexture: Nullable<InternalTexture>;
  48021. /**
  48022. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  48023. * or used a shadow, depth texture...
  48024. * @param name The friendly name of the texture
  48025. * @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)
  48026. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  48027. * @param generateMipMaps True if mip maps need to be generated after render.
  48028. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  48029. * @param type The type of the buffer in the RTT (int, half float, float...)
  48030. * @param isCube True if a cube texture needs to be created
  48031. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  48032. * @param generateDepthBuffer True to generate a depth buffer
  48033. * @param generateStencilBuffer True to generate a stencil buffer
  48034. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  48035. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  48036. * @param delayAllocation if the texture allocation should be delayed (default: false)
  48037. */
  48038. constructor(name: string, size: number | {
  48039. width: number;
  48040. height: number;
  48041. } | {
  48042. ratio: number;
  48043. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  48044. /**
  48045. * Creates a depth stencil texture.
  48046. * This is only available in WebGL 2 or with the depth texture extension available.
  48047. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48048. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48049. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48050. */
  48051. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48052. private _processSizeParameter;
  48053. /**
  48054. * Define the number of samples to use in case of MSAA.
  48055. * It defaults to one meaning no MSAA has been enabled.
  48056. */
  48057. samples: number;
  48058. /**
  48059. * Resets the refresh counter of the texture and start bak from scratch.
  48060. * Could be useful to regenerate the texture if it is setup to render only once.
  48061. */
  48062. resetRefreshCounter(): void;
  48063. /**
  48064. * Define the refresh rate of the texture or the rendering frequency.
  48065. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48066. */
  48067. refreshRate: number;
  48068. /**
  48069. * Adds a post process to the render target rendering passes.
  48070. * @param postProcess define the post process to add
  48071. */
  48072. addPostProcess(postProcess: PostProcess): void;
  48073. /**
  48074. * Clear all the post processes attached to the render target
  48075. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48076. */
  48077. clearPostProcesses(dispose?: boolean): void;
  48078. /**
  48079. * Remove one of the post process from the list of attached post processes to the texture
  48080. * @param postProcess define the post process to remove from the list
  48081. */
  48082. removePostProcess(postProcess: PostProcess): void;
  48083. /** @hidden */
  48084. _shouldRender(): boolean;
  48085. /**
  48086. * Gets the actual render size of the texture.
  48087. * @returns the width of the render size
  48088. */
  48089. getRenderSize(): number;
  48090. /**
  48091. * Gets the actual render width of the texture.
  48092. * @returns the width of the render size
  48093. */
  48094. getRenderWidth(): number;
  48095. /**
  48096. * Gets the actual render height of the texture.
  48097. * @returns the height of the render size
  48098. */
  48099. getRenderHeight(): number;
  48100. /**
  48101. * Get if the texture can be rescaled or not.
  48102. */
  48103. readonly canRescale: boolean;
  48104. /**
  48105. * Resize the texture using a ratio.
  48106. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48107. */
  48108. scale(ratio: number): void;
  48109. /**
  48110. * Get the texture reflection matrix used to rotate/transform the reflection.
  48111. * @returns the reflection matrix
  48112. */
  48113. getReflectionTextureMatrix(): Matrix;
  48114. /**
  48115. * Resize the texture to a new desired size.
  48116. * Be carrefull as it will recreate all the data in the new texture.
  48117. * @param size Define the new size. It can be:
  48118. * - a number for squared texture,
  48119. * - an object containing { width: number, height: number }
  48120. * - or an object containing a ratio { ratio: number }
  48121. */
  48122. resize(size: number | {
  48123. width: number;
  48124. height: number;
  48125. } | {
  48126. ratio: number;
  48127. }): void;
  48128. /**
  48129. * Renders all the objects from the render list into the texture.
  48130. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48131. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48132. */
  48133. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48134. private _bestReflectionRenderTargetDimension;
  48135. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48136. private renderToTarget;
  48137. /**
  48138. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48139. * This allowed control for front to back rendering or reversly depending of the special needs.
  48140. *
  48141. * @param renderingGroupId The rendering group id corresponding to its index
  48142. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48143. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48144. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48145. */
  48146. 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;
  48147. /**
  48148. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48149. *
  48150. * @param renderingGroupId The rendering group id corresponding to its index
  48151. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48152. */
  48153. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48154. /**
  48155. * Clones the texture.
  48156. * @returns the cloned texture
  48157. */
  48158. clone(): RenderTargetTexture;
  48159. /**
  48160. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48161. * @returns The JSON representation of the texture
  48162. */
  48163. serialize(): any;
  48164. /**
  48165. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48166. */
  48167. disposeFramebufferObjects(): void;
  48168. /**
  48169. * Dispose the texture and release its associated resources.
  48170. */
  48171. dispose(): void;
  48172. /** @hidden */
  48173. _rebuild(): void;
  48174. /**
  48175. * Clear the info related to rendering groups preventing retention point in material dispose.
  48176. */
  48177. freeRenderingGroups(): void;
  48178. }
  48179. }
  48180. declare module BABYLON {
  48181. /**
  48182. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48183. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48184. */
  48185. class Texture extends BaseTexture {
  48186. /** nearest is mag = nearest and min = nearest and mip = linear */
  48187. static readonly NEAREST_SAMPLINGMODE: number;
  48188. /** nearest is mag = nearest and min = nearest and mip = linear */
  48189. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48191. static readonly BILINEAR_SAMPLINGMODE: number;
  48192. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48193. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48194. /** Trilinear is mag = linear and min = linear and mip = linear */
  48195. static readonly TRILINEAR_SAMPLINGMODE: number;
  48196. /** Trilinear is mag = linear and min = linear and mip = linear */
  48197. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48198. /** mag = nearest and min = nearest and mip = nearest */
  48199. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48200. /** mag = nearest and min = linear and mip = nearest */
  48201. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48202. /** mag = nearest and min = linear and mip = linear */
  48203. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48204. /** mag = nearest and min = linear and mip = none */
  48205. static readonly NEAREST_LINEAR: number;
  48206. /** mag = nearest and min = nearest and mip = none */
  48207. static readonly NEAREST_NEAREST: number;
  48208. /** mag = linear and min = nearest and mip = nearest */
  48209. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48210. /** mag = linear and min = nearest and mip = linear */
  48211. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48212. /** mag = linear and min = linear and mip = none */
  48213. static readonly LINEAR_LINEAR: number;
  48214. /** mag = linear and min = nearest and mip = none */
  48215. static readonly LINEAR_NEAREST: number;
  48216. /** Explicit coordinates mode */
  48217. static readonly EXPLICIT_MODE: number;
  48218. /** Spherical coordinates mode */
  48219. static readonly SPHERICAL_MODE: number;
  48220. /** Planar coordinates mode */
  48221. static readonly PLANAR_MODE: number;
  48222. /** Cubic coordinates mode */
  48223. static readonly CUBIC_MODE: number;
  48224. /** Projection coordinates mode */
  48225. static readonly PROJECTION_MODE: number;
  48226. /** Inverse Cubic coordinates mode */
  48227. static readonly SKYBOX_MODE: number;
  48228. /** Inverse Cubic coordinates mode */
  48229. static readonly INVCUBIC_MODE: number;
  48230. /** Equirectangular coordinates mode */
  48231. static readonly EQUIRECTANGULAR_MODE: number;
  48232. /** Equirectangular Fixed coordinates mode */
  48233. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48234. /** Equirectangular Fixed Mirrored coordinates mode */
  48235. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48236. /** Texture is not repeating outside of 0..1 UVs */
  48237. static readonly CLAMP_ADDRESSMODE: number;
  48238. /** Texture is repeating outside of 0..1 UVs */
  48239. static readonly WRAP_ADDRESSMODE: number;
  48240. /** Texture is repeating and mirrored */
  48241. static readonly MIRROR_ADDRESSMODE: number;
  48242. /**
  48243. * 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
  48244. */
  48245. static UseSerializedUrlIfAny: boolean;
  48246. /**
  48247. * Define the url of the texture.
  48248. */
  48249. url: Nullable<string>;
  48250. /**
  48251. * Define an offset on the texture to offset the u coordinates of the UVs
  48252. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48253. */
  48254. uOffset: number;
  48255. /**
  48256. * Define an offset on the texture to offset the v coordinates of the UVs
  48257. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48258. */
  48259. vOffset: number;
  48260. /**
  48261. * Define an offset on the texture to scale the u coordinates of the UVs
  48262. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48263. */
  48264. uScale: number;
  48265. /**
  48266. * Define an offset on the texture to scale the v coordinates of the UVs
  48267. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48268. */
  48269. vScale: number;
  48270. /**
  48271. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48272. * @see http://doc.babylonjs.com/how_to/more_materials
  48273. */
  48274. uAng: number;
  48275. /**
  48276. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48277. * @see http://doc.babylonjs.com/how_to/more_materials
  48278. */
  48279. vAng: number;
  48280. /**
  48281. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48282. * @see http://doc.babylonjs.com/how_to/more_materials
  48283. */
  48284. wAng: number;
  48285. /**
  48286. * Defines the center of rotation (U)
  48287. */
  48288. uRotationCenter: number;
  48289. /**
  48290. * Defines the center of rotation (V)
  48291. */
  48292. vRotationCenter: number;
  48293. /**
  48294. * Defines the center of rotation (W)
  48295. */
  48296. wRotationCenter: number;
  48297. /**
  48298. * Are mip maps generated for this texture or not.
  48299. */
  48300. readonly noMipmap: boolean;
  48301. private _noMipmap;
  48302. /** @hidden */
  48303. _invertY: boolean;
  48304. private _rowGenerationMatrix;
  48305. private _cachedTextureMatrix;
  48306. private _projectionModeMatrix;
  48307. private _t0;
  48308. private _t1;
  48309. private _t2;
  48310. private _cachedUOffset;
  48311. private _cachedVOffset;
  48312. private _cachedUScale;
  48313. private _cachedVScale;
  48314. private _cachedUAng;
  48315. private _cachedVAng;
  48316. private _cachedWAng;
  48317. private _cachedProjectionMatrixId;
  48318. private _cachedCoordinatesMode;
  48319. /** @hidden */
  48320. protected _initialSamplingMode: number;
  48321. /** @hidden */
  48322. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48323. private _deleteBuffer;
  48324. protected _format: Nullable<number>;
  48325. private _delayedOnLoad;
  48326. private _delayedOnError;
  48327. /**
  48328. * Observable triggered once the texture has been loaded.
  48329. */
  48330. onLoadObservable: Observable<Texture>;
  48331. protected _isBlocking: boolean;
  48332. /**
  48333. * Is the texture preventing material to render while loading.
  48334. * If false, a default texture will be used instead of the loading one during the preparation step.
  48335. */
  48336. isBlocking: boolean;
  48337. /**
  48338. * Get the current sampling mode associated with the texture.
  48339. */
  48340. readonly samplingMode: number;
  48341. /**
  48342. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48343. */
  48344. readonly invertY: boolean;
  48345. /**
  48346. * Instantiates a new texture.
  48347. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48348. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48349. * @param url define the url of the picture to load as a texture
  48350. * @param scene define the scene the texture will belong to
  48351. * @param noMipmap define if the texture will require mip maps or not
  48352. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48353. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48354. * @param onLoad define a callback triggered when the texture has been loaded
  48355. * @param onError define a callback triggered when an error occurred during the loading session
  48356. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48357. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48358. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48359. */
  48360. 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);
  48361. /**
  48362. * Update the url (and optional buffer) of this texture if url was null during construction.
  48363. * @param url the url of the texture
  48364. * @param buffer the buffer of the texture (defaults to null)
  48365. * @param onLoad callback called when the texture is loaded (defaults to null)
  48366. */
  48367. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48368. /**
  48369. * Finish the loading sequence of a texture flagged as delayed load.
  48370. * @hidden
  48371. */
  48372. delayLoad(): void;
  48373. private _prepareRowForTextureGeneration;
  48374. /**
  48375. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48376. * @returns the transform matrix of the texture.
  48377. */
  48378. getTextureMatrix(): Matrix;
  48379. /**
  48380. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48381. * @returns The reflection texture transform
  48382. */
  48383. getReflectionTextureMatrix(): Matrix;
  48384. /**
  48385. * Clones the texture.
  48386. * @returns the cloned texture
  48387. */
  48388. clone(): Texture;
  48389. /**
  48390. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48391. * @returns The JSON representation of the texture
  48392. */
  48393. serialize(): any;
  48394. /**
  48395. * Get the current class name of the texture useful for serialization or dynamic coding.
  48396. * @returns "Texture"
  48397. */
  48398. getClassName(): string;
  48399. /**
  48400. * Dispose the texture and release its associated resources.
  48401. */
  48402. dispose(): void;
  48403. /**
  48404. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48405. * @param parsedTexture Define the JSON representation of the texture
  48406. * @param scene Define the scene the parsed texture should be instantiated in
  48407. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48408. * @returns The parsed texture if successful
  48409. */
  48410. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48411. /**
  48412. * Creates a texture from its base 64 representation.
  48413. * @param data Define the base64 payload without the data: prefix
  48414. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48415. * @param scene Define the scene the texture should belong to
  48416. * @param noMipmap Forces the texture to not create mip map information if true
  48417. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48418. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48419. * @param onLoad define a callback triggered when the texture has been loaded
  48420. * @param onError define a callback triggered when an error occurred during the loading session
  48421. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48422. * @returns the created texture
  48423. */
  48424. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48425. /**
  48426. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48427. * @param data Define the base64 payload without the data: prefix
  48428. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48429. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48430. * @param scene Define the scene the texture should belong to
  48431. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48432. * @param noMipmap Forces the texture to not create mip map information if true
  48433. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48434. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48435. * @param onLoad define a callback triggered when the texture has been loaded
  48436. * @param onError define a callback triggered when an error occurred during the loading session
  48437. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48438. * @returns the created texture
  48439. */
  48440. 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;
  48441. }
  48442. }
  48443. declare module BABYLON {
  48444. /**
  48445. * Settings for finer control over video usage
  48446. */
  48447. interface VideoTextureSettings {
  48448. /**
  48449. * Applies `autoplay` to video, if specified
  48450. */
  48451. autoPlay?: boolean;
  48452. /**
  48453. * Applies `loop` to video, if specified
  48454. */
  48455. loop?: boolean;
  48456. /**
  48457. * Automatically updates internal texture from video at every frame in the render loop
  48458. */
  48459. autoUpdateTexture: boolean;
  48460. /**
  48461. * Image src displayed during the video loading or until the user interacts with the video.
  48462. */
  48463. poster?: string;
  48464. }
  48465. /**
  48466. * If you want to display a video in your scene, this is the special texture for that.
  48467. * This special texture works similar to other textures, with the exception of a few parameters.
  48468. * @see https://doc.babylonjs.com/how_to/video_texture
  48469. */
  48470. class VideoTexture extends Texture {
  48471. /**
  48472. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48473. */
  48474. readonly autoUpdateTexture: boolean;
  48475. /**
  48476. * The video instance used by the texture internally
  48477. */
  48478. readonly video: HTMLVideoElement;
  48479. private _onUserActionRequestedObservable;
  48480. /**
  48481. * Event triggerd when a dom action is required by the user to play the video.
  48482. * This happens due to recent changes in browser policies preventing video to auto start.
  48483. */
  48484. readonly onUserActionRequestedObservable: Observable<Texture>;
  48485. private _generateMipMaps;
  48486. private _engine;
  48487. private _stillImageCaptured;
  48488. private _displayingPosterTexture;
  48489. private _settings;
  48490. private _createInternalTextureOnEvent;
  48491. /**
  48492. * Creates a video texture.
  48493. * If you want to display a video in your scene, this is the special texture for that.
  48494. * This special texture works similar to other textures, with the exception of a few parameters.
  48495. * @see https://doc.babylonjs.com/how_to/video_texture
  48496. * @param name optional name, will detect from video source, if not defined
  48497. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48498. * @param scene is obviously the current scene.
  48499. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48500. * @param invertY is false by default but can be used to invert video on Y axis
  48501. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48502. * @param settings allows finer control over video usage
  48503. */
  48504. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48505. private _getName;
  48506. private _getVideo;
  48507. private _createInternalTexture;
  48508. private reset;
  48509. /**
  48510. * @hidden Internal method to initiate `update`.
  48511. */
  48512. _rebuild(): void;
  48513. /**
  48514. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48515. */
  48516. update(): void;
  48517. /**
  48518. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48519. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48520. */
  48521. updateTexture(isVisible: boolean): void;
  48522. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48523. /**
  48524. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48525. * @param url New url.
  48526. */
  48527. updateURL(url: string): void;
  48528. /**
  48529. * Dispose the texture and release its associated resources.
  48530. */
  48531. dispose(): void;
  48532. /**
  48533. * Creates a video texture straight from your WebCam video feed.
  48534. * @param scene Define the scene the texture should be created in
  48535. * @param onReady Define a callback to triggered once the texture will be ready
  48536. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48537. */
  48538. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48539. minWidth: number;
  48540. maxWidth: number;
  48541. minHeight: number;
  48542. maxHeight: number;
  48543. deviceId: string;
  48544. }): void;
  48545. }
  48546. }
  48547. declare var DracoDecoderModule: any;
  48548. declare var WebAssembly: any;
  48549. declare module BABYLON {
  48550. /**
  48551. * Configuration for Draco compression
  48552. */
  48553. interface IDracoCompressionConfiguration {
  48554. /**
  48555. * Configuration for the decoder.
  48556. */
  48557. decoder?: {
  48558. /**
  48559. * The url to the WebAssembly module.
  48560. */
  48561. wasmUrl?: string;
  48562. /**
  48563. * The url to the WebAssembly binary.
  48564. */
  48565. wasmBinaryUrl?: string;
  48566. /**
  48567. * The url to the fallback JavaScript module.
  48568. */
  48569. fallbackUrl?: string;
  48570. };
  48571. }
  48572. /**
  48573. * Draco compression (https://google.github.io/draco/)
  48574. *
  48575. * This class wraps the Draco module.
  48576. *
  48577. * **Encoder**
  48578. *
  48579. * The encoder is not currently implemented.
  48580. *
  48581. * **Decoder**
  48582. *
  48583. * 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.
  48584. *
  48585. * To update the configuration, use the following code:
  48586. * ```javascript
  48587. * BABYLON.DracoCompression.Configuration = {
  48588. * decoder: {
  48589. * wasmUrl: "<url to the WebAssembly library>",
  48590. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48591. * fallbackUrl: "<url to the fallback JavaScript library>",
  48592. * }
  48593. * };
  48594. * ```
  48595. *
  48596. * 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.
  48597. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48598. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48599. *
  48600. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48601. * ```javascript
  48602. * var dracoCompression = new BABYLON.DracoCompression();
  48603. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48604. * [BABYLON.VertexBuffer.PositionKind]: 0
  48605. * });
  48606. * ```
  48607. *
  48608. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48609. */
  48610. class DracoCompression implements IDisposable {
  48611. private static _DecoderModulePromise;
  48612. /**
  48613. * The configuration. Defaults to the following urls:
  48614. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48615. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48616. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48617. */
  48618. static Configuration: IDracoCompressionConfiguration;
  48619. /**
  48620. * Returns true if the decoder is available.
  48621. */
  48622. static readonly DecoderAvailable: boolean;
  48623. /**
  48624. * Constructor
  48625. */
  48626. constructor();
  48627. /**
  48628. * Stop all async operations and release resources.
  48629. */
  48630. dispose(): void;
  48631. /**
  48632. * Decode Draco compressed mesh data to vertex data.
  48633. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48634. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48635. * @returns A promise that resolves with the decoded vertex data
  48636. */
  48637. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48638. [kind: string]: number;
  48639. }): Promise<VertexData>;
  48640. private static _GetDecoderModule;
  48641. private static _LoadScriptAsync;
  48642. private static _LoadFileAsync;
  48643. }
  48644. }
  48645. declare module BABYLON {
  48646. /**
  48647. * AmmoJS Physics plugin
  48648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48649. * @see https://github.com/kripken/ammo.js/
  48650. */
  48651. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48652. private _useDeltaForWorldStep;
  48653. /**
  48654. * Reference to the Ammo library
  48655. */
  48656. bjsAMMO: any;
  48657. /**
  48658. * Created ammoJS world which physics bodies are added to
  48659. */
  48660. world: any;
  48661. /**
  48662. * Name of the plugin
  48663. */
  48664. name: string;
  48665. private _timeStep;
  48666. private _fixedTimeStep;
  48667. private _maxSteps;
  48668. private _tmpQuaternion;
  48669. private _tmpAmmoTransform;
  48670. private _tmpAmmoQuaternion;
  48671. private _tmpAmmoConcreteContactResultCallback;
  48672. private _collisionConfiguration;
  48673. private _dispatcher;
  48674. private _overlappingPairCache;
  48675. private _solver;
  48676. private _tmpAmmoVectorA;
  48677. private _tmpAmmoVectorB;
  48678. private _tmpAmmoVectorC;
  48679. private _tmpContactCallbackResult;
  48680. private static readonly DISABLE_COLLISION_FLAG;
  48681. private static readonly KINEMATIC_FLAG;
  48682. private static readonly DISABLE_DEACTIVATION_FLAG;
  48683. /**
  48684. * Initializes the ammoJS plugin
  48685. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48686. */
  48687. constructor(_useDeltaForWorldStep?: boolean);
  48688. /**
  48689. * Sets the gravity of the physics world (m/(s^2))
  48690. * @param gravity Gravity to set
  48691. */
  48692. setGravity(gravity: Vector3): void;
  48693. /**
  48694. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48695. * @param timeStep timestep to use in seconds
  48696. */
  48697. setTimeStep(timeStep: number): void;
  48698. /**
  48699. * 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)
  48700. * @param fixedTimeStep fixedTimeStep to use in seconds
  48701. */
  48702. setFixedTimeStep(fixedTimeStep: number): void;
  48703. /**
  48704. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48705. * @param maxSteps the maximum number of steps by the physics engine per frame
  48706. */
  48707. setMaxSteps(maxSteps: number): void;
  48708. /**
  48709. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48710. * @returns the current timestep in seconds
  48711. */
  48712. getTimeStep(): number;
  48713. private _isImpostorInContact;
  48714. private _isImpostorPairInContact;
  48715. private _stepSimulation;
  48716. /**
  48717. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48718. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48719. * After the step the babylon meshes are set to the position of the physics imposters
  48720. * @param delta amount of time to step forward
  48721. * @param impostors array of imposters to update before/after the step
  48722. */
  48723. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48724. /**
  48725. * Applies an implulse on the imposter
  48726. * @param impostor imposter to apply impulse
  48727. * @param force amount of force to be applied to the imposter
  48728. * @param contactPoint the location to apply the impulse on the imposter
  48729. */
  48730. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48731. /**
  48732. * Applies a force on the imposter
  48733. * @param impostor imposter to apply force
  48734. * @param force amount of force to be applied to the imposter
  48735. * @param contactPoint the location to apply the force on the imposter
  48736. */
  48737. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48738. /**
  48739. * Creates a physics body using the plugin
  48740. * @param impostor the imposter to create the physics body on
  48741. */
  48742. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48743. /**
  48744. * Removes the physics body from the imposter and disposes of the body's memory
  48745. * @param impostor imposter to remove the physics body from
  48746. */
  48747. removePhysicsBody(impostor: PhysicsImpostor): void;
  48748. /**
  48749. * Generates a joint
  48750. * @param impostorJoint the imposter joint to create the joint with
  48751. */
  48752. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48753. /**
  48754. * Removes a joint
  48755. * @param impostorJoint the imposter joint to remove the joint from
  48756. */
  48757. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48758. private _addMeshVerts;
  48759. private _createShape;
  48760. /**
  48761. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48762. * @param impostor imposter containing the physics body and babylon object
  48763. */
  48764. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48765. /**
  48766. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48767. * @param impostor imposter containing the physics body and babylon object
  48768. * @param newPosition new position
  48769. * @param newRotation new rotation
  48770. */
  48771. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48772. /**
  48773. * If this plugin is supported
  48774. * @returns true if its supported
  48775. */
  48776. isSupported(): boolean;
  48777. /**
  48778. * Sets the linear velocity of the physics body
  48779. * @param impostor imposter to set the velocity on
  48780. * @param velocity velocity to set
  48781. */
  48782. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48783. /**
  48784. * Sets the angular velocity of the physics body
  48785. * @param impostor imposter to set the velocity on
  48786. * @param velocity velocity to set
  48787. */
  48788. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48789. /**
  48790. * gets the linear velocity
  48791. * @param impostor imposter to get linear velocity from
  48792. * @returns linear velocity
  48793. */
  48794. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48795. /**
  48796. * gets the angular velocity
  48797. * @param impostor imposter to get angular velocity from
  48798. * @returns angular velocity
  48799. */
  48800. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48801. /**
  48802. * Sets the mass of physics body
  48803. * @param impostor imposter to set the mass on
  48804. * @param mass mass to set
  48805. */
  48806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48807. /**
  48808. * Gets the mass of the physics body
  48809. * @param impostor imposter to get the mass from
  48810. * @returns mass
  48811. */
  48812. getBodyMass(impostor: PhysicsImpostor): number;
  48813. /**
  48814. * Gets friction of the impostor
  48815. * @param impostor impostor to get friction from
  48816. * @returns friction value
  48817. */
  48818. getBodyFriction(impostor: PhysicsImpostor): number;
  48819. /**
  48820. * Sets friction of the impostor
  48821. * @param impostor impostor to set friction on
  48822. * @param friction friction value
  48823. */
  48824. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48825. /**
  48826. * Gets restitution of the impostor
  48827. * @param impostor impostor to get restitution from
  48828. * @returns restitution value
  48829. */
  48830. getBodyRestitution(impostor: PhysicsImpostor): number;
  48831. /**
  48832. * Sets resitution of the impostor
  48833. * @param impostor impostor to set resitution on
  48834. * @param restitution resitution value
  48835. */
  48836. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48837. /**
  48838. * Sleeps the physics body and stops it from being active
  48839. * @param impostor impostor to sleep
  48840. */
  48841. sleepBody(impostor: PhysicsImpostor): void;
  48842. /**
  48843. * Activates the physics body
  48844. * @param impostor impostor to activate
  48845. */
  48846. wakeUpBody(impostor: PhysicsImpostor): void;
  48847. /**
  48848. * Updates the distance parameters of the joint
  48849. * @param joint joint to update
  48850. * @param maxDistance maximum distance of the joint
  48851. * @param minDistance minimum distance of the joint
  48852. */
  48853. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48854. /**
  48855. * Sets a motor on the joint
  48856. * @param joint joint to set motor on
  48857. * @param speed speed of the motor
  48858. * @param maxForce maximum force of the motor
  48859. * @param motorIndex index of the motor
  48860. */
  48861. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48862. /**
  48863. * Sets the motors limit
  48864. * @param joint joint to set limit on
  48865. * @param upperLimit upper limit
  48866. * @param lowerLimit lower limit
  48867. */
  48868. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48869. /**
  48870. * Syncs the position and rotation of a mesh with the impostor
  48871. * @param mesh mesh to sync
  48872. * @param impostor impostor to update the mesh with
  48873. */
  48874. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48875. /**
  48876. * Gets the radius of the impostor
  48877. * @param impostor impostor to get radius from
  48878. * @returns the radius
  48879. */
  48880. getRadius(impostor: PhysicsImpostor): number;
  48881. /**
  48882. * Gets the box size of the impostor
  48883. * @param impostor impostor to get box size from
  48884. * @param result the resulting box size
  48885. */
  48886. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48887. /**
  48888. * Disposes of the impostor
  48889. */
  48890. dispose(): void;
  48891. }
  48892. }
  48893. declare module BABYLON {
  48894. /** @hidden */
  48895. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48896. private _useDeltaForWorldStep;
  48897. world: any;
  48898. name: string;
  48899. private _physicsMaterials;
  48900. private _fixedTimeStep;
  48901. BJSCANNON: any;
  48902. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48903. setGravity(gravity: Vector3): void;
  48904. setTimeStep(timeStep: number): void;
  48905. getTimeStep(): number;
  48906. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48907. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48908. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48909. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48910. private _processChildMeshes;
  48911. removePhysicsBody(impostor: PhysicsImpostor): void;
  48912. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48913. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48914. private _addMaterial;
  48915. private _checkWithEpsilon;
  48916. private _createShape;
  48917. private _createHeightmap;
  48918. private _minus90X;
  48919. private _plus90X;
  48920. private _tmpPosition;
  48921. private _tmpDeltaPosition;
  48922. private _tmpUnityRotation;
  48923. private _updatePhysicsBodyTransformation;
  48924. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48925. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48926. isSupported(): boolean;
  48927. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48928. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48930. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48931. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48932. getBodyMass(impostor: PhysicsImpostor): number;
  48933. getBodyFriction(impostor: PhysicsImpostor): number;
  48934. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48935. getBodyRestitution(impostor: PhysicsImpostor): number;
  48936. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48937. sleepBody(impostor: PhysicsImpostor): void;
  48938. wakeUpBody(impostor: PhysicsImpostor): void;
  48939. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48940. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48941. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48942. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48943. getRadius(impostor: PhysicsImpostor): number;
  48944. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48945. dispose(): void;
  48946. private _extendNamespace;
  48947. }
  48948. }
  48949. declare module BABYLON {
  48950. /** @hidden */
  48951. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48952. world: any;
  48953. name: string;
  48954. BJSOIMO: any;
  48955. constructor(iterations?: number);
  48956. setGravity(gravity: Vector3): void;
  48957. setTimeStep(timeStep: number): void;
  48958. getTimeStep(): number;
  48959. private _tmpImpostorsArray;
  48960. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48961. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48962. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48963. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48964. private _tmpPositionVector;
  48965. removePhysicsBody(impostor: PhysicsImpostor): void;
  48966. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48967. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48968. isSupported(): boolean;
  48969. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48970. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48971. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48972. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48973. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48974. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48975. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48976. getBodyMass(impostor: PhysicsImpostor): number;
  48977. getBodyFriction(impostor: PhysicsImpostor): number;
  48978. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48979. getBodyRestitution(impostor: PhysicsImpostor): number;
  48980. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48981. sleepBody(impostor: PhysicsImpostor): void;
  48982. wakeUpBody(impostor: PhysicsImpostor): void;
  48983. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48984. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48985. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48986. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48987. getRadius(impostor: PhysicsImpostor): number;
  48988. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48989. dispose(): void;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /**
  48994. * Particle emitter emitting particles from the inside of a box.
  48995. * It emits the particles randomly between 2 given directions.
  48996. */
  48997. class BoxParticleEmitter implements IParticleEmitterType {
  48998. /**
  48999. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49000. */
  49001. direction1: Vector3;
  49002. /**
  49003. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49004. */
  49005. direction2: Vector3;
  49006. /**
  49007. * 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.
  49008. */
  49009. minEmitBox: Vector3;
  49010. /**
  49011. * 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.
  49012. */
  49013. maxEmitBox: Vector3;
  49014. /**
  49015. * Creates a new instance BoxParticleEmitter
  49016. */
  49017. constructor();
  49018. /**
  49019. * Called by the particle System when the direction is computed for the created particle.
  49020. * @param worldMatrix is the world matrix of the particle system
  49021. * @param directionToUpdate is the direction vector to update with the result
  49022. * @param particle is the particle we are computed the direction for
  49023. */
  49024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49025. /**
  49026. * Called by the particle System when the position is computed for the created particle.
  49027. * @param worldMatrix is the world matrix of the particle system
  49028. * @param positionToUpdate is the position vector to update with the result
  49029. * @param particle is the particle we are computed the position for
  49030. */
  49031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49032. /**
  49033. * Clones the current emitter and returns a copy of it
  49034. * @returns the new emitter
  49035. */
  49036. clone(): BoxParticleEmitter;
  49037. /**
  49038. * Called by the GPUParticleSystem to setup the update shader
  49039. * @param effect defines the update shader
  49040. */
  49041. applyToShader(effect: Effect): void;
  49042. /**
  49043. * Returns a string to use to update the GPU particles update shader
  49044. * @returns a string containng the defines string
  49045. */
  49046. getEffectDefines(): string;
  49047. /**
  49048. * Returns the string "BoxParticleEmitter"
  49049. * @returns a string containing the class name
  49050. */
  49051. getClassName(): string;
  49052. /**
  49053. * Serializes the particle system to a JSON object.
  49054. * @returns the JSON object
  49055. */
  49056. serialize(): any;
  49057. /**
  49058. * Parse properties from a JSON object
  49059. * @param serializationObject defines the JSON object
  49060. */
  49061. parse(serializationObject: any): void;
  49062. }
  49063. }
  49064. declare module BABYLON {
  49065. /**
  49066. * Particle emitter emitting particles from the inside of a cone.
  49067. * It emits the particles alongside the cone volume from the base to the particle.
  49068. * The emission direction might be randomized.
  49069. */
  49070. class ConeParticleEmitter implements IParticleEmitterType {
  49071. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  49072. directionRandomizer: number;
  49073. private _radius;
  49074. private _angle;
  49075. private _height;
  49076. /**
  49077. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  49078. */
  49079. radiusRange: number;
  49080. /**
  49081. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  49082. */
  49083. heightRange: number;
  49084. /**
  49085. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  49086. */
  49087. emitFromSpawnPointOnly: boolean;
  49088. /**
  49089. * Gets or sets the radius of the emission cone
  49090. */
  49091. radius: number;
  49092. /**
  49093. * Gets or sets the angle of the emission cone
  49094. */
  49095. angle: number;
  49096. private _buildHeight;
  49097. /**
  49098. * Creates a new instance ConeParticleEmitter
  49099. * @param radius the radius of the emission cone (1 by default)
  49100. * @param angles the cone base angle (PI by default)
  49101. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  49102. */
  49103. constructor(radius?: number, angle?: number,
  49104. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  49105. directionRandomizer?: number);
  49106. /**
  49107. * Called by the particle System when the direction is computed for the created particle.
  49108. * @param worldMatrix is the world matrix of the particle system
  49109. * @param directionToUpdate is the direction vector to update with the result
  49110. * @param particle is the particle we are computed the direction for
  49111. */
  49112. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49113. /**
  49114. * Called by the particle System when the position is computed for the created particle.
  49115. * @param worldMatrix is the world matrix of the particle system
  49116. * @param positionToUpdate is the position vector to update with the result
  49117. * @param particle is the particle we are computed the position for
  49118. */
  49119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49120. /**
  49121. * Clones the current emitter and returns a copy of it
  49122. * @returns the new emitter
  49123. */
  49124. clone(): ConeParticleEmitter;
  49125. /**
  49126. * Called by the GPUParticleSystem to setup the update shader
  49127. * @param effect defines the update shader
  49128. */
  49129. applyToShader(effect: Effect): void;
  49130. /**
  49131. * Returns a string to use to update the GPU particles update shader
  49132. * @returns a string containng the defines string
  49133. */
  49134. getEffectDefines(): string;
  49135. /**
  49136. * Returns the string "ConeParticleEmitter"
  49137. * @returns a string containing the class name
  49138. */
  49139. getClassName(): string;
  49140. /**
  49141. * Serializes the particle system to a JSON object.
  49142. * @returns the JSON object
  49143. */
  49144. serialize(): any;
  49145. /**
  49146. * Parse properties from a JSON object
  49147. * @param serializationObject defines the JSON object
  49148. */
  49149. parse(serializationObject: any): void;
  49150. }
  49151. }
  49152. declare module BABYLON {
  49153. /**
  49154. * Particle emitter emitting particles from the inside of a cylinder.
  49155. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  49156. */
  49157. class CylinderParticleEmitter implements IParticleEmitterType {
  49158. /**
  49159. * The radius of the emission cylinder.
  49160. */
  49161. radius: number;
  49162. /**
  49163. * The height of the emission cylinder.
  49164. */
  49165. height: number;
  49166. /**
  49167. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49168. */
  49169. radiusRange: number;
  49170. /**
  49171. * How much to randomize the particle direction [0-1].
  49172. */
  49173. directionRandomizer: number;
  49174. /**
  49175. * Creates a new instance CylinderParticleEmitter
  49176. * @param radius the radius of the emission cylinder (1 by default)
  49177. * @param height the height of the emission cylinder (1 by default)
  49178. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49179. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49180. */
  49181. constructor(
  49182. /**
  49183. * The radius of the emission cylinder.
  49184. */
  49185. radius?: number,
  49186. /**
  49187. * The height of the emission cylinder.
  49188. */
  49189. height?: number,
  49190. /**
  49191. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49192. */
  49193. radiusRange?: number,
  49194. /**
  49195. * How much to randomize the particle direction [0-1].
  49196. */
  49197. directionRandomizer?: number);
  49198. /**
  49199. * Called by the particle System when the direction is computed for the created particle.
  49200. * @param worldMatrix is the world matrix of the particle system
  49201. * @param directionToUpdate is the direction vector to update with the result
  49202. * @param particle is the particle we are computed the direction for
  49203. */
  49204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49205. /**
  49206. * Called by the particle System when the position is computed for the created particle.
  49207. * @param worldMatrix is the world matrix of the particle system
  49208. * @param positionToUpdate is the position vector to update with the result
  49209. * @param particle is the particle we are computed the position for
  49210. */
  49211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49212. /**
  49213. * Clones the current emitter and returns a copy of it
  49214. * @returns the new emitter
  49215. */
  49216. clone(): CylinderParticleEmitter;
  49217. /**
  49218. * Called by the GPUParticleSystem to setup the update shader
  49219. * @param effect defines the update shader
  49220. */
  49221. applyToShader(effect: Effect): void;
  49222. /**
  49223. * Returns a string to use to update the GPU particles update shader
  49224. * @returns a string containng the defines string
  49225. */
  49226. getEffectDefines(): string;
  49227. /**
  49228. * Returns the string "CylinderParticleEmitter"
  49229. * @returns a string containing the class name
  49230. */
  49231. getClassName(): string;
  49232. /**
  49233. * Serializes the particle system to a JSON object.
  49234. * @returns the JSON object
  49235. */
  49236. serialize(): any;
  49237. /**
  49238. * Parse properties from a JSON object
  49239. * @param serializationObject defines the JSON object
  49240. */
  49241. parse(serializationObject: any): void;
  49242. }
  49243. /**
  49244. * Particle emitter emitting particles from the inside of a cylinder.
  49245. * It emits the particles randomly between two vectors.
  49246. */
  49247. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  49248. /**
  49249. * The min limit of the emission direction.
  49250. */
  49251. direction1: Vector3;
  49252. /**
  49253. * The max limit of the emission direction.
  49254. */
  49255. direction2: Vector3;
  49256. /**
  49257. * Creates a new instance CylinderDirectedParticleEmitter
  49258. * @param radius the radius of the emission cylinder (1 by default)
  49259. * @param height the height of the emission cylinder (1 by default)
  49260. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49261. * @param direction1 the min limit of the emission direction (up vector by default)
  49262. * @param direction2 the max limit of the emission direction (up vector by default)
  49263. */
  49264. constructor(radius?: number, height?: number, radiusRange?: number,
  49265. /**
  49266. * The min limit of the emission direction.
  49267. */
  49268. direction1?: Vector3,
  49269. /**
  49270. * The max limit of the emission direction.
  49271. */
  49272. direction2?: Vector3);
  49273. /**
  49274. * Called by the particle System when the direction is computed for the created particle.
  49275. * @param worldMatrix is the world matrix of the particle system
  49276. * @param directionToUpdate is the direction vector to update with the result
  49277. * @param particle is the particle we are computed the direction for
  49278. */
  49279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49280. /**
  49281. * Clones the current emitter and returns a copy of it
  49282. * @returns the new emitter
  49283. */
  49284. clone(): CylinderDirectedParticleEmitter;
  49285. /**
  49286. * Called by the GPUParticleSystem to setup the update shader
  49287. * @param effect defines the update shader
  49288. */
  49289. applyToShader(effect: Effect): void;
  49290. /**
  49291. * Returns a string to use to update the GPU particles update shader
  49292. * @returns a string containng the defines string
  49293. */
  49294. getEffectDefines(): string;
  49295. /**
  49296. * Returns the string "CylinderDirectedParticleEmitter"
  49297. * @returns a string containing the class name
  49298. */
  49299. getClassName(): string;
  49300. /**
  49301. * Serializes the particle system to a JSON object.
  49302. * @returns the JSON object
  49303. */
  49304. serialize(): any;
  49305. /**
  49306. * Parse properties from a JSON object
  49307. * @param serializationObject defines the JSON object
  49308. */
  49309. parse(serializationObject: any): void;
  49310. }
  49311. }
  49312. declare module BABYLON {
  49313. /**
  49314. * Particle emitter emitting particles from the inside of a hemisphere.
  49315. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  49316. */
  49317. class HemisphericParticleEmitter implements IParticleEmitterType {
  49318. /**
  49319. * The radius of the emission hemisphere.
  49320. */
  49321. radius: number;
  49322. /**
  49323. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49324. */
  49325. radiusRange: number;
  49326. /**
  49327. * How much to randomize the particle direction [0-1].
  49328. */
  49329. directionRandomizer: number;
  49330. /**
  49331. * Creates a new instance HemisphericParticleEmitter
  49332. * @param radius the radius of the emission hemisphere (1 by default)
  49333. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49334. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49335. */
  49336. constructor(
  49337. /**
  49338. * The radius of the emission hemisphere.
  49339. */
  49340. radius?: number,
  49341. /**
  49342. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49343. */
  49344. radiusRange?: number,
  49345. /**
  49346. * How much to randomize the particle direction [0-1].
  49347. */
  49348. directionRandomizer?: number);
  49349. /**
  49350. * Called by the particle System when the direction is computed for the created particle.
  49351. * @param worldMatrix is the world matrix of the particle system
  49352. * @param directionToUpdate is the direction vector to update with the result
  49353. * @param particle is the particle we are computed the direction for
  49354. */
  49355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49356. /**
  49357. * Called by the particle System when the position is computed for the created particle.
  49358. * @param worldMatrix is the world matrix of the particle system
  49359. * @param positionToUpdate is the position vector to update with the result
  49360. * @param particle is the particle we are computed the position for
  49361. */
  49362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49363. /**
  49364. * Clones the current emitter and returns a copy of it
  49365. * @returns the new emitter
  49366. */
  49367. clone(): HemisphericParticleEmitter;
  49368. /**
  49369. * Called by the GPUParticleSystem to setup the update shader
  49370. * @param effect defines the update shader
  49371. */
  49372. applyToShader(effect: Effect): void;
  49373. /**
  49374. * Returns a string to use to update the GPU particles update shader
  49375. * @returns a string containng the defines string
  49376. */
  49377. getEffectDefines(): string;
  49378. /**
  49379. * Returns the string "HemisphericParticleEmitter"
  49380. * @returns a string containing the class name
  49381. */
  49382. getClassName(): string;
  49383. /**
  49384. * Serializes the particle system to a JSON object.
  49385. * @returns the JSON object
  49386. */
  49387. serialize(): any;
  49388. /**
  49389. * Parse properties from a JSON object
  49390. * @param serializationObject defines the JSON object
  49391. */
  49392. parse(serializationObject: any): void;
  49393. }
  49394. }
  49395. declare module BABYLON {
  49396. /**
  49397. * Particle emitter represents a volume emitting particles.
  49398. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49399. */
  49400. interface IParticleEmitterType {
  49401. /**
  49402. * Called by the particle System when the direction is computed for the created particle.
  49403. * @param worldMatrix is the world matrix of the particle system
  49404. * @param directionToUpdate is the direction vector to update with the result
  49405. * @param particle is the particle we are computed the direction for
  49406. */
  49407. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49408. /**
  49409. * Called by the particle System when the position is computed for the created particle.
  49410. * @param worldMatrix is the world matrix of the particle system
  49411. * @param positionToUpdate is the position vector to update with the result
  49412. * @param particle is the particle we are computed the position for
  49413. */
  49414. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49415. /**
  49416. * Clones the current emitter and returns a copy of it
  49417. * @returns the new emitter
  49418. */
  49419. clone(): IParticleEmitterType;
  49420. /**
  49421. * Called by the GPUParticleSystem to setup the update shader
  49422. * @param effect defines the update shader
  49423. */
  49424. applyToShader(effect: Effect): void;
  49425. /**
  49426. * Returns a string to use to update the GPU particles update shader
  49427. * @returns the effect defines string
  49428. */
  49429. getEffectDefines(): string;
  49430. /**
  49431. * Returns a string representing the class name
  49432. * @returns a string containing the class name
  49433. */
  49434. getClassName(): string;
  49435. /**
  49436. * Serializes the particle system to a JSON object.
  49437. * @returns the JSON object
  49438. */
  49439. serialize(): any;
  49440. /**
  49441. * Parse properties from a JSON object
  49442. * @param serializationObject defines the JSON object
  49443. */
  49444. parse(serializationObject: any): void;
  49445. }
  49446. }
  49447. declare module BABYLON {
  49448. /**
  49449. * Particle emitter emitting particles from a point.
  49450. * It emits the particles randomly between 2 given directions.
  49451. */
  49452. class PointParticleEmitter implements IParticleEmitterType {
  49453. /**
  49454. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49455. */
  49456. direction1: Vector3;
  49457. /**
  49458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49459. */
  49460. direction2: Vector3;
  49461. /**
  49462. * Creates a new instance PointParticleEmitter
  49463. */
  49464. constructor();
  49465. /**
  49466. * Called by the particle System when the direction is computed for the created particle.
  49467. * @param worldMatrix is the world matrix of the particle system
  49468. * @param directionToUpdate is the direction vector to update with the result
  49469. * @param particle is the particle we are computed the direction for
  49470. */
  49471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49472. /**
  49473. * Called by the particle System when the position is computed for the created particle.
  49474. * @param worldMatrix is the world matrix of the particle system
  49475. * @param positionToUpdate is the position vector to update with the result
  49476. * @param particle is the particle we are computed the position for
  49477. */
  49478. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49479. /**
  49480. * Clones the current emitter and returns a copy of it
  49481. * @returns the new emitter
  49482. */
  49483. clone(): PointParticleEmitter;
  49484. /**
  49485. * Called by the GPUParticleSystem to setup the update shader
  49486. * @param effect defines the update shader
  49487. */
  49488. applyToShader(effect: Effect): void;
  49489. /**
  49490. * Returns a string to use to update the GPU particles update shader
  49491. * @returns a string containng the defines string
  49492. */
  49493. getEffectDefines(): string;
  49494. /**
  49495. * Returns the string "PointParticleEmitter"
  49496. * @returns a string containing the class name
  49497. */
  49498. getClassName(): string;
  49499. /**
  49500. * Serializes the particle system to a JSON object.
  49501. * @returns the JSON object
  49502. */
  49503. serialize(): any;
  49504. /**
  49505. * Parse properties from a JSON object
  49506. * @param serializationObject defines the JSON object
  49507. */
  49508. parse(serializationObject: any): void;
  49509. }
  49510. }
  49511. declare module BABYLON {
  49512. /**
  49513. * Particle emitter emitting particles from the inside of a sphere.
  49514. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49515. */
  49516. class SphereParticleEmitter implements IParticleEmitterType {
  49517. /**
  49518. * The radius of the emission sphere.
  49519. */
  49520. radius: number;
  49521. /**
  49522. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49523. */
  49524. radiusRange: number;
  49525. /**
  49526. * How much to randomize the particle direction [0-1].
  49527. */
  49528. directionRandomizer: number;
  49529. /**
  49530. * Creates a new instance SphereParticleEmitter
  49531. * @param radius the radius of the emission sphere (1 by default)
  49532. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49533. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49534. */
  49535. constructor(
  49536. /**
  49537. * The radius of the emission sphere.
  49538. */
  49539. radius?: number,
  49540. /**
  49541. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49542. */
  49543. radiusRange?: number,
  49544. /**
  49545. * How much to randomize the particle direction [0-1].
  49546. */
  49547. directionRandomizer?: number);
  49548. /**
  49549. * Called by the particle System when the direction is computed for the created particle.
  49550. * @param worldMatrix is the world matrix of the particle system
  49551. * @param directionToUpdate is the direction vector to update with the result
  49552. * @param particle is the particle we are computed the direction for
  49553. */
  49554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49555. /**
  49556. * Called by the particle System when the position is computed for the created particle.
  49557. * @param worldMatrix is the world matrix of the particle system
  49558. * @param positionToUpdate is the position vector to update with the result
  49559. * @param particle is the particle we are computed the position for
  49560. */
  49561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49562. /**
  49563. * Clones the current emitter and returns a copy of it
  49564. * @returns the new emitter
  49565. */
  49566. clone(): SphereParticleEmitter;
  49567. /**
  49568. * Called by the GPUParticleSystem to setup the update shader
  49569. * @param effect defines the update shader
  49570. */
  49571. applyToShader(effect: Effect): void;
  49572. /**
  49573. * Returns a string to use to update the GPU particles update shader
  49574. * @returns a string containng the defines string
  49575. */
  49576. getEffectDefines(): string;
  49577. /**
  49578. * Returns the string "SphereParticleEmitter"
  49579. * @returns a string containing the class name
  49580. */
  49581. getClassName(): string;
  49582. /**
  49583. * Serializes the particle system to a JSON object.
  49584. * @returns the JSON object
  49585. */
  49586. serialize(): any;
  49587. /**
  49588. * Parse properties from a JSON object
  49589. * @param serializationObject defines the JSON object
  49590. */
  49591. parse(serializationObject: any): void;
  49592. }
  49593. /**
  49594. * Particle emitter emitting particles from the inside of a sphere.
  49595. * It emits the particles randomly between two vectors.
  49596. */
  49597. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49598. /**
  49599. * The min limit of the emission direction.
  49600. */
  49601. direction1: Vector3;
  49602. /**
  49603. * The max limit of the emission direction.
  49604. */
  49605. direction2: Vector3;
  49606. /**
  49607. * Creates a new instance SphereDirectedParticleEmitter
  49608. * @param radius the radius of the emission sphere (1 by default)
  49609. * @param direction1 the min limit of the emission direction (up vector by default)
  49610. * @param direction2 the max limit of the emission direction (up vector by default)
  49611. */
  49612. constructor(radius?: number,
  49613. /**
  49614. * The min limit of the emission direction.
  49615. */
  49616. direction1?: Vector3,
  49617. /**
  49618. * The max limit of the emission direction.
  49619. */
  49620. direction2?: Vector3);
  49621. /**
  49622. * Called by the particle System when the direction is computed for the created particle.
  49623. * @param worldMatrix is the world matrix of the particle system
  49624. * @param directionToUpdate is the direction vector to update with the result
  49625. * @param particle is the particle we are computed the direction for
  49626. */
  49627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49628. /**
  49629. * Clones the current emitter and returns a copy of it
  49630. * @returns the new emitter
  49631. */
  49632. clone(): SphereDirectedParticleEmitter;
  49633. /**
  49634. * Called by the GPUParticleSystem to setup the update shader
  49635. * @param effect defines the update shader
  49636. */
  49637. applyToShader(effect: Effect): void;
  49638. /**
  49639. * Returns a string to use to update the GPU particles update shader
  49640. * @returns a string containng the defines string
  49641. */
  49642. getEffectDefines(): string;
  49643. /**
  49644. * Returns the string "SphereDirectedParticleEmitter"
  49645. * @returns a string containing the class name
  49646. */
  49647. getClassName(): string;
  49648. /**
  49649. * Serializes the particle system to a JSON object.
  49650. * @returns the JSON object
  49651. */
  49652. serialize(): any;
  49653. /**
  49654. * Parse properties from a JSON object
  49655. * @param serializationObject defines the JSON object
  49656. */
  49657. parse(serializationObject: any): void;
  49658. }
  49659. }
  49660. declare module BABYLON {
  49661. /**
  49662. * This represents a set of one or more post processes in Babylon.
  49663. * A post process can be used to apply a shader to a texture after it is rendered.
  49664. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49665. */
  49666. class PostProcessRenderEffect {
  49667. private _postProcesses;
  49668. private _getPostProcesses;
  49669. private _singleInstance;
  49670. private _cameras;
  49671. private _indicesForCamera;
  49672. /**
  49673. * Name of the effect
  49674. * @hidden
  49675. */
  49676. _name: string;
  49677. /**
  49678. * Instantiates a post process render effect.
  49679. * A post process can be used to apply a shader to a texture after it is rendered.
  49680. * @param engine The engine the effect is tied to
  49681. * @param name The name of the effect
  49682. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49683. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49684. */
  49685. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49686. /**
  49687. * Checks if all the post processes in the effect are supported.
  49688. */
  49689. readonly isSupported: boolean;
  49690. /**
  49691. * Updates the current state of the effect
  49692. * @hidden
  49693. */
  49694. _update(): void;
  49695. /**
  49696. * Attaches the effect on cameras
  49697. * @param cameras The camera to attach to.
  49698. * @hidden
  49699. */
  49700. _attachCameras(cameras: Camera): void;
  49701. /**
  49702. * Attaches the effect on cameras
  49703. * @param cameras The camera to attach to.
  49704. * @hidden
  49705. */
  49706. _attachCameras(cameras: Camera[]): void;
  49707. /**
  49708. * Detatches the effect on cameras
  49709. * @param cameras The camera to detatch from.
  49710. * @hidden
  49711. */
  49712. _detachCameras(cameras: Camera): void;
  49713. /**
  49714. * Detatches the effect on cameras
  49715. * @param cameras The camera to detatch from.
  49716. * @hidden
  49717. */
  49718. _detachCameras(cameras: Camera[]): void;
  49719. /**
  49720. * Enables the effect on given cameras
  49721. * @param cameras The camera to enable.
  49722. * @hidden
  49723. */
  49724. _enable(cameras: Camera): void;
  49725. /**
  49726. * Enables the effect on given cameras
  49727. * @param cameras The camera to enable.
  49728. * @hidden
  49729. */
  49730. _enable(cameras: Nullable<Camera[]>): void;
  49731. /**
  49732. * Disables the effect on the given cameras
  49733. * @param cameras The camera to disable.
  49734. * @hidden
  49735. */
  49736. _disable(cameras: Camera): void;
  49737. /**
  49738. * Disables the effect on the given cameras
  49739. * @param cameras The camera to disable.
  49740. * @hidden
  49741. */
  49742. _disable(cameras: Nullable<Camera[]>): void;
  49743. /**
  49744. * Gets a list of the post processes contained in the effect.
  49745. * @param camera The camera to get the post processes on.
  49746. * @returns The list of the post processes in the effect.
  49747. */
  49748. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49749. }
  49750. }
  49751. declare module BABYLON {
  49752. /**
  49753. * PostProcessRenderPipeline
  49754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49755. */
  49756. class PostProcessRenderPipeline {
  49757. private engine;
  49758. private _renderEffects;
  49759. private _renderEffectsForIsolatedPass;
  49760. /**
  49761. * @hidden
  49762. */
  49763. protected _cameras: Camera[];
  49764. /** @hidden */
  49765. _name: string;
  49766. /**
  49767. * Initializes a PostProcessRenderPipeline
  49768. * @param engine engine to add the pipeline to
  49769. * @param name name of the pipeline
  49770. */
  49771. constructor(engine: Engine, name: string);
  49772. /**
  49773. * "PostProcessRenderPipeline"
  49774. * @returns "PostProcessRenderPipeline"
  49775. */
  49776. getClassName(): string;
  49777. /**
  49778. * If all the render effects in the pipeline are support
  49779. */
  49780. readonly isSupported: boolean;
  49781. /**
  49782. * Adds an effect to the pipeline
  49783. * @param renderEffect the effect to add
  49784. */
  49785. addEffect(renderEffect: PostProcessRenderEffect): void;
  49786. /** @hidden */
  49787. _rebuild(): void;
  49788. /** @hidden */
  49789. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49790. /** @hidden */
  49791. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49792. /** @hidden */
  49793. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49794. /** @hidden */
  49795. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49796. /** @hidden */
  49797. _attachCameras(cameras: Camera, unique: boolean): void;
  49798. /** @hidden */
  49799. _attachCameras(cameras: Camera[], unique: boolean): void;
  49800. /** @hidden */
  49801. _detachCameras(cameras: Camera): void;
  49802. /** @hidden */
  49803. _detachCameras(cameras: Nullable<Camera[]>): void;
  49804. /** @hidden */
  49805. _update(): void;
  49806. /** @hidden */
  49807. _reset(): void;
  49808. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49809. /**
  49810. * Disposes of the pipeline
  49811. */
  49812. dispose(): void;
  49813. }
  49814. }
  49815. declare module BABYLON {
  49816. /**
  49817. * PostProcessRenderPipelineManager class
  49818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49819. */
  49820. class PostProcessRenderPipelineManager {
  49821. private _renderPipelines;
  49822. /**
  49823. * Initializes a PostProcessRenderPipelineManager
  49824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49825. */
  49826. constructor();
  49827. /**
  49828. * Adds a pipeline to the manager
  49829. * @param renderPipeline The pipeline to add
  49830. */
  49831. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49832. /**
  49833. * Attaches a camera to the pipeline
  49834. * @param renderPipelineName The name of the pipeline to attach to
  49835. * @param cameras the camera to attach
  49836. * @param unique if the camera can be attached multiple times to the pipeline
  49837. */
  49838. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49839. /**
  49840. * Detaches a camera from the pipeline
  49841. * @param renderPipelineName The name of the pipeline to detach from
  49842. * @param cameras the camera to detach
  49843. */
  49844. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49845. /**
  49846. * Enables an effect by name on a pipeline
  49847. * @param renderPipelineName the name of the pipeline to enable the effect in
  49848. * @param renderEffectName the name of the effect to enable
  49849. * @param cameras the cameras that the effect should be enabled on
  49850. */
  49851. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49852. /**
  49853. * Disables an effect by name on a pipeline
  49854. * @param renderPipelineName the name of the pipeline to disable the effect in
  49855. * @param renderEffectName the name of the effect to disable
  49856. * @param cameras the cameras that the effect should be disabled on
  49857. */
  49858. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49859. /**
  49860. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49861. */
  49862. update(): void;
  49863. /** @hidden */
  49864. _rebuild(): void;
  49865. /**
  49866. * Disposes of the manager and pipelines
  49867. */
  49868. dispose(): void;
  49869. }
  49870. }
  49871. declare module BABYLON {
  49872. interface Scene {
  49873. /** @hidden (Backing field) */
  49874. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49875. /**
  49876. * Gets the postprocess render pipeline manager
  49877. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49878. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49879. */
  49880. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49881. }
  49882. /**
  49883. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49884. */
  49885. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49886. /**
  49887. * The component name helpfull to identify the component in the list of scene components.
  49888. */
  49889. readonly name: string;
  49890. /**
  49891. * The scene the component belongs to.
  49892. */
  49893. scene: Scene;
  49894. /**
  49895. * Creates a new instance of the component for the given scene
  49896. * @param scene Defines the scene to register the component in
  49897. */
  49898. constructor(scene: Scene);
  49899. /**
  49900. * Registers the component in a given scene
  49901. */
  49902. register(): void;
  49903. /**
  49904. * Rebuilds the elements related to this component in case of
  49905. * context lost for instance.
  49906. */
  49907. rebuild(): void;
  49908. /**
  49909. * Disposes the component and the associated ressources
  49910. */
  49911. dispose(): void;
  49912. private _gatherRenderTargets;
  49913. }
  49914. }
  49915. declare module BABYLON {
  49916. /**
  49917. * Helper class dealing with the extraction of spherical polynomial dataArray
  49918. * from a cube map.
  49919. */
  49920. class CubeMapToSphericalPolynomialTools {
  49921. private static FileFaces;
  49922. /**
  49923. * Converts a texture to the according Spherical Polynomial data.
  49924. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49925. *
  49926. * @param texture The texture to extract the information from.
  49927. * @return The Spherical Polynomial data.
  49928. */
  49929. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49930. /**
  49931. * Converts a cubemap to the according Spherical Polynomial data.
  49932. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49933. *
  49934. * @param cubeInfo The Cube map to extract the information from.
  49935. * @return The Spherical Polynomial data.
  49936. */
  49937. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49938. }
  49939. }
  49940. declare module BABYLON {
  49941. /**
  49942. * Header information of HDR texture files.
  49943. */
  49944. interface HDRInfo {
  49945. /**
  49946. * The height of the texture in pixels.
  49947. */
  49948. height: number;
  49949. /**
  49950. * The width of the texture in pixels.
  49951. */
  49952. width: number;
  49953. /**
  49954. * The index of the beginning of the data in the binary file.
  49955. */
  49956. dataPosition: number;
  49957. }
  49958. /**
  49959. * This groups tools to convert HDR texture to native colors array.
  49960. */
  49961. class HDRTools {
  49962. private static Ldexp;
  49963. private static Rgbe2float;
  49964. private static readStringLine;
  49965. /**
  49966. * Reads header information from an RGBE texture stored in a native array.
  49967. * More information on this format are available here:
  49968. * https://en.wikipedia.org/wiki/RGBE_image_format
  49969. *
  49970. * @param uint8array The binary file stored in native array.
  49971. * @return The header information.
  49972. */
  49973. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49974. /**
  49975. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49976. * This RGBE texture needs to store the information as a panorama.
  49977. *
  49978. * More information on this format are available here:
  49979. * https://en.wikipedia.org/wiki/RGBE_image_format
  49980. *
  49981. * @param buffer The binary file stored in an array buffer.
  49982. * @param size The expected size of the extracted cubemap.
  49983. * @return The Cube Map information.
  49984. */
  49985. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49986. /**
  49987. * Returns the pixels data extracted from an RGBE texture.
  49988. * This pixels will be stored left to right up to down in the R G B order in one array.
  49989. *
  49990. * More information on this format are available here:
  49991. * https://en.wikipedia.org/wiki/RGBE_image_format
  49992. *
  49993. * @param uint8array The binary file stored in an array buffer.
  49994. * @param hdrInfo The header information of the file.
  49995. * @return The pixels data in RGB right to left up to down order.
  49996. */
  49997. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49998. private static RGBE_ReadPixels_RLE;
  49999. }
  50000. }
  50001. declare module BABYLON {
  50002. /**
  50003. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50004. */
  50005. interface CubeMapInfo {
  50006. /**
  50007. * The pixel array for the front face.
  50008. * This is stored in format, left to right, up to down format.
  50009. */
  50010. front: Nullable<ArrayBufferView>;
  50011. /**
  50012. * The pixel array for the back face.
  50013. * This is stored in format, left to right, up to down format.
  50014. */
  50015. back: Nullable<ArrayBufferView>;
  50016. /**
  50017. * The pixel array for the left face.
  50018. * This is stored in format, left to right, up to down format.
  50019. */
  50020. left: Nullable<ArrayBufferView>;
  50021. /**
  50022. * The pixel array for the right face.
  50023. * This is stored in format, left to right, up to down format.
  50024. */
  50025. right: Nullable<ArrayBufferView>;
  50026. /**
  50027. * The pixel array for the up face.
  50028. * This is stored in format, left to right, up to down format.
  50029. */
  50030. up: Nullable<ArrayBufferView>;
  50031. /**
  50032. * The pixel array for the down face.
  50033. * This is stored in format, left to right, up to down format.
  50034. */
  50035. down: Nullable<ArrayBufferView>;
  50036. /**
  50037. * The size of the cubemap stored.
  50038. *
  50039. * Each faces will be size * size pixels.
  50040. */
  50041. size: number;
  50042. /**
  50043. * The format of the texture.
  50044. *
  50045. * RGBA, RGB.
  50046. */
  50047. format: number;
  50048. /**
  50049. * The type of the texture data.
  50050. *
  50051. * UNSIGNED_INT, FLOAT.
  50052. */
  50053. type: number;
  50054. /**
  50055. * Specifies whether the texture is in gamma space.
  50056. */
  50057. gammaSpace: boolean;
  50058. }
  50059. /**
  50060. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50061. */
  50062. class PanoramaToCubeMapTools {
  50063. private static FACE_FRONT;
  50064. private static FACE_BACK;
  50065. private static FACE_RIGHT;
  50066. private static FACE_LEFT;
  50067. private static FACE_DOWN;
  50068. private static FACE_UP;
  50069. /**
  50070. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50071. *
  50072. * @param float32Array The source data.
  50073. * @param inputWidth The width of the input panorama.
  50074. * @param inputHeight The height of the input panorama.
  50075. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50076. * @return The cubemap data
  50077. */
  50078. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50079. private static CreateCubemapTexture;
  50080. private static CalcProjectionSpherical;
  50081. }
  50082. }
  50083. declare module BABYLON {
  50084. }
  50085. declare module BABYLON {
  50086. }
  50087. declare module BABYLON {
  50088. }
  50089. declare module BABYLON {
  50090. }
  50091. declare module BABYLON {
  50092. /**
  50093. * 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.
  50094. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50095. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50096. */
  50097. class CustomProceduralTexture extends ProceduralTexture {
  50098. private _animate;
  50099. private _time;
  50100. private _config;
  50101. private _texturePath;
  50102. /**
  50103. * Instantiates a new Custom Procedural Texture.
  50104. * 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.
  50105. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50106. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50107. * @param name Define the name of the texture
  50108. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50109. * @param size Define the size of the texture to create
  50110. * @param scene Define the scene the texture belongs to
  50111. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50112. * @param generateMipMaps Define if the texture should creates mip maps or not
  50113. */
  50114. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50115. private _loadJson;
  50116. /**
  50117. * Is the texture ready to be used ? (rendered at least once)
  50118. * @returns true if ready, otherwise, false.
  50119. */
  50120. isReady(): boolean;
  50121. /**
  50122. * Render the texture to its associated render target.
  50123. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50124. */
  50125. render(useCameraPostProcess?: boolean): void;
  50126. /**
  50127. * Update the list of dependant textures samplers in the shader.
  50128. */
  50129. updateTextures(): void;
  50130. /**
  50131. * Update the uniform values of the procedural texture in the shader.
  50132. */
  50133. updateShaderUniforms(): void;
  50134. /**
  50135. * Define if the texture animates or not.
  50136. */
  50137. animate: boolean;
  50138. }
  50139. }
  50140. declare module BABYLON {
  50141. /**
  50142. * Class used to generate noise procedural textures
  50143. */
  50144. class NoiseProceduralTexture extends ProceduralTexture {
  50145. private _time;
  50146. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50147. brightness: number;
  50148. /** Defines the number of octaves to process */
  50149. octaves: number;
  50150. /** Defines the level of persistence (0.8 by default) */
  50151. persistence: number;
  50152. /** Gets or sets animation speed factor (default is 1) */
  50153. animationSpeedFactor: number;
  50154. /**
  50155. * Creates a new NoiseProceduralTexture
  50156. * @param name defines the name fo the texture
  50157. * @param size defines the size of the texture (default is 256)
  50158. * @param scene defines the hosting scene
  50159. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50160. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50161. */
  50162. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50163. private _updateShaderUniforms;
  50164. protected _getDefines(): string;
  50165. /** Generate the current state of the procedural texture */
  50166. render(useCameraPostProcess?: boolean): void;
  50167. /**
  50168. * Serializes this noise procedural texture
  50169. * @returns a serialized noise procedural texture object
  50170. */
  50171. serialize(): any;
  50172. /**
  50173. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50174. * @param parsedTexture defines parsed texture data
  50175. * @param scene defines the current scene
  50176. * @param rootUrl defines the root URL containing noise procedural texture information
  50177. * @returns a parsed NoiseProceduralTexture
  50178. */
  50179. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50180. }
  50181. }
  50182. declare module BABYLON {
  50183. /**
  50184. * 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.
  50185. * This is the base class of any Procedural texture and contains most of the shareable code.
  50186. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50187. */
  50188. class ProceduralTexture extends Texture {
  50189. isCube: boolean;
  50190. /**
  50191. * Define if the texture is enabled or not (disabled texture will not render)
  50192. */
  50193. isEnabled: boolean;
  50194. /**
  50195. * Define if the texture must be cleared before rendering (default is true)
  50196. */
  50197. autoClear: boolean;
  50198. /**
  50199. * Callback called when the texture is generated
  50200. */
  50201. onGenerated: () => void;
  50202. /**
  50203. * Event raised when the texture is generated
  50204. */
  50205. onGeneratedObservable: Observable<ProceduralTexture>;
  50206. /** @hidden */
  50207. _generateMipMaps: boolean;
  50208. /** @hidden **/
  50209. _effect: Effect;
  50210. /** @hidden */
  50211. _textures: {
  50212. [key: string]: Texture;
  50213. };
  50214. private _size;
  50215. private _currentRefreshId;
  50216. private _refreshRate;
  50217. private _vertexBuffers;
  50218. private _indexBuffer;
  50219. private _uniforms;
  50220. private _samplers;
  50221. private _fragment;
  50222. private _floats;
  50223. private _ints;
  50224. private _floatsArrays;
  50225. private _colors3;
  50226. private _colors4;
  50227. private _vectors2;
  50228. private _vectors3;
  50229. private _matrices;
  50230. private _fallbackTexture;
  50231. private _fallbackTextureUsed;
  50232. private _engine;
  50233. private _cachedDefines;
  50234. private _contentUpdateId;
  50235. private _contentData;
  50236. /**
  50237. * Instantiates a new procedural texture.
  50238. * 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.
  50239. * This is the base class of any Procedural texture and contains most of the shareable code.
  50240. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50241. * @param name Define the name of the texture
  50242. * @param size Define the size of the texture to create
  50243. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50244. * @param scene Define the scene the texture belongs to
  50245. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50246. * @param generateMipMaps Define if the texture should creates mip maps or not
  50247. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50248. */
  50249. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50250. /**
  50251. * The effect that is created when initializing the post process.
  50252. * @returns The created effect corrisponding the the postprocess.
  50253. */
  50254. getEffect(): Effect;
  50255. /**
  50256. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50257. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50258. */
  50259. getContent(): Nullable<ArrayBufferView>;
  50260. private _createIndexBuffer;
  50261. /** @hidden */
  50262. _rebuild(): void;
  50263. /**
  50264. * Resets the texture in order to recreate its associated resources.
  50265. * This can be called in case of context loss
  50266. */
  50267. reset(): void;
  50268. protected _getDefines(): string;
  50269. /**
  50270. * Is the texture ready to be used ? (rendered at least once)
  50271. * @returns true if ready, otherwise, false.
  50272. */
  50273. isReady(): boolean;
  50274. /**
  50275. * Resets the refresh counter of the texture and start bak from scratch.
  50276. * Could be useful to regenerate the texture if it is setup to render only once.
  50277. */
  50278. resetRefreshCounter(): void;
  50279. /**
  50280. * Set the fragment shader to use in order to render the texture.
  50281. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50282. */
  50283. setFragment(fragment: any): void;
  50284. /**
  50285. * Define the refresh rate of the texture or the rendering frequency.
  50286. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50287. */
  50288. refreshRate: number;
  50289. /** @hidden */
  50290. _shouldRender(): boolean;
  50291. /**
  50292. * Get the size the texture is rendering at.
  50293. * @returns the size (texture is always squared)
  50294. */
  50295. getRenderSize(): number;
  50296. /**
  50297. * Resize the texture to new value.
  50298. * @param size Define the new size the texture should have
  50299. * @param generateMipMaps Define whether the new texture should create mip maps
  50300. */
  50301. resize(size: number, generateMipMaps: boolean): void;
  50302. private _checkUniform;
  50303. /**
  50304. * Set a texture in the shader program used to render.
  50305. * @param name Define the name of the uniform samplers as defined in the shader
  50306. * @param texture Define the texture to bind to this sampler
  50307. * @return the texture itself allowing "fluent" like uniform updates
  50308. */
  50309. setTexture(name: string, texture: Texture): ProceduralTexture;
  50310. /**
  50311. * Set a float in the shader.
  50312. * @param name Define the name of the uniform as defined in the shader
  50313. * @param value Define the value to give to the uniform
  50314. * @return the texture itself allowing "fluent" like uniform updates
  50315. */
  50316. setFloat(name: string, value: number): ProceduralTexture;
  50317. /**
  50318. * Set a int in the shader.
  50319. * @param name Define the name of the uniform as defined in the shader
  50320. * @param value Define the value to give to the uniform
  50321. * @return the texture itself allowing "fluent" like uniform updates
  50322. */
  50323. setInt(name: string, value: number): ProceduralTexture;
  50324. /**
  50325. * Set an array of floats in the shader.
  50326. * @param name Define the name of the uniform as defined in the shader
  50327. * @param value Define the value to give to the uniform
  50328. * @return the texture itself allowing "fluent" like uniform updates
  50329. */
  50330. setFloats(name: string, value: number[]): ProceduralTexture;
  50331. /**
  50332. * Set a vec3 in the shader from a Color3.
  50333. * @param name Define the name of the uniform as defined in the shader
  50334. * @param value Define the value to give to the uniform
  50335. * @return the texture itself allowing "fluent" like uniform updates
  50336. */
  50337. setColor3(name: string, value: Color3): ProceduralTexture;
  50338. /**
  50339. * Set a vec4 in the shader from a Color4.
  50340. * @param name Define the name of the uniform as defined in the shader
  50341. * @param value Define the value to give to the uniform
  50342. * @return the texture itself allowing "fluent" like uniform updates
  50343. */
  50344. setColor4(name: string, value: Color4): ProceduralTexture;
  50345. /**
  50346. * Set a vec2 in the shader from a Vector2.
  50347. * @param name Define the name of the uniform as defined in the shader
  50348. * @param value Define the value to give to the uniform
  50349. * @return the texture itself allowing "fluent" like uniform updates
  50350. */
  50351. setVector2(name: string, value: Vector2): ProceduralTexture;
  50352. /**
  50353. * Set a vec3 in the shader from a Vector3.
  50354. * @param name Define the name of the uniform as defined in the shader
  50355. * @param value Define the value to give to the uniform
  50356. * @return the texture itself allowing "fluent" like uniform updates
  50357. */
  50358. setVector3(name: string, value: Vector3): ProceduralTexture;
  50359. /**
  50360. * Set a mat4 in the shader from a MAtrix.
  50361. * @param name Define the name of the uniform as defined in the shader
  50362. * @param value Define the value to give to the uniform
  50363. * @return the texture itself allowing "fluent" like uniform updates
  50364. */
  50365. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50366. /**
  50367. * Render the texture to its associated render target.
  50368. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50369. */
  50370. render(useCameraPostProcess?: boolean): void;
  50371. /**
  50372. * Clone the texture.
  50373. * @returns the cloned texture
  50374. */
  50375. clone(): ProceduralTexture;
  50376. /**
  50377. * Dispose the texture and release its asoociated resources.
  50378. */
  50379. dispose(): void;
  50380. }
  50381. }
  50382. declare module BABYLON {
  50383. interface AbstractScene {
  50384. /**
  50385. * The list of procedural textures added to the scene
  50386. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50387. */
  50388. proceduralTextures: Array<ProceduralTexture>;
  50389. }
  50390. /**
  50391. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50392. * in a given scene.
  50393. */
  50394. class ProceduralTextureSceneComponent implements ISceneComponent {
  50395. /**
  50396. * The component name helpfull to identify the component in the list of scene components.
  50397. */
  50398. readonly name: string;
  50399. /**
  50400. * The scene the component belongs to.
  50401. */
  50402. scene: Scene;
  50403. /**
  50404. * Creates a new instance of the component for the given scene
  50405. * @param scene Defines the scene to register the component in
  50406. */
  50407. constructor(scene: Scene);
  50408. /**
  50409. * Registers the component in a given scene
  50410. */
  50411. register(): void;
  50412. /**
  50413. * Rebuilds the elements related to this component in case of
  50414. * context lost for instance.
  50415. */
  50416. rebuild(): void;
  50417. /**
  50418. * Disposes the component and the associated ressources.
  50419. */
  50420. dispose(): void;
  50421. private _beforeClear;
  50422. }
  50423. }
  50424. declare module BABYLON {
  50425. /**
  50426. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50427. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50428. */
  50429. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50430. private _scene;
  50431. private _camerasToBeAttached;
  50432. /**
  50433. * ID of the sharpen post process,
  50434. */
  50435. private readonly SharpenPostProcessId;
  50436. /**
  50437. * @ignore
  50438. * ID of the image processing post process;
  50439. */
  50440. readonly ImageProcessingPostProcessId: string;
  50441. /**
  50442. * @ignore
  50443. * ID of the Fast Approximate Anti-Aliasing post process;
  50444. */
  50445. readonly FxaaPostProcessId: string;
  50446. /**
  50447. * ID of the chromatic aberration post process,
  50448. */
  50449. private readonly ChromaticAberrationPostProcessId;
  50450. /**
  50451. * ID of the grain post process
  50452. */
  50453. private readonly GrainPostProcessId;
  50454. /**
  50455. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50456. */
  50457. sharpen: SharpenPostProcess;
  50458. private _sharpenEffect;
  50459. private bloom;
  50460. /**
  50461. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50462. */
  50463. depthOfField: DepthOfFieldEffect;
  50464. /**
  50465. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50466. */
  50467. fxaa: FxaaPostProcess;
  50468. /**
  50469. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50470. */
  50471. imageProcessing: ImageProcessingPostProcess;
  50472. /**
  50473. * Chromatic aberration post process which will shift rgb colors in the image
  50474. */
  50475. chromaticAberration: ChromaticAberrationPostProcess;
  50476. private _chromaticAberrationEffect;
  50477. /**
  50478. * Grain post process which add noise to the image
  50479. */
  50480. grain: GrainPostProcess;
  50481. private _grainEffect;
  50482. /**
  50483. * Glow post process which adds a glow to emmisive areas of the image
  50484. */
  50485. private _glowLayer;
  50486. /**
  50487. * Animations which can be used to tweak settings over a period of time
  50488. */
  50489. animations: Animation[];
  50490. private _imageProcessingConfigurationObserver;
  50491. private _sharpenEnabled;
  50492. private _bloomEnabled;
  50493. private _depthOfFieldEnabled;
  50494. private _depthOfFieldBlurLevel;
  50495. private _fxaaEnabled;
  50496. private _imageProcessingEnabled;
  50497. private _defaultPipelineTextureType;
  50498. private _bloomScale;
  50499. private _chromaticAberrationEnabled;
  50500. private _grainEnabled;
  50501. private _buildAllowed;
  50502. /**
  50503. * Enable or disable the sharpen process from the pipeline
  50504. */
  50505. sharpenEnabled: boolean;
  50506. private _resizeObserver;
  50507. private _hardwareScaleLevel;
  50508. private _bloomKernel;
  50509. /**
  50510. * Specifies the size of the bloom blur kernel, relative to the final output size
  50511. */
  50512. bloomKernel: number;
  50513. /**
  50514. * Specifies the weight of the bloom in the final rendering
  50515. */
  50516. private _bloomWeight;
  50517. /**
  50518. * Specifies the luma threshold for the area that will be blurred by the bloom
  50519. */
  50520. private _bloomThreshold;
  50521. private _hdr;
  50522. /**
  50523. * The strength of the bloom.
  50524. */
  50525. bloomWeight: number;
  50526. /**
  50527. * The strength of the bloom.
  50528. */
  50529. bloomThreshold: number;
  50530. /**
  50531. * The scale of the bloom, lower value will provide better performance.
  50532. */
  50533. bloomScale: number;
  50534. /**
  50535. * Enable or disable the bloom from the pipeline
  50536. */
  50537. bloomEnabled: boolean;
  50538. private _rebuildBloom;
  50539. /**
  50540. * If the depth of field is enabled.
  50541. */
  50542. depthOfFieldEnabled: boolean;
  50543. /**
  50544. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50545. */
  50546. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50547. /**
  50548. * If the anti aliasing is enabled.
  50549. */
  50550. fxaaEnabled: boolean;
  50551. private _samples;
  50552. /**
  50553. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50554. */
  50555. samples: number;
  50556. /**
  50557. * If image processing is enabled.
  50558. */
  50559. imageProcessingEnabled: boolean;
  50560. /**
  50561. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50562. */
  50563. glowLayerEnabled: boolean;
  50564. /**
  50565. * Enable or disable the chromaticAberration process from the pipeline
  50566. */
  50567. chromaticAberrationEnabled: boolean;
  50568. /**
  50569. * Enable or disable the grain process from the pipeline
  50570. */
  50571. grainEnabled: boolean;
  50572. /**
  50573. * @constructor
  50574. * @param name - The rendering pipeline name (default: "")
  50575. * @param hdr - If high dynamic range textures should be used (default: true)
  50576. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50577. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50578. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50579. */
  50580. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50581. /**
  50582. * Force the compilation of the entire pipeline.
  50583. */
  50584. prepare(): void;
  50585. private _hasCleared;
  50586. private _prevPostProcess;
  50587. private _prevPrevPostProcess;
  50588. private _setAutoClearAndTextureSharing;
  50589. private _depthOfFieldSceneObserver;
  50590. private _buildPipeline;
  50591. private _disposePostProcesses;
  50592. /**
  50593. * Adds a camera to the pipeline
  50594. * @param camera the camera to be added
  50595. */
  50596. addCamera(camera: Camera): void;
  50597. /**
  50598. * Removes a camera from the pipeline
  50599. * @param camera the camera to remove
  50600. */
  50601. removeCamera(camera: Camera): void;
  50602. /**
  50603. * Dispose of the pipeline and stop all post processes
  50604. */
  50605. dispose(): void;
  50606. /**
  50607. * Serialize the rendering pipeline (Used when exporting)
  50608. * @returns the serialized object
  50609. */
  50610. serialize(): any;
  50611. /**
  50612. * Parse the serialized pipeline
  50613. * @param source Source pipeline.
  50614. * @param scene The scene to load the pipeline to.
  50615. * @param rootUrl The URL of the serialized pipeline.
  50616. * @returns An instantiated pipeline from the serialized object.
  50617. */
  50618. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50619. }
  50620. }
  50621. declare module BABYLON {
  50622. /**
  50623. * BABYLON.JS Chromatic Aberration GLSL Shader
  50624. * Author: Olivier Guyot
  50625. * Separates very slightly R, G and B colors on the edges of the screen
  50626. * Inspired by Francois Tarlier & Martins Upitis
  50627. */
  50628. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50629. /**
  50630. * @ignore
  50631. * The chromatic aberration PostProcess id in the pipeline
  50632. */
  50633. LensChromaticAberrationEffect: string;
  50634. /**
  50635. * @ignore
  50636. * The highlights enhancing PostProcess id in the pipeline
  50637. */
  50638. HighlightsEnhancingEffect: string;
  50639. /**
  50640. * @ignore
  50641. * The depth-of-field PostProcess id in the pipeline
  50642. */
  50643. LensDepthOfFieldEffect: string;
  50644. private _scene;
  50645. private _depthTexture;
  50646. private _grainTexture;
  50647. private _chromaticAberrationPostProcess;
  50648. private _highlightsPostProcess;
  50649. private _depthOfFieldPostProcess;
  50650. private _edgeBlur;
  50651. private _grainAmount;
  50652. private _chromaticAberration;
  50653. private _distortion;
  50654. private _highlightsGain;
  50655. private _highlightsThreshold;
  50656. private _dofDistance;
  50657. private _dofAperture;
  50658. private _dofDarken;
  50659. private _dofPentagon;
  50660. private _blurNoise;
  50661. /**
  50662. * @constructor
  50663. *
  50664. * Effect parameters are as follow:
  50665. * {
  50666. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50667. * edge_blur: number; // from 0 to x (1 for realism)
  50668. * distortion: number; // from 0 to x (1 for realism)
  50669. * grain_amount: number; // from 0 to 1
  50670. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50671. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50672. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50673. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50674. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50675. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50676. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50677. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50678. * }
  50679. * Note: if an effect parameter is unset, effect is disabled
  50680. *
  50681. * @param name The rendering pipeline name
  50682. * @param parameters - An object containing all parameters (see above)
  50683. * @param scene The scene linked to this pipeline
  50684. * @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)
  50685. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50686. */
  50687. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50688. /**
  50689. * Sets the amount of blur at the edges
  50690. * @param amount blur amount
  50691. */
  50692. setEdgeBlur(amount: number): void;
  50693. /**
  50694. * Sets edge blur to 0
  50695. */
  50696. disableEdgeBlur(): void;
  50697. /**
  50698. * Sets the amout of grain
  50699. * @param amount Amount of grain
  50700. */
  50701. setGrainAmount(amount: number): void;
  50702. /**
  50703. * Set grain amount to 0
  50704. */
  50705. disableGrain(): void;
  50706. /**
  50707. * Sets the chromatic aberration amount
  50708. * @param amount amount of chromatic aberration
  50709. */
  50710. setChromaticAberration(amount: number): void;
  50711. /**
  50712. * Sets chromatic aberration amount to 0
  50713. */
  50714. disableChromaticAberration(): void;
  50715. /**
  50716. * Sets the EdgeDistortion amount
  50717. * @param amount amount of EdgeDistortion
  50718. */
  50719. setEdgeDistortion(amount: number): void;
  50720. /**
  50721. * Sets edge distortion to 0
  50722. */
  50723. disableEdgeDistortion(): void;
  50724. /**
  50725. * Sets the FocusDistance amount
  50726. * @param amount amount of FocusDistance
  50727. */
  50728. setFocusDistance(amount: number): void;
  50729. /**
  50730. * Disables depth of field
  50731. */
  50732. disableDepthOfField(): void;
  50733. /**
  50734. * Sets the Aperture amount
  50735. * @param amount amount of Aperture
  50736. */
  50737. setAperture(amount: number): void;
  50738. /**
  50739. * Sets the DarkenOutOfFocus amount
  50740. * @param amount amount of DarkenOutOfFocus
  50741. */
  50742. setDarkenOutOfFocus(amount: number): void;
  50743. /**
  50744. * Creates a pentagon bokeh effect
  50745. */
  50746. enablePentagonBokeh(): void;
  50747. /**
  50748. * Disables the pentagon bokeh effect
  50749. */
  50750. disablePentagonBokeh(): void;
  50751. /**
  50752. * Enables noise blur
  50753. */
  50754. enableNoiseBlur(): void;
  50755. /**
  50756. * Disables noise blur
  50757. */
  50758. disableNoiseBlur(): void;
  50759. /**
  50760. * Sets the HighlightsGain amount
  50761. * @param amount amount of HighlightsGain
  50762. */
  50763. setHighlightsGain(amount: number): void;
  50764. /**
  50765. * Sets the HighlightsThreshold amount
  50766. * @param amount amount of HighlightsThreshold
  50767. */
  50768. setHighlightsThreshold(amount: number): void;
  50769. /**
  50770. * Disables highlights
  50771. */
  50772. disableHighlights(): void;
  50773. /**
  50774. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50775. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50776. */
  50777. dispose(disableDepthRender?: boolean): void;
  50778. private _createChromaticAberrationPostProcess;
  50779. private _createHighlightsPostProcess;
  50780. private _createDepthOfFieldPostProcess;
  50781. private _createGrainTexture;
  50782. }
  50783. }
  50784. declare module BABYLON {
  50785. /**
  50786. * Render pipeline to produce ssao effect
  50787. */
  50788. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50789. /**
  50790. * @ignore
  50791. * The PassPostProcess id in the pipeline that contains the original scene color
  50792. */
  50793. SSAOOriginalSceneColorEffect: string;
  50794. /**
  50795. * @ignore
  50796. * The SSAO PostProcess id in the pipeline
  50797. */
  50798. SSAORenderEffect: string;
  50799. /**
  50800. * @ignore
  50801. * The horizontal blur PostProcess id in the pipeline
  50802. */
  50803. SSAOBlurHRenderEffect: string;
  50804. /**
  50805. * @ignore
  50806. * The vertical blur PostProcess id in the pipeline
  50807. */
  50808. SSAOBlurVRenderEffect: string;
  50809. /**
  50810. * @ignore
  50811. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50812. */
  50813. SSAOCombineRenderEffect: string;
  50814. /**
  50815. * The output strength of the SSAO post-process. Default value is 1.0.
  50816. */
  50817. totalStrength: number;
  50818. /**
  50819. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50820. */
  50821. maxZ: number;
  50822. /**
  50823. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50824. */
  50825. minZAspect: number;
  50826. private _samples;
  50827. /**
  50828. * Number of samples used for the SSAO calculations. Default value is 8
  50829. */
  50830. samples: number;
  50831. private _textureSamples;
  50832. /**
  50833. * Number of samples to use for antialiasing
  50834. */
  50835. textureSamples: number;
  50836. /**
  50837. * Ratio object used for SSAO ratio and blur ratio
  50838. */
  50839. private _ratio;
  50840. /**
  50841. * Dynamically generated sphere sampler.
  50842. */
  50843. private _sampleSphere;
  50844. /**
  50845. * Blur filter offsets
  50846. */
  50847. private _samplerOffsets;
  50848. private _expensiveBlur;
  50849. /**
  50850. * If bilateral blur should be used
  50851. */
  50852. expensiveBlur: boolean;
  50853. /**
  50854. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50855. */
  50856. radius: number;
  50857. /**
  50858. * The base color of the SSAO post-process
  50859. * The final result is "base + ssao" between [0, 1]
  50860. */
  50861. base: number;
  50862. /**
  50863. * Support test.
  50864. */
  50865. static readonly IsSupported: boolean;
  50866. private _scene;
  50867. private _depthTexture;
  50868. private _normalTexture;
  50869. private _randomTexture;
  50870. private _originalColorPostProcess;
  50871. private _ssaoPostProcess;
  50872. private _blurHPostProcess;
  50873. private _blurVPostProcess;
  50874. private _ssaoCombinePostProcess;
  50875. private _firstUpdate;
  50876. /**
  50877. * @constructor
  50878. * @param name The rendering pipeline name
  50879. * @param scene The scene linked to this pipeline
  50880. * @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 }
  50881. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50882. */
  50883. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50884. /**
  50885. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50886. */
  50887. dispose(disableGeometryBufferRenderer?: boolean): void;
  50888. private _createBlurPostProcess;
  50889. /** @hidden */
  50890. _rebuild(): void;
  50891. private _bits;
  50892. private _radicalInverse_VdC;
  50893. private _hammersley;
  50894. private _hemisphereSample_uniform;
  50895. private _generateHemisphere;
  50896. private _createSSAOPostProcess;
  50897. private _createSSAOCombinePostProcess;
  50898. private _createRandomTexture;
  50899. /**
  50900. * Serialize the rendering pipeline (Used when exporting)
  50901. * @returns the serialized object
  50902. */
  50903. serialize(): any;
  50904. /**
  50905. * Parse the serialized pipeline
  50906. * @param source Source pipeline.
  50907. * @param scene The scene to load the pipeline to.
  50908. * @param rootUrl The URL of the serialized pipeline.
  50909. * @returns An instantiated pipeline from the serialized object.
  50910. */
  50911. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50912. }
  50913. }
  50914. declare module BABYLON {
  50915. /**
  50916. * Render pipeline to produce ssao effect
  50917. */
  50918. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50919. /**
  50920. * @ignore
  50921. * The PassPostProcess id in the pipeline that contains the original scene color
  50922. */
  50923. SSAOOriginalSceneColorEffect: string;
  50924. /**
  50925. * @ignore
  50926. * The SSAO PostProcess id in the pipeline
  50927. */
  50928. SSAORenderEffect: string;
  50929. /**
  50930. * @ignore
  50931. * The horizontal blur PostProcess id in the pipeline
  50932. */
  50933. SSAOBlurHRenderEffect: string;
  50934. /**
  50935. * @ignore
  50936. * The vertical blur PostProcess id in the pipeline
  50937. */
  50938. SSAOBlurVRenderEffect: string;
  50939. /**
  50940. * @ignore
  50941. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50942. */
  50943. SSAOCombineRenderEffect: string;
  50944. /**
  50945. * The output strength of the SSAO post-process. Default value is 1.0.
  50946. */
  50947. totalStrength: number;
  50948. /**
  50949. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50950. */
  50951. radius: number;
  50952. /**
  50953. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50954. * Must not be equal to fallOff and superior to fallOff.
  50955. * Default value is 0.975
  50956. */
  50957. area: number;
  50958. /**
  50959. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50960. * Must not be equal to area and inferior to area.
  50961. * Default value is 0.0
  50962. */
  50963. fallOff: number;
  50964. /**
  50965. * The base color of the SSAO post-process
  50966. * The final result is "base + ssao" between [0, 1]
  50967. */
  50968. base: number;
  50969. private _scene;
  50970. private _depthTexture;
  50971. private _randomTexture;
  50972. private _originalColorPostProcess;
  50973. private _ssaoPostProcess;
  50974. private _blurHPostProcess;
  50975. private _blurVPostProcess;
  50976. private _ssaoCombinePostProcess;
  50977. private _firstUpdate;
  50978. /**
  50979. * @constructor
  50980. * @param name - The rendering pipeline name
  50981. * @param scene - The scene linked to this pipeline
  50982. * @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 }
  50983. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50984. */
  50985. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50986. /**
  50987. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50988. */
  50989. dispose(disableDepthRender?: boolean): void;
  50990. private _createBlurPostProcess;
  50991. /** @hidden */
  50992. _rebuild(): void;
  50993. private _createSSAOPostProcess;
  50994. private _createSSAOCombinePostProcess;
  50995. private _createRandomTexture;
  50996. }
  50997. }
  50998. declare module BABYLON {
  50999. /**
  51000. * Standard rendering pipeline
  51001. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51002. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51003. */
  51004. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51005. /**
  51006. * Public members
  51007. */
  51008. /**
  51009. * Post-process which contains the original scene color before the pipeline applies all the effects
  51010. */
  51011. originalPostProcess: Nullable<PostProcess>;
  51012. /**
  51013. * Post-process used to down scale an image x4
  51014. */
  51015. downSampleX4PostProcess: Nullable<PostProcess>;
  51016. /**
  51017. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51018. */
  51019. brightPassPostProcess: Nullable<PostProcess>;
  51020. /**
  51021. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51022. */
  51023. blurHPostProcesses: PostProcess[];
  51024. /**
  51025. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51026. */
  51027. blurVPostProcesses: PostProcess[];
  51028. /**
  51029. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51030. */
  51031. textureAdderPostProcess: Nullable<PostProcess>;
  51032. /**
  51033. * Post-process used to create volumetric lighting effect
  51034. */
  51035. volumetricLightPostProcess: Nullable<PostProcess>;
  51036. /**
  51037. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51038. */
  51039. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51040. /**
  51041. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51042. */
  51043. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51044. /**
  51045. * Post-process used to merge the volumetric light effect and the real scene color
  51046. */
  51047. volumetricLightMergePostProces: Nullable<PostProcess>;
  51048. /**
  51049. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51050. */
  51051. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51052. /**
  51053. * Base post-process used to calculate the average luminance of the final image for HDR
  51054. */
  51055. luminancePostProcess: Nullable<PostProcess>;
  51056. /**
  51057. * Post-processes used to create down sample post-processes in order to get
  51058. * the average luminance of the final image for HDR
  51059. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51060. */
  51061. luminanceDownSamplePostProcesses: PostProcess[];
  51062. /**
  51063. * Post-process used to create a HDR effect (light adaptation)
  51064. */
  51065. hdrPostProcess: Nullable<PostProcess>;
  51066. /**
  51067. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51068. */
  51069. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51070. /**
  51071. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51072. */
  51073. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51074. /**
  51075. * Post-process used to merge the final HDR post-process and the real scene color
  51076. */
  51077. hdrFinalPostProcess: Nullable<PostProcess>;
  51078. /**
  51079. * Post-process used to create a lens flare effect
  51080. */
  51081. lensFlarePostProcess: Nullable<PostProcess>;
  51082. /**
  51083. * Post-process that merges the result of the lens flare post-process and the real scene color
  51084. */
  51085. lensFlareComposePostProcess: Nullable<PostProcess>;
  51086. /**
  51087. * Post-process used to create a motion blur effect
  51088. */
  51089. motionBlurPostProcess: Nullable<PostProcess>;
  51090. /**
  51091. * Post-process used to create a depth of field effect
  51092. */
  51093. depthOfFieldPostProcess: Nullable<PostProcess>;
  51094. /**
  51095. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51096. */
  51097. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51098. /**
  51099. * Represents the brightness threshold in order to configure the illuminated surfaces
  51100. */
  51101. brightThreshold: number;
  51102. /**
  51103. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51104. */
  51105. blurWidth: number;
  51106. /**
  51107. * Sets if the blur for highlighted surfaces must be only horizontal
  51108. */
  51109. horizontalBlur: boolean;
  51110. /**
  51111. * Sets the overall exposure used by the pipeline
  51112. */
  51113. exposure: number;
  51114. /**
  51115. * Texture used typically to simulate "dirty" on camera lens
  51116. */
  51117. lensTexture: Nullable<Texture>;
  51118. /**
  51119. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51120. */
  51121. volumetricLightCoefficient: number;
  51122. /**
  51123. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51124. */
  51125. volumetricLightPower: number;
  51126. /**
  51127. * Used the set the blur intensity to smooth the volumetric lights
  51128. */
  51129. volumetricLightBlurScale: number;
  51130. /**
  51131. * Light (spot or directional) used to generate the volumetric lights rays
  51132. * The source light must have a shadow generate so the pipeline can get its
  51133. * depth map
  51134. */
  51135. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51136. /**
  51137. * For eye adaptation, represents the minimum luminance the eye can see
  51138. */
  51139. hdrMinimumLuminance: number;
  51140. /**
  51141. * For eye adaptation, represents the decrease luminance speed
  51142. */
  51143. hdrDecreaseRate: number;
  51144. /**
  51145. * For eye adaptation, represents the increase luminance speed
  51146. */
  51147. hdrIncreaseRate: number;
  51148. /**
  51149. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51150. */
  51151. lensColorTexture: Nullable<Texture>;
  51152. /**
  51153. * The overall strengh for the lens flare effect
  51154. */
  51155. lensFlareStrength: number;
  51156. /**
  51157. * Dispersion coefficient for lens flare ghosts
  51158. */
  51159. lensFlareGhostDispersal: number;
  51160. /**
  51161. * Main lens flare halo width
  51162. */
  51163. lensFlareHaloWidth: number;
  51164. /**
  51165. * Based on the lens distortion effect, defines how much the lens flare result
  51166. * is distorted
  51167. */
  51168. lensFlareDistortionStrength: number;
  51169. /**
  51170. * Lens star texture must be used to simulate rays on the flares and is available
  51171. * in the documentation
  51172. */
  51173. lensStarTexture: Nullable<Texture>;
  51174. /**
  51175. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51176. * flare effect by taking account of the dirt texture
  51177. */
  51178. lensFlareDirtTexture: Nullable<Texture>;
  51179. /**
  51180. * Represents the focal length for the depth of field effect
  51181. */
  51182. depthOfFieldDistance: number;
  51183. /**
  51184. * Represents the blur intensity for the blurred part of the depth of field effect
  51185. */
  51186. depthOfFieldBlurWidth: number;
  51187. /**
  51188. * For motion blur, defines how much the image is blurred by the movement
  51189. */
  51190. motionStrength: number;
  51191. /**
  51192. * List of animations for the pipeline (IAnimatable implementation)
  51193. */
  51194. animations: Animation[];
  51195. /**
  51196. * Private members
  51197. */
  51198. private _scene;
  51199. private _currentDepthOfFieldSource;
  51200. private _basePostProcess;
  51201. private _hdrCurrentLuminance;
  51202. private _floatTextureType;
  51203. private _ratio;
  51204. private _bloomEnabled;
  51205. private _depthOfFieldEnabled;
  51206. private _vlsEnabled;
  51207. private _lensFlareEnabled;
  51208. private _hdrEnabled;
  51209. private _motionBlurEnabled;
  51210. private _fxaaEnabled;
  51211. private _motionBlurSamples;
  51212. private _volumetricLightStepsCount;
  51213. private _samples;
  51214. /**
  51215. * @ignore
  51216. * Specifies if the bloom pipeline is enabled
  51217. */
  51218. BloomEnabled: boolean;
  51219. /**
  51220. * @ignore
  51221. * Specifies if the depth of field pipeline is enabed
  51222. */
  51223. DepthOfFieldEnabled: boolean;
  51224. /**
  51225. * @ignore
  51226. * Specifies if the lens flare pipeline is enabed
  51227. */
  51228. LensFlareEnabled: boolean;
  51229. /**
  51230. * @ignore
  51231. * Specifies if the HDR pipeline is enabled
  51232. */
  51233. HDREnabled: boolean;
  51234. /**
  51235. * @ignore
  51236. * Specifies if the volumetric lights scattering effect is enabled
  51237. */
  51238. VLSEnabled: boolean;
  51239. /**
  51240. * @ignore
  51241. * Specifies if the motion blur effect is enabled
  51242. */
  51243. MotionBlurEnabled: boolean;
  51244. /**
  51245. * Specifies if anti-aliasing is enabled
  51246. */
  51247. fxaaEnabled: boolean;
  51248. /**
  51249. * Specifies the number of steps used to calculate the volumetric lights
  51250. * Typically in interval [50, 200]
  51251. */
  51252. volumetricLightStepsCount: number;
  51253. /**
  51254. * Specifies the number of samples used for the motion blur effect
  51255. * Typically in interval [16, 64]
  51256. */
  51257. motionBlurSamples: number;
  51258. /**
  51259. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51260. */
  51261. samples: number;
  51262. /**
  51263. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51264. * @constructor
  51265. * @param name The rendering pipeline name
  51266. * @param scene The scene linked to this pipeline
  51267. * @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)
  51268. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51269. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51270. */
  51271. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51272. private _buildPipeline;
  51273. private _createDownSampleX4PostProcess;
  51274. private _createBrightPassPostProcess;
  51275. private _createBlurPostProcesses;
  51276. private _createTextureAdderPostProcess;
  51277. private _createVolumetricLightPostProcess;
  51278. private _createLuminancePostProcesses;
  51279. private _createHdrPostProcess;
  51280. private _createLensFlarePostProcess;
  51281. private _createDepthOfFieldPostProcess;
  51282. private _createMotionBlurPostProcess;
  51283. private _getDepthTexture;
  51284. private _disposePostProcesses;
  51285. /**
  51286. * Dispose of the pipeline and stop all post processes
  51287. */
  51288. dispose(): void;
  51289. /**
  51290. * Serialize the rendering pipeline (Used when exporting)
  51291. * @returns the serialized object
  51292. */
  51293. serialize(): any;
  51294. /**
  51295. * Parse the serialized pipeline
  51296. * @param source Source pipeline.
  51297. * @param scene The scene to load the pipeline to.
  51298. * @param rootUrl The URL of the serialized pipeline.
  51299. * @returns An instantiated pipeline from the serialized object.
  51300. */
  51301. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51302. /**
  51303. * Luminance steps
  51304. */
  51305. static LuminanceSteps: number;
  51306. }
  51307. }