babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667
  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. * The action to be carried out following a trigger
  2814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2815. */
  2816. class Action {
  2817. /** the trigger, with or without parameters, for the action */
  2818. triggerOptions: any;
  2819. /**
  2820. * Trigger for the action
  2821. */
  2822. trigger: number;
  2823. /**
  2824. * Internal only - manager for action
  2825. * @hidden
  2826. */
  2827. _actionManager: ActionManager;
  2828. private _nextActiveAction;
  2829. private _child;
  2830. private _condition?;
  2831. private _triggerParameter;
  2832. /**
  2833. * An event triggered prior to action being executed.
  2834. */
  2835. onBeforeExecuteObservable: Observable<Action>;
  2836. /**
  2837. * Creates a new Action
  2838. * @param triggerOptions the trigger, with or without parameters, for the action
  2839. * @param condition an optional determinant of action
  2840. */
  2841. constructor(
  2842. /** the trigger, with or without parameters, for the action */
  2843. triggerOptions: any, condition?: Condition);
  2844. /**
  2845. * Internal only
  2846. * @hidden
  2847. */
  2848. _prepare(): void;
  2849. /**
  2850. * Gets the trigger parameters
  2851. * @returns the trigger parameters
  2852. */
  2853. getTriggerParameter(): any;
  2854. /**
  2855. * Internal only - executes current action event
  2856. * @hidden
  2857. */
  2858. _executeCurrent(evt?: ActionEvent): void;
  2859. /**
  2860. * Execute placeholder for child classes
  2861. * @param evt optional action event
  2862. */
  2863. execute(evt?: ActionEvent): void;
  2864. /**
  2865. * Skips to next active action
  2866. */
  2867. skipToNextActiveAction(): void;
  2868. /**
  2869. * Adds action to chain of actions, may be a DoNothingAction
  2870. * @param action defines the next action to execute
  2871. * @returns The action passed in
  2872. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2873. */
  2874. then(action: Action): Action;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getProperty(propertyPath: string): string;
  2880. /**
  2881. * Internal only
  2882. * @hidden
  2883. */
  2884. _getEffectiveTarget(target: any, propertyPath: string): any;
  2885. /**
  2886. * Serialize placeholder for child classes
  2887. * @param parent of child
  2888. * @returns the serialized object
  2889. */
  2890. serialize(parent: any): any;
  2891. /**
  2892. * Internal only called by serialize
  2893. * @hidden
  2894. */
  2895. protected _serialize(serializedAction: any, parent?: any): any;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _SerializeValueAsString: (value: any) => string;
  2901. /**
  2902. * Internal only
  2903. * @hidden
  2904. */
  2905. static _GetTargetProperty: (target: Scene | Node) => {
  2906. name: string;
  2907. targetType: string;
  2908. value: string;
  2909. };
  2910. }
  2911. }
  2912. declare module BABYLON {
  2913. /**
  2914. * ActionEvent is the event being sent when an action is triggered.
  2915. */
  2916. class ActionEvent {
  2917. /** The mesh or sprite that triggered the action */
  2918. source: any;
  2919. /** The X mouse cursor position at the time of the event */
  2920. pointerX: number;
  2921. /** The Y mouse cursor position at the time of the event */
  2922. pointerY: number;
  2923. /** The mesh that is currently pointed at (can be null) */
  2924. meshUnderPointer: Nullable<AbstractMesh>;
  2925. /** the original (browser) event that triggered the ActionEvent */
  2926. sourceEvent?: any;
  2927. /** additional data for the event */
  2928. additionalData?: any;
  2929. /**
  2930. * Creates a new ActionEvent
  2931. * @param source The mesh or sprite that triggered the action
  2932. * @param pointerX The X mouse cursor position at the time of the event
  2933. * @param pointerY The Y mouse cursor position at the time of the event
  2934. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2935. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2936. * @param additionalData additional data for the event
  2937. */
  2938. constructor(
  2939. /** The mesh or sprite that triggered the action */
  2940. source: any,
  2941. /** The X mouse cursor position at the time of the event */
  2942. pointerX: number,
  2943. /** The Y mouse cursor position at the time of the event */
  2944. pointerY: number,
  2945. /** The mesh that is currently pointed at (can be null) */
  2946. meshUnderPointer: Nullable<AbstractMesh>,
  2947. /** the original (browser) event that triggered the ActionEvent */
  2948. sourceEvent?: any,
  2949. /** additional data for the event */
  2950. additionalData?: any);
  2951. /**
  2952. * Helper function to auto-create an ActionEvent from a source mesh.
  2953. * @param source The source mesh that triggered the event
  2954. * @param evt The original (browser) event
  2955. * @param additionalData additional data for the event
  2956. * @returns the new ActionEvent
  2957. */
  2958. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2959. /**
  2960. * Helper function to auto-create an ActionEvent from a source sprite
  2961. * @param source The source sprite that triggered the event
  2962. * @param scene Scene associated with the sprite
  2963. * @param evt The original (browser) event
  2964. * @param additionalData additional data for the event
  2965. * @returns the new ActionEvent
  2966. */
  2967. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2968. /**
  2969. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2970. * @param scene the scene where the event occurred
  2971. * @param evt The original (browser) event
  2972. * @returns the new ActionEvent
  2973. */
  2974. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2975. /**
  2976. * Helper function to auto-create an ActionEvent from a primitive
  2977. * @param prim defines the target primitive
  2978. * @param pointerPos defines the pointer position
  2979. * @param evt The original (browser) event
  2980. * @param additionalData additional data for the event
  2981. * @returns the new ActionEvent
  2982. */
  2983. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2984. }
  2985. /**
  2986. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2987. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2989. */
  2990. class ActionManager {
  2991. /**
  2992. * Nothing
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly NothingTrigger: number;
  2996. /**
  2997. * On pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnPickTrigger: number;
  3001. /**
  3002. * On left pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnLeftPickTrigger: number;
  3006. /**
  3007. * On right pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnRightPickTrigger: number;
  3011. /**
  3012. * On center pick
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnCenterPickTrigger: number;
  3016. /**
  3017. * On pick down
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnPickDownTrigger: number;
  3021. /**
  3022. * On double pick
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnDoublePickTrigger: number;
  3026. /**
  3027. * On pick up
  3028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3029. */
  3030. static readonly OnPickUpTrigger: number;
  3031. /**
  3032. * On pick out.
  3033. * This trigger will only be raised if you also declared a OnPickDown
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnPickOutTrigger: number;
  3037. /**
  3038. * On long press
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnLongPressTrigger: number;
  3042. /**
  3043. * On pointer over
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOverTrigger: number;
  3047. /**
  3048. * On pointer out
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnPointerOutTrigger: number;
  3052. /**
  3053. * On every frame
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnEveryFrameTrigger: number;
  3057. /**
  3058. * On intersection enter
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionEnterTrigger: number;
  3062. /**
  3063. * On intersection exit
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnIntersectionExitTrigger: number;
  3067. /**
  3068. * On key down
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyDownTrigger: number;
  3072. /**
  3073. * On key up
  3074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3075. */
  3076. static readonly OnKeyUpTrigger: number;
  3077. /** Gets the list of active triggers */
  3078. static Triggers: {
  3079. [key: string]: number;
  3080. };
  3081. /** Gets the list of actions */
  3082. actions: Action[];
  3083. /** Gets the cursor to use when hovering items */
  3084. hoverCursor: string;
  3085. private _scene;
  3086. /**
  3087. * Creates a new action manager
  3088. * @param scene defines the hosting scene
  3089. */
  3090. constructor(scene: Scene);
  3091. /**
  3092. * Releases all associated resources
  3093. */
  3094. dispose(): void;
  3095. /**
  3096. * Gets hosting scene
  3097. * @returns the hosting scene
  3098. */
  3099. getScene(): Scene;
  3100. /**
  3101. * Does this action manager handles actions of any of the given triggers
  3102. * @param triggers defines the triggers to be tested
  3103. * @return a boolean indicating whether one (or more) of the triggers is handled
  3104. */
  3105. hasSpecificTriggers(triggers: number[]): boolean;
  3106. /**
  3107. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3108. * speed.
  3109. * @param triggerA defines the trigger to be tested
  3110. * @param triggerB defines the trigger to be tested
  3111. * @return a boolean indicating whether one (or more) of the triggers is handled
  3112. */
  3113. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3114. /**
  3115. * Does this action manager handles actions of a given trigger
  3116. * @param trigger defines the trigger to be tested
  3117. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3118. * @return whether the trigger is handled
  3119. */
  3120. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3121. /**
  3122. * Does this action manager has pointer triggers
  3123. */
  3124. readonly hasPointerTriggers: boolean;
  3125. /**
  3126. * Does this action manager has pick triggers
  3127. */
  3128. readonly hasPickTriggers: boolean;
  3129. /**
  3130. * Does exist one action manager with at least one trigger
  3131. **/
  3132. static readonly HasTriggers: boolean;
  3133. /**
  3134. * Does exist one action manager with at least one pick trigger
  3135. **/
  3136. static readonly HasPickTriggers: boolean;
  3137. /**
  3138. * Does exist one action manager that handles actions of a given trigger
  3139. * @param trigger defines the trigger to be tested
  3140. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3141. **/
  3142. static HasSpecificTrigger(trigger: number): boolean;
  3143. /**
  3144. * Registers an action to this action manager
  3145. * @param action defines the action to be registered
  3146. * @return the action amended (prepared) after registration
  3147. */
  3148. registerAction(action: Action): Nullable<Action>;
  3149. /**
  3150. * Unregisters an action to this action manager
  3151. * @param action defines the action to be unregistered
  3152. * @return a boolean indicating whether the action has been unregistered
  3153. */
  3154. unregisterAction(action: Action): Boolean;
  3155. /**
  3156. * Process a specific trigger
  3157. * @param trigger defines the trigger to process
  3158. * @param evt defines the event details to be processed
  3159. */
  3160. processTrigger(trigger: number, evt?: ActionEvent): void;
  3161. /** @hidden */
  3162. _getEffectiveTarget(target: any, propertyPath: string): any;
  3163. /** @hidden */
  3164. _getProperty(propertyPath: string): string;
  3165. /**
  3166. * Serialize this manager to a JSON object
  3167. * @param name defines the property name to store this manager
  3168. * @returns a JSON representation of this manager
  3169. */
  3170. serialize(name: string): any;
  3171. /**
  3172. * Creates a new ActionManager from a JSON data
  3173. * @param parsedActions defines the JSON data to read from
  3174. * @param object defines the hosting mesh
  3175. * @param scene defines the hosting scene
  3176. */
  3177. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3178. /**
  3179. * Get a trigger name by index
  3180. * @param trigger defines the trigger index
  3181. * @returns a trigger name
  3182. */
  3183. static GetTriggerName(trigger: number): string;
  3184. }
  3185. }
  3186. declare module BABYLON {
  3187. /**
  3188. * A Condition applied to an Action
  3189. */
  3190. class Condition {
  3191. /**
  3192. * Internal only - manager for action
  3193. * @hidden
  3194. */
  3195. _actionManager: ActionManager;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _evaluationId: number;
  3201. /**
  3202. * Internal only
  3203. * @hidden
  3204. */
  3205. _currentResult: boolean;
  3206. /**
  3207. * Creates a new Condition
  3208. * @param actionManager the manager of the action the condition is applied to
  3209. */
  3210. constructor(actionManager: ActionManager);
  3211. /**
  3212. * Check if the current condition is valid
  3213. * @returns a boolean
  3214. */
  3215. isValid(): boolean;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getProperty(propertyPath: string): string;
  3221. /**
  3222. * Internal only
  3223. * @hidden
  3224. */
  3225. _getEffectiveTarget(target: any, propertyPath: string): any;
  3226. /**
  3227. * Serialize placeholder for child classes
  3228. * @returns the serialized object
  3229. */
  3230. serialize(): any;
  3231. /**
  3232. * Internal only
  3233. * @hidden
  3234. */
  3235. protected _serialize(serializedCondition: any): any;
  3236. }
  3237. /**
  3238. * Defines specific conditional operators as extensions of Condition
  3239. */
  3240. class ValueCondition extends Condition {
  3241. /** path to specify the property of the target the conditional operator uses */
  3242. propertyPath: string;
  3243. /** the value compared by the conditional operator against the current value of the property */
  3244. value: any;
  3245. /** the conditional operator, default ValueCondition.IsEqual */
  3246. operator: number;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsEqual;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsDifferent;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsGreater;
  3262. /**
  3263. * Internal only
  3264. * @hidden
  3265. */
  3266. private static _IsLesser;
  3267. /**
  3268. * returns the number for IsEqual
  3269. */
  3270. static readonly IsEqual: number;
  3271. /**
  3272. * Returns the number for IsDifferent
  3273. */
  3274. static readonly IsDifferent: number;
  3275. /**
  3276. * Returns the number for IsGreater
  3277. */
  3278. static readonly IsGreater: number;
  3279. /**
  3280. * Returns the number for IsLesser
  3281. */
  3282. static readonly IsLesser: number;
  3283. /**
  3284. * Internal only The action manager for the condition
  3285. * @hidden
  3286. */
  3287. _actionManager: ActionManager;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _target;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _effectiveTarget;
  3298. /**
  3299. * Internal only
  3300. * @hidden
  3301. */
  3302. private _property;
  3303. /**
  3304. * Creates a new ValueCondition
  3305. * @param actionManager manager for the action the condition applies to
  3306. * @param target for the action
  3307. * @param propertyPath path to specify the property of the target the conditional operator uses
  3308. * @param value the value compared by the conditional operator against the current value of the property
  3309. * @param operator the conditional operator, default ValueCondition.IsEqual
  3310. */
  3311. constructor(actionManager: ActionManager, target: any,
  3312. /** path to specify the property of the target the conditional operator uses */
  3313. propertyPath: string,
  3314. /** the value compared by the conditional operator against the current value of the property */
  3315. value: any,
  3316. /** the conditional operator, default ValueCondition.IsEqual */
  3317. operator?: number);
  3318. /**
  3319. * Compares the given value with the property value for the specified conditional operator
  3320. * @returns the result of the comparison
  3321. */
  3322. isValid(): boolean;
  3323. /**
  3324. * Serialize the ValueCondition into a JSON compatible object
  3325. * @returns serialization object
  3326. */
  3327. serialize(): any;
  3328. /**
  3329. * Gets the name of the conditional operator for the ValueCondition
  3330. * @param operator the conditional operator
  3331. * @returns the name
  3332. */
  3333. static GetOperatorName(operator: number): string;
  3334. }
  3335. /**
  3336. * Defines a predicate condition as an extension of Condition
  3337. */
  3338. class PredicateCondition extends Condition {
  3339. /** defines the predicate function used to validate the condition */
  3340. predicate: () => boolean;
  3341. /**
  3342. * Internal only - manager for action
  3343. * @hidden
  3344. */
  3345. _actionManager: ActionManager;
  3346. /**
  3347. * Creates a new PredicateCondition
  3348. * @param actionManager manager for the action the condition applies to
  3349. * @param predicate defines the predicate function used to validate the condition
  3350. */
  3351. constructor(actionManager: ActionManager,
  3352. /** defines the predicate function used to validate the condition */
  3353. predicate: () => boolean);
  3354. /**
  3355. * @returns the validity of the predicate condition
  3356. */
  3357. isValid(): boolean;
  3358. }
  3359. /**
  3360. * Defines a state condition as an extension of Condition
  3361. */
  3362. class StateCondition extends Condition {
  3363. /** Value to compare with target state */
  3364. value: string;
  3365. /**
  3366. * Internal only - manager for action
  3367. * @hidden
  3368. */
  3369. _actionManager: ActionManager;
  3370. /**
  3371. * Internal only
  3372. * @hidden
  3373. */
  3374. private _target;
  3375. /**
  3376. * Creates a new StateCondition
  3377. * @param actionManager manager for the action the condition applies to
  3378. * @param target of the condition
  3379. * @param value to compare with target state
  3380. */
  3381. constructor(actionManager: ActionManager, target: any,
  3382. /** Value to compare with target state */
  3383. value: string);
  3384. /**
  3385. * Gets a boolean indicating if the current condition is met
  3386. * @returns the validity of the state
  3387. */
  3388. isValid(): boolean;
  3389. /**
  3390. * Serialize the StateCondition into a JSON compatible object
  3391. * @returns serialization object
  3392. */
  3393. serialize(): any;
  3394. }
  3395. }
  3396. declare module BABYLON {
  3397. /**
  3398. * This defines an action responsible to toggle a boolean once triggered.
  3399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3400. */
  3401. class SwitchBooleanAction extends Action {
  3402. /**
  3403. * The path to the boolean property in the target object
  3404. */
  3405. propertyPath: string;
  3406. private _target;
  3407. private _effectiveTarget;
  3408. private _property;
  3409. /**
  3410. * Instantiate the action
  3411. * @param triggerOptions defines the trigger options
  3412. * @param target defines the object containing the boolean
  3413. * @param propertyPath defines the path to the boolean property in the target object
  3414. * @param condition defines the trigger related conditions
  3415. */
  3416. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3417. /** @hidden */
  3418. _prepare(): void;
  3419. /**
  3420. * Execute the action toggle the boolean value.
  3421. */
  3422. execute(): void;
  3423. /**
  3424. * Serializes the actions and its related information.
  3425. * @param parent defines the object to serialize in
  3426. * @returns the serialized object
  3427. */
  3428. serialize(parent: any): any;
  3429. }
  3430. /**
  3431. * This defines an action responsible to set a the state field of the target
  3432. * to a desired value once triggered.
  3433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3434. */
  3435. class SetStateAction extends Action {
  3436. /**
  3437. * The value to store in the state field.
  3438. */
  3439. value: string;
  3440. private _target;
  3441. /**
  3442. * Instantiate the action
  3443. * @param triggerOptions defines the trigger options
  3444. * @param target defines the object containing the state property
  3445. * @param value defines the value to store in the state field
  3446. * @param condition defines the trigger related conditions
  3447. */
  3448. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3449. /**
  3450. * Execute the action and store the value on the target state property.
  3451. */
  3452. execute(): void;
  3453. /**
  3454. * Serializes the actions and its related information.
  3455. * @param parent defines the object to serialize in
  3456. * @returns the serialized object
  3457. */
  3458. serialize(parent: any): any;
  3459. }
  3460. /**
  3461. * This defines an action responsible to set a property of the target
  3462. * to a desired value once triggered.
  3463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3464. */
  3465. class SetValueAction extends Action {
  3466. /**
  3467. * The path of the property to set in the target.
  3468. */
  3469. propertyPath: string;
  3470. /**
  3471. * The value to set in the property
  3472. */
  3473. value: any;
  3474. private _target;
  3475. private _effectiveTarget;
  3476. private _property;
  3477. /**
  3478. * Instantiate the action
  3479. * @param triggerOptions defines the trigger options
  3480. * @param target defines the object containing the property
  3481. * @param propertyPath defines the path of the property to set in the target
  3482. * @param value defines the value to set in the property
  3483. * @param condition defines the trigger related conditions
  3484. */
  3485. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3486. /** @hidden */
  3487. _prepare(): void;
  3488. /**
  3489. * Execute the action and set the targetted property to the desired value.
  3490. */
  3491. execute(): void;
  3492. /**
  3493. * Serializes the actions and its related information.
  3494. * @param parent defines the object to serialize in
  3495. * @returns the serialized object
  3496. */
  3497. serialize(parent: any): any;
  3498. }
  3499. /**
  3500. * This defines an action responsible to increment the target value
  3501. * to a desired value once triggered.
  3502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3503. */
  3504. class IncrementValueAction extends Action {
  3505. /**
  3506. * The path of the property to increment in the target.
  3507. */
  3508. propertyPath: string;
  3509. /**
  3510. * The value we should increment the property by.
  3511. */
  3512. value: any;
  3513. private _target;
  3514. private _effectiveTarget;
  3515. private _property;
  3516. /**
  3517. * Instantiate the action
  3518. * @param triggerOptions defines the trigger options
  3519. * @param target defines the object containing the property
  3520. * @param propertyPath defines the path of the property to increment in the target
  3521. * @param value defines the value value we should increment the property by
  3522. * @param condition defines the trigger related conditions
  3523. */
  3524. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3525. /** @hidden */
  3526. _prepare(): void;
  3527. /**
  3528. * Execute the action and increment the target of the value amount.
  3529. */
  3530. execute(): void;
  3531. /**
  3532. * Serializes the actions and its related information.
  3533. * @param parent defines the object to serialize in
  3534. * @returns the serialized object
  3535. */
  3536. serialize(parent: any): any;
  3537. }
  3538. /**
  3539. * This defines an action responsible to start an animation once triggered.
  3540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3541. */
  3542. class PlayAnimationAction extends Action {
  3543. /**
  3544. * Where the animation should start (animation frame)
  3545. */
  3546. from: number;
  3547. /**
  3548. * Where the animation should stop (animation frame)
  3549. */
  3550. to: number;
  3551. /**
  3552. * Define if the animation should loop or stop after the first play.
  3553. */
  3554. loop?: boolean;
  3555. private _target;
  3556. /**
  3557. * Instantiate the action
  3558. * @param triggerOptions defines the trigger options
  3559. * @param target defines the target animation or animation name
  3560. * @param from defines from where the animation should start (animation frame)
  3561. * @param end defines where the animation should stop (animation frame)
  3562. * @param loop defines if the animation should loop or stop after the first play
  3563. * @param condition defines the trigger related conditions
  3564. */
  3565. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3566. /** @hidden */
  3567. _prepare(): void;
  3568. /**
  3569. * Execute the action and play the animation.
  3570. */
  3571. execute(): void;
  3572. /**
  3573. * Serializes the actions and its related information.
  3574. * @param parent defines the object to serialize in
  3575. * @returns the serialized object
  3576. */
  3577. serialize(parent: any): any;
  3578. }
  3579. /**
  3580. * This defines an action responsible to stop an animation once triggered.
  3581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3582. */
  3583. class StopAnimationAction extends Action {
  3584. private _target;
  3585. /**
  3586. * Instantiate the action
  3587. * @param triggerOptions defines the trigger options
  3588. * @param target defines the target animation or animation name
  3589. * @param condition defines the trigger related conditions
  3590. */
  3591. constructor(triggerOptions: any, target: any, condition?: Condition);
  3592. /** @hidden */
  3593. _prepare(): void;
  3594. /**
  3595. * Execute the action and stop the animation.
  3596. */
  3597. execute(): void;
  3598. /**
  3599. * Serializes the actions and its related information.
  3600. * @param parent defines the object to serialize in
  3601. * @returns the serialized object
  3602. */
  3603. serialize(parent: any): any;
  3604. }
  3605. /**
  3606. * This defines an action responsible that does nothing once triggered.
  3607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3608. */
  3609. class DoNothingAction extends Action {
  3610. /**
  3611. * Instantiate the action
  3612. * @param triggerOptions defines the trigger options
  3613. * @param condition defines the trigger related conditions
  3614. */
  3615. constructor(triggerOptions?: any, condition?: Condition);
  3616. /**
  3617. * Execute the action and do nothing.
  3618. */
  3619. execute(): void;
  3620. /**
  3621. * Serializes the actions and its related information.
  3622. * @param parent defines the object to serialize in
  3623. * @returns the serialized object
  3624. */
  3625. serialize(parent: any): any;
  3626. }
  3627. /**
  3628. * This defines an action responsible to trigger several actions once triggered.
  3629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3630. */
  3631. class CombineAction extends Action {
  3632. /**
  3633. * The list of aggregated animations to run.
  3634. */
  3635. children: Action[];
  3636. /**
  3637. * Instantiate the action
  3638. * @param triggerOptions defines the trigger options
  3639. * @param children defines the list of aggregated animations to run
  3640. * @param condition defines the trigger related conditions
  3641. */
  3642. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3643. /** @hidden */
  3644. _prepare(): void;
  3645. /**
  3646. * Execute the action and executes all the aggregated actions.
  3647. */
  3648. execute(evt: ActionEvent): void;
  3649. /**
  3650. * Serializes the actions and its related information.
  3651. * @param parent defines the object to serialize in
  3652. * @returns the serialized object
  3653. */
  3654. serialize(parent: any): any;
  3655. }
  3656. /**
  3657. * This defines an action responsible to run code (external event) once triggered.
  3658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3659. */
  3660. class ExecuteCodeAction extends Action {
  3661. /**
  3662. * The callback function to run.
  3663. */
  3664. func: (evt: ActionEvent) => void;
  3665. /**
  3666. * Instantiate the action
  3667. * @param triggerOptions defines the trigger options
  3668. * @param func defines the callback function to run
  3669. * @param condition defines the trigger related conditions
  3670. */
  3671. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3672. /**
  3673. * Execute the action and run the attached code.
  3674. */
  3675. execute(evt: ActionEvent): void;
  3676. }
  3677. /**
  3678. * This defines an action responsible to set the parent property of the target once triggered.
  3679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3680. */
  3681. class SetParentAction extends Action {
  3682. private _parent;
  3683. private _target;
  3684. /**
  3685. * Instantiate the action
  3686. * @param triggerOptions defines the trigger options
  3687. * @param target defines the target containing the parent property
  3688. * @param parent defines from where the animation should start (animation frame)
  3689. * @param condition defines the trigger related conditions
  3690. */
  3691. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3692. /** @hidden */
  3693. _prepare(): void;
  3694. /**
  3695. * Execute the action and set the parent property.
  3696. */
  3697. execute(): void;
  3698. /**
  3699. * Serializes the actions and its related information.
  3700. * @param parent defines the object to serialize in
  3701. * @returns the serialized object
  3702. */
  3703. serialize(parent: any): any;
  3704. }
  3705. }
  3706. declare module BABYLON {
  3707. /**
  3708. * This defines an action helpful to play a defined sound on a triggered action.
  3709. */
  3710. class PlaySoundAction extends Action {
  3711. private _sound;
  3712. /**
  3713. * Instantiate the action
  3714. * @param triggerOptions defines the trigger options
  3715. * @param sound defines the sound to play
  3716. * @param condition defines the trigger related conditions
  3717. */
  3718. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3719. /** @hidden */
  3720. _prepare(): void;
  3721. /**
  3722. * Execute the action and play the sound.
  3723. */
  3724. execute(): void;
  3725. /**
  3726. * Serializes the actions and its related information.
  3727. * @param parent defines the object to serialize in
  3728. * @returns the serialized object
  3729. */
  3730. serialize(parent: any): any;
  3731. }
  3732. /**
  3733. * This defines an action helpful to stop a defined sound on a triggered action.
  3734. */
  3735. class StopSoundAction extends Action {
  3736. private _sound;
  3737. /**
  3738. * Instantiate the action
  3739. * @param triggerOptions defines the trigger options
  3740. * @param sound defines the sound to stop
  3741. * @param condition defines the trigger related conditions
  3742. */
  3743. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3744. /** @hidden */
  3745. _prepare(): void;
  3746. /**
  3747. * Execute the action and stop the sound.
  3748. */
  3749. execute(): void;
  3750. /**
  3751. * Serializes the actions and its related information.
  3752. * @param parent defines the object to serialize in
  3753. * @returns the serialized object
  3754. */
  3755. serialize(parent: any): any;
  3756. }
  3757. }
  3758. declare module BABYLON {
  3759. /**
  3760. * This defines an action responsible to change the value of a property
  3761. * by interpolating between its current value and the newly set one once triggered.
  3762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3763. */
  3764. class InterpolateValueAction extends Action {
  3765. /**
  3766. * Defines the path of the property where the value should be interpolated
  3767. */
  3768. propertyPath: string;
  3769. /**
  3770. * Defines the target value at the end of the interpolation.
  3771. */
  3772. value: any;
  3773. /**
  3774. * Defines the time it will take for the property to interpolate to the value.
  3775. */
  3776. duration: number;
  3777. /**
  3778. * Defines if the other scene animations should be stopped when the action has been triggered
  3779. */
  3780. stopOtherAnimations?: boolean;
  3781. /**
  3782. * Defines a callback raised once the interpolation animation has been done.
  3783. */
  3784. onInterpolationDone?: () => void;
  3785. /**
  3786. * Observable triggered once the interpolation animation has been done.
  3787. */
  3788. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3789. private _target;
  3790. private _effectiveTarget;
  3791. private _property;
  3792. /**
  3793. * Instantiate the action
  3794. * @param triggerOptions defines the trigger options
  3795. * @param target defines the object containing the value to interpolate
  3796. * @param propertyPath defines the path to the property in the target object
  3797. * @param value defines the target value at the end of the interpolation
  3798. * @param duration deines the time it will take for the property to interpolate to the value.
  3799. * @param condition defines the trigger related conditions
  3800. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3801. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3802. */
  3803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3804. /** @hidden */
  3805. _prepare(): void;
  3806. /**
  3807. * Execute the action starts the value interpolation.
  3808. */
  3809. execute(): void;
  3810. /**
  3811. * Serializes the actions and its related information.
  3812. * @param parent defines the object to serialize in
  3813. * @returns the serialized object
  3814. */
  3815. serialize(parent: any): any;
  3816. }
  3817. }
  3818. declare module BABYLON {
  3819. /**
  3820. * Class used to store an actual running animation
  3821. */
  3822. class Animatable {
  3823. /** defines the target object */
  3824. target: any;
  3825. /** defines the starting frame number (default is 0) */
  3826. fromFrame: number;
  3827. /** defines the ending frame number (default is 100) */
  3828. toFrame: number;
  3829. /** defines if the animation must loop (default is false) */
  3830. loopAnimation: boolean;
  3831. /** defines a callback to call when animation ends if it is not looping */
  3832. onAnimationEnd?: (() => void) | null | undefined;
  3833. /** defines a callback to call when animation loops */
  3834. onAnimationLoop?: (() => void) | null | undefined;
  3835. private _localDelayOffset;
  3836. private _pausedDelay;
  3837. private _runtimeAnimations;
  3838. private _paused;
  3839. private _scene;
  3840. private _speedRatio;
  3841. private _weight;
  3842. private _syncRoot;
  3843. /**
  3844. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3845. * This will only apply for non looping animation (default is true)
  3846. */
  3847. disposeOnEnd: boolean;
  3848. /**
  3849. * Gets a boolean indicating if the animation has started
  3850. */
  3851. animationStarted: boolean;
  3852. /**
  3853. * Observer raised when the animation ends
  3854. */
  3855. onAnimationEndObservable: Observable<Animatable>;
  3856. /**
  3857. * Observer raised when the animation loops
  3858. */
  3859. onAnimationLoopObservable: Observable<Animatable>;
  3860. /**
  3861. * Gets the root Animatable used to synchronize and normalize animations
  3862. */
  3863. readonly syncRoot: Animatable;
  3864. /**
  3865. * Gets the current frame of the first RuntimeAnimation
  3866. * Used to synchronize Animatables
  3867. */
  3868. readonly masterFrame: number;
  3869. /**
  3870. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3871. */
  3872. weight: number;
  3873. /**
  3874. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3875. */
  3876. speedRatio: number;
  3877. /**
  3878. * Creates a new Animatable
  3879. * @param scene defines the hosting scene
  3880. * @param target defines the target object
  3881. * @param fromFrame defines the starting frame number (default is 0)
  3882. * @param toFrame defines the ending frame number (default is 100)
  3883. * @param loopAnimation defines if the animation must loop (default is false)
  3884. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3885. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3886. * @param animations defines a group of animation to add to the new Animatable
  3887. * @param onAnimationLoop defines a callback to call when animation loops
  3888. */
  3889. constructor(scene: Scene,
  3890. /** defines the target object */
  3891. target: any,
  3892. /** defines the starting frame number (default is 0) */
  3893. fromFrame?: number,
  3894. /** defines the ending frame number (default is 100) */
  3895. toFrame?: number,
  3896. /** defines if the animation must loop (default is false) */
  3897. loopAnimation?: boolean, speedRatio?: number,
  3898. /** defines a callback to call when animation ends if it is not looping */
  3899. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  3900. /** defines a callback to call when animation loops */
  3901. onAnimationLoop?: (() => void) | null | undefined);
  3902. /**
  3903. * Synchronize and normalize current Animatable with a source Animatable
  3904. * This is useful when using animation weights and when animations are not of the same length
  3905. * @param root defines the root Animatable to synchronize with
  3906. * @returns the current Animatable
  3907. */
  3908. syncWith(root: Animatable): Animatable;
  3909. /**
  3910. * Gets the list of runtime animations
  3911. * @returns an array of RuntimeAnimation
  3912. */
  3913. getAnimations(): RuntimeAnimation[];
  3914. /**
  3915. * Adds more animations to the current animatable
  3916. * @param target defines the target of the animations
  3917. * @param animations defines the new animations to add
  3918. */
  3919. appendAnimations(target: any, animations: Animation[]): void;
  3920. /**
  3921. * Gets the source animation for a specific property
  3922. * @param property defines the propertyu to look for
  3923. * @returns null or the source animation for the given property
  3924. */
  3925. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3926. /**
  3927. * Gets the runtime animation for a specific property
  3928. * @param property defines the propertyu to look for
  3929. * @returns null or the runtime animation for the given property
  3930. */
  3931. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3932. /**
  3933. * Resets the animatable to its original state
  3934. */
  3935. reset(): void;
  3936. /**
  3937. * Allows the animatable to blend with current running animations
  3938. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3939. * @param blendingSpeed defines the blending speed to use
  3940. */
  3941. enableBlending(blendingSpeed: number): void;
  3942. /**
  3943. * Disable animation blending
  3944. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3945. */
  3946. disableBlending(): void;
  3947. /**
  3948. * Jump directly to a given frame
  3949. * @param frame defines the frame to jump to
  3950. */
  3951. goToFrame(frame: number): void;
  3952. /**
  3953. * Pause the animation
  3954. */
  3955. pause(): void;
  3956. /**
  3957. * Restart the animation
  3958. */
  3959. restart(): void;
  3960. private _raiseOnAnimationEnd;
  3961. /**
  3962. * Stop and delete the current animation
  3963. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3964. * @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)
  3965. */
  3966. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3967. /**
  3968. * Wait asynchronously for the animation to end
  3969. * @returns a promise which will be fullfilled when the animation ends
  3970. */
  3971. waitAsync(): Promise<Animatable>;
  3972. /** @hidden */
  3973. _animate(delay: number): boolean;
  3974. }
  3975. }
  3976. declare module BABYLON {
  3977. /**
  3978. * Represents the range of an animation
  3979. */
  3980. class AnimationRange {
  3981. /**The name of the animation range**/
  3982. name: string;
  3983. /**The starting frame of the animation */
  3984. from: number;
  3985. /**The ending frame of the animation*/
  3986. to: number;
  3987. /**
  3988. * Initializes the range of an animation
  3989. * @param name The name of the animation range
  3990. * @param from The starting frame of the animation
  3991. * @param to The ending frame of the animation
  3992. */
  3993. constructor(
  3994. /**The name of the animation range**/
  3995. name: string,
  3996. /**The starting frame of the animation */
  3997. from: number,
  3998. /**The ending frame of the animation*/
  3999. to: number);
  4000. /**
  4001. * Makes a copy of the animation range
  4002. * @returns A copy of the animation range
  4003. */
  4004. clone(): AnimationRange;
  4005. }
  4006. /**
  4007. * Composed of a frame, and an action function
  4008. */
  4009. class AnimationEvent {
  4010. /** The frame for which the event is triggered **/
  4011. frame: number;
  4012. /** The event to perform when triggered **/
  4013. action: (currentFrame: number) => void;
  4014. /** Specifies if the event should be triggered only once**/
  4015. onlyOnce?: boolean | undefined;
  4016. /**
  4017. * Specifies if the animation event is done
  4018. */
  4019. isDone: boolean;
  4020. /**
  4021. * Initializes the animation event
  4022. * @param frame The frame for which the event is triggered
  4023. * @param action The event to perform when triggered
  4024. * @param onlyOnce Specifies if the event should be triggered only once
  4025. */
  4026. constructor(
  4027. /** The frame for which the event is triggered **/
  4028. frame: number,
  4029. /** The event to perform when triggered **/
  4030. action: (currentFrame: number) => void,
  4031. /** Specifies if the event should be triggered only once**/
  4032. onlyOnce?: boolean | undefined);
  4033. /** @hidden */
  4034. _clone(): AnimationEvent;
  4035. }
  4036. /**
  4037. * A cursor which tracks a point on a path
  4038. */
  4039. class PathCursor {
  4040. private path;
  4041. /**
  4042. * Stores path cursor callbacks for when an onchange event is triggered
  4043. */
  4044. private _onchange;
  4045. /**
  4046. * The value of the path cursor
  4047. */
  4048. value: number;
  4049. /**
  4050. * The animation array of the path cursor
  4051. */
  4052. animations: Animation[];
  4053. /**
  4054. * Initializes the path cursor
  4055. * @param path The path to track
  4056. */
  4057. constructor(path: Path2);
  4058. /**
  4059. * Gets the cursor point on the path
  4060. * @returns A point on the path cursor at the cursor location
  4061. */
  4062. getPoint(): Vector3;
  4063. /**
  4064. * Moves the cursor ahead by the step amount
  4065. * @param step The amount to move the cursor forward
  4066. * @returns This path cursor
  4067. */
  4068. moveAhead(step?: number): PathCursor;
  4069. /**
  4070. * Moves the cursor behind by the step amount
  4071. * @param step The amount to move the cursor back
  4072. * @returns This path cursor
  4073. */
  4074. moveBack(step?: number): PathCursor;
  4075. /**
  4076. * Moves the cursor by the step amount
  4077. * If the step amount is greater than one, an exception is thrown
  4078. * @param step The amount to move the cursor
  4079. * @returns This path cursor
  4080. */
  4081. move(step: number): PathCursor;
  4082. /**
  4083. * Ensures that the value is limited between zero and one
  4084. * @returns This path cursor
  4085. */
  4086. private ensureLimits;
  4087. /**
  4088. * Runs onchange callbacks on change (used by the animation engine)
  4089. * @returns This path cursor
  4090. */
  4091. private raiseOnChange;
  4092. /**
  4093. * Executes a function on change
  4094. * @param f A path cursor onchange callback
  4095. * @returns This path cursor
  4096. */
  4097. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4098. }
  4099. /**
  4100. * Defines an interface which represents an animation key frame
  4101. */
  4102. interface IAnimationKey {
  4103. /**
  4104. * Frame of the key frame
  4105. */
  4106. frame: number;
  4107. /**
  4108. * Value at the specifies key frame
  4109. */
  4110. value: any;
  4111. /**
  4112. * The input tangent for the cubic hermite spline
  4113. */
  4114. inTangent?: any;
  4115. /**
  4116. * The output tangent for the cubic hermite spline
  4117. */
  4118. outTangent?: any;
  4119. /**
  4120. * The animation interpolation type
  4121. */
  4122. interpolation?: AnimationKeyInterpolation;
  4123. }
  4124. /**
  4125. * Enum for the animation key frame interpolation type
  4126. */
  4127. enum AnimationKeyInterpolation {
  4128. /**
  4129. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4130. */
  4131. STEP = 1
  4132. }
  4133. /**
  4134. * Class used to store any kind of animation
  4135. */
  4136. class Animation {
  4137. /**Name of the animation */
  4138. name: string;
  4139. /**Property to animate */
  4140. targetProperty: string;
  4141. /**The frames per second of the animation */
  4142. framePerSecond: number;
  4143. /**The data type of the animation */
  4144. dataType: number;
  4145. /**The loop mode of the animation */
  4146. loopMode?: number | undefined;
  4147. /**Specifies if blending should be enabled */
  4148. enableBlending?: boolean | undefined;
  4149. /**
  4150. * Use matrix interpolation instead of using direct key value when animating matrices
  4151. */
  4152. static AllowMatricesInterpolation: boolean;
  4153. /**
  4154. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4155. */
  4156. static AllowMatrixDecomposeForInterpolation: boolean;
  4157. /**
  4158. * Stores the key frames of the animation
  4159. */
  4160. private _keys;
  4161. /**
  4162. * Stores the easing function of the animation
  4163. */
  4164. private _easingFunction;
  4165. /**
  4166. * @hidden Internal use only
  4167. */
  4168. _runtimeAnimations: RuntimeAnimation[];
  4169. /**
  4170. * The set of event that will be linked to this animation
  4171. */
  4172. private _events;
  4173. /**
  4174. * Stores an array of target property paths
  4175. */
  4176. targetPropertyPath: string[];
  4177. /**
  4178. * Stores the blending speed of the animation
  4179. */
  4180. blendingSpeed: number;
  4181. /**
  4182. * Stores the animation ranges for the animation
  4183. */
  4184. private _ranges;
  4185. /**
  4186. * @hidden Internal use
  4187. */
  4188. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4189. /**
  4190. * Sets up an animation
  4191. * @param property The property to animate
  4192. * @param animationType The animation type to apply
  4193. * @param framePerSecond The frames per second of the animation
  4194. * @param easingFunction The easing function used in the animation
  4195. * @returns The created animation
  4196. */
  4197. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4198. /**
  4199. * Create and start an animation on a node
  4200. * @param name defines the name of the global animation that will be run on all nodes
  4201. * @param node defines the root node where the animation will take place
  4202. * @param targetProperty defines property to animate
  4203. * @param framePerSecond defines the number of frame per second yo use
  4204. * @param totalFrame defines the number of frames in total
  4205. * @param from defines the initial value
  4206. * @param to defines the final value
  4207. * @param loopMode defines which loop mode you want to use (off by default)
  4208. * @param easingFunction defines the easing function to use (linear by default)
  4209. * @param onAnimationEnd defines the callback to call when animation end
  4210. * @returns the animatable created for this animation
  4211. */
  4212. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4213. /**
  4214. * Create and start an animation on a node and its descendants
  4215. * @param name defines the name of the global animation that will be run on all nodes
  4216. * @param node defines the root node where the animation will take place
  4217. * @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
  4218. * @param targetProperty defines property to animate
  4219. * @param framePerSecond defines the number of frame per second to use
  4220. * @param totalFrame defines the number of frames in total
  4221. * @param from defines the initial value
  4222. * @param to defines the final value
  4223. * @param loopMode defines which loop mode you want to use (off by default)
  4224. * @param easingFunction defines the easing function to use (linear by default)
  4225. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4226. * @returns the list of animatables created for all nodes
  4227. * @example https://www.babylonjs-playground.com/#MH0VLI
  4228. */
  4229. 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[]>;
  4230. /**
  4231. * Creates a new animation, merges it with the existing animations and starts it
  4232. * @param name Name of the animation
  4233. * @param node Node which contains the scene that begins the animations
  4234. * @param targetProperty Specifies which property to animate
  4235. * @param framePerSecond The frames per second of the animation
  4236. * @param totalFrame The total number of frames
  4237. * @param from The frame at the beginning of the animation
  4238. * @param to The frame at the end of the animation
  4239. * @param loopMode Specifies the loop mode of the animation
  4240. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4241. * @param onAnimationEnd Callback to run once the animation is complete
  4242. * @returns Nullable animation
  4243. */
  4244. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4245. /**
  4246. * Transition property of an host to the target Value
  4247. * @param property The property to transition
  4248. * @param targetValue The target Value of the property
  4249. * @param host The object where the property to animate belongs
  4250. * @param scene Scene used to run the animation
  4251. * @param frameRate Framerate (in frame/s) to use
  4252. * @param transition The transition type we want to use
  4253. * @param duration The duration of the animation, in milliseconds
  4254. * @param onAnimationEnd Callback trigger at the end of the animation
  4255. * @returns Nullable animation
  4256. */
  4257. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4258. /**
  4259. * Return the array of runtime animations currently using this animation
  4260. */
  4261. readonly runtimeAnimations: RuntimeAnimation[];
  4262. /**
  4263. * Specifies if any of the runtime animations are currently running
  4264. */
  4265. readonly hasRunningRuntimeAnimations: boolean;
  4266. /**
  4267. * Initializes the animation
  4268. * @param name Name of the animation
  4269. * @param targetProperty Property to animate
  4270. * @param framePerSecond The frames per second of the animation
  4271. * @param dataType The data type of the animation
  4272. * @param loopMode The loop mode of the animation
  4273. * @param enableBlendings Specifies if blending should be enabled
  4274. */
  4275. constructor(
  4276. /**Name of the animation */
  4277. name: string,
  4278. /**Property to animate */
  4279. targetProperty: string,
  4280. /**The frames per second of the animation */
  4281. framePerSecond: number,
  4282. /**The data type of the animation */
  4283. dataType: number,
  4284. /**The loop mode of the animation */
  4285. loopMode?: number | undefined,
  4286. /**Specifies if blending should be enabled */
  4287. enableBlending?: boolean | undefined);
  4288. /**
  4289. * Converts the animation to a string
  4290. * @param fullDetails support for multiple levels of logging within scene loading
  4291. * @returns String form of the animation
  4292. */
  4293. toString(fullDetails?: boolean): string;
  4294. /**
  4295. * Add an event to this animation
  4296. * @param event Event to add
  4297. */
  4298. addEvent(event: AnimationEvent): void;
  4299. /**
  4300. * Remove all events found at the given frame
  4301. * @param frame The frame to remove events from
  4302. */
  4303. removeEvents(frame: number): void;
  4304. /**
  4305. * Retrieves all the events from the animation
  4306. * @returns Events from the animation
  4307. */
  4308. getEvents(): AnimationEvent[];
  4309. /**
  4310. * Creates an animation range
  4311. * @param name Name of the animation range
  4312. * @param from Starting frame of the animation range
  4313. * @param to Ending frame of the animation
  4314. */
  4315. createRange(name: string, from: number, to: number): void;
  4316. /**
  4317. * Deletes an animation range by name
  4318. * @param name Name of the animation range to delete
  4319. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4320. */
  4321. deleteRange(name: string, deleteFrames?: boolean): void;
  4322. /**
  4323. * Gets the animation range by name, or null if not defined
  4324. * @param name Name of the animation range
  4325. * @returns Nullable animation range
  4326. */
  4327. getRange(name: string): Nullable<AnimationRange>;
  4328. /**
  4329. * Gets the key frames from the animation
  4330. * @returns The key frames of the animation
  4331. */
  4332. getKeys(): Array<IAnimationKey>;
  4333. /**
  4334. * Gets the highest frame rate of the animation
  4335. * @returns Highest frame rate of the animation
  4336. */
  4337. getHighestFrame(): number;
  4338. /**
  4339. * Gets the easing function of the animation
  4340. * @returns Easing function of the animation
  4341. */
  4342. getEasingFunction(): IEasingFunction;
  4343. /**
  4344. * Sets the easing function of the animation
  4345. * @param easingFunction A custom mathematical formula for animation
  4346. */
  4347. setEasingFunction(easingFunction: EasingFunction): void;
  4348. /**
  4349. * Interpolates a scalar linearly
  4350. * @param startValue Start value of the animation curve
  4351. * @param endValue End value of the animation curve
  4352. * @param gradient Scalar amount to interpolate
  4353. * @returns Interpolated scalar value
  4354. */
  4355. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4356. /**
  4357. * Interpolates a scalar cubically
  4358. * @param startValue Start value of the animation curve
  4359. * @param outTangent End tangent of the animation
  4360. * @param endValue End value of the animation curve
  4361. * @param inTangent Start tangent of the animation curve
  4362. * @param gradient Scalar amount to interpolate
  4363. * @returns Interpolated scalar value
  4364. */
  4365. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4366. /**
  4367. * Interpolates a quaternion using a spherical linear interpolation
  4368. * @param startValue Start value of the animation curve
  4369. * @param endValue End value of the animation curve
  4370. * @param gradient Scalar amount to interpolate
  4371. * @returns Interpolated quaternion value
  4372. */
  4373. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4374. /**
  4375. * Interpolates a quaternion cubically
  4376. * @param startValue Start value of the animation curve
  4377. * @param outTangent End tangent of the animation curve
  4378. * @param endValue End value of the animation curve
  4379. * @param inTangent Start tangent of the animation curve
  4380. * @param gradient Scalar amount to interpolate
  4381. * @returns Interpolated quaternion value
  4382. */
  4383. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4384. /**
  4385. * Interpolates a Vector3 linearl
  4386. * @param startValue Start value of the animation curve
  4387. * @param endValue End value of the animation curve
  4388. * @param gradient Scalar amount to interpolate
  4389. * @returns Interpolated scalar value
  4390. */
  4391. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4392. /**
  4393. * Interpolates a Vector3 cubically
  4394. * @param startValue Start value of the animation curve
  4395. * @param outTangent End tangent of the animation
  4396. * @param endValue End value of the animation curve
  4397. * @param inTangent Start tangent of the animation curve
  4398. * @param gradient Scalar amount to interpolate
  4399. * @returns InterpolatedVector3 value
  4400. */
  4401. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4402. /**
  4403. * Interpolates a Vector2 linearly
  4404. * @param startValue Start value of the animation curve
  4405. * @param endValue End value of the animation curve
  4406. * @param gradient Scalar amount to interpolate
  4407. * @returns Interpolated Vector2 value
  4408. */
  4409. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4410. /**
  4411. * Interpolates a Vector2 cubically
  4412. * @param startValue Start value of the animation curve
  4413. * @param outTangent End tangent of the animation
  4414. * @param endValue End value of the animation curve
  4415. * @param inTangent Start tangent of the animation curve
  4416. * @param gradient Scalar amount to interpolate
  4417. * @returns Interpolated Vector2 value
  4418. */
  4419. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4420. /**
  4421. * Interpolates a size linearly
  4422. * @param startValue Start value of the animation curve
  4423. * @param endValue End value of the animation curve
  4424. * @param gradient Scalar amount to interpolate
  4425. * @returns Interpolated Size value
  4426. */
  4427. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4428. /**
  4429. * Interpolates a Color3 linearly
  4430. * @param startValue Start value of the animation curve
  4431. * @param endValue End value of the animation curve
  4432. * @param gradient Scalar amount to interpolate
  4433. * @returns Interpolated Color3 value
  4434. */
  4435. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4436. /**
  4437. * @hidden Internal use only
  4438. */
  4439. _getKeyValue(value: any): any;
  4440. /**
  4441. * @hidden Internal use only
  4442. */
  4443. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4444. /**
  4445. * Defines the function to use to interpolate matrices
  4446. * @param startValue defines the start matrix
  4447. * @param endValue defines the end matrix
  4448. * @param gradient defines the gradient between both matrices
  4449. * @param result defines an optional target matrix where to store the interpolation
  4450. * @returns the interpolated matrix
  4451. */
  4452. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4453. /**
  4454. * Makes a copy of the animation
  4455. * @returns Cloned animation
  4456. */
  4457. clone(): Animation;
  4458. /**
  4459. * Sets the key frames of the animation
  4460. * @param values The animation key frames to set
  4461. */
  4462. setKeys(values: Array<IAnimationKey>): void;
  4463. /**
  4464. * Serializes the animation to an object
  4465. * @returns Serialized object
  4466. */
  4467. serialize(): any;
  4468. /**
  4469. * Float animation type
  4470. */
  4471. private static _ANIMATIONTYPE_FLOAT;
  4472. /**
  4473. * Vector3 animation type
  4474. */
  4475. private static _ANIMATIONTYPE_VECTOR3;
  4476. /**
  4477. * Quaternion animation type
  4478. */
  4479. private static _ANIMATIONTYPE_QUATERNION;
  4480. /**
  4481. * Matrix animation type
  4482. */
  4483. private static _ANIMATIONTYPE_MATRIX;
  4484. /**
  4485. * Color3 animation type
  4486. */
  4487. private static _ANIMATIONTYPE_COLOR3;
  4488. /**
  4489. * Vector2 animation type
  4490. */
  4491. private static _ANIMATIONTYPE_VECTOR2;
  4492. /**
  4493. * Size animation type
  4494. */
  4495. private static _ANIMATIONTYPE_SIZE;
  4496. /**
  4497. * Relative Loop Mode
  4498. */
  4499. private static _ANIMATIONLOOPMODE_RELATIVE;
  4500. /**
  4501. * Cycle Loop Mode
  4502. */
  4503. private static _ANIMATIONLOOPMODE_CYCLE;
  4504. /**
  4505. * Constant Loop Mode
  4506. */
  4507. private static _ANIMATIONLOOPMODE_CONSTANT;
  4508. /**
  4509. * Get the float animation type
  4510. */
  4511. static readonly ANIMATIONTYPE_FLOAT: number;
  4512. /**
  4513. * Get the Vector3 animation type
  4514. */
  4515. static readonly ANIMATIONTYPE_VECTOR3: number;
  4516. /**
  4517. * Get the Vector2 animation type
  4518. */
  4519. static readonly ANIMATIONTYPE_VECTOR2: number;
  4520. /**
  4521. * Get the Size animation type
  4522. */
  4523. static readonly ANIMATIONTYPE_SIZE: number;
  4524. /**
  4525. * Get the Quaternion animation type
  4526. */
  4527. static readonly ANIMATIONTYPE_QUATERNION: number;
  4528. /**
  4529. * Get the Matrix animation type
  4530. */
  4531. static readonly ANIMATIONTYPE_MATRIX: number;
  4532. /**
  4533. * Get the Color3 animation type
  4534. */
  4535. static readonly ANIMATIONTYPE_COLOR3: number;
  4536. /**
  4537. * Get the Relative Loop Mode
  4538. */
  4539. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4540. /**
  4541. * Get the Cycle Loop Mode
  4542. */
  4543. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4544. /**
  4545. * Get the Constant Loop Mode
  4546. */
  4547. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4548. /** @hidden */
  4549. static _UniversalLerp(left: any, right: any, amount: number): any;
  4550. /**
  4551. * Parses an animation object and creates an animation
  4552. * @param parsedAnimation Parsed animation object
  4553. * @returns Animation object
  4554. */
  4555. static Parse(parsedAnimation: any): Animation;
  4556. /**
  4557. * Appends the serialized animations from the source animations
  4558. * @param source Source containing the animations
  4559. * @param destination Target to store the animations
  4560. */
  4561. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4562. }
  4563. }
  4564. declare module BABYLON {
  4565. /**
  4566. * This class defines the direct association between an animation and a target
  4567. */
  4568. class TargetedAnimation {
  4569. /**
  4570. * Animation to perform
  4571. */
  4572. animation: Animation;
  4573. /**
  4574. * Target to animate
  4575. */
  4576. target: any;
  4577. }
  4578. /**
  4579. * Use this class to create coordinated animations on multiple targets
  4580. */
  4581. class AnimationGroup implements IDisposable {
  4582. /** The name of the animation group */
  4583. name: string;
  4584. private _scene;
  4585. private _targetedAnimations;
  4586. private _animatables;
  4587. private _from;
  4588. private _to;
  4589. private _isStarted;
  4590. private _isPaused;
  4591. private _speedRatio;
  4592. /**
  4593. * Gets or sets the unique id of the node
  4594. */
  4595. uniqueId: number;
  4596. /**
  4597. * This observable will notify when one animation have ended
  4598. */
  4599. onAnimationEndObservable: Observable<TargetedAnimation>;
  4600. /**
  4601. * Observer raised when one animation loops
  4602. */
  4603. onAnimationLoopObservable: Observable<TargetedAnimation>;
  4604. /**
  4605. * This observable will notify when all animations have ended.
  4606. */
  4607. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4608. /**
  4609. * This observable will notify when all animations have paused.
  4610. */
  4611. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4612. /**
  4613. * This observable will notify when all animations are playing.
  4614. */
  4615. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4616. /**
  4617. * Gets the first frame
  4618. */
  4619. readonly from: number;
  4620. /**
  4621. * Gets the last frame
  4622. */
  4623. readonly to: number;
  4624. /**
  4625. * Define if the animations are started
  4626. */
  4627. readonly isStarted: boolean;
  4628. /**
  4629. * Gets a value indicating that the current group is playing
  4630. */
  4631. readonly isPlaying: boolean;
  4632. /**
  4633. * Gets or sets the speed ratio to use for all animations
  4634. */
  4635. /**
  4636. * Gets or sets the speed ratio to use for all animations
  4637. */
  4638. speedRatio: number;
  4639. /**
  4640. * Gets the targeted animations for this animation group
  4641. */
  4642. readonly targetedAnimations: Array<TargetedAnimation>;
  4643. /**
  4644. * returning the list of animatables controlled by this animation group.
  4645. */
  4646. readonly animatables: Array<Animatable>;
  4647. /**
  4648. * Instantiates a new Animation Group.
  4649. * This helps managing several animations at once.
  4650. * @see http://doc.babylonjs.com/how_to/group
  4651. * @param name Defines the name of the group
  4652. * @param scene Defines the scene the group belongs to
  4653. */
  4654. constructor(
  4655. /** The name of the animation group */
  4656. name: string, scene?: Nullable<Scene>);
  4657. /**
  4658. * Add an animation (with its target) in the group
  4659. * @param animation defines the animation we want to add
  4660. * @param target defines the target of the animation
  4661. * @returns the TargetedAnimation object
  4662. */
  4663. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4664. /**
  4665. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4666. * It can add constant keys at begin or end
  4667. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4668. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4669. * @returns the animation group
  4670. */
  4671. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4672. /**
  4673. * Start all animations on given targets
  4674. * @param loop defines if animations must loop
  4675. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4676. * @param from defines the from key (optional)
  4677. * @param to defines the to key (optional)
  4678. * @returns the current animation group
  4679. */
  4680. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4681. /**
  4682. * Pause all animations
  4683. * @returns the animation group
  4684. */
  4685. pause(): AnimationGroup;
  4686. /**
  4687. * Play all animations to initial state
  4688. * This function will start() the animations if they were not started or will restart() them if they were paused
  4689. * @param loop defines if animations must loop
  4690. * @returns the animation group
  4691. */
  4692. play(loop?: boolean): AnimationGroup;
  4693. /**
  4694. * Reset all animations to initial state
  4695. * @returns the animation group
  4696. */
  4697. reset(): AnimationGroup;
  4698. /**
  4699. * Restart animations from key 0
  4700. * @returns the animation group
  4701. */
  4702. restart(): AnimationGroup;
  4703. /**
  4704. * Stop all animations
  4705. * @returns the animation group
  4706. */
  4707. stop(): AnimationGroup;
  4708. /**
  4709. * Set animation weight for all animatables
  4710. * @param weight defines the weight to use
  4711. * @return the animationGroup
  4712. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4713. */
  4714. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4715. /**
  4716. * Synchronize and normalize all animatables with a source animatable
  4717. * @param root defines the root animatable to synchronize with
  4718. * @return the animationGroup
  4719. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4720. */
  4721. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4722. /**
  4723. * Goes to a specific frame in this animation group
  4724. * @param frame the frame number to go to
  4725. * @return the animationGroup
  4726. */
  4727. goToFrame(frame: number): AnimationGroup;
  4728. /**
  4729. * Dispose all associated resources
  4730. */
  4731. dispose(): void;
  4732. private _checkAnimationGroupEnded;
  4733. /**
  4734. * Returns a new AnimationGroup object parsed from the source provided.
  4735. * @param parsedAnimationGroup defines the source
  4736. * @param scene defines the scene that will receive the animationGroup
  4737. * @returns a new AnimationGroup
  4738. */
  4739. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4740. /**
  4741. * Returns the string "AnimationGroup"
  4742. * @returns "AnimationGroup"
  4743. */
  4744. getClassName(): string;
  4745. /**
  4746. * Creates a detailled string about the object
  4747. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4748. * @returns a string representing the object
  4749. */
  4750. toString(fullDetails?: boolean): string;
  4751. }
  4752. }
  4753. declare module BABYLON {
  4754. /**
  4755. * Class used to override all child animations of a given target
  4756. */
  4757. class AnimationPropertiesOverride {
  4758. /**
  4759. * Gets or sets a value indicating if animation blending must be used
  4760. */
  4761. enableBlending: boolean;
  4762. /**
  4763. * Gets or sets the blending speed to use when enableBlending is true
  4764. */
  4765. blendingSpeed: number;
  4766. /**
  4767. * Gets or sets the default loop mode to use
  4768. */
  4769. loopMode: number;
  4770. }
  4771. }
  4772. declare module BABYLON {
  4773. /**
  4774. * This represents the main contract an easing function should follow.
  4775. * Easing functions are used throughout the animation system.
  4776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4777. */
  4778. interface IEasingFunction {
  4779. /**
  4780. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4781. * of the easing function.
  4782. * The link below provides some of the most common examples of easing functions.
  4783. * @see https://easings.net/
  4784. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4785. * @returns the corresponding value on the curve defined by the easing function
  4786. */
  4787. ease(gradient: number): number;
  4788. }
  4789. /**
  4790. * Base class used for every default easing function.
  4791. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4792. */
  4793. class EasingFunction implements IEasingFunction {
  4794. /**
  4795. * Interpolation follows the mathematical formula associated with the easing function.
  4796. */
  4797. static readonly EASINGMODE_EASEIN: number;
  4798. /**
  4799. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4800. */
  4801. static readonly EASINGMODE_EASEOUT: number;
  4802. /**
  4803. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4804. */
  4805. static readonly EASINGMODE_EASEINOUT: number;
  4806. private _easingMode;
  4807. /**
  4808. * Sets the easing mode of the current function.
  4809. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4810. */
  4811. setEasingMode(easingMode: number): void;
  4812. /**
  4813. * Gets the current easing mode.
  4814. * @returns the easing mode
  4815. */
  4816. getEasingMode(): number;
  4817. /**
  4818. * @hidden
  4819. */
  4820. easeInCore(gradient: number): number;
  4821. /**
  4822. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4823. * of the easing function.
  4824. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4825. * @returns the corresponding value on the curve defined by the easing function
  4826. */
  4827. ease(gradient: number): number;
  4828. }
  4829. /**
  4830. * Easing function with a circle shape (see link below).
  4831. * @see https://easings.net/#easeInCirc
  4832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4833. */
  4834. class CircleEase extends EasingFunction implements IEasingFunction {
  4835. /** @hidden */
  4836. easeInCore(gradient: number): number;
  4837. }
  4838. /**
  4839. * Easing function with a ease back shape (see link below).
  4840. * @see https://easings.net/#easeInBack
  4841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4842. */
  4843. class BackEase extends EasingFunction implements IEasingFunction {
  4844. /** Defines the amplitude of the function */
  4845. amplitude: number;
  4846. /**
  4847. * Instantiates a back ease easing
  4848. * @see https://easings.net/#easeInBack
  4849. * @param amplitude Defines the amplitude of the function
  4850. */
  4851. constructor(
  4852. /** Defines the amplitude of the function */
  4853. amplitude?: number);
  4854. /** @hidden */
  4855. easeInCore(gradient: number): number;
  4856. }
  4857. /**
  4858. * Easing function with a bouncing shape (see link below).
  4859. * @see https://easings.net/#easeInBounce
  4860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4861. */
  4862. class BounceEase extends EasingFunction implements IEasingFunction {
  4863. /** Defines the number of bounces */
  4864. bounces: number;
  4865. /** Defines the amplitude of the bounce */
  4866. bounciness: number;
  4867. /**
  4868. * Instantiates a bounce easing
  4869. * @see https://easings.net/#easeInBounce
  4870. * @param bounces Defines the number of bounces
  4871. * @param bounciness Defines the amplitude of the bounce
  4872. */
  4873. constructor(
  4874. /** Defines the number of bounces */
  4875. bounces?: number,
  4876. /** Defines the amplitude of the bounce */
  4877. bounciness?: number);
  4878. /** @hidden */
  4879. easeInCore(gradient: number): number;
  4880. }
  4881. /**
  4882. * Easing function with a power of 3 shape (see link below).
  4883. * @see https://easings.net/#easeInCubic
  4884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4885. */
  4886. class CubicEase extends EasingFunction implements IEasingFunction {
  4887. /** @hidden */
  4888. easeInCore(gradient: number): number;
  4889. }
  4890. /**
  4891. * Easing function with an elastic shape (see link below).
  4892. * @see https://easings.net/#easeInElastic
  4893. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4894. */
  4895. class ElasticEase extends EasingFunction implements IEasingFunction {
  4896. /** Defines the number of oscillations*/
  4897. oscillations: number;
  4898. /** Defines the amplitude of the oscillations*/
  4899. springiness: number;
  4900. /**
  4901. * Instantiates an elastic easing function
  4902. * @see https://easings.net/#easeInElastic
  4903. * @param oscillations Defines the number of oscillations
  4904. * @param springiness Defines the amplitude of the oscillations
  4905. */
  4906. constructor(
  4907. /** Defines the number of oscillations*/
  4908. oscillations?: number,
  4909. /** Defines the amplitude of the oscillations*/
  4910. springiness?: number);
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. /**
  4915. * Easing function with an exponential shape (see link below).
  4916. * @see https://easings.net/#easeInExpo
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4920. /** Defines the exponent of the function */
  4921. exponent: number;
  4922. /**
  4923. * Instantiates an exponential easing function
  4924. * @see https://easings.net/#easeInExpo
  4925. * @param exponent Defines the exponent of the function
  4926. */
  4927. constructor(
  4928. /** Defines the exponent of the function */
  4929. exponent?: number);
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a power shape (see link below).
  4935. * @see https://easings.net/#easeInQuad
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. class PowerEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the power of the function */
  4940. power: number;
  4941. /**
  4942. * Instantiates an power base easing function
  4943. * @see https://easings.net/#easeInQuad
  4944. * @param power Defines the power of the function
  4945. */
  4946. constructor(
  4947. /** Defines the power of the function */
  4948. power?: number);
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a power of 2 shape (see link below).
  4954. * @see https://easings.net/#easeInQuad
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a power of 4 shape (see link below).
  4963. * @see https://easings.net/#easeInQuart
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. class QuarticEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a power of 5 shape (see link below).
  4972. * @see https://easings.net/#easeInQuint
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. class QuinticEase extends EasingFunction implements IEasingFunction {
  4976. /** @hidden */
  4977. easeInCore(gradient: number): number;
  4978. }
  4979. /**
  4980. * Easing function with a sin shape (see link below).
  4981. * @see https://easings.net/#easeInSine
  4982. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4983. */
  4984. class SineEase extends EasingFunction implements IEasingFunction {
  4985. /** @hidden */
  4986. easeInCore(gradient: number): number;
  4987. }
  4988. /**
  4989. * Easing function with a bezier shape (see link below).
  4990. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4991. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4992. */
  4993. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4994. /** Defines the x component of the start tangent in the bezier curve */
  4995. x1: number;
  4996. /** Defines the y component of the start tangent in the bezier curve */
  4997. y1: number;
  4998. /** Defines the x component of the end tangent in the bezier curve */
  4999. x2: number;
  5000. /** Defines the y component of the end tangent in the bezier curve */
  5001. y2: number;
  5002. /**
  5003. * Instantiates a bezier function
  5004. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5005. * @param x1 Defines the x component of the start tangent in the bezier curve
  5006. * @param y1 Defines the y component of the start tangent in the bezier curve
  5007. * @param x2 Defines the x component of the end tangent in the bezier curve
  5008. * @param y2 Defines the y component of the end tangent in the bezier curve
  5009. */
  5010. constructor(
  5011. /** Defines the x component of the start tangent in the bezier curve */
  5012. x1?: number,
  5013. /** Defines the y component of the start tangent in the bezier curve */
  5014. y1?: number,
  5015. /** Defines the x component of the end tangent in the bezier curve */
  5016. x2?: number,
  5017. /** Defines the y component of the end tangent in the bezier curve */
  5018. y2?: number);
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. }
  5023. declare module BABYLON {
  5024. /**
  5025. * Defines a runtime animation
  5026. */
  5027. class RuntimeAnimation {
  5028. private _events;
  5029. /**
  5030. * The current frame of the runtime animation
  5031. */
  5032. private _currentFrame;
  5033. /**
  5034. * The animation used by the runtime animation
  5035. */
  5036. private _animation;
  5037. /**
  5038. * The target of the runtime animation
  5039. */
  5040. private _target;
  5041. /**
  5042. * The initiating animatable
  5043. */
  5044. private _host;
  5045. /**
  5046. * The original value of the runtime animation
  5047. */
  5048. private _originalValue;
  5049. /**
  5050. * The original blend value of the runtime animation
  5051. */
  5052. private _originalBlendValue;
  5053. /**
  5054. * The offsets cache of the runtime animation
  5055. */
  5056. private _offsetsCache;
  5057. /**
  5058. * The high limits cache of the runtime animation
  5059. */
  5060. private _highLimitsCache;
  5061. /**
  5062. * Specifies if the runtime animation has been stopped
  5063. */
  5064. private _stopped;
  5065. /**
  5066. * The blending factor of the runtime animation
  5067. */
  5068. private _blendingFactor;
  5069. /**
  5070. * The BabylonJS scene
  5071. */
  5072. private _scene;
  5073. /**
  5074. * The current value of the runtime animation
  5075. */
  5076. private _currentValue;
  5077. /** @hidden */
  5078. _workValue: any;
  5079. /**
  5080. * The active target of the runtime animation
  5081. */
  5082. private _activeTarget;
  5083. /**
  5084. * The target path of the runtime animation
  5085. */
  5086. private _targetPath;
  5087. /**
  5088. * The weight of the runtime animation
  5089. */
  5090. private _weight;
  5091. /**
  5092. * The ratio offset of the runtime animation
  5093. */
  5094. private _ratioOffset;
  5095. /**
  5096. * The previous delay of the runtime animation
  5097. */
  5098. private _previousDelay;
  5099. /**
  5100. * The previous ratio of the runtime animation
  5101. */
  5102. private _previousRatio;
  5103. /**
  5104. * Gets the current frame of the runtime animation
  5105. */
  5106. readonly currentFrame: number;
  5107. /**
  5108. * Gets the weight of the runtime animation
  5109. */
  5110. readonly weight: number;
  5111. /**
  5112. * Gets the current value of the runtime animation
  5113. */
  5114. readonly currentValue: any;
  5115. /**
  5116. * Gets the target path of the runtime animation
  5117. */
  5118. readonly targetPath: string;
  5119. /**
  5120. * Gets the actual target of the runtime animation
  5121. */
  5122. readonly target: any;
  5123. /**
  5124. * Create a new RuntimeAnimation object
  5125. * @param target defines the target of the animation
  5126. * @param animation defines the source animation object
  5127. * @param scene defines the hosting scene
  5128. * @param host defines the initiating Animatable
  5129. */
  5130. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5131. /**
  5132. * Gets the animation from the runtime animation
  5133. */
  5134. readonly animation: Animation;
  5135. /**
  5136. * Resets the runtime animation to the beginning
  5137. * @param restoreOriginal defines whether to restore the target property to the original value
  5138. */
  5139. reset(restoreOriginal?: boolean): void;
  5140. /**
  5141. * Specifies if the runtime animation is stopped
  5142. * @returns Boolean specifying if the runtime animation is stopped
  5143. */
  5144. isStopped(): boolean;
  5145. /**
  5146. * Disposes of the runtime animation
  5147. */
  5148. dispose(): void;
  5149. /**
  5150. * Interpolates the animation from the current frame
  5151. * @param currentFrame The frame to interpolate the animation to
  5152. * @param repeatCount The number of times that the animation should loop
  5153. * @param loopMode The type of looping mode to use
  5154. * @param offsetValue Animation offset value
  5155. * @param highLimitValue The high limit value
  5156. * @returns The interpolated value
  5157. */
  5158. private _interpolate;
  5159. /**
  5160. * Apply the interpolated value to the target
  5161. * @param currentValue defines the value computed by the animation
  5162. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5163. */
  5164. setValue(currentValue: any, weight?: number): void;
  5165. private _setValue;
  5166. /**
  5167. * Gets the loop pmode of the runtime animation
  5168. * @returns Loop Mode
  5169. */
  5170. private _getCorrectLoopMode;
  5171. /**
  5172. * Move the current animation to a given frame
  5173. * @param frame defines the frame to move to
  5174. */
  5175. goToFrame(frame: number): void;
  5176. /**
  5177. * @hidden Internal use only
  5178. */
  5179. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5180. /**
  5181. * Execute the current animation
  5182. * @param delay defines the delay to add to the current frame
  5183. * @param from defines the lower bound of the animation range
  5184. * @param to defines the upper bound of the animation range
  5185. * @param loop defines if the current animation must loop
  5186. * @param speedRatio defines the current speed ratio
  5187. * @param weight defines the weight of the animation (default is -1 so no weight)
  5188. * @param onLoop optional callback called when animation loops
  5189. * @returns a boolean indicating if the animation is running
  5190. */
  5191. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  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. * This represents an orbital type of camera.
  6807. *
  6808. * 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.
  6809. * 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.
  6810. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6811. */
  6812. class ArcRotateCamera extends TargetCamera {
  6813. /**
  6814. * Defines the rotation angle of the camera along the longitudinal axis.
  6815. */
  6816. alpha: number;
  6817. /**
  6818. * Defines the rotation angle of the camera along the latitudinal axis.
  6819. */
  6820. beta: number;
  6821. /**
  6822. * Defines the radius of the camera from it s target point.
  6823. */
  6824. radius: number;
  6825. protected _target: Vector3;
  6826. protected _targetHost: Nullable<AbstractMesh>;
  6827. /**
  6828. * Defines the target point of the camera.
  6829. * The camera looks towards it form the radius distance.
  6830. */
  6831. target: Vector3;
  6832. /**
  6833. * Current inertia value on the longitudinal axis.
  6834. * The bigger this number the longer it will take for the camera to stop.
  6835. */
  6836. inertialAlphaOffset: number;
  6837. /**
  6838. * Current inertia value on the latitudinal axis.
  6839. * The bigger this number the longer it will take for the camera to stop.
  6840. */
  6841. inertialBetaOffset: number;
  6842. /**
  6843. * Current inertia value on the radius axis.
  6844. * The bigger this number the longer it will take for the camera to stop.
  6845. */
  6846. inertialRadiusOffset: number;
  6847. /**
  6848. * Minimum allowed angle on the longitudinal axis.
  6849. * This can help limiting how the Camera is able to move in the scene.
  6850. */
  6851. lowerAlphaLimit: Nullable<number>;
  6852. /**
  6853. * Maximum allowed angle on the longitudinal axis.
  6854. * This can help limiting how the Camera is able to move in the scene.
  6855. */
  6856. upperAlphaLimit: Nullable<number>;
  6857. /**
  6858. * Minimum allowed angle on the latitudinal axis.
  6859. * This can help limiting how the Camera is able to move in the scene.
  6860. */
  6861. lowerBetaLimit: number;
  6862. /**
  6863. * Maximum allowed angle on the latitudinal axis.
  6864. * This can help limiting how the Camera is able to move in the scene.
  6865. */
  6866. upperBetaLimit: number;
  6867. /**
  6868. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6869. * This can help limiting how the Camera is able to move in the scene.
  6870. */
  6871. lowerRadiusLimit: Nullable<number>;
  6872. /**
  6873. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6874. * This can help limiting how the Camera is able to move in the scene.
  6875. */
  6876. upperRadiusLimit: Nullable<number>;
  6877. /**
  6878. * Defines the current inertia value used during panning of the camera along the X axis.
  6879. */
  6880. inertialPanningX: number;
  6881. /**
  6882. * Defines the current inertia value used during panning of the camera along the Y axis.
  6883. */
  6884. inertialPanningY: number;
  6885. /**
  6886. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6887. * Basically if your fingers moves away from more than this distance you will be considered
  6888. * in pinch mode.
  6889. */
  6890. pinchToPanMaxDistance: number;
  6891. /**
  6892. * Defines the maximum distance the camera can pan.
  6893. * This could help keeping the cammera always in your scene.
  6894. */
  6895. panningDistanceLimit: Nullable<number>;
  6896. /**
  6897. * Defines the target of the camera before paning.
  6898. */
  6899. panningOriginTarget: Vector3;
  6900. /**
  6901. * Defines the value of the inertia used during panning.
  6902. * 0 would mean stop inertia and one would mean no decelleration at all.
  6903. */
  6904. panningInertia: number;
  6905. /**
  6906. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6907. */
  6908. angularSensibilityX: number;
  6909. /**
  6910. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6911. */
  6912. angularSensibilityY: number;
  6913. /**
  6914. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6915. */
  6916. pinchPrecision: number;
  6917. /**
  6918. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6919. * It will be used instead of pinchDeltaPrecision if different from 0.
  6920. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6921. */
  6922. pinchDeltaPercentage: number;
  6923. /**
  6924. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6925. */
  6926. panningSensibility: number;
  6927. /**
  6928. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6929. */
  6930. keysUp: number[];
  6931. /**
  6932. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6933. */
  6934. keysDown: number[];
  6935. /**
  6936. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6937. */
  6938. keysLeft: number[];
  6939. /**
  6940. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6941. */
  6942. keysRight: number[];
  6943. /**
  6944. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6945. */
  6946. wheelPrecision: number;
  6947. /**
  6948. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6949. * It will be used instead of pinchDeltaPrecision if different from 0.
  6950. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6951. */
  6952. wheelDeltaPercentage: number;
  6953. /**
  6954. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6955. */
  6956. zoomOnFactor: number;
  6957. /**
  6958. * Defines a screen offset for the camera position.
  6959. */
  6960. targetScreenOffset: Vector2;
  6961. /**
  6962. * Allows the camera to be completely reversed.
  6963. * If false the camera can not arrive upside down.
  6964. */
  6965. allowUpsideDown: boolean;
  6966. /**
  6967. * Define if double tap/click is used to restore the previously saved state of the camera.
  6968. */
  6969. useInputToRestoreState: boolean;
  6970. /** @hidden */
  6971. _viewMatrix: Matrix;
  6972. /** @hidden */
  6973. _useCtrlForPanning: boolean;
  6974. /** @hidden */
  6975. _panningMouseButton: number;
  6976. /**
  6977. * Defines the inpute associated to the camera.
  6978. */
  6979. inputs: ArcRotateCameraInputsManager;
  6980. /** @hidden */
  6981. _reset: () => void;
  6982. /**
  6983. * Defines the allowed panning axis.
  6984. */
  6985. panningAxis: Vector3;
  6986. protected _localDirection: Vector3;
  6987. protected _transformedDirection: Vector3;
  6988. private _bouncingBehavior;
  6989. /**
  6990. * Gets the bouncing behavior of the camera if it has been enabled.
  6991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6992. */
  6993. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6994. /**
  6995. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6996. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6997. */
  6998. useBouncingBehavior: boolean;
  6999. private _framingBehavior;
  7000. /**
  7001. * Gets the framing behavior of the camera if it has been enabled.
  7002. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7003. */
  7004. readonly framingBehavior: Nullable<FramingBehavior>;
  7005. /**
  7006. * Defines if the framing behavior of the camera is enabled on the camera.
  7007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7008. */
  7009. useFramingBehavior: boolean;
  7010. private _autoRotationBehavior;
  7011. /**
  7012. * Gets the auto rotation behavior of the camera if it has been enabled.
  7013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7014. */
  7015. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7016. /**
  7017. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7018. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7019. */
  7020. useAutoRotationBehavior: boolean;
  7021. /**
  7022. * Observable triggered when the mesh target has been changed on the camera.
  7023. */
  7024. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7025. /**
  7026. * Event raised when the camera is colliding with a mesh.
  7027. */
  7028. onCollide: (collidedMesh: AbstractMesh) => void;
  7029. /**
  7030. * Defines whether the camera should check collision with the objects oh the scene.
  7031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7032. */
  7033. checkCollisions: boolean;
  7034. /**
  7035. * Defines the collision radius of the camera.
  7036. * This simulates a sphere around the camera.
  7037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7038. */
  7039. collisionRadius: Vector3;
  7040. protected _collider: Collider;
  7041. protected _previousPosition: Vector3;
  7042. protected _collisionVelocity: Vector3;
  7043. protected _newPosition: Vector3;
  7044. protected _previousAlpha: number;
  7045. protected _previousBeta: number;
  7046. protected _previousRadius: number;
  7047. protected _collisionTriggered: boolean;
  7048. protected _targetBoundingCenter: Nullable<Vector3>;
  7049. private _computationVector;
  7050. private _tempAxisVector;
  7051. private _tempAxisRotationMatrix;
  7052. /**
  7053. * Instantiates a new ArcRotateCamera in a given scene
  7054. * @param name Defines the name of the camera
  7055. * @param alpha Defines the camera rotation along the logitudinal axis
  7056. * @param beta Defines the camera rotation along the latitudinal axis
  7057. * @param radius Defines the camera distance from its target
  7058. * @param target Defines the camera target
  7059. * @param scene Defines the scene the camera belongs to
  7060. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7061. */
  7062. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7063. /** @hidden */
  7064. _initCache(): void;
  7065. /** @hidden */
  7066. _updateCache(ignoreParentClass?: boolean): void;
  7067. protected _getTargetPosition(): Vector3;
  7068. private _storedAlpha;
  7069. private _storedBeta;
  7070. private _storedRadius;
  7071. private _storedTarget;
  7072. /**
  7073. * Stores the current state of the camera (alpha, beta, radius and target)
  7074. * @returns the camera itself
  7075. */
  7076. storeState(): Camera;
  7077. /**
  7078. * @hidden
  7079. * Restored camera state. You must call storeState() first
  7080. */
  7081. _restoreStateValues(): boolean;
  7082. /** @hidden */
  7083. _isSynchronizedViewMatrix(): boolean;
  7084. /**
  7085. * Attached controls to the current camera.
  7086. * @param element Defines the element the controls should be listened from
  7087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7088. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7089. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7090. */
  7091. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7092. /**
  7093. * Detach the current controls from the camera.
  7094. * The camera will stop reacting to inputs.
  7095. * @param element Defines the element to stop listening the inputs from
  7096. */
  7097. detachControl(element: HTMLElement): void;
  7098. /** @hidden */
  7099. _checkInputs(): void;
  7100. protected _checkLimits(): void;
  7101. /**
  7102. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7103. */
  7104. rebuildAnglesAndRadius(): void;
  7105. /**
  7106. * Use a position to define the current camera related information like aplha, beta and radius
  7107. * @param position Defines the position to set the camera at
  7108. */
  7109. setPosition(position: Vector3): void;
  7110. /**
  7111. * Defines the target the camera should look at.
  7112. * This will automatically adapt alpha beta and radius to fit within the new target.
  7113. * @param target Defines the new target as a Vector or a mesh
  7114. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7115. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7116. */
  7117. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7118. /** @hidden */
  7119. _getViewMatrix(): Matrix;
  7120. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7121. /**
  7122. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7123. * @param meshes Defines the mesh to zoom on
  7124. * @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)
  7125. */
  7126. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7127. /**
  7128. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7129. * The target will be changed but the radius
  7130. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7131. * @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)
  7132. */
  7133. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7134. min: Vector3;
  7135. max: Vector3;
  7136. distance: number;
  7137. }, doNotUpdateMaxZ?: boolean): void;
  7138. /**
  7139. * @override
  7140. * Override Camera.createRigCamera
  7141. */
  7142. createRigCamera(name: string, cameraIndex: number): Camera;
  7143. /**
  7144. * @hidden
  7145. * @override
  7146. * Override Camera._updateRigCameras
  7147. */
  7148. _updateRigCameras(): void;
  7149. /**
  7150. * Destroy the camera and release the current resources hold by it.
  7151. */
  7152. dispose(): void;
  7153. /**
  7154. * Gets the current object class name.
  7155. * @return the class name
  7156. */
  7157. getClassName(): string;
  7158. }
  7159. }
  7160. declare module BABYLON {
  7161. /**
  7162. * Default Inputs manager for the ArcRotateCamera.
  7163. * It groups all the default supported inputs for ease of use.
  7164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7165. */
  7166. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7167. /**
  7168. * Instantiates a new ArcRotateCameraInputsManager.
  7169. * @param camera Defines the camera the inputs belong to
  7170. */
  7171. constructor(camera: ArcRotateCamera);
  7172. /**
  7173. * Add mouse wheel input support to the input manager.
  7174. * @returns the current input manager
  7175. */
  7176. addMouseWheel(): ArcRotateCameraInputsManager;
  7177. /**
  7178. * Add pointers input support to the input manager.
  7179. * @returns the current input manager
  7180. */
  7181. addPointers(): ArcRotateCameraInputsManager;
  7182. /**
  7183. * Add keyboard input support to the input manager.
  7184. * @returns the current input manager
  7185. */
  7186. addKeyboard(): ArcRotateCameraInputsManager;
  7187. /**
  7188. * Add orientation input support to the input manager.
  7189. * @returns the current input manager
  7190. */
  7191. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7192. }
  7193. }
  7194. declare module BABYLON {
  7195. /**
  7196. * This is the base class of all the camera used in the application.
  7197. * @see http://doc.babylonjs.com/features/cameras
  7198. */
  7199. class Camera extends Node {
  7200. /**
  7201. * This is the default projection mode used by the cameras.
  7202. * It helps recreating a feeling of perspective and better appreciate depth.
  7203. * This is the best way to simulate real life cameras.
  7204. */
  7205. static readonly PERSPECTIVE_CAMERA: number;
  7206. /**
  7207. * This helps creating camera with an orthographic mode.
  7208. * 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.
  7209. */
  7210. static readonly ORTHOGRAPHIC_CAMERA: number;
  7211. /**
  7212. * This is the default FOV mode for perspective cameras.
  7213. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7214. */
  7215. static readonly FOVMODE_VERTICAL_FIXED: number;
  7216. /**
  7217. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7218. */
  7219. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7220. /**
  7221. * This specifies ther is no need for a camera rig.
  7222. * Basically only one eye is rendered corresponding to the camera.
  7223. */
  7224. static readonly RIG_MODE_NONE: number;
  7225. /**
  7226. * Simulates a camera Rig with one blue eye and one red eye.
  7227. * This can be use with 3d blue and red glasses.
  7228. */
  7229. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7230. /**
  7231. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7232. */
  7233. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7234. /**
  7235. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7236. */
  7237. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7238. /**
  7239. * Defines that both eyes of the camera will be rendered over under each other.
  7240. */
  7241. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7242. /**
  7243. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7244. */
  7245. static readonly RIG_MODE_VR: number;
  7246. /**
  7247. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7248. */
  7249. static readonly RIG_MODE_WEBVR: number;
  7250. /**
  7251. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7252. */
  7253. static readonly RIG_MODE_CUSTOM: number;
  7254. /**
  7255. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7256. */
  7257. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7258. /**
  7259. * @hidden
  7260. * Might be removed once multiview will be a thing
  7261. */
  7262. static UseAlternateWebVRRendering: boolean;
  7263. /**
  7264. * Define the input manager associated with the camera.
  7265. */
  7266. inputs: CameraInputsManager<Camera>;
  7267. /**
  7268. * Define the current local position of the camera in the scene
  7269. */
  7270. position: Vector3;
  7271. /**
  7272. * The vector the camera should consider as up.
  7273. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7274. */
  7275. upVector: Vector3;
  7276. /**
  7277. * Define the current limit on the left side for an orthographic camera
  7278. * In scene unit
  7279. */
  7280. orthoLeft: Nullable<number>;
  7281. /**
  7282. * Define the current limit on the right side for an orthographic camera
  7283. * In scene unit
  7284. */
  7285. orthoRight: Nullable<number>;
  7286. /**
  7287. * Define the current limit on the bottom side for an orthographic camera
  7288. * In scene unit
  7289. */
  7290. orthoBottom: Nullable<number>;
  7291. /**
  7292. * Define the current limit on the top side for an orthographic camera
  7293. * In scene unit
  7294. */
  7295. orthoTop: Nullable<number>;
  7296. /**
  7297. * Field Of View is set in Radians. (default is 0.8)
  7298. */
  7299. fov: number;
  7300. /**
  7301. * Define the minimum distance the camera can see from.
  7302. * This is important to note that the depth buffer are not infinite and the closer it starts
  7303. * the more your scene might encounter depth fighting issue.
  7304. */
  7305. minZ: number;
  7306. /**
  7307. * Define the maximum distance the camera can see to.
  7308. * This is important to note that the depth buffer are not infinite and the further it end
  7309. * the more your scene might encounter depth fighting issue.
  7310. */
  7311. maxZ: number;
  7312. /**
  7313. * Define the default inertia of the camera.
  7314. * This helps giving a smooth feeling to the camera movement.
  7315. */
  7316. inertia: number;
  7317. /**
  7318. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7319. */
  7320. mode: number;
  7321. /**
  7322. * Define wether the camera is intermediate.
  7323. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7324. */
  7325. isIntermediate: boolean;
  7326. /**
  7327. * Define the viewport of the camera.
  7328. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7329. */
  7330. viewport: Viewport;
  7331. /**
  7332. * Restricts the camera to viewing objects with the same layerMask.
  7333. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7334. */
  7335. layerMask: number;
  7336. /**
  7337. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7338. */
  7339. fovMode: number;
  7340. /**
  7341. * Rig mode of the camera.
  7342. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7343. * This is normally controlled byt the camera themselves as internal use.
  7344. */
  7345. cameraRigMode: number;
  7346. /**
  7347. * Defines the distance between both "eyes" in case of a RIG
  7348. */
  7349. interaxialDistance: number;
  7350. /**
  7351. * Defines if stereoscopic rendering is done side by side or over under.
  7352. */
  7353. isStereoscopicSideBySide: boolean;
  7354. /**
  7355. * 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
  7356. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7357. * else in the scene.
  7358. */
  7359. customRenderTargets: RenderTargetTexture[];
  7360. /**
  7361. * When set, the camera will render to this render target instead of the default canvas
  7362. */
  7363. outputRenderTarget: Nullable<RenderTargetTexture>;
  7364. /**
  7365. * Observable triggered when the camera view matrix has changed.
  7366. */
  7367. onViewMatrixChangedObservable: Observable<Camera>;
  7368. /**
  7369. * Observable triggered when the camera Projection matrix has changed.
  7370. */
  7371. onProjectionMatrixChangedObservable: Observable<Camera>;
  7372. /**
  7373. * Observable triggered when the inputs have been processed.
  7374. */
  7375. onAfterCheckInputsObservable: Observable<Camera>;
  7376. /**
  7377. * Observable triggered when reset has been called and applied to the camera.
  7378. */
  7379. onRestoreStateObservable: Observable<Camera>;
  7380. /** @hidden */
  7381. _cameraRigParams: any;
  7382. /** @hidden */
  7383. _rigCameras: Camera[];
  7384. /** @hidden */
  7385. _rigPostProcess: Nullable<PostProcess>;
  7386. protected _webvrViewMatrix: Matrix;
  7387. /** @hidden */
  7388. _skipRendering: boolean;
  7389. /** @hidden */
  7390. _alternateCamera: Camera;
  7391. /** @hidden */
  7392. _projectionMatrix: Matrix;
  7393. /** @hidden */
  7394. _postProcesses: Nullable<PostProcess>[];
  7395. /** @hidden */
  7396. _activeMeshes: SmartArray<AbstractMesh>;
  7397. protected _globalPosition: Vector3;
  7398. /** hidden */
  7399. _computedViewMatrix: Matrix;
  7400. private _doNotComputeProjectionMatrix;
  7401. private _transformMatrix;
  7402. private _frustumPlanes;
  7403. private _refreshFrustumPlanes;
  7404. private _storedFov;
  7405. private _stateStored;
  7406. /**
  7407. * Instantiates a new camera object.
  7408. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7409. * @see http://doc.babylonjs.com/features/cameras
  7410. * @param name Defines the name of the camera in the scene
  7411. * @param position Defines the position of the camera
  7412. * @param scene Defines the scene the camera belongs too
  7413. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7414. */
  7415. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7416. /**
  7417. * Store current camera state (fov, position, etc..)
  7418. * @returns the camera
  7419. */
  7420. storeState(): Camera;
  7421. /**
  7422. * Restores the camera state values if it has been stored. You must call storeState() first
  7423. */
  7424. protected _restoreStateValues(): boolean;
  7425. /**
  7426. * Restored camera state. You must call storeState() first.
  7427. * @returns true if restored and false otherwise
  7428. */
  7429. restoreState(): boolean;
  7430. /**
  7431. * Gets the class name of the camera.
  7432. * @returns the class name
  7433. */
  7434. getClassName(): string;
  7435. /**
  7436. * Gets a string representation of the camera useful for debug purpose.
  7437. * @param fullDetails Defines that a more verboe level of logging is required
  7438. * @returns the string representation
  7439. */
  7440. toString(fullDetails?: boolean): string;
  7441. /**
  7442. * Gets the current world space position of the camera.
  7443. */
  7444. readonly globalPosition: Vector3;
  7445. /**
  7446. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7447. * @returns the active meshe list
  7448. */
  7449. getActiveMeshes(): SmartArray<AbstractMesh>;
  7450. /**
  7451. * Check wether a mesh is part of the current active mesh list of the camera
  7452. * @param mesh Defines the mesh to check
  7453. * @returns true if active, false otherwise
  7454. */
  7455. isActiveMesh(mesh: Mesh): boolean;
  7456. /**
  7457. * Is this camera ready to be used/rendered
  7458. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7459. * @return true if the camera is ready
  7460. */
  7461. isReady(completeCheck?: boolean): boolean;
  7462. /** @hidden */
  7463. _initCache(): void;
  7464. /** @hidden */
  7465. _updateCache(ignoreParentClass?: boolean): void;
  7466. /** @hidden */
  7467. _isSynchronized(): boolean;
  7468. /** @hidden */
  7469. _isSynchronizedViewMatrix(): boolean;
  7470. /** @hidden */
  7471. _isSynchronizedProjectionMatrix(): boolean;
  7472. /**
  7473. * Attach the input controls to a specific dom element to get the input from.
  7474. * @param element Defines the element the controls should be listened from
  7475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7476. */
  7477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7478. /**
  7479. * Detach the current controls from the specified dom element.
  7480. * @param element Defines the element to stop listening the inputs from
  7481. */
  7482. detachControl(element: HTMLElement): void;
  7483. /**
  7484. * Update the camera state according to the different inputs gathered during the frame.
  7485. */
  7486. update(): void;
  7487. /** @hidden */
  7488. _checkInputs(): void;
  7489. /** @hidden */
  7490. readonly rigCameras: Camera[];
  7491. /**
  7492. * Gets the post process used by the rig cameras
  7493. */
  7494. readonly rigPostProcess: Nullable<PostProcess>;
  7495. /**
  7496. * Internal, gets the first post proces.
  7497. * @returns the first post process to be run on this camera.
  7498. */
  7499. _getFirstPostProcess(): Nullable<PostProcess>;
  7500. private _cascadePostProcessesToRigCams;
  7501. /**
  7502. * Attach a post process to the camera.
  7503. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7504. * @param postProcess The post process to attach to the camera
  7505. * @param insertAt The position of the post process in case several of them are in use in the scene
  7506. * @returns the position the post process has been inserted at
  7507. */
  7508. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7509. /**
  7510. * Detach a post process to the camera.
  7511. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7512. * @param postProcess The post process to detach from the camera
  7513. */
  7514. detachPostProcess(postProcess: PostProcess): void;
  7515. /**
  7516. * Gets the current world matrix of the camera
  7517. */
  7518. getWorldMatrix(): Matrix;
  7519. /** @hidden */
  7520. protected _getViewMatrix(): Matrix;
  7521. /**
  7522. * Gets the current view matrix of the camera.
  7523. * @param force forces the camera to recompute the matrix without looking at the cached state
  7524. * @returns the view matrix
  7525. */
  7526. getViewMatrix(force?: boolean): Matrix;
  7527. /**
  7528. * Freeze the projection matrix.
  7529. * It will prevent the cache check of the camera projection compute and can speed up perf
  7530. * if no parameter of the camera are meant to change
  7531. * @param projection Defines manually a projection if necessary
  7532. */
  7533. freezeProjectionMatrix(projection?: Matrix): void;
  7534. /**
  7535. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7536. */
  7537. unfreezeProjectionMatrix(): void;
  7538. /**
  7539. * Gets the current projection matrix of the camera.
  7540. * @param force forces the camera to recompute the matrix without looking at the cached state
  7541. * @returns the projection matrix
  7542. */
  7543. getProjectionMatrix(force?: boolean): Matrix;
  7544. /**
  7545. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7546. * @returns a Matrix
  7547. */
  7548. getTransformationMatrix(): Matrix;
  7549. private _updateFrustumPlanes;
  7550. /**
  7551. * Checks if a cullable object (mesh...) is in the camera frustum
  7552. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7553. * @param target The object to check
  7554. * @returns true if the object is in frustum otherwise false
  7555. */
  7556. isInFrustum(target: ICullable): boolean;
  7557. /**
  7558. * Checks if a cullable object (mesh...) is in the camera frustum
  7559. * Unlike isInFrustum this cheks the full bounding box
  7560. * @param target The object to check
  7561. * @returns true if the object is in frustum otherwise false
  7562. */
  7563. isCompletelyInFrustum(target: ICullable): boolean;
  7564. /**
  7565. * Gets a ray in the forward direction from the camera.
  7566. * @param length Defines the length of the ray to create
  7567. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7568. * @param origin Defines the start point of the ray which defaults to the camera position
  7569. * @returns the forward ray
  7570. */
  7571. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7572. /**
  7573. * Releases resources associated with this node.
  7574. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7575. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7576. */
  7577. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7578. /**
  7579. * Gets the left camera of a rig setup in case of Rigged Camera
  7580. */
  7581. readonly leftCamera: Nullable<FreeCamera>;
  7582. /**
  7583. * Gets the right camera of a rig setup in case of Rigged Camera
  7584. */
  7585. readonly rightCamera: Nullable<FreeCamera>;
  7586. /**
  7587. * Gets the left camera target of a rig setup in case of Rigged Camera
  7588. * @returns the target position
  7589. */
  7590. getLeftTarget(): Nullable<Vector3>;
  7591. /**
  7592. * Gets the right camera target of a rig setup in case of Rigged Camera
  7593. * @returns the target position
  7594. */
  7595. getRightTarget(): Nullable<Vector3>;
  7596. /**
  7597. * @hidden
  7598. */
  7599. setCameraRigMode(mode: number, rigParams: any): void;
  7600. private _getVRProjectionMatrix;
  7601. protected _updateCameraRotationMatrix(): void;
  7602. protected _updateWebVRCameraRotationMatrix(): void;
  7603. /**
  7604. * This function MUST be overwritten by the different WebVR cameras available.
  7605. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7606. */
  7607. protected _getWebVRProjectionMatrix(): Matrix;
  7608. /**
  7609. * This function MUST be overwritten by the different WebVR cameras available.
  7610. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7611. */
  7612. protected _getWebVRViewMatrix(): Matrix;
  7613. /** @hidden */
  7614. setCameraRigParameter(name: string, value: any): void;
  7615. /**
  7616. * needs to be overridden by children so sub has required properties to be copied
  7617. * @hidden
  7618. */
  7619. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7620. /**
  7621. * May need to be overridden by children
  7622. * @hidden
  7623. */
  7624. _updateRigCameras(): void;
  7625. /** @hidden */
  7626. _setupInputs(): void;
  7627. /**
  7628. * Serialiaze the camera setup to a json represention
  7629. * @returns the JSON representation
  7630. */
  7631. serialize(): any;
  7632. /**
  7633. * Clones the current camera.
  7634. * @param name The cloned camera name
  7635. * @returns the cloned camera
  7636. */
  7637. clone(name: string): Camera;
  7638. /**
  7639. * Gets the direction of the camera relative to a given local axis.
  7640. * @param localAxis Defines the reference axis to provide a relative direction.
  7641. * @return the direction
  7642. */
  7643. getDirection(localAxis: Vector3): Vector3;
  7644. /**
  7645. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7646. * @param localAxis Defines the reference axis to provide a relative direction.
  7647. * @param result Defines the vector to store the result in
  7648. */
  7649. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7650. /**
  7651. * Gets a camera constructor for a given camera type
  7652. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7653. * @param name The name of the camera the result will be able to instantiate
  7654. * @param scene The scene the result will construct the camera in
  7655. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7656. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7657. * @returns a factory method to construc the camera
  7658. */
  7659. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7660. /**
  7661. * Compute the world matrix of the camera.
  7662. * @returns the camera workd matrix
  7663. */
  7664. computeWorldMatrix(): Matrix;
  7665. /**
  7666. * Parse a JSON and creates the camera from the parsed information
  7667. * @param parsedCamera The JSON to parse
  7668. * @param scene The scene to instantiate the camera in
  7669. * @returns the newly constructed camera
  7670. */
  7671. static Parse(parsedCamera: any, scene: Scene): Camera;
  7672. }
  7673. }
  7674. declare module BABYLON {
  7675. /**
  7676. * @ignore
  7677. * This is a list of all the different input types that are available in the application.
  7678. * Fo instance: ArcRotateCameraGamepadInput...
  7679. */
  7680. var CameraInputTypes: {};
  7681. /**
  7682. * This is the contract to implement in order to create a new input class.
  7683. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7684. */
  7685. interface ICameraInput<TCamera extends Camera> {
  7686. /**
  7687. * Defines the camera the input is attached to.
  7688. */
  7689. camera: Nullable<TCamera>;
  7690. /**
  7691. * Gets the class name of the current intput.
  7692. * @returns the class name
  7693. */
  7694. getClassName(): string;
  7695. /**
  7696. * Get the friendly name associated with the input class.
  7697. * @returns the input friendly name
  7698. */
  7699. getSimpleName(): string;
  7700. /**
  7701. * Attach the input controls to a specific dom element to get the input from.
  7702. * @param element Defines the element the controls should be listened from
  7703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7704. */
  7705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7706. /**
  7707. * Detach the current controls from the specified dom element.
  7708. * @param element Defines the element to stop listening the inputs from
  7709. */
  7710. detachControl(element: Nullable<HTMLElement>): void;
  7711. /**
  7712. * Update the current camera state depending on the inputs that have been used this frame.
  7713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7714. */
  7715. checkInputs?: () => void;
  7716. }
  7717. /**
  7718. * Represents a map of input types to input instance or input index to input instance.
  7719. */
  7720. interface CameraInputsMap<TCamera extends Camera> {
  7721. /**
  7722. * Accessor to the input by input type.
  7723. */
  7724. [name: string]: ICameraInput<TCamera>;
  7725. /**
  7726. * Accessor to the input by input index.
  7727. */
  7728. [idx: number]: ICameraInput<TCamera>;
  7729. }
  7730. /**
  7731. * This represents the input manager used within a camera.
  7732. * It helps dealing with all the different kind of input attached to a camera.
  7733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7734. */
  7735. class CameraInputsManager<TCamera extends Camera> {
  7736. /**
  7737. * Defines the list of inputs attahed to the camera.
  7738. */
  7739. attached: CameraInputsMap<TCamera>;
  7740. /**
  7741. * Defines the dom element the camera is collecting inputs from.
  7742. * This is null if the controls have not been attached.
  7743. */
  7744. attachedElement: Nullable<HTMLElement>;
  7745. /**
  7746. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7747. */
  7748. noPreventDefault: boolean;
  7749. /**
  7750. * Defined the camera the input manager belongs to.
  7751. */
  7752. camera: TCamera;
  7753. /**
  7754. * Update the current camera state depending on the inputs that have been used this frame.
  7755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7756. */
  7757. checkInputs: () => void;
  7758. /**
  7759. * Instantiate a new Camera Input Manager.
  7760. * @param camera Defines the camera the input manager blongs to
  7761. */
  7762. constructor(camera: TCamera);
  7763. /**
  7764. * Add an input method to a camera
  7765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7766. * @param input camera input method
  7767. */
  7768. add(input: ICameraInput<TCamera>): void;
  7769. /**
  7770. * Remove a specific input method from a camera
  7771. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7772. * @param inputToRemove camera input method
  7773. */
  7774. remove(inputToRemove: ICameraInput<TCamera>): void;
  7775. /**
  7776. * Remove a specific input type from a camera
  7777. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7778. * @param inputType the type of the input to remove
  7779. */
  7780. removeByType(inputType: string): void;
  7781. private _addCheckInputs;
  7782. /**
  7783. * Attach the input controls to the currently attached dom element to listen the events from.
  7784. * @param input Defines the input to attach
  7785. */
  7786. attachInput(input: ICameraInput<TCamera>): void;
  7787. /**
  7788. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7789. * @param element Defines the dom element to collect the events from
  7790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7791. */
  7792. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7793. /**
  7794. * Detach the current manager inputs controls from a specific dom element.
  7795. * @param element Defines the dom element to collect the events from
  7796. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7797. */
  7798. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7799. /**
  7800. * Rebuild the dynamic inputCheck function from the current list of
  7801. * defined inputs in the manager.
  7802. */
  7803. rebuildInputCheck(): void;
  7804. /**
  7805. * Remove all attached input methods from a camera
  7806. */
  7807. clear(): void;
  7808. /**
  7809. * Serialize the current input manager attached to a camera.
  7810. * This ensures than once parsed,
  7811. * the input associated to the camera will be identical to the current ones
  7812. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7813. */
  7814. serialize(serializedCamera: any): void;
  7815. /**
  7816. * Parses an input manager serialized JSON to restore the previous list of inputs
  7817. * and states associated to a camera.
  7818. * @param parsedCamera Defines the JSON to parse
  7819. */
  7820. parse(parsedCamera: any): void;
  7821. }
  7822. }
  7823. declare module BABYLON {
  7824. /**
  7825. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7826. * being tilted forward or back and left or right.
  7827. */
  7828. class DeviceOrientationCamera extends FreeCamera {
  7829. private _initialQuaternion;
  7830. private _quaternionCache;
  7831. /**
  7832. * Creates a new device orientation camera
  7833. * @param name The name of the camera
  7834. * @param position The start position camera
  7835. * @param scene The scene the camera belongs to
  7836. */
  7837. constructor(name: string, position: Vector3, scene: Scene);
  7838. /**
  7839. * Gets the current instance class name ("DeviceOrientationCamera").
  7840. * This helps avoiding instanceof at run time.
  7841. * @returns the class name
  7842. */
  7843. getClassName(): string;
  7844. /**
  7845. * @hidden
  7846. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7847. */
  7848. _checkInputs(): void;
  7849. /**
  7850. * Reset the camera to its default orientation on the specified axis only.
  7851. * @param axis The axis to reset
  7852. */
  7853. resetToCurrentRotation(axis?: Axis): void;
  7854. }
  7855. }
  7856. declare module BABYLON {
  7857. /**
  7858. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7859. * such as in a 3D Space Shooter or a Flight Simulator.
  7860. */
  7861. class FlyCamera extends TargetCamera {
  7862. /**
  7863. * Define the collision ellipsoid of the camera.
  7864. * This is helpful for simulating a camera body, like a player's body.
  7865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7866. */
  7867. ellipsoid: Vector3;
  7868. /**
  7869. * Define an offset for the position of the ellipsoid around the camera.
  7870. * This can be helpful if the camera is attached away from the player's body center,
  7871. * such as at its head.
  7872. */
  7873. ellipsoidOffset: Vector3;
  7874. /**
  7875. * Enable or disable collisions of the camera with the rest of the scene objects.
  7876. */
  7877. checkCollisions: boolean;
  7878. /**
  7879. * Enable or disable gravity on the camera.
  7880. */
  7881. applyGravity: boolean;
  7882. /**
  7883. * Define the current direction the camera is moving to.
  7884. */
  7885. cameraDirection: Vector3;
  7886. /**
  7887. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7888. * This overrides and empties cameraRotation.
  7889. */
  7890. rotationQuaternion: BABYLON.Quaternion;
  7891. /**
  7892. * Track Roll to maintain the wanted Rolling when looking around.
  7893. */
  7894. _trackRoll: number;
  7895. /**
  7896. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7897. */
  7898. rollCorrect: number;
  7899. /**
  7900. * Mimic a banked turn, Rolling the camera when Yawing.
  7901. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7902. */
  7903. bankedTurn: boolean;
  7904. /**
  7905. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7906. */
  7907. bankedTurnLimit: number;
  7908. /**
  7909. * Value of 0 disables the banked Roll.
  7910. * Value of 1 is equal to the Yaw angle in radians.
  7911. */
  7912. bankedTurnMultiplier: number;
  7913. /**
  7914. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7915. */
  7916. inputs: FlyCameraInputsManager;
  7917. /**
  7918. * Gets the input sensibility for mouse input.
  7919. * Higher values reduce sensitivity.
  7920. */
  7921. /**
  7922. * Sets the input sensibility for a mouse input.
  7923. * Higher values reduce sensitivity.
  7924. */
  7925. angularSensibility: number;
  7926. /**
  7927. * Get the keys for camera movement forward.
  7928. */
  7929. /**
  7930. * Set the keys for camera movement forward.
  7931. */
  7932. keysForward: number[];
  7933. /**
  7934. * Get the keys for camera movement backward.
  7935. */
  7936. keysBackward: number[];
  7937. /**
  7938. * Get the keys for camera movement up.
  7939. */
  7940. /**
  7941. * Set the keys for camera movement up.
  7942. */
  7943. keysUp: number[];
  7944. /**
  7945. * Get the keys for camera movement down.
  7946. */
  7947. /**
  7948. * Set the keys for camera movement down.
  7949. */
  7950. keysDown: number[];
  7951. /**
  7952. * Get the keys for camera movement left.
  7953. */
  7954. /**
  7955. * Set the keys for camera movement left.
  7956. */
  7957. keysLeft: number[];
  7958. /**
  7959. * Set the keys for camera movement right.
  7960. */
  7961. /**
  7962. * Set the keys for camera movement right.
  7963. */
  7964. keysRight: number[];
  7965. /**
  7966. * Event raised when the camera collides with a mesh in the scene.
  7967. */
  7968. onCollide: (collidedMesh: AbstractMesh) => void;
  7969. private _collider;
  7970. private _needMoveForGravity;
  7971. private _oldPosition;
  7972. private _diffPosition;
  7973. private _newPosition;
  7974. /** @hidden */
  7975. _localDirection: Vector3;
  7976. /** @hidden */
  7977. _transformedDirection: Vector3;
  7978. /**
  7979. * Instantiates a FlyCamera.
  7980. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7981. * such as in a 3D Space Shooter or a Flight Simulator.
  7982. * @param name Define the name of the camera in the scene.
  7983. * @param position Define the starting position of the camera in the scene.
  7984. * @param scene Define the scene the camera belongs to.
  7985. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7986. */
  7987. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7988. /**
  7989. * Attach a control to the HTML DOM element.
  7990. * @param element Defines the element that listens to the input events.
  7991. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7992. */
  7993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7994. /**
  7995. * Detach a control from the HTML DOM element.
  7996. * The camera will stop reacting to that input.
  7997. * @param element Defines the element that listens to the input events.
  7998. */
  7999. detachControl(element: HTMLElement): void;
  8000. private _collisionMask;
  8001. /**
  8002. * Get the mask that the camera ignores in collision events.
  8003. */
  8004. /**
  8005. * Set the mask that the camera ignores in collision events.
  8006. */
  8007. collisionMask: number;
  8008. /** @hidden */
  8009. _collideWithWorld(displacement: Vector3): void;
  8010. /** @hidden */
  8011. private _onCollisionPositionChange;
  8012. /** @hidden */
  8013. _checkInputs(): void;
  8014. /** @hidden */
  8015. _decideIfNeedsToMove(): boolean;
  8016. /** @hidden */
  8017. _updatePosition(): void;
  8018. /**
  8019. * Restore the Roll to its target value at the rate specified.
  8020. * @param rate - Higher means slower restoring.
  8021. * @hidden
  8022. */
  8023. restoreRoll(rate: number): void;
  8024. /**
  8025. * Destroy the camera and release the current resources held by it.
  8026. */
  8027. dispose(): void;
  8028. /**
  8029. * Get the current object class name.
  8030. * @returns the class name.
  8031. */
  8032. getClassName(): string;
  8033. }
  8034. }
  8035. declare module BABYLON {
  8036. /**
  8037. * Default Inputs manager for the FlyCamera.
  8038. * It groups all the default supported inputs for ease of use.
  8039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8040. */
  8041. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8042. /**
  8043. * Instantiates a new FlyCameraInputsManager.
  8044. * @param camera Defines the camera the inputs belong to.
  8045. */
  8046. constructor(camera: FlyCamera);
  8047. /**
  8048. * Add keyboard input support to the input manager.
  8049. * @returns the new FlyCameraKeyboardMoveInput().
  8050. */
  8051. addKeyboard(): FlyCameraInputsManager;
  8052. /**
  8053. * Add mouse input support to the input manager.
  8054. * @param touchEnabled Enable touch screen support.
  8055. * @returns the new FlyCameraMouseInput().
  8056. */
  8057. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8058. }
  8059. }
  8060. declare module BABYLON {
  8061. /**
  8062. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8063. * an arc rotate version arcFollowCamera are available.
  8064. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8065. */
  8066. class FollowCamera extends TargetCamera {
  8067. /**
  8068. * Distance the follow camera should follow an object at
  8069. */
  8070. radius: number;
  8071. /**
  8072. * Define a rotation offset between the camera and the object it follows
  8073. */
  8074. rotationOffset: number;
  8075. /**
  8076. * Define a height offset between the camera and the object it follows.
  8077. * It can help following an object from the top (like a car chaing a plane)
  8078. */
  8079. heightOffset: number;
  8080. /**
  8081. * Define how fast the camera can accelerate to follow it s target.
  8082. */
  8083. cameraAcceleration: number;
  8084. /**
  8085. * Define the speed limit of the camera following an object.
  8086. */
  8087. maxCameraSpeed: number;
  8088. /**
  8089. * Define the target of the camera.
  8090. */
  8091. lockedTarget: Nullable<AbstractMesh>;
  8092. /**
  8093. * Instantiates the follow camera.
  8094. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8095. * @param name Define the name of the camera in the scene
  8096. * @param position Define the position of the camera
  8097. * @param scene Define the scene the camera belong to
  8098. * @param lockedTarget Define the target of the camera
  8099. */
  8100. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8101. private _follow;
  8102. /** @hidden */
  8103. _checkInputs(): void;
  8104. /**
  8105. * Gets the camera class name.
  8106. * @returns the class name
  8107. */
  8108. getClassName(): string;
  8109. }
  8110. /**
  8111. * Arc Rotate version of the follow camera.
  8112. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8113. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8114. */
  8115. class ArcFollowCamera extends TargetCamera {
  8116. /** The longitudinal angle of the camera */
  8117. alpha: number;
  8118. /** The latitudinal angle of the camera */
  8119. beta: number;
  8120. /** The radius of the camera from its target */
  8121. radius: number;
  8122. /** Define the camera target (the messh it should follow) */
  8123. target: Nullable<AbstractMesh>;
  8124. private _cartesianCoordinates;
  8125. /**
  8126. * Instantiates a new ArcFollowCamera
  8127. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8128. * @param name Define the name of the camera
  8129. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8130. * @param beta Define the rotation angle of the camera around the elevation axis
  8131. * @param radius Define the radius of the camera from its target point
  8132. * @param target Define the target of the camera
  8133. * @param scene Define the scene the camera belongs to
  8134. */
  8135. constructor(name: string,
  8136. /** The longitudinal angle of the camera */
  8137. alpha: number,
  8138. /** The latitudinal angle of the camera */
  8139. beta: number,
  8140. /** The radius of the camera from its target */
  8141. radius: number,
  8142. /** Define the camera target (the messh it should follow) */
  8143. target: Nullable<AbstractMesh>, scene: Scene);
  8144. private _follow;
  8145. /** @hidden */
  8146. _checkInputs(): void;
  8147. /**
  8148. * Returns the class name of the object.
  8149. * It is mostly used internally for serialization purposes.
  8150. */
  8151. getClassName(): string;
  8152. }
  8153. }
  8154. declare module BABYLON {
  8155. /**
  8156. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8157. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8158. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8159. */
  8160. class FreeCamera extends TargetCamera {
  8161. /**
  8162. * Define the collision ellipsoid of the camera.
  8163. * This is helpful to simulate a camera body like the player body around the camera
  8164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8165. */
  8166. ellipsoid: Vector3;
  8167. /**
  8168. * Define an offset for the position of the ellipsoid around the camera.
  8169. * This can be helpful to determine the center of the body near the gravity center of the body
  8170. * instead of its head.
  8171. */
  8172. ellipsoidOffset: Vector3;
  8173. /**
  8174. * Enable or disable collisions of the camera with the rest of the scene objects.
  8175. */
  8176. checkCollisions: boolean;
  8177. /**
  8178. * Enable or disable gravity on the camera.
  8179. */
  8180. applyGravity: boolean;
  8181. /**
  8182. * Define the input manager associated to the camera.
  8183. */
  8184. inputs: FreeCameraInputsManager;
  8185. /**
  8186. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8187. * Higher values reduce sensitivity.
  8188. */
  8189. /**
  8190. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8191. * Higher values reduce sensitivity.
  8192. */
  8193. angularSensibility: number;
  8194. /**
  8195. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8196. */
  8197. keysUp: number[];
  8198. /**
  8199. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8200. */
  8201. keysDown: number[];
  8202. /**
  8203. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8204. */
  8205. keysLeft: number[];
  8206. /**
  8207. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8208. */
  8209. keysRight: number[];
  8210. /**
  8211. * Event raised when the camera collide with a mesh in the scene.
  8212. */
  8213. onCollide: (collidedMesh: AbstractMesh) => void;
  8214. private _collider;
  8215. private _needMoveForGravity;
  8216. private _oldPosition;
  8217. private _diffPosition;
  8218. private _newPosition;
  8219. /** @hidden */
  8220. _localDirection: Vector3;
  8221. /** @hidden */
  8222. _transformedDirection: Vector3;
  8223. /**
  8224. * Instantiates a Free Camera.
  8225. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8226. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8228. * @param name Define the name of the camera in the scene
  8229. * @param position Define the start position of the camera in the scene
  8230. * @param scene Define the scene the camera belongs to
  8231. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8232. */
  8233. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8234. /**
  8235. * Attached controls to the current camera.
  8236. * @param element Defines the element the controls should be listened from
  8237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8238. */
  8239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8240. /**
  8241. * Detach the current controls from the camera.
  8242. * The camera will stop reacting to inputs.
  8243. * @param element Defines the element to stop listening the inputs from
  8244. */
  8245. detachControl(element: HTMLElement): void;
  8246. private _collisionMask;
  8247. /**
  8248. * Define a collision mask to limit the list of object the camera can collide with
  8249. */
  8250. collisionMask: number;
  8251. /** @hidden */
  8252. _collideWithWorld(displacement: Vector3): void;
  8253. private _onCollisionPositionChange;
  8254. /** @hidden */
  8255. _checkInputs(): void;
  8256. /** @hidden */
  8257. _decideIfNeedsToMove(): boolean;
  8258. /** @hidden */
  8259. _updatePosition(): void;
  8260. /**
  8261. * Destroy the camera and release the current resources hold by it.
  8262. */
  8263. dispose(): void;
  8264. /**
  8265. * Gets the current object class name.
  8266. * @return the class name
  8267. */
  8268. getClassName(): string;
  8269. }
  8270. }
  8271. declare module BABYLON {
  8272. /**
  8273. * Default Inputs manager for the FreeCamera.
  8274. * It groups all the default supported inputs for ease of use.
  8275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8276. */
  8277. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8278. /**
  8279. * Instantiates a new FreeCameraInputsManager.
  8280. * @param camera Defines the camera the inputs belong to
  8281. */
  8282. constructor(camera: FreeCamera);
  8283. /**
  8284. * Add keyboard input support to the input manager.
  8285. * @returns the current input manager
  8286. */
  8287. addKeyboard(): FreeCameraInputsManager;
  8288. /**
  8289. * Add mouse input support to the input manager.
  8290. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8291. * @returns the current input manager
  8292. */
  8293. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8294. /**
  8295. * Add orientation input support to the input manager.
  8296. * @returns the current input manager
  8297. */
  8298. addDeviceOrientation(): FreeCameraInputsManager;
  8299. /**
  8300. * Add touch input support to the input manager.
  8301. * @returns the current input manager
  8302. */
  8303. addTouch(): FreeCameraInputsManager;
  8304. /**
  8305. * Add virtual joystick input support to the input manager.
  8306. * @returns the current input manager
  8307. */
  8308. addVirtualJoystick(): FreeCameraInputsManager;
  8309. }
  8310. }
  8311. declare module BABYLON {
  8312. /**
  8313. * This represents a FPS type of camera. This is only here for back compat purpose.
  8314. * Please use the UniversalCamera instead as both are identical.
  8315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8316. */
  8317. class GamepadCamera extends UniversalCamera {
  8318. /**
  8319. * Instantiates a new Gamepad Camera
  8320. * This represents a FPS type of camera. This is only here for back compat purpose.
  8321. * Please use the UniversalCamera instead as both are identical.
  8322. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8323. * @param name Define the name of the camera in the scene
  8324. * @param position Define the start position of the camera in the scene
  8325. * @param scene Define the scene the camera belongs to
  8326. */
  8327. constructor(name: string, position: Vector3, scene: Scene);
  8328. /**
  8329. * Gets the current object class name.
  8330. * @return the class name
  8331. */
  8332. getClassName(): string;
  8333. }
  8334. }
  8335. declare module BABYLON {
  8336. /**
  8337. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8338. * This is the base of the follow, arc rotate cameras and Free camera
  8339. * @see http://doc.babylonjs.com/features/cameras
  8340. */
  8341. class TargetCamera extends Camera {
  8342. private static _RigCamTransformMatrix;
  8343. private static _TargetTransformMatrix;
  8344. private static _TargetFocalPoint;
  8345. /**
  8346. * Define the current direction the camera is moving to
  8347. */
  8348. cameraDirection: Vector3;
  8349. /**
  8350. * Define the current rotation the camera is rotating to
  8351. */
  8352. cameraRotation: Vector2;
  8353. /**
  8354. * When set, the up vector of the camera will be updated by the rotation of the camera
  8355. */
  8356. updateUpVectorFromRotation: boolean;
  8357. private _tmpQuaternion;
  8358. /**
  8359. * Define the current rotation of the camera
  8360. */
  8361. rotation: Vector3;
  8362. /**
  8363. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8364. */
  8365. rotationQuaternion: Quaternion;
  8366. /**
  8367. * Define the current speed of the camera
  8368. */
  8369. speed: number;
  8370. /**
  8371. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8372. * around all axis.
  8373. */
  8374. noRotationConstraint: boolean;
  8375. /**
  8376. * Define the current target of the camera as an object or a position.
  8377. */
  8378. lockedTarget: any;
  8379. /** @hidden */
  8380. _currentTarget: Vector3;
  8381. /** @hidden */
  8382. _initialFocalDistance: number;
  8383. /** @hidden */
  8384. _viewMatrix: Matrix;
  8385. /** @hidden */
  8386. _camMatrix: Matrix;
  8387. /** @hidden */
  8388. _cameraTransformMatrix: Matrix;
  8389. /** @hidden */
  8390. _cameraRotationMatrix: Matrix;
  8391. /** @hidden */
  8392. _referencePoint: Vector3;
  8393. /** @hidden */
  8394. _transformedReferencePoint: Vector3;
  8395. protected _globalCurrentTarget: Vector3;
  8396. protected _globalCurrentUpVector: Vector3;
  8397. /** @hidden */
  8398. _reset: () => void;
  8399. private _defaultUp;
  8400. /**
  8401. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8402. * This is the base of the follow, arc rotate cameras and Free camera
  8403. * @see http://doc.babylonjs.com/features/cameras
  8404. * @param name Defines the name of the camera in the scene
  8405. * @param position Defines the start position of the camera in the scene
  8406. * @param scene Defines the scene the camera belongs to
  8407. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8408. */
  8409. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8410. /**
  8411. * Gets the position in front of the camera at a given distance.
  8412. * @param distance The distance from the camera we want the position to be
  8413. * @returns the position
  8414. */
  8415. getFrontPosition(distance: number): Vector3;
  8416. /** @hidden */
  8417. _getLockedTargetPosition(): Nullable<Vector3>;
  8418. private _storedPosition;
  8419. private _storedRotation;
  8420. private _storedRotationQuaternion;
  8421. /**
  8422. * Store current camera state of the camera (fov, position, rotation, etc..)
  8423. * @returns the camera
  8424. */
  8425. storeState(): Camera;
  8426. /**
  8427. * Restored camera state. You must call storeState() first
  8428. * @returns whether it was successful or not
  8429. * @hidden
  8430. */
  8431. _restoreStateValues(): boolean;
  8432. /** @hidden */
  8433. _initCache(): void;
  8434. /** @hidden */
  8435. _updateCache(ignoreParentClass?: boolean): void;
  8436. /** @hidden */
  8437. _isSynchronizedViewMatrix(): boolean;
  8438. /** @hidden */
  8439. _computeLocalCameraSpeed(): number;
  8440. /** @hidden */
  8441. setTarget(target: Vector3): void;
  8442. /**
  8443. * Return the current target position of the camera. This value is expressed in local space.
  8444. * @returns the target position
  8445. */
  8446. getTarget(): Vector3;
  8447. /** @hidden */
  8448. _decideIfNeedsToMove(): boolean;
  8449. /** @hidden */
  8450. _updatePosition(): void;
  8451. /** @hidden */
  8452. _checkInputs(): void;
  8453. protected _updateCameraRotationMatrix(): void;
  8454. /**
  8455. * 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)
  8456. * @returns the current camera
  8457. */
  8458. private _rotateUpVectorWithCameraRotationMatrix;
  8459. private _cachedRotationZ;
  8460. private _cachedQuaternionRotationZ;
  8461. /** @hidden */
  8462. _getViewMatrix(): Matrix;
  8463. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8464. /**
  8465. * @hidden
  8466. */
  8467. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8468. /**
  8469. * @hidden
  8470. */
  8471. _updateRigCameras(): void;
  8472. private _getRigCamPositionAndTarget;
  8473. /**
  8474. * Gets the current object class name.
  8475. * @return the class name
  8476. */
  8477. getClassName(): string;
  8478. }
  8479. }
  8480. declare module BABYLON {
  8481. /**
  8482. * This represents a FPS type of camera controlled by touch.
  8483. * This is like a universal camera minus the Gamepad controls.
  8484. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8485. */
  8486. class TouchCamera extends FreeCamera {
  8487. /**
  8488. * Defines the touch sensibility for rotation.
  8489. * The higher the faster.
  8490. */
  8491. touchAngularSensibility: number;
  8492. /**
  8493. * Defines the touch sensibility for move.
  8494. * The higher the faster.
  8495. */
  8496. touchMoveSensibility: number;
  8497. /**
  8498. * Instantiates a new touch camera.
  8499. * This represents a FPS type of camera controlled by touch.
  8500. * This is like a universal camera minus the Gamepad controls.
  8501. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8502. * @param name Define the name of the camera in the scene
  8503. * @param position Define the start position of the camera in the scene
  8504. * @param scene Define the scene the camera belongs to
  8505. */
  8506. constructor(name: string, position: Vector3, scene: Scene);
  8507. /**
  8508. * Gets the current object class name.
  8509. * @return the class name
  8510. */
  8511. getClassName(): string;
  8512. /** @hidden */
  8513. _setupInputs(): void;
  8514. }
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * 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,
  8519. * which still works and will still be found in many Playgrounds.
  8520. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8521. */
  8522. class UniversalCamera extends TouchCamera {
  8523. /**
  8524. * Defines the gamepad rotation sensiblity.
  8525. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8526. */
  8527. gamepadAngularSensibility: number;
  8528. /**
  8529. * Defines the gamepad move sensiblity.
  8530. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8531. */
  8532. gamepadMoveSensibility: number;
  8533. /**
  8534. * 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,
  8535. * which still works and will still be found in many Playgrounds.
  8536. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8537. * @param name Define the name of the camera in the scene
  8538. * @param position Define the start position of the camera in the scene
  8539. * @param scene Define the scene the camera belongs to
  8540. */
  8541. constructor(name: string, position: Vector3, scene: Scene);
  8542. /**
  8543. * Gets the current object class name.
  8544. * @return the class name
  8545. */
  8546. getClassName(): string;
  8547. }
  8548. }
  8549. declare module BABYLON {
  8550. /**
  8551. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8552. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8553. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8554. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8555. */
  8556. class VirtualJoysticksCamera extends FreeCamera {
  8557. /**
  8558. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  8559. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8560. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8561. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8562. * @param name Define the name of the camera in the scene
  8563. * @param position Define the start position of the camera in the scene
  8564. * @param scene Define the scene the camera belongs to
  8565. */
  8566. constructor(name: string, position: Vector3, scene: Scene);
  8567. /**
  8568. * Gets the current object class name.
  8569. * @return the class name
  8570. */
  8571. getClassName(): string;
  8572. }
  8573. }
  8574. interface VRDisplay extends EventTarget {
  8575. /**
  8576. * Dictionary of capabilities describing the VRDisplay.
  8577. */
  8578. readonly capabilities: VRDisplayCapabilities;
  8579. /**
  8580. * z-depth defining the far plane of the eye view frustum
  8581. * enables mapping of values in the render target depth
  8582. * attachment to scene coordinates. Initially set to 10000.0.
  8583. */
  8584. depthFar: number;
  8585. /**
  8586. * z-depth defining the near plane of the eye view frustum
  8587. * enables mapping of values in the render target depth
  8588. * attachment to scene coordinates. Initially set to 0.01.
  8589. */
  8590. depthNear: number;
  8591. /**
  8592. * An identifier for this distinct VRDisplay. Used as an
  8593. * association point in the Gamepad API.
  8594. */
  8595. readonly displayId: number;
  8596. /**
  8597. * A display name, a user-readable name identifying it.
  8598. */
  8599. readonly displayName: string;
  8600. readonly isConnected: boolean;
  8601. readonly isPresenting: boolean;
  8602. /**
  8603. * If this VRDisplay supports room-scale experiences, the optional
  8604. * stage attribute contains details on the room-scale parameters.
  8605. */
  8606. readonly stageParameters: VRStageParameters | null;
  8607. /**
  8608. * Passing the value returned by `requestAnimationFrame` to
  8609. * `cancelAnimationFrame` will unregister the callback.
  8610. * @param handle Define the hanle of the request to cancel
  8611. */
  8612. cancelAnimationFrame(handle: number): void;
  8613. /**
  8614. * Stops presenting to the VRDisplay.
  8615. * @returns a promise to know when it stopped
  8616. */
  8617. exitPresent(): Promise<void>;
  8618. /**
  8619. * Return the current VREyeParameters for the given eye.
  8620. * @param whichEye Define the eye we want the parameter for
  8621. * @returns the eye parameters
  8622. */
  8623. getEyeParameters(whichEye: string): VREyeParameters;
  8624. /**
  8625. * Populates the passed VRFrameData with the information required to render
  8626. * the current frame.
  8627. * @param frameData Define the data structure to populate
  8628. * @returns true if ok otherwise false
  8629. */
  8630. getFrameData(frameData: VRFrameData): boolean;
  8631. /**
  8632. * Get the layers currently being presented.
  8633. * @returns the list of VR layers
  8634. */
  8635. getLayers(): VRLayer[];
  8636. /**
  8637. * Return a VRPose containing the future predicted pose of the VRDisplay
  8638. * when the current frame will be presented. The value returned will not
  8639. * change until JavaScript has returned control to the browser.
  8640. *
  8641. * The VRPose will contain the position, orientation, velocity,
  8642. * and acceleration of each of these properties.
  8643. * @returns the pose object
  8644. */
  8645. getPose(): VRPose;
  8646. /**
  8647. * Return the current instantaneous pose of the VRDisplay, with no
  8648. * prediction applied.
  8649. * @returns the current instantaneous pose
  8650. */
  8651. getImmediatePose(): VRPose;
  8652. /**
  8653. * The callback passed to `requestAnimationFrame` will be called
  8654. * any time a new frame should be rendered. When the VRDisplay is
  8655. * presenting the callback will be called at the native refresh
  8656. * rate of the HMD. When not presenting this function acts
  8657. * identically to how window.requestAnimationFrame acts. Content should
  8658. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8659. * asynchronously from other displays and at differing refresh rates.
  8660. * @param callback Define the eaction to run next frame
  8661. * @returns the request handle it
  8662. */
  8663. requestAnimationFrame(callback: FrameRequestCallback): number;
  8664. /**
  8665. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8666. * Repeat calls while already presenting will update the VRLayers being displayed.
  8667. * @param layers Define the list of layer to present
  8668. * @returns a promise to know when the request has been fulfilled
  8669. */
  8670. requestPresent(layers: VRLayer[]): Promise<void>;
  8671. /**
  8672. * Reset the pose for this display, treating its current position and
  8673. * orientation as the "origin/zero" values. VRPose.position,
  8674. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8675. * updated when calling resetPose(). This should be called in only
  8676. * sitting-space experiences.
  8677. */
  8678. resetPose(): void;
  8679. /**
  8680. * The VRLayer provided to the VRDisplay will be captured and presented
  8681. * in the HMD. Calling this function has the same effect on the source
  8682. * canvas as any other operation that uses its source image, and canvases
  8683. * created without preserveDrawingBuffer set to true will be cleared.
  8684. * @param pose Define the pose to submit
  8685. */
  8686. submitFrame(pose?: VRPose): void;
  8687. }
  8688. declare var VRDisplay: {
  8689. prototype: VRDisplay;
  8690. new (): VRDisplay;
  8691. };
  8692. interface VRLayer {
  8693. leftBounds?: number[] | Float32Array | null;
  8694. rightBounds?: number[] | Float32Array | null;
  8695. source?: HTMLCanvasElement | null;
  8696. }
  8697. interface VRDisplayCapabilities {
  8698. readonly canPresent: boolean;
  8699. readonly hasExternalDisplay: boolean;
  8700. readonly hasOrientation: boolean;
  8701. readonly hasPosition: boolean;
  8702. readonly maxLayers: number;
  8703. }
  8704. interface VREyeParameters {
  8705. /** @deprecated */
  8706. readonly fieldOfView: VRFieldOfView;
  8707. readonly offset: Float32Array;
  8708. readonly renderHeight: number;
  8709. readonly renderWidth: number;
  8710. }
  8711. interface VRFieldOfView {
  8712. readonly downDegrees: number;
  8713. readonly leftDegrees: number;
  8714. readonly rightDegrees: number;
  8715. readonly upDegrees: number;
  8716. }
  8717. interface VRFrameData {
  8718. readonly leftProjectionMatrix: Float32Array;
  8719. readonly leftViewMatrix: Float32Array;
  8720. readonly pose: VRPose;
  8721. readonly rightProjectionMatrix: Float32Array;
  8722. readonly rightViewMatrix: Float32Array;
  8723. readonly timestamp: number;
  8724. }
  8725. interface VRPose {
  8726. readonly angularAcceleration: Float32Array | null;
  8727. readonly angularVelocity: Float32Array | null;
  8728. readonly linearAcceleration: Float32Array | null;
  8729. readonly linearVelocity: Float32Array | null;
  8730. readonly orientation: Float32Array | null;
  8731. readonly position: Float32Array | null;
  8732. readonly timestamp: number;
  8733. }
  8734. interface VRStageParameters {
  8735. sittingToStandingTransform?: Float32Array;
  8736. sizeX?: number;
  8737. sizeY?: number;
  8738. }
  8739. interface Navigator {
  8740. getVRDisplays(): Promise<VRDisplay[]>;
  8741. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8742. }
  8743. interface Window {
  8744. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8745. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8746. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8747. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8748. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8749. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8750. }
  8751. interface Gamepad {
  8752. readonly displayId: number;
  8753. }
  8754. declare module BABYLON {
  8755. /** @hidden */
  8756. class Collider {
  8757. /** Define if a collision was found */
  8758. collisionFound: boolean;
  8759. /**
  8760. * Define last intersection point in local space
  8761. */
  8762. intersectionPoint: Vector3;
  8763. /**
  8764. * Define last collided mesh
  8765. */
  8766. collidedMesh: Nullable<AbstractMesh>;
  8767. private _collisionPoint;
  8768. private _planeIntersectionPoint;
  8769. private _tempVector;
  8770. private _tempVector2;
  8771. private _tempVector3;
  8772. private _tempVector4;
  8773. private _edge;
  8774. private _baseToVertex;
  8775. private _destinationPoint;
  8776. private _slidePlaneNormal;
  8777. private _displacementVector;
  8778. /** @hidden */
  8779. _radius: Vector3;
  8780. /** @hidden */
  8781. _retry: number;
  8782. private _velocity;
  8783. private _basePoint;
  8784. private _epsilon;
  8785. /** @hidden */
  8786. _velocityWorldLength: number;
  8787. /** @hidden */
  8788. _basePointWorld: Vector3;
  8789. private _velocityWorld;
  8790. private _normalizedVelocity;
  8791. /** @hidden */
  8792. _initialVelocity: Vector3;
  8793. /** @hidden */
  8794. _initialPosition: Vector3;
  8795. private _nearestDistance;
  8796. private _collisionMask;
  8797. collisionMask: number;
  8798. /**
  8799. * Gets the plane normal used to compute the sliding response (in local space)
  8800. */
  8801. readonly slidePlaneNormal: Vector3;
  8802. /** @hidden */
  8803. _initialize(source: Vector3, dir: Vector3, e: number): void;
  8804. /** @hidden */
  8805. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  8806. /** @hidden */
  8807. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  8808. /** @hidden */
  8809. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  8810. /** @hidden */
  8811. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  8812. /** @hidden */
  8813. _getResponse(pos: Vector3, vel: Vector3): void;
  8814. }
  8815. }
  8816. declare module BABYLON {
  8817. /** @hidden */
  8818. var CollisionWorker: string;
  8819. /** @hidden */
  8820. interface ICollisionCoordinator {
  8821. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8822. init(scene: Scene): void;
  8823. destroy(): void;
  8824. onMeshAdded(mesh: AbstractMesh): void;
  8825. onMeshUpdated(mesh: AbstractMesh): void;
  8826. onMeshRemoved(mesh: AbstractMesh): void;
  8827. onGeometryAdded(geometry: Geometry): void;
  8828. onGeometryUpdated(geometry: Geometry): void;
  8829. onGeometryDeleted(geometry: Geometry): void;
  8830. }
  8831. /** @hidden */
  8832. interface SerializedMesh {
  8833. id: string;
  8834. name: string;
  8835. uniqueId: number;
  8836. geometryId: Nullable<string>;
  8837. sphereCenter: Array<number>;
  8838. sphereRadius: number;
  8839. boxMinimum: Array<number>;
  8840. boxMaximum: Array<number>;
  8841. worldMatrixFromCache: any;
  8842. subMeshes: Array<SerializedSubMesh>;
  8843. checkCollisions: boolean;
  8844. }
  8845. /** @hidden */
  8846. interface SerializedSubMesh {
  8847. position: number;
  8848. verticesStart: number;
  8849. verticesCount: number;
  8850. indexStart: number;
  8851. indexCount: number;
  8852. hasMaterial: boolean;
  8853. sphereCenter: Array<number>;
  8854. sphereRadius: number;
  8855. boxMinimum: Array<number>;
  8856. boxMaximum: Array<number>;
  8857. }
  8858. /**
  8859. * Interface describing the value associated with a geometry.
  8860. * @hidden
  8861. */
  8862. interface SerializedGeometry {
  8863. /**
  8864. * Defines the unique ID of the geometry
  8865. */
  8866. id: string;
  8867. /**
  8868. * Defines the array containing the positions
  8869. */
  8870. positions: Float32Array;
  8871. /**
  8872. * Defines the array containing the indices
  8873. */
  8874. indices: Uint32Array;
  8875. /**
  8876. * Defines the array containing the normals
  8877. */
  8878. normals: Float32Array;
  8879. }
  8880. /** @hidden */
  8881. interface BabylonMessage {
  8882. taskType: WorkerTaskType;
  8883. payload: InitPayload | CollidePayload | UpdatePayload;
  8884. }
  8885. /** @hidden */
  8886. interface SerializedColliderToWorker {
  8887. position: Array<number>;
  8888. velocity: Array<number>;
  8889. radius: Array<number>;
  8890. }
  8891. /** Defines supported task for worker process */
  8892. enum WorkerTaskType {
  8893. /** Initialization */
  8894. INIT = 0,
  8895. /** Update of geometry */
  8896. UPDATE = 1,
  8897. /** Evaluate collision */
  8898. COLLIDE = 2
  8899. }
  8900. /** @hidden */
  8901. interface WorkerReply {
  8902. error: WorkerReplyType;
  8903. taskType: WorkerTaskType;
  8904. payload?: any;
  8905. }
  8906. /** @hidden */
  8907. interface CollisionReplyPayload {
  8908. newPosition: Array<number>;
  8909. collisionId: number;
  8910. collidedMeshUniqueId: number;
  8911. }
  8912. /** @hidden */
  8913. interface InitPayload {
  8914. }
  8915. /** @hidden */
  8916. interface CollidePayload {
  8917. collisionId: number;
  8918. collider: SerializedColliderToWorker;
  8919. maximumRetry: number;
  8920. excludedMeshUniqueId: Nullable<number>;
  8921. }
  8922. /** @hidden */
  8923. interface UpdatePayload {
  8924. updatedMeshes: {
  8925. [n: number]: SerializedMesh;
  8926. };
  8927. updatedGeometries: {
  8928. [s: string]: SerializedGeometry;
  8929. };
  8930. removedMeshes: Array<number>;
  8931. removedGeometries: Array<string>;
  8932. }
  8933. /** Defines kind of replies returned by worker */
  8934. enum WorkerReplyType {
  8935. /** Success */
  8936. SUCCESS = 0,
  8937. /** Unkown error */
  8938. UNKNOWN_ERROR = 1
  8939. }
  8940. /** @hidden */
  8941. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  8942. private _scene;
  8943. private _scaledPosition;
  8944. private _scaledVelocity;
  8945. private _collisionsCallbackArray;
  8946. private _init;
  8947. private _runningUpdated;
  8948. private _worker;
  8949. private _addUpdateMeshesList;
  8950. private _addUpdateGeometriesList;
  8951. private _toRemoveMeshesArray;
  8952. private _toRemoveGeometryArray;
  8953. constructor();
  8954. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  8955. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  8956. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8957. init(scene: Scene): void;
  8958. destroy(): void;
  8959. onMeshAdded(mesh: AbstractMesh): void;
  8960. onMeshUpdated: (transformNode: TransformNode) => void;
  8961. onMeshRemoved(mesh: AbstractMesh): void;
  8962. onGeometryAdded(geometry: Geometry): void;
  8963. onGeometryUpdated: (geometry: Geometry) => void;
  8964. onGeometryDeleted(geometry: Geometry): void;
  8965. private _afterRender;
  8966. private _onMessageFromWorker;
  8967. }
  8968. /** @hidden */
  8969. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  8970. private _scene;
  8971. private _scaledPosition;
  8972. private _scaledVelocity;
  8973. private _finalPosition;
  8974. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8975. init(scene: Scene): void;
  8976. destroy(): void;
  8977. onMeshAdded(mesh: AbstractMesh): void;
  8978. onMeshUpdated(mesh: AbstractMesh): void;
  8979. onMeshRemoved(mesh: AbstractMesh): void;
  8980. onGeometryAdded(geometry: Geometry): void;
  8981. onGeometryUpdated(geometry: Geometry): void;
  8982. onGeometryDeleted(geometry: Geometry): void;
  8983. private _collideWithWorld;
  8984. }
  8985. }
  8986. declare function importScripts(...urls: string[]): void;
  8987. declare const safePostMessage: any;
  8988. declare module BABYLON {
  8989. /** @hidden */
  8990. var WorkerIncluded: boolean;
  8991. /** @hidden */
  8992. class CollisionCache {
  8993. private _meshes;
  8994. private _geometries;
  8995. getMeshes(): {
  8996. [n: number]: SerializedMesh;
  8997. };
  8998. getGeometries(): {
  8999. [s: number]: SerializedGeometry;
  9000. };
  9001. getMesh(id: any): SerializedMesh;
  9002. addMesh(mesh: SerializedMesh): void;
  9003. removeMesh(uniqueId: number): void;
  9004. getGeometry(id: string): SerializedGeometry;
  9005. addGeometry(geometry: SerializedGeometry): void;
  9006. removeGeometry(id: string): void;
  9007. }
  9008. /** @hidden */
  9009. class CollideWorker {
  9010. collider: Collider;
  9011. private _collisionCache;
  9012. private finalPosition;
  9013. private collisionsScalingMatrix;
  9014. private collisionTranformationMatrix;
  9015. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9016. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9017. private checkCollision;
  9018. private processCollisionsForSubMeshes;
  9019. private collideForSubMesh;
  9020. private checkSubmeshCollision;
  9021. }
  9022. /** @hidden */
  9023. interface ICollisionDetector {
  9024. onInit(payload: InitPayload): void;
  9025. onUpdate(payload: UpdatePayload): void;
  9026. onCollision(payload: CollidePayload): void;
  9027. }
  9028. /** @hidden */
  9029. class CollisionDetectorTransferable implements ICollisionDetector {
  9030. private _collisionCache;
  9031. onInit(payload: InitPayload): void;
  9032. onUpdate(payload: UpdatePayload): void;
  9033. onCollision(payload: CollidePayload): void;
  9034. }
  9035. }
  9036. declare module BABYLON {
  9037. /**
  9038. * @hidden
  9039. */
  9040. class IntersectionInfo {
  9041. bu: Nullable<number>;
  9042. bv: Nullable<number>;
  9043. distance: number;
  9044. faceId: number;
  9045. subMeshId: number;
  9046. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9047. }
  9048. /**
  9049. * Information about the result of picking within a scene
  9050. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9051. */
  9052. class PickingInfo {
  9053. /**
  9054. * If the pick collided with an object
  9055. */
  9056. hit: boolean;
  9057. /**
  9058. * Distance away where the pick collided
  9059. */
  9060. distance: number;
  9061. /**
  9062. * The location of pick collision
  9063. */
  9064. pickedPoint: Nullable<Vector3>;
  9065. /**
  9066. * The mesh corresponding the the pick collision
  9067. */
  9068. pickedMesh: Nullable<AbstractMesh>;
  9069. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9070. bu: number;
  9071. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9072. bv: number;
  9073. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  9074. faceId: number;
  9075. /** Id of the the submesh that was picked */
  9076. subMeshId: number;
  9077. /** If a sprite was picked, this will be the sprite the pick collided with */
  9078. pickedSprite: Nullable<Sprite>;
  9079. /**
  9080. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9081. */
  9082. originMesh: Nullable<AbstractMesh>;
  9083. /**
  9084. * The ray that was used to perform the picking.
  9085. */
  9086. ray: Nullable<Ray>;
  9087. /**
  9088. * Gets the normal correspodning to the face the pick collided with
  9089. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9090. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9091. * @returns The normal correspodning to the face the pick collided with
  9092. */
  9093. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9094. /**
  9095. * Gets the texture coordinates of where the pick occured
  9096. * @returns the vector containing the coordnates of the texture
  9097. */
  9098. getTextureCoordinates(): Nullable<Vector2>;
  9099. }
  9100. }
  9101. declare module BABYLON {
  9102. /**
  9103. * Class used to store bounding box information
  9104. */
  9105. class BoundingBox implements ICullable {
  9106. /**
  9107. * Gets the 8 vectors representing the bounding box in local space
  9108. */
  9109. readonly vectors: Vector3[];
  9110. /**
  9111. * Gets the center of the bounding box in local space
  9112. */
  9113. readonly center: Vector3;
  9114. /**
  9115. * Gets the center of the bounding box in world space
  9116. */
  9117. readonly centerWorld: Vector3;
  9118. /**
  9119. * Gets the extend size in local space
  9120. */
  9121. readonly extendSize: Vector3;
  9122. /**
  9123. * Gets the extend size in world space
  9124. */
  9125. readonly extendSizeWorld: Vector3;
  9126. /**
  9127. * Gets the OBB (object bounding box) directions
  9128. */
  9129. readonly directions: Vector3[];
  9130. /**
  9131. * Gets the 8 vectors representing the bounding box in world space
  9132. */
  9133. readonly vectorsWorld: Vector3[];
  9134. /**
  9135. * Gets the minimum vector in world space
  9136. */
  9137. readonly minimumWorld: Vector3;
  9138. /**
  9139. * Gets the maximum vector in world space
  9140. */
  9141. readonly maximumWorld: Vector3;
  9142. /**
  9143. * Gets the minimum vector in local space
  9144. */
  9145. readonly minimum: Vector3;
  9146. /**
  9147. * Gets the maximum vector in local space
  9148. */
  9149. readonly maximum: Vector3;
  9150. private _worldMatrix;
  9151. private static readonly TmpVector3;
  9152. /**
  9153. * @hidden
  9154. */
  9155. _tag: number;
  9156. /**
  9157. * Creates a new bounding box
  9158. * @param min defines the minimum vector (in local space)
  9159. * @param max defines the maximum vector (in local space)
  9160. * @param worldMatrix defines the new world matrix
  9161. */
  9162. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9163. /**
  9164. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9165. * @param min defines the new minimum vector (in local space)
  9166. * @param max defines the new maximum vector (in local space)
  9167. * @param worldMatrix defines the new world matrix
  9168. */
  9169. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9170. /**
  9171. * Scale the current bounding box by applying a scale factor
  9172. * @param factor defines the scale factor to apply
  9173. * @returns the current bounding box
  9174. */
  9175. scale(factor: number): BoundingBox;
  9176. /**
  9177. * Gets the world matrix of the bounding box
  9178. * @returns a matrix
  9179. */
  9180. getWorldMatrix(): DeepImmutable<Matrix>;
  9181. /** @hidden */
  9182. _update(world: DeepImmutable<Matrix>): void;
  9183. /**
  9184. * Tests if the bounding box is intersecting the frustum planes
  9185. * @param frustumPlanes defines the frustum planes to test
  9186. * @returns true if there is an intersection
  9187. */
  9188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9189. /**
  9190. * Tests if the bounding box is entirely inside the frustum planes
  9191. * @param frustumPlanes defines the frustum planes to test
  9192. * @returns true if there is an inclusion
  9193. */
  9194. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9195. /**
  9196. * Tests if a point is inside the bounding box
  9197. * @param point defines the point to test
  9198. * @returns true if the point is inside the bounding box
  9199. */
  9200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9201. /**
  9202. * Tests if the bounding box intersects with a bounding sphere
  9203. * @param sphere defines the sphere to test
  9204. * @returns true if there is an intersection
  9205. */
  9206. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  9207. /**
  9208. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9209. * @param min defines the min vector to use
  9210. * @param max defines the max vector to use
  9211. * @returns true if there is an intersection
  9212. */
  9213. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  9214. /**
  9215. * Tests if two bounding boxes are intersections
  9216. * @param box0 defines the first box to test
  9217. * @param box1 defines the second box to test
  9218. * @returns true if there is an intersection
  9219. */
  9220. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  9221. /**
  9222. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9223. * @param minPoint defines the minimum vector of the bounding box
  9224. * @param maxPoint defines the maximum vector of the bounding box
  9225. * @param sphereCenter defines the sphere center
  9226. * @param sphereRadius defines the sphere radius
  9227. * @returns true if there is an intersection
  9228. */
  9229. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  9230. /**
  9231. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9232. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9233. * @param frustumPlanes defines the frustum planes to test
  9234. * @return true if there is an inclusion
  9235. */
  9236. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9237. /**
  9238. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9239. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9240. * @param frustumPlanes defines the frustum planes to test
  9241. * @return true if there is an intersection
  9242. */
  9243. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9244. }
  9245. }
  9246. declare module BABYLON {
  9247. /**
  9248. * Interface for cullable objects
  9249. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9250. */
  9251. interface ICullable {
  9252. /**
  9253. * Checks if the object or part of the object is in the frustum
  9254. * @param frustumPlanes Camera near/planes
  9255. * @returns true if the object is in frustum otherwise false
  9256. */
  9257. isInFrustum(frustumPlanes: Plane[]): boolean;
  9258. /**
  9259. * Checks if a cullable object (mesh...) is in the camera frustum
  9260. * Unlike isInFrustum this cheks the full bounding box
  9261. * @param frustumPlanes Camera near/planes
  9262. * @returns true if the object is in frustum otherwise false
  9263. */
  9264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9265. }
  9266. /**
  9267. * Info for a bounding data of a mesh
  9268. */
  9269. class BoundingInfo implements ICullable {
  9270. /**
  9271. * Bounding box for the mesh
  9272. */
  9273. readonly boundingBox: BoundingBox;
  9274. /**
  9275. * Bounding sphere for the mesh
  9276. */
  9277. readonly boundingSphere: BoundingSphere;
  9278. private _isLocked;
  9279. private static readonly TmpVector3;
  9280. /**
  9281. * Constructs bounding info
  9282. * @param minimum min vector of the bounding box/sphere
  9283. * @param maximum max vector of the bounding box/sphere
  9284. * @param worldMatrix defines the new world matrix
  9285. */
  9286. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9287. /**
  9288. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9289. * @param min defines the new minimum vector (in local space)
  9290. * @param max defines the new maximum vector (in local space)
  9291. * @param worldMatrix defines the new world matrix
  9292. */
  9293. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9294. /**
  9295. * min vector of the bounding box/sphere
  9296. */
  9297. readonly minimum: Vector3;
  9298. /**
  9299. * max vector of the bounding box/sphere
  9300. */
  9301. readonly maximum: Vector3;
  9302. /**
  9303. * If the info is locked and won't be updated to avoid perf overhead
  9304. */
  9305. isLocked: boolean;
  9306. /**
  9307. * Updates the bounding sphere and box
  9308. * @param world world matrix to be used to update
  9309. */
  9310. update(world: DeepImmutable<Matrix>): void;
  9311. /**
  9312. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9313. * @param center New center of the bounding info
  9314. * @param extend New extend of the bounding info
  9315. * @returns the current bounding info
  9316. */
  9317. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  9318. /**
  9319. * Scale the current bounding info by applying a scale factor
  9320. * @param factor defines the scale factor to apply
  9321. * @returns the current bounding info
  9322. */
  9323. scale(factor: number): BoundingInfo;
  9324. /**
  9325. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9326. * @param frustumPlanes defines the frustum to test
  9327. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  9328. * @returns true if the bounding info is in the frustum planes
  9329. */
  9330. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  9331. /**
  9332. * Gets the world distance between the min and max points of the bounding box
  9333. */
  9334. readonly diagonalLength: number;
  9335. /**
  9336. * Checks if a cullable object (mesh...) is in the camera frustum
  9337. * Unlike isInFrustum this cheks the full bounding box
  9338. * @param frustumPlanes Camera near/planes
  9339. * @returns true if the object is in frustum otherwise false
  9340. */
  9341. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9342. /** @hidden */
  9343. _checkCollision(collider: Collider): boolean;
  9344. /**
  9345. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9346. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9347. * @param point the point to check intersection with
  9348. * @returns if the point intersects
  9349. */
  9350. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9351. /**
  9352. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9353. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9354. * @param boundingInfo the bounding info to check intersection with
  9355. * @param precise if the intersection should be done using OBB
  9356. * @returns if the bounding info intersects
  9357. */
  9358. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  9359. }
  9360. }
  9361. declare module BABYLON {
  9362. /**
  9363. * Class used to store bounding sphere information
  9364. */
  9365. class BoundingSphere {
  9366. /**
  9367. * Gets the center of the bounding sphere in local space
  9368. */
  9369. readonly center: Vector3;
  9370. /**
  9371. * Radius of the bounding sphere in local space
  9372. */
  9373. radius: number;
  9374. /**
  9375. * Gets the center of the bounding sphere in world space
  9376. */
  9377. readonly centerWorld: Vector3;
  9378. /**
  9379. * Radius of the bounding sphere in world space
  9380. */
  9381. radiusWorld: number;
  9382. /**
  9383. * Gets the minimum vector in local space
  9384. */
  9385. readonly minimum: Vector3;
  9386. /**
  9387. * Gets the maximum vector in local space
  9388. */
  9389. readonly maximum: Vector3;
  9390. private _worldMatrix;
  9391. private static readonly TmpVector3;
  9392. /**
  9393. * Creates a new bounding sphere
  9394. * @param min defines the minimum vector (in local space)
  9395. * @param max defines the maximum vector (in local space)
  9396. * @param worldMatrix defines the new world matrix
  9397. */
  9398. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9399. /**
  9400. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9401. * @param min defines the new minimum vector (in local space)
  9402. * @param max defines the new maximum vector (in local space)
  9403. * @param worldMatrix defines the new world matrix
  9404. */
  9405. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9406. /**
  9407. * Scale the current bounding sphere by applying a scale factor
  9408. * @param factor defines the scale factor to apply
  9409. * @returns the current bounding box
  9410. */
  9411. scale(factor: number): BoundingSphere;
  9412. /**
  9413. * Gets the world matrix of the bounding box
  9414. * @returns a matrix
  9415. */
  9416. getWorldMatrix(): DeepImmutable<Matrix>;
  9417. /** @hidden */
  9418. _update(worldMatrix: DeepImmutable<Matrix>): void;
  9419. /**
  9420. * Tests if the bounding sphere is intersecting the frustum planes
  9421. * @param frustumPlanes defines the frustum planes to test
  9422. * @returns true if there is an intersection
  9423. */
  9424. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9425. /**
  9426. * Tests if the bounding sphere center is in between the frustum planes.
  9427. * Used for optimistic fast inclusion.
  9428. * @param frustumPlanes defines the frustum planes to test
  9429. * @returns true if the sphere center is in between the frustum planes
  9430. */
  9431. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9432. /**
  9433. * Tests if a point is inside the bounding sphere
  9434. * @param point defines the point to test
  9435. * @returns true if the point is inside the bounding sphere
  9436. */
  9437. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9438. /**
  9439. * Checks if two sphere intersct
  9440. * @param sphere0 sphere 0
  9441. * @param sphere1 sphere 1
  9442. * @returns true if the speres intersect
  9443. */
  9444. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  9445. }
  9446. }
  9447. declare module BABYLON {
  9448. /**
  9449. * Class representing a ray with position and direction
  9450. */
  9451. class Ray {
  9452. /** origin point */
  9453. origin: Vector3;
  9454. /** direction */
  9455. direction: Vector3;
  9456. /** length of the ray */
  9457. length: number;
  9458. private static readonly TmpVector3;
  9459. private _tmpRay;
  9460. /**
  9461. * Creates a new ray
  9462. * @param origin origin point
  9463. * @param direction direction
  9464. * @param length length of the ray
  9465. */
  9466. constructor(
  9467. /** origin point */
  9468. origin: Vector3,
  9469. /** direction */
  9470. direction: Vector3,
  9471. /** length of the ray */
  9472. length?: number);
  9473. /**
  9474. * Checks if the ray intersects a box
  9475. * @param minimum bound of the box
  9476. * @param maximum bound of the box
  9477. * @param intersectionTreshold extra extend to be added to the box in all direction
  9478. * @returns if the box was hit
  9479. */
  9480. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9481. /**
  9482. * Checks if the ray intersects a box
  9483. * @param box the bounding box to check
  9484. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9485. * @returns if the box was hit
  9486. */
  9487. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9488. /**
  9489. * If the ray hits a sphere
  9490. * @param sphere the bounding sphere to check
  9491. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9492. * @returns true if it hits the sphere
  9493. */
  9494. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9495. /**
  9496. * If the ray hits a triange
  9497. * @param vertex0 triangle vertex
  9498. * @param vertex1 triangle vertex
  9499. * @param vertex2 triangle vertex
  9500. * @returns intersection information if hit
  9501. */
  9502. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9503. /**
  9504. * Checks if ray intersects a plane
  9505. * @param plane the plane to check
  9506. * @returns the distance away it was hit
  9507. */
  9508. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9509. /**
  9510. * Checks if ray intersects a mesh
  9511. * @param mesh the mesh to check
  9512. * @param fastCheck if only the bounding box should checked
  9513. * @returns picking info of the intersecton
  9514. */
  9515. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9516. /**
  9517. * Checks if ray intersects a mesh
  9518. * @param meshes the meshes to check
  9519. * @param fastCheck if only the bounding box should checked
  9520. * @param results array to store result in
  9521. * @returns Array of picking infos
  9522. */
  9523. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9524. private _comparePickingInfo;
  9525. private static smallnum;
  9526. private static rayl;
  9527. /**
  9528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9529. * @param sega the first point of the segment to test the intersection against
  9530. * @param segb the second point of the segment to test the intersection against
  9531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9533. */
  9534. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9535. /**
  9536. * Update the ray from viewport position
  9537. * @param x position
  9538. * @param y y position
  9539. * @param viewportWidth viewport width
  9540. * @param viewportHeight viewport height
  9541. * @param world world matrix
  9542. * @param view view matrix
  9543. * @param projection projection matrix
  9544. * @returns this ray updated
  9545. */
  9546. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9547. /**
  9548. * Creates a ray with origin and direction of 0,0,0
  9549. * @returns the new ray
  9550. */
  9551. static Zero(): Ray;
  9552. /**
  9553. * Creates a new ray from screen space and viewport
  9554. * @param x position
  9555. * @param y y position
  9556. * @param viewportWidth viewport width
  9557. * @param viewportHeight viewport height
  9558. * @param world world matrix
  9559. * @param view view matrix
  9560. * @param projection projection matrix
  9561. * @returns new ray
  9562. */
  9563. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9564. /**
  9565. * 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
  9566. * transformed to the given world matrix.
  9567. * @param origin The origin point
  9568. * @param end The end point
  9569. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9570. * @returns the new ray
  9571. */
  9572. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9573. /**
  9574. * Transforms a ray by a matrix
  9575. * @param ray ray to transform
  9576. * @param matrix matrix to apply
  9577. * @returns the resulting new ray
  9578. */
  9579. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9580. /**
  9581. * Transforms a ray by a matrix
  9582. * @param ray ray to transform
  9583. * @param matrix matrix to apply
  9584. * @param result ray to store result in
  9585. */
  9586. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9587. }
  9588. }
  9589. /**
  9590. * Module Debug contains the (visual) components to debug a scene correctly
  9591. */
  9592. declare module BABYLON.Debug {
  9593. /**
  9594. * The Axes viewer will show 3 axes in a specific point in space
  9595. */
  9596. class AxesViewer {
  9597. private _xAxis;
  9598. private _yAxis;
  9599. private _zAxis;
  9600. private _scaleLinesFactor;
  9601. private _instanced;
  9602. /**
  9603. * Gets the hosting scene
  9604. */
  9605. scene: Scene;
  9606. /**
  9607. * Gets or sets a number used to scale line length
  9608. */
  9609. scaleLines: number;
  9610. /** Gets the node hierarchy used to render x-axis */
  9611. readonly xAxis: TransformNode;
  9612. /** Gets the node hierarchy used to render y-axis */
  9613. readonly yAxis: TransformNode;
  9614. /** Gets the node hierarchy used to render z-axis */
  9615. readonly zAxis: TransformNode;
  9616. /**
  9617. * Creates a new AxesViewer
  9618. * @param scene defines the hosting scene
  9619. * @param scaleLines defines a number used to scale line length (1 by default)
  9620. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  9621. * @param xAxis defines the node hierarchy used to render the x-axis
  9622. * @param yAxis defines the node hierarchy used to render the y-axis
  9623. * @param zAxis defines the node hierarchy used to render the z-axis
  9624. */
  9625. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  9626. /**
  9627. * Force the viewer to update
  9628. * @param position defines the position of the viewer
  9629. * @param xaxis defines the x axis of the viewer
  9630. * @param yaxis defines the y axis of the viewer
  9631. * @param zaxis defines the z axis of the viewer
  9632. */
  9633. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9634. /**
  9635. * Creates an instance of this axes viewer.
  9636. * @returns a new axes viewer with instanced meshes
  9637. */
  9638. createInstance(): AxesViewer;
  9639. /** Releases resources */
  9640. dispose(): void;
  9641. private static _SetRenderingGroupId;
  9642. }
  9643. }
  9644. declare module BABYLON.Debug {
  9645. /**
  9646. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9647. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9648. */
  9649. class BoneAxesViewer extends AxesViewer {
  9650. /**
  9651. * Gets or sets the target mesh where to display the axes viewer
  9652. */
  9653. mesh: Nullable<Mesh>;
  9654. /**
  9655. * Gets or sets the target bone where to display the axes viewer
  9656. */
  9657. bone: Nullable<Bone>;
  9658. /** Gets current position */
  9659. pos: Vector3;
  9660. /** Gets direction of X axis */
  9661. xaxis: Vector3;
  9662. /** Gets direction of Y axis */
  9663. yaxis: Vector3;
  9664. /** Gets direction of Z axis */
  9665. zaxis: Vector3;
  9666. /**
  9667. * Creates a new BoneAxesViewer
  9668. * @param scene defines the hosting scene
  9669. * @param bone defines the target bone
  9670. * @param mesh defines the target mesh
  9671. * @param scaleLines defines a scaling factor for line length (1 by default)
  9672. */
  9673. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9674. /**
  9675. * Force the viewer to update
  9676. */
  9677. update(): void;
  9678. /** Releases resources */
  9679. dispose(): void;
  9680. }
  9681. }
  9682. declare module BABYLON {
  9683. /**
  9684. * Interface used to define scene explorer extensibility option
  9685. */
  9686. interface IExplorerExtensibilityOption {
  9687. /**
  9688. * Define the option label
  9689. */
  9690. label: string;
  9691. /**
  9692. * Defines the action to execute on click
  9693. */
  9694. action: (entity: any) => void;
  9695. }
  9696. /**
  9697. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9698. */
  9699. interface IExplorerExtensibilityGroup {
  9700. /**
  9701. * Defines a predicate to test if a given type mut be extended
  9702. */
  9703. predicate: (entity: any) => boolean;
  9704. /**
  9705. * Gets the list of options added to a type
  9706. */
  9707. entries: IExplorerExtensibilityOption[];
  9708. }
  9709. /**
  9710. * Interface used to define the options to use to create the Inspector
  9711. */
  9712. interface IInspectorOptions {
  9713. /**
  9714. * Display in overlay mode (default: false)
  9715. */
  9716. overlay?: boolean;
  9717. /**
  9718. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9719. */
  9720. globalRoot?: HTMLElement;
  9721. /**
  9722. * Display the Scene explorer
  9723. */
  9724. showExplorer?: boolean;
  9725. /**
  9726. * Display the property inspector
  9727. */
  9728. showInspector?: boolean;
  9729. /**
  9730. * Display in embed mode (both panes on the right)
  9731. */
  9732. embedMode?: boolean;
  9733. /**
  9734. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9735. */
  9736. handleResize?: boolean;
  9737. /**
  9738. * Allow the panes to popup (default: true)
  9739. */
  9740. enablePopup?: boolean;
  9741. /**
  9742. * Allow the panes to be closed by users (default: true)
  9743. */
  9744. enableClose?: boolean;
  9745. /**
  9746. * Optional list of extensibility entries
  9747. */
  9748. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9749. }
  9750. interface Scene {
  9751. /**
  9752. * @hidden
  9753. * Backing field
  9754. */
  9755. _debugLayer: DebugLayer;
  9756. /**
  9757. * Gets the debug layer (aka Inspector) associated with the scene
  9758. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9759. */
  9760. debugLayer: DebugLayer;
  9761. }
  9762. /**
  9763. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9764. * what is happening in your scene
  9765. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9766. */
  9767. class DebugLayer {
  9768. /**
  9769. * Define the url to get the inspector script from.
  9770. * By default it uses the babylonjs CDN.
  9771. * @ignoreNaming
  9772. */
  9773. static InspectorURL: string;
  9774. private _scene;
  9775. private BJSINSPECTOR;
  9776. /**
  9777. * Observable triggered when a property is changed through the inspector.
  9778. */
  9779. onPropertyChangedObservable: Observable<{
  9780. object: any;
  9781. property: string;
  9782. value: any;
  9783. initialValue: any;
  9784. }>;
  9785. /**
  9786. * Instantiates a new debug layer.
  9787. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9788. * what is happening in your scene
  9789. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9790. * @param scene Defines the scene to inspect
  9791. */
  9792. constructor(scene: Scene);
  9793. /** Creates the inspector window. */
  9794. private _createInspector;
  9795. /** Get the inspector from bundle or global */
  9796. private _getGlobalInspector;
  9797. /**
  9798. * Get if the inspector is visible or not.
  9799. * @returns true if visible otherwise, false
  9800. */
  9801. isVisible(): boolean;
  9802. /**
  9803. * Hide the inspector and close its window.
  9804. */
  9805. hide(): void;
  9806. /**
  9807. * Launch the debugLayer.
  9808. * @param config Define the configuration of the inspector
  9809. */
  9810. show(config?: IInspectorOptions): void;
  9811. }
  9812. }
  9813. declare module BABYLON.Debug {
  9814. /**
  9815. * Used to show the physics impostor around the specific mesh
  9816. */
  9817. class PhysicsViewer {
  9818. /** @hidden */
  9819. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9820. /** @hidden */
  9821. protected _meshes: Array<Nullable<AbstractMesh>>;
  9822. /** @hidden */
  9823. protected _scene: Nullable<Scene>;
  9824. /** @hidden */
  9825. protected _numMeshes: number;
  9826. /** @hidden */
  9827. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9828. private _renderFunction;
  9829. private _utilityLayer;
  9830. private _debugBoxMesh;
  9831. private _debugSphereMesh;
  9832. private _debugMaterial;
  9833. /**
  9834. * Creates a new PhysicsViewer
  9835. * @param scene defines the hosting scene
  9836. */
  9837. constructor(scene: Scene);
  9838. /** @hidden */
  9839. protected _updateDebugMeshes(): void;
  9840. /**
  9841. * Renders a specified physic impostor
  9842. * @param impostor defines the impostor to render
  9843. * @returns the new debug mesh used to render the impostor
  9844. */
  9845. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9846. /**
  9847. * Hides a specified physic impostor
  9848. * @param impostor defines the impostor to hide
  9849. */
  9850. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9851. private _getDebugMaterial;
  9852. private _getDebugBoxMesh;
  9853. private _getDebugSphereMesh;
  9854. private _getDebugMesh;
  9855. /** Releases all resources */
  9856. dispose(): void;
  9857. }
  9858. }
  9859. declare module BABYLON {
  9860. /**
  9861. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9862. * in order to better appreciate the issue one might have.
  9863. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9864. */
  9865. class RayHelper {
  9866. /**
  9867. * Defines the ray we are currently tryin to visualize.
  9868. */
  9869. ray: Nullable<Ray>;
  9870. private _renderPoints;
  9871. private _renderLine;
  9872. private _renderFunction;
  9873. private _scene;
  9874. private _updateToMeshFunction;
  9875. private _attachedToMesh;
  9876. private _meshSpaceDirection;
  9877. private _meshSpaceOrigin;
  9878. /**
  9879. * Helper function to create a colored helper in a scene in one line.
  9880. * @param ray Defines the ray we are currently tryin to visualize
  9881. * @param scene Defines the scene the ray is used in
  9882. * @param color Defines the color we want to see the ray in
  9883. * @returns The newly created ray helper.
  9884. */
  9885. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9886. /**
  9887. * Instantiate a new ray helper.
  9888. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9889. * in order to better appreciate the issue one might have.
  9890. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9891. * @param ray Defines the ray we are currently tryin to visualize
  9892. */
  9893. constructor(ray: Ray);
  9894. /**
  9895. * Shows the ray we are willing to debug.
  9896. * @param scene Defines the scene the ray needs to be rendered in
  9897. * @param color Defines the color the ray needs to be rendered in
  9898. */
  9899. show(scene: Scene, color?: Color3): void;
  9900. /**
  9901. * Hides the ray we are debugging.
  9902. */
  9903. hide(): void;
  9904. private _render;
  9905. /**
  9906. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9907. * @param mesh Defines the mesh we want the helper attached to
  9908. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9909. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9910. * @param length Defines the length of the ray
  9911. */
  9912. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9913. /**
  9914. * Detach the ray helper from the mesh it has previously been attached to.
  9915. */
  9916. detachFromMesh(): void;
  9917. private _updateToMesh;
  9918. /**
  9919. * Dispose the helper and release its associated resources.
  9920. */
  9921. dispose(): void;
  9922. }
  9923. }
  9924. declare module BABYLON.Debug {
  9925. /**
  9926. * Class used to render a debug view of a given skeleton
  9927. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9928. */
  9929. class SkeletonViewer {
  9930. /** defines the skeleton to render */
  9931. skeleton: Skeleton;
  9932. /** defines the mesh attached to the skeleton */
  9933. mesh: AbstractMesh;
  9934. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9935. autoUpdateBonesMatrices: boolean;
  9936. /** defines the rendering group id to use with the viewer */
  9937. renderingGroupId: number;
  9938. /** Gets or sets the color used to render the skeleton */
  9939. color: Color3;
  9940. private _scene;
  9941. private _debugLines;
  9942. private _debugMesh;
  9943. private _isEnabled;
  9944. private _renderFunction;
  9945. private _utilityLayer;
  9946. /**
  9947. * Returns the mesh used to render the bones
  9948. */
  9949. readonly debugMesh: Nullable<LinesMesh>;
  9950. /**
  9951. * Creates a new SkeletonViewer
  9952. * @param skeleton defines the skeleton to render
  9953. * @param mesh defines the mesh attached to the skeleton
  9954. * @param scene defines the hosting scene
  9955. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9956. * @param renderingGroupId defines the rendering group id to use with the viewer
  9957. */
  9958. constructor(
  9959. /** defines the skeleton to render */
  9960. skeleton: Skeleton,
  9961. /** defines the mesh attached to the skeleton */
  9962. mesh: AbstractMesh, scene: Scene,
  9963. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9964. autoUpdateBonesMatrices?: boolean,
  9965. /** defines the rendering group id to use with the viewer */
  9966. renderingGroupId?: number);
  9967. /** Gets or sets a boolean indicating if the viewer is enabled */
  9968. isEnabled: boolean;
  9969. private _getBonePosition;
  9970. private _getLinesForBonesWithLength;
  9971. private _getLinesForBonesNoLength;
  9972. /** Update the viewer to sync with current skeleton state */
  9973. update(): void;
  9974. /** Release associated resources */
  9975. dispose(): void;
  9976. }
  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. * Single axis drag gizmo
  13152. */
  13153. class AxisDragGizmo extends Gizmo {
  13154. /**
  13155. * Drag behavior responsible for the gizmos dragging interactions
  13156. */
  13157. dragBehavior: PointerDragBehavior;
  13158. private _pointerObserver;
  13159. /**
  13160. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13161. */
  13162. snapDistance: number;
  13163. /**
  13164. * Event that fires each time the gizmo snaps to a new location.
  13165. * * snapDistance is the the change in distance
  13166. */
  13167. onSnapObservable: Observable<{
  13168. snapDistance: number;
  13169. }>;
  13170. /** @hidden */
  13171. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13172. /** @hidden */
  13173. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13174. /**
  13175. * Creates an AxisDragGizmo
  13176. * @param gizmoLayer The utility layer the gizmo will be added to
  13177. * @param dragAxis The axis which the gizmo will be able to drag on
  13178. * @param color The color of the gizmo
  13179. */
  13180. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13181. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13182. /**
  13183. * Disposes of the gizmo
  13184. */
  13185. dispose(): void;
  13186. }
  13187. }
  13188. declare module BABYLON {
  13189. /**
  13190. * Single axis scale gizmo
  13191. */
  13192. class AxisScaleGizmo extends Gizmo {
  13193. private _coloredMaterial;
  13194. /**
  13195. * Drag behavior responsible for the gizmos dragging interactions
  13196. */
  13197. dragBehavior: PointerDragBehavior;
  13198. private _pointerObserver;
  13199. /**
  13200. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13201. */
  13202. snapDistance: number;
  13203. /**
  13204. * Event that fires each time the gizmo snaps to a new location.
  13205. * * snapDistance is the the change in distance
  13206. */
  13207. onSnapObservable: Observable<{
  13208. snapDistance: number;
  13209. }>;
  13210. /**
  13211. * If the scaling operation should be done on all axis (default: false)
  13212. */
  13213. uniformScaling: boolean;
  13214. /**
  13215. * Creates an AxisScaleGizmo
  13216. * @param gizmoLayer The utility layer the gizmo will be added to
  13217. * @param dragAxis The axis which the gizmo will be able to scale on
  13218. * @param color The color of the gizmo
  13219. */
  13220. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13221. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13222. /**
  13223. * Disposes of the gizmo
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13228. * @param mesh The mesh to replace the default mesh of the gizmo
  13229. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13230. */
  13231. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13232. }
  13233. }
  13234. declare module BABYLON {
  13235. /**
  13236. * Bounding box gizmo
  13237. */
  13238. class BoundingBoxGizmo extends Gizmo {
  13239. private _lineBoundingBox;
  13240. private _rotateSpheresParent;
  13241. private _scaleBoxesParent;
  13242. private _boundingDimensions;
  13243. private _renderObserver;
  13244. private _pointerObserver;
  13245. private _scaleDragSpeed;
  13246. private _tmpQuaternion;
  13247. private _tmpVector;
  13248. private _tmpRotationMatrix;
  13249. /**
  13250. * 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)
  13251. */
  13252. ignoreChildren: boolean;
  13253. /**
  13254. * 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)
  13255. */
  13256. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13257. /**
  13258. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13259. */
  13260. rotationSphereSize: number;
  13261. /**
  13262. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13263. */
  13264. scaleBoxSize: number;
  13265. /**
  13266. * 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)
  13267. */
  13268. fixedDragMeshScreenSize: boolean;
  13269. /**
  13270. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13271. */
  13272. fixedDragMeshScreenSizeDistanceFactor: number;
  13273. /**
  13274. * Fired when a rotation sphere or scale box is dragged
  13275. */
  13276. onDragStartObservable: Observable<{}>;
  13277. /**
  13278. * Fired when a scale box is dragged
  13279. */
  13280. onScaleBoxDragObservable: Observable<{}>;
  13281. /**
  13282. * Fired when a scale box drag is ended
  13283. */
  13284. onScaleBoxDragEndObservable: Observable<{}>;
  13285. /**
  13286. * Fired when a rotation sphere is dragged
  13287. */
  13288. onRotationSphereDragObservable: Observable<{}>;
  13289. /**
  13290. * Fired when a rotation sphere drag is ended
  13291. */
  13292. onRotationSphereDragEndObservable: Observable<{}>;
  13293. /**
  13294. * 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)
  13295. */
  13296. scalePivot: Nullable<Vector3>;
  13297. private _anchorMesh;
  13298. private _existingMeshScale;
  13299. private _dragMesh;
  13300. private pointerDragBehavior;
  13301. private static _PivotCached;
  13302. private static _OldPivotPoint;
  13303. private static _PivotTranslation;
  13304. private static _PivotTmpVector;
  13305. /** @hidden */
  13306. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13307. /** @hidden */
  13308. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13309. /**
  13310. * Creates an BoundingBoxGizmo
  13311. * @param gizmoLayer The utility layer the gizmo will be added to
  13312. * @param color The color of the gizmo
  13313. */
  13314. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13315. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13316. private _selectNode;
  13317. /**
  13318. * Updates the bounding box information for the Gizmo
  13319. */
  13320. updateBoundingBox(): void;
  13321. private _updateRotationSpheres;
  13322. private _updateScaleBoxes;
  13323. /**
  13324. * Enables rotation on the specified axis and disables rotation on the others
  13325. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13326. */
  13327. setEnabledRotationAxis(axis: string): void;
  13328. private _updateDummy;
  13329. /**
  13330. * Enables a pointer drag behavior on the bounding box of the gizmo
  13331. */
  13332. enableDragBehavior(): void;
  13333. /**
  13334. * Disposes of the gizmo
  13335. */
  13336. dispose(): void;
  13337. /**
  13338. * 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)
  13339. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13340. * @returns the bounding box mesh with the passed in mesh as a child
  13341. */
  13342. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13343. /**
  13344. * CustomMeshes are not supported by this gizmo
  13345. * @param mesh The mesh to replace the default mesh of the gizmo
  13346. */
  13347. setCustomMesh(mesh: Mesh): void;
  13348. }
  13349. }
  13350. declare module BABYLON {
  13351. /**
  13352. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13353. */
  13354. class Gizmo implements IDisposable {
  13355. /** The utility layer the gizmo will be added to */
  13356. gizmoLayer: UtilityLayerRenderer;
  13357. /**
  13358. * The root mesh of the gizmo
  13359. */
  13360. protected _rootMesh: Mesh;
  13361. private _attachedMesh;
  13362. /**
  13363. * Ratio for the scale of the gizmo (Default: 1)
  13364. */
  13365. scaleRatio: number;
  13366. private _tmpMatrix;
  13367. /**
  13368. * If a custom mesh has been set (Default: false)
  13369. */
  13370. protected _customMeshSet: boolean;
  13371. /**
  13372. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13373. * * When set, interactions will be enabled
  13374. */
  13375. attachedMesh: Nullable<AbstractMesh>;
  13376. /**
  13377. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13378. * @param mesh The mesh to replace the default mesh of the gizmo
  13379. */
  13380. setCustomMesh(mesh: Mesh): void;
  13381. /**
  13382. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13383. */
  13384. updateGizmoRotationToMatchAttachedMesh: boolean;
  13385. /**
  13386. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13387. */
  13388. updateGizmoPositionToMatchAttachedMesh: boolean;
  13389. /**
  13390. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13391. */
  13392. protected _updateScale: boolean;
  13393. protected _interactionsEnabled: boolean;
  13394. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13395. private _beforeRenderObserver;
  13396. /**
  13397. * Creates a gizmo
  13398. * @param gizmoLayer The utility layer the gizmo will be added to
  13399. */
  13400. constructor(
  13401. /** The utility layer the gizmo will be added to */
  13402. gizmoLayer?: UtilityLayerRenderer);
  13403. private _tempVector;
  13404. /**
  13405. * @hidden
  13406. * Updates the gizmo to match the attached mesh's position/rotation
  13407. */
  13408. protected _update(): void;
  13409. /**
  13410. * Disposes of the gizmo
  13411. */
  13412. dispose(): void;
  13413. }
  13414. }
  13415. declare module BABYLON {
  13416. /**
  13417. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13418. */
  13419. class GizmoManager implements IDisposable {
  13420. private scene;
  13421. /**
  13422. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13423. */
  13424. gizmos: {
  13425. positionGizmo: Nullable<PositionGizmo>;
  13426. rotationGizmo: Nullable<RotationGizmo>;
  13427. scaleGizmo: Nullable<ScaleGizmo>;
  13428. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13429. };
  13430. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13431. clearGizmoOnEmptyPointerEvent: boolean;
  13432. /** Fires an event when the manager is attached to a mesh */
  13433. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13434. private _gizmosEnabled;
  13435. private _pointerObserver;
  13436. private _attachedMesh;
  13437. private _boundingBoxColor;
  13438. private _defaultUtilityLayer;
  13439. private _defaultKeepDepthUtilityLayer;
  13440. /**
  13441. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13442. */
  13443. boundingBoxDragBehavior: SixDofDragBehavior;
  13444. /**
  13445. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13446. */
  13447. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13448. /**
  13449. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13450. */
  13451. usePointerToAttachGizmos: boolean;
  13452. /**
  13453. * Instatiates a gizmo manager
  13454. * @param scene the scene to overlay the gizmos on top of
  13455. */
  13456. constructor(scene: Scene);
  13457. /**
  13458. * Attaches a set of gizmos to the specified mesh
  13459. * @param mesh The mesh the gizmo's should be attached to
  13460. */
  13461. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13462. /**
  13463. * If the position gizmo is enabled
  13464. */
  13465. positionGizmoEnabled: boolean;
  13466. /**
  13467. * If the rotation gizmo is enabled
  13468. */
  13469. rotationGizmoEnabled: boolean;
  13470. /**
  13471. * If the scale gizmo is enabled
  13472. */
  13473. scaleGizmoEnabled: boolean;
  13474. /**
  13475. * If the boundingBox gizmo is enabled
  13476. */
  13477. boundingBoxGizmoEnabled: boolean;
  13478. /**
  13479. * Disposes of the gizmo manager
  13480. */
  13481. dispose(): void;
  13482. }
  13483. }
  13484. declare module BABYLON {
  13485. /**
  13486. * Single plane rotation gizmo
  13487. */
  13488. class PlaneRotationGizmo extends Gizmo {
  13489. /**
  13490. * Drag behavior responsible for the gizmos dragging interactions
  13491. */
  13492. dragBehavior: PointerDragBehavior;
  13493. private _pointerObserver;
  13494. /**
  13495. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13496. */
  13497. snapDistance: number;
  13498. /**
  13499. * Event that fires each time the gizmo snaps to a new location.
  13500. * * snapDistance is the the change in distance
  13501. */
  13502. onSnapObservable: Observable<{
  13503. snapDistance: number;
  13504. }>;
  13505. /**
  13506. * Creates a PlaneRotationGizmo
  13507. * @param gizmoLayer The utility layer the gizmo will be added to
  13508. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13509. * @param color The color of the gizmo
  13510. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13511. */
  13512. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13514. /**
  13515. * Disposes of the gizmo
  13516. */
  13517. dispose(): void;
  13518. }
  13519. }
  13520. declare module BABYLON {
  13521. /**
  13522. * Gizmo that enables dragging a mesh along 3 axis
  13523. */
  13524. class PositionGizmo extends Gizmo {
  13525. /**
  13526. * Internal gizmo used for interactions on the x axis
  13527. */
  13528. xGizmo: AxisDragGizmo;
  13529. /**
  13530. * Internal gizmo used for interactions on the y axis
  13531. */
  13532. yGizmo: AxisDragGizmo;
  13533. /**
  13534. * Internal gizmo used for interactions on the z axis
  13535. */
  13536. zGizmo: AxisDragGizmo;
  13537. /** Fires an event when any of it's sub gizmos are dragged */
  13538. onDragStartObservable: Observable<{}>;
  13539. /** Fires an event when any of it's sub gizmos are released from dragging */
  13540. onDragEndObservable: Observable<{}>;
  13541. attachedMesh: Nullable<AbstractMesh>;
  13542. /**
  13543. * Creates a PositionGizmo
  13544. * @param gizmoLayer The utility layer the gizmo will be added to
  13545. */
  13546. constructor(gizmoLayer?: UtilityLayerRenderer);
  13547. updateGizmoRotationToMatchAttachedMesh: boolean;
  13548. /**
  13549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13550. */
  13551. snapDistance: number;
  13552. /**
  13553. * Ratio for the scale of the gizmo (Default: 1)
  13554. */
  13555. scaleRatio: number;
  13556. /**
  13557. * Disposes of the gizmo
  13558. */
  13559. dispose(): void;
  13560. /**
  13561. * CustomMeshes are not supported by this gizmo
  13562. * @param mesh The mesh to replace the default mesh of the gizmo
  13563. */
  13564. setCustomMesh(mesh: Mesh): void;
  13565. }
  13566. }
  13567. declare module BABYLON {
  13568. /**
  13569. * Gizmo that enables rotating a mesh along 3 axis
  13570. */
  13571. class RotationGizmo extends Gizmo {
  13572. /**
  13573. * Internal gizmo used for interactions on the x axis
  13574. */
  13575. xGizmo: PlaneRotationGizmo;
  13576. /**
  13577. * Internal gizmo used for interactions on the y axis
  13578. */
  13579. yGizmo: PlaneRotationGizmo;
  13580. /**
  13581. * Internal gizmo used for interactions on the z axis
  13582. */
  13583. zGizmo: PlaneRotationGizmo;
  13584. /** Fires an event when any of it's sub gizmos are dragged */
  13585. onDragStartObservable: Observable<{}>;
  13586. /** Fires an event when any of it's sub gizmos are released from dragging */
  13587. onDragEndObservable: Observable<{}>;
  13588. attachedMesh: Nullable<AbstractMesh>;
  13589. /**
  13590. * Creates a RotationGizmo
  13591. * @param gizmoLayer The utility layer the gizmo will be added to
  13592. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13593. */
  13594. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13595. updateGizmoRotationToMatchAttachedMesh: boolean;
  13596. /**
  13597. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13598. */
  13599. snapDistance: number;
  13600. /**
  13601. * Ratio for the scale of the gizmo (Default: 1)
  13602. */
  13603. scaleRatio: number;
  13604. /**
  13605. * Disposes of the gizmo
  13606. */
  13607. dispose(): void;
  13608. /**
  13609. * CustomMeshes are not supported by this gizmo
  13610. * @param mesh The mesh to replace the default mesh of the gizmo
  13611. */
  13612. setCustomMesh(mesh: Mesh): void;
  13613. }
  13614. }
  13615. declare module BABYLON {
  13616. /**
  13617. * Gizmo that enables scaling a mesh along 3 axis
  13618. */
  13619. class ScaleGizmo extends Gizmo {
  13620. /**
  13621. * Internal gizmo used for interactions on the x axis
  13622. */
  13623. xGizmo: AxisScaleGizmo;
  13624. /**
  13625. * Internal gizmo used for interactions on the y axis
  13626. */
  13627. yGizmo: AxisScaleGizmo;
  13628. /**
  13629. * Internal gizmo used for interactions on the z axis
  13630. */
  13631. zGizmo: AxisScaleGizmo;
  13632. /**
  13633. * Internal gizmo used to scale all axis equally
  13634. */
  13635. uniformScaleGizmo: AxisScaleGizmo;
  13636. /** Fires an event when any of it's sub gizmos are dragged */
  13637. onDragStartObservable: Observable<{}>;
  13638. /** Fires an event when any of it's sub gizmos are released from dragging */
  13639. onDragEndObservable: Observable<{}>;
  13640. attachedMesh: Nullable<AbstractMesh>;
  13641. /**
  13642. * Creates a ScaleGizmo
  13643. * @param gizmoLayer The utility layer the gizmo will be added to
  13644. */
  13645. constructor(gizmoLayer?: UtilityLayerRenderer);
  13646. updateGizmoRotationToMatchAttachedMesh: boolean;
  13647. /**
  13648. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13649. */
  13650. snapDistance: number;
  13651. /**
  13652. * Ratio for the scale of the gizmo (Default: 1)
  13653. */
  13654. scaleRatio: number;
  13655. /**
  13656. * Disposes of the gizmo
  13657. */
  13658. dispose(): void;
  13659. }
  13660. }
  13661. declare module BABYLON {
  13662. /**
  13663. * Represents the different options available during the creation of
  13664. * a Environment helper.
  13665. *
  13666. * This can control the default ground, skybox and image processing setup of your scene.
  13667. */
  13668. interface IEnvironmentHelperOptions {
  13669. /**
  13670. * Specifies wether or not to create a ground.
  13671. * True by default.
  13672. */
  13673. createGround: boolean;
  13674. /**
  13675. * Specifies the ground size.
  13676. * 15 by default.
  13677. */
  13678. groundSize: number;
  13679. /**
  13680. * The texture used on the ground for the main color.
  13681. * Comes from the BabylonJS CDN by default.
  13682. *
  13683. * Remarks: Can be either a texture or a url.
  13684. */
  13685. groundTexture: string | BaseTexture;
  13686. /**
  13687. * The color mixed in the ground texture by default.
  13688. * BabylonJS clearColor by default.
  13689. */
  13690. groundColor: Color3;
  13691. /**
  13692. * Specifies the ground opacity.
  13693. * 1 by default.
  13694. */
  13695. groundOpacity: number;
  13696. /**
  13697. * Enables the ground to receive shadows.
  13698. * True by default.
  13699. */
  13700. enableGroundShadow: boolean;
  13701. /**
  13702. * Helps preventing the shadow to be fully black on the ground.
  13703. * 0.5 by default.
  13704. */
  13705. groundShadowLevel: number;
  13706. /**
  13707. * Creates a mirror texture attach to the ground.
  13708. * false by default.
  13709. */
  13710. enableGroundMirror: boolean;
  13711. /**
  13712. * Specifies the ground mirror size ratio.
  13713. * 0.3 by default as the default kernel is 64.
  13714. */
  13715. groundMirrorSizeRatio: number;
  13716. /**
  13717. * Specifies the ground mirror blur kernel size.
  13718. * 64 by default.
  13719. */
  13720. groundMirrorBlurKernel: number;
  13721. /**
  13722. * Specifies the ground mirror visibility amount.
  13723. * 1 by default
  13724. */
  13725. groundMirrorAmount: number;
  13726. /**
  13727. * Specifies the ground mirror reflectance weight.
  13728. * This uses the standard weight of the background material to setup the fresnel effect
  13729. * of the mirror.
  13730. * 1 by default.
  13731. */
  13732. groundMirrorFresnelWeight: number;
  13733. /**
  13734. * Specifies the ground mirror Falloff distance.
  13735. * This can helps reducing the size of the reflection.
  13736. * 0 by Default.
  13737. */
  13738. groundMirrorFallOffDistance: number;
  13739. /**
  13740. * Specifies the ground mirror texture type.
  13741. * Unsigned Int by Default.
  13742. */
  13743. groundMirrorTextureType: number;
  13744. /**
  13745. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13746. * the shown objects.
  13747. */
  13748. groundYBias: number;
  13749. /**
  13750. * Specifies wether or not to create a skybox.
  13751. * True by default.
  13752. */
  13753. createSkybox: boolean;
  13754. /**
  13755. * Specifies the skybox size.
  13756. * 20 by default.
  13757. */
  13758. skyboxSize: number;
  13759. /**
  13760. * The texture used on the skybox for the main color.
  13761. * Comes from the BabylonJS CDN by default.
  13762. *
  13763. * Remarks: Can be either a texture or a url.
  13764. */
  13765. skyboxTexture: string | BaseTexture;
  13766. /**
  13767. * The color mixed in the skybox texture by default.
  13768. * BabylonJS clearColor by default.
  13769. */
  13770. skyboxColor: Color3;
  13771. /**
  13772. * The background rotation around the Y axis of the scene.
  13773. * This helps aligning the key lights of your scene with the background.
  13774. * 0 by default.
  13775. */
  13776. backgroundYRotation: number;
  13777. /**
  13778. * Compute automatically the size of the elements to best fit with the scene.
  13779. */
  13780. sizeAuto: boolean;
  13781. /**
  13782. * Default position of the rootMesh if autoSize is not true.
  13783. */
  13784. rootPosition: Vector3;
  13785. /**
  13786. * Sets up the image processing in the scene.
  13787. * true by default.
  13788. */
  13789. setupImageProcessing: boolean;
  13790. /**
  13791. * The texture used as your environment texture in the scene.
  13792. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13793. *
  13794. * Remarks: Can be either a texture or a url.
  13795. */
  13796. environmentTexture: string | BaseTexture;
  13797. /**
  13798. * The value of the exposure to apply to the scene.
  13799. * 0.6 by default if setupImageProcessing is true.
  13800. */
  13801. cameraExposure: number;
  13802. /**
  13803. * The value of the contrast to apply to the scene.
  13804. * 1.6 by default if setupImageProcessing is true.
  13805. */
  13806. cameraContrast: number;
  13807. /**
  13808. * Specifies wether or not tonemapping should be enabled in the scene.
  13809. * true by default if setupImageProcessing is true.
  13810. */
  13811. toneMappingEnabled: boolean;
  13812. }
  13813. /**
  13814. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13815. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13816. * It also helps with the default setup of your imageProcessing configuration.
  13817. */
  13818. class EnvironmentHelper {
  13819. /**
  13820. * Default ground texture URL.
  13821. */
  13822. private static _groundTextureCDNUrl;
  13823. /**
  13824. * Default skybox texture URL.
  13825. */
  13826. private static _skyboxTextureCDNUrl;
  13827. /**
  13828. * Default environment texture URL.
  13829. */
  13830. private static _environmentTextureCDNUrl;
  13831. /**
  13832. * Creates the default options for the helper.
  13833. */
  13834. private static _getDefaultOptions;
  13835. private _rootMesh;
  13836. /**
  13837. * Gets the root mesh created by the helper.
  13838. */
  13839. readonly rootMesh: Mesh;
  13840. private _skybox;
  13841. /**
  13842. * Gets the skybox created by the helper.
  13843. */
  13844. readonly skybox: Nullable<Mesh>;
  13845. private _skyboxTexture;
  13846. /**
  13847. * Gets the skybox texture created by the helper.
  13848. */
  13849. readonly skyboxTexture: Nullable<BaseTexture>;
  13850. private _skyboxMaterial;
  13851. /**
  13852. * Gets the skybox material created by the helper.
  13853. */
  13854. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13855. private _ground;
  13856. /**
  13857. * Gets the ground mesh created by the helper.
  13858. */
  13859. readonly ground: Nullable<Mesh>;
  13860. private _groundTexture;
  13861. /**
  13862. * Gets the ground texture created by the helper.
  13863. */
  13864. readonly groundTexture: Nullable<BaseTexture>;
  13865. private _groundMirror;
  13866. /**
  13867. * Gets the ground mirror created by the helper.
  13868. */
  13869. readonly groundMirror: Nullable<MirrorTexture>;
  13870. /**
  13871. * Gets the ground mirror render list to helps pushing the meshes
  13872. * you wish in the ground reflection.
  13873. */
  13874. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13875. private _groundMaterial;
  13876. /**
  13877. * Gets the ground material created by the helper.
  13878. */
  13879. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13880. /**
  13881. * Stores the creation options.
  13882. */
  13883. private readonly _scene;
  13884. private _options;
  13885. /**
  13886. * This observable will be notified with any error during the creation of the environment,
  13887. * mainly texture creation errors.
  13888. */
  13889. onErrorObservable: Observable<{
  13890. message?: string;
  13891. exception?: any;
  13892. }>;
  13893. /**
  13894. * constructor
  13895. * @param options
  13896. * @param scene The scene to add the material to
  13897. */
  13898. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13899. /**
  13900. * Updates the background according to the new options
  13901. * @param options
  13902. */
  13903. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13904. /**
  13905. * Sets the primary color of all the available elements.
  13906. * @param color the main color to affect to the ground and the background
  13907. */
  13908. setMainColor(color: Color3): void;
  13909. /**
  13910. * Setup the image processing according to the specified options.
  13911. */
  13912. private _setupImageProcessing;
  13913. /**
  13914. * Setup the environment texture according to the specified options.
  13915. */
  13916. private _setupEnvironmentTexture;
  13917. /**
  13918. * Setup the background according to the specified options.
  13919. */
  13920. private _setupBackground;
  13921. /**
  13922. * Get the scene sizes according to the setup.
  13923. */
  13924. private _getSceneSize;
  13925. /**
  13926. * Setup the ground according to the specified options.
  13927. */
  13928. private _setupGround;
  13929. /**
  13930. * Setup the ground material according to the specified options.
  13931. */
  13932. private _setupGroundMaterial;
  13933. /**
  13934. * Setup the ground diffuse texture according to the specified options.
  13935. */
  13936. private _setupGroundDiffuseTexture;
  13937. /**
  13938. * Setup the ground mirror texture according to the specified options.
  13939. */
  13940. private _setupGroundMirrorTexture;
  13941. /**
  13942. * Setup the ground to receive the mirror texture.
  13943. */
  13944. private _setupMirrorInGroundMaterial;
  13945. /**
  13946. * Setup the skybox according to the specified options.
  13947. */
  13948. private _setupSkybox;
  13949. /**
  13950. * Setup the skybox material according to the specified options.
  13951. */
  13952. private _setupSkyboxMaterial;
  13953. /**
  13954. * Setup the skybox reflection texture according to the specified options.
  13955. */
  13956. private _setupSkyboxReflectionTexture;
  13957. private _errorHandler;
  13958. /**
  13959. * Dispose all the elements created by the Helper.
  13960. */
  13961. dispose(): void;
  13962. }
  13963. }
  13964. declare module BABYLON {
  13965. /**
  13966. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13967. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13968. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13969. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13970. */
  13971. class PhotoDome extends TransformNode {
  13972. private _useDirectMapping;
  13973. /**
  13974. * The texture being displayed on the sphere
  13975. */
  13976. protected _photoTexture: Texture;
  13977. /**
  13978. * Gets or sets the texture being displayed on the sphere
  13979. */
  13980. photoTexture: Texture;
  13981. /**
  13982. * Observable raised when an error occured while loading the 360 image
  13983. */
  13984. onLoadErrorObservable: Observable<string>;
  13985. /**
  13986. * The skybox material
  13987. */
  13988. protected _material: BackgroundMaterial;
  13989. /**
  13990. * The surface used for the skybox
  13991. */
  13992. protected _mesh: Mesh;
  13993. /**
  13994. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13995. * Also see the options.resolution property.
  13996. */
  13997. fovMultiplier: number;
  13998. /**
  13999. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  14000. * @param name Element's name, child elements will append suffixes for their own names.
  14001. * @param urlsOfPhoto defines the url of the photo to display
  14002. * @param options defines an object containing optional or exposed sub element properties
  14003. * @param onError defines a callback called when an error occured while loading the texture
  14004. */
  14005. constructor(name: string, urlOfPhoto: string, options: {
  14006. resolution?: number;
  14007. size?: number;
  14008. useDirectMapping?: boolean;
  14009. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  14010. /**
  14011. * Releases resources associated with this node.
  14012. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14013. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14014. */
  14015. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14016. }
  14017. }
  14018. declare module BABYLON {
  14019. interface Scene {
  14020. /**
  14021. * Creates a default light for the scene.
  14022. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  14023. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  14024. */
  14025. createDefaultLight(replace?: boolean): void;
  14026. /**
  14027. * Creates a default camera for the scene.
  14028. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  14029. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14030. * @param replace has default false, when true replaces the active camera in the scene
  14031. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  14032. */
  14033. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14034. /**
  14035. * Creates a default camera and a default light.
  14036. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  14037. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14038. * @param replace has the default false, when true replaces the active camera/light in the scene
  14039. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  14040. */
  14041. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14042. /**
  14043. * Creates a new sky box
  14044. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  14045. * @param environmentTexture defines the texture to use as environment texture
  14046. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  14047. * @param scale defines the overall scale of the skybox
  14048. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14049. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14050. * @returns a new mesh holding the sky box
  14051. */
  14052. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14053. /**
  14054. * Creates a new environment
  14055. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14056. * @param options defines the options you can use to configure the environment
  14057. * @returns the new EnvironmentHelper
  14058. */
  14059. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14060. /**
  14061. * Creates a new VREXperienceHelper
  14062. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14063. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14064. * @returns a new VREXperienceHelper
  14065. */
  14066. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14067. /**
  14068. * Creates a new XREXperienceHelper
  14069. * @see http://doc.babylonjs.com/how_to/webxr
  14070. * @returns a promise for a new XREXperienceHelper
  14071. */
  14072. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14073. }
  14074. }
  14075. declare module BABYLON {
  14076. /**
  14077. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14078. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14079. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14080. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14081. */
  14082. class VideoDome extends TransformNode {
  14083. private _useDirectMapping;
  14084. /**
  14085. * The video texture being displayed on the sphere
  14086. */
  14087. protected _videoTexture: VideoTexture;
  14088. /**
  14089. * Gets the video texture being displayed on the sphere
  14090. */
  14091. readonly videoTexture: VideoTexture;
  14092. /**
  14093. * The skybox material
  14094. */
  14095. protected _material: BackgroundMaterial;
  14096. /**
  14097. * The surface used for the skybox
  14098. */
  14099. protected _mesh: Mesh;
  14100. /**
  14101. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14102. * Also see the options.resolution property.
  14103. */
  14104. fovMultiplier: number;
  14105. /**
  14106. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14107. * @param name Element's name, child elements will append suffixes for their own names.
  14108. * @param urlsOrVideo defines the url(s) or the video element to use
  14109. * @param options An object containing optional or exposed sub element properties
  14110. */
  14111. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14112. resolution?: number;
  14113. clickToPlay?: boolean;
  14114. autoPlay?: boolean;
  14115. loop?: boolean;
  14116. size?: number;
  14117. poster?: string;
  14118. useDirectMapping?: boolean;
  14119. }, scene: Scene);
  14120. /**
  14121. * Releases resources associated with this node.
  14122. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14123. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14124. */
  14125. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14126. }
  14127. }
  14128. declare module BABYLON {
  14129. /**
  14130. * This class can be used to get instrumentation data from a Babylon engine
  14131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14132. */
  14133. class EngineInstrumentation implements IDisposable {
  14134. /**
  14135. * Define the instrumented engine.
  14136. */
  14137. engine: Engine;
  14138. private _captureGPUFrameTime;
  14139. private _gpuFrameTimeToken;
  14140. private _gpuFrameTime;
  14141. private _captureShaderCompilationTime;
  14142. private _shaderCompilationTime;
  14143. private _onBeginFrameObserver;
  14144. private _onEndFrameObserver;
  14145. private _onBeforeShaderCompilationObserver;
  14146. private _onAfterShaderCompilationObserver;
  14147. /**
  14148. * Gets the perf counter used for GPU frame time
  14149. */
  14150. readonly gpuFrameTimeCounter: PerfCounter;
  14151. /**
  14152. * Gets the GPU frame time capture status
  14153. */
  14154. /**
  14155. * Enable or disable the GPU frame time capture
  14156. */
  14157. captureGPUFrameTime: boolean;
  14158. /**
  14159. * Gets the perf counter used for shader compilation time
  14160. */
  14161. readonly shaderCompilationTimeCounter: PerfCounter;
  14162. /**
  14163. * Gets the shader compilation time capture status
  14164. */
  14165. /**
  14166. * Enable or disable the shader compilation time capture
  14167. */
  14168. captureShaderCompilationTime: boolean;
  14169. /**
  14170. * Instantiates a new engine instrumentation.
  14171. * This class can be used to get instrumentation data from a Babylon engine
  14172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14173. * @param engine Defines the engine to instrument
  14174. */
  14175. constructor(
  14176. /**
  14177. * Define the instrumented engine.
  14178. */
  14179. engine: Engine);
  14180. /**
  14181. * Dispose and release associated resources.
  14182. */
  14183. dispose(): void;
  14184. }
  14185. }
  14186. declare module BABYLON {
  14187. /**
  14188. * This class can be used to get instrumentation data from a Babylon engine
  14189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14190. */
  14191. class SceneInstrumentation implements IDisposable {
  14192. /**
  14193. * Defines the scene to instrument
  14194. */
  14195. scene: Scene;
  14196. private _captureActiveMeshesEvaluationTime;
  14197. private _activeMeshesEvaluationTime;
  14198. private _captureRenderTargetsRenderTime;
  14199. private _renderTargetsRenderTime;
  14200. private _captureFrameTime;
  14201. private _frameTime;
  14202. private _captureRenderTime;
  14203. private _renderTime;
  14204. private _captureInterFrameTime;
  14205. private _interFrameTime;
  14206. private _captureParticlesRenderTime;
  14207. private _particlesRenderTime;
  14208. private _captureSpritesRenderTime;
  14209. private _spritesRenderTime;
  14210. private _capturePhysicsTime;
  14211. private _physicsTime;
  14212. private _captureAnimationsTime;
  14213. private _animationsTime;
  14214. private _captureCameraRenderTime;
  14215. private _cameraRenderTime;
  14216. private _onBeforeActiveMeshesEvaluationObserver;
  14217. private _onAfterActiveMeshesEvaluationObserver;
  14218. private _onBeforeRenderTargetsRenderObserver;
  14219. private _onAfterRenderTargetsRenderObserver;
  14220. private _onAfterRenderObserver;
  14221. private _onBeforeDrawPhaseObserver;
  14222. private _onAfterDrawPhaseObserver;
  14223. private _onBeforeAnimationsObserver;
  14224. private _onBeforeParticlesRenderingObserver;
  14225. private _onAfterParticlesRenderingObserver;
  14226. private _onBeforeSpritesRenderingObserver;
  14227. private _onAfterSpritesRenderingObserver;
  14228. private _onBeforePhysicsObserver;
  14229. private _onAfterPhysicsObserver;
  14230. private _onAfterAnimationsObserver;
  14231. private _onBeforeCameraRenderObserver;
  14232. private _onAfterCameraRenderObserver;
  14233. /**
  14234. * Gets the perf counter used for active meshes evaluation time
  14235. */
  14236. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14237. /**
  14238. * Gets the active meshes evaluation time capture status
  14239. */
  14240. /**
  14241. * Enable or disable the active meshes evaluation time capture
  14242. */
  14243. captureActiveMeshesEvaluationTime: boolean;
  14244. /**
  14245. * Gets the perf counter used for render targets render time
  14246. */
  14247. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14248. /**
  14249. * Gets the render targets render time capture status
  14250. */
  14251. /**
  14252. * Enable or disable the render targets render time capture
  14253. */
  14254. captureRenderTargetsRenderTime: boolean;
  14255. /**
  14256. * Gets the perf counter used for particles render time
  14257. */
  14258. readonly particlesRenderTimeCounter: PerfCounter;
  14259. /**
  14260. * Gets the particles render time capture status
  14261. */
  14262. /**
  14263. * Enable or disable the particles render time capture
  14264. */
  14265. captureParticlesRenderTime: boolean;
  14266. /**
  14267. * Gets the perf counter used for sprites render time
  14268. */
  14269. readonly spritesRenderTimeCounter: PerfCounter;
  14270. /**
  14271. * Gets the sprites render time capture status
  14272. */
  14273. /**
  14274. * Enable or disable the sprites render time capture
  14275. */
  14276. captureSpritesRenderTime: boolean;
  14277. /**
  14278. * Gets the perf counter used for physics time
  14279. */
  14280. readonly physicsTimeCounter: PerfCounter;
  14281. /**
  14282. * Gets the physics time capture status
  14283. */
  14284. /**
  14285. * Enable or disable the physics time capture
  14286. */
  14287. capturePhysicsTime: boolean;
  14288. /**
  14289. * Gets the perf counter used for animations time
  14290. */
  14291. readonly animationsTimeCounter: PerfCounter;
  14292. /**
  14293. * Gets the animations time capture status
  14294. */
  14295. /**
  14296. * Enable or disable the animations time capture
  14297. */
  14298. captureAnimationsTime: boolean;
  14299. /**
  14300. * Gets the perf counter used for frame time capture
  14301. */
  14302. readonly frameTimeCounter: PerfCounter;
  14303. /**
  14304. * Gets the frame time capture status
  14305. */
  14306. /**
  14307. * Enable or disable the frame time capture
  14308. */
  14309. captureFrameTime: boolean;
  14310. /**
  14311. * Gets the perf counter used for inter-frames time capture
  14312. */
  14313. readonly interFrameTimeCounter: PerfCounter;
  14314. /**
  14315. * Gets the inter-frames time capture status
  14316. */
  14317. /**
  14318. * Enable or disable the inter-frames time capture
  14319. */
  14320. captureInterFrameTime: boolean;
  14321. /**
  14322. * Gets the perf counter used for render time capture
  14323. */
  14324. readonly renderTimeCounter: PerfCounter;
  14325. /**
  14326. * Gets the render time capture status
  14327. */
  14328. /**
  14329. * Enable or disable the render time capture
  14330. */
  14331. captureRenderTime: boolean;
  14332. /**
  14333. * Gets the perf counter used for camera render time capture
  14334. */
  14335. readonly cameraRenderTimeCounter: PerfCounter;
  14336. /**
  14337. * Gets the camera render time capture status
  14338. */
  14339. /**
  14340. * Enable or disable the camera render time capture
  14341. */
  14342. captureCameraRenderTime: boolean;
  14343. /**
  14344. * Gets the perf counter used for draw calls
  14345. */
  14346. readonly drawCallsCounter: PerfCounter;
  14347. /**
  14348. * Gets the perf counter used for texture collisions
  14349. */
  14350. readonly textureCollisionsCounter: PerfCounter;
  14351. /**
  14352. * Instantiates a new scene instrumentation.
  14353. * This class can be used to get instrumentation data from a Babylon engine
  14354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14355. * @param scene Defines the scene to instrument
  14356. */
  14357. constructor(
  14358. /**
  14359. * Defines the scene to instrument
  14360. */
  14361. scene: Scene);
  14362. /**
  14363. * Dispose and release associated resources.
  14364. */
  14365. dispose(): void;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. /**
  14370. * @hidden
  14371. **/
  14372. class _TimeToken {
  14373. _startTimeQuery: Nullable<WebGLQuery>;
  14374. _endTimeQuery: Nullable<WebGLQuery>;
  14375. _timeElapsedQuery: Nullable<WebGLQuery>;
  14376. _timeElapsedQueryEnded: boolean;
  14377. }
  14378. }
  14379. declare module BABYLON {
  14380. /**
  14381. * Effect layer options. This helps customizing the behaviour
  14382. * of the effect layer.
  14383. */
  14384. interface IEffectLayerOptions {
  14385. /**
  14386. * Multiplication factor apply to the canvas size to compute the render target size
  14387. * used to generated the objects (the smaller the faster).
  14388. */
  14389. mainTextureRatio: number;
  14390. /**
  14391. * Enforces a fixed size texture to ensure effect stability across devices.
  14392. */
  14393. mainTextureFixedSize?: number;
  14394. /**
  14395. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14396. */
  14397. alphaBlendingMode: number;
  14398. /**
  14399. * The camera attached to the layer.
  14400. */
  14401. camera: Nullable<Camera>;
  14402. /**
  14403. * The rendering group to draw the layer in.
  14404. */
  14405. renderingGroupId: number;
  14406. }
  14407. /**
  14408. * The effect layer Helps adding post process effect blended with the main pass.
  14409. *
  14410. * This can be for instance use to generate glow or higlight effects on the scene.
  14411. *
  14412. * The effect layer class can not be used directly and is intented to inherited from to be
  14413. * customized per effects.
  14414. */
  14415. abstract class EffectLayer {
  14416. private _vertexBuffers;
  14417. private _indexBuffer;
  14418. private _cachedDefines;
  14419. private _effectLayerMapGenerationEffect;
  14420. private _effectLayerOptions;
  14421. private _mergeEffect;
  14422. protected _scene: Scene;
  14423. protected _engine: Engine;
  14424. protected _maxSize: number;
  14425. protected _mainTextureDesiredSize: ISize;
  14426. protected _mainTexture: RenderTargetTexture;
  14427. protected _shouldRender: boolean;
  14428. protected _postProcesses: PostProcess[];
  14429. protected _textures: BaseTexture[];
  14430. protected _emissiveTextureAndColor: {
  14431. texture: Nullable<BaseTexture>;
  14432. color: Color4;
  14433. };
  14434. /**
  14435. * The name of the layer
  14436. */
  14437. name: string;
  14438. /**
  14439. * The clear color of the texture used to generate the glow map.
  14440. */
  14441. neutralColor: Color4;
  14442. /**
  14443. * Specifies wether the highlight layer is enabled or not.
  14444. */
  14445. isEnabled: boolean;
  14446. /**
  14447. * Gets the camera attached to the layer.
  14448. */
  14449. readonly camera: Nullable<Camera>;
  14450. /**
  14451. * Gets the rendering group id the layer should render in.
  14452. */
  14453. readonly renderingGroupId: number;
  14454. /**
  14455. * An event triggered when the effect layer has been disposed.
  14456. */
  14457. onDisposeObservable: Observable<EffectLayer>;
  14458. /**
  14459. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14460. */
  14461. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14462. /**
  14463. * An event triggered when the generated texture is being merged in the scene.
  14464. */
  14465. onBeforeComposeObservable: Observable<EffectLayer>;
  14466. /**
  14467. * An event triggered when the generated texture has been merged in the scene.
  14468. */
  14469. onAfterComposeObservable: Observable<EffectLayer>;
  14470. /**
  14471. * An event triggered when the efffect layer changes its size.
  14472. */
  14473. onSizeChangedObservable: Observable<EffectLayer>;
  14474. /**
  14475. * Instantiates a new effect Layer and references it in the scene.
  14476. * @param name The name of the layer
  14477. * @param scene The scene to use the layer in
  14478. */
  14479. constructor(
  14480. /** The Friendly of the effect in the scene */
  14481. name: string, scene: Scene);
  14482. /**
  14483. * Get the effect name of the layer.
  14484. * @return The effect name
  14485. */
  14486. abstract getEffectName(): string;
  14487. /**
  14488. * Checks for the readiness of the element composing the layer.
  14489. * @param subMesh the mesh to check for
  14490. * @param useInstances specify wether or not to use instances to render the mesh
  14491. * @return true if ready otherwise, false
  14492. */
  14493. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14494. /**
  14495. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14496. * @returns true if the effect requires stencil during the main canvas render pass.
  14497. */
  14498. abstract needStencil(): boolean;
  14499. /**
  14500. * Create the merge effect. This is the shader use to blit the information back
  14501. * to the main canvas at the end of the scene rendering.
  14502. * @returns The effect containing the shader used to merge the effect on the main canvas
  14503. */
  14504. protected abstract _createMergeEffect(): Effect;
  14505. /**
  14506. * Creates the render target textures and post processes used in the effect layer.
  14507. */
  14508. protected abstract _createTextureAndPostProcesses(): void;
  14509. /**
  14510. * Implementation specific of rendering the generating effect on the main canvas.
  14511. * @param effect The effect used to render through
  14512. */
  14513. protected abstract _internalRender(effect: Effect): void;
  14514. /**
  14515. * Sets the required values for both the emissive texture and and the main color.
  14516. */
  14517. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14518. /**
  14519. * Free any resources and references associated to a mesh.
  14520. * Internal use
  14521. * @param mesh The mesh to free.
  14522. */
  14523. abstract _disposeMesh(mesh: Mesh): void;
  14524. /**
  14525. * Serializes this layer (Glow or Highlight for example)
  14526. * @returns a serialized layer object
  14527. */
  14528. abstract serialize?(): any;
  14529. /**
  14530. * Initializes the effect layer with the required options.
  14531. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14532. */
  14533. protected _init(options: Partial<IEffectLayerOptions>): void;
  14534. /**
  14535. * Generates the index buffer of the full screen quad blending to the main canvas.
  14536. */
  14537. private _generateIndexBuffer;
  14538. /**
  14539. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14540. */
  14541. private _genrateVertexBuffer;
  14542. /**
  14543. * Sets the main texture desired size which is the closest power of two
  14544. * of the engine canvas size.
  14545. */
  14546. private _setMainTextureSize;
  14547. /**
  14548. * Creates the main texture for the effect layer.
  14549. */
  14550. protected _createMainTexture(): void;
  14551. /**
  14552. * Checks for the readiness of the element composing the layer.
  14553. * @param subMesh the mesh to check for
  14554. * @param useInstances specify wether or not to use instances to render the mesh
  14555. * @param emissiveTexture the associated emissive texture used to generate the glow
  14556. * @return true if ready otherwise, false
  14557. */
  14558. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14559. /**
  14560. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14561. */
  14562. render(): void;
  14563. /**
  14564. * Determine if a given mesh will be used in the current effect.
  14565. * @param mesh mesh to test
  14566. * @returns true if the mesh will be used
  14567. */
  14568. hasMesh(mesh: AbstractMesh): boolean;
  14569. /**
  14570. * Returns true if the layer contains information to display, otherwise false.
  14571. * @returns true if the glow layer should be rendered
  14572. */
  14573. shouldRender(): boolean;
  14574. /**
  14575. * Returns true if the mesh should render, otherwise false.
  14576. * @param mesh The mesh to render
  14577. * @returns true if it should render otherwise false
  14578. */
  14579. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14580. /**
  14581. * Returns true if the mesh should render, otherwise false.
  14582. * @param mesh The mesh to render
  14583. * @returns true if it should render otherwise false
  14584. */
  14585. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14586. /**
  14587. * Renders the submesh passed in parameter to the generation map.
  14588. */
  14589. protected _renderSubMesh(subMesh: SubMesh): void;
  14590. /**
  14591. * Rebuild the required buffers.
  14592. * @hidden Internal use only.
  14593. */
  14594. _rebuild(): void;
  14595. /**
  14596. * Dispose only the render target textures and post process.
  14597. */
  14598. private _disposeTextureAndPostProcesses;
  14599. /**
  14600. * Dispose the highlight layer and free resources.
  14601. */
  14602. dispose(): void;
  14603. /**
  14604. * Gets the class name of the effect layer
  14605. * @returns the string with the class name of the effect layer
  14606. */
  14607. getClassName(): string;
  14608. /**
  14609. * Creates an effect layer from parsed effect layer data
  14610. * @param parsedEffectLayer defines effect layer data
  14611. * @param scene defines the current scene
  14612. * @param rootUrl defines the root URL containing the effect layer information
  14613. * @returns a parsed effect Layer
  14614. */
  14615. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14616. }
  14617. }
  14618. declare module BABYLON {
  14619. interface AbstractScene {
  14620. /**
  14621. * The list of effect layers (highlights/glow) added to the scene
  14622. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14623. * @see http://doc.babylonjs.com/how_to/glow_layer
  14624. */
  14625. effectLayers: Array<EffectLayer>;
  14626. /**
  14627. * Removes the given effect layer from this scene.
  14628. * @param toRemove defines the effect layer to remove
  14629. * @returns the index of the removed effect layer
  14630. */
  14631. removeEffectLayer(toRemove: EffectLayer): number;
  14632. /**
  14633. * Adds the given effect layer to this scene
  14634. * @param newEffectLayer defines the effect layer to add
  14635. */
  14636. addEffectLayer(newEffectLayer: EffectLayer): void;
  14637. }
  14638. /**
  14639. * Defines the layer scene component responsible to manage any effect layers
  14640. * in a given scene.
  14641. */
  14642. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14643. /**
  14644. * The component name helpfull to identify the component in the list of scene components.
  14645. */
  14646. readonly name: string;
  14647. /**
  14648. * The scene the component belongs to.
  14649. */
  14650. scene: Scene;
  14651. private _engine;
  14652. private _renderEffects;
  14653. private _needStencil;
  14654. private _previousStencilState;
  14655. /**
  14656. * Creates a new instance of the component for the given scene
  14657. * @param scene Defines the scene to register the component in
  14658. */
  14659. constructor(scene: Scene);
  14660. /**
  14661. * Registers the component in a given scene
  14662. */
  14663. register(): void;
  14664. /**
  14665. * Rebuilds the elements related to this component in case of
  14666. * context lost for instance.
  14667. */
  14668. rebuild(): void;
  14669. /**
  14670. * Serializes the component data to the specified json object
  14671. * @param serializationObject The object to serialize to
  14672. */
  14673. serialize(serializationObject: any): void;
  14674. /**
  14675. * Adds all the element from the container to the scene
  14676. * @param container the container holding the elements
  14677. */
  14678. addFromContainer(container: AbstractScene): void;
  14679. /**
  14680. * Removes all the elements in the container from the scene
  14681. * @param container contains the elements to remove
  14682. */
  14683. removeFromContainer(container: AbstractScene): void;
  14684. /**
  14685. * Disposes the component and the associated ressources.
  14686. */
  14687. dispose(): void;
  14688. private _isReadyForMesh;
  14689. private _renderMainTexture;
  14690. private _setStencil;
  14691. private _setStencilBack;
  14692. private _draw;
  14693. private _drawCamera;
  14694. private _drawRenderingGroup;
  14695. }
  14696. }
  14697. declare module BABYLON {
  14698. interface AbstractScene {
  14699. /**
  14700. * Return a the first highlight layer of the scene with a given name.
  14701. * @param name The name of the highlight layer to look for.
  14702. * @return The highlight layer if found otherwise null.
  14703. */
  14704. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14705. }
  14706. /**
  14707. * Glow layer options. This helps customizing the behaviour
  14708. * of the glow layer.
  14709. */
  14710. interface IGlowLayerOptions {
  14711. /**
  14712. * Multiplication factor apply to the canvas size to compute the render target size
  14713. * used to generated the glowing objects (the smaller the faster).
  14714. */
  14715. mainTextureRatio: number;
  14716. /**
  14717. * Enforces a fixed size texture to ensure resize independant blur.
  14718. */
  14719. mainTextureFixedSize?: number;
  14720. /**
  14721. * How big is the kernel of the blur texture.
  14722. */
  14723. blurKernelSize: number;
  14724. /**
  14725. * The camera attached to the layer.
  14726. */
  14727. camera: Nullable<Camera>;
  14728. /**
  14729. * Enable MSAA by chosing the number of samples.
  14730. */
  14731. mainTextureSamples?: number;
  14732. /**
  14733. * The rendering group to draw the layer in.
  14734. */
  14735. renderingGroupId: number;
  14736. }
  14737. /**
  14738. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14739. *
  14740. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14741. * glowy meshes to your scene.
  14742. *
  14743. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14744. */
  14745. class GlowLayer extends EffectLayer {
  14746. /**
  14747. * Effect Name of the layer.
  14748. */
  14749. static readonly EffectName: string;
  14750. /**
  14751. * The default blur kernel size used for the glow.
  14752. */
  14753. static DefaultBlurKernelSize: number;
  14754. /**
  14755. * The default texture size ratio used for the glow.
  14756. */
  14757. static DefaultTextureRatio: number;
  14758. /**
  14759. * Sets the kernel size of the blur.
  14760. */
  14761. /**
  14762. * Gets the kernel size of the blur.
  14763. */
  14764. blurKernelSize: number;
  14765. /**
  14766. * Sets the glow intensity.
  14767. */
  14768. /**
  14769. * Gets the glow intensity.
  14770. */
  14771. intensity: number;
  14772. private _options;
  14773. private _intensity;
  14774. private _horizontalBlurPostprocess1;
  14775. private _verticalBlurPostprocess1;
  14776. private _horizontalBlurPostprocess2;
  14777. private _verticalBlurPostprocess2;
  14778. private _blurTexture1;
  14779. private _blurTexture2;
  14780. private _postProcesses1;
  14781. private _postProcesses2;
  14782. private _includedOnlyMeshes;
  14783. private _excludedMeshes;
  14784. /**
  14785. * Callback used to let the user override the color selection on a per mesh basis
  14786. */
  14787. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14788. /**
  14789. * Callback used to let the user override the texture selection on a per mesh basis
  14790. */
  14791. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14792. /**
  14793. * Instantiates a new glow Layer and references it to the scene.
  14794. * @param name The name of the layer
  14795. * @param scene The scene to use the layer in
  14796. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14797. */
  14798. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14799. /**
  14800. * Get the effect name of the layer.
  14801. * @return The effect name
  14802. */
  14803. getEffectName(): string;
  14804. /**
  14805. * Create the merge effect. This is the shader use to blit the information back
  14806. * to the main canvas at the end of the scene rendering.
  14807. */
  14808. protected _createMergeEffect(): Effect;
  14809. /**
  14810. * Creates the render target textures and post processes used in the glow layer.
  14811. */
  14812. protected _createTextureAndPostProcesses(): void;
  14813. /**
  14814. * Checks for the readiness of the element composing the layer.
  14815. * @param subMesh the mesh to check for
  14816. * @param useInstances specify wether or not to use instances to render the mesh
  14817. * @param emissiveTexture the associated emissive texture used to generate the glow
  14818. * @return true if ready otherwise, false
  14819. */
  14820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14821. /**
  14822. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14823. */
  14824. needStencil(): boolean;
  14825. /**
  14826. * Implementation specific of rendering the generating effect on the main canvas.
  14827. * @param effect The effect used to render through
  14828. */
  14829. protected _internalRender(effect: Effect): void;
  14830. /**
  14831. * Sets the required values for both the emissive texture and and the main color.
  14832. */
  14833. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14834. /**
  14835. * Returns true if the mesh should render, otherwise false.
  14836. * @param mesh The mesh to render
  14837. * @returns true if it should render otherwise false
  14838. */
  14839. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14840. /**
  14841. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14842. * @param mesh The mesh to exclude from the glow layer
  14843. */
  14844. addExcludedMesh(mesh: Mesh): void;
  14845. /**
  14846. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14847. * @param mesh The mesh to remove
  14848. */
  14849. removeExcludedMesh(mesh: Mesh): void;
  14850. /**
  14851. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14852. * @param mesh The mesh to include in the glow layer
  14853. */
  14854. addIncludedOnlyMesh(mesh: Mesh): void;
  14855. /**
  14856. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14857. * @param mesh The mesh to remove
  14858. */
  14859. removeIncludedOnlyMesh(mesh: Mesh): void;
  14860. /**
  14861. * Determine if a given mesh will be used in the glow layer
  14862. * @param mesh The mesh to test
  14863. * @returns true if the mesh will be highlighted by the current glow layer
  14864. */
  14865. hasMesh(mesh: AbstractMesh): boolean;
  14866. /**
  14867. * Free any resources and references associated to a mesh.
  14868. * Internal use
  14869. * @param mesh The mesh to free.
  14870. * @hidden
  14871. */
  14872. _disposeMesh(mesh: Mesh): void;
  14873. /**
  14874. * Gets the class name of the effect layer
  14875. * @returns the string with the class name of the effect layer
  14876. */
  14877. getClassName(): string;
  14878. /**
  14879. * Serializes this glow layer
  14880. * @returns a serialized glow layer object
  14881. */
  14882. serialize(): any;
  14883. /**
  14884. * Creates a Glow Layer from parsed glow layer data
  14885. * @param parsedGlowLayer defines glow layer data
  14886. * @param scene defines the current scene
  14887. * @param rootUrl defines the root URL containing the glow layer information
  14888. * @returns a parsed Glow Layer
  14889. */
  14890. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14891. }
  14892. }
  14893. declare module BABYLON {
  14894. interface AbstractScene {
  14895. /**
  14896. * Return a the first highlight layer of the scene with a given name.
  14897. * @param name The name of the highlight layer to look for.
  14898. * @return The highlight layer if found otherwise null.
  14899. */
  14900. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14901. }
  14902. /**
  14903. * Highlight layer options. This helps customizing the behaviour
  14904. * of the highlight layer.
  14905. */
  14906. interface IHighlightLayerOptions {
  14907. /**
  14908. * Multiplication factor apply to the canvas size to compute the render target size
  14909. * used to generated the glowing objects (the smaller the faster).
  14910. */
  14911. mainTextureRatio: number;
  14912. /**
  14913. * Enforces a fixed size texture to ensure resize independant blur.
  14914. */
  14915. mainTextureFixedSize?: number;
  14916. /**
  14917. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14918. * of the picture to blur (the smaller the faster).
  14919. */
  14920. blurTextureSizeRatio: number;
  14921. /**
  14922. * How big in texel of the blur texture is the vertical blur.
  14923. */
  14924. blurVerticalSize: number;
  14925. /**
  14926. * How big in texel of the blur texture is the horizontal blur.
  14927. */
  14928. blurHorizontalSize: number;
  14929. /**
  14930. * Alpha blending mode used to apply the blur. Default is combine.
  14931. */
  14932. alphaBlendingMode: number;
  14933. /**
  14934. * The camera attached to the layer.
  14935. */
  14936. camera: Nullable<Camera>;
  14937. /**
  14938. * Should we display highlight as a solid stroke?
  14939. */
  14940. isStroke?: boolean;
  14941. /**
  14942. * The rendering group to draw the layer in.
  14943. */
  14944. renderingGroupId: number;
  14945. }
  14946. /**
  14947. * The highlight layer Helps adding a glow effect around a mesh.
  14948. *
  14949. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14950. * glowy meshes to your scene.
  14951. *
  14952. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14953. */
  14954. class HighlightLayer extends EffectLayer {
  14955. name: string;
  14956. /**
  14957. * Effect Name of the highlight layer.
  14958. */
  14959. static readonly EffectName: string;
  14960. /**
  14961. * The neutral color used during the preparation of the glow effect.
  14962. * This is black by default as the blend operation is a blend operation.
  14963. */
  14964. static NeutralColor: Color4;
  14965. /**
  14966. * Stencil value used for glowing meshes.
  14967. */
  14968. static GlowingMeshStencilReference: number;
  14969. /**
  14970. * Stencil value used for the other meshes in the scene.
  14971. */
  14972. static NormalMeshStencilReference: number;
  14973. /**
  14974. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14975. */
  14976. innerGlow: boolean;
  14977. /**
  14978. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14979. */
  14980. outerGlow: boolean;
  14981. /**
  14982. * Specifies the horizontal size of the blur.
  14983. */
  14984. /**
  14985. * Gets the horizontal size of the blur.
  14986. */
  14987. blurHorizontalSize: number;
  14988. /**
  14989. * Specifies the vertical size of the blur.
  14990. */
  14991. /**
  14992. * Gets the vertical size of the blur.
  14993. */
  14994. blurVerticalSize: number;
  14995. /**
  14996. * An event triggered when the highlight layer is being blurred.
  14997. */
  14998. onBeforeBlurObservable: Observable<HighlightLayer>;
  14999. /**
  15000. * An event triggered when the highlight layer has been blurred.
  15001. */
  15002. onAfterBlurObservable: Observable<HighlightLayer>;
  15003. private _instanceGlowingMeshStencilReference;
  15004. private _options;
  15005. private _downSamplePostprocess;
  15006. private _horizontalBlurPostprocess;
  15007. private _verticalBlurPostprocess;
  15008. private _blurTexture;
  15009. private _meshes;
  15010. private _excludedMeshes;
  15011. /**
  15012. * Instantiates a new highlight Layer and references it to the scene..
  15013. * @param name The name of the layer
  15014. * @param scene The scene to use the layer in
  15015. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15016. */
  15017. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15018. /**
  15019. * Get the effect name of the layer.
  15020. * @return The effect name
  15021. */
  15022. getEffectName(): string;
  15023. /**
  15024. * Create the merge effect. This is the shader use to blit the information back
  15025. * to the main canvas at the end of the scene rendering.
  15026. */
  15027. protected _createMergeEffect(): Effect;
  15028. /**
  15029. * Creates the render target textures and post processes used in the highlight layer.
  15030. */
  15031. protected _createTextureAndPostProcesses(): void;
  15032. /**
  15033. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15034. */
  15035. needStencil(): boolean;
  15036. /**
  15037. * Checks for the readiness of the element composing the layer.
  15038. * @param subMesh the mesh to check for
  15039. * @param useInstances specify wether or not to use instances to render the mesh
  15040. * @param emissiveTexture the associated emissive texture used to generate the glow
  15041. * @return true if ready otherwise, false
  15042. */
  15043. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15044. /**
  15045. * Implementation specific of rendering the generating effect on the main canvas.
  15046. * @param effect The effect used to render through
  15047. */
  15048. protected _internalRender(effect: Effect): void;
  15049. /**
  15050. * Returns true if the layer contains information to display, otherwise false.
  15051. */
  15052. shouldRender(): boolean;
  15053. /**
  15054. * Returns true if the mesh should render, otherwise false.
  15055. * @param mesh The mesh to render
  15056. * @returns true if it should render otherwise false
  15057. */
  15058. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15059. /**
  15060. * Sets the required values for both the emissive texture and and the main color.
  15061. */
  15062. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15063. /**
  15064. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15065. * @param mesh The mesh to exclude from the highlight layer
  15066. */
  15067. addExcludedMesh(mesh: Mesh): void;
  15068. /**
  15069. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15070. * @param mesh The mesh to highlight
  15071. */
  15072. removeExcludedMesh(mesh: Mesh): void;
  15073. /**
  15074. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15075. * @param mesh mesh to test
  15076. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15077. */
  15078. hasMesh(mesh: AbstractMesh): boolean;
  15079. /**
  15080. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15081. * @param mesh The mesh to highlight
  15082. * @param color The color of the highlight
  15083. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15084. */
  15085. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15086. /**
  15087. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15088. * @param mesh The mesh to highlight
  15089. */
  15090. removeMesh(mesh: Mesh): void;
  15091. /**
  15092. * Force the stencil to the normal expected value for none glowing parts
  15093. */
  15094. private _defaultStencilReference;
  15095. /**
  15096. * Free any resources and references associated to a mesh.
  15097. * Internal use
  15098. * @param mesh The mesh to free.
  15099. * @hidden
  15100. */
  15101. _disposeMesh(mesh: Mesh): void;
  15102. /**
  15103. * Dispose the highlight layer and free resources.
  15104. */
  15105. dispose(): void;
  15106. /**
  15107. * Gets the class name of the effect layer
  15108. * @returns the string with the class name of the effect layer
  15109. */
  15110. getClassName(): string;
  15111. /**
  15112. * Serializes this Highlight layer
  15113. * @returns a serialized Highlight layer object
  15114. */
  15115. serialize(): any;
  15116. /**
  15117. * Creates a Highlight layer from parsed Highlight layer data
  15118. * @param parsedHightlightLayer defines the Highlight layer data
  15119. * @param scene defines the current scene
  15120. * @param rootUrl defines the root URL containing the Highlight layer information
  15121. * @returns a parsed Highlight layer
  15122. */
  15123. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15124. }
  15125. }
  15126. declare module BABYLON {
  15127. /**
  15128. * This represents a full screen 2d layer.
  15129. * This can be useful to display a picture in the background of your scene for instance.
  15130. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15131. */
  15132. class Layer {
  15133. /**
  15134. * Define the name of the layer.
  15135. */
  15136. name: string;
  15137. /**
  15138. * Define the texture the layer should display.
  15139. */
  15140. texture: Nullable<Texture>;
  15141. /**
  15142. * Is the layer in background or foreground.
  15143. */
  15144. isBackground: boolean;
  15145. /**
  15146. * Define the color of the layer (instead of texture).
  15147. */
  15148. color: Color4;
  15149. /**
  15150. * Define the scale of the layer in order to zoom in out of the texture.
  15151. */
  15152. scale: Vector2;
  15153. /**
  15154. * Define an offset for the layer in order to shift the texture.
  15155. */
  15156. offset: Vector2;
  15157. /**
  15158. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15159. */
  15160. alphaBlendingMode: number;
  15161. /**
  15162. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15163. * Alpha test will not mix with the background color in case of transparency.
  15164. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15165. */
  15166. alphaTest: boolean;
  15167. /**
  15168. * Define a mask to restrict the layer to only some of the scene cameras.
  15169. */
  15170. layerMask: number;
  15171. /**
  15172. * Define the list of render target the layer is visible into.
  15173. */
  15174. renderTargetTextures: RenderTargetTexture[];
  15175. /**
  15176. * Define if the layer is only used in renderTarget or if it also
  15177. * renders in the main frame buffer of the canvas.
  15178. */
  15179. renderOnlyInRenderTargetTextures: boolean;
  15180. private _scene;
  15181. private _vertexBuffers;
  15182. private _indexBuffer;
  15183. private _effect;
  15184. private _alphaTestEffect;
  15185. /**
  15186. * An event triggered when the layer is disposed.
  15187. */
  15188. onDisposeObservable: Observable<Layer>;
  15189. private _onDisposeObserver;
  15190. /**
  15191. * Back compatibility with callback before the onDisposeObservable existed.
  15192. * The set callback will be triggered when the layer has been disposed.
  15193. */
  15194. onDispose: () => void;
  15195. /**
  15196. * An event triggered before rendering the scene
  15197. */
  15198. onBeforeRenderObservable: Observable<Layer>;
  15199. private _onBeforeRenderObserver;
  15200. /**
  15201. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15202. * The set callback will be triggered just before rendering the layer.
  15203. */
  15204. onBeforeRender: () => void;
  15205. /**
  15206. * An event triggered after rendering the scene
  15207. */
  15208. onAfterRenderObservable: Observable<Layer>;
  15209. private _onAfterRenderObserver;
  15210. /**
  15211. * Back compatibility with callback before the onAfterRenderObservable existed.
  15212. * The set callback will be triggered just after rendering the layer.
  15213. */
  15214. onAfterRender: () => void;
  15215. /**
  15216. * Instantiates a new layer.
  15217. * This represents a full screen 2d layer.
  15218. * This can be useful to display a picture in the background of your scene for instance.
  15219. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15220. * @param name Define the name of the layer in the scene
  15221. * @param imgUrl Define the url of the texture to display in the layer
  15222. * @param scene Define the scene the layer belongs to
  15223. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15224. * @param color Defines a color for the layer
  15225. */
  15226. constructor(
  15227. /**
  15228. * Define the name of the layer.
  15229. */
  15230. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15231. private _createIndexBuffer;
  15232. /** @hidden */
  15233. _rebuild(): void;
  15234. /**
  15235. * Renders the layer in the scene.
  15236. */
  15237. render(): void;
  15238. /**
  15239. * Disposes and releases the associated ressources.
  15240. */
  15241. dispose(): void;
  15242. }
  15243. }
  15244. declare module BABYLON {
  15245. interface AbstractScene {
  15246. /**
  15247. * The list of layers (background and foreground) of the scene
  15248. */
  15249. layers: Array<Layer>;
  15250. }
  15251. /**
  15252. * Defines the layer scene component responsible to manage any layers
  15253. * in a given scene.
  15254. */
  15255. class LayerSceneComponent implements ISceneComponent {
  15256. /**
  15257. * The component name helpfull to identify the component in the list of scene components.
  15258. */
  15259. readonly name: string;
  15260. /**
  15261. * The scene the component belongs to.
  15262. */
  15263. scene: Scene;
  15264. private _engine;
  15265. /**
  15266. * Creates a new instance of the component for the given scene
  15267. * @param scene Defines the scene to register the component in
  15268. */
  15269. constructor(scene: Scene);
  15270. /**
  15271. * Registers the component in a given scene
  15272. */
  15273. register(): void;
  15274. /**
  15275. * Rebuilds the elements related to this component in case of
  15276. * context lost for instance.
  15277. */
  15278. rebuild(): void;
  15279. /**
  15280. * Disposes the component and the associated ressources.
  15281. */
  15282. dispose(): void;
  15283. private _draw;
  15284. private _drawCameraPredicate;
  15285. private _drawCameraBackground;
  15286. private _drawCameraForeground;
  15287. private _drawRenderTargetPredicate;
  15288. private _drawRenderTargetBackground;
  15289. private _drawRenderTargetForeground;
  15290. }
  15291. }
  15292. declare module BABYLON {
  15293. /**
  15294. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15295. * It controls one of the indiviual texture used in the effect.
  15296. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15297. */
  15298. class LensFlare {
  15299. /**
  15300. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15301. */
  15302. size: number;
  15303. /**
  15304. * 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.
  15305. */
  15306. position: number;
  15307. /**
  15308. * Define the lens color.
  15309. */
  15310. color: Color3;
  15311. /**
  15312. * Define the lens texture.
  15313. */
  15314. texture: Nullable<Texture>;
  15315. /**
  15316. * Define the alpha mode to render this particular lens.
  15317. */
  15318. alphaMode: number;
  15319. private _system;
  15320. /**
  15321. * Creates a new Lens Flare.
  15322. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15323. * It controls one of the indiviual texture used in the effect.
  15324. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15325. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15326. * @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.
  15327. * @param color Define the lens color
  15328. * @param imgUrl Define the lens texture url
  15329. * @param system Define the `lensFlareSystem` this flare is part of
  15330. * @returns The newly created Lens Flare
  15331. */
  15332. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15333. /**
  15334. * Instantiates a new Lens Flare.
  15335. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15336. * It controls one of the indiviual texture used in the effect.
  15337. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15338. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15339. * @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.
  15340. * @param color Define the lens color
  15341. * @param imgUrl Define the lens texture url
  15342. * @param system Define the `lensFlareSystem` this flare is part of
  15343. */
  15344. constructor(
  15345. /**
  15346. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15347. */
  15348. size: number,
  15349. /**
  15350. * 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.
  15351. */
  15352. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15353. /**
  15354. * Dispose and release the lens flare with its associated resources.
  15355. */
  15356. dispose(): void;
  15357. }
  15358. }
  15359. declare module BABYLON {
  15360. /**
  15361. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15362. * It is usually composed of several `BABYLON.lensFlare`.
  15363. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15364. */
  15365. class LensFlareSystem {
  15366. /**
  15367. * Define the name of the lens flare system
  15368. */
  15369. name: string;
  15370. /**
  15371. * List of lens flares used in this system.
  15372. */
  15373. lensFlares: LensFlare[];
  15374. /**
  15375. * Define a limit from the border the lens flare can be visible.
  15376. */
  15377. borderLimit: number;
  15378. /**
  15379. * Define a viewport border we do not want to see the lens flare in.
  15380. */
  15381. viewportBorder: number;
  15382. /**
  15383. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15384. */
  15385. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15386. /**
  15387. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15388. */
  15389. layerMask: number;
  15390. /**
  15391. * Define the id of the lens flare system in the scene.
  15392. * (equal to name by default)
  15393. */
  15394. id: string;
  15395. private _scene;
  15396. private _emitter;
  15397. private _vertexBuffers;
  15398. private _indexBuffer;
  15399. private _effect;
  15400. private _positionX;
  15401. private _positionY;
  15402. private _isEnabled;
  15403. /**
  15404. * Instantiates a lens flare system.
  15405. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15406. * It is usually composed of several `BABYLON.lensFlare`.
  15407. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15408. * @param name Define the name of the lens flare system in the scene
  15409. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15410. * @param scene Define the scene the lens flare system belongs to
  15411. */
  15412. constructor(
  15413. /**
  15414. * Define the name of the lens flare system
  15415. */
  15416. name: string, emitter: any, scene: Scene);
  15417. /**
  15418. * Define if the lens flare system is enabled.
  15419. */
  15420. isEnabled: boolean;
  15421. /**
  15422. * Get the scene the effects belongs to.
  15423. * @returns the scene holding the lens flare system
  15424. */
  15425. getScene(): Scene;
  15426. /**
  15427. * Get the emitter of the lens flare system.
  15428. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15429. * @returns the emitter of the lens flare system
  15430. */
  15431. getEmitter(): any;
  15432. /**
  15433. * Set the emitter of the lens flare system.
  15434. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15435. * @param newEmitter Define the new emitter of the system
  15436. */
  15437. setEmitter(newEmitter: any): void;
  15438. /**
  15439. * Get the lens flare system emitter position.
  15440. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15441. * @returns the position
  15442. */
  15443. getEmitterPosition(): Vector3;
  15444. /**
  15445. * @hidden
  15446. */
  15447. computeEffectivePosition(globalViewport: Viewport): boolean;
  15448. /** @hidden */
  15449. _isVisible(): boolean;
  15450. /**
  15451. * @hidden
  15452. */
  15453. render(): boolean;
  15454. /**
  15455. * Dispose and release the lens flare with its associated resources.
  15456. */
  15457. dispose(): void;
  15458. /**
  15459. * Parse a lens flare system from a JSON repressentation
  15460. * @param parsedLensFlareSystem Define the JSON to parse
  15461. * @param scene Define the scene the parsed system should be instantiated in
  15462. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15463. * @returns the parsed system
  15464. */
  15465. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15466. /**
  15467. * Serialize the current Lens Flare System into a JSON representation.
  15468. * @returns the serialized JSON
  15469. */
  15470. serialize(): any;
  15471. }
  15472. }
  15473. declare module BABYLON {
  15474. interface AbstractScene {
  15475. /**
  15476. * The list of lens flare system added to the scene
  15477. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15478. */
  15479. lensFlareSystems: Array<LensFlareSystem>;
  15480. /**
  15481. * Removes the given lens flare system from this scene.
  15482. * @param toRemove The lens flare system to remove
  15483. * @returns The index of the removed lens flare system
  15484. */
  15485. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15486. /**
  15487. * Adds the given lens flare system to this scene
  15488. * @param newLensFlareSystem The lens flare system to add
  15489. */
  15490. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15491. /**
  15492. * Gets a lens flare system using its name
  15493. * @param name defines the name to look for
  15494. * @returns the lens flare system or null if not found
  15495. */
  15496. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15497. /**
  15498. * Gets a lens flare system using its id
  15499. * @param id defines the id to look for
  15500. * @returns the lens flare system or null if not found
  15501. */
  15502. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15503. }
  15504. /**
  15505. * Defines the lens flare scene component responsible to manage any lens flares
  15506. * in a given scene.
  15507. */
  15508. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15509. /**
  15510. * The component name helpfull to identify the component in the list of scene components.
  15511. */
  15512. readonly name: string;
  15513. /**
  15514. * The scene the component belongs to.
  15515. */
  15516. scene: Scene;
  15517. /**
  15518. * Creates a new instance of the component for the given scene
  15519. * @param scene Defines the scene to register the component in
  15520. */
  15521. constructor(scene: Scene);
  15522. /**
  15523. * Registers the component in a given scene
  15524. */
  15525. register(): void;
  15526. /**
  15527. * Rebuilds the elements related to this component in case of
  15528. * context lost for instance.
  15529. */
  15530. rebuild(): void;
  15531. /**
  15532. * Adds all the element from the container to the scene
  15533. * @param container the container holding the elements
  15534. */
  15535. addFromContainer(container: AbstractScene): void;
  15536. /**
  15537. * Removes all the elements in the container from the scene
  15538. * @param container contains the elements to remove
  15539. */
  15540. removeFromContainer(container: AbstractScene): void;
  15541. /**
  15542. * Serializes the component data to the specified json object
  15543. * @param serializationObject The object to serialize to
  15544. */
  15545. serialize(serializationObject: any): void;
  15546. /**
  15547. * Disposes the component and the associated ressources.
  15548. */
  15549. dispose(): void;
  15550. private _draw;
  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. private static _BlackReadOnly;
  20555. /**
  20556. * Creates a new Color3 from the string containing valid hexadecimal values
  20557. * @param hex defines a string containing valid hexadecimal values
  20558. * @returns a new Color3 object
  20559. */
  20560. static FromHexString(hex: string): Color3;
  20561. /**
  20562. * Creates a new Vector3 from the starting index of the given array
  20563. * @param array defines the source array
  20564. * @param offset defines an offset in the source array
  20565. * @returns a new Color3 object
  20566. */
  20567. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20568. /**
  20569. * Creates a new Color3 from integer values (< 256)
  20570. * @param r defines the red component to read from (value between 0 and 255)
  20571. * @param g defines the green component to read from (value between 0 and 255)
  20572. * @param b defines the blue component to read from (value between 0 and 255)
  20573. * @returns a new Color3 object
  20574. */
  20575. static FromInts(r: number, g: number, b: number): Color3;
  20576. /**
  20577. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20578. * @param start defines the start Color3 value
  20579. * @param end defines the end Color3 value
  20580. * @param amount defines the gradient value between start and end
  20581. * @returns a new Color3 object
  20582. */
  20583. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20584. /**
  20585. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20586. * @param left defines the start value
  20587. * @param right defines the end value
  20588. * @param amount defines the gradient factor
  20589. * @param result defines the Color3 object where to store the result
  20590. */
  20591. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20592. /**
  20593. * Returns a Color3 value containing a red color
  20594. * @returns a new Color3 object
  20595. */
  20596. static Red(): Color3;
  20597. /**
  20598. * Returns a Color3 value containing a green color
  20599. * @returns a new Color3 object
  20600. */
  20601. static Green(): Color3;
  20602. /**
  20603. * Returns a Color3 value containing a blue color
  20604. * @returns a new Color3 object
  20605. */
  20606. static Blue(): Color3;
  20607. /**
  20608. * Returns a Color3 value containing a black color
  20609. * @returns a new Color3 object
  20610. */
  20611. static Black(): Color3;
  20612. /**
  20613. * Gets a Color3 value containing a black color that must not be updated
  20614. */
  20615. static readonly BlackReadOnly: DeepImmutable<Color3>;
  20616. /**
  20617. * Returns a Color3 value containing a white color
  20618. * @returns a new Color3 object
  20619. */
  20620. static White(): Color3;
  20621. /**
  20622. * Returns a Color3 value containing a purple color
  20623. * @returns a new Color3 object
  20624. */
  20625. static Purple(): Color3;
  20626. /**
  20627. * Returns a Color3 value containing a magenta color
  20628. * @returns a new Color3 object
  20629. */
  20630. static Magenta(): Color3;
  20631. /**
  20632. * Returns a Color3 value containing a yellow color
  20633. * @returns a new Color3 object
  20634. */
  20635. static Yellow(): Color3;
  20636. /**
  20637. * Returns a Color3 value containing a gray color
  20638. * @returns a new Color3 object
  20639. */
  20640. static Gray(): Color3;
  20641. /**
  20642. * Returns a Color3 value containing a teal color
  20643. * @returns a new Color3 object
  20644. */
  20645. static Teal(): Color3;
  20646. /**
  20647. * Returns a Color3 value containing a random color
  20648. * @returns a new Color3 object
  20649. */
  20650. static Random(): Color3;
  20651. }
  20652. /**
  20653. * Class used to hold a RBGA color
  20654. */
  20655. class Color4 {
  20656. /**
  20657. * Defines the red component (between 0 and 1, default is 0)
  20658. */
  20659. r: number;
  20660. /**
  20661. * Defines the green component (between 0 and 1, default is 0)
  20662. */
  20663. g: number;
  20664. /**
  20665. * Defines the blue component (between 0 and 1, default is 0)
  20666. */
  20667. b: number;
  20668. /**
  20669. * Defines the alpha component (between 0 and 1, default is 1)
  20670. */
  20671. a: number;
  20672. /**
  20673. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20674. * @param r defines the red component (between 0 and 1, default is 0)
  20675. * @param g defines the green component (between 0 and 1, default is 0)
  20676. * @param b defines the blue component (between 0 and 1, default is 0)
  20677. * @param a defines the alpha component (between 0 and 1, default is 1)
  20678. */
  20679. constructor(
  20680. /**
  20681. * Defines the red component (between 0 and 1, default is 0)
  20682. */
  20683. r?: number,
  20684. /**
  20685. * Defines the green component (between 0 and 1, default is 0)
  20686. */
  20687. g?: number,
  20688. /**
  20689. * Defines the blue component (between 0 and 1, default is 0)
  20690. */
  20691. b?: number,
  20692. /**
  20693. * Defines the alpha component (between 0 and 1, default is 1)
  20694. */
  20695. a?: number);
  20696. /**
  20697. * Adds in place the given Color4 values to the current Color4 object
  20698. * @param right defines the second operand
  20699. * @returns the current updated Color4 object
  20700. */
  20701. addInPlace(right: DeepImmutable<Color4>): Color4;
  20702. /**
  20703. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20704. * @returns the new array
  20705. */
  20706. asArray(): number[];
  20707. /**
  20708. * Stores from the starting index in the given array the Color4 successive values
  20709. * @param array defines the array where to store the r,g,b components
  20710. * @param index defines an optional index in the target array to define where to start storing values
  20711. * @returns the current Color4 object
  20712. */
  20713. toArray(array: number[], index?: number): Color4;
  20714. /**
  20715. * Determines equality between Color4 objects
  20716. * @param otherColor defines the second operand
  20717. * @returns true if the rgba values are equal to the given ones
  20718. */
  20719. equals(otherColor: DeepImmutable<Color4>): boolean;
  20720. /**
  20721. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20722. * @param right defines the second operand
  20723. * @returns a new Color4 object
  20724. */
  20725. add(right: DeepImmutable<Color4>): Color4;
  20726. /**
  20727. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20728. * @param right defines the second operand
  20729. * @returns a new Color4 object
  20730. */
  20731. subtract(right: DeepImmutable<Color4>): Color4;
  20732. /**
  20733. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20734. * @param right defines the second operand
  20735. * @param result defines the Color4 object where to store the result
  20736. * @returns the current Color4 object
  20737. */
  20738. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20739. /**
  20740. * Creates a new Color4 with the current Color4 values multiplied by scale
  20741. * @param scale defines the scaling factor to apply
  20742. * @returns a new Color4 object
  20743. */
  20744. scale(scale: number): Color4;
  20745. /**
  20746. * Multiplies the current Color4 values by scale and stores the result in "result"
  20747. * @param scale defines the scaling factor to apply
  20748. * @param result defines the Color4 object where to store the result
  20749. * @returns the current unmodified Color4
  20750. */
  20751. scaleToRef(scale: number, result: Color4): Color4;
  20752. /**
  20753. * Scale the current Color4 values by a factor and add the result to a given Color4
  20754. * @param scale defines the scale factor
  20755. * @param result defines the Color4 object where to store the result
  20756. * @returns the unmodified current Color4
  20757. */
  20758. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20759. /**
  20760. * Clamps the rgb values by the min and max values and stores the result into "result"
  20761. * @param min defines minimum clamping value (default is 0)
  20762. * @param max defines maximum clamping value (default is 1)
  20763. * @param result defines color to store the result into.
  20764. * @returns the cuurent Color4
  20765. */
  20766. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20767. /**
  20768. * Multipy an Color4 value by another and return a new Color4 object
  20769. * @param color defines the Color4 value to multiply by
  20770. * @returns a new Color4 object
  20771. */
  20772. multiply(color: Color4): Color4;
  20773. /**
  20774. * Multipy a Color4 value by another and push the result in a reference value
  20775. * @param color defines the Color4 value to multiply by
  20776. * @param result defines the Color4 to fill the result in
  20777. * @returns the result Color4
  20778. */
  20779. multiplyToRef(color: Color4, result: Color4): Color4;
  20780. /**
  20781. * Creates a string with the Color4 current values
  20782. * @returns the string representation of the Color4 object
  20783. */
  20784. toString(): string;
  20785. /**
  20786. * Returns the string "Color4"
  20787. * @returns "Color4"
  20788. */
  20789. getClassName(): string;
  20790. /**
  20791. * Compute the Color4 hash code
  20792. * @returns an unique number that can be used to hash Color4 objects
  20793. */
  20794. getHashCode(): number;
  20795. /**
  20796. * Creates a new Color4 copied from the current one
  20797. * @returns a new Color4 object
  20798. */
  20799. clone(): Color4;
  20800. /**
  20801. * Copies the given Color4 values into the current one
  20802. * @param source defines the source Color4 object
  20803. * @returns the current updated Color4 object
  20804. */
  20805. copyFrom(source: Color4): Color4;
  20806. /**
  20807. * Copies the given float values into the current one
  20808. * @param r defines the red component to read from
  20809. * @param g defines the green component to read from
  20810. * @param b defines the blue component to read from
  20811. * @param a defines the alpha component to read from
  20812. * @returns the current updated Color4 object
  20813. */
  20814. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20815. /**
  20816. * Copies the given float values into the current one
  20817. * @param r defines the red component to read from
  20818. * @param g defines the green component to read from
  20819. * @param b defines the blue component to read from
  20820. * @param a defines the alpha component to read from
  20821. * @returns the current updated Color4 object
  20822. */
  20823. set(r: number, g: number, b: number, a: number): Color4;
  20824. /**
  20825. * Compute the Color4 hexadecimal code as a string
  20826. * @returns a string containing the hexadecimal representation of the Color4 object
  20827. */
  20828. toHexString(): string;
  20829. /**
  20830. * Computes a new Color4 converted from the current one to linear space
  20831. * @returns a new Color4 object
  20832. */
  20833. toLinearSpace(): Color4;
  20834. /**
  20835. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20836. * @param convertedColor defines the Color4 object where to store the linear space version
  20837. * @returns the unmodified Color4
  20838. */
  20839. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20840. /**
  20841. * Computes a new Color4 converted from the current one to gamma space
  20842. * @returns a new Color4 object
  20843. */
  20844. toGammaSpace(): Color4;
  20845. /**
  20846. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20847. * @param convertedColor defines the Color4 object where to store the gamma space version
  20848. * @returns the unmodified Color4
  20849. */
  20850. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20851. /**
  20852. * Creates a new Color4 from the string containing valid hexadecimal values
  20853. * @param hex defines a string containing valid hexadecimal values
  20854. * @returns a new Color4 object
  20855. */
  20856. static FromHexString(hex: string): Color4;
  20857. /**
  20858. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20859. * @param left defines the start value
  20860. * @param right defines the end value
  20861. * @param amount defines the gradient factor
  20862. * @returns a new Color4 object
  20863. */
  20864. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20865. /**
  20866. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20867. * @param left defines the start value
  20868. * @param right defines the end value
  20869. * @param amount defines the gradient factor
  20870. * @param result defines the Color4 object where to store data
  20871. */
  20872. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20873. /**
  20874. * Creates a new Color4 from a Color3 and an alpha value
  20875. * @param color3 defines the source Color3 to read from
  20876. * @param alpha defines the alpha component (1.0 by default)
  20877. * @returns a new Color4 object
  20878. */
  20879. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20880. /**
  20881. * Creates a new Color4 from the starting index element of the given array
  20882. * @param array defines the source array to read from
  20883. * @param offset defines the offset in the source array
  20884. * @returns a new Color4 object
  20885. */
  20886. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20887. /**
  20888. * Creates a new Color3 from integer values (< 256)
  20889. * @param r defines the red component to read from (value between 0 and 255)
  20890. * @param g defines the green component to read from (value between 0 and 255)
  20891. * @param b defines the blue component to read from (value between 0 and 255)
  20892. * @param a defines the alpha component to read from (value between 0 and 255)
  20893. * @returns a new Color3 object
  20894. */
  20895. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20896. /**
  20897. * Check the content of a given array and convert it to an array containing RGBA data
  20898. * If the original array was already containing count * 4 values then it is returned directly
  20899. * @param colors defines the array to check
  20900. * @param count defines the number of RGBA data to expect
  20901. * @returns an array containing count * 4 values (RGBA)
  20902. */
  20903. static CheckColors4(colors: number[], count: number): number[];
  20904. }
  20905. /**
  20906. * Class representing a vector containing 2 coordinates
  20907. */
  20908. class Vector2 {
  20909. /** defines the first coordinate */
  20910. x: number;
  20911. /** defines the second coordinate */
  20912. y: number;
  20913. /**
  20914. * Creates a new Vector2 from the given x and y coordinates
  20915. * @param x defines the first coordinate
  20916. * @param y defines the second coordinate
  20917. */
  20918. constructor(
  20919. /** defines the first coordinate */
  20920. x?: number,
  20921. /** defines the second coordinate */
  20922. y?: number);
  20923. /**
  20924. * Gets a string with the Vector2 coordinates
  20925. * @returns a string with the Vector2 coordinates
  20926. */
  20927. toString(): string;
  20928. /**
  20929. * Gets class name
  20930. * @returns the string "Vector2"
  20931. */
  20932. getClassName(): string;
  20933. /**
  20934. * Gets current vector hash code
  20935. * @returns the Vector2 hash code as a number
  20936. */
  20937. getHashCode(): number;
  20938. /**
  20939. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20940. * @param array defines the source array
  20941. * @param index defines the offset in source array
  20942. * @returns the current Vector2
  20943. */
  20944. toArray(array: FloatArray, index?: number): Vector2;
  20945. /**
  20946. * Copy the current vector to an array
  20947. * @returns a new array with 2 elements: the Vector2 coordinates.
  20948. */
  20949. asArray(): number[];
  20950. /**
  20951. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20952. * @param source defines the source Vector2
  20953. * @returns the current updated Vector2
  20954. */
  20955. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20956. /**
  20957. * Sets the Vector2 coordinates with the given floats
  20958. * @param x defines the first coordinate
  20959. * @param y defines the second coordinate
  20960. * @returns the current updated Vector2
  20961. */
  20962. copyFromFloats(x: number, y: number): Vector2;
  20963. /**
  20964. * Sets the Vector2 coordinates with the given floats
  20965. * @param x defines the first coordinate
  20966. * @param y defines the second coordinate
  20967. * @returns the current updated Vector2
  20968. */
  20969. set(x: number, y: number): Vector2;
  20970. /**
  20971. * Add another vector with the current one
  20972. * @param otherVector defines the other vector
  20973. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20974. */
  20975. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20976. /**
  20977. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20978. * @param otherVector defines the other vector
  20979. * @param result defines the target vector
  20980. * @returns the unmodified current Vector2
  20981. */
  20982. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20983. /**
  20984. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20985. * @param otherVector defines the other vector
  20986. * @returns the current updated Vector2
  20987. */
  20988. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20989. /**
  20990. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20991. * @param otherVector defines the other vector
  20992. * @returns a new Vector2
  20993. */
  20994. addVector3(otherVector: Vector3): Vector2;
  20995. /**
  20996. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20997. * @param otherVector defines the other vector
  20998. * @returns a new Vector2
  20999. */
  21000. subtract(otherVector: Vector2): Vector2;
  21001. /**
  21002. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  21003. * @param otherVector defines the other vector
  21004. * @param result defines the target vector
  21005. * @returns the unmodified current Vector2
  21006. */
  21007. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21008. /**
  21009. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  21010. * @param otherVector defines the other vector
  21011. * @returns the current updated Vector2
  21012. */
  21013. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21014. /**
  21015. * Multiplies in place the current Vector2 coordinates by the given ones
  21016. * @param otherVector defines the other vector
  21017. * @returns the current updated Vector2
  21018. */
  21019. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21020. /**
  21021. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  21022. * @param otherVector defines the other vector
  21023. * @returns a new Vector2
  21024. */
  21025. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  21026. /**
  21027. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  21028. * @param otherVector defines the other vector
  21029. * @param result defines the target vector
  21030. * @returns the unmodified current Vector2
  21031. */
  21032. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21033. /**
  21034. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  21035. * @param x defines the first coordinate
  21036. * @param y defines the second coordinate
  21037. * @returns a new Vector2
  21038. */
  21039. multiplyByFloats(x: number, y: number): Vector2;
  21040. /**
  21041. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  21042. * @param otherVector defines the other vector
  21043. * @returns a new Vector2
  21044. */
  21045. divide(otherVector: Vector2): Vector2;
  21046. /**
  21047. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  21048. * @param otherVector defines the other vector
  21049. * @param result defines the target vector
  21050. * @returns the unmodified current Vector2
  21051. */
  21052. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21053. /**
  21054. * Divides the current Vector2 coordinates by the given ones
  21055. * @param otherVector defines the other vector
  21056. * @returns the current updated Vector2
  21057. */
  21058. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21059. /**
  21060. * Gets a new Vector2 with current Vector2 negated coordinates
  21061. * @returns a new Vector2
  21062. */
  21063. negate(): Vector2;
  21064. /**
  21065. * Multiply the Vector2 coordinates by scale
  21066. * @param scale defines the scaling factor
  21067. * @returns the current updated Vector2
  21068. */
  21069. scaleInPlace(scale: number): Vector2;
  21070. /**
  21071. * Returns a new Vector2 scaled by "scale" from the current Vector2
  21072. * @param scale defines the scaling factor
  21073. * @returns a new Vector2
  21074. */
  21075. scale(scale: number): Vector2;
  21076. /**
  21077. * Scale the current Vector2 values by a factor to a given Vector2
  21078. * @param scale defines the scale factor
  21079. * @param result defines the Vector2 object where to store the result
  21080. * @returns the unmodified current Vector2
  21081. */
  21082. scaleToRef(scale: number, result: Vector2): Vector2;
  21083. /**
  21084. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  21085. * @param scale defines the scale factor
  21086. * @param result defines the Vector2 object where to store the result
  21087. * @returns the unmodified current Vector2
  21088. */
  21089. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  21090. /**
  21091. * Gets a boolean if two vectors are equals
  21092. * @param otherVector defines the other vector
  21093. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  21094. */
  21095. equals(otherVector: DeepImmutable<Vector2>): boolean;
  21096. /**
  21097. * Gets a boolean if two vectors are equals (using an epsilon value)
  21098. * @param otherVector defines the other vector
  21099. * @param epsilon defines the minimal distance to consider equality
  21100. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  21101. */
  21102. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  21103. /**
  21104. * Gets a new Vector2 from current Vector2 floored values
  21105. * @returns a new Vector2
  21106. */
  21107. floor(): Vector2;
  21108. /**
  21109. * Gets a new Vector2 from current Vector2 floored values
  21110. * @returns a new Vector2
  21111. */
  21112. fract(): Vector2;
  21113. /**
  21114. * Gets the length of the vector
  21115. * @returns the vector length (float)
  21116. */
  21117. length(): number;
  21118. /**
  21119. * Gets the vector squared length
  21120. * @returns the vector squared length (float)
  21121. */
  21122. lengthSquared(): number;
  21123. /**
  21124. * Normalize the vector
  21125. * @returns the current updated Vector2
  21126. */
  21127. normalize(): Vector2;
  21128. /**
  21129. * Gets a new Vector2 copied from the Vector2
  21130. * @returns a new Vector2
  21131. */
  21132. clone(): Vector2;
  21133. /**
  21134. * Gets a new Vector2(0, 0)
  21135. * @returns a new Vector2
  21136. */
  21137. static Zero(): Vector2;
  21138. /**
  21139. * Gets a new Vector2(1, 1)
  21140. * @returns a new Vector2
  21141. */
  21142. static One(): Vector2;
  21143. /**
  21144. * Gets a new Vector2 set from the given index element of the given array
  21145. * @param array defines the data source
  21146. * @param offset defines the offset in the data source
  21147. * @returns a new Vector2
  21148. */
  21149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21150. /**
  21151. * Sets "result" from the given index element of the given array
  21152. * @param array defines the data source
  21153. * @param offset defines the offset in the data source
  21154. * @param result defines the target vector
  21155. */
  21156. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21157. /**
  21158. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21159. * @param value1 defines 1st point of control
  21160. * @param value2 defines 2nd point of control
  21161. * @param value3 defines 3rd point of control
  21162. * @param value4 defines 4th point of control
  21163. * @param amount defines the interpolation factor
  21164. * @returns a new Vector2
  21165. */
  21166. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21167. /**
  21168. * 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".
  21169. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21170. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21171. * @param value defines the value to clamp
  21172. * @param min defines the lower limit
  21173. * @param max defines the upper limit
  21174. * @returns a new Vector2
  21175. */
  21176. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21177. /**
  21178. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21179. * @param value1 defines the 1st control point
  21180. * @param tangent1 defines the outgoing tangent
  21181. * @param value2 defines the 2nd control point
  21182. * @param tangent2 defines the incoming tangent
  21183. * @param amount defines the interpolation factor
  21184. * @returns a new Vector2
  21185. */
  21186. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21187. /**
  21188. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21189. * @param start defines the start vector
  21190. * @param end defines the end vector
  21191. * @param amount defines the interpolation factor
  21192. * @returns a new Vector2
  21193. */
  21194. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21195. /**
  21196. * Gets the dot product of the vector "left" and the vector "right"
  21197. * @param left defines first vector
  21198. * @param right defines second vector
  21199. * @returns the dot product (float)
  21200. */
  21201. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21202. /**
  21203. * Returns a new Vector2 equal to the normalized given vector
  21204. * @param vector defines the vector to normalize
  21205. * @returns a new Vector2
  21206. */
  21207. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21208. /**
  21209. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21210. * @param left defines 1st vector
  21211. * @param right defines 2nd vector
  21212. * @returns a new Vector2
  21213. */
  21214. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21215. /**
  21216. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21217. * @param left defines 1st vector
  21218. * @param right defines 2nd vector
  21219. * @returns a new Vector2
  21220. */
  21221. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21222. /**
  21223. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21224. * @param vector defines the vector to transform
  21225. * @param transformation defines the matrix to apply
  21226. * @returns a new Vector2
  21227. */
  21228. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21229. /**
  21230. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21231. * @param vector defines the vector to transform
  21232. * @param transformation defines the matrix to apply
  21233. * @param result defines the target vector
  21234. */
  21235. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21236. /**
  21237. * Determines if a given vector is included in a triangle
  21238. * @param p defines the vector to test
  21239. * @param p0 defines 1st triangle point
  21240. * @param p1 defines 2nd triangle point
  21241. * @param p2 defines 3rd triangle point
  21242. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21243. */
  21244. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21245. /**
  21246. * Gets the distance between the vectors "value1" and "value2"
  21247. * @param value1 defines first vector
  21248. * @param value2 defines second vector
  21249. * @returns the distance between vectors
  21250. */
  21251. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21252. /**
  21253. * Returns the squared distance between the vectors "value1" and "value2"
  21254. * @param value1 defines first vector
  21255. * @param value2 defines second vector
  21256. * @returns the squared distance between vectors
  21257. */
  21258. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21259. /**
  21260. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21261. * @param value1 defines first vector
  21262. * @param value2 defines second vector
  21263. * @returns a new Vector2
  21264. */
  21265. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21266. /**
  21267. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21268. * @param p defines the middle point
  21269. * @param segA defines one point of the segment
  21270. * @param segB defines the other point of the segment
  21271. * @returns the shortest distance
  21272. */
  21273. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21274. }
  21275. /**
  21276. * Classed used to store (x,y,z) vector representation
  21277. * A Vector3 is the main object used in 3D geometry
  21278. * It can represent etiher the coordinates of a point the space, either a direction
  21279. * Reminder: Babylon.js uses a left handed forward facing system
  21280. */
  21281. class Vector3 {
  21282. /**
  21283. * Defines the first coordinates (on X axis)
  21284. */
  21285. x: number;
  21286. /**
  21287. * Defines the second coordinates (on Y axis)
  21288. */
  21289. y: number;
  21290. /**
  21291. * Defines the third coordinates (on Z axis)
  21292. */
  21293. z: number;
  21294. private static _UpReadOnly;
  21295. /**
  21296. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21297. * @param x defines the first coordinates (on X axis)
  21298. * @param y defines the second coordinates (on Y axis)
  21299. * @param z defines the third coordinates (on Z axis)
  21300. */
  21301. constructor(
  21302. /**
  21303. * Defines the first coordinates (on X axis)
  21304. */
  21305. x?: number,
  21306. /**
  21307. * Defines the second coordinates (on Y axis)
  21308. */
  21309. y?: number,
  21310. /**
  21311. * Defines the third coordinates (on Z axis)
  21312. */
  21313. z?: number);
  21314. /**
  21315. * Creates a string representation of the Vector3
  21316. * @returns a string with the Vector3 coordinates.
  21317. */
  21318. toString(): string;
  21319. /**
  21320. * Gets the class name
  21321. * @returns the string "Vector3"
  21322. */
  21323. getClassName(): string;
  21324. /**
  21325. * Creates the Vector3 hash code
  21326. * @returns a number which tends to be unique between Vector3 instances
  21327. */
  21328. getHashCode(): number;
  21329. /**
  21330. * Creates an array containing three elements : the coordinates of the Vector3
  21331. * @returns a new array of numbers
  21332. */
  21333. asArray(): number[];
  21334. /**
  21335. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21336. * @param array defines the destination array
  21337. * @param index defines the offset in the destination array
  21338. * @returns the current Vector3
  21339. */
  21340. toArray(array: FloatArray, index?: number): Vector3;
  21341. /**
  21342. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21343. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21344. */
  21345. toQuaternion(): Quaternion;
  21346. /**
  21347. * Adds the given vector to the current Vector3
  21348. * @param otherVector defines the second operand
  21349. * @returns the current updated Vector3
  21350. */
  21351. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21352. /**
  21353. * Adds the given coordinates to the current Vector3
  21354. * @param x defines the x coordinate of the operand
  21355. * @param y defines the y coordinate of the operand
  21356. * @param z defines the z coordinate of the operand
  21357. * @returns the current updated Vector3
  21358. */
  21359. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21360. /**
  21361. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21362. * @param otherVector defines the second operand
  21363. * @returns the resulting Vector3
  21364. */
  21365. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21366. /**
  21367. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21368. * @param otherVector defines the second operand
  21369. * @param result defines the Vector3 object where to store the result
  21370. * @returns the current Vector3
  21371. */
  21372. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21373. /**
  21374. * Subtract the given vector from the current Vector3
  21375. * @param otherVector defines the second operand
  21376. * @returns the current updated Vector3
  21377. */
  21378. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21379. /**
  21380. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21381. * @param otherVector defines the second operand
  21382. * @returns the resulting Vector3
  21383. */
  21384. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21385. /**
  21386. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21387. * @param otherVector defines the second operand
  21388. * @param result defines the Vector3 object where to store the result
  21389. * @returns the current Vector3
  21390. */
  21391. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21392. /**
  21393. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21394. * @param x defines the x coordinate of the operand
  21395. * @param y defines the y coordinate of the operand
  21396. * @param z defines the z coordinate of the operand
  21397. * @returns the resulting Vector3
  21398. */
  21399. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21400. /**
  21401. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21402. * @param x defines the x coordinate of the operand
  21403. * @param y defines the y coordinate of the operand
  21404. * @param z defines the z coordinate of the operand
  21405. * @param result defines the Vector3 object where to store the result
  21406. * @returns the current Vector3
  21407. */
  21408. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21409. /**
  21410. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21411. * @returns a new Vector3
  21412. */
  21413. negate(): Vector3;
  21414. /**
  21415. * Multiplies the Vector3 coordinates by the float "scale"
  21416. * @param scale defines the multiplier factor
  21417. * @returns the current updated Vector3
  21418. */
  21419. scaleInPlace(scale: number): Vector3;
  21420. /**
  21421. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21422. * @param scale defines the multiplier factor
  21423. * @returns a new Vector3
  21424. */
  21425. scale(scale: number): Vector3;
  21426. /**
  21427. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21428. * @param scale defines the multiplier factor
  21429. * @param result defines the Vector3 object where to store the result
  21430. * @returns the current Vector3
  21431. */
  21432. scaleToRef(scale: number, result: Vector3): Vector3;
  21433. /**
  21434. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21435. * @param scale defines the scale factor
  21436. * @param result defines the Vector3 object where to store the result
  21437. * @returns the unmodified current Vector3
  21438. */
  21439. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21440. /**
  21441. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21442. * @param otherVector defines the second operand
  21443. * @returns true if both vectors are equals
  21444. */
  21445. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21446. /**
  21447. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21448. * @param otherVector defines the second operand
  21449. * @param epsilon defines the minimal distance to define values as equals
  21450. * @returns true if both vectors are distant less than epsilon
  21451. */
  21452. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21453. /**
  21454. * Returns true if the current Vector3 coordinates equals the given floats
  21455. * @param x defines the x coordinate of the operand
  21456. * @param y defines the y coordinate of the operand
  21457. * @param z defines the z coordinate of the operand
  21458. * @returns true if both vectors are equals
  21459. */
  21460. equalsToFloats(x: number, y: number, z: number): boolean;
  21461. /**
  21462. * Multiplies the current Vector3 coordinates by the given ones
  21463. * @param otherVector defines the second operand
  21464. * @returns the current updated Vector3
  21465. */
  21466. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21467. /**
  21468. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21469. * @param otherVector defines the second operand
  21470. * @returns the new Vector3
  21471. */
  21472. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21473. /**
  21474. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21475. * @param otherVector defines the second operand
  21476. * @param result defines the Vector3 object where to store the result
  21477. * @returns the current Vector3
  21478. */
  21479. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21480. /**
  21481. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21482. * @param x defines the x coordinate of the operand
  21483. * @param y defines the y coordinate of the operand
  21484. * @param z defines the z coordinate of the operand
  21485. * @returns the new Vector3
  21486. */
  21487. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21488. /**
  21489. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21490. * @param otherVector defines the second operand
  21491. * @returns the new Vector3
  21492. */
  21493. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21494. /**
  21495. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21496. * @param otherVector defines the second operand
  21497. * @param result defines the Vector3 object where to store the result
  21498. * @returns the current Vector3
  21499. */
  21500. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21501. /**
  21502. * Divides the current Vector3 coordinates by the given ones.
  21503. * @param otherVector defines the second operand
  21504. * @returns the current updated Vector3
  21505. */
  21506. divideInPlace(otherVector: Vector3): Vector3;
  21507. /**
  21508. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21509. * @param other defines the second operand
  21510. * @returns the current updated Vector3
  21511. */
  21512. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21513. /**
  21514. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21515. * @param other defines the second operand
  21516. * @returns the current updated Vector3
  21517. */
  21518. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21519. /**
  21520. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21521. * @param x defines the x coordinate of the operand
  21522. * @param y defines the y coordinate of the operand
  21523. * @param z defines the z coordinate of the operand
  21524. * @returns the current updated Vector3
  21525. */
  21526. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21527. /**
  21528. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21529. * @param x defines the x coordinate of the operand
  21530. * @param y defines the y coordinate of the operand
  21531. * @param z defines the z coordinate of the operand
  21532. * @returns the current updated Vector3
  21533. */
  21534. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21535. /**
  21536. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21537. */
  21538. readonly isNonUniform: boolean;
  21539. /**
  21540. * Gets a new Vector3 from current Vector3 floored values
  21541. * @returns a new Vector3
  21542. */
  21543. floor(): Vector3;
  21544. /**
  21545. * Gets a new Vector3 from current Vector3 floored values
  21546. * @returns a new Vector3
  21547. */
  21548. fract(): Vector3;
  21549. /**
  21550. * Gets the length of the Vector3
  21551. * @returns the length of the Vecto3
  21552. */
  21553. length(): number;
  21554. /**
  21555. * Gets the squared length of the Vector3
  21556. * @returns squared length of the Vector3
  21557. */
  21558. lengthSquared(): number;
  21559. /**
  21560. * Normalize the current Vector3.
  21561. * Please note that this is an in place operation.
  21562. * @returns the current updated Vector3
  21563. */
  21564. normalize(): Vector3;
  21565. /**
  21566. * Reorders the x y z properties of the vector in place
  21567. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21568. * @returns the current updated vector
  21569. */
  21570. reorderInPlace(order: string): this;
  21571. /**
  21572. * Rotates the vector around 0,0,0 by a quaternion
  21573. * @param quaternion the rotation quaternion
  21574. * @param result vector to store the result
  21575. * @returns the resulting vector
  21576. */
  21577. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21578. /**
  21579. * Rotates a vector around a given point
  21580. * @param quaternion the rotation quaternion
  21581. * @param point the point to rotate around
  21582. * @param result vector to store the result
  21583. * @returns the resulting vector
  21584. */
  21585. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21586. /**
  21587. * Normalize the current Vector3 with the given input length.
  21588. * Please note that this is an in place operation.
  21589. * @param len the length of the vector
  21590. * @returns the current updated Vector3
  21591. */
  21592. normalizeFromLength(len: number): Vector3;
  21593. /**
  21594. * Normalize the current Vector3 to a new vector
  21595. * @returns the new Vector3
  21596. */
  21597. normalizeToNew(): Vector3;
  21598. /**
  21599. * Normalize the current Vector3 to the reference
  21600. * @param reference define the Vector3 to update
  21601. * @returns the updated Vector3
  21602. */
  21603. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21604. /**
  21605. * Creates a new Vector3 copied from the current Vector3
  21606. * @returns the new Vector3
  21607. */
  21608. clone(): Vector3;
  21609. /**
  21610. * Copies the given vector coordinates to the current Vector3 ones
  21611. * @param source defines the source Vector3
  21612. * @returns the current updated Vector3
  21613. */
  21614. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21615. /**
  21616. * Copies the given floats to the current Vector3 coordinates
  21617. * @param x defines the x coordinate of the operand
  21618. * @param y defines the y coordinate of the operand
  21619. * @param z defines the z coordinate of the operand
  21620. * @returns the current updated Vector3
  21621. */
  21622. copyFromFloats(x: number, y: number, z: number): Vector3;
  21623. /**
  21624. * Copies the given floats to the current Vector3 coordinates
  21625. * @param x defines the x coordinate of the operand
  21626. * @param y defines the y coordinate of the operand
  21627. * @param z defines the z coordinate of the operand
  21628. * @returns the current updated Vector3
  21629. */
  21630. set(x: number, y: number, z: number): Vector3;
  21631. /**
  21632. * Copies the given float to the current Vector3 coordinates
  21633. * @param v defines the x, y and z coordinates of the operand
  21634. * @returns the current updated Vector3
  21635. */
  21636. setAll(v: number): Vector3;
  21637. /**
  21638. * Get the clip factor between two vectors
  21639. * @param vector0 defines the first operand
  21640. * @param vector1 defines the second operand
  21641. * @param axis defines the axis to use
  21642. * @param size defines the size along the axis
  21643. * @returns the clip factor
  21644. */
  21645. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21646. /**
  21647. * Get angle between two vectors
  21648. * @param vector0 angle between vector0 and vector1
  21649. * @param vector1 angle between vector0 and vector1
  21650. * @param normal direction of the normal
  21651. * @return the angle between vector0 and vector1
  21652. */
  21653. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21654. /**
  21655. * Returns a new Vector3 set from the index "offset" of the given array
  21656. * @param array defines the source array
  21657. * @param offset defines the offset in the source array
  21658. * @returns the new Vector3
  21659. */
  21660. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21661. /**
  21662. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21663. * This function is deprecated. Use FromArray instead
  21664. * @param array defines the source array
  21665. * @param offset defines the offset in the source array
  21666. * @returns the new Vector3
  21667. */
  21668. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21669. /**
  21670. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21671. * @param array defines the source array
  21672. * @param offset defines the offset in the source array
  21673. * @param result defines the Vector3 where to store the result
  21674. */
  21675. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21676. /**
  21677. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21678. * This function is deprecated. Use FromArrayToRef instead.
  21679. * @param array defines the source array
  21680. * @param offset defines the offset in the source array
  21681. * @param result defines the Vector3 where to store the result
  21682. */
  21683. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21684. /**
  21685. * Sets the given vector "result" with the given floats.
  21686. * @param x defines the x coordinate of the source
  21687. * @param y defines the y coordinate of the source
  21688. * @param z defines the z coordinate of the source
  21689. * @param result defines the Vector3 where to store the result
  21690. */
  21691. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21692. /**
  21693. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21694. * @returns a new empty Vector3
  21695. */
  21696. static Zero(): Vector3;
  21697. /**
  21698. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21699. * @returns a new unit Vector3
  21700. */
  21701. static One(): Vector3;
  21702. /**
  21703. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21704. * @returns a new up Vector3
  21705. */
  21706. static Up(): Vector3;
  21707. /**
  21708. * Gets a up Vector3 that must not be updated
  21709. */
  21710. static readonly UpReadOnly: DeepImmutable<Vector3>;
  21711. /**
  21712. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21713. * @returns a new down Vector3
  21714. */
  21715. static Down(): Vector3;
  21716. /**
  21717. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21718. * @returns a new forward Vector3
  21719. */
  21720. static Forward(): Vector3;
  21721. /**
  21722. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21723. * @returns a new forward Vector3
  21724. */
  21725. static Backward(): Vector3;
  21726. /**
  21727. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21728. * @returns a new right Vector3
  21729. */
  21730. static Right(): Vector3;
  21731. /**
  21732. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21733. * @returns a new left Vector3
  21734. */
  21735. static Left(): Vector3;
  21736. /**
  21737. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21738. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21739. * @param vector defines the Vector3 to transform
  21740. * @param transformation defines the transformation matrix
  21741. * @returns the transformed Vector3
  21742. */
  21743. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21744. /**
  21745. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21746. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21747. * @param vector defines the Vector3 to transform
  21748. * @param transformation defines the transformation matrix
  21749. * @param result defines the Vector3 where to store the result
  21750. */
  21751. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21752. /**
  21753. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21754. * This method computes tranformed coordinates only, not transformed direction vectors
  21755. * @param x define the x coordinate of the source vector
  21756. * @param y define the y coordinate of the source vector
  21757. * @param z define the z coordinate of the source vector
  21758. * @param transformation defines the transformation matrix
  21759. * @param result defines the Vector3 where to store the result
  21760. */
  21761. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21762. /**
  21763. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21764. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21765. * @param vector defines the Vector3 to transform
  21766. * @param transformation defines the transformation matrix
  21767. * @returns the new Vector3
  21768. */
  21769. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21770. /**
  21771. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21772. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21773. * @param vector defines the Vector3 to transform
  21774. * @param transformation defines the transformation matrix
  21775. * @param result defines the Vector3 where to store the result
  21776. */
  21777. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21778. /**
  21779. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21780. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21781. * @param x define the x coordinate of the source vector
  21782. * @param y define the y coordinate of the source vector
  21783. * @param z define the z coordinate of the source vector
  21784. * @param transformation defines the transformation matrix
  21785. * @param result defines the Vector3 where to store the result
  21786. */
  21787. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21788. /**
  21789. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21790. * @param value1 defines the first control point
  21791. * @param value2 defines the second control point
  21792. * @param value3 defines the third control point
  21793. * @param value4 defines the fourth control point
  21794. * @param amount defines the amount on the spline to use
  21795. * @returns the new Vector3
  21796. */
  21797. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21798. /**
  21799. * 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"
  21800. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21801. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21802. * @param value defines the current value
  21803. * @param min defines the lower range value
  21804. * @param max defines the upper range value
  21805. * @returns the new Vector3
  21806. */
  21807. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21808. /**
  21809. * 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"
  21810. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21811. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21812. * @param value defines the current value
  21813. * @param min defines the lower range value
  21814. * @param max defines the upper range value
  21815. * @param result defines the Vector3 where to store the result
  21816. */
  21817. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21818. /**
  21819. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21820. * @param value1 defines the first control point
  21821. * @param tangent1 defines the first tangent vector
  21822. * @param value2 defines the second control point
  21823. * @param tangent2 defines the second tangent vector
  21824. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21825. * @returns the new Vector3
  21826. */
  21827. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21828. /**
  21829. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21830. * @param start defines the start value
  21831. * @param end defines the end value
  21832. * @param amount max defines amount between both (between 0 and 1)
  21833. * @returns the new Vector3
  21834. */
  21835. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21836. /**
  21837. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21838. * @param start defines the start value
  21839. * @param end defines the end value
  21840. * @param amount max defines amount between both (between 0 and 1)
  21841. * @param result defines the Vector3 where to store the result
  21842. */
  21843. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21844. /**
  21845. * Returns the dot product (float) between the vectors "left" and "right"
  21846. * @param left defines the left operand
  21847. * @param right defines the right operand
  21848. * @returns the dot product
  21849. */
  21850. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21851. /**
  21852. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21853. * The cross product is then orthogonal to both "left" and "right"
  21854. * @param left defines the left operand
  21855. * @param right defines the right operand
  21856. * @returns the cross product
  21857. */
  21858. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21859. /**
  21860. * Sets the given vector "result" with the cross product of "left" and "right"
  21861. * The cross product is then orthogonal to both "left" and "right"
  21862. * @param left defines the left operand
  21863. * @param right defines the right operand
  21864. * @param result defines the Vector3 where to store the result
  21865. */
  21866. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21867. /**
  21868. * Returns a new Vector3 as the normalization of the given vector
  21869. * @param vector defines the Vector3 to normalize
  21870. * @returns the new Vector3
  21871. */
  21872. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21873. /**
  21874. * Sets the given vector "result" with the normalization of the given first vector
  21875. * @param vector defines the Vector3 to normalize
  21876. * @param result defines the Vector3 where to store the result
  21877. */
  21878. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21879. /**
  21880. * Project a Vector3 onto screen space
  21881. * @param vector defines the Vector3 to project
  21882. * @param world defines the world matrix to use
  21883. * @param transform defines the transform (view x projection) matrix to use
  21884. * @param viewport defines the screen viewport to use
  21885. * @returns the new Vector3
  21886. */
  21887. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21888. /** @hidden */
  21889. private static UnprojectFromInvertedMatrixToRef;
  21890. /**
  21891. * Unproject from screen space to object space
  21892. * @param source defines the screen space Vector3 to use
  21893. * @param viewportWidth defines the current width of the viewport
  21894. * @param viewportHeight defines the current height of the viewport
  21895. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21896. * @param transform defines the transform (view x projection) matrix to use
  21897. * @returns the new Vector3
  21898. */
  21899. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21900. /**
  21901. * Unproject from screen space to object space
  21902. * @param source defines the screen space Vector3 to use
  21903. * @param viewportWidth defines the current width of the viewport
  21904. * @param viewportHeight defines the current height of the viewport
  21905. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21906. * @param view defines the view matrix to use
  21907. * @param projection defines the projection matrix to use
  21908. * @returns the new Vector3
  21909. */
  21910. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21911. /**
  21912. * Unproject from screen space to object space
  21913. * @param source defines the screen space Vector3 to use
  21914. * @param viewportWidth defines the current width of the viewport
  21915. * @param viewportHeight defines the current height of the viewport
  21916. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21917. * @param view defines the view matrix to use
  21918. * @param projection defines the projection matrix to use
  21919. * @param result defines the Vector3 where to store the result
  21920. */
  21921. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21922. /**
  21923. * Unproject from screen space to object space
  21924. * @param sourceX defines the screen space x coordinate to use
  21925. * @param sourceY defines the screen space y coordinate to use
  21926. * @param sourceZ defines the screen space z coordinate to use
  21927. * @param viewportWidth defines the current width of the viewport
  21928. * @param viewportHeight defines the current height of the viewport
  21929. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21930. * @param view defines the view matrix to use
  21931. * @param projection defines the projection matrix to use
  21932. * @param result defines the Vector3 where to store the result
  21933. */
  21934. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21935. /**
  21936. * Unproject a ray from screen space to object space
  21937. * @param sourceX defines the screen space x coordinate to use
  21938. * @param sourceY defines the screen space y coordinate to use
  21939. * @param viewportWidth defines the current width of the viewport
  21940. * @param viewportHeight defines the current height of the viewport
  21941. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21942. * @param view defines the view matrix to use
  21943. * @param projection defines the projection matrix to use
  21944. * @param ray defines the Ray where to store the result
  21945. */
  21946. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21947. /**
  21948. * Gets the minimal coordinate values between two Vector3
  21949. * @param left defines the first operand
  21950. * @param right defines the second operand
  21951. * @returns the new Vector3
  21952. */
  21953. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21954. /**
  21955. * Gets the maximal coordinate values between two Vector3
  21956. * @param left defines the first operand
  21957. * @param right defines the second operand
  21958. * @returns the new Vector3
  21959. */
  21960. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21961. /**
  21962. * Returns the distance between the vectors "value1" and "value2"
  21963. * @param value1 defines the first operand
  21964. * @param value2 defines the second operand
  21965. * @returns the distance
  21966. */
  21967. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21968. /**
  21969. * Returns the squared distance between the vectors "value1" and "value2"
  21970. * @param value1 defines the first operand
  21971. * @param value2 defines the second operand
  21972. * @returns the squared distance
  21973. */
  21974. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21975. /**
  21976. * Returns a new Vector3 located at the center between "value1" and "value2"
  21977. * @param value1 defines the first operand
  21978. * @param value2 defines the second operand
  21979. * @returns the new Vector3
  21980. */
  21981. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21982. /**
  21983. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21984. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21985. * to something in order to rotate it from its local system to the given target system
  21986. * Note: axis1, axis2 and axis3 are normalized during this operation
  21987. * @param axis1 defines the first axis
  21988. * @param axis2 defines the second axis
  21989. * @param axis3 defines the third axis
  21990. * @returns a new Vector3
  21991. */
  21992. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21993. /**
  21994. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21995. * @param axis1 defines the first axis
  21996. * @param axis2 defines the second axis
  21997. * @param axis3 defines the third axis
  21998. * @param ref defines the Vector3 where to store the result
  21999. */
  22000. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  22001. }
  22002. /**
  22003. * Vector4 class created for EulerAngle class conversion to Quaternion
  22004. */
  22005. class Vector4 {
  22006. /** x value of the vector */
  22007. x: number;
  22008. /** y value of the vector */
  22009. y: number;
  22010. /** z value of the vector */
  22011. z: number;
  22012. /** w value of the vector */
  22013. w: number;
  22014. /**
  22015. * Creates a Vector4 object from the given floats.
  22016. * @param x x value of the vector
  22017. * @param y y value of the vector
  22018. * @param z z value of the vector
  22019. * @param w w value of the vector
  22020. */
  22021. constructor(
  22022. /** x value of the vector */
  22023. x: number,
  22024. /** y value of the vector */
  22025. y: number,
  22026. /** z value of the vector */
  22027. z: number,
  22028. /** w value of the vector */
  22029. w: number);
  22030. /**
  22031. * Returns the string with the Vector4 coordinates.
  22032. * @returns a string containing all the vector values
  22033. */
  22034. toString(): string;
  22035. /**
  22036. * Returns the string "Vector4".
  22037. * @returns "Vector4"
  22038. */
  22039. getClassName(): string;
  22040. /**
  22041. * Returns the Vector4 hash code.
  22042. * @returns a unique hash code
  22043. */
  22044. getHashCode(): number;
  22045. /**
  22046. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  22047. * @returns the resulting array
  22048. */
  22049. asArray(): number[];
  22050. /**
  22051. * Populates the given array from the given index with the Vector4 coordinates.
  22052. * @param array array to populate
  22053. * @param index index of the array to start at (default: 0)
  22054. * @returns the Vector4.
  22055. */
  22056. toArray(array: FloatArray, index?: number): Vector4;
  22057. /**
  22058. * Adds the given vector to the current Vector4.
  22059. * @param otherVector the vector to add
  22060. * @returns the updated Vector4.
  22061. */
  22062. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22063. /**
  22064. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  22065. * @param otherVector the vector to add
  22066. * @returns the resulting vector
  22067. */
  22068. add(otherVector: DeepImmutable<Vector4>): Vector4;
  22069. /**
  22070. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  22071. * @param otherVector the vector to add
  22072. * @param result the vector to store the result
  22073. * @returns the current Vector4.
  22074. */
  22075. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22076. /**
  22077. * Subtract in place the given vector from the current Vector4.
  22078. * @param otherVector the vector to subtract
  22079. * @returns the updated Vector4.
  22080. */
  22081. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22082. /**
  22083. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  22084. * @param otherVector the vector to add
  22085. * @returns the new vector with the result
  22086. */
  22087. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  22088. /**
  22089. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  22090. * @param otherVector the vector to subtract
  22091. * @param result the vector to store the result
  22092. * @returns the current Vector4.
  22093. */
  22094. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22095. /**
  22096. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22097. */
  22098. /**
  22099. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22100. * @param x value to subtract
  22101. * @param y value to subtract
  22102. * @param z value to subtract
  22103. * @param w value to subtract
  22104. * @returns new vector containing the result
  22105. */
  22106. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22107. /**
  22108. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22109. * @param x value to subtract
  22110. * @param y value to subtract
  22111. * @param z value to subtract
  22112. * @param w value to subtract
  22113. * @param result the vector to store the result in
  22114. * @returns the current Vector4.
  22115. */
  22116. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  22117. /**
  22118. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  22119. * @returns a new vector with the negated values
  22120. */
  22121. negate(): Vector4;
  22122. /**
  22123. * Multiplies the current Vector4 coordinates by scale (float).
  22124. * @param scale the number to scale with
  22125. * @returns the updated Vector4.
  22126. */
  22127. scaleInPlace(scale: number): Vector4;
  22128. /**
  22129. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22130. * @param scale the number to scale with
  22131. * @returns a new vector with the result
  22132. */
  22133. scale(scale: number): Vector4;
  22134. /**
  22135. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22136. * @param scale the number to scale with
  22137. * @param result a vector to store the result in
  22138. * @returns the current Vector4.
  22139. */
  22140. scaleToRef(scale: number, result: Vector4): Vector4;
  22141. /**
  22142. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22143. * @param scale defines the scale factor
  22144. * @param result defines the Vector4 object where to store the result
  22145. * @returns the unmodified current Vector4
  22146. */
  22147. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22148. /**
  22149. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22150. * @param otherVector the vector to compare against
  22151. * @returns true if they are equal
  22152. */
  22153. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22154. /**
  22155. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22156. * @param otherVector vector to compare against
  22157. * @param epsilon (Default: very small number)
  22158. * @returns true if they are equal
  22159. */
  22160. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22161. /**
  22162. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22163. * @param x x value to compare against
  22164. * @param y y value to compare against
  22165. * @param z z value to compare against
  22166. * @param w w value to compare against
  22167. * @returns true if equal
  22168. */
  22169. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22170. /**
  22171. * Multiplies in place the current Vector4 by the given one.
  22172. * @param otherVector vector to multiple with
  22173. * @returns the updated Vector4.
  22174. */
  22175. multiplyInPlace(otherVector: Vector4): Vector4;
  22176. /**
  22177. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22178. * @param otherVector vector to multiple with
  22179. * @returns resulting new vector
  22180. */
  22181. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22182. /**
  22183. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22184. * @param otherVector vector to multiple with
  22185. * @param result vector to store the result
  22186. * @returns the current Vector4.
  22187. */
  22188. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22189. /**
  22190. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22191. * @param x x value multiply with
  22192. * @param y y value multiply with
  22193. * @param z z value multiply with
  22194. * @param w w value multiply with
  22195. * @returns resulting new vector
  22196. */
  22197. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22198. /**
  22199. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22200. * @param otherVector vector to devide with
  22201. * @returns resulting new vector
  22202. */
  22203. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22204. /**
  22205. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22206. * @param otherVector vector to devide with
  22207. * @param result vector to store the result
  22208. * @returns the current Vector4.
  22209. */
  22210. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22211. /**
  22212. * Divides the current Vector3 coordinates by the given ones.
  22213. * @param otherVector vector to devide with
  22214. * @returns the updated Vector3.
  22215. */
  22216. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22217. /**
  22218. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22219. * @param other defines the second operand
  22220. * @returns the current updated Vector4
  22221. */
  22222. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22223. /**
  22224. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22225. * @param other defines the second operand
  22226. * @returns the current updated Vector4
  22227. */
  22228. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22229. /**
  22230. * Gets a new Vector4 from current Vector4 floored values
  22231. * @returns a new Vector4
  22232. */
  22233. floor(): Vector4;
  22234. /**
  22235. * Gets a new Vector4 from current Vector3 floored values
  22236. * @returns a new Vector4
  22237. */
  22238. fract(): Vector4;
  22239. /**
  22240. * Returns the Vector4 length (float).
  22241. * @returns the length
  22242. */
  22243. length(): number;
  22244. /**
  22245. * Returns the Vector4 squared length (float).
  22246. * @returns the length squared
  22247. */
  22248. lengthSquared(): number;
  22249. /**
  22250. * Normalizes in place the Vector4.
  22251. * @returns the updated Vector4.
  22252. */
  22253. normalize(): Vector4;
  22254. /**
  22255. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22256. * @returns this converted to a new vector3
  22257. */
  22258. toVector3(): Vector3;
  22259. /**
  22260. * Returns a new Vector4 copied from the current one.
  22261. * @returns the new cloned vector
  22262. */
  22263. clone(): Vector4;
  22264. /**
  22265. * Updates the current Vector4 with the given one coordinates.
  22266. * @param source the source vector to copy from
  22267. * @returns the updated Vector4.
  22268. */
  22269. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22270. /**
  22271. * Updates the current Vector4 coordinates with the given floats.
  22272. * @param x float to copy from
  22273. * @param y float to copy from
  22274. * @param z float to copy from
  22275. * @param w float to copy from
  22276. * @returns the updated Vector4.
  22277. */
  22278. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22279. /**
  22280. * Updates the current Vector4 coordinates with the given floats.
  22281. * @param x float to set from
  22282. * @param y float to set from
  22283. * @param z float to set from
  22284. * @param w float to set from
  22285. * @returns the updated Vector4.
  22286. */
  22287. set(x: number, y: number, z: number, w: number): Vector4;
  22288. /**
  22289. * Copies the given float to the current Vector3 coordinates
  22290. * @param v defines the x, y, z and w coordinates of the operand
  22291. * @returns the current updated Vector3
  22292. */
  22293. setAll(v: number): Vector4;
  22294. /**
  22295. * Returns a new Vector4 set from the starting index of the given array.
  22296. * @param array the array to pull values from
  22297. * @param offset the offset into the array to start at
  22298. * @returns the new vector
  22299. */
  22300. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22301. /**
  22302. * Updates the given vector "result" from the starting index of the given array.
  22303. * @param array the array to pull values from
  22304. * @param offset the offset into the array to start at
  22305. * @param result the vector to store the result in
  22306. */
  22307. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22308. /**
  22309. * Updates the given vector "result" from the starting index of the given Float32Array.
  22310. * @param array the array to pull values from
  22311. * @param offset the offset into the array to start at
  22312. * @param result the vector to store the result in
  22313. */
  22314. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22315. /**
  22316. * Updates the given vector "result" coordinates from the given floats.
  22317. * @param x float to set from
  22318. * @param y float to set from
  22319. * @param z float to set from
  22320. * @param w float to set from
  22321. * @param result the vector to the floats in
  22322. */
  22323. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22324. /**
  22325. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22326. * @returns the new vector
  22327. */
  22328. static Zero(): Vector4;
  22329. /**
  22330. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22331. * @returns the new vector
  22332. */
  22333. static One(): Vector4;
  22334. /**
  22335. * Returns a new normalized Vector4 from the given one.
  22336. * @param vector the vector to normalize
  22337. * @returns the vector
  22338. */
  22339. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22340. /**
  22341. * Updates the given vector "result" from the normalization of the given one.
  22342. * @param vector the vector to normalize
  22343. * @param result the vector to store the result in
  22344. */
  22345. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22346. /**
  22347. * Returns a vector with the minimum values from the left and right vectors
  22348. * @param left left vector to minimize
  22349. * @param right right vector to minimize
  22350. * @returns a new vector with the minimum of the left and right vector values
  22351. */
  22352. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22353. /**
  22354. * Returns a vector with the maximum values from the left and right vectors
  22355. * @param left left vector to maximize
  22356. * @param right right vector to maximize
  22357. * @returns a new vector with the maximum of the left and right vector values
  22358. */
  22359. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22360. /**
  22361. * Returns the distance (float) between the vectors "value1" and "value2".
  22362. * @param value1 value to calulate the distance between
  22363. * @param value2 value to calulate the distance between
  22364. * @return the distance between the two vectors
  22365. */
  22366. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22367. /**
  22368. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22369. * @param value1 value to calulate the distance between
  22370. * @param value2 value to calulate the distance between
  22371. * @return the distance between the two vectors squared
  22372. */
  22373. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22374. /**
  22375. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22376. * @param value1 value to calulate the center between
  22377. * @param value2 value to calulate the center between
  22378. * @return the center between the two vectors
  22379. */
  22380. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22381. /**
  22382. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22383. * This methods computes transformed normalized direction vectors only.
  22384. * @param vector the vector to transform
  22385. * @param transformation the transformation matrix to apply
  22386. * @returns the new vector
  22387. */
  22388. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22389. /**
  22390. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22391. * This methods computes transformed normalized direction vectors only.
  22392. * @param vector the vector to transform
  22393. * @param transformation the transformation matrix to apply
  22394. * @param result the vector to store the result in
  22395. */
  22396. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22397. /**
  22398. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22399. * This methods computes transformed normalized direction vectors only.
  22400. * @param x value to transform
  22401. * @param y value to transform
  22402. * @param z value to transform
  22403. * @param w value to transform
  22404. * @param transformation the transformation matrix to apply
  22405. * @param result the vector to store the results in
  22406. */
  22407. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22408. /**
  22409. * Creates a new Vector4 from a Vector3
  22410. * @param source defines the source data
  22411. * @param w defines the 4th component (default is 0)
  22412. * @returns a new Vector4
  22413. */
  22414. static FromVector3(source: Vector3, w?: number): Vector4;
  22415. }
  22416. /**
  22417. * Interface for the size containing width and height
  22418. */
  22419. interface ISize {
  22420. /**
  22421. * Width
  22422. */
  22423. width: number;
  22424. /**
  22425. * Heighht
  22426. */
  22427. height: number;
  22428. }
  22429. /**
  22430. * Size containing widht and height
  22431. */
  22432. class Size implements ISize {
  22433. /**
  22434. * Width
  22435. */
  22436. width: number;
  22437. /**
  22438. * Height
  22439. */
  22440. height: number;
  22441. /**
  22442. * Creates a Size object from the given width and height (floats).
  22443. * @param width width of the new size
  22444. * @param height height of the new size
  22445. */
  22446. constructor(width: number, height: number);
  22447. /**
  22448. * Returns a string with the Size width and height
  22449. * @returns a string with the Size width and height
  22450. */
  22451. toString(): string;
  22452. /**
  22453. * "Size"
  22454. * @returns the string "Size"
  22455. */
  22456. getClassName(): string;
  22457. /**
  22458. * Returns the Size hash code.
  22459. * @returns a hash code for a unique width and height
  22460. */
  22461. getHashCode(): number;
  22462. /**
  22463. * Updates the current size from the given one.
  22464. * @param src the given size
  22465. */
  22466. copyFrom(src: Size): void;
  22467. /**
  22468. * Updates in place the current Size from the given floats.
  22469. * @param width width of the new size
  22470. * @param height height of the new size
  22471. * @returns the updated Size.
  22472. */
  22473. copyFromFloats(width: number, height: number): Size;
  22474. /**
  22475. * Updates in place the current Size from the given floats.
  22476. * @param width width to set
  22477. * @param height height to set
  22478. * @returns the updated Size.
  22479. */
  22480. set(width: number, height: number): Size;
  22481. /**
  22482. * Multiplies the width and height by numbers
  22483. * @param w factor to multiple the width by
  22484. * @param h factor to multiple the height by
  22485. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22486. */
  22487. multiplyByFloats(w: number, h: number): Size;
  22488. /**
  22489. * Clones the size
  22490. * @returns a new Size copied from the given one.
  22491. */
  22492. clone(): Size;
  22493. /**
  22494. * True if the current Size and the given one width and height are strictly equal.
  22495. * @param other the other size to compare against
  22496. * @returns True if the current Size and the given one width and height are strictly equal.
  22497. */
  22498. equals(other: Size): boolean;
  22499. /**
  22500. * The surface of the Size : width * height (float).
  22501. */
  22502. readonly surface: number;
  22503. /**
  22504. * Create a new size of zero
  22505. * @returns a new Size set to (0.0, 0.0)
  22506. */
  22507. static Zero(): Size;
  22508. /**
  22509. * Sums the width and height of two sizes
  22510. * @param otherSize size to add to this size
  22511. * @returns a new Size set as the addition result of the current Size and the given one.
  22512. */
  22513. add(otherSize: Size): Size;
  22514. /**
  22515. * Subtracts the width and height of two
  22516. * @param otherSize size to subtract to this size
  22517. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22518. */
  22519. subtract(otherSize: Size): Size;
  22520. /**
  22521. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22522. * @param start starting size to lerp between
  22523. * @param end end size to lerp between
  22524. * @param amount amount to lerp between the start and end values
  22525. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22526. */
  22527. static Lerp(start: Size, end: Size, amount: number): Size;
  22528. }
  22529. /**
  22530. * Class used to store quaternion data
  22531. * @see https://en.wikipedia.org/wiki/Quaternion
  22532. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22533. */
  22534. class Quaternion {
  22535. /** defines the first component (0 by default) */
  22536. x: number;
  22537. /** defines the second component (0 by default) */
  22538. y: number;
  22539. /** defines the third component (0 by default) */
  22540. z: number;
  22541. /** defines the fourth component (1.0 by default) */
  22542. w: number;
  22543. /**
  22544. * Creates a new Quaternion from the given floats
  22545. * @param x defines the first component (0 by default)
  22546. * @param y defines the second component (0 by default)
  22547. * @param z defines the third component (0 by default)
  22548. * @param w defines the fourth component (1.0 by default)
  22549. */
  22550. constructor(
  22551. /** defines the first component (0 by default) */
  22552. x?: number,
  22553. /** defines the second component (0 by default) */
  22554. y?: number,
  22555. /** defines the third component (0 by default) */
  22556. z?: number,
  22557. /** defines the fourth component (1.0 by default) */
  22558. w?: number);
  22559. /**
  22560. * Gets a string representation for the current quaternion
  22561. * @returns a string with the Quaternion coordinates
  22562. */
  22563. toString(): string;
  22564. /**
  22565. * Gets the class name of the quaternion
  22566. * @returns the string "Quaternion"
  22567. */
  22568. getClassName(): string;
  22569. /**
  22570. * Gets a hash code for this quaternion
  22571. * @returns the quaternion hash code
  22572. */
  22573. getHashCode(): number;
  22574. /**
  22575. * Copy the quaternion to an array
  22576. * @returns a new array populated with 4 elements from the quaternion coordinates
  22577. */
  22578. asArray(): number[];
  22579. /**
  22580. * Check if two quaternions are equals
  22581. * @param otherQuaternion defines the second operand
  22582. * @return true if the current quaternion and the given one coordinates are strictly equals
  22583. */
  22584. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22585. /**
  22586. * Clone the current quaternion
  22587. * @returns a new quaternion copied from the current one
  22588. */
  22589. clone(): Quaternion;
  22590. /**
  22591. * Copy a quaternion to the current one
  22592. * @param other defines the other quaternion
  22593. * @returns the updated current quaternion
  22594. */
  22595. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22596. /**
  22597. * Updates the current quaternion with the given float coordinates
  22598. * @param x defines the x coordinate
  22599. * @param y defines the y coordinate
  22600. * @param z defines the z coordinate
  22601. * @param w defines the w coordinate
  22602. * @returns the updated current quaternion
  22603. */
  22604. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22605. /**
  22606. * Updates the current quaternion from the given float coordinates
  22607. * @param x defines the x coordinate
  22608. * @param y defines the y coordinate
  22609. * @param z defines the z coordinate
  22610. * @param w defines the w coordinate
  22611. * @returns the updated current quaternion
  22612. */
  22613. set(x: number, y: number, z: number, w: number): Quaternion;
  22614. /**
  22615. * Adds two quaternions
  22616. * @param other defines the second operand
  22617. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22618. */
  22619. add(other: DeepImmutable<Quaternion>): Quaternion;
  22620. /**
  22621. * Add a quaternion to the current one
  22622. * @param other defines the quaternion to add
  22623. * @returns the current quaternion
  22624. */
  22625. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22626. /**
  22627. * Subtract two quaternions
  22628. * @param other defines the second operand
  22629. * @returns a new quaternion as the subtraction result of the given one from the current one
  22630. */
  22631. subtract(other: Quaternion): Quaternion;
  22632. /**
  22633. * Multiplies the current quaternion by a scale factor
  22634. * @param value defines the scale factor
  22635. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22636. */
  22637. scale(value: number): Quaternion;
  22638. /**
  22639. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22640. * @param scale defines the scale factor
  22641. * @param result defines the Quaternion object where to store the result
  22642. * @returns the unmodified current quaternion
  22643. */
  22644. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22645. /**
  22646. * Multiplies in place the current quaternion by a scale factor
  22647. * @param value defines the scale factor
  22648. * @returns the current modified quaternion
  22649. */
  22650. scaleInPlace(value: number): Quaternion;
  22651. /**
  22652. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22653. * @param scale defines the scale factor
  22654. * @param result defines the Quaternion object where to store the result
  22655. * @returns the unmodified current quaternion
  22656. */
  22657. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22658. /**
  22659. * Multiplies two quaternions
  22660. * @param q1 defines the second operand
  22661. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22662. */
  22663. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22664. /**
  22665. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22666. * @param q1 defines the second operand
  22667. * @param result defines the target quaternion
  22668. * @returns the current quaternion
  22669. */
  22670. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22671. /**
  22672. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22673. * @param q1 defines the second operand
  22674. * @returns the currentupdated quaternion
  22675. */
  22676. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22677. /**
  22678. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22679. * @param ref defines the target quaternion
  22680. * @returns the current quaternion
  22681. */
  22682. conjugateToRef(ref: Quaternion): Quaternion;
  22683. /**
  22684. * Conjugates in place (1-q) the current quaternion
  22685. * @returns the current updated quaternion
  22686. */
  22687. conjugateInPlace(): Quaternion;
  22688. /**
  22689. * Conjugates in place (1-q) the current quaternion
  22690. * @returns a new quaternion
  22691. */
  22692. conjugate(): Quaternion;
  22693. /**
  22694. * Gets length of current quaternion
  22695. * @returns the quaternion length (float)
  22696. */
  22697. length(): number;
  22698. /**
  22699. * Normalize in place the current quaternion
  22700. * @returns the current updated quaternion
  22701. */
  22702. normalize(): Quaternion;
  22703. /**
  22704. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22705. * @param order is a reserved parameter and is ignore for now
  22706. * @returns a new Vector3 containing the Euler angles
  22707. */
  22708. toEulerAngles(order?: string): Vector3;
  22709. /**
  22710. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22711. * @param result defines the vector which will be filled with the Euler angles
  22712. * @param order is a reserved parameter and is ignore for now
  22713. * @returns the current unchanged quaternion
  22714. */
  22715. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22716. /**
  22717. * Updates the given rotation matrix with the current quaternion values
  22718. * @param result defines the target matrix
  22719. * @returns the current unchanged quaternion
  22720. */
  22721. toRotationMatrix(result: Matrix): Quaternion;
  22722. /**
  22723. * Updates the current quaternion from the given rotation matrix values
  22724. * @param matrix defines the source matrix
  22725. * @returns the current updated quaternion
  22726. */
  22727. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22728. /**
  22729. * Creates a new quaternion from a rotation matrix
  22730. * @param matrix defines the source matrix
  22731. * @returns a new quaternion created from the given rotation matrix values
  22732. */
  22733. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22734. /**
  22735. * Updates the given quaternion with the given rotation matrix values
  22736. * @param matrix defines the source matrix
  22737. * @param result defines the target quaternion
  22738. */
  22739. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22740. /**
  22741. * Returns the dot product (float) between the quaternions "left" and "right"
  22742. * @param left defines the left operand
  22743. * @param right defines the right operand
  22744. * @returns the dot product
  22745. */
  22746. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22747. /**
  22748. * Checks if the two quaternions are close to each other
  22749. * @param quat0 defines the first quaternion to check
  22750. * @param quat1 defines the second quaternion to check
  22751. * @returns true if the two quaternions are close to each other
  22752. */
  22753. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22754. /**
  22755. * Creates an empty quaternion
  22756. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22757. */
  22758. static Zero(): Quaternion;
  22759. /**
  22760. * Inverse a given quaternion
  22761. * @param q defines the source quaternion
  22762. * @returns a new quaternion as the inverted current quaternion
  22763. */
  22764. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22765. /**
  22766. * Inverse a given quaternion
  22767. * @param q defines the source quaternion
  22768. * @param result the quaternion the result will be stored in
  22769. * @returns the result quaternion
  22770. */
  22771. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22772. /**
  22773. * Creates an identity quaternion
  22774. * @returns the identity quaternion
  22775. */
  22776. static Identity(): Quaternion;
  22777. /**
  22778. * Gets a boolean indicating if the given quaternion is identity
  22779. * @param quaternion defines the quaternion to check
  22780. * @returns true if the quaternion is identity
  22781. */
  22782. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22783. /**
  22784. * Creates a quaternion from a rotation around an axis
  22785. * @param axis defines the axis to use
  22786. * @param angle defines the angle to use
  22787. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22788. */
  22789. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22790. /**
  22791. * Creates a rotation around an axis and stores it into the given quaternion
  22792. * @param axis defines the axis to use
  22793. * @param angle defines the angle to use
  22794. * @param result defines the target quaternion
  22795. * @returns the target quaternion
  22796. */
  22797. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22798. /**
  22799. * Creates a new quaternion from data stored into an array
  22800. * @param array defines the data source
  22801. * @param offset defines the offset in the source array where the data starts
  22802. * @returns a new quaternion
  22803. */
  22804. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22805. /**
  22806. * Create a quaternion from Euler rotation angles
  22807. * @param x Pitch
  22808. * @param y Yaw
  22809. * @param z Roll
  22810. * @returns the new Quaternion
  22811. */
  22812. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22813. /**
  22814. * Updates a quaternion from Euler rotation angles
  22815. * @param x Pitch
  22816. * @param y Yaw
  22817. * @param z Roll
  22818. * @param result the quaternion to store the result
  22819. * @returns the updated quaternion
  22820. */
  22821. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22822. /**
  22823. * Create a quaternion from Euler rotation vector
  22824. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22825. * @returns the new Quaternion
  22826. */
  22827. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22828. /**
  22829. * Updates a quaternion from Euler rotation vector
  22830. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22831. * @param result the quaternion to store the result
  22832. * @returns the updated quaternion
  22833. */
  22834. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22835. /**
  22836. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22837. * @param yaw defines the rotation around Y axis
  22838. * @param pitch defines the rotation around X axis
  22839. * @param roll defines the rotation around Z axis
  22840. * @returns the new quaternion
  22841. */
  22842. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22843. /**
  22844. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22845. * @param yaw defines the rotation around Y axis
  22846. * @param pitch defines the rotation around X axis
  22847. * @param roll defines the rotation around Z axis
  22848. * @param result defines the target quaternion
  22849. */
  22850. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22851. /**
  22852. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22853. * @param alpha defines the rotation around first axis
  22854. * @param beta defines the rotation around second axis
  22855. * @param gamma defines the rotation around third axis
  22856. * @returns the new quaternion
  22857. */
  22858. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22859. /**
  22860. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22861. * @param alpha defines the rotation around first axis
  22862. * @param beta defines the rotation around second axis
  22863. * @param gamma defines the rotation around third axis
  22864. * @param result defines the target quaternion
  22865. */
  22866. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22867. /**
  22868. * 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)
  22869. * @param axis1 defines the first axis
  22870. * @param axis2 defines the second axis
  22871. * @param axis3 defines the third axis
  22872. * @returns the new quaternion
  22873. */
  22874. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22875. /**
  22876. * 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
  22877. * @param axis1 defines the first axis
  22878. * @param axis2 defines the second axis
  22879. * @param axis3 defines the third axis
  22880. * @param ref defines the target quaternion
  22881. */
  22882. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22883. /**
  22884. * Interpolates between two quaternions
  22885. * @param left defines first quaternion
  22886. * @param right defines second quaternion
  22887. * @param amount defines the gradient to use
  22888. * @returns the new interpolated quaternion
  22889. */
  22890. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22891. /**
  22892. * Interpolates between two quaternions and stores it into a target quaternion
  22893. * @param left defines first quaternion
  22894. * @param right defines second quaternion
  22895. * @param amount defines the gradient to use
  22896. * @param result defines the target quaternion
  22897. */
  22898. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22899. /**
  22900. * Interpolate between two quaternions using Hermite interpolation
  22901. * @param value1 defines first quaternion
  22902. * @param tangent1 defines the incoming tangent
  22903. * @param value2 defines second quaternion
  22904. * @param tangent2 defines the outgoing tangent
  22905. * @param amount defines the target quaternion
  22906. * @returns the new interpolated quaternion
  22907. */
  22908. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22909. }
  22910. /**
  22911. * Class used to store matrix data (4x4)
  22912. */
  22913. class Matrix {
  22914. private static _updateFlagSeed;
  22915. private static _identityReadOnly;
  22916. private _isIdentity;
  22917. private _isIdentityDirty;
  22918. private _isIdentity3x2;
  22919. private _isIdentity3x2Dirty;
  22920. /**
  22921. * Gets the update flag of the matrix which is an unique number for the matrix.
  22922. * It will be incremented every time the matrix data change.
  22923. * You can use it to speed the comparison between two versions of the same matrix.
  22924. */
  22925. updateFlag: number;
  22926. private readonly _m;
  22927. /**
  22928. * Gets the internal data of the matrix
  22929. */
  22930. readonly m: DeepImmutable<Float32Array>;
  22931. /** @hidden */
  22932. _markAsUpdated(): void;
  22933. /** @hidden */
  22934. private _updateIdentityStatus;
  22935. /**
  22936. * Creates an empty matrix (filled with zeros)
  22937. */
  22938. constructor();
  22939. /**
  22940. * Check if the current matrix is identity
  22941. * @returns true is the matrix is the identity matrix
  22942. */
  22943. isIdentity(): boolean;
  22944. /**
  22945. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22946. * @returns true is the matrix is the identity matrix
  22947. */
  22948. isIdentityAs3x2(): boolean;
  22949. /**
  22950. * Gets the determinant of the matrix
  22951. * @returns the matrix determinant
  22952. */
  22953. determinant(): number;
  22954. /**
  22955. * Returns the matrix as a Float32Array
  22956. * @returns the matrix underlying array
  22957. */
  22958. toArray(): DeepImmutable<Float32Array>;
  22959. /**
  22960. * Returns the matrix as a Float32Array
  22961. * @returns the matrix underlying array.
  22962. */
  22963. asArray(): DeepImmutable<Float32Array>;
  22964. /**
  22965. * Inverts the current matrix in place
  22966. * @returns the current inverted matrix
  22967. */
  22968. invert(): Matrix;
  22969. /**
  22970. * Sets all the matrix elements to zero
  22971. * @returns the current matrix
  22972. */
  22973. reset(): Matrix;
  22974. /**
  22975. * Adds the current matrix with a second one
  22976. * @param other defines the matrix to add
  22977. * @returns a new matrix as the addition of the current matrix and the given one
  22978. */
  22979. add(other: DeepImmutable<Matrix>): Matrix;
  22980. /**
  22981. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22982. * @param other defines the matrix to add
  22983. * @param result defines the target matrix
  22984. * @returns the current matrix
  22985. */
  22986. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22987. /**
  22988. * Adds in place the given matrix to the current matrix
  22989. * @param other defines the second operand
  22990. * @returns the current updated matrix
  22991. */
  22992. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22993. /**
  22994. * Sets the given matrix to the current inverted Matrix
  22995. * @param other defines the target matrix
  22996. * @returns the unmodified current matrix
  22997. */
  22998. invertToRef(other: Matrix): Matrix;
  22999. /**
  23000. * add a value at the specified position in the current Matrix
  23001. * @param index the index of the value within the matrix. between 0 and 15.
  23002. * @param value the value to be added
  23003. * @returns the current updated matrix
  23004. */
  23005. addAtIndex(index: number, value: number): Matrix;
  23006. /**
  23007. * mutiply the specified position in the current Matrix by a value
  23008. * @param index the index of the value within the matrix. between 0 and 15.
  23009. * @param value the value to be added
  23010. * @returns the current updated matrix
  23011. */
  23012. multiplyAtIndex(index: number, value: number): Matrix;
  23013. /**
  23014. * Inserts the translation vector (using 3 floats) in the current matrix
  23015. * @param x defines the 1st component of the translation
  23016. * @param y defines the 2nd component of the translation
  23017. * @param z defines the 3rd component of the translation
  23018. * @returns the current updated matrix
  23019. */
  23020. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  23021. /**
  23022. * Inserts the translation vector in the current matrix
  23023. * @param vector3 defines the translation to insert
  23024. * @returns the current updated matrix
  23025. */
  23026. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  23027. /**
  23028. * Gets the translation value of the current matrix
  23029. * @returns a new Vector3 as the extracted translation from the matrix
  23030. */
  23031. getTranslation(): Vector3;
  23032. /**
  23033. * Fill a Vector3 with the extracted translation from the matrix
  23034. * @param result defines the Vector3 where to store the translation
  23035. * @returns the current matrix
  23036. */
  23037. getTranslationToRef(result: Vector3): Matrix;
  23038. /**
  23039. * Remove rotation and scaling part from the matrix
  23040. * @returns the updated matrix
  23041. */
  23042. removeRotationAndScaling(): Matrix;
  23043. /**
  23044. * Multiply two matrices
  23045. * @param other defines the second operand
  23046. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  23047. */
  23048. multiply(other: DeepImmutable<Matrix>): Matrix;
  23049. /**
  23050. * Copy the current matrix from the given one
  23051. * @param other defines the source matrix
  23052. * @returns the current updated matrix
  23053. */
  23054. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  23055. /**
  23056. * Populates the given array from the starting index with the current matrix values
  23057. * @param array defines the target array
  23058. * @param offset defines the offset in the target array where to start storing values
  23059. * @returns the current matrix
  23060. */
  23061. copyToArray(array: Float32Array, offset?: number): Matrix;
  23062. /**
  23063. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  23064. * @param other defines the second operand
  23065. * @param result defines the matrix where to store the multiplication
  23066. * @returns the current matrix
  23067. */
  23068. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  23069. /**
  23070. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  23071. * @param other defines the second operand
  23072. * @param result defines the array where to store the multiplication
  23073. * @param offset defines the offset in the target array where to start storing values
  23074. * @returns the current matrix
  23075. */
  23076. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  23077. /**
  23078. * Check equality between this matrix and a second one
  23079. * @param value defines the second matrix to compare
  23080. * @returns true is the current matrix and the given one values are strictly equal
  23081. */
  23082. equals(value: DeepImmutable<Matrix>): boolean;
  23083. /**
  23084. * Clone the current matrix
  23085. * @returns a new matrix from the current matrix
  23086. */
  23087. clone(): Matrix;
  23088. /**
  23089. * Returns the name of the current matrix class
  23090. * @returns the string "Matrix"
  23091. */
  23092. getClassName(): string;
  23093. /**
  23094. * Gets the hash code of the current matrix
  23095. * @returns the hash code
  23096. */
  23097. getHashCode(): number;
  23098. /**
  23099. * Decomposes the current Matrix into a translation, rotation and scaling components
  23100. * @param scale defines the scale vector3 given as a reference to update
  23101. * @param rotation defines the rotation quaternion given as a reference to update
  23102. * @param translation defines the translation vector3 given as a reference to update
  23103. * @returns true if operation was successful
  23104. */
  23105. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  23106. /**
  23107. * Gets specific row of the matrix
  23108. * @param index defines the number of the row to get
  23109. * @returns the index-th row of the current matrix as a new Vector4
  23110. */
  23111. getRow(index: number): Nullable<Vector4>;
  23112. /**
  23113. * Sets the index-th row of the current matrix to the vector4 values
  23114. * @param index defines the number of the row to set
  23115. * @param row defines the target vector4
  23116. * @returns the updated current matrix
  23117. */
  23118. setRow(index: number, row: Vector4): Matrix;
  23119. /**
  23120. * Compute the transpose of the matrix
  23121. * @returns the new transposed matrix
  23122. */
  23123. transpose(): Matrix;
  23124. /**
  23125. * Compute the transpose of the matrix and store it in a given matrix
  23126. * @param result defines the target matrix
  23127. * @returns the current matrix
  23128. */
  23129. transposeToRef(result: Matrix): Matrix;
  23130. /**
  23131. * Sets the index-th row of the current matrix with the given 4 x float values
  23132. * @param index defines the row index
  23133. * @param x defines the x component to set
  23134. * @param y defines the y component to set
  23135. * @param z defines the z component to set
  23136. * @param w defines the w component to set
  23137. * @returns the updated current matrix
  23138. */
  23139. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23140. /**
  23141. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23142. * @param scale defines the scale factor
  23143. * @returns a new matrix
  23144. */
  23145. scale(scale: number): Matrix;
  23146. /**
  23147. * Scale the current matrix values by a factor to a given result matrix
  23148. * @param scale defines the scale factor
  23149. * @param result defines the matrix to store the result
  23150. * @returns the current matrix
  23151. */
  23152. scaleToRef(scale: number, result: Matrix): Matrix;
  23153. /**
  23154. * Scale the current matrix values by a factor and add the result to a given matrix
  23155. * @param scale defines the scale factor
  23156. * @param result defines the Matrix to store the result
  23157. * @returns the current matrix
  23158. */
  23159. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23160. /**
  23161. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23162. * @param ref matrix to store the result
  23163. */
  23164. toNormalMatrix(ref: Matrix): void;
  23165. /**
  23166. * Gets only rotation part of the current matrix
  23167. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23168. */
  23169. getRotationMatrix(): Matrix;
  23170. /**
  23171. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23172. * @param result defines the target matrix to store data to
  23173. * @returns the current matrix
  23174. */
  23175. getRotationMatrixToRef(result: Matrix): Matrix;
  23176. /**
  23177. * Toggles model matrix from being right handed to left handed in place and vice versa
  23178. */
  23179. toggleModelMatrixHandInPlace(): void;
  23180. /**
  23181. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23182. */
  23183. toggleProjectionMatrixHandInPlace(): void;
  23184. /**
  23185. * Creates a matrix from an array
  23186. * @param array defines the source array
  23187. * @param offset defines an offset in the source array
  23188. * @returns a new Matrix set from the starting index of the given array
  23189. */
  23190. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23191. /**
  23192. * Copy the content of an array into a given matrix
  23193. * @param array defines the source array
  23194. * @param offset defines an offset in the source array
  23195. * @param result defines the target matrix
  23196. */
  23197. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23198. /**
  23199. * Stores an array into a matrix after having multiplied each component by a given factor
  23200. * @param array defines the source array
  23201. * @param offset defines the offset in the source array
  23202. * @param scale defines the scaling factor
  23203. * @param result defines the target matrix
  23204. */
  23205. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23206. /**
  23207. * Gets an identity matrix that must not be updated
  23208. */
  23209. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23210. /**
  23211. * Stores a list of values (16) inside a given matrix
  23212. * @param initialM11 defines 1st value of 1st row
  23213. * @param initialM12 defines 2nd value of 1st row
  23214. * @param initialM13 defines 3rd value of 1st row
  23215. * @param initialM14 defines 4th value of 1st row
  23216. * @param initialM21 defines 1st value of 2nd row
  23217. * @param initialM22 defines 2nd value of 2nd row
  23218. * @param initialM23 defines 3rd value of 2nd row
  23219. * @param initialM24 defines 4th value of 2nd row
  23220. * @param initialM31 defines 1st value of 3rd row
  23221. * @param initialM32 defines 2nd value of 3rd row
  23222. * @param initialM33 defines 3rd value of 3rd row
  23223. * @param initialM34 defines 4th value of 3rd row
  23224. * @param initialM41 defines 1st value of 4th row
  23225. * @param initialM42 defines 2nd value of 4th row
  23226. * @param initialM43 defines 3rd value of 4th row
  23227. * @param initialM44 defines 4th value of 4th row
  23228. * @param result defines the target matrix
  23229. */
  23230. 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;
  23231. /**
  23232. * Creates new matrix from a list of values (16)
  23233. * @param initialM11 defines 1st value of 1st row
  23234. * @param initialM12 defines 2nd value of 1st row
  23235. * @param initialM13 defines 3rd value of 1st row
  23236. * @param initialM14 defines 4th value of 1st row
  23237. * @param initialM21 defines 1st value of 2nd row
  23238. * @param initialM22 defines 2nd value of 2nd row
  23239. * @param initialM23 defines 3rd value of 2nd row
  23240. * @param initialM24 defines 4th value of 2nd row
  23241. * @param initialM31 defines 1st value of 3rd row
  23242. * @param initialM32 defines 2nd value of 3rd row
  23243. * @param initialM33 defines 3rd value of 3rd row
  23244. * @param initialM34 defines 4th value of 3rd row
  23245. * @param initialM41 defines 1st value of 4th row
  23246. * @param initialM42 defines 2nd value of 4th row
  23247. * @param initialM43 defines 3rd value of 4th row
  23248. * @param initialM44 defines 4th value of 4th row
  23249. * @returns the new matrix
  23250. */
  23251. 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;
  23252. /**
  23253. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23254. * @param scale defines the scale vector3
  23255. * @param rotation defines the rotation quaternion
  23256. * @param translation defines the translation vector3
  23257. * @returns a new matrix
  23258. */
  23259. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23260. /**
  23261. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23262. * @param scale defines the scale vector3
  23263. * @param rotation defines the rotation quaternion
  23264. * @param translation defines the translation vector3
  23265. * @param result defines the target matrix
  23266. */
  23267. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23268. /**
  23269. * Creates a new identity matrix
  23270. * @returns a new identity matrix
  23271. */
  23272. static Identity(): Matrix;
  23273. /**
  23274. * Creates a new identity matrix and stores the result in a given matrix
  23275. * @param result defines the target matrix
  23276. */
  23277. static IdentityToRef(result: Matrix): void;
  23278. /**
  23279. * Creates a new zero matrix
  23280. * @returns a new zero matrix
  23281. */
  23282. static Zero(): Matrix;
  23283. /**
  23284. * Creates a new rotation matrix for "angle" radians around the X axis
  23285. * @param angle defines the angle (in radians) to use
  23286. * @return the new matrix
  23287. */
  23288. static RotationX(angle: number): Matrix;
  23289. /**
  23290. * Creates a new matrix as the invert of a given matrix
  23291. * @param source defines the source matrix
  23292. * @returns the new matrix
  23293. */
  23294. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23295. /**
  23296. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23297. * @param angle defines the angle (in radians) to use
  23298. * @param result defines the target matrix
  23299. */
  23300. static RotationXToRef(angle: number, result: Matrix): void;
  23301. /**
  23302. * Creates a new rotation matrix for "angle" radians around the Y axis
  23303. * @param angle defines the angle (in radians) to use
  23304. * @return the new matrix
  23305. */
  23306. static RotationY(angle: number): Matrix;
  23307. /**
  23308. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23309. * @param angle defines the angle (in radians) to use
  23310. * @param result defines the target matrix
  23311. */
  23312. static RotationYToRef(angle: number, result: Matrix): void;
  23313. /**
  23314. * Creates a new rotation matrix for "angle" radians around the Z axis
  23315. * @param angle defines the angle (in radians) to use
  23316. * @return the new matrix
  23317. */
  23318. static RotationZ(angle: number): Matrix;
  23319. /**
  23320. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23321. * @param angle defines the angle (in radians) to use
  23322. * @param result defines the target matrix
  23323. */
  23324. static RotationZToRef(angle: number, result: Matrix): void;
  23325. /**
  23326. * Creates a new rotation matrix for "angle" radians around the given axis
  23327. * @param axis defines the axis to use
  23328. * @param angle defines the angle (in radians) to use
  23329. * @return the new matrix
  23330. */
  23331. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23332. /**
  23333. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23334. * @param axis defines the axis to use
  23335. * @param angle defines the angle (in radians) to use
  23336. * @param result defines the target matrix
  23337. */
  23338. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23339. /**
  23340. * Creates a rotation matrix
  23341. * @param yaw defines the yaw angle in radians (Y axis)
  23342. * @param pitch defines the pitch angle in radians (X axis)
  23343. * @param roll defines the roll angle in radians (X axis)
  23344. * @returns the new rotation matrix
  23345. */
  23346. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23347. /**
  23348. * Creates a rotation matrix and stores it in a given matrix
  23349. * @param yaw defines the yaw angle in radians (Y axis)
  23350. * @param pitch defines the pitch angle in radians (X axis)
  23351. * @param roll defines the roll angle in radians (X axis)
  23352. * @param result defines the target matrix
  23353. */
  23354. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23355. /**
  23356. * Creates a scaling matrix
  23357. * @param x defines the scale factor on X axis
  23358. * @param y defines the scale factor on Y axis
  23359. * @param z defines the scale factor on Z axis
  23360. * @returns the new matrix
  23361. */
  23362. static Scaling(x: number, y: number, z: number): Matrix;
  23363. /**
  23364. * Creates a scaling matrix and stores it in a given matrix
  23365. * @param x defines the scale factor on X axis
  23366. * @param y defines the scale factor on Y axis
  23367. * @param z defines the scale factor on Z axis
  23368. * @param result defines the target matrix
  23369. */
  23370. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23371. /**
  23372. * Creates a translation matrix
  23373. * @param x defines the translation on X axis
  23374. * @param y defines the translation on Y axis
  23375. * @param z defines the translationon Z axis
  23376. * @returns the new matrix
  23377. */
  23378. static Translation(x: number, y: number, z: number): Matrix;
  23379. /**
  23380. * Creates a translation matrix and stores it in a given matrix
  23381. * @param x defines the translation on X axis
  23382. * @param y defines the translation on Y axis
  23383. * @param z defines the translationon Z axis
  23384. * @param result defines the target matrix
  23385. */
  23386. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23387. /**
  23388. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23389. * @param startValue defines the start value
  23390. * @param endValue defines the end value
  23391. * @param gradient defines the gradient factor
  23392. * @returns the new matrix
  23393. */
  23394. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23395. /**
  23396. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23397. * @param startValue defines the start value
  23398. * @param endValue defines the end value
  23399. * @param gradient defines the gradient factor
  23400. * @param result defines the Matrix object where to store data
  23401. */
  23402. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23403. /**
  23404. * Builds a new matrix whose values are computed by:
  23405. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23406. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23407. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23408. * @param startValue defines the first matrix
  23409. * @param endValue defines the second matrix
  23410. * @param gradient defines the gradient between the two matrices
  23411. * @returns the new matrix
  23412. */
  23413. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23414. /**
  23415. * Update a matrix to values which are computed by:
  23416. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23417. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23418. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23419. * @param startValue defines the first matrix
  23420. * @param endValue defines the second matrix
  23421. * @param gradient defines the gradient between the two matrices
  23422. * @param result defines the target matrix
  23423. */
  23424. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23425. /**
  23426. * 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"
  23427. * This function works in left handed mode
  23428. * @param eye defines the final position of the entity
  23429. * @param target defines where the entity should look at
  23430. * @param up defines the up vector for the entity
  23431. * @returns the new matrix
  23432. */
  23433. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23434. /**
  23435. * 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".
  23436. * This function works in left handed mode
  23437. * @param eye defines the final position of the entity
  23438. * @param target defines where the entity should look at
  23439. * @param up defines the up vector for the entity
  23440. * @param result defines the target matrix
  23441. */
  23442. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23443. /**
  23444. * 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"
  23445. * This function works in right handed mode
  23446. * @param eye defines the final position of the entity
  23447. * @param target defines where the entity should look at
  23448. * @param up defines the up vector for the entity
  23449. * @returns the new matrix
  23450. */
  23451. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23452. /**
  23453. * 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".
  23454. * This function works in right handed mode
  23455. * @param eye defines the final position of the entity
  23456. * @param target defines where the entity should look at
  23457. * @param up defines the up vector for the entity
  23458. * @param result defines the target matrix
  23459. */
  23460. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23461. /**
  23462. * Create a left-handed orthographic projection matrix
  23463. * @param width defines the viewport width
  23464. * @param height defines the viewport height
  23465. * @param znear defines the near clip plane
  23466. * @param zfar defines the far clip plane
  23467. * @returns a new matrix as a left-handed orthographic projection matrix
  23468. */
  23469. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23470. /**
  23471. * Store a left-handed orthographic projection to a given matrix
  23472. * @param width defines the viewport width
  23473. * @param height defines the viewport height
  23474. * @param znear defines the near clip plane
  23475. * @param zfar defines the far clip plane
  23476. * @param result defines the target matrix
  23477. */
  23478. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23479. /**
  23480. * Create a left-handed orthographic projection matrix
  23481. * @param left defines the viewport left coordinate
  23482. * @param right defines the viewport right coordinate
  23483. * @param bottom defines the viewport bottom coordinate
  23484. * @param top defines the viewport top coordinate
  23485. * @param znear defines the near clip plane
  23486. * @param zfar defines the far clip plane
  23487. * @returns a new matrix as a left-handed orthographic projection matrix
  23488. */
  23489. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23490. /**
  23491. * Stores a left-handed orthographic projection into a given matrix
  23492. * @param left defines the viewport left coordinate
  23493. * @param right defines the viewport right coordinate
  23494. * @param bottom defines the viewport bottom coordinate
  23495. * @param top defines the viewport top coordinate
  23496. * @param znear defines the near clip plane
  23497. * @param zfar defines the far clip plane
  23498. * @param result defines the target matrix
  23499. */
  23500. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23501. /**
  23502. * Creates a right-handed orthographic projection matrix
  23503. * @param left defines the viewport left coordinate
  23504. * @param right defines the viewport right coordinate
  23505. * @param bottom defines the viewport bottom coordinate
  23506. * @param top defines the viewport top coordinate
  23507. * @param znear defines the near clip plane
  23508. * @param zfar defines the far clip plane
  23509. * @returns a new matrix as a right-handed orthographic projection matrix
  23510. */
  23511. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23512. /**
  23513. * Stores a right-handed orthographic projection into a given matrix
  23514. * @param left defines the viewport left coordinate
  23515. * @param right defines the viewport right coordinate
  23516. * @param bottom defines the viewport bottom coordinate
  23517. * @param top defines the viewport top coordinate
  23518. * @param znear defines the near clip plane
  23519. * @param zfar defines the far clip plane
  23520. * @param result defines the target matrix
  23521. */
  23522. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23523. /**
  23524. * Creates a left-handed perspective projection matrix
  23525. * @param width defines the viewport width
  23526. * @param height defines the viewport height
  23527. * @param znear defines the near clip plane
  23528. * @param zfar defines the far clip plane
  23529. * @returns a new matrix as a left-handed perspective projection matrix
  23530. */
  23531. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23532. /**
  23533. * Creates a left-handed perspective projection matrix
  23534. * @param fov defines the horizontal field of view
  23535. * @param aspect defines the aspect ratio
  23536. * @param znear defines the near clip plane
  23537. * @param zfar defines the far clip plane
  23538. * @returns a new matrix as a left-handed perspective projection matrix
  23539. */
  23540. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23541. /**
  23542. * Stores a left-handed perspective projection into a given matrix
  23543. * @param fov defines the horizontal field of view
  23544. * @param aspect defines the aspect ratio
  23545. * @param znear defines the near clip plane
  23546. * @param zfar defines the far clip plane
  23547. * @param result defines the target matrix
  23548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23549. */
  23550. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23551. /**
  23552. * Creates a right-handed perspective projection matrix
  23553. * @param fov defines the horizontal field of view
  23554. * @param aspect defines the aspect ratio
  23555. * @param znear defines the near clip plane
  23556. * @param zfar defines the far clip plane
  23557. * @returns a new matrix as a right-handed perspective projection matrix
  23558. */
  23559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23560. /**
  23561. * Stores a right-handed perspective projection into a given matrix
  23562. * @param fov defines the horizontal field of view
  23563. * @param aspect defines the aspect ratio
  23564. * @param znear defines the near clip plane
  23565. * @param zfar defines the far clip plane
  23566. * @param result defines the target matrix
  23567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23568. */
  23569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23570. /**
  23571. * Stores a perspective projection for WebVR info a given matrix
  23572. * @param fov defines the field of view
  23573. * @param znear defines the near clip plane
  23574. * @param zfar defines the far clip plane
  23575. * @param result defines the target matrix
  23576. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23577. */
  23578. static PerspectiveFovWebVRToRef(fov: {
  23579. upDegrees: number;
  23580. downDegrees: number;
  23581. leftDegrees: number;
  23582. rightDegrees: number;
  23583. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23584. /**
  23585. * Computes a complete transformation matrix
  23586. * @param viewport defines the viewport to use
  23587. * @param world defines the world matrix
  23588. * @param view defines the view matrix
  23589. * @param projection defines the projection matrix
  23590. * @param zmin defines the near clip plane
  23591. * @param zmax defines the far clip plane
  23592. * @returns the transformation matrix
  23593. */
  23594. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23595. /**
  23596. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23597. * @param matrix defines the matrix to use
  23598. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23599. */
  23600. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23601. /**
  23602. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23603. * @param matrix defines the matrix to use
  23604. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23605. */
  23606. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23607. /**
  23608. * Compute the transpose of a given matrix
  23609. * @param matrix defines the matrix to transpose
  23610. * @returns the new matrix
  23611. */
  23612. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23613. /**
  23614. * Compute the transpose of a matrix and store it in a target matrix
  23615. * @param matrix defines the matrix to transpose
  23616. * @param result defines the target matrix
  23617. */
  23618. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23619. /**
  23620. * Computes a reflection matrix from a plane
  23621. * @param plane defines the reflection plane
  23622. * @returns a new matrix
  23623. */
  23624. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23625. /**
  23626. * Computes a reflection matrix from a plane
  23627. * @param plane defines the reflection plane
  23628. * @param result defines the target matrix
  23629. */
  23630. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23631. /**
  23632. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23633. * @param xaxis defines the value of the 1st axis
  23634. * @param yaxis defines the value of the 2nd axis
  23635. * @param zaxis defines the value of the 3rd axis
  23636. * @param result defines the target matrix
  23637. */
  23638. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23639. /**
  23640. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23641. * @param quat defines the quaternion to use
  23642. * @param result defines the target matrix
  23643. */
  23644. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23645. }
  23646. /**
  23647. * Represens a plane by the equation ax + by + cz + d = 0
  23648. */
  23649. class Plane {
  23650. /**
  23651. * Normal of the plane (a,b,c)
  23652. */
  23653. normal: Vector3;
  23654. /**
  23655. * d component of the plane
  23656. */
  23657. d: number;
  23658. /**
  23659. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23660. * @param a a component of the plane
  23661. * @param b b component of the plane
  23662. * @param c c component of the plane
  23663. * @param d d component of the plane
  23664. */
  23665. constructor(a: number, b: number, c: number, d: number);
  23666. /**
  23667. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23668. */
  23669. asArray(): number[];
  23670. /**
  23671. * @returns a new plane copied from the current Plane.
  23672. */
  23673. clone(): Plane;
  23674. /**
  23675. * @returns the string "Plane".
  23676. */
  23677. getClassName(): string;
  23678. /**
  23679. * @returns the Plane hash code.
  23680. */
  23681. getHashCode(): number;
  23682. /**
  23683. * Normalize the current Plane in place.
  23684. * @returns the updated Plane.
  23685. */
  23686. normalize(): Plane;
  23687. /**
  23688. * Applies a transformation the plane and returns the result
  23689. * @param transformation the transformation matrix to be applied to the plane
  23690. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23691. */
  23692. transform(transformation: DeepImmutable<Matrix>): Plane;
  23693. /**
  23694. * Calcualtte the dot product between the point and the plane normal
  23695. * @param point point to calculate the dot product with
  23696. * @returns the dot product (float) of the point coordinates and the plane normal.
  23697. */
  23698. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23699. /**
  23700. * Updates the current Plane from the plane defined by the three given points.
  23701. * @param point1 one of the points used to contruct the plane
  23702. * @param point2 one of the points used to contruct the plane
  23703. * @param point3 one of the points used to contruct the plane
  23704. * @returns the updated Plane.
  23705. */
  23706. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23707. /**
  23708. * Checks if the plane is facing a given direction
  23709. * @param direction the direction to check if the plane is facing
  23710. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23711. * @returns True is the vector "direction" is the same side than the plane normal.
  23712. */
  23713. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23714. /**
  23715. * Calculates the distance to a point
  23716. * @param point point to calculate distance to
  23717. * @returns the signed distance (float) from the given point to the Plane.
  23718. */
  23719. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23720. /**
  23721. * Creates a plane from an array
  23722. * @param array the array to create a plane from
  23723. * @returns a new Plane from the given array.
  23724. */
  23725. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23726. /**
  23727. * Creates a plane from three points
  23728. * @param point1 point used to create the plane
  23729. * @param point2 point used to create the plane
  23730. * @param point3 point used to create the plane
  23731. * @returns a new Plane defined by the three given points.
  23732. */
  23733. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23734. /**
  23735. * Creates a plane from an origin point and a normal
  23736. * @param origin origin of the plane to be constructed
  23737. * @param normal normal of the plane to be constructed
  23738. * @returns a new Plane the normal vector to this plane at the given origin point.
  23739. * Note : the vector "normal" is updated because normalized.
  23740. */
  23741. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23742. /**
  23743. * Calculates the distance from a plane and a point
  23744. * @param origin origin of the plane to be constructed
  23745. * @param normal normal of the plane to be constructed
  23746. * @param point point to calculate distance to
  23747. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23748. */
  23749. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23750. }
  23751. /**
  23752. * Class used to represent a viewport on screen
  23753. */
  23754. class Viewport {
  23755. /** viewport left coordinate */
  23756. x: number;
  23757. /** viewport top coordinate */
  23758. y: number;
  23759. /**viewport width */
  23760. width: number;
  23761. /** viewport height */
  23762. height: number;
  23763. /**
  23764. * Creates a Viewport object located at (x, y) and sized (width, height)
  23765. * @param x defines viewport left coordinate
  23766. * @param y defines viewport top coordinate
  23767. * @param width defines the viewport width
  23768. * @param height defines the viewport height
  23769. */
  23770. constructor(
  23771. /** viewport left coordinate */
  23772. x: number,
  23773. /** viewport top coordinate */
  23774. y: number,
  23775. /**viewport width */
  23776. width: number,
  23777. /** viewport height */
  23778. height: number);
  23779. /**
  23780. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23781. * @param renderWidthOrEngine defines either an engine or the rendering width
  23782. * @param renderHeight defines the rendering height
  23783. * @returns a new Viewport
  23784. */
  23785. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23786. /**
  23787. * Returns a new Viewport copied from the current one
  23788. * @returns a new Viewport
  23789. */
  23790. clone(): Viewport;
  23791. }
  23792. /**
  23793. * Reprasents a camera frustum
  23794. */
  23795. class Frustum {
  23796. /**
  23797. * Gets the planes representing the frustum
  23798. * @param transform matrix to be applied to the returned planes
  23799. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23800. */
  23801. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23802. /**
  23803. * Gets the near frustum plane transformed by the transform matrix
  23804. * @param transform transformation matrix to be applied to the resulting frustum plane
  23805. * @param frustumPlane the resuling frustum plane
  23806. */
  23807. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23808. /**
  23809. * Gets the far frustum plane transformed by the transform matrix
  23810. * @param transform transformation matrix to be applied to the resulting frustum plane
  23811. * @param frustumPlane the resuling frustum plane
  23812. */
  23813. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23814. /**
  23815. * Gets the left frustum plane transformed by the transform matrix
  23816. * @param transform transformation matrix to be applied to the resulting frustum plane
  23817. * @param frustumPlane the resuling frustum plane
  23818. */
  23819. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23820. /**
  23821. * Gets the right frustum plane transformed by the transform matrix
  23822. * @param transform transformation matrix to be applied to the resulting frustum plane
  23823. * @param frustumPlane the resuling frustum plane
  23824. */
  23825. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23826. /**
  23827. * Gets the top frustum plane transformed by the transform matrix
  23828. * @param transform transformation matrix to be applied to the resulting frustum plane
  23829. * @param frustumPlane the resuling frustum plane
  23830. */
  23831. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23832. /**
  23833. * Gets the bottom frustum plane transformed by the transform matrix
  23834. * @param transform transformation matrix to be applied to the resulting frustum plane
  23835. * @param frustumPlane the resuling frustum plane
  23836. */
  23837. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23838. /**
  23839. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23840. * @param transform transformation matrix to be applied to the resulting frustum planes
  23841. * @param frustumPlanes the resuling frustum planes
  23842. */
  23843. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23844. }
  23845. /** Defines supported spaces */
  23846. enum Space {
  23847. /** Local (object) space */
  23848. LOCAL = 0,
  23849. /** World space */
  23850. WORLD = 1,
  23851. /** Bone space */
  23852. BONE = 2
  23853. }
  23854. /** Defines the 3 main axes */
  23855. class Axis {
  23856. /** X axis */
  23857. static X: Vector3;
  23858. /** Y axis */
  23859. static Y: Vector3;
  23860. /** Z axis */
  23861. static Z: Vector3;
  23862. }
  23863. /** Class used to represent a Bezier curve */
  23864. class BezierCurve {
  23865. /**
  23866. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23867. * @param t defines the time
  23868. * @param x1 defines the left coordinate on X axis
  23869. * @param y1 defines the left coordinate on Y axis
  23870. * @param x2 defines the right coordinate on X axis
  23871. * @param y2 defines the right coordinate on Y axis
  23872. * @returns the interpolated value
  23873. */
  23874. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23875. }
  23876. /**
  23877. * Defines potential orientation for back face culling
  23878. */
  23879. enum Orientation {
  23880. /**
  23881. * Clockwise
  23882. */
  23883. CW = 0,
  23884. /** Counter clockwise */
  23885. CCW = 1
  23886. }
  23887. /**
  23888. * Defines angle representation
  23889. */
  23890. class Angle {
  23891. private _radians;
  23892. /**
  23893. * Creates an Angle object of "radians" radians (float).
  23894. */
  23895. constructor(radians: number);
  23896. /**
  23897. * Get value in degrees
  23898. * @returns the Angle value in degrees (float)
  23899. */
  23900. degrees(): number;
  23901. /**
  23902. * Get value in radians
  23903. * @returns the Angle value in radians (float)
  23904. */
  23905. radians(): number;
  23906. /**
  23907. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23908. * @param a defines first vector
  23909. * @param b defines second vector
  23910. * @returns a new Angle
  23911. */
  23912. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23913. /**
  23914. * Gets a new Angle object from the given float in radians
  23915. * @param radians defines the angle value in radians
  23916. * @returns a new Angle
  23917. */
  23918. static FromRadians(radians: number): Angle;
  23919. /**
  23920. * Gets a new Angle object from the given float in degrees
  23921. * @param degrees defines the angle value in degrees
  23922. * @returns a new Angle
  23923. */
  23924. static FromDegrees(degrees: number): Angle;
  23925. }
  23926. /**
  23927. * This represents an arc in a 2d space.
  23928. */
  23929. class Arc2 {
  23930. /** Defines the start point of the arc */
  23931. startPoint: Vector2;
  23932. /** Defines the mid point of the arc */
  23933. midPoint: Vector2;
  23934. /** Defines the end point of the arc */
  23935. endPoint: Vector2;
  23936. /**
  23937. * Defines the center point of the arc.
  23938. */
  23939. centerPoint: Vector2;
  23940. /**
  23941. * Defines the radius of the arc.
  23942. */
  23943. radius: number;
  23944. /**
  23945. * Defines the angle of the arc (from mid point to end point).
  23946. */
  23947. angle: Angle;
  23948. /**
  23949. * Defines the start angle of the arc (from start point to middle point).
  23950. */
  23951. startAngle: Angle;
  23952. /**
  23953. * Defines the orientation of the arc (clock wise/counter clock wise).
  23954. */
  23955. orientation: Orientation;
  23956. /**
  23957. * Creates an Arc object from the three given points : start, middle and end.
  23958. * @param startPoint Defines the start point of the arc
  23959. * @param midPoint Defines the midlle point of the arc
  23960. * @param endPoint Defines the end point of the arc
  23961. */
  23962. constructor(
  23963. /** Defines the start point of the arc */
  23964. startPoint: Vector2,
  23965. /** Defines the mid point of the arc */
  23966. midPoint: Vector2,
  23967. /** Defines the end point of the arc */
  23968. endPoint: Vector2);
  23969. }
  23970. /**
  23971. * Represents a 2D path made up of multiple 2D points
  23972. */
  23973. class Path2 {
  23974. private _points;
  23975. private _length;
  23976. /**
  23977. * If the path start and end point are the same
  23978. */
  23979. closed: boolean;
  23980. /**
  23981. * Creates a Path2 object from the starting 2D coordinates x and y.
  23982. * @param x the starting points x value
  23983. * @param y the starting points y value
  23984. */
  23985. constructor(x: number, y: number);
  23986. /**
  23987. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23988. * @param x the added points x value
  23989. * @param y the added points y value
  23990. * @returns the updated Path2.
  23991. */
  23992. addLineTo(x: number, y: number): Path2;
  23993. /**
  23994. * 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.
  23995. * @param midX middle point x value
  23996. * @param midY middle point y value
  23997. * @param endX end point x value
  23998. * @param endY end point y value
  23999. * @param numberOfSegments (default: 36)
  24000. * @returns the updated Path2.
  24001. */
  24002. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  24003. /**
  24004. * Closes the Path2.
  24005. * @returns the Path2.
  24006. */
  24007. close(): Path2;
  24008. /**
  24009. * Gets the sum of the distance between each sequential point in the path
  24010. * @returns the Path2 total length (float).
  24011. */
  24012. length(): number;
  24013. /**
  24014. * Gets the points which construct the path
  24015. * @returns the Path2 internal array of points.
  24016. */
  24017. getPoints(): Vector2[];
  24018. /**
  24019. * Retreives the point at the distance aways from the starting point
  24020. * @param normalizedLengthPosition the length along the path to retreive the point from
  24021. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  24022. */
  24023. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  24024. /**
  24025. * Creates a new path starting from an x and y position
  24026. * @param x starting x value
  24027. * @param y starting y value
  24028. * @returns a new Path2 starting at the coordinates (x, y).
  24029. */
  24030. static StartingAt(x: number, y: number): Path2;
  24031. }
  24032. /**
  24033. * Represents a 3D path made up of multiple 3D points
  24034. */
  24035. class Path3D {
  24036. /**
  24037. * an array of Vector3, the curve axis of the Path3D
  24038. */
  24039. path: Vector3[];
  24040. private _curve;
  24041. private _distances;
  24042. private _tangents;
  24043. private _normals;
  24044. private _binormals;
  24045. private _raw;
  24046. /**
  24047. * new Path3D(path, normal, raw)
  24048. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  24049. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  24050. * @param path an array of Vector3, the curve axis of the Path3D
  24051. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  24052. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  24053. */
  24054. constructor(
  24055. /**
  24056. * an array of Vector3, the curve axis of the Path3D
  24057. */
  24058. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  24059. /**
  24060. * Returns the Path3D array of successive Vector3 designing its curve.
  24061. * @returns the Path3D array of successive Vector3 designing its curve.
  24062. */
  24063. getCurve(): Vector3[];
  24064. /**
  24065. * Returns an array populated with tangent vectors on each Path3D curve point.
  24066. * @returns an array populated with tangent vectors on each Path3D curve point.
  24067. */
  24068. getTangents(): Vector3[];
  24069. /**
  24070. * Returns an array populated with normal vectors on each Path3D curve point.
  24071. * @returns an array populated with normal vectors on each Path3D curve point.
  24072. */
  24073. getNormals(): Vector3[];
  24074. /**
  24075. * Returns an array populated with binormal vectors on each Path3D curve point.
  24076. * @returns an array populated with binormal vectors on each Path3D curve point.
  24077. */
  24078. getBinormals(): Vector3[];
  24079. /**
  24080. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  24081. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  24082. */
  24083. getDistances(): number[];
  24084. /**
  24085. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  24086. * @param path path which all values are copied into the curves points
  24087. * @param firstNormal which should be projected onto the curve
  24088. * @returns the same object updated.
  24089. */
  24090. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  24091. private _compute;
  24092. private _getFirstNonNullVector;
  24093. private _getLastNonNullVector;
  24094. private _normalVector;
  24095. }
  24096. /**
  24097. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24098. * A Curve3 is designed from a series of successive Vector3.
  24099. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  24100. */
  24101. class Curve3 {
  24102. private _points;
  24103. private _length;
  24104. /**
  24105. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  24106. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  24107. * @param v1 (Vector3) the control point
  24108. * @param v2 (Vector3) the end point of the Quadratic Bezier
  24109. * @param nbPoints (integer) the wanted number of points in the curve
  24110. * @returns the created Curve3
  24111. */
  24112. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24113. /**
  24114. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  24115. * @param v0 (Vector3) the origin point of the Cubic Bezier
  24116. * @param v1 (Vector3) the first control point
  24117. * @param v2 (Vector3) the second control point
  24118. * @param v3 (Vector3) the end point of the Cubic Bezier
  24119. * @param nbPoints (integer) the wanted number of points in the curve
  24120. * @returns the created Curve3
  24121. */
  24122. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24123. /**
  24124. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  24125. * @param p1 (Vector3) the origin point of the Hermite Spline
  24126. * @param t1 (Vector3) the tangent vector at the origin point
  24127. * @param p2 (Vector3) the end point of the Hermite Spline
  24128. * @param t2 (Vector3) the tangent vector at the end point
  24129. * @param nbPoints (integer) the wanted number of points in the curve
  24130. * @returns the created Curve3
  24131. */
  24132. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24133. /**
  24134. * Returns a Curve3 object along a CatmullRom Spline curve :
  24135. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24136. * @param nbPoints (integer) the wanted number of points between each curve control points
  24137. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24138. * @returns the created Curve3
  24139. */
  24140. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24141. /**
  24142. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24143. * A Curve3 is designed from a series of successive Vector3.
  24144. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24145. * @param points points which make up the curve
  24146. */
  24147. constructor(points: Vector3[]);
  24148. /**
  24149. * @returns the Curve3 stored array of successive Vector3
  24150. */
  24151. getPoints(): Vector3[];
  24152. /**
  24153. * @returns the computed length (float) of the curve.
  24154. */
  24155. length(): number;
  24156. /**
  24157. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24158. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24159. * curveA and curveB keep unchanged.
  24160. * @param curve the curve to continue from this curve
  24161. * @returns the newly constructed curve
  24162. */
  24163. continue(curve: DeepImmutable<Curve3>): Curve3;
  24164. private _computeLength;
  24165. }
  24166. /**
  24167. * Contains position and normal vectors for a vertex
  24168. */
  24169. class PositionNormalVertex {
  24170. /** the position of the vertex (defaut: 0,0,0) */
  24171. position: Vector3;
  24172. /** the normal of the vertex (defaut: 0,1,0) */
  24173. normal: Vector3;
  24174. /**
  24175. * Creates a PositionNormalVertex
  24176. * @param position the position of the vertex (defaut: 0,0,0)
  24177. * @param normal the normal of the vertex (defaut: 0,1,0)
  24178. */
  24179. constructor(
  24180. /** the position of the vertex (defaut: 0,0,0) */
  24181. position?: Vector3,
  24182. /** the normal of the vertex (defaut: 0,1,0) */
  24183. normal?: Vector3);
  24184. /**
  24185. * Clones the PositionNormalVertex
  24186. * @returns the cloned PositionNormalVertex
  24187. */
  24188. clone(): PositionNormalVertex;
  24189. }
  24190. /**
  24191. * Contains position, normal and uv vectors for a vertex
  24192. */
  24193. class PositionNormalTextureVertex {
  24194. /** the position of the vertex (defaut: 0,0,0) */
  24195. position: Vector3;
  24196. /** the normal of the vertex (defaut: 0,1,0) */
  24197. normal: Vector3;
  24198. /** the uv of the vertex (default: 0,0) */
  24199. uv: Vector2;
  24200. /**
  24201. * Creates a PositionNormalTextureVertex
  24202. * @param position the position of the vertex (defaut: 0,0,0)
  24203. * @param normal the normal of the vertex (defaut: 0,1,0)
  24204. * @param uv the uv of the vertex (default: 0,0)
  24205. */
  24206. constructor(
  24207. /** the position of the vertex (defaut: 0,0,0) */
  24208. position?: Vector3,
  24209. /** the normal of the vertex (defaut: 0,1,0) */
  24210. normal?: Vector3,
  24211. /** the uv of the vertex (default: 0,0) */
  24212. uv?: Vector2);
  24213. /**
  24214. * Clones the PositionNormalTextureVertex
  24215. * @returns the cloned PositionNormalTextureVertex
  24216. */
  24217. clone(): PositionNormalTextureVertex;
  24218. }
  24219. /**
  24220. * @hidden
  24221. */
  24222. class Tmp {
  24223. static Color3: Color3[];
  24224. static Color4: Color4[];
  24225. static Vector2: Vector2[];
  24226. static Vector3: Vector3[];
  24227. static Vector4: Vector4[];
  24228. static Quaternion: Quaternion[];
  24229. static Matrix: Matrix[];
  24230. }
  24231. }
  24232. declare module BABYLON {
  24233. /**
  24234. * Class representing spherical polynomial coefficients to the 3rd degree
  24235. */
  24236. class SphericalPolynomial {
  24237. /**
  24238. * The x coefficients of the spherical polynomial
  24239. */
  24240. x: Vector3;
  24241. /**
  24242. * The y coefficients of the spherical polynomial
  24243. */
  24244. y: Vector3;
  24245. /**
  24246. * The z coefficients of the spherical polynomial
  24247. */
  24248. z: Vector3;
  24249. /**
  24250. * The xx coefficients of the spherical polynomial
  24251. */
  24252. xx: Vector3;
  24253. /**
  24254. * The yy coefficients of the spherical polynomial
  24255. */
  24256. yy: Vector3;
  24257. /**
  24258. * The zz coefficients of the spherical polynomial
  24259. */
  24260. zz: Vector3;
  24261. /**
  24262. * The xy coefficients of the spherical polynomial
  24263. */
  24264. xy: Vector3;
  24265. /**
  24266. * The yz coefficients of the spherical polynomial
  24267. */
  24268. yz: Vector3;
  24269. /**
  24270. * The zx coefficients of the spherical polynomial
  24271. */
  24272. zx: Vector3;
  24273. /**
  24274. * Adds an ambient color to the spherical polynomial
  24275. * @param color the color to add
  24276. */
  24277. addAmbient(color: Color3): void;
  24278. /**
  24279. * Scales the spherical polynomial by the given amount
  24280. * @param scale the amount to scale
  24281. */
  24282. scale(scale: number): void;
  24283. /**
  24284. * Gets the spherical polynomial from harmonics
  24285. * @param harmonics the spherical harmonics
  24286. * @returns the spherical polynomial
  24287. */
  24288. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24289. /**
  24290. * Constructs a spherical polynomial from an array.
  24291. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24292. * @returns the spherical polynomial
  24293. */
  24294. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24295. }
  24296. /**
  24297. * Class representing spherical harmonics coefficients to the 3rd degree
  24298. */
  24299. class SphericalHarmonics {
  24300. /**
  24301. * The l0,0 coefficients of the spherical harmonics
  24302. */
  24303. l00: Vector3;
  24304. /**
  24305. * The l1,-1 coefficients of the spherical harmonics
  24306. */
  24307. l1_1: Vector3;
  24308. /**
  24309. * The l1,0 coefficients of the spherical harmonics
  24310. */
  24311. l10: Vector3;
  24312. /**
  24313. * The l1,1 coefficients of the spherical harmonics
  24314. */
  24315. l11: Vector3;
  24316. /**
  24317. * The l2,-2 coefficients of the spherical harmonics
  24318. */
  24319. l2_2: Vector3;
  24320. /**
  24321. * The l2,-1 coefficients of the spherical harmonics
  24322. */
  24323. l2_1: Vector3;
  24324. /**
  24325. * The l2,0 coefficients of the spherical harmonics
  24326. */
  24327. l20: Vector3;
  24328. /**
  24329. * The l2,1 coefficients of the spherical harmonics
  24330. */
  24331. l21: Vector3;
  24332. /**
  24333. * The l2,2 coefficients of the spherical harmonics
  24334. */
  24335. lL22: Vector3;
  24336. /**
  24337. * Adds a light to the spherical harmonics
  24338. * @param direction the direction of the light
  24339. * @param color the color of the light
  24340. * @param deltaSolidAngle the delta solid angle of the light
  24341. */
  24342. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24343. /**
  24344. * Scales the spherical harmonics by the given amount
  24345. * @param scale the amount to scale
  24346. */
  24347. scale(scale: number): void;
  24348. /**
  24349. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24350. *
  24351. * ```
  24352. * E_lm = A_l * L_lm
  24353. * ```
  24354. *
  24355. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24356. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24357. * the scaling factors are given in equation 9.
  24358. */
  24359. convertIncidentRadianceToIrradiance(): void;
  24360. /**
  24361. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24362. *
  24363. * ```
  24364. * L = (1/pi) * E * rho
  24365. * ```
  24366. *
  24367. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24368. */
  24369. convertIrradianceToLambertianRadiance(): void;
  24370. /**
  24371. * Gets the spherical harmonics from polynomial
  24372. * @param polynomial the spherical polynomial
  24373. * @returns the spherical harmonics
  24374. */
  24375. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24376. /**
  24377. * Constructs a spherical harmonics from an array.
  24378. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24379. * @returns the spherical harmonics
  24380. */
  24381. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24382. }
  24383. }
  24384. declare module BABYLON {
  24385. /**
  24386. * Class used to store all common mesh properties
  24387. */
  24388. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24389. /** No occlusion */
  24390. static OCCLUSION_TYPE_NONE: number;
  24391. /** Occlusion set to optimisitic */
  24392. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24393. /** Occlusion set to strict */
  24394. static OCCLUSION_TYPE_STRICT: number;
  24395. /** Use an accurante occlusion algorithm */
  24396. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24397. /** Use a conservative occlusion algorithm */
  24398. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24400. * Test order :
  24401. * Is the bounding sphere outside the frustum ?
  24402. * If not, are the bounding box vertices outside the frustum ?
  24403. * It not, then the cullable object is in the frustum.
  24404. */
  24405. static readonly CULLINGSTRATEGY_STANDARD: number;
  24406. /** Culling strategy : Bounding Sphere Only.
  24407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24408. * It's also less accurate than the standard because some not visible objects can still be selected.
  24409. * Test : is the bounding sphere outside the frustum ?
  24410. * If not, then the cullable object is in the frustum.
  24411. */
  24412. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24413. /** Culling strategy : Optimistic Inclusion.
  24414. * This in an inclusion test first, then the standard exclusion test.
  24415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24416. * 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.
  24417. * Anyway, it's as accurate as the standard strategy.
  24418. * Test :
  24419. * Is the cullable object bounding sphere center in the frustum ?
  24420. * If not, apply the default culling strategy.
  24421. */
  24422. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24426. * 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.
  24427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24428. * Test :
  24429. * Is the cullable object bounding sphere center in the frustum ?
  24430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24431. */
  24432. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24433. /**
  24434. * No billboard
  24435. */
  24436. static readonly BILLBOARDMODE_NONE: number;
  24437. /** Billboard on X axis */
  24438. static readonly BILLBOARDMODE_X: number;
  24439. /** Billboard on Y axis */
  24440. static readonly BILLBOARDMODE_Y: number;
  24441. /** Billboard on Z axis */
  24442. static readonly BILLBOARDMODE_Z: number;
  24443. /** Billboard on all axes */
  24444. static readonly BILLBOARDMODE_ALL: number;
  24445. private _facetData;
  24446. /**
  24447. * The culling strategy to use to check whether the mesh must be rendered or not.
  24448. * This value can be changed at any time and will be used on the next render mesh selection.
  24449. * The possible values are :
  24450. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24451. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24452. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24453. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24454. * Please read each static variable documentation to get details about the culling process.
  24455. * */
  24456. cullingStrategy: number;
  24457. /**
  24458. * Gets the number of facets in the mesh
  24459. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24460. */
  24461. readonly facetNb: number;
  24462. /**
  24463. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24465. */
  24466. partitioningSubdivisions: number;
  24467. /**
  24468. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24469. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24471. */
  24472. partitioningBBoxRatio: number;
  24473. /**
  24474. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24475. * Works only for updatable meshes.
  24476. * Doesn't work with multi-materials
  24477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24478. */
  24479. mustDepthSortFacets: boolean;
  24480. /**
  24481. * The location (Vector3) where the facet depth sort must be computed from.
  24482. * By default, the active camera position.
  24483. * Used only when facet depth sort is enabled
  24484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24485. */
  24486. facetDepthSortFrom: Vector3;
  24487. /**
  24488. * gets a boolean indicating if facetData is enabled
  24489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24490. */
  24491. readonly isFacetDataEnabled: boolean;
  24492. /** @hidden */
  24493. _updateNonUniformScalingState(value: boolean): boolean;
  24494. /**
  24495. * An event triggered when this mesh collides with another one
  24496. */
  24497. onCollideObservable: Observable<AbstractMesh>;
  24498. private _onCollideObserver;
  24499. /** Set a function to call when this mesh collides with another one */
  24500. onCollide: () => void;
  24501. /**
  24502. * An event triggered when the collision's position changes
  24503. */
  24504. onCollisionPositionChangeObservable: Observable<Vector3>;
  24505. private _onCollisionPositionChangeObserver;
  24506. /** Set a function to call when the collision's position changes */
  24507. onCollisionPositionChange: () => void;
  24508. /**
  24509. * An event triggered when material is changed
  24510. */
  24511. onMaterialChangedObservable: Observable<AbstractMesh>;
  24512. /**
  24513. * Gets or sets the orientation for POV movement & rotation
  24514. */
  24515. definedFacingForward: boolean;
  24516. /** @hidden */
  24517. _occlusionQuery: Nullable<WebGLQuery>;
  24518. private _visibility;
  24519. /**
  24520. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24521. */
  24522. /**
  24523. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24524. */
  24525. visibility: number;
  24526. /** Gets or sets the alpha index used to sort transparent meshes
  24527. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24528. */
  24529. alphaIndex: number;
  24530. /**
  24531. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24532. */
  24533. isVisible: boolean;
  24534. /**
  24535. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24536. */
  24537. isPickable: boolean;
  24538. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24539. showSubMeshesBoundingBox: boolean;
  24540. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24541. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24542. */
  24543. isBlocker: boolean;
  24544. /**
  24545. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24546. */
  24547. enablePointerMoveEvents: boolean;
  24548. /**
  24549. * Specifies the rendering group id for this mesh (0 by default)
  24550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24551. */
  24552. renderingGroupId: number;
  24553. private _material;
  24554. /** Gets or sets current material */
  24555. material: Nullable<Material>;
  24556. private _receiveShadows;
  24557. /**
  24558. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24559. * @see http://doc.babylonjs.com/babylon101/shadows
  24560. */
  24561. receiveShadows: boolean;
  24562. /** Defines color to use when rendering outline */
  24563. outlineColor: Color3;
  24564. /** Define width to use when rendering outline */
  24565. outlineWidth: number;
  24566. /** Defines color to use when rendering overlay */
  24567. overlayColor: Color3;
  24568. /** Defines alpha to use when rendering overlay */
  24569. overlayAlpha: number;
  24570. private _hasVertexAlpha;
  24571. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24572. hasVertexAlpha: boolean;
  24573. private _useVertexColors;
  24574. /** 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) */
  24575. useVertexColors: boolean;
  24576. private _computeBonesUsingShaders;
  24577. /**
  24578. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24579. */
  24580. computeBonesUsingShaders: boolean;
  24581. private _numBoneInfluencers;
  24582. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24583. numBoneInfluencers: number;
  24584. private _applyFog;
  24585. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24586. applyFog: boolean;
  24587. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24588. useOctreeForRenderingSelection: boolean;
  24589. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24590. useOctreeForPicking: boolean;
  24591. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24592. useOctreeForCollisions: boolean;
  24593. private _layerMask;
  24594. /**
  24595. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24596. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24597. */
  24598. layerMask: number;
  24599. /**
  24600. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24601. */
  24602. alwaysSelectAsActiveMesh: boolean;
  24603. /**
  24604. * Gets or sets the current action manager
  24605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24606. */
  24607. actionManager: Nullable<ActionManager>;
  24608. private _checkCollisions;
  24609. private _collisionMask;
  24610. private _collisionGroup;
  24611. /**
  24612. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24613. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24614. */
  24615. ellipsoid: Vector3;
  24616. /**
  24617. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24618. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24619. */
  24620. ellipsoidOffset: Vector3;
  24621. private _collider;
  24622. private _oldPositionForCollisions;
  24623. private _diffPositionForCollisions;
  24624. /**
  24625. * Gets or sets a collision mask used to mask collisions (default is -1).
  24626. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24627. */
  24628. collisionMask: number;
  24629. /**
  24630. * Gets or sets the current collision group mask (-1 by default).
  24631. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24632. */
  24633. collisionGroup: number;
  24634. /**
  24635. * Defines edge width used when edgesRenderer is enabled
  24636. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24637. */
  24638. edgesWidth: number;
  24639. /**
  24640. * Defines edge color used when edgesRenderer is enabled
  24641. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24642. */
  24643. edgesColor: Color4;
  24644. /** @hidden */
  24645. _edgesRenderer: Nullable<IEdgesRenderer>;
  24646. /** @hidden */
  24647. _masterMesh: Nullable<AbstractMesh>;
  24648. /** @hidden */
  24649. _boundingInfo: Nullable<BoundingInfo>;
  24650. /** @hidden */
  24651. _renderId: number;
  24652. /**
  24653. * Gets or sets the list of subMeshes
  24654. * @see http://doc.babylonjs.com/how_to/multi_materials
  24655. */
  24656. subMeshes: SubMesh[];
  24657. /** @hidden */
  24658. _intersectionsInProgress: AbstractMesh[];
  24659. /** @hidden */
  24660. _unIndexed: boolean;
  24661. /** @hidden */
  24662. _lightSources: Light[];
  24663. /** @hidden */
  24664. readonly _positions: Nullable<Vector3[]>;
  24665. /** @hidden */
  24666. _waitingActions: any;
  24667. /** @hidden */
  24668. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24669. private _skeleton;
  24670. /** @hidden */
  24671. _bonesTransformMatrices: Nullable<Float32Array>;
  24672. /**
  24673. * Gets or sets a skeleton to apply skining transformations
  24674. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24675. */
  24676. skeleton: Nullable<Skeleton>;
  24677. /**
  24678. * An event triggered when the mesh is rebuilt.
  24679. */
  24680. onRebuildObservable: Observable<AbstractMesh>;
  24681. /**
  24682. * Creates a new AbstractMesh
  24683. * @param name defines the name of the mesh
  24684. * @param scene defines the hosting scene
  24685. */
  24686. constructor(name: string, scene?: Nullable<Scene>);
  24687. /**
  24688. * Returns the string "AbstractMesh"
  24689. * @returns "AbstractMesh"
  24690. */
  24691. getClassName(): string;
  24692. /**
  24693. * Gets a string representation of the current mesh
  24694. * @param fullDetails defines a boolean indicating if full details must be included
  24695. * @returns a string representation of the current mesh
  24696. */
  24697. toString(fullDetails?: boolean): string;
  24698. /** @hidden */
  24699. _rebuild(): void;
  24700. /** @hidden */
  24701. _resyncLightSources(): void;
  24702. /** @hidden */
  24703. _resyncLighSource(light: Light): void;
  24704. /** @hidden */
  24705. _unBindEffect(): void;
  24706. /** @hidden */
  24707. _removeLightSource(light: Light): void;
  24708. private _markSubMeshesAsDirty;
  24709. /** @hidden */
  24710. _markSubMeshesAsLightDirty(): void;
  24711. /** @hidden */
  24712. _markSubMeshesAsAttributesDirty(): void;
  24713. /** @hidden */
  24714. _markSubMeshesAsMiscDirty(): void;
  24715. /**
  24716. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24717. */
  24718. scaling: Vector3;
  24719. /**
  24720. * Returns true if the mesh is blocked. Implemented by child classes
  24721. */
  24722. readonly isBlocked: boolean;
  24723. /**
  24724. * Returns the mesh itself by default. Implemented by child classes
  24725. * @param camera defines the camera to use to pick the right LOD level
  24726. * @returns the currentAbstractMesh
  24727. */
  24728. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24729. /**
  24730. * Returns 0 by default. Implemented by child classes
  24731. * @returns an integer
  24732. */
  24733. getTotalVertices(): number;
  24734. /**
  24735. * Returns a positive integer : the total number of indices in this mesh geometry.
  24736. * @returns the numner of indices or zero if the mesh has no geometry.
  24737. */
  24738. getTotalIndices(): number;
  24739. /**
  24740. * Returns null by default. Implemented by child classes
  24741. * @returns null
  24742. */
  24743. getIndices(): Nullable<IndicesArray>;
  24744. /**
  24745. * Returns the array of the requested vertex data kind. Implemented by child classes
  24746. * @param kind defines the vertex data kind to use
  24747. * @returns null
  24748. */
  24749. getVerticesData(kind: string): Nullable<FloatArray>;
  24750. /**
  24751. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24752. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24753. * Note that a new underlying VertexBuffer object is created each call.
  24754. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24755. * @param kind defines vertex data kind:
  24756. * * BABYLON.VertexBuffer.PositionKind
  24757. * * BABYLON.VertexBuffer.UVKind
  24758. * * BABYLON.VertexBuffer.UV2Kind
  24759. * * BABYLON.VertexBuffer.UV3Kind
  24760. * * BABYLON.VertexBuffer.UV4Kind
  24761. * * BABYLON.VertexBuffer.UV5Kind
  24762. * * BABYLON.VertexBuffer.UV6Kind
  24763. * * BABYLON.VertexBuffer.ColorKind
  24764. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24765. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24766. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24767. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24768. * @param data defines the data source
  24769. * @param updatable defines if the data must be flagged as updatable (or static)
  24770. * @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
  24771. * @returns the current mesh
  24772. */
  24773. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24774. /**
  24775. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24776. * If the mesh has no geometry, it is simply returned as it is.
  24777. * @param kind defines vertex data kind:
  24778. * * BABYLON.VertexBuffer.PositionKind
  24779. * * BABYLON.VertexBuffer.UVKind
  24780. * * BABYLON.VertexBuffer.UV2Kind
  24781. * * BABYLON.VertexBuffer.UV3Kind
  24782. * * BABYLON.VertexBuffer.UV4Kind
  24783. * * BABYLON.VertexBuffer.UV5Kind
  24784. * * BABYLON.VertexBuffer.UV6Kind
  24785. * * BABYLON.VertexBuffer.ColorKind
  24786. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24787. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24788. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24789. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24790. * @param data defines the data source
  24791. * @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
  24792. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24793. * @returns the current mesh
  24794. */
  24795. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24796. /**
  24797. * Sets the mesh indices,
  24798. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24799. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24800. * @param totalVertices Defines the total number of vertices
  24801. * @returns the current mesh
  24802. */
  24803. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24804. /**
  24805. * Gets a boolean indicating if specific vertex data is present
  24806. * @param kind defines the vertex data kind to use
  24807. * @returns true is data kind is present
  24808. */
  24809. isVerticesDataPresent(kind: string): boolean;
  24810. /**
  24811. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24812. * @returns a BoundingInfo
  24813. */
  24814. getBoundingInfo(): BoundingInfo;
  24815. /**
  24816. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24817. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24818. * @returns the current mesh
  24819. */
  24820. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24821. /**
  24822. * Overwrite the current bounding info
  24823. * @param boundingInfo defines the new bounding info
  24824. * @returns the current mesh
  24825. */
  24826. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24827. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24828. readonly useBones: boolean;
  24829. /** @hidden */
  24830. _preActivate(): void;
  24831. /** @hidden */
  24832. _preActivateForIntermediateRendering(renderId: number): void;
  24833. /** @hidden */
  24834. _activate(renderId: number): void;
  24835. /**
  24836. * Gets the current world matrix
  24837. * @returns a Matrix
  24838. */
  24839. getWorldMatrix(): Matrix;
  24840. /** @hidden */
  24841. _getWorldMatrixDeterminant(): number;
  24842. /**
  24843. * Perform relative position change from the point of view of behind the front of the mesh.
  24844. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24845. * Supports definition of mesh facing forward or backward
  24846. * @param amountRight defines the distance on the right axis
  24847. * @param amountUp defines the distance on the up axis
  24848. * @param amountForward defines the distance on the forward axis
  24849. * @returns the current mesh
  24850. */
  24851. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24852. /**
  24853. * Calculate relative position change from the point of view of behind the front of the mesh.
  24854. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24855. * Supports definition of mesh facing forward or backward
  24856. * @param amountRight defines the distance on the right axis
  24857. * @param amountUp defines the distance on the up axis
  24858. * @param amountForward defines the distance on the forward axis
  24859. * @returns the new displacement vector
  24860. */
  24861. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24862. /**
  24863. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24864. * Supports definition of mesh facing forward or backward
  24865. * @param flipBack defines the flip
  24866. * @param twirlClockwise defines the twirl
  24867. * @param tiltRight defines the tilt
  24868. * @returns the current mesh
  24869. */
  24870. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24871. /**
  24872. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24873. * Supports definition of mesh facing forward or backward.
  24874. * @param flipBack defines the flip
  24875. * @param twirlClockwise defines the twirl
  24876. * @param tiltRight defines the tilt
  24877. * @returns the new rotation vector
  24878. */
  24879. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24880. /**
  24881. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24882. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24883. * @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
  24884. * @returns the new bounding vectors
  24885. */
  24886. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24887. min: Vector3;
  24888. max: Vector3;
  24889. };
  24890. /**
  24891. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24892. * This means the mesh underlying bounding box and sphere are recomputed.
  24893. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24894. * @returns the current mesh
  24895. */
  24896. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24897. /** @hidden */
  24898. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24899. /** @hidden */
  24900. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24901. /** @hidden */
  24902. _updateBoundingInfo(): AbstractMesh;
  24903. /** @hidden */
  24904. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24905. /** @hidden */
  24906. protected _afterComputeWorldMatrix(): void;
  24907. /**
  24908. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24909. * A mesh is in the frustum if its bounding box intersects the frustum
  24910. * @param frustumPlanes defines the frustum to test
  24911. * @returns true if the mesh is in the frustum planes
  24912. */
  24913. isInFrustum(frustumPlanes: Plane[]): boolean;
  24914. /**
  24915. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24916. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24917. * @param frustumPlanes defines the frustum to test
  24918. * @returns true if the mesh is completely in the frustum planes
  24919. */
  24920. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24921. /**
  24922. * True if the mesh intersects another mesh or a SolidParticle object
  24923. * @param mesh defines a target mesh or SolidParticle to test
  24924. * @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)
  24925. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24926. * @returns true if there is an intersection
  24927. */
  24928. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24929. /**
  24930. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24931. * @param point defines the point to test
  24932. * @returns true if there is an intersection
  24933. */
  24934. intersectsPoint(point: Vector3): boolean;
  24935. /**
  24936. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24937. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24938. */
  24939. checkCollisions: boolean;
  24940. /**
  24941. * Gets Collider object used to compute collisions (not physics)
  24942. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24943. */
  24944. readonly collider: Collider;
  24945. /**
  24946. * Move the mesh using collision engine
  24947. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24948. * @param displacement defines the requested displacement vector
  24949. * @returns the current mesh
  24950. */
  24951. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24952. private _onCollisionPositionChange;
  24953. /** @hidden */
  24954. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24955. /** @hidden */
  24956. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24957. /** @hidden */
  24958. _checkCollision(collider: Collider): AbstractMesh;
  24959. /** @hidden */
  24960. _generatePointsArray(): boolean;
  24961. /**
  24962. * Checks if the passed Ray intersects with the mesh
  24963. * @param ray defines the ray to use
  24964. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24965. * @returns the picking info
  24966. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24967. */
  24968. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24969. /**
  24970. * Clones the current mesh
  24971. * @param name defines the mesh name
  24972. * @param newParent defines the new mesh parent
  24973. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24974. * @returns the new mesh
  24975. */
  24976. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24977. /**
  24978. * Disposes all the submeshes of the current meshnp
  24979. * @returns the current mesh
  24980. */
  24981. releaseSubMeshes(): AbstractMesh;
  24982. /**
  24983. * Releases resources associated with this abstract mesh.
  24984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24986. */
  24987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24988. /**
  24989. * Adds the passed mesh as a child to the current mesh
  24990. * @param mesh defines the child mesh
  24991. * @returns the current mesh
  24992. */
  24993. addChild(mesh: AbstractMesh): AbstractMesh;
  24994. /**
  24995. * Removes the passed mesh from the current mesh children list
  24996. * @param mesh defines the child mesh
  24997. * @returns the current mesh
  24998. */
  24999. removeChild(mesh: AbstractMesh): AbstractMesh;
  25000. /** @hidden */
  25001. private _initFacetData;
  25002. /**
  25003. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25004. * This method can be called within the render loop.
  25005. * 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
  25006. * @returns the current mesh
  25007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25008. */
  25009. updateFacetData(): AbstractMesh;
  25010. /**
  25011. * Returns the facetLocalNormals array.
  25012. * The normals are expressed in the mesh local spac
  25013. * @returns an array of Vector3
  25014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25015. */
  25016. getFacetLocalNormals(): Vector3[];
  25017. /**
  25018. * Returns the facetLocalPositions array.
  25019. * The facet positions are expressed in the mesh local space
  25020. * @returns an array of Vector3
  25021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25022. */
  25023. getFacetLocalPositions(): Vector3[];
  25024. /**
  25025. * Returns the facetLocalPartioning array
  25026. * @returns an array of array of numbers
  25027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25028. */
  25029. getFacetLocalPartitioning(): number[][];
  25030. /**
  25031. * Returns the i-th facet position in the world system.
  25032. * This method allocates a new Vector3 per call
  25033. * @param i defines the facet index
  25034. * @returns a new Vector3
  25035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25036. */
  25037. getFacetPosition(i: number): Vector3;
  25038. /**
  25039. * Sets the reference Vector3 with the i-th facet position in the world system
  25040. * @param i defines the facet index
  25041. * @param ref defines the target vector
  25042. * @returns the current mesh
  25043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25044. */
  25045. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25046. /**
  25047. * Returns the i-th facet normal in the world system.
  25048. * This method allocates a new Vector3 per call
  25049. * @param i defines the facet index
  25050. * @returns a new Vector3
  25051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25052. */
  25053. getFacetNormal(i: number): Vector3;
  25054. /**
  25055. * Sets the reference Vector3 with the i-th facet normal in the world system
  25056. * @param i defines the facet index
  25057. * @param ref defines the target vector
  25058. * @returns the current mesh
  25059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25060. */
  25061. getFacetNormalToRef(i: number, ref: Vector3): this;
  25062. /**
  25063. * 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)
  25064. * @param x defines x coordinate
  25065. * @param y defines y coordinate
  25066. * @param z defines z coordinate
  25067. * @returns the array of facet indexes
  25068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25069. */
  25070. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25071. /**
  25072. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25073. * @param projected sets as the (x,y,z) world projection on the facet
  25074. * @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
  25075. * @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
  25076. * @param x defines x coordinate
  25077. * @param y defines y coordinate
  25078. * @param z defines z coordinate
  25079. * @returns the face index if found (or null instead)
  25080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25081. */
  25082. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25083. /**
  25084. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25085. * @param projected sets as the (x,y,z) local projection on the facet
  25086. * @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
  25087. * @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
  25088. * @param x defines x coordinate
  25089. * @param y defines y coordinate
  25090. * @param z defines z coordinate
  25091. * @returns the face index if found (or null instead)
  25092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25093. */
  25094. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25095. /**
  25096. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25097. * @returns the parameters
  25098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25099. */
  25100. getFacetDataParameters(): any;
  25101. /**
  25102. * Disables the feature FacetData and frees the related memory
  25103. * @returns the current mesh
  25104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25105. */
  25106. disableFacetData(): AbstractMesh;
  25107. /**
  25108. * Updates the AbstractMesh indices array
  25109. * @param indices defines the data source
  25110. * @returns the current mesh
  25111. */
  25112. updateIndices(indices: IndicesArray): AbstractMesh;
  25113. /**
  25114. * Creates new normals data for the mesh
  25115. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25116. * @returns the current mesh
  25117. */
  25118. createNormals(updatable: boolean): AbstractMesh;
  25119. /**
  25120. * Align the mesh with a normal
  25121. * @param normal defines the normal to use
  25122. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25123. * @returns the current mesh
  25124. */
  25125. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25126. /** @hidden */
  25127. _checkOcclusionQuery(): boolean;
  25128. }
  25129. }
  25130. declare module BABYLON {
  25131. /**
  25132. * Class used to store data that will be store in GPU memory
  25133. */
  25134. class Buffer {
  25135. private _engine;
  25136. private _buffer;
  25137. /** @hidden */
  25138. _data: Nullable<DataArray>;
  25139. private _updatable;
  25140. private _instanced;
  25141. /**
  25142. * Gets the byte stride.
  25143. */
  25144. readonly byteStride: number;
  25145. /**
  25146. * Constructor
  25147. * @param engine the engine
  25148. * @param data the data to use for this buffer
  25149. * @param updatable whether the data is updatable
  25150. * @param stride the stride (optional)
  25151. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25152. * @param instanced whether the buffer is instanced (optional)
  25153. * @param useBytes set to true if the stride in in bytes (optional)
  25154. */
  25155. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25156. /**
  25157. * Create a new VertexBuffer based on the current buffer
  25158. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25159. * @param offset defines offset in the buffer (0 by default)
  25160. * @param size defines the size in floats of attributes (position is 3 for instance)
  25161. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25162. * @param instanced defines if the vertex buffer contains indexed data
  25163. * @param useBytes defines if the offset and stride are in bytes
  25164. * @returns the new vertex buffer
  25165. */
  25166. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25167. /**
  25168. * Gets a boolean indicating if the Buffer is updatable?
  25169. * @returns true if the buffer is updatable
  25170. */
  25171. isUpdatable(): boolean;
  25172. /**
  25173. * Gets current buffer's data
  25174. * @returns a DataArray or null
  25175. */
  25176. getData(): Nullable<DataArray>;
  25177. /**
  25178. * Gets underlying native buffer
  25179. * @returns underlying native buffer
  25180. */
  25181. getBuffer(): Nullable<WebGLBuffer>;
  25182. /**
  25183. * Gets the stride in float32 units (i.e. byte stride / 4).
  25184. * May not be an integer if the byte stride is not divisible by 4.
  25185. * DEPRECATED. Use byteStride instead.
  25186. * @returns the stride in float32 units
  25187. */
  25188. getStrideSize(): number;
  25189. /**
  25190. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25191. * @param data defines the data to store
  25192. */
  25193. create(data?: Nullable<DataArray>): void;
  25194. /** @hidden */
  25195. _rebuild(): void;
  25196. /**
  25197. * Update current buffer data
  25198. * @param data defines the data to store
  25199. */
  25200. update(data: DataArray): void;
  25201. /**
  25202. * Updates the data directly.
  25203. * @param data the new data
  25204. * @param offset the new offset
  25205. * @param vertexCount the vertex count (optional)
  25206. * @param useBytes set to true if the offset is in bytes
  25207. */
  25208. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25209. /**
  25210. * Release all resources
  25211. */
  25212. dispose(): void;
  25213. }
  25214. }
  25215. declare module BABYLON {
  25216. /**
  25217. * Class for building Constructive Solid Geometry
  25218. */
  25219. class CSG {
  25220. private polygons;
  25221. /**
  25222. * The world matrix
  25223. */
  25224. matrix: Matrix;
  25225. /**
  25226. * Stores the position
  25227. */
  25228. position: Vector3;
  25229. /**
  25230. * Stores the rotation
  25231. */
  25232. rotation: Vector3;
  25233. /**
  25234. * Stores the rotation quaternion
  25235. */
  25236. rotationQuaternion: Nullable<Quaternion>;
  25237. /**
  25238. * Stores the scaling vector
  25239. */
  25240. scaling: Vector3;
  25241. /**
  25242. * Convert the BABYLON.Mesh to BABYLON.CSG
  25243. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25244. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25245. */
  25246. static FromMesh(mesh: Mesh): CSG;
  25247. /**
  25248. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25249. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25250. */
  25251. private static FromPolygons;
  25252. /**
  25253. * Clones, or makes a deep copy, of the BABYLON.CSG
  25254. * @returns A new BABYLON.CSG
  25255. */
  25256. clone(): CSG;
  25257. /**
  25258. * Unions this CSG with another CSG
  25259. * @param csg The CSG to union against this CSG
  25260. * @returns The unioned CSG
  25261. */
  25262. union(csg: CSG): CSG;
  25263. /**
  25264. * Unions this CSG with another CSG in place
  25265. * @param csg The CSG to union against this CSG
  25266. */
  25267. unionInPlace(csg: CSG): void;
  25268. /**
  25269. * Subtracts this CSG with another CSG
  25270. * @param csg The CSG to subtract against this CSG
  25271. * @returns A new BABYLON.CSG
  25272. */
  25273. subtract(csg: CSG): CSG;
  25274. /**
  25275. * Subtracts this CSG with another CSG in place
  25276. * @param csg The CSG to subtact against this CSG
  25277. */
  25278. subtractInPlace(csg: CSG): void;
  25279. /**
  25280. * Intersect this CSG with another CSG
  25281. * @param csg The CSG to intersect against this CSG
  25282. * @returns A new BABYLON.CSG
  25283. */
  25284. intersect(csg: CSG): CSG;
  25285. /**
  25286. * Intersects this CSG with another CSG in place
  25287. * @param csg The CSG to intersect against this CSG
  25288. */
  25289. intersectInPlace(csg: CSG): void;
  25290. /**
  25291. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25292. * not modified.
  25293. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25294. */
  25295. inverse(): CSG;
  25296. /**
  25297. * Inverses the BABYLON.CSG in place
  25298. */
  25299. inverseInPlace(): void;
  25300. /**
  25301. * This is used to keep meshes transformations so they can be restored
  25302. * when we build back a Babylon Mesh
  25303. * NB : All CSG operations are performed in world coordinates
  25304. * @param csg The BABYLON.CSG to copy the transform attributes from
  25305. * @returns This BABYLON.CSG
  25306. */
  25307. copyTransformAttributes(csg: CSG): CSG;
  25308. /**
  25309. * Build Raw mesh from CSG
  25310. * Coordinates here are in world space
  25311. * @param name The name of the mesh geometry
  25312. * @param scene The BABYLON.Scene
  25313. * @param keepSubMeshes Specifies if the submeshes should be kept
  25314. * @returns A new BABYLON.Mesh
  25315. */
  25316. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25317. /**
  25318. * Build Mesh from CSG taking material and transforms into account
  25319. * @param name The name of the BABYLON.Mesh
  25320. * @param material The material of the BABYLON.Mesh
  25321. * @param scene The BABYLON.Scene
  25322. * @param keepSubMeshes Specifies if submeshes should be kept
  25323. * @returns The new BABYLON.Mesh
  25324. */
  25325. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25326. }
  25327. }
  25328. declare module BABYLON {
  25329. /**
  25330. * Class used to store geometry data (vertex buffers + index buffer)
  25331. */
  25332. class Geometry implements IGetSetVerticesData {
  25333. /**
  25334. * Gets or sets the ID of the geometry
  25335. */
  25336. id: string;
  25337. /**
  25338. * Gets or sets the unique ID of the geometry
  25339. */
  25340. uniqueId: number;
  25341. /**
  25342. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25343. */
  25344. delayLoadState: number;
  25345. /**
  25346. * Gets the file containing the data to load when running in delay load state
  25347. */
  25348. delayLoadingFile: Nullable<string>;
  25349. /**
  25350. * Callback called when the geometry is updated
  25351. */
  25352. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25353. private _scene;
  25354. private _engine;
  25355. private _meshes;
  25356. private _totalVertices;
  25357. /** @hidden */
  25358. _indices: IndicesArray;
  25359. /** @hidden */
  25360. _vertexBuffers: {
  25361. [key: string]: VertexBuffer;
  25362. };
  25363. private _isDisposed;
  25364. private _extend;
  25365. private _boundingBias;
  25366. /** @hidden */
  25367. _delayInfo: Array<string>;
  25368. private _indexBuffer;
  25369. private _indexBufferIsUpdatable;
  25370. /** @hidden */
  25371. _boundingInfo: Nullable<BoundingInfo>;
  25372. /** @hidden */
  25373. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25374. /** @hidden */
  25375. _softwareSkinningFrameId: number;
  25376. private _vertexArrayObjects;
  25377. private _updatable;
  25378. /** @hidden */
  25379. _positions: Nullable<Vector3[]>;
  25380. /**
  25381. * 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
  25382. */
  25383. /**
  25384. * 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
  25385. */
  25386. boundingBias: Vector2;
  25387. /**
  25388. * Static function used to attach a new empty geometry to a mesh
  25389. * @param mesh defines the mesh to attach the geometry to
  25390. * @returns the new Geometry
  25391. */
  25392. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25393. /**
  25394. * Creates a new geometry
  25395. * @param id defines the unique ID
  25396. * @param scene defines the hosting scene
  25397. * @param vertexData defines the VertexData used to get geometry data
  25398. * @param updatable defines if geometry must be updatable (false by default)
  25399. * @param mesh defines the mesh that will be associated with the geometry
  25400. */
  25401. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25402. /**
  25403. * Gets the current extend of the geometry
  25404. */
  25405. readonly extend: {
  25406. minimum: Vector3;
  25407. maximum: Vector3;
  25408. };
  25409. /**
  25410. * Gets the hosting scene
  25411. * @returns the hosting Scene
  25412. */
  25413. getScene(): Scene;
  25414. /**
  25415. * Gets the hosting engine
  25416. * @returns the hosting Engine
  25417. */
  25418. getEngine(): Engine;
  25419. /**
  25420. * Defines if the geometry is ready to use
  25421. * @returns true if the geometry is ready to be used
  25422. */
  25423. isReady(): boolean;
  25424. /**
  25425. * Gets a value indicating that the geometry should not be serialized
  25426. */
  25427. readonly doNotSerialize: boolean;
  25428. /** @hidden */
  25429. _rebuild(): void;
  25430. /**
  25431. * Affects all geometry data in one call
  25432. * @param vertexData defines the geometry data
  25433. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25434. */
  25435. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25436. /**
  25437. * Set specific vertex data
  25438. * @param kind defines the data kind (Position, normal, etc...)
  25439. * @param data defines the vertex data to use
  25440. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25441. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25442. */
  25443. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25444. /**
  25445. * Removes a specific vertex data
  25446. * @param kind defines the data kind (Position, normal, etc...)
  25447. */
  25448. removeVerticesData(kind: string): void;
  25449. /**
  25450. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25451. * @param buffer defines the vertex buffer to use
  25452. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25453. */
  25454. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25455. /**
  25456. * Update a specific vertex buffer
  25457. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25458. * It will do nothing if the buffer is not updatable
  25459. * @param kind defines the data kind (Position, normal, etc...)
  25460. * @param data defines the data to use
  25461. * @param offset defines the offset in the target buffer where to store the data
  25462. * @param useBytes set to true if the offset is in bytes
  25463. */
  25464. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25465. /**
  25466. * Update a specific vertex buffer
  25467. * This function will create a new buffer if the current one is not updatable
  25468. * @param kind defines the data kind (Position, normal, etc...)
  25469. * @param data defines the data to use
  25470. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25471. */
  25472. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25473. private _updateBoundingInfo;
  25474. /** @hidden */
  25475. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25476. /**
  25477. * Gets total number of vertices
  25478. * @returns the total number of vertices
  25479. */
  25480. getTotalVertices(): number;
  25481. /**
  25482. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25483. * @param kind defines the data kind (Position, normal, etc...)
  25484. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25485. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25486. * @returns a float array containing vertex data
  25487. */
  25488. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25489. /**
  25490. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25491. * @param kind defines the data kind (Position, normal, etc...)
  25492. * @returns true if the vertex buffer with the specified kind is updatable
  25493. */
  25494. isVertexBufferUpdatable(kind: string): boolean;
  25495. /**
  25496. * Gets a specific vertex buffer
  25497. * @param kind defines the data kind (Position, normal, etc...)
  25498. * @returns a VertexBuffer
  25499. */
  25500. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25501. /**
  25502. * Returns all vertex buffers
  25503. * @return an object holding all vertex buffers indexed by kind
  25504. */
  25505. getVertexBuffers(): Nullable<{
  25506. [key: string]: VertexBuffer;
  25507. }>;
  25508. /**
  25509. * Gets a boolean indicating if specific vertex buffer is present
  25510. * @param kind defines the data kind (Position, normal, etc...)
  25511. * @returns true if data is present
  25512. */
  25513. isVerticesDataPresent(kind: string): boolean;
  25514. /**
  25515. * Gets a list of all attached data kinds (Position, normal, etc...)
  25516. * @returns a list of string containing all kinds
  25517. */
  25518. getVerticesDataKinds(): string[];
  25519. /**
  25520. * Update index buffer
  25521. * @param indices defines the indices to store in the index buffer
  25522. * @param offset defines the offset in the target buffer where to store the data
  25523. */
  25524. updateIndices(indices: IndicesArray, offset?: number): void;
  25525. /**
  25526. * Creates a new index buffer
  25527. * @param indices defines the indices to store in the index buffer
  25528. * @param totalVertices defines the total number of vertices (could be null)
  25529. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25530. */
  25531. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25532. /**
  25533. * Return the total number of indices
  25534. * @returns the total number of indices
  25535. */
  25536. getTotalIndices(): number;
  25537. /**
  25538. * Gets the index buffer array
  25539. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25540. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25541. * @returns the index buffer array
  25542. */
  25543. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25544. /**
  25545. * Gets the index buffer
  25546. * @return the index buffer
  25547. */
  25548. getIndexBuffer(): Nullable<WebGLBuffer>;
  25549. /** @hidden */
  25550. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25551. /**
  25552. * Release the associated resources for a specific mesh
  25553. * @param mesh defines the source mesh
  25554. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25555. */
  25556. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25557. /**
  25558. * Apply current geometry to a given mesh
  25559. * @param mesh defines the mesh to apply geometry to
  25560. */
  25561. applyToMesh(mesh: Mesh): void;
  25562. private _updateExtend;
  25563. private _applyToMesh;
  25564. private notifyUpdate;
  25565. /**
  25566. * Load the geometry if it was flagged as delay loaded
  25567. * @param scene defines the hosting scene
  25568. * @param onLoaded defines a callback called when the geometry is loaded
  25569. */
  25570. load(scene: Scene, onLoaded?: () => void): void;
  25571. private _queueLoad;
  25572. /**
  25573. * Invert the geometry to move from a right handed system to a left handed one.
  25574. */
  25575. toLeftHanded(): void;
  25576. /** @hidden */
  25577. _resetPointsArrayCache(): void;
  25578. /** @hidden */
  25579. _generatePointsArray(): boolean;
  25580. /**
  25581. * Gets a value indicating if the geometry is disposed
  25582. * @returns true if the geometry was disposed
  25583. */
  25584. isDisposed(): boolean;
  25585. private _disposeVertexArrayObjects;
  25586. /**
  25587. * Free all associated resources
  25588. */
  25589. dispose(): void;
  25590. /**
  25591. * Clone the current geometry into a new geometry
  25592. * @param id defines the unique ID of the new geometry
  25593. * @returns a new geometry object
  25594. */
  25595. copy(id: string): Geometry;
  25596. /**
  25597. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25598. * @return a JSON representation of the current geometry data (without the vertices data)
  25599. */
  25600. serialize(): any;
  25601. private toNumberArray;
  25602. /**
  25603. * Serialize all vertices data into a JSON oject
  25604. * @returns a JSON representation of the current geometry data
  25605. */
  25606. serializeVerticeData(): any;
  25607. /**
  25608. * Extracts a clone of a mesh geometry
  25609. * @param mesh defines the source mesh
  25610. * @param id defines the unique ID of the new geometry object
  25611. * @returns the new geometry object
  25612. */
  25613. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25614. /**
  25615. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25616. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25617. * Be aware Math.random() could cause collisions, but:
  25618. * "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"
  25619. * @returns a string containing a new GUID
  25620. */
  25621. static RandomId(): string;
  25622. /** @hidden */
  25623. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25624. private static _CleanMatricesWeights;
  25625. /**
  25626. * Create a new geometry from persisted data (Using .babylon file format)
  25627. * @param parsedVertexData defines the persisted data
  25628. * @param scene defines the hosting scene
  25629. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25630. * @returns the new geometry object
  25631. */
  25632. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25633. }
  25634. /**
  25635. * Abstract class used to provide common services for all typed geometries
  25636. * @hidden
  25637. */
  25638. class _PrimitiveGeometry extends Geometry {
  25639. private _canBeRegenerated;
  25640. private _beingRegenerated;
  25641. /**
  25642. * Creates a new typed geometry
  25643. * @param id defines the unique ID of the geometry
  25644. * @param scene defines the hosting scene
  25645. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25646. * @param mesh defines the hosting mesh (can be null)
  25647. */
  25648. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25649. /**
  25650. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25651. * @returns true if the geometry can be regenerated
  25652. */
  25653. canBeRegenerated(): boolean;
  25654. /**
  25655. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25656. */
  25657. regenerate(): void;
  25658. /**
  25659. * Clone the geometry
  25660. * @param id defines the unique ID of the new geometry
  25661. * @returns the new geometry
  25662. */
  25663. asNewGeometry(id: string): Geometry;
  25664. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25666. /** @hidden */
  25667. _regenerateVertexData(): VertexData;
  25668. copy(id: string): Geometry;
  25669. serialize(): any;
  25670. }
  25671. /**
  25672. * Creates a ribbon geometry
  25673. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25674. */
  25675. class RibbonGeometry extends _PrimitiveGeometry {
  25676. /**
  25677. * Defines the array of paths to use
  25678. */
  25679. pathArray: Vector3[][];
  25680. /**
  25681. * Defines if the last and first points of each path in your pathArray must be joined
  25682. */
  25683. closeArray: boolean;
  25684. /**
  25685. * Defines if the last and first points of each path in your pathArray must be joined
  25686. */
  25687. closePath: boolean;
  25688. /**
  25689. * Defines the offset between points
  25690. */
  25691. offset: number;
  25692. /**
  25693. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25694. */
  25695. side: number;
  25696. /**
  25697. * Creates a ribbon geometry
  25698. * @param id defines the unique ID of the geometry
  25699. * @param scene defines the hosting scene
  25700. * @param pathArray defines the array of paths to use
  25701. * @param closeArray defines if the last path and the first path must be joined
  25702. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25703. * @param offset defines the offset between points
  25704. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25705. * @param mesh defines the hosting mesh (can be null)
  25706. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25707. */
  25708. constructor(id: string, scene: Scene,
  25709. /**
  25710. * Defines the array of paths to use
  25711. */
  25712. pathArray: Vector3[][],
  25713. /**
  25714. * Defines if the last and first points of each path in your pathArray must be joined
  25715. */
  25716. closeArray: boolean,
  25717. /**
  25718. * Defines if the last and first points of each path in your pathArray must be joined
  25719. */
  25720. closePath: boolean,
  25721. /**
  25722. * Defines the offset between points
  25723. */
  25724. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25725. /**
  25726. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25727. */
  25728. side?: number);
  25729. /** @hidden */
  25730. _regenerateVertexData(): VertexData;
  25731. copy(id: string): Geometry;
  25732. }
  25733. /**
  25734. * Creates a box geometry
  25735. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25736. */
  25737. class BoxGeometry extends _PrimitiveGeometry {
  25738. /**
  25739. * Defines the zise of the box (width, height and depth are the same)
  25740. */
  25741. size: number;
  25742. /**
  25743. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25744. */
  25745. side: number;
  25746. /**
  25747. * Creates a box geometry
  25748. * @param id defines the unique ID of the geometry
  25749. * @param scene defines the hosting scene
  25750. * @param size defines the zise of the box (width, height and depth are the same)
  25751. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25752. * @param mesh defines the hosting mesh (can be null)
  25753. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25754. */
  25755. constructor(id: string, scene: Scene,
  25756. /**
  25757. * Defines the zise of the box (width, height and depth are the same)
  25758. */
  25759. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25760. /**
  25761. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25762. */
  25763. side?: number);
  25764. /** @hidden */
  25765. _regenerateVertexData(): VertexData;
  25766. copy(id: string): Geometry;
  25767. serialize(): any;
  25768. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25769. }
  25770. /**
  25771. * Creates a sphere geometry
  25772. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25773. */
  25774. class SphereGeometry extends _PrimitiveGeometry {
  25775. /**
  25776. * Defines the number of segments to use to create the sphere
  25777. */
  25778. segments: number;
  25779. /**
  25780. * Defines the diameter of the sphere
  25781. */
  25782. diameter: number;
  25783. /**
  25784. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25785. */
  25786. side: number;
  25787. /**
  25788. * Create a new sphere geometry
  25789. * @param id defines the unique ID of the geometry
  25790. * @param scene defines the hosting scene
  25791. * @param segments defines the number of segments to use to create the sphere
  25792. * @param diameter defines the diameter of the sphere
  25793. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25794. * @param mesh defines the hosting mesh (can be null)
  25795. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25796. */
  25797. constructor(id: string, scene: Scene,
  25798. /**
  25799. * Defines the number of segments to use to create the sphere
  25800. */
  25801. segments: number,
  25802. /**
  25803. * Defines the diameter of the sphere
  25804. */
  25805. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25806. /**
  25807. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25808. */
  25809. side?: number);
  25810. /** @hidden */
  25811. _regenerateVertexData(): VertexData;
  25812. copy(id: string): Geometry;
  25813. serialize(): any;
  25814. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25815. }
  25816. /**
  25817. * Creates a disc geometry
  25818. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25819. */
  25820. class DiscGeometry extends _PrimitiveGeometry {
  25821. /**
  25822. * Defines the radius of the disc
  25823. */
  25824. radius: number;
  25825. /**
  25826. * Defines the tesselation factor to apply to the disc
  25827. */
  25828. tessellation: number;
  25829. /**
  25830. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25831. */
  25832. side: number;
  25833. /**
  25834. * Creates a new disc geometry
  25835. * @param id defines the unique ID of the geometry
  25836. * @param scene defines the hosting scene
  25837. * @param radius defines the radius of the disc
  25838. * @param tessellation defines the tesselation factor to apply to the disc
  25839. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25840. * @param mesh defines the hosting mesh (can be null)
  25841. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25842. */
  25843. constructor(id: string, scene: Scene,
  25844. /**
  25845. * Defines the radius of the disc
  25846. */
  25847. radius: number,
  25848. /**
  25849. * Defines the tesselation factor to apply to the disc
  25850. */
  25851. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25852. /**
  25853. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25854. */
  25855. side?: number);
  25856. /** @hidden */
  25857. _regenerateVertexData(): VertexData;
  25858. copy(id: string): Geometry;
  25859. }
  25860. /**
  25861. * Creates a new cylinder geometry
  25862. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25863. */
  25864. class CylinderGeometry extends _PrimitiveGeometry {
  25865. /**
  25866. * Defines the height of the cylinder
  25867. */
  25868. height: number;
  25869. /**
  25870. * Defines the diameter of the cylinder's top cap
  25871. */
  25872. diameterTop: number;
  25873. /**
  25874. * Defines the diameter of the cylinder's bottom cap
  25875. */
  25876. diameterBottom: number;
  25877. /**
  25878. * Defines the tessellation factor to apply to the cylinder
  25879. */
  25880. tessellation: number;
  25881. /**
  25882. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25883. */
  25884. subdivisions: number;
  25885. /**
  25886. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25887. */
  25888. side: number;
  25889. /**
  25890. * Creates a new cylinder geometry
  25891. * @param id defines the unique ID of the geometry
  25892. * @param scene defines the hosting scene
  25893. * @param height defines the height of the cylinder
  25894. * @param diameterTop defines the diameter of the cylinder's top cap
  25895. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25896. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25897. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25898. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25899. * @param mesh defines the hosting mesh (can be null)
  25900. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25901. */
  25902. constructor(id: string, scene: Scene,
  25903. /**
  25904. * Defines the height of the cylinder
  25905. */
  25906. height: number,
  25907. /**
  25908. * Defines the diameter of the cylinder's top cap
  25909. */
  25910. diameterTop: number,
  25911. /**
  25912. * Defines the diameter of the cylinder's bottom cap
  25913. */
  25914. diameterBottom: number,
  25915. /**
  25916. * Defines the tessellation factor to apply to the cylinder
  25917. */
  25918. tessellation: number,
  25919. /**
  25920. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25921. */
  25922. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25923. /**
  25924. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25925. */
  25926. side?: number);
  25927. /** @hidden */
  25928. _regenerateVertexData(): VertexData;
  25929. copy(id: string): Geometry;
  25930. serialize(): any;
  25931. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25932. }
  25933. /**
  25934. * Creates a new torus geometry
  25935. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25936. */
  25937. class TorusGeometry extends _PrimitiveGeometry {
  25938. /**
  25939. * Defines the diameter of the torus
  25940. */
  25941. diameter: number;
  25942. /**
  25943. * Defines the thickness of the torus (ie. internal diameter)
  25944. */
  25945. thickness: number;
  25946. /**
  25947. * Defines the tesselation factor to apply to the torus
  25948. */
  25949. tessellation: number;
  25950. /**
  25951. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25952. */
  25953. side: number;
  25954. /**
  25955. * Creates a new torus geometry
  25956. * @param id defines the unique ID of the geometry
  25957. * @param scene defines the hosting scene
  25958. * @param diameter defines the diameter of the torus
  25959. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25960. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25961. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25962. * @param mesh defines the hosting mesh (can be null)
  25963. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25964. */
  25965. constructor(id: string, scene: Scene,
  25966. /**
  25967. * Defines the diameter of the torus
  25968. */
  25969. diameter: number,
  25970. /**
  25971. * Defines the thickness of the torus (ie. internal diameter)
  25972. */
  25973. thickness: number,
  25974. /**
  25975. * Defines the tesselation factor to apply to the torus
  25976. */
  25977. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25978. /**
  25979. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25980. */
  25981. side?: number);
  25982. /** @hidden */
  25983. _regenerateVertexData(): VertexData;
  25984. copy(id: string): Geometry;
  25985. serialize(): any;
  25986. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25987. }
  25988. /**
  25989. * Creates a new ground geometry
  25990. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25991. */
  25992. class GroundGeometry extends _PrimitiveGeometry {
  25993. /**
  25994. * Defines the width of the ground
  25995. */
  25996. width: number;
  25997. /**
  25998. * Defines the height of the ground
  25999. */
  26000. height: number;
  26001. /**
  26002. * Defines the subdivisions to apply to the ground
  26003. */
  26004. subdivisions: number;
  26005. /**
  26006. * Creates a new ground geometry
  26007. * @param id defines the unique ID of the geometry
  26008. * @param scene defines the hosting scene
  26009. * @param width defines the width of the ground
  26010. * @param height defines the height of the ground
  26011. * @param subdivisions defines the subdivisions to apply to the ground
  26012. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26013. * @param mesh defines the hosting mesh (can be null)
  26014. */
  26015. constructor(id: string, scene: Scene,
  26016. /**
  26017. * Defines the width of the ground
  26018. */
  26019. width: number,
  26020. /**
  26021. * Defines the height of the ground
  26022. */
  26023. height: number,
  26024. /**
  26025. * Defines the subdivisions to apply to the ground
  26026. */
  26027. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26028. /** @hidden */
  26029. _regenerateVertexData(): VertexData;
  26030. copy(id: string): Geometry;
  26031. serialize(): any;
  26032. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  26033. }
  26034. /**
  26035. * Creates a tiled ground geometry
  26036. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  26037. */
  26038. class TiledGroundGeometry extends _PrimitiveGeometry {
  26039. /**
  26040. * Defines the minimum value on X axis
  26041. */
  26042. xmin: number;
  26043. /**
  26044. * Defines the minimum value on Z axis
  26045. */
  26046. zmin: number;
  26047. /**
  26048. * Defines the maximum value on X axis
  26049. */
  26050. xmax: number;
  26051. /**
  26052. * Defines the maximum value on Z axis
  26053. */
  26054. zmax: number;
  26055. /**
  26056. * Defines the subdivisions to apply to the ground
  26057. */
  26058. subdivisions: {
  26059. w: number;
  26060. h: number;
  26061. };
  26062. /**
  26063. * Defines the precision to use when computing the tiles
  26064. */
  26065. precision: {
  26066. w: number;
  26067. h: number;
  26068. };
  26069. /**
  26070. * Creates a tiled ground geometry
  26071. * @param id defines the unique ID of the geometry
  26072. * @param scene defines the hosting scene
  26073. * @param xmin defines the minimum value on X axis
  26074. * @param zmin defines the minimum value on Z axis
  26075. * @param xmax defines the maximum value on X axis
  26076. * @param zmax defines the maximum value on Z axis
  26077. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26078. * @param precision defines the precision to use when computing the tiles
  26079. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26080. * @param mesh defines the hosting mesh (can be null)
  26081. */
  26082. constructor(id: string, scene: Scene,
  26083. /**
  26084. * Defines the minimum value on X axis
  26085. */
  26086. xmin: number,
  26087. /**
  26088. * Defines the minimum value on Z axis
  26089. */
  26090. zmin: number,
  26091. /**
  26092. * Defines the maximum value on X axis
  26093. */
  26094. xmax: number,
  26095. /**
  26096. * Defines the maximum value on Z axis
  26097. */
  26098. zmax: number,
  26099. /**
  26100. * Defines the subdivisions to apply to the ground
  26101. */
  26102. subdivisions: {
  26103. w: number;
  26104. h: number;
  26105. },
  26106. /**
  26107. * Defines the precision to use when computing the tiles
  26108. */
  26109. precision: {
  26110. w: number;
  26111. h: number;
  26112. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26113. /** @hidden */
  26114. _regenerateVertexData(): VertexData;
  26115. copy(id: string): Geometry;
  26116. }
  26117. /**
  26118. * Creates a plane geometry
  26119. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26120. */
  26121. class PlaneGeometry extends _PrimitiveGeometry {
  26122. /**
  26123. * Defines the size of the plane (width === height)
  26124. */
  26125. size: number;
  26126. /**
  26127. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26128. */
  26129. side: number;
  26130. /**
  26131. * Creates a plane geometry
  26132. * @param id defines the unique ID of the geometry
  26133. * @param scene defines the hosting scene
  26134. * @param size defines the size of the plane (width === height)
  26135. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26136. * @param mesh defines the hosting mesh (can be null)
  26137. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26138. */
  26139. constructor(id: string, scene: Scene,
  26140. /**
  26141. * Defines the size of the plane (width === height)
  26142. */
  26143. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26144. /**
  26145. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26146. */
  26147. side?: number);
  26148. /** @hidden */
  26149. _regenerateVertexData(): VertexData;
  26150. copy(id: string): Geometry;
  26151. serialize(): any;
  26152. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26153. }
  26154. /**
  26155. * Creates a torus knot geometry
  26156. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26157. */
  26158. class TorusKnotGeometry extends _PrimitiveGeometry {
  26159. /**
  26160. * Defines the radius of the torus knot
  26161. */
  26162. radius: number;
  26163. /**
  26164. * Defines the thickness of the torus knot tube
  26165. */
  26166. tube: number;
  26167. /**
  26168. * Defines the number of radial segments
  26169. */
  26170. radialSegments: number;
  26171. /**
  26172. * Defines the number of tubular segments
  26173. */
  26174. tubularSegments: number;
  26175. /**
  26176. * Defines the first number of windings
  26177. */
  26178. p: number;
  26179. /**
  26180. * Defines the second number of windings
  26181. */
  26182. q: number;
  26183. /**
  26184. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26185. */
  26186. side: number;
  26187. /**
  26188. * Creates a torus knot geometry
  26189. * @param id defines the unique ID of the geometry
  26190. * @param scene defines the hosting scene
  26191. * @param radius defines the radius of the torus knot
  26192. * @param tube defines the thickness of the torus knot tube
  26193. * @param radialSegments defines the number of radial segments
  26194. * @param tubularSegments defines the number of tubular segments
  26195. * @param p defines the first number of windings
  26196. * @param q defines the second number of windings
  26197. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26198. * @param mesh defines the hosting mesh (can be null)
  26199. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26200. */
  26201. constructor(id: string, scene: Scene,
  26202. /**
  26203. * Defines the radius of the torus knot
  26204. */
  26205. radius: number,
  26206. /**
  26207. * Defines the thickness of the torus knot tube
  26208. */
  26209. tube: number,
  26210. /**
  26211. * Defines the number of radial segments
  26212. */
  26213. radialSegments: number,
  26214. /**
  26215. * Defines the number of tubular segments
  26216. */
  26217. tubularSegments: number,
  26218. /**
  26219. * Defines the first number of windings
  26220. */
  26221. p: number,
  26222. /**
  26223. * Defines the second number of windings
  26224. */
  26225. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26226. /**
  26227. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26228. */
  26229. side?: number);
  26230. /** @hidden */
  26231. _regenerateVertexData(): VertexData;
  26232. copy(id: string): Geometry;
  26233. serialize(): any;
  26234. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26235. }
  26236. }
  26237. declare module BABYLON {
  26238. /**
  26239. * Mesh representing the gorund
  26240. */
  26241. class GroundMesh extends Mesh {
  26242. /** If octree should be generated */
  26243. generateOctree: boolean;
  26244. private _heightQuads;
  26245. /** @hidden */
  26246. _subdivisionsX: number;
  26247. /** @hidden */
  26248. _subdivisionsY: number;
  26249. /** @hidden */
  26250. _width: number;
  26251. /** @hidden */
  26252. _height: number;
  26253. /** @hidden */
  26254. _minX: number;
  26255. /** @hidden */
  26256. _maxX: number;
  26257. /** @hidden */
  26258. _minZ: number;
  26259. /** @hidden */
  26260. _maxZ: number;
  26261. constructor(name: string, scene: Scene);
  26262. /**
  26263. * "GroundMesh"
  26264. * @returns "GroundMesh"
  26265. */
  26266. getClassName(): string;
  26267. /**
  26268. * The minimum of x and y subdivisions
  26269. */
  26270. readonly subdivisions: number;
  26271. /**
  26272. * X subdivisions
  26273. */
  26274. readonly subdivisionsX: number;
  26275. /**
  26276. * Y subdivisions
  26277. */
  26278. readonly subdivisionsY: number;
  26279. /**
  26280. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26281. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26282. * @param chunksCount the number of subdivisions for x and y
  26283. * @param octreeBlocksSize (Default: 32)
  26284. */
  26285. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26286. /**
  26287. * Returns a height (y) value in the Worl system :
  26288. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26289. * @param x x coordinate
  26290. * @param z z coordinate
  26291. * @returns the ground y position if (x, z) are outside the ground surface.
  26292. */
  26293. getHeightAtCoordinates(x: number, z: number): number;
  26294. /**
  26295. * Returns a normalized vector (Vector3) orthogonal to the ground
  26296. * at the ground coordinates (x, z) expressed in the World system.
  26297. * @param x x coordinate
  26298. * @param z z coordinate
  26299. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26300. */
  26301. getNormalAtCoordinates(x: number, z: number): Vector3;
  26302. /**
  26303. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26304. * at the ground coordinates (x, z) expressed in the World system.
  26305. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26306. * @param x x coordinate
  26307. * @param z z coordinate
  26308. * @param ref vector to store the result
  26309. * @returns the GroundMesh.
  26310. */
  26311. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26312. /**
  26313. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26314. * if the ground has been updated.
  26315. * This can be used in the render loop.
  26316. * @returns the GroundMesh.
  26317. */
  26318. updateCoordinateHeights(): GroundMesh;
  26319. private _getFacetAt;
  26320. private _initHeightQuads;
  26321. private _computeHeightQuads;
  26322. /**
  26323. * Serializes this ground mesh
  26324. * @param serializationObject object to write serialization to
  26325. */
  26326. serialize(serializationObject: any): void;
  26327. /**
  26328. * Parses a serialized ground mesh
  26329. * @param parsedMesh the serialized mesh
  26330. * @param scene the scene to create the ground mesh in
  26331. * @returns the created ground mesh
  26332. */
  26333. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26334. }
  26335. }
  26336. declare module BABYLON {
  26337. /**
  26338. * Creates an instance based on a source mesh.
  26339. */
  26340. class InstancedMesh extends AbstractMesh {
  26341. private _sourceMesh;
  26342. private _currentLOD;
  26343. /** @hidden */
  26344. _indexInSourceMeshInstanceArray: number;
  26345. constructor(name: string, source: Mesh);
  26346. /**
  26347. * Returns the string "InstancedMesh".
  26348. */
  26349. getClassName(): string;
  26350. /**
  26351. * If the source mesh receives shadows
  26352. */
  26353. readonly receiveShadows: boolean;
  26354. /**
  26355. * The material of the source mesh
  26356. */
  26357. readonly material: Nullable<Material>;
  26358. /**
  26359. * Visibility of the source mesh
  26360. */
  26361. readonly visibility: number;
  26362. /**
  26363. * Skeleton of the source mesh
  26364. */
  26365. readonly skeleton: Nullable<Skeleton>;
  26366. /**
  26367. * Rendering ground id of the source mesh
  26368. */
  26369. renderingGroupId: number;
  26370. /**
  26371. * Returns the total number of vertices (integer).
  26372. */
  26373. getTotalVertices(): number;
  26374. /**
  26375. * Returns a positive integer : the total number of indices in this mesh geometry.
  26376. * @returns the numner of indices or zero if the mesh has no geometry.
  26377. */
  26378. getTotalIndices(): number;
  26379. /**
  26380. * The source mesh of the instance
  26381. */
  26382. readonly sourceMesh: Mesh;
  26383. /**
  26384. * Is this node ready to be used/rendered
  26385. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26386. * @return {boolean} is it ready
  26387. */
  26388. isReady(completeCheck?: boolean): boolean;
  26389. /**
  26390. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26391. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26392. * @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.
  26393. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26394. */
  26395. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26396. /**
  26397. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26398. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26399. * The `data` are either a numeric array either a Float32Array.
  26400. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26401. * 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).
  26402. * Note that a new underlying VertexBuffer object is created each call.
  26403. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26404. *
  26405. * Possible `kind` values :
  26406. * - BABYLON.VertexBuffer.PositionKind
  26407. * - BABYLON.VertexBuffer.UVKind
  26408. * - BABYLON.VertexBuffer.UV2Kind
  26409. * - BABYLON.VertexBuffer.UV3Kind
  26410. * - BABYLON.VertexBuffer.UV4Kind
  26411. * - BABYLON.VertexBuffer.UV5Kind
  26412. * - BABYLON.VertexBuffer.UV6Kind
  26413. * - BABYLON.VertexBuffer.ColorKind
  26414. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26415. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26416. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26417. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26418. *
  26419. * Returns the Mesh.
  26420. */
  26421. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26422. /**
  26423. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26424. * If the mesh has no geometry, it is simply returned as it is.
  26425. * The `data` are either a numeric array either a Float32Array.
  26426. * No new underlying VertexBuffer object is created.
  26427. * 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.
  26428. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26429. *
  26430. * Possible `kind` values :
  26431. * - BABYLON.VertexBuffer.PositionKind
  26432. * - BABYLON.VertexBuffer.UVKind
  26433. * - BABYLON.VertexBuffer.UV2Kind
  26434. * - BABYLON.VertexBuffer.UV3Kind
  26435. * - BABYLON.VertexBuffer.UV4Kind
  26436. * - BABYLON.VertexBuffer.UV5Kind
  26437. * - BABYLON.VertexBuffer.UV6Kind
  26438. * - BABYLON.VertexBuffer.ColorKind
  26439. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26440. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26441. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26442. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26443. *
  26444. * Returns the Mesh.
  26445. */
  26446. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26447. /**
  26448. * Sets the mesh indices.
  26449. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26450. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26451. * This method creates a new index buffer each call.
  26452. * Returns the Mesh.
  26453. */
  26454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26455. /**
  26456. * Boolean : True if the mesh owns the requested kind of data.
  26457. */
  26458. isVerticesDataPresent(kind: string): boolean;
  26459. /**
  26460. * Returns an array of indices (IndicesArray).
  26461. */
  26462. getIndices(): Nullable<IndicesArray>;
  26463. readonly _positions: Nullable<Vector3[]>;
  26464. /**
  26465. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26466. * This means the mesh underlying bounding box and sphere are recomputed.
  26467. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26468. * @returns the current mesh
  26469. */
  26470. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26471. /** @hidden */
  26472. _preActivate(): InstancedMesh;
  26473. /** @hidden */
  26474. _activate(renderId: number): InstancedMesh;
  26475. /**
  26476. * Returns the current associated LOD AbstractMesh.
  26477. */
  26478. getLOD(camera: Camera): AbstractMesh;
  26479. /** @hidden */
  26480. _syncSubMeshes(): InstancedMesh;
  26481. /** @hidden */
  26482. _generatePointsArray(): boolean;
  26483. /**
  26484. * Creates a new InstancedMesh from the current mesh.
  26485. * - name (string) : the cloned mesh name
  26486. * - newParent (optional Node) : the optional Node to parent the clone to.
  26487. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26488. *
  26489. * Returns the clone.
  26490. */
  26491. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26492. /**
  26493. * Disposes the InstancedMesh.
  26494. * Returns nothing.
  26495. */
  26496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26497. }
  26498. }
  26499. declare module BABYLON {
  26500. /**
  26501. * Line mesh
  26502. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26503. */
  26504. class LinesMesh extends Mesh {
  26505. /**
  26506. * If vertex color should be applied to the mesh
  26507. */
  26508. useVertexColor?: boolean | undefined;
  26509. /**
  26510. * If vertex alpha should be applied to the mesh
  26511. */
  26512. useVertexAlpha?: boolean | undefined;
  26513. /**
  26514. * Color of the line (Default: White)
  26515. */
  26516. color: Color3;
  26517. /**
  26518. * Alpha of the line (Default: 1)
  26519. */
  26520. alpha: number;
  26521. /**
  26522. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26523. * This margin is expressed in world space coordinates, so its value may vary.
  26524. * Default value is 0.1
  26525. */
  26526. intersectionThreshold: number;
  26527. private _colorShader;
  26528. /**
  26529. * Creates a new LinesMesh
  26530. * @param name defines the name
  26531. * @param scene defines the hosting scene
  26532. * @param parent defines the parent mesh if any
  26533. * @param source defines the optional source LinesMesh used to clone data from
  26534. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26535. * When false, achieved by calling a clone(), also passing False.
  26536. * This will make creation of children, recursive.
  26537. * @param useVertexColor defines if this LinesMesh supports vertex color
  26538. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26539. */
  26540. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26541. /**
  26542. * If vertex color should be applied to the mesh
  26543. */
  26544. useVertexColor?: boolean | undefined,
  26545. /**
  26546. * If vertex alpha should be applied to the mesh
  26547. */
  26548. useVertexAlpha?: boolean | undefined);
  26549. /**
  26550. * Returns the string "LineMesh"
  26551. */
  26552. getClassName(): string;
  26553. /**
  26554. * @hidden
  26555. */
  26556. /**
  26557. * @hidden
  26558. */
  26559. material: Material;
  26560. /**
  26561. * @hidden
  26562. */
  26563. readonly checkCollisions: boolean;
  26564. /** @hidden */
  26565. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26566. /** @hidden */
  26567. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26568. /**
  26569. * Disposes of the line mesh
  26570. * @param doNotRecurse If children should be disposed
  26571. */
  26572. dispose(doNotRecurse?: boolean): void;
  26573. /**
  26574. * Returns a new LineMesh object cloned from the current one.
  26575. */
  26576. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26577. /**
  26578. * Creates a new InstancedLinesMesh object from the mesh model.
  26579. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26580. * @param name defines the name of the new instance
  26581. * @returns a new InstancedLinesMesh
  26582. */
  26583. createInstance(name: string): InstancedLinesMesh;
  26584. }
  26585. /**
  26586. * Creates an instance based on a source LinesMesh
  26587. */
  26588. class InstancedLinesMesh extends InstancedMesh {
  26589. /**
  26590. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26591. * This margin is expressed in world space coordinates, so its value may vary.
  26592. * Initilized with the intersectionThreshold value of the source LinesMesh
  26593. */
  26594. intersectionThreshold: number;
  26595. constructor(name: string, source: LinesMesh);
  26596. /**
  26597. * Returns the string "InstancedLinesMesh".
  26598. */
  26599. getClassName(): string;
  26600. }
  26601. }
  26602. declare module BABYLON {
  26603. /**
  26604. * @hidden
  26605. **/
  26606. class _CreationDataStorage {
  26607. closePath?: boolean;
  26608. closeArray?: boolean;
  26609. idx: number[];
  26610. dashSize: number;
  26611. gapSize: number;
  26612. path3D: Path3D;
  26613. pathArray: Vector3[][];
  26614. arc: number;
  26615. radius: number;
  26616. cap: number;
  26617. tessellation: number;
  26618. }
  26619. /**
  26620. * @hidden
  26621. **/
  26622. class _InstanceDataStorage {
  26623. visibleInstances: any;
  26624. renderIdForInstances: number[];
  26625. batchCache: _InstancesBatch;
  26626. instancesBufferSize: number;
  26627. instancesBuffer: Nullable<Buffer>;
  26628. instancesData: Float32Array;
  26629. overridenInstanceCount: number;
  26630. }
  26631. /**
  26632. * @hidden
  26633. **/
  26634. class _InstancesBatch {
  26635. mustReturn: boolean;
  26636. visibleInstances: Nullable<InstancedMesh[]>[];
  26637. renderSelf: boolean[];
  26638. }
  26639. /**
  26640. * Class used to represent renderable models
  26641. */
  26642. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26643. /**
  26644. * Mesh side orientation : usually the external or front surface
  26645. */
  26646. static readonly FRONTSIDE: number;
  26647. /**
  26648. * Mesh side orientation : usually the internal or back surface
  26649. */
  26650. static readonly BACKSIDE: number;
  26651. /**
  26652. * Mesh side orientation : both internal and external or front and back surfaces
  26653. */
  26654. static readonly DOUBLESIDE: number;
  26655. /**
  26656. * Mesh side orientation : by default, `FRONTSIDE`
  26657. */
  26658. static readonly DEFAULTSIDE: number;
  26659. /**
  26660. * Mesh cap setting : no cap
  26661. */
  26662. static readonly NO_CAP: number;
  26663. /**
  26664. * Mesh cap setting : one cap at the beginning of the mesh
  26665. */
  26666. static readonly CAP_START: number;
  26667. /**
  26668. * Mesh cap setting : one cap at the end of the mesh
  26669. */
  26670. static readonly CAP_END: number;
  26671. /**
  26672. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26673. */
  26674. static readonly CAP_ALL: number;
  26675. private _onBeforeRenderObservable;
  26676. private _onAfterRenderObservable;
  26677. private _onBeforeDrawObservable;
  26678. /**
  26679. * An event triggered before rendering the mesh
  26680. */
  26681. readonly onBeforeRenderObservable: Observable<Mesh>;
  26682. /**
  26683. * An event triggered after rendering the mesh
  26684. */
  26685. readonly onAfterRenderObservable: Observable<Mesh>;
  26686. /**
  26687. * An event triggered before drawing the mesh
  26688. */
  26689. readonly onBeforeDrawObservable: Observable<Mesh>;
  26690. private _onBeforeDrawObserver;
  26691. /**
  26692. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26693. */
  26694. onBeforeDraw: () => void;
  26695. /**
  26696. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26697. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26698. */
  26699. delayLoadState: number;
  26700. /**
  26701. * Gets the list of instances created from this mesh
  26702. * it is not supposed to be modified manually.
  26703. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26704. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26705. */
  26706. instances: InstancedMesh[];
  26707. /**
  26708. * Gets the file containing delay loading data for this mesh
  26709. */
  26710. delayLoadingFile: string;
  26711. /** @hidden */
  26712. _binaryInfo: any;
  26713. private _LODLevels;
  26714. /**
  26715. * User defined function used to change how LOD level selection is done
  26716. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26717. */
  26718. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26719. private _morphTargetManager;
  26720. /**
  26721. * Gets or sets the morph target manager
  26722. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26723. */
  26724. morphTargetManager: Nullable<MorphTargetManager>;
  26725. /** @hidden */
  26726. _creationDataStorage: Nullable<_CreationDataStorage>;
  26727. /** @hidden */
  26728. _geometry: Nullable<Geometry>;
  26729. /** @hidden */
  26730. _delayInfo: Array<string>;
  26731. /** @hidden */
  26732. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26733. /** @hidden */
  26734. _instanceDataStorage: _InstanceDataStorage;
  26735. private _effectiveMaterial;
  26736. /** @hidden */
  26737. _shouldGenerateFlatShading: boolean;
  26738. private _preActivateId;
  26739. /** @hidden */
  26740. _originalBuilderSideOrientation: number;
  26741. /**
  26742. * Use this property to change the original side orientation defined at construction time
  26743. */
  26744. overrideMaterialSideOrientation: Nullable<number>;
  26745. private _areNormalsFrozen;
  26746. private _sourcePositions;
  26747. private _sourceNormals;
  26748. private _source;
  26749. private meshMap;
  26750. /**
  26751. * Gets the source mesh (the one used to clone this one from)
  26752. */
  26753. readonly source: Nullable<Mesh>;
  26754. /**
  26755. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26756. */
  26757. isUnIndexed: boolean;
  26758. /**
  26759. * @constructor
  26760. * @param name The value used by scene.getMeshByName() to do a lookup.
  26761. * @param scene The scene to add this mesh to.
  26762. * @param parent The parent of this mesh, if it has one
  26763. * @param source An optional Mesh from which geometry is shared, cloned.
  26764. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26765. * When false, achieved by calling a clone(), also passing False.
  26766. * This will make creation of children, recursive.
  26767. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26768. */
  26769. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26770. /**
  26771. * Gets the class name
  26772. * @returns the string "Mesh".
  26773. */
  26774. getClassName(): string;
  26775. /**
  26776. * Returns a description of this mesh
  26777. * @param fullDetails define if full details about this mesh must be used
  26778. * @returns a descriptive string representing this mesh
  26779. */
  26780. toString(fullDetails?: boolean): string;
  26781. /** @hidden */
  26782. _unBindEffect(): void;
  26783. /**
  26784. * Gets a boolean indicating if this mesh has LOD
  26785. */
  26786. readonly hasLODLevels: boolean;
  26787. /**
  26788. * Gets the list of MeshLODLevel associated with the current mesh
  26789. * @returns an array of MeshLODLevel
  26790. */
  26791. getLODLevels(): MeshLODLevel[];
  26792. private _sortLODLevels;
  26793. /**
  26794. * Add a mesh as LOD level triggered at the given distance.
  26795. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26796. * @param distance The distance from the center of the object to show this level
  26797. * @param mesh The mesh to be added as LOD level (can be null)
  26798. * @return This mesh (for chaining)
  26799. */
  26800. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26801. /**
  26802. * Returns the LOD level mesh at the passed distance or null if not found.
  26803. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26804. * @param distance The distance from the center of the object to show this level
  26805. * @returns a Mesh or `null`
  26806. */
  26807. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26808. /**
  26809. * Remove a mesh from the LOD array
  26810. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26811. * @param mesh defines the mesh to be removed
  26812. * @return This mesh (for chaining)
  26813. */
  26814. removeLODLevel(mesh: Mesh): Mesh;
  26815. /**
  26816. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26817. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26818. * @param camera defines the camera to use to compute distance
  26819. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26820. * @return This mesh (for chaining)
  26821. */
  26822. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26823. /**
  26824. * Gets the mesh internal Geometry object
  26825. */
  26826. readonly geometry: Nullable<Geometry>;
  26827. /**
  26828. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26829. * @returns the total number of vertices
  26830. */
  26831. getTotalVertices(): number;
  26832. /**
  26833. * Returns the content of an associated vertex buffer
  26834. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26835. * - BABYLON.VertexBuffer.PositionKind
  26836. * - BABYLON.VertexBuffer.UVKind
  26837. * - BABYLON.VertexBuffer.UV2Kind
  26838. * - BABYLON.VertexBuffer.UV3Kind
  26839. * - BABYLON.VertexBuffer.UV4Kind
  26840. * - BABYLON.VertexBuffer.UV5Kind
  26841. * - BABYLON.VertexBuffer.UV6Kind
  26842. * - BABYLON.VertexBuffer.ColorKind
  26843. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26844. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26845. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26846. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26847. * @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
  26848. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26849. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26850. */
  26851. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26852. /**
  26853. * Returns the mesh VertexBuffer object from the requested `kind`
  26854. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26855. * - BABYLON.VertexBuffer.PositionKind
  26856. * - BABYLON.VertexBuffer.UVKind
  26857. * - BABYLON.VertexBuffer.UV2Kind
  26858. * - BABYLON.VertexBuffer.UV3Kind
  26859. * - BABYLON.VertexBuffer.UV4Kind
  26860. * - BABYLON.VertexBuffer.UV5Kind
  26861. * - BABYLON.VertexBuffer.UV6Kind
  26862. * - BABYLON.VertexBuffer.ColorKind
  26863. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26864. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26865. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26866. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26867. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26868. */
  26869. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26870. /**
  26871. * Tests if a specific vertex buffer is associated with this mesh
  26872. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26873. * - BABYLON.VertexBuffer.PositionKind
  26874. * - BABYLON.VertexBuffer.UVKind
  26875. * - BABYLON.VertexBuffer.UV2Kind
  26876. * - BABYLON.VertexBuffer.UV3Kind
  26877. * - BABYLON.VertexBuffer.UV4Kind
  26878. * - BABYLON.VertexBuffer.UV5Kind
  26879. * - BABYLON.VertexBuffer.UV6Kind
  26880. * - BABYLON.VertexBuffer.ColorKind
  26881. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26882. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26883. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26884. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26885. * @returns a boolean
  26886. */
  26887. isVerticesDataPresent(kind: string): boolean;
  26888. /**
  26889. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26890. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26891. * - BABYLON.VertexBuffer.PositionKind
  26892. * - BABYLON.VertexBuffer.UVKind
  26893. * - BABYLON.VertexBuffer.UV2Kind
  26894. * - BABYLON.VertexBuffer.UV3Kind
  26895. * - BABYLON.VertexBuffer.UV4Kind
  26896. * - BABYLON.VertexBuffer.UV5Kind
  26897. * - BABYLON.VertexBuffer.UV6Kind
  26898. * - BABYLON.VertexBuffer.ColorKind
  26899. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26900. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26901. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26902. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26903. * @returns a boolean
  26904. */
  26905. isVertexBufferUpdatable(kind: string): boolean;
  26906. /**
  26907. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26908. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26909. * - BABYLON.VertexBuffer.PositionKind
  26910. * - BABYLON.VertexBuffer.UVKind
  26911. * - BABYLON.VertexBuffer.UV2Kind
  26912. * - BABYLON.VertexBuffer.UV3Kind
  26913. * - BABYLON.VertexBuffer.UV4Kind
  26914. * - BABYLON.VertexBuffer.UV5Kind
  26915. * - BABYLON.VertexBuffer.UV6Kind
  26916. * - BABYLON.VertexBuffer.ColorKind
  26917. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26918. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26919. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26920. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26921. * @returns an array of strings
  26922. */
  26923. getVerticesDataKinds(): string[];
  26924. /**
  26925. * Returns a positive integer : the total number of indices in this mesh geometry.
  26926. * @returns the numner of indices or zero if the mesh has no geometry.
  26927. */
  26928. getTotalIndices(): number;
  26929. /**
  26930. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26931. * @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.
  26932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26933. * @returns the indices array or an empty array if the mesh has no geometry
  26934. */
  26935. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26936. readonly isBlocked: boolean;
  26937. /**
  26938. * Determine if the current mesh is ready to be rendered
  26939. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26940. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26941. * @returns true if all associated assets are ready (material, textures, shaders)
  26942. */
  26943. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26944. /**
  26945. * 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.
  26946. */
  26947. readonly areNormalsFrozen: boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  26950. * @returns the current mesh
  26951. */
  26952. freezeNormals(): Mesh;
  26953. /**
  26954. * 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
  26955. * @returns the current mesh
  26956. */
  26957. unfreezeNormals(): Mesh;
  26958. /**
  26959. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26960. */
  26961. overridenInstanceCount: number;
  26962. /** @hidden */
  26963. _preActivate(): Mesh;
  26964. /** @hidden */
  26965. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26966. /** @hidden */
  26967. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26968. /**
  26969. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26970. * This means the mesh underlying bounding box and sphere are recomputed.
  26971. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26972. * @returns the current mesh
  26973. */
  26974. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26975. /** @hidden */
  26976. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26977. /**
  26978. * This function will subdivide the mesh into multiple submeshes
  26979. * @param count defines the expected number of submeshes
  26980. */
  26981. subdivide(count: number): void;
  26982. /**
  26983. * Copy a FloatArray into a specific associated vertex buffer
  26984. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26985. * - BABYLON.VertexBuffer.PositionKind
  26986. * - BABYLON.VertexBuffer.UVKind
  26987. * - BABYLON.VertexBuffer.UV2Kind
  26988. * - BABYLON.VertexBuffer.UV3Kind
  26989. * - BABYLON.VertexBuffer.UV4Kind
  26990. * - BABYLON.VertexBuffer.UV5Kind
  26991. * - BABYLON.VertexBuffer.UV6Kind
  26992. * - BABYLON.VertexBuffer.ColorKind
  26993. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26994. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26995. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26996. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26997. * @param data defines the data source
  26998. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26999. * @param stride defines the data stride size (can be null)
  27000. * @returns the current mesh
  27001. */
  27002. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  27003. /**
  27004. * Flags an associated vertex buffer as updatable
  27005. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27006. * - BABYLON.VertexBuffer.PositionKind
  27007. * - BABYLON.VertexBuffer.UVKind
  27008. * - BABYLON.VertexBuffer.UV2Kind
  27009. * - BABYLON.VertexBuffer.UV3Kind
  27010. * - BABYLON.VertexBuffer.UV4Kind
  27011. * - BABYLON.VertexBuffer.UV5Kind
  27012. * - BABYLON.VertexBuffer.UV6Kind
  27013. * - BABYLON.VertexBuffer.ColorKind
  27014. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27015. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27016. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27017. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27018. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27019. */
  27020. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27021. /**
  27022. * Sets the mesh global Vertex Buffer
  27023. * @param buffer defines the buffer to use
  27024. * @returns the current mesh
  27025. */
  27026. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27027. /**
  27028. * Update a specific associated vertex buffer
  27029. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27030. * - BABYLON.VertexBuffer.PositionKind
  27031. * - BABYLON.VertexBuffer.UVKind
  27032. * - BABYLON.VertexBuffer.UV2Kind
  27033. * - BABYLON.VertexBuffer.UV3Kind
  27034. * - BABYLON.VertexBuffer.UV4Kind
  27035. * - BABYLON.VertexBuffer.UV5Kind
  27036. * - BABYLON.VertexBuffer.UV6Kind
  27037. * - BABYLON.VertexBuffer.ColorKind
  27038. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27039. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27040. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27041. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27042. * @param data defines the data source
  27043. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27044. * @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)
  27045. * @returns the current mesh
  27046. */
  27047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27048. /**
  27049. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27050. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27051. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27052. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27053. * @returns the current mesh
  27054. */
  27055. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27056. /**
  27057. * Creates a un-shared specific occurence of the geometry for the mesh.
  27058. * @returns the current mesh
  27059. */
  27060. makeGeometryUnique(): Mesh;
  27061. /**
  27062. * Set the index buffer of this mesh
  27063. * @param indices defines the source data
  27064. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27065. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27066. * @returns the current mesh
  27067. */
  27068. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27069. /**
  27070. * Update the current index buffer
  27071. * @param indices defines the source data
  27072. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27073. * @returns the current mesh
  27074. */
  27075. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27076. /**
  27077. * Invert the geometry to move from a right handed system to a left handed one.
  27078. * @returns the current mesh
  27079. */
  27080. toLeftHanded(): Mesh;
  27081. /** @hidden */
  27082. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27083. /** @hidden */
  27084. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27085. /**
  27086. * Registers for this mesh a javascript function called just before the rendering process
  27087. * @param func defines the function to call before rendering this mesh
  27088. * @returns the current mesh
  27089. */
  27090. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27091. /**
  27092. * Disposes a previously registered javascript function called before the rendering
  27093. * @param func defines the function to remove
  27094. * @returns the current mesh
  27095. */
  27096. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27097. /**
  27098. * Registers for this mesh a javascript function called just after the rendering is complete
  27099. * @param func defines the function to call after rendering this mesh
  27100. * @returns the current mesh
  27101. */
  27102. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27103. /**
  27104. * Disposes a previously registered javascript function called after the rendering.
  27105. * @param func defines the function to remove
  27106. * @returns the current mesh
  27107. */
  27108. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27109. /** @hidden */
  27110. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27111. /** @hidden */
  27112. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27113. /** @hidden */
  27114. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27115. /**
  27116. * 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
  27117. * @param subMesh defines the subMesh to render
  27118. * @param enableAlphaMode defines if alpha mode can be changed
  27119. * @returns the current mesh
  27120. */
  27121. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27122. private _onBeforeDraw;
  27123. /**
  27124. * Renormalize the mesh and patch it up if there are no weights
  27125. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27126. * However in the case of zero weights then we set just a single influence to 1.
  27127. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27128. */
  27129. cleanMatrixWeights(): void;
  27130. private normalizeSkinFourWeights;
  27131. private normalizeSkinWeightsAndExtra;
  27132. /**
  27133. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27134. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27135. * the user know there was an issue with importing the mesh
  27136. * @returns a validation object with skinned, valid and report string
  27137. */
  27138. validateSkinning(): {
  27139. skinned: boolean;
  27140. valid: boolean;
  27141. report: string;
  27142. };
  27143. /** @hidden */
  27144. _checkDelayState(): Mesh;
  27145. private _queueLoad;
  27146. /**
  27147. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27148. * A mesh is in the frustum if its bounding box intersects the frustum
  27149. * @param frustumPlanes defines the frustum to test
  27150. * @returns true if the mesh is in the frustum planes
  27151. */
  27152. isInFrustum(frustumPlanes: Plane[]): boolean;
  27153. /**
  27154. * Sets the mesh material by the material or multiMaterial `id` property
  27155. * @param id is a string identifying the material or the multiMaterial
  27156. * @returns the current mesh
  27157. */
  27158. setMaterialByID(id: string): Mesh;
  27159. /**
  27160. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27161. * @returns an array of IAnimatable
  27162. */
  27163. getAnimatables(): IAnimatable[];
  27164. /**
  27165. * Modifies the mesh geometry according to the passed transformation matrix.
  27166. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27167. * The mesh normals are modified using the same transformation.
  27168. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27169. * @param transform defines the transform matrix to use
  27170. * @see http://doc.babylonjs.com/resources/baking_transformations
  27171. * @returns the current mesh
  27172. */
  27173. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27174. /**
  27175. * Modifies the mesh geometry according to its own current World Matrix.
  27176. * The mesh World Matrix is then reset.
  27177. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27178. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27179. * @see http://doc.babylonjs.com/resources/baking_transformations
  27180. * @returns the current mesh
  27181. */
  27182. bakeCurrentTransformIntoVertices(): Mesh;
  27183. /** @hidden */
  27184. readonly _positions: Nullable<Vector3[]>;
  27185. /** @hidden */
  27186. _resetPointsArrayCache(): Mesh;
  27187. /** @hidden */
  27188. _generatePointsArray(): boolean;
  27189. /**
  27190. * Returns a new Mesh object generated from the current mesh properties.
  27191. * This method must not get confused with createInstance()
  27192. * @param name is a string, the name given to the new mesh
  27193. * @param newParent can be any Node object (default `null`)
  27194. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27195. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27196. * @returns a new mesh
  27197. */
  27198. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27199. /**
  27200. * Releases resources associated with this mesh.
  27201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27203. */
  27204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27205. /**
  27206. * Modifies the mesh geometry according to a displacement map.
  27207. * 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.
  27208. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27209. * @param url is a string, the URL from the image file is to be downloaded.
  27210. * @param minHeight is the lower limit of the displacement.
  27211. * @param maxHeight is the upper limit of the displacement.
  27212. * @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.
  27213. * @param uvOffset is an optional vector2 used to offset UV.
  27214. * @param uvScale is an optional vector2 used to scale UV.
  27215. * @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.
  27216. * @returns the Mesh.
  27217. */
  27218. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27219. /**
  27220. * Modifies the mesh geometry according to a displacementMap buffer.
  27221. * 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.
  27222. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27223. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27224. * @param heightMapWidth is the width of the buffer image.
  27225. * @param heightMapHeight is the height of the buffer image.
  27226. * @param minHeight is the lower limit of the displacement.
  27227. * @param maxHeight is the upper limit of the displacement.
  27228. * @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.
  27229. * @param uvOffset is an optional vector2 used to offset UV.
  27230. * @param uvScale is an optional vector2 used to scale UV.
  27231. * @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.
  27232. * @returns the Mesh.
  27233. */
  27234. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27235. /**
  27236. * Modify the mesh to get a flat shading rendering.
  27237. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27238. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27239. * @returns current mesh
  27240. */
  27241. convertToFlatShadedMesh(): Mesh;
  27242. /**
  27243. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27244. * In other words, more vertices, no more indices and a single bigger VBO.
  27245. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27246. * @returns current mesh
  27247. */
  27248. convertToUnIndexedMesh(): Mesh;
  27249. /**
  27250. * Inverses facet orientations.
  27251. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27252. * @param flipNormals will also inverts the normals
  27253. * @returns current mesh
  27254. */
  27255. flipFaces(flipNormals?: boolean): Mesh;
  27256. /**
  27257. * Creates a new InstancedMesh object from the mesh model.
  27258. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27259. * @param name defines the name of the new instance
  27260. * @returns a new InstancedMesh
  27261. */
  27262. createInstance(name: string): InstancedMesh;
  27263. /**
  27264. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27265. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27266. * @returns the current mesh
  27267. */
  27268. synchronizeInstances(): Mesh;
  27269. /**
  27270. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27271. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27272. * This should be used together with the simplification to avoid disappearing triangles.
  27273. * @param successCallback an optional success callback to be called after the optimization finished.
  27274. * @returns the current mesh
  27275. */
  27276. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27277. /**
  27278. * Serialize current mesh
  27279. * @param serializationObject defines the object which will receive the serialization data
  27280. */
  27281. serialize(serializationObject: any): void;
  27282. /** @hidden */
  27283. _syncGeometryWithMorphTargetManager(): void;
  27284. /**
  27285. * Returns a new Mesh object parsed from the source provided.
  27286. * @param parsedMesh is the source
  27287. * @param scene defines the hosting scene
  27288. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27289. * @returns a new Mesh
  27290. */
  27291. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27292. /**
  27293. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27294. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27295. * @param name defines the name of the mesh to create
  27296. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27297. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27298. * @param closePath creates a seam between the first and the last points of each path of the path array
  27299. * @param offset is taken in account only if the `pathArray` is containing a single path
  27300. * @param scene defines the hosting scene
  27301. * @param updatable defines if the mesh must be flagged as updatable
  27302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27303. * @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)
  27304. * @returns a new Mesh
  27305. */
  27306. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27307. /**
  27308. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27309. * @param name defines the name of the mesh to create
  27310. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27311. * @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
  27312. * @param scene defines the hosting scene
  27313. * @param updatable defines if the mesh must be flagged as updatable
  27314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27315. * @returns a new Mesh
  27316. */
  27317. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27318. /**
  27319. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27320. * @param name defines the name of the mesh to create
  27321. * @param size sets the size (float) of each box side (default 1)
  27322. * @param scene defines the hosting scene
  27323. * @param updatable defines if the mesh must be flagged as updatable
  27324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27325. * @returns a new Mesh
  27326. */
  27327. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27328. /**
  27329. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27330. * @param name defines the name of the mesh to create
  27331. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27332. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27333. * @param scene defines the hosting scene
  27334. * @param updatable defines if the mesh must be flagged as updatable
  27335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27336. * @returns a new Mesh
  27337. */
  27338. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27339. /**
  27340. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27341. * @param name defines the name of the mesh to create
  27342. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27343. * @param diameterTop set the top cap diameter (floats, default 1)
  27344. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27345. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27346. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27347. * @param scene defines the hosting scene
  27348. * @param updatable defines if the mesh must be flagged as updatable
  27349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27350. * @returns a new Mesh
  27351. */
  27352. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27353. /**
  27354. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27355. * @param name defines the name of the mesh to create
  27356. * @param diameter sets the diameter size (float) of the torus (default 1)
  27357. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27358. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27359. * @param scene defines the hosting scene
  27360. * @param updatable defines if the mesh must be flagged as updatable
  27361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27362. * @returns a new Mesh
  27363. */
  27364. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27365. /**
  27366. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27367. * @param name defines the name of the mesh to create
  27368. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27369. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27370. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27371. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27372. * @param p the number of windings on X axis (positive integers, default 2)
  27373. * @param q the number of windings on Y axis (positive integers, default 3)
  27374. * @param scene defines the hosting scene
  27375. * @param updatable defines if the mesh must be flagged as updatable
  27376. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27377. * @returns a new Mesh
  27378. */
  27379. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27380. /**
  27381. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27382. * @param name defines the name of the mesh to create
  27383. * @param points is an array successive Vector3
  27384. * @param scene defines the hosting scene
  27385. * @param updatable defines if the mesh must be flagged as updatable
  27386. * @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).
  27387. * @returns a new Mesh
  27388. */
  27389. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27390. /**
  27391. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27392. * @param name defines the name of the mesh to create
  27393. * @param points is an array successive Vector3
  27394. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27395. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27396. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27397. * @param scene defines the hosting scene
  27398. * @param updatable defines if the mesh must be flagged as updatable
  27399. * @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)
  27400. * @returns a new Mesh
  27401. */
  27402. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27403. /**
  27404. * Creates a polygon mesh.
  27405. * Please consider using the same method from the MeshBuilder class instead.
  27406. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27407. * 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.
  27408. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27409. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27410. * Remember you can only change the shape positions, not their number when updating a polygon.
  27411. */
  27412. /**
  27413. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27414. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27415. * @param name defines the name of the mesh to create
  27416. * @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
  27417. * @param scene defines the hosting scene
  27418. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27419. * @param updatable defines if the mesh must be flagged as updatable
  27420. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27421. * @returns a new Mesh
  27422. */
  27423. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27424. /**
  27425. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27426. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27427. * @param name defines the name of the mesh to create
  27428. * @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
  27429. * @param depth defines the height of extrusion
  27430. * @param scene defines the hosting scene
  27431. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27432. * @param updatable defines if the mesh must be flagged as updatable
  27433. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27434. * @returns a new Mesh
  27435. */
  27436. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27437. /**
  27438. * Creates an extruded shape mesh.
  27439. * 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
  27440. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27441. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27442. * @param name defines the name of the mesh to create
  27443. * @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
  27444. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27445. * @param scale is the value to scale the shape
  27446. * @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
  27447. * @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
  27448. * @param scene defines the hosting scene
  27449. * @param updatable defines if the mesh must be flagged as updatable
  27450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27451. * @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)
  27452. * @returns a new Mesh
  27453. */
  27454. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27455. /**
  27456. * Creates an custom extruded shape mesh.
  27457. * The custom extrusion is a parametric shape.
  27458. * It has no predefined shape. Its final shape will depend on the input parameters.
  27459. * Please consider using the same method from the MeshBuilder class instead
  27460. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27461. * @param name defines the name of the mesh to create
  27462. * @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
  27463. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27464. * @param scaleFunction is a custom Javascript function called on each path point
  27465. * @param rotationFunction is a custom Javascript function called on each path point
  27466. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27467. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27468. * @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
  27469. * @param scene defines the hosting scene
  27470. * @param updatable defines if the mesh must be flagged as updatable
  27471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27472. * @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)
  27473. * @returns a new Mesh
  27474. */
  27475. 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;
  27476. /**
  27477. * Creates lathe mesh.
  27478. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27479. * Please consider using the same method from the MeshBuilder class instead
  27480. * @param name defines the name of the mesh to create
  27481. * @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
  27482. * @param radius is the radius value of the lathe
  27483. * @param tessellation is the side number of the lathe.
  27484. * @param scene defines the hosting scene
  27485. * @param updatable defines if the mesh must be flagged as updatable
  27486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27487. * @returns a new Mesh
  27488. */
  27489. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27490. /**
  27491. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27492. * @param name defines the name of the mesh to create
  27493. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27494. * @param scene defines the hosting scene
  27495. * @param updatable defines if the mesh must be flagged as updatable
  27496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27497. * @returns a new Mesh
  27498. */
  27499. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27500. /**
  27501. * Creates a ground mesh.
  27502. * Please consider using the same method from the MeshBuilder class instead
  27503. * @param name defines the name of the mesh to create
  27504. * @param width set the width of the ground
  27505. * @param height set the height of the ground
  27506. * @param subdivisions sets the number of subdivisions per side
  27507. * @param scene defines the hosting scene
  27508. * @param updatable defines if the mesh must be flagged as updatable
  27509. * @returns a new Mesh
  27510. */
  27511. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27512. /**
  27513. * Creates a tiled ground mesh.
  27514. * Please consider using the same method from the MeshBuilder class instead
  27515. * @param name defines the name of the mesh to create
  27516. * @param xmin set the ground minimum X coordinate
  27517. * @param zmin set the ground minimum Y coordinate
  27518. * @param xmax set the ground maximum X coordinate
  27519. * @param zmax set the ground maximum Z coordinate
  27520. * @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
  27521. * @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
  27522. * @param scene defines the hosting scene
  27523. * @param updatable defines if the mesh must be flagged as updatable
  27524. * @returns a new Mesh
  27525. */
  27526. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27527. w: number;
  27528. h: number;
  27529. }, precision: {
  27530. w: number;
  27531. h: number;
  27532. }, scene: Scene, updatable?: boolean): Mesh;
  27533. /**
  27534. * Creates a ground mesh from a height map.
  27535. * Please consider using the same method from the MeshBuilder class instead
  27536. * @see http://doc.babylonjs.com/babylon101/height_map
  27537. * @param name defines the name of the mesh to create
  27538. * @param url sets the URL of the height map image resource
  27539. * @param width set the ground width size
  27540. * @param height set the ground height size
  27541. * @param subdivisions sets the number of subdivision per side
  27542. * @param minHeight is the minimum altitude on the ground
  27543. * @param maxHeight is the maximum altitude on the ground
  27544. * @param scene defines the hosting scene
  27545. * @param updatable defines if the mesh must be flagged as updatable
  27546. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27547. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27548. * @returns a new Mesh
  27549. */
  27550. 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;
  27551. /**
  27552. * Creates a tube mesh.
  27553. * The tube is a parametric shape.
  27554. * It has no predefined shape. Its final shape will depend on the input parameters.
  27555. * Please consider using the same method from the MeshBuilder class instead
  27556. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27557. * @param name defines the name of the mesh to create
  27558. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27559. * @param radius sets the tube radius size
  27560. * @param tessellation is the number of sides on the tubular surface
  27561. * @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
  27562. * @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
  27563. * @param scene defines the hosting scene
  27564. * @param updatable defines if the mesh must be flagged as updatable
  27565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27566. * @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)
  27567. * @returns a new Mesh
  27568. */
  27569. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27570. (i: number, distance: number): number;
  27571. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27572. /**
  27573. * Creates a polyhedron mesh.
  27574. * Please consider using the same method from the MeshBuilder class instead.
  27575. * * 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
  27576. * * The parameter `size` (positive float, default 1) sets the polygon size
  27577. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27578. * * 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`
  27579. * * 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
  27580. * * 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)`)
  27581. * * 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
  27582. * * 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
  27583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27584. * * 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
  27585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27586. * @param name defines the name of the mesh to create
  27587. * @param options defines the options used to create the mesh
  27588. * @param scene defines the hosting scene
  27589. * @returns a new Mesh
  27590. */
  27591. static CreatePolyhedron(name: string, options: {
  27592. type?: number;
  27593. size?: number;
  27594. sizeX?: number;
  27595. sizeY?: number;
  27596. sizeZ?: number;
  27597. custom?: any;
  27598. faceUV?: Vector4[];
  27599. faceColors?: Color4[];
  27600. updatable?: boolean;
  27601. sideOrientation?: number;
  27602. }, scene: Scene): Mesh;
  27603. /**
  27604. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27605. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27606. * * 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`)
  27607. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27608. * * 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
  27609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27610. * * 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
  27611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27612. * @param name defines the name of the mesh
  27613. * @param options defines the options used to create the mesh
  27614. * @param scene defines the hosting scene
  27615. * @returns a new Mesh
  27616. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27617. */
  27618. static CreateIcoSphere(name: string, options: {
  27619. radius?: number;
  27620. flat?: boolean;
  27621. subdivisions?: number;
  27622. sideOrientation?: number;
  27623. updatable?: boolean;
  27624. }, scene: Scene): Mesh;
  27625. /**
  27626. * Creates a decal mesh.
  27627. * Please consider using the same method from the MeshBuilder class instead.
  27628. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27629. * @param name defines the name of the mesh
  27630. * @param sourceMesh defines the mesh receiving the decal
  27631. * @param position sets the position of the decal in world coordinates
  27632. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27633. * @param size sets the decal scaling
  27634. * @param angle sets the angle to rotate the decal
  27635. * @returns a new Mesh
  27636. */
  27637. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27638. /**
  27639. * Prepare internal position array for software CPU skinning
  27640. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27641. */
  27642. setPositionsForCPUSkinning(): Float32Array;
  27643. /**
  27644. * Prepare internal normal array for software CPU skinning
  27645. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27646. */
  27647. setNormalsForCPUSkinning(): Float32Array;
  27648. /**
  27649. * Updates the vertex buffer by applying transformation from the bones
  27650. * @param skeleton defines the skeleton to apply to current mesh
  27651. * @returns the current mesh
  27652. */
  27653. applySkeleton(skeleton: Skeleton): Mesh;
  27654. /**
  27655. * 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
  27656. * @param meshes defines the list of meshes to scan
  27657. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27658. */
  27659. static MinMax(meshes: AbstractMesh[]): {
  27660. min: Vector3;
  27661. max: Vector3;
  27662. };
  27663. /**
  27664. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27665. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27666. * @returns a vector3
  27667. */
  27668. static Center(meshesOrMinMaxVector: {
  27669. min: Vector3;
  27670. max: Vector3;
  27671. } | AbstractMesh[]): Vector3;
  27672. /**
  27673. * Merge the array of meshes into a single mesh for performance reasons.
  27674. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27675. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27676. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27677. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27678. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27679. * @returns a new mesh
  27680. */
  27681. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27682. /** @hidden */
  27683. addInstance(instance: InstancedMesh): void;
  27684. /** @hidden */
  27685. removeInstance(instance: InstancedMesh): void;
  27686. }
  27687. }
  27688. declare module BABYLON {
  27689. /**
  27690. * Define an interface for all classes that will get and set the data on vertices
  27691. */
  27692. interface IGetSetVerticesData {
  27693. /**
  27694. * Gets a boolean indicating if specific vertex data is present
  27695. * @param kind defines the vertex data kind to use
  27696. * @returns true is data kind is present
  27697. */
  27698. isVerticesDataPresent(kind: string): boolean;
  27699. /**
  27700. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27701. * @param kind defines the data kind (Position, normal, etc...)
  27702. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27703. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27704. * @returns a float array containing vertex data
  27705. */
  27706. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27707. /**
  27708. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27709. * @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.
  27710. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27711. * @returns the indices array or an empty array if the mesh has no geometry
  27712. */
  27713. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27714. /**
  27715. * Set specific vertex data
  27716. * @param kind defines the data kind (Position, normal, etc...)
  27717. * @param data defines the vertex data to use
  27718. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27719. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27720. */
  27721. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27722. /**
  27723. * Update a specific associated vertex buffer
  27724. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27725. * - BABYLON.VertexBuffer.PositionKind
  27726. * - BABYLON.VertexBuffer.UVKind
  27727. * - BABYLON.VertexBuffer.UV2Kind
  27728. * - BABYLON.VertexBuffer.UV3Kind
  27729. * - BABYLON.VertexBuffer.UV4Kind
  27730. * - BABYLON.VertexBuffer.UV5Kind
  27731. * - BABYLON.VertexBuffer.UV6Kind
  27732. * - BABYLON.VertexBuffer.ColorKind
  27733. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27734. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27735. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27736. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27737. * @param data defines the data source
  27738. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27739. * @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)
  27740. */
  27741. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27742. /**
  27743. * Creates a new index buffer
  27744. * @param indices defines the indices to store in the index buffer
  27745. * @param totalVertices defines the total number of vertices (could be null)
  27746. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27747. */
  27748. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27749. }
  27750. /**
  27751. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27752. */
  27753. class VertexData {
  27754. /**
  27755. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27756. */
  27757. positions: Nullable<FloatArray>;
  27758. /**
  27759. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27760. */
  27761. normals: Nullable<FloatArray>;
  27762. /**
  27763. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27764. */
  27765. tangents: Nullable<FloatArray>;
  27766. /**
  27767. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27768. */
  27769. uvs: Nullable<FloatArray>;
  27770. /**
  27771. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27772. */
  27773. uvs2: Nullable<FloatArray>;
  27774. /**
  27775. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27776. */
  27777. uvs3: Nullable<FloatArray>;
  27778. /**
  27779. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27780. */
  27781. uvs4: Nullable<FloatArray>;
  27782. /**
  27783. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27784. */
  27785. uvs5: Nullable<FloatArray>;
  27786. /**
  27787. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27788. */
  27789. uvs6: Nullable<FloatArray>;
  27790. /**
  27791. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27792. */
  27793. colors: Nullable<FloatArray>;
  27794. /**
  27795. * 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).
  27796. */
  27797. matricesIndices: Nullable<FloatArray>;
  27798. /**
  27799. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27800. */
  27801. matricesWeights: Nullable<FloatArray>;
  27802. /**
  27803. * An array extending the number of possible indices
  27804. */
  27805. matricesIndicesExtra: Nullable<FloatArray>;
  27806. /**
  27807. * An array extending the number of possible weights when the number of indices is extended
  27808. */
  27809. matricesWeightsExtra: Nullable<FloatArray>;
  27810. /**
  27811. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27812. */
  27813. indices: Nullable<IndicesArray>;
  27814. /**
  27815. * Uses the passed data array to set the set the values for the specified kind of data
  27816. * @param data a linear array of floating numbers
  27817. * @param kind the type of data that is being set, eg positions, colors etc
  27818. */
  27819. set(data: FloatArray, kind: string): void;
  27820. /**
  27821. * Associates the vertexData to the passed Mesh.
  27822. * Sets it as updatable or not (default `false`)
  27823. * @param mesh the mesh the vertexData is applied to
  27824. * @param updatable when used and having the value true allows new data to update the vertexData
  27825. * @returns the VertexData
  27826. */
  27827. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27828. /**
  27829. * Associates the vertexData to the passed Geometry.
  27830. * Sets it as updatable or not (default `false`)
  27831. * @param geometry the geometry the vertexData is applied to
  27832. * @param updatable when used and having the value true allows new data to update the vertexData
  27833. * @returns VertexData
  27834. */
  27835. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27836. /**
  27837. * Updates the associated mesh
  27838. * @param mesh the mesh to be updated
  27839. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27840. * @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
  27841. * @returns VertexData
  27842. */
  27843. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27844. /**
  27845. * Updates the associated geometry
  27846. * @param geometry the geometry to be updated
  27847. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27848. * @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
  27849. * @returns VertexData.
  27850. */
  27851. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27852. private _applyTo;
  27853. private _update;
  27854. /**
  27855. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27856. * @param matrix the transforming matrix
  27857. * @returns the VertexData
  27858. */
  27859. transform(matrix: Matrix): VertexData;
  27860. /**
  27861. * Merges the passed VertexData into the current one
  27862. * @param other the VertexData to be merged into the current one
  27863. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27864. * @returns the modified VertexData
  27865. */
  27866. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27867. private _mergeElement;
  27868. private _validate;
  27869. /**
  27870. * Serializes the VertexData
  27871. * @returns a serialized object
  27872. */
  27873. serialize(): any;
  27874. /**
  27875. * Extracts the vertexData from a mesh
  27876. * @param mesh the mesh from which to extract the VertexData
  27877. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27878. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27879. * @returns the object VertexData associated to the passed mesh
  27880. */
  27881. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27882. /**
  27883. * Extracts the vertexData from the geometry
  27884. * @param geometry the geometry from which to extract the VertexData
  27885. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27886. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27887. * @returns the object VertexData associated to the passed mesh
  27888. */
  27889. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27890. private static _ExtractFrom;
  27891. /**
  27892. * Creates the VertexData for a Ribbon
  27893. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27894. * * pathArray array of paths, each of which an array of successive Vector3
  27895. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27896. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27897. * * 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
  27898. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27899. * * 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)
  27900. * * 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)
  27901. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27902. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27903. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27904. * @returns the VertexData of the ribbon
  27905. */
  27906. static CreateRibbon(options: {
  27907. pathArray: Vector3[][];
  27908. closeArray?: boolean;
  27909. closePath?: boolean;
  27910. offset?: number;
  27911. sideOrientation?: number;
  27912. frontUVs?: Vector4;
  27913. backUVs?: Vector4;
  27914. invertUV?: boolean;
  27915. uvs?: Vector2[];
  27916. colors?: Color4[];
  27917. }): VertexData;
  27918. /**
  27919. * Creates the VertexData for a box
  27920. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27921. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27922. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27923. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27924. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27925. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27926. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27927. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27928. * * 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)
  27929. * * 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)
  27930. * @returns the VertexData of the box
  27931. */
  27932. static CreateBox(options: {
  27933. size?: number;
  27934. width?: number;
  27935. height?: number;
  27936. depth?: number;
  27937. faceUV?: Vector4[];
  27938. faceColors?: Color4[];
  27939. sideOrientation?: number;
  27940. frontUVs?: Vector4;
  27941. backUVs?: Vector4;
  27942. }): VertexData;
  27943. /**
  27944. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27945. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27946. * * segments sets the number of horizontal strips optional, default 32
  27947. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27948. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27949. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27950. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27951. * * 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
  27952. * * 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
  27953. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27954. * * 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)
  27955. * * 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)
  27956. * @returns the VertexData of the ellipsoid
  27957. */
  27958. static CreateSphere(options: {
  27959. segments?: number;
  27960. diameter?: number;
  27961. diameterX?: number;
  27962. diameterY?: number;
  27963. diameterZ?: number;
  27964. arc?: number;
  27965. slice?: number;
  27966. sideOrientation?: number;
  27967. frontUVs?: Vector4;
  27968. backUVs?: Vector4;
  27969. }): VertexData;
  27970. /**
  27971. * Creates the VertexData for a cylinder, cone or prism
  27972. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27973. * * height sets the height (y direction) of the cylinder, optional, default 2
  27974. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27975. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27976. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27977. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27978. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27979. * * 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
  27980. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27981. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27982. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27983. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27984. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27985. * * 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)
  27986. * * 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)
  27987. * @returns the VertexData of the cylinder, cone or prism
  27988. */
  27989. static CreateCylinder(options: {
  27990. height?: number;
  27991. diameterTop?: number;
  27992. diameterBottom?: number;
  27993. diameter?: number;
  27994. tessellation?: number;
  27995. subdivisions?: number;
  27996. arc?: number;
  27997. faceColors?: Color4[];
  27998. faceUV?: Vector4[];
  27999. hasRings?: boolean;
  28000. enclose?: boolean;
  28001. sideOrientation?: number;
  28002. frontUVs?: Vector4;
  28003. backUVs?: Vector4;
  28004. }): VertexData;
  28005. /**
  28006. * Creates the VertexData for a torus
  28007. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28008. * * diameter the diameter of the torus, optional default 1
  28009. * * thickness the diameter of the tube forming the torus, optional default 0.5
  28010. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28011. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28012. * * 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)
  28013. * * 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)
  28014. * @returns the VertexData of the torus
  28015. */
  28016. static CreateTorus(options: {
  28017. diameter?: number;
  28018. thickness?: number;
  28019. tessellation?: number;
  28020. sideOrientation?: number;
  28021. frontUVs?: Vector4;
  28022. backUVs?: Vector4;
  28023. }): VertexData;
  28024. /**
  28025. * Creates the VertexData of the LineSystem
  28026. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  28027. * - lines an array of lines, each line being an array of successive Vector3
  28028. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  28029. * @returns the VertexData of the LineSystem
  28030. */
  28031. static CreateLineSystem(options: {
  28032. lines: Vector3[][];
  28033. colors?: Nullable<Color4[][]>;
  28034. }): VertexData;
  28035. /**
  28036. * Create the VertexData for a DashedLines
  28037. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  28038. * - points an array successive Vector3
  28039. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  28040. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  28041. * - dashNb the intended total number of dashes, optional, default 200
  28042. * @returns the VertexData for the DashedLines
  28043. */
  28044. static CreateDashedLines(options: {
  28045. points: Vector3[];
  28046. dashSize?: number;
  28047. gapSize?: number;
  28048. dashNb?: number;
  28049. }): VertexData;
  28050. /**
  28051. * Creates the VertexData for a Ground
  28052. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28053. * - width the width (x direction) of the ground, optional, default 1
  28054. * - height the height (z direction) of the ground, optional, default 1
  28055. * - subdivisions the number of subdivisions per side, optional, default 1
  28056. * @returns the VertexData of the Ground
  28057. */
  28058. static CreateGround(options: {
  28059. width?: number;
  28060. height?: number;
  28061. subdivisions?: number;
  28062. subdivisionsX?: number;
  28063. subdivisionsY?: number;
  28064. }): VertexData;
  28065. /**
  28066. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28067. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28068. * * xmin the ground minimum X coordinate, optional, default -1
  28069. * * zmin the ground minimum Z coordinate, optional, default -1
  28070. * * xmax the ground maximum X coordinate, optional, default 1
  28071. * * zmax the ground maximum Z coordinate, optional, default 1
  28072. * * 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}
  28073. * * 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}
  28074. * @returns the VertexData of the TiledGround
  28075. */
  28076. static CreateTiledGround(options: {
  28077. xmin: number;
  28078. zmin: number;
  28079. xmax: number;
  28080. zmax: number;
  28081. subdivisions?: {
  28082. w: number;
  28083. h: number;
  28084. };
  28085. precision?: {
  28086. w: number;
  28087. h: number;
  28088. };
  28089. }): VertexData;
  28090. /**
  28091. * Creates the VertexData of the Ground designed from a heightmap
  28092. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28093. * * width the width (x direction) of the ground
  28094. * * height the height (z direction) of the ground
  28095. * * subdivisions the number of subdivisions per side
  28096. * * minHeight the minimum altitude on the ground, optional, default 0
  28097. * * maxHeight the maximum altitude on the ground, optional default 1
  28098. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28099. * * buffer the array holding the image color data
  28100. * * bufferWidth the width of image
  28101. * * bufferHeight the height of image
  28102. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28103. * @returns the VertexData of the Ground designed from a heightmap
  28104. */
  28105. static CreateGroundFromHeightMap(options: {
  28106. width: number;
  28107. height: number;
  28108. subdivisions: number;
  28109. minHeight: number;
  28110. maxHeight: number;
  28111. colorFilter: Color3;
  28112. buffer: Uint8Array;
  28113. bufferWidth: number;
  28114. bufferHeight: number;
  28115. alphaFilter: number;
  28116. }): VertexData;
  28117. /**
  28118. * Creates the VertexData for a Plane
  28119. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28120. * * size sets the width and height of the plane to the value of size, optional default 1
  28121. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28122. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28123. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28124. * * 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)
  28125. * * 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)
  28126. * @returns the VertexData of the box
  28127. */
  28128. static CreatePlane(options: {
  28129. size?: number;
  28130. width?: number;
  28131. height?: number;
  28132. sideOrientation?: number;
  28133. frontUVs?: Vector4;
  28134. backUVs?: Vector4;
  28135. }): VertexData;
  28136. /**
  28137. * Creates the VertexData of the Disc or regular Polygon
  28138. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28139. * * radius the radius of the disc, optional default 0.5
  28140. * * tessellation the number of polygon sides, optional, default 64
  28141. * * 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
  28142. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28143. * * 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)
  28144. * * 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)
  28145. * @returns the VertexData of the box
  28146. */
  28147. static CreateDisc(options: {
  28148. radius?: number;
  28149. tessellation?: number;
  28150. arc?: number;
  28151. sideOrientation?: number;
  28152. frontUVs?: Vector4;
  28153. backUVs?: Vector4;
  28154. }): VertexData;
  28155. /**
  28156. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28157. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28158. * @param polygon a mesh built from polygonTriangulation.build()
  28159. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28160. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28161. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28162. * @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)
  28163. * @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)
  28164. * @returns the VertexData of the Polygon
  28165. */
  28166. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28167. /**
  28168. * Creates the VertexData of the IcoSphere
  28169. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28170. * * radius the radius of the IcoSphere, optional default 1
  28171. * * radiusX allows stretching in the x direction, optional, default radius
  28172. * * radiusY allows stretching in the y direction, optional, default radius
  28173. * * radiusZ allows stretching in the z direction, optional, default radius
  28174. * * flat when true creates a flat shaded mesh, optional, default true
  28175. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28176. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28177. * * 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)
  28178. * * 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)
  28179. * @returns the VertexData of the IcoSphere
  28180. */
  28181. static CreateIcoSphere(options: {
  28182. radius?: number;
  28183. radiusX?: number;
  28184. radiusY?: number;
  28185. radiusZ?: number;
  28186. flat?: boolean;
  28187. subdivisions?: number;
  28188. sideOrientation?: number;
  28189. frontUVs?: Vector4;
  28190. backUVs?: Vector4;
  28191. }): VertexData;
  28192. /**
  28193. * Creates the VertexData for a Polyhedron
  28194. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28195. * * type provided types are:
  28196. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28197. * * 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)
  28198. * * size the size of the IcoSphere, optional default 1
  28199. * * sizeX allows stretching in the x direction, optional, default size
  28200. * * sizeY allows stretching in the y direction, optional, default size
  28201. * * sizeZ allows stretching in the z direction, optional, default size
  28202. * * 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
  28203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28204. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28205. * * flat when true creates a flat shaded mesh, optional, default true
  28206. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28207. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28208. * * 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)
  28209. * * 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)
  28210. * @returns the VertexData of the Polyhedron
  28211. */
  28212. static CreatePolyhedron(options: {
  28213. type?: number;
  28214. size?: number;
  28215. sizeX?: number;
  28216. sizeY?: number;
  28217. sizeZ?: number;
  28218. custom?: any;
  28219. faceUV?: Vector4[];
  28220. faceColors?: Color4[];
  28221. flat?: boolean;
  28222. sideOrientation?: number;
  28223. frontUVs?: Vector4;
  28224. backUVs?: Vector4;
  28225. }): VertexData;
  28226. /**
  28227. * Creates the VertexData for a TorusKnot
  28228. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28229. * * radius the radius of the torus knot, optional, default 2
  28230. * * tube the thickness of the tube, optional, default 0.5
  28231. * * radialSegments the number of sides on each tube segments, optional, default 32
  28232. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28233. * * p the number of windings around the z axis, optional, default 2
  28234. * * q the number of windings around the x axis, optional, default 3
  28235. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28236. * * 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)
  28237. * * 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)
  28238. * @returns the VertexData of the Torus Knot
  28239. */
  28240. static CreateTorusKnot(options: {
  28241. radius?: number;
  28242. tube?: number;
  28243. radialSegments?: number;
  28244. tubularSegments?: number;
  28245. p?: number;
  28246. q?: number;
  28247. sideOrientation?: number;
  28248. frontUVs?: Vector4;
  28249. backUVs?: Vector4;
  28250. }): VertexData;
  28251. /**
  28252. * Compute normals for given positions and indices
  28253. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28254. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28255. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28256. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28257. * * facetNormals : optional array of facet normals (vector3)
  28258. * * facetPositions : optional array of facet positions (vector3)
  28259. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28260. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28261. * * bInfo : optional bounding info, required for facetPartitioning computation
  28262. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28263. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28264. * * useRightHandedSystem: optional boolean to for right handed system computation
  28265. * * depthSort : optional boolean to enable the facet depth sort computation
  28266. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28267. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28268. */
  28269. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28270. facetNormals?: any;
  28271. facetPositions?: any;
  28272. facetPartitioning?: any;
  28273. ratio?: number;
  28274. bInfo?: any;
  28275. bbSize?: Vector3;
  28276. subDiv?: any;
  28277. useRightHandedSystem?: boolean;
  28278. depthSort?: boolean;
  28279. distanceTo?: Vector3;
  28280. depthSortedFacets?: any;
  28281. }): void;
  28282. private static _ComputeSides;
  28283. /**
  28284. * Applies VertexData created from the imported parameters to the geometry
  28285. * @param parsedVertexData the parsed data from an imported file
  28286. * @param geometry the geometry to apply the VertexData to
  28287. */
  28288. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28289. }
  28290. }
  28291. declare module BABYLON {
  28292. /**
  28293. * Class containing static functions to help procedurally build meshes
  28294. */
  28295. class MeshBuilder {
  28296. private static _UpdateSideOrientation;
  28297. /**
  28298. * Creates a box mesh
  28299. * * The parameter `size` sets the size (float) of each box side (default 1)
  28300. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28301. * * 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)
  28302. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28304. * * 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
  28305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28306. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28307. * @param name defines the name of the mesh
  28308. * @param options defines the options used to create the mesh
  28309. * @param scene defines the hosting scene
  28310. * @returns the box mesh
  28311. */
  28312. static CreateBox(name: string, options: {
  28313. size?: number;
  28314. width?: number;
  28315. height?: number;
  28316. depth?: number;
  28317. faceUV?: Vector4[];
  28318. faceColors?: Color4[];
  28319. sideOrientation?: number;
  28320. frontUVs?: Vector4;
  28321. backUVs?: Vector4;
  28322. updatable?: boolean;
  28323. }, scene?: Nullable<Scene>): Mesh;
  28324. /**
  28325. * Creates a sphere mesh
  28326. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28327. * * 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`)
  28328. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28329. * * 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
  28330. * * 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)
  28331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28332. * * 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
  28333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28334. * @param name defines the name of the mesh
  28335. * @param options defines the options used to create the mesh
  28336. * @param scene defines the hosting scene
  28337. * @returns the sphere mesh
  28338. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28339. */
  28340. static CreateSphere(name: string, options: {
  28341. segments?: number;
  28342. diameter?: number;
  28343. diameterX?: number;
  28344. diameterY?: number;
  28345. diameterZ?: number;
  28346. arc?: number;
  28347. slice?: number;
  28348. sideOrientation?: number;
  28349. frontUVs?: Vector4;
  28350. backUVs?: Vector4;
  28351. updatable?: boolean;
  28352. }, scene: any): Mesh;
  28353. /**
  28354. * Creates a plane polygonal mesh. By default, this is a disc
  28355. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28356. * * 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
  28357. * * 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
  28358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28359. * * 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
  28360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28361. * @param name defines the name of the mesh
  28362. * @param options defines the options used to create the mesh
  28363. * @param scene defines the hosting scene
  28364. * @returns the plane polygonal mesh
  28365. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28366. */
  28367. static CreateDisc(name: string, options: {
  28368. radius?: number;
  28369. tessellation?: number;
  28370. arc?: number;
  28371. updatable?: boolean;
  28372. sideOrientation?: number;
  28373. frontUVs?: Vector4;
  28374. backUVs?: Vector4;
  28375. }, scene?: Nullable<Scene>): Mesh;
  28376. /**
  28377. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28378. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28379. * * 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`)
  28380. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28381. * * 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
  28382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28383. * * 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
  28384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28385. * @param name defines the name of the mesh
  28386. * @param options defines the options used to create the mesh
  28387. * @param scene defines the hosting scene
  28388. * @returns the icosahedron mesh
  28389. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28390. */
  28391. static CreateIcoSphere(name: string, options: {
  28392. radius?: number;
  28393. radiusX?: number;
  28394. radiusY?: number;
  28395. radiusZ?: number;
  28396. flat?: boolean;
  28397. subdivisions?: number;
  28398. sideOrientation?: number;
  28399. frontUVs?: Vector4;
  28400. backUVs?: Vector4;
  28401. updatable?: boolean;
  28402. }, scene: Scene): Mesh;
  28403. /**
  28404. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28405. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28406. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28407. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28408. * * 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
  28409. * * 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
  28410. * * 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
  28411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28412. * * 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
  28413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28414. * * 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
  28415. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28416. * * 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
  28417. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28419. * @param name defines the name of the mesh
  28420. * @param options defines the options used to create the mesh
  28421. * @param scene defines the hosting scene
  28422. * @returns the ribbon mesh
  28423. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28425. */
  28426. static CreateRibbon(name: string, options: {
  28427. pathArray: Vector3[][];
  28428. closeArray?: boolean;
  28429. closePath?: boolean;
  28430. offset?: number;
  28431. updatable?: boolean;
  28432. sideOrientation?: number;
  28433. frontUVs?: Vector4;
  28434. backUVs?: Vector4;
  28435. instance?: Mesh;
  28436. invertUV?: boolean;
  28437. uvs?: Vector2[];
  28438. colors?: Color4[];
  28439. }, scene?: Nullable<Scene>): Mesh;
  28440. /**
  28441. * Creates a cylinder or a cone mesh
  28442. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28443. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28444. * * 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.
  28445. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28446. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28447. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28448. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28449. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28450. * * 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).
  28451. * * 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
  28452. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28453. * * 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
  28454. * * 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.
  28455. * * If `enclose` is false, a ring surface is one element.
  28456. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28457. * * 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
  28458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28459. * * 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
  28460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28461. * @param name defines the name of the mesh
  28462. * @param options defines the options used to create the mesh
  28463. * @param scene defines the hosting scene
  28464. * @returns the cylinder mesh
  28465. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28466. */
  28467. static CreateCylinder(name: string, options: {
  28468. height?: number;
  28469. diameterTop?: number;
  28470. diameterBottom?: number;
  28471. diameter?: number;
  28472. tessellation?: number;
  28473. subdivisions?: number;
  28474. arc?: number;
  28475. faceColors?: Color4[];
  28476. faceUV?: Vector4[];
  28477. updatable?: boolean;
  28478. hasRings?: boolean;
  28479. enclose?: boolean;
  28480. sideOrientation?: number;
  28481. frontUVs?: Vector4;
  28482. backUVs?: Vector4;
  28483. }, scene: any): Mesh;
  28484. /**
  28485. * Creates a torus mesh
  28486. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28487. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28488. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28490. * * 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
  28491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28492. * @param name defines the name of the mesh
  28493. * @param options defines the options used to create the mesh
  28494. * @param scene defines the hosting scene
  28495. * @returns the torus mesh
  28496. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28497. */
  28498. static CreateTorus(name: string, options: {
  28499. diameter?: number;
  28500. thickness?: number;
  28501. tessellation?: number;
  28502. updatable?: boolean;
  28503. sideOrientation?: number;
  28504. frontUVs?: Vector4;
  28505. backUVs?: Vector4;
  28506. }, scene: any): Mesh;
  28507. /**
  28508. * Creates a torus knot mesh
  28509. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28510. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28511. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28512. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28514. * * 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
  28515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28516. * @param name defines the name of the mesh
  28517. * @param options defines the options used to create the mesh
  28518. * @param scene defines the hosting scene
  28519. * @returns the torus knot mesh
  28520. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28521. */
  28522. static CreateTorusKnot(name: string, options: {
  28523. radius?: number;
  28524. tube?: number;
  28525. radialSegments?: number;
  28526. tubularSegments?: number;
  28527. p?: number;
  28528. q?: number;
  28529. updatable?: boolean;
  28530. sideOrientation?: number;
  28531. frontUVs?: Vector4;
  28532. backUVs?: Vector4;
  28533. }, scene: any): Mesh;
  28534. /**
  28535. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28536. * * 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
  28537. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28538. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28539. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28540. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28541. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28542. * * 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
  28543. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28546. * @param name defines the name of the new line system
  28547. * @param options defines the options used to create the line system
  28548. * @param scene defines the hosting scene
  28549. * @returns a new line system mesh
  28550. */
  28551. static CreateLineSystem(name: string, options: {
  28552. lines: Vector3[][];
  28553. updatable?: boolean;
  28554. instance?: Nullable<LinesMesh>;
  28555. colors?: Nullable<Color4[][]>;
  28556. useVertexAlpha?: boolean;
  28557. }, scene: Nullable<Scene>): LinesMesh;
  28558. /**
  28559. * Creates a line mesh
  28560. * 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
  28561. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28562. * * The parameter `points` is an array successive Vector3
  28563. * * 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
  28564. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28565. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28566. * * When updating an instance, remember that only point positions can change, not the number of points
  28567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28569. * @param name defines the name of the new line system
  28570. * @param options defines the options used to create the line system
  28571. * @param scene defines the hosting scene
  28572. * @returns a new line mesh
  28573. */
  28574. static CreateLines(name: string, options: {
  28575. points: Vector3[];
  28576. updatable?: boolean;
  28577. instance?: Nullable<LinesMesh>;
  28578. colors?: Color4[];
  28579. useVertexAlpha?: boolean;
  28580. }, scene?: Nullable<Scene>): LinesMesh;
  28581. /**
  28582. * Creates a dashed line mesh
  28583. * * 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
  28584. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28585. * * The parameter `points` is an array successive Vector3
  28586. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28587. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28588. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28589. * * 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
  28590. * * When updating an instance, remember that only point positions can change, not the number of points
  28591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28592. * @param name defines the name of the mesh
  28593. * @param options defines the options used to create the mesh
  28594. * @param scene defines the hosting scene
  28595. * @returns the dashed line mesh
  28596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28597. */
  28598. static CreateDashedLines(name: string, options: {
  28599. points: Vector3[];
  28600. dashSize?: number;
  28601. gapSize?: number;
  28602. dashNb?: number;
  28603. updatable?: boolean;
  28604. instance?: LinesMesh;
  28605. }, scene?: Nullable<Scene>): LinesMesh;
  28606. /**
  28607. * 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.
  28608. * * 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.
  28609. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28610. * * 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.
  28611. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28612. * * 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
  28613. * * 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
  28614. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28616. * * 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
  28617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28619. * @param name defines the name of the mesh
  28620. * @param options defines the options used to create the mesh
  28621. * @param scene defines the hosting scene
  28622. * @returns the extruded shape mesh
  28623. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28625. */
  28626. static ExtrudeShape(name: string, options: {
  28627. shape: Vector3[];
  28628. path: Vector3[];
  28629. scale?: number;
  28630. rotation?: number;
  28631. cap?: number;
  28632. updatable?: boolean;
  28633. sideOrientation?: number;
  28634. frontUVs?: Vector4;
  28635. backUVs?: Vector4;
  28636. instance?: Mesh;
  28637. invertUV?: boolean;
  28638. }, scene?: Nullable<Scene>): Mesh;
  28639. /**
  28640. * Creates an custom extruded shape mesh.
  28641. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28642. * * 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.
  28643. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28644. * * 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
  28645. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28646. * * 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
  28647. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28648. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28649. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28650. * * 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
  28651. * * 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
  28652. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28654. * * 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
  28655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28657. * @param name defines the name of the mesh
  28658. * @param options defines the options used to create the mesh
  28659. * @param scene defines the hosting scene
  28660. * @returns the custom extruded shape mesh
  28661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28662. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28664. */
  28665. static ExtrudeShapeCustom(name: string, options: {
  28666. shape: Vector3[];
  28667. path: Vector3[];
  28668. scaleFunction?: any;
  28669. rotationFunction?: any;
  28670. ribbonCloseArray?: boolean;
  28671. ribbonClosePath?: boolean;
  28672. cap?: number;
  28673. updatable?: boolean;
  28674. sideOrientation?: number;
  28675. frontUVs?: Vector4;
  28676. backUVs?: Vector4;
  28677. instance?: Mesh;
  28678. invertUV?: boolean;
  28679. }, scene: Scene): Mesh;
  28680. /**
  28681. * Creates lathe mesh.
  28682. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28683. * * 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
  28684. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28685. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28686. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28687. * * 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
  28688. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28689. * * 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
  28690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28691. * * 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
  28692. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28694. * @param name defines the name of the mesh
  28695. * @param options defines the options used to create the mesh
  28696. * @param scene defines the hosting scene
  28697. * @returns the lathe mesh
  28698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28699. */
  28700. static CreateLathe(name: string, options: {
  28701. shape: Vector3[];
  28702. radius?: number;
  28703. tessellation?: number;
  28704. clip?: number;
  28705. arc?: number;
  28706. closed?: boolean;
  28707. updatable?: boolean;
  28708. sideOrientation?: number;
  28709. frontUVs?: Vector4;
  28710. backUVs?: Vector4;
  28711. cap?: number;
  28712. invertUV?: boolean;
  28713. }, scene: Scene): Mesh;
  28714. /**
  28715. * Creates a plane mesh
  28716. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28717. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28718. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28720. * * 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
  28721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28722. * @param name defines the name of the mesh
  28723. * @param options defines the options used to create the mesh
  28724. * @param scene defines the hosting scene
  28725. * @returns the plane mesh
  28726. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28727. */
  28728. static CreatePlane(name: string, options: {
  28729. size?: number;
  28730. width?: number;
  28731. height?: number;
  28732. sideOrientation?: number;
  28733. frontUVs?: Vector4;
  28734. backUVs?: Vector4;
  28735. updatable?: boolean;
  28736. sourcePlane?: Plane;
  28737. }, scene: Scene): Mesh;
  28738. /**
  28739. * Creates a ground mesh
  28740. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28741. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28743. * @param name defines the name of the mesh
  28744. * @param options defines the options used to create the mesh
  28745. * @param scene defines the hosting scene
  28746. * @returns the ground mesh
  28747. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28748. */
  28749. static CreateGround(name: string, options: {
  28750. width?: number;
  28751. height?: number;
  28752. subdivisions?: number;
  28753. subdivisionsX?: number;
  28754. subdivisionsY?: number;
  28755. updatable?: boolean;
  28756. }, scene: any): Mesh;
  28757. /**
  28758. * Creates a tiled ground mesh
  28759. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28760. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28761. * * 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
  28762. * * 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
  28763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28764. * @param name defines the name of the mesh
  28765. * @param options defines the options used to create the mesh
  28766. * @param scene defines the hosting scene
  28767. * @returns the tiled ground mesh
  28768. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28769. */
  28770. static CreateTiledGround(name: string, options: {
  28771. xmin: number;
  28772. zmin: number;
  28773. xmax: number;
  28774. zmax: number;
  28775. subdivisions?: {
  28776. w: number;
  28777. h: number;
  28778. };
  28779. precision?: {
  28780. w: number;
  28781. h: number;
  28782. };
  28783. updatable?: boolean;
  28784. }, scene: Scene): Mesh;
  28785. /**
  28786. * Creates a ground mesh from a height map
  28787. * * The parameter `url` sets the URL of the height map image resource.
  28788. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28789. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28790. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28791. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28792. * * 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.
  28793. * * 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).
  28794. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28796. * @param name defines the name of the mesh
  28797. * @param url defines the url to the height map
  28798. * @param options defines the options used to create the mesh
  28799. * @param scene defines the hosting scene
  28800. * @returns the ground mesh
  28801. * @see https://doc.babylonjs.com/babylon101/height_map
  28802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28803. */
  28804. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28805. width?: number;
  28806. height?: number;
  28807. subdivisions?: number;
  28808. minHeight?: number;
  28809. maxHeight?: number;
  28810. colorFilter?: Color3;
  28811. alphaFilter?: number;
  28812. updatable?: boolean;
  28813. onReady?: (mesh: GroundMesh) => void;
  28814. }, scene: Scene): GroundMesh;
  28815. /**
  28816. * Creates a polygon mesh
  28817. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28818. * * 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
  28819. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28821. * * 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)
  28822. * * Remember you can only change the shape positions, not their number when updating a polygon
  28823. * @param name defines the name of the mesh
  28824. * @param options defines the options used to create the mesh
  28825. * @param scene defines the hosting scene
  28826. * @returns the polygon mesh
  28827. */
  28828. static CreatePolygon(name: string, options: {
  28829. shape: Vector3[];
  28830. holes?: Vector3[][];
  28831. depth?: number;
  28832. faceUV?: Vector4[];
  28833. faceColors?: Color4[];
  28834. updatable?: boolean;
  28835. sideOrientation?: number;
  28836. frontUVs?: Vector4;
  28837. backUVs?: Vector4;
  28838. }, scene: Scene): Mesh;
  28839. /**
  28840. * Creates an extruded polygon mesh, with depth in the Y direction.
  28841. * * 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)
  28842. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28843. * @param name defines the name of the mesh
  28844. * @param options defines the options used to create the mesh
  28845. * @param scene defines the hosting scene
  28846. * @returns the polygon mesh
  28847. */
  28848. static ExtrudePolygon(name: string, options: {
  28849. shape: Vector3[];
  28850. holes?: Vector3[][];
  28851. depth?: number;
  28852. faceUV?: Vector4[];
  28853. faceColors?: Color4[];
  28854. updatable?: boolean;
  28855. sideOrientation?: number;
  28856. frontUVs?: Vector4;
  28857. backUVs?: Vector4;
  28858. }, scene: Scene): Mesh;
  28859. /**
  28860. * Creates a tube mesh.
  28861. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28862. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28863. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28864. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28865. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28866. * * 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)
  28867. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28868. * * 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
  28869. * * 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
  28870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28871. * * 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
  28872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28874. * @param name defines the name of the mesh
  28875. * @param options defines the options used to create the mesh
  28876. * @param scene defines the hosting scene
  28877. * @returns the tube mesh
  28878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28879. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28880. */
  28881. static CreateTube(name: string, options: {
  28882. path: Vector3[];
  28883. radius?: number;
  28884. tessellation?: number;
  28885. radiusFunction?: {
  28886. (i: number, distance: number): number;
  28887. };
  28888. cap?: number;
  28889. arc?: number;
  28890. updatable?: boolean;
  28891. sideOrientation?: number;
  28892. frontUVs?: Vector4;
  28893. backUVs?: Vector4;
  28894. instance?: Mesh;
  28895. invertUV?: boolean;
  28896. }, scene: Scene): Mesh;
  28897. /**
  28898. * Creates a polyhedron mesh
  28899. * * 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
  28900. * * The parameter `size` (positive float, default 1) sets the polygon size
  28901. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28902. * * 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`
  28903. * * 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
  28904. * * 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)`)
  28905. * * 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
  28906. * * 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
  28907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28908. * * 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
  28909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28910. * @param name defines the name of the mesh
  28911. * @param options defines the options used to create the mesh
  28912. * @param scene defines the hosting scene
  28913. * @returns the polyhedron mesh
  28914. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28915. */
  28916. static CreatePolyhedron(name: string, options: {
  28917. type?: number;
  28918. size?: number;
  28919. sizeX?: number;
  28920. sizeY?: number;
  28921. sizeZ?: number;
  28922. custom?: any;
  28923. faceUV?: Vector4[];
  28924. faceColors?: Color4[];
  28925. flat?: boolean;
  28926. updatable?: boolean;
  28927. sideOrientation?: number;
  28928. frontUVs?: Vector4;
  28929. backUVs?: Vector4;
  28930. }, scene: Scene): Mesh;
  28931. /**
  28932. * Creates a decal mesh.
  28933. * 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
  28934. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28935. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28936. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28937. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28938. * @param name defines the name of the mesh
  28939. * @param sourceMesh defines the mesh where the decal must be applied
  28940. * @param options defines the options used to create the mesh
  28941. * @param scene defines the hosting scene
  28942. * @returns the decal mesh
  28943. * @see https://doc.babylonjs.com/how_to/decals
  28944. */
  28945. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28946. position?: Vector3;
  28947. normal?: Vector3;
  28948. size?: Vector3;
  28949. angle?: number;
  28950. }): Mesh;
  28951. private static _ExtrudeShapeGeneric;
  28952. }
  28953. }
  28954. declare module BABYLON {
  28955. /**
  28956. * Class used to represent a specific level of detail of a mesh
  28957. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28958. */
  28959. class MeshLODLevel {
  28960. /** Defines the distance where this level should star being displayed */
  28961. distance: number;
  28962. /** Defines the mesh to use to render this level */
  28963. mesh: Nullable<Mesh>;
  28964. /**
  28965. * Creates a new LOD level
  28966. * @param distance defines the distance where this level should star being displayed
  28967. * @param mesh defines the mesh to use to render this level
  28968. */
  28969. constructor(
  28970. /** Defines the distance where this level should star being displayed */
  28971. distance: number,
  28972. /** Defines the mesh to use to render this level */
  28973. mesh: Nullable<Mesh>);
  28974. }
  28975. }
  28976. declare module BABYLON {
  28977. /**
  28978. * A simplifier interface for future simplification implementations
  28979. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28980. */
  28981. interface ISimplifier {
  28982. /**
  28983. * Simplification of a given mesh according to the given settings.
  28984. * Since this requires computation, it is assumed that the function runs async.
  28985. * @param settings The settings of the simplification, including quality and distance
  28986. * @param successCallback A callback that will be called after the mesh was simplified.
  28987. * @param errorCallback in case of an error, this callback will be called. optional.
  28988. */
  28989. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28990. }
  28991. /**
  28992. * Expected simplification settings.
  28993. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28994. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28995. */
  28996. interface ISimplificationSettings {
  28997. /**
  28998. * Gets or sets the expected quality
  28999. */
  29000. quality: number;
  29001. /**
  29002. * Gets or sets the distance when this optimized version should be used
  29003. */
  29004. distance: number;
  29005. /**
  29006. * Gets an already optimized mesh
  29007. */
  29008. optimizeMesh?: boolean;
  29009. }
  29010. /**
  29011. * Class used to specify simplification options
  29012. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29013. */
  29014. class SimplificationSettings implements ISimplificationSettings {
  29015. /** expected quality */
  29016. quality: number;
  29017. /** distance when this optimized version should be used */
  29018. distance: number;
  29019. /** already optimized mesh */
  29020. optimizeMesh?: boolean | undefined;
  29021. /**
  29022. * Creates a SimplificationSettings
  29023. * @param quality expected quality
  29024. * @param distance distance when this optimized version should be used
  29025. * @param optimizeMesh already optimized mesh
  29026. */
  29027. constructor(
  29028. /** expected quality */
  29029. quality: number,
  29030. /** distance when this optimized version should be used */
  29031. distance: number,
  29032. /** already optimized mesh */
  29033. optimizeMesh?: boolean | undefined);
  29034. }
  29035. /**
  29036. * Interface used to define a simplification task
  29037. */
  29038. interface ISimplificationTask {
  29039. /**
  29040. * Array of settings
  29041. */
  29042. settings: Array<ISimplificationSettings>;
  29043. /**
  29044. * Simplification type
  29045. */
  29046. simplificationType: SimplificationType;
  29047. /**
  29048. * Mesh to simplify
  29049. */
  29050. mesh: Mesh;
  29051. /**
  29052. * Callback called on success
  29053. */
  29054. successCallback?: () => void;
  29055. /**
  29056. * Defines if parallel processing can be used
  29057. */
  29058. parallelProcessing: boolean;
  29059. }
  29060. /**
  29061. * Queue used to order the simplification tasks
  29062. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29063. */
  29064. class SimplificationQueue {
  29065. private _simplificationArray;
  29066. /**
  29067. * Gets a boolean indicating that the process is still running
  29068. */
  29069. running: boolean;
  29070. /**
  29071. * Creates a new queue
  29072. */
  29073. constructor();
  29074. /**
  29075. * Adds a new simplification task
  29076. * @param task defines a task to add
  29077. */
  29078. addTask(task: ISimplificationTask): void;
  29079. /**
  29080. * Execute next task
  29081. */
  29082. executeNext(): void;
  29083. /**
  29084. * Execute a simplification task
  29085. * @param task defines the task to run
  29086. */
  29087. runSimplification(task: ISimplificationTask): void;
  29088. private getSimplifier;
  29089. }
  29090. /**
  29091. * The implemented types of simplification
  29092. * At the moment only Quadratic Error Decimation is implemented
  29093. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29094. */
  29095. enum SimplificationType {
  29096. /** Quadratic error decimation */
  29097. QUADRATIC = 0
  29098. }
  29099. }
  29100. declare module BABYLON {
  29101. interface Scene {
  29102. /** @hidden (Backing field) */
  29103. _simplificationQueue: SimplificationQueue;
  29104. /**
  29105. * Gets or sets the simplification queue attached to the scene
  29106. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29107. */
  29108. simplificationQueue: SimplificationQueue;
  29109. }
  29110. interface Mesh {
  29111. /**
  29112. * Simplify the mesh according to the given array of settings.
  29113. * Function will return immediately and will simplify async
  29114. * @param settings a collection of simplification settings
  29115. * @param parallelProcessing should all levels calculate parallel or one after the other
  29116. * @param simplificationType the type of simplification to run
  29117. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29118. * @returns the current mesh
  29119. */
  29120. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29121. }
  29122. /**
  29123. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29124. * created in a scene
  29125. */
  29126. class SimplicationQueueSceneComponent implements ISceneComponent {
  29127. /**
  29128. * The component name helpfull to identify the component in the list of scene components.
  29129. */
  29130. readonly name: string;
  29131. /**
  29132. * The scene the component belongs to.
  29133. */
  29134. scene: Scene;
  29135. /**
  29136. * Creates a new instance of the component for the given scene
  29137. * @param scene Defines the scene to register the component in
  29138. */
  29139. constructor(scene: Scene);
  29140. /**
  29141. * Registers the component in a given scene
  29142. */
  29143. register(): void;
  29144. /**
  29145. * Rebuilds the elements related to this component in case of
  29146. * context lost for instance.
  29147. */
  29148. rebuild(): void;
  29149. /**
  29150. * Disposes the component and the associated ressources
  29151. */
  29152. dispose(): void;
  29153. private _beforeCameraUpdate;
  29154. }
  29155. }
  29156. declare module BABYLON {
  29157. /**
  29158. * Polygon
  29159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29160. */
  29161. class Polygon {
  29162. /**
  29163. * Creates a rectangle
  29164. * @param xmin bottom X coord
  29165. * @param ymin bottom Y coord
  29166. * @param xmax top X coord
  29167. * @param ymax top Y coord
  29168. * @returns points that make the resulting rectation
  29169. */
  29170. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29171. /**
  29172. * Creates a circle
  29173. * @param radius radius of circle
  29174. * @param cx scale in x
  29175. * @param cy scale in y
  29176. * @param numberOfSides number of sides that make up the circle
  29177. * @returns points that make the resulting circle
  29178. */
  29179. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29180. /**
  29181. * Creates a polygon from input string
  29182. * @param input Input polygon data
  29183. * @returns the parsed points
  29184. */
  29185. static Parse(input: string): Vector2[];
  29186. /**
  29187. * Starts building a polygon from x and y coordinates
  29188. * @param x x coordinate
  29189. * @param y y coordinate
  29190. * @returns the started path2
  29191. */
  29192. static StartingAt(x: number, y: number): Path2;
  29193. }
  29194. /**
  29195. * Builds a polygon
  29196. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29197. */
  29198. class PolygonMeshBuilder {
  29199. private _points;
  29200. private _outlinepoints;
  29201. private _holes;
  29202. private _name;
  29203. private _scene;
  29204. private _epoints;
  29205. private _eholes;
  29206. private _addToepoint;
  29207. /**
  29208. * Creates a PolygonMeshBuilder
  29209. * @param name name of the builder
  29210. * @param contours Path of the polygon
  29211. * @param scene scene to add to
  29212. */
  29213. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29214. /**
  29215. * Adds a whole within the polygon
  29216. * @param hole Array of points defining the hole
  29217. * @returns this
  29218. */
  29219. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29220. /**
  29221. * Creates the polygon
  29222. * @param updatable If the mesh should be updatable
  29223. * @param depth The depth of the mesh created
  29224. * @returns the created mesh
  29225. */
  29226. build(updatable?: boolean, depth?: number): Mesh;
  29227. /**
  29228. * Adds a side to the polygon
  29229. * @param positions points that make the polygon
  29230. * @param normals normals of the polygon
  29231. * @param uvs uvs of the polygon
  29232. * @param indices indices of the polygon
  29233. * @param bounds bounds of the polygon
  29234. * @param points points of the polygon
  29235. * @param depth depth of the polygon
  29236. * @param flip flip of the polygon
  29237. */
  29238. private addSide;
  29239. }
  29240. }
  29241. declare module BABYLON {
  29242. /**
  29243. * Base class for submeshes
  29244. */
  29245. class BaseSubMesh {
  29246. /** @hidden */
  29247. _materialDefines: Nullable<MaterialDefines>;
  29248. /** @hidden */
  29249. _materialEffect: Nullable<Effect>;
  29250. /**
  29251. * Gets associated effect
  29252. */
  29253. readonly effect: Nullable<Effect>;
  29254. /**
  29255. * Sets associated effect (effect used to render this submesh)
  29256. * @param effect defines the effect to associate with
  29257. * @param defines defines the set of defines used to compile this effect
  29258. */
  29259. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29260. }
  29261. /**
  29262. * Defines a subdivision inside a mesh
  29263. */
  29264. class SubMesh extends BaseSubMesh implements ICullable {
  29265. /** the material index to use */
  29266. materialIndex: number;
  29267. /** vertex index start */
  29268. verticesStart: number;
  29269. /** vertices count */
  29270. verticesCount: number;
  29271. /** index start */
  29272. indexStart: number;
  29273. /** indices count */
  29274. indexCount: number;
  29275. /** @hidden */
  29276. _linesIndexCount: number;
  29277. private _mesh;
  29278. private _renderingMesh;
  29279. private _boundingInfo;
  29280. private _linesIndexBuffer;
  29281. /** @hidden */
  29282. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29283. /** @hidden */
  29284. _trianglePlanes: Plane[];
  29285. /** @hidden */
  29286. _lastColliderTransformMatrix: Matrix;
  29287. /** @hidden */
  29288. _renderId: number;
  29289. /** @hidden */
  29290. _alphaIndex: number;
  29291. /** @hidden */
  29292. _distanceToCamera: number;
  29293. /** @hidden */
  29294. _id: number;
  29295. private _currentMaterial;
  29296. /**
  29297. * Add a new submesh to a mesh
  29298. * @param materialIndex defines the material index to use
  29299. * @param verticesStart defines vertex index start
  29300. * @param verticesCount defines vertices count
  29301. * @param indexStart defines index start
  29302. * @param indexCount defines indices count
  29303. * @param mesh defines the parent mesh
  29304. * @param renderingMesh defines an optional rendering mesh
  29305. * @param createBoundingBox defines if bounding box should be created for this submesh
  29306. * @returns the new submesh
  29307. */
  29308. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29309. /**
  29310. * Creates a new submesh
  29311. * @param materialIndex defines the material index to use
  29312. * @param verticesStart defines vertex index start
  29313. * @param verticesCount defines vertices count
  29314. * @param indexStart defines index start
  29315. * @param indexCount defines indices count
  29316. * @param mesh defines the parent mesh
  29317. * @param renderingMesh defines an optional rendering mesh
  29318. * @param createBoundingBox defines if bounding box should be created for this submesh
  29319. */
  29320. constructor(
  29321. /** the material index to use */
  29322. materialIndex: number,
  29323. /** vertex index start */
  29324. verticesStart: number,
  29325. /** vertices count */
  29326. verticesCount: number,
  29327. /** index start */
  29328. indexStart: number,
  29329. /** indices count */
  29330. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29331. /**
  29332. * Returns true if this submesh covers the entire parent mesh
  29333. * @ignorenaming
  29334. */
  29335. readonly IsGlobal: boolean;
  29336. /**
  29337. * Returns the submesh BoudingInfo object
  29338. * @returns current bounding info (or mesh's one if the submesh is global)
  29339. */
  29340. getBoundingInfo(): BoundingInfo;
  29341. /**
  29342. * Sets the submesh BoundingInfo
  29343. * @param boundingInfo defines the new bounding info to use
  29344. * @returns the SubMesh
  29345. */
  29346. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29347. /**
  29348. * Returns the mesh of the current submesh
  29349. * @return the parent mesh
  29350. */
  29351. getMesh(): AbstractMesh;
  29352. /**
  29353. * Returns the rendering mesh of the submesh
  29354. * @returns the rendering mesh (could be different from parent mesh)
  29355. */
  29356. getRenderingMesh(): Mesh;
  29357. /**
  29358. * Returns the submesh material
  29359. * @returns null or the current material
  29360. */
  29361. getMaterial(): Nullable<Material>;
  29362. /**
  29363. * Sets a new updated BoundingInfo object to the submesh
  29364. * @returns the SubMesh
  29365. */
  29366. refreshBoundingInfo(): SubMesh;
  29367. /** @hidden */
  29368. _checkCollision(collider: Collider): boolean;
  29369. /**
  29370. * Updates the submesh BoundingInfo
  29371. * @param world defines the world matrix to use to update the bounding info
  29372. * @returns the submesh
  29373. */
  29374. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29375. /**
  29376. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29377. * @param frustumPlanes defines the frustum planes
  29378. * @returns true if the submesh is intersecting with the frustum
  29379. */
  29380. isInFrustum(frustumPlanes: Plane[]): boolean;
  29381. /**
  29382. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29383. * @param frustumPlanes defines the frustum planes
  29384. * @returns true if the submesh is inside the frustum
  29385. */
  29386. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29387. /**
  29388. * Renders the submesh
  29389. * @param enableAlphaMode defines if alpha needs to be used
  29390. * @returns the submesh
  29391. */
  29392. render(enableAlphaMode: boolean): SubMesh;
  29393. /**
  29394. * @hidden
  29395. */
  29396. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29397. /**
  29398. * Checks if the submesh intersects with a ray
  29399. * @param ray defines the ray to test
  29400. * @returns true is the passed ray intersects the submesh bounding box
  29401. */
  29402. canIntersects(ray: Ray): boolean;
  29403. /**
  29404. * Intersects current submesh with a ray
  29405. * @param ray defines the ray to test
  29406. * @param positions defines mesh's positions array
  29407. * @param indices defines mesh's indices array
  29408. * @param fastCheck defines if only bounding info should be used
  29409. * @returns intersection info or null if no intersection
  29410. */
  29411. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29412. /** @hidden */
  29413. private _intersectLines;
  29414. /** @hidden */
  29415. private _intersectTriangles;
  29416. /** @hidden */
  29417. _rebuild(): void;
  29418. /**
  29419. * Creates a new submesh from the passed mesh
  29420. * @param newMesh defines the new hosting mesh
  29421. * @param newRenderingMesh defines an optional rendering mesh
  29422. * @returns the new submesh
  29423. */
  29424. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29425. /**
  29426. * Release associated resources
  29427. */
  29428. dispose(): void;
  29429. /**
  29430. * Creates a new submesh from indices data
  29431. * @param materialIndex the index of the main mesh material
  29432. * @param startIndex the index where to start the copy in the mesh indices array
  29433. * @param indexCount the number of indices to copy then from the startIndex
  29434. * @param mesh the main mesh to create the submesh from
  29435. * @param renderingMesh the optional rendering mesh
  29436. * @returns a new submesh
  29437. */
  29438. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29439. }
  29440. }
  29441. declare module BABYLON {
  29442. /**
  29443. * 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.
  29444. * @see https://doc.babylonjs.com/how_to/transformnode
  29445. */
  29446. class TransformNode extends Node {
  29447. /**
  29448. * Object will not rotate to face the camera
  29449. */
  29450. static BILLBOARDMODE_NONE: number;
  29451. /**
  29452. * Object will rotate to face the camera but only on the x axis
  29453. */
  29454. static BILLBOARDMODE_X: number;
  29455. /**
  29456. * Object will rotate to face the camera but only on the y axis
  29457. */
  29458. static BILLBOARDMODE_Y: number;
  29459. /**
  29460. * Object will rotate to face the camera but only on the z axis
  29461. */
  29462. static BILLBOARDMODE_Z: number;
  29463. /**
  29464. * Object will rotate to face the camera
  29465. */
  29466. static BILLBOARDMODE_ALL: number;
  29467. private _forward;
  29468. private _forwardInverted;
  29469. private _up;
  29470. private _right;
  29471. private _rightInverted;
  29472. private _position;
  29473. private _rotation;
  29474. private _rotationQuaternion;
  29475. protected _scaling: Vector3;
  29476. protected _isDirty: boolean;
  29477. private _transformToBoneReferal;
  29478. /**
  29479. * Set the billboard mode. Default is 0.
  29480. *
  29481. * | Value | Type | Description |
  29482. * | --- | --- | --- |
  29483. * | 0 | BILLBOARDMODE_NONE | |
  29484. * | 1 | BILLBOARDMODE_X | |
  29485. * | 2 | BILLBOARDMODE_Y | |
  29486. * | 4 | BILLBOARDMODE_Z | |
  29487. * | 7 | BILLBOARDMODE_ALL | |
  29488. *
  29489. */
  29490. billboardMode: number;
  29491. /**
  29492. * 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
  29493. */
  29494. scalingDeterminant: number;
  29495. /**
  29496. * Sets the distance of the object to max, often used by skybox
  29497. */
  29498. infiniteDistance: boolean;
  29499. /**
  29500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29501. * By default the system will update normals to compensate
  29502. */
  29503. ignoreNonUniformScaling: boolean;
  29504. /** @hidden */
  29505. _poseMatrix: Matrix;
  29506. /** @hidden */
  29507. _localMatrix: Matrix;
  29508. private _absolutePosition;
  29509. private _pivotMatrix;
  29510. private _pivotMatrixInverse;
  29511. protected _postMultiplyPivotMatrix: boolean;
  29512. protected _isWorldMatrixFrozen: boolean;
  29513. /** @hidden */
  29514. _indexInSceneTransformNodesArray: number;
  29515. /**
  29516. * An event triggered after the world matrix is updated
  29517. */
  29518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29520. /**
  29521. * Gets a string identifying the name of the class
  29522. * @returns "TransformNode" string
  29523. */
  29524. getClassName(): string;
  29525. /**
  29526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29527. */
  29528. position: Vector3;
  29529. /**
  29530. * 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)).
  29531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29532. */
  29533. rotation: Vector3;
  29534. /**
  29535. * 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)).
  29536. */
  29537. scaling: Vector3;
  29538. /**
  29539. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29541. */
  29542. rotationQuaternion: Nullable<Quaternion>;
  29543. /**
  29544. * The forward direction of that transform in world space.
  29545. */
  29546. readonly forward: Vector3;
  29547. /**
  29548. * The up direction of that transform in world space.
  29549. */
  29550. readonly up: Vector3;
  29551. /**
  29552. * The right direction of that transform in world space.
  29553. */
  29554. readonly right: Vector3;
  29555. /**
  29556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29557. * @param matrix the matrix to copy the pose from
  29558. * @returns this TransformNode.
  29559. */
  29560. updatePoseMatrix(matrix: Matrix): TransformNode;
  29561. /**
  29562. * Returns the mesh Pose matrix.
  29563. * @returns the pose matrix
  29564. */
  29565. getPoseMatrix(): Matrix;
  29566. /** @hidden */
  29567. _isSynchronized(): boolean;
  29568. /** @hidden */
  29569. _initCache(): void;
  29570. /**
  29571. * Flag the transform node as dirty (Forcing it to update everything)
  29572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29573. * @returns this transform node
  29574. */
  29575. markAsDirty(property: string): TransformNode;
  29576. /**
  29577. * Returns the current mesh absolute position.
  29578. * Returns a Vector3.
  29579. */
  29580. readonly absolutePosition: Vector3;
  29581. /**
  29582. * Sets a new matrix to apply before all other transformation
  29583. * @param matrix defines the transform matrix
  29584. * @returns the current TransformNode
  29585. */
  29586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29587. /**
  29588. * Sets a new pivot matrix to the current node
  29589. * @param matrix defines the new pivot matrix to use
  29590. * @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
  29591. * @returns the current TransformNode
  29592. */
  29593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29594. /**
  29595. * Returns the mesh pivot matrix.
  29596. * Default : Identity.
  29597. * @returns the matrix
  29598. */
  29599. getPivotMatrix(): Matrix;
  29600. /**
  29601. * Prevents the World matrix to be computed any longer.
  29602. * @returns the TransformNode.
  29603. */
  29604. freezeWorldMatrix(): TransformNode;
  29605. /**
  29606. * Allows back the World matrix computation.
  29607. * @returns the TransformNode.
  29608. */
  29609. unfreezeWorldMatrix(): this;
  29610. /**
  29611. * True if the World matrix has been frozen.
  29612. */
  29613. readonly isWorldMatrixFrozen: boolean;
  29614. /**
  29615. * Retuns the mesh absolute position in the World.
  29616. * @returns a Vector3.
  29617. */
  29618. getAbsolutePosition(): Vector3;
  29619. /**
  29620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29621. * @param absolutePosition the absolute position to set
  29622. * @returns the TransformNode.
  29623. */
  29624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29625. /**
  29626. * Sets the mesh position in its local space.
  29627. * @param vector3 the position to set in localspace
  29628. * @returns the TransformNode.
  29629. */
  29630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29631. /**
  29632. * Returns the mesh position in the local space from the current World matrix values.
  29633. * @returns a new Vector3.
  29634. */
  29635. getPositionExpressedInLocalSpace(): Vector3;
  29636. /**
  29637. * Translates the mesh along the passed Vector3 in its local space.
  29638. * @param vector3 the distance to translate in localspace
  29639. * @returns the TransformNode.
  29640. */
  29641. locallyTranslate(vector3: Vector3): TransformNode;
  29642. private static _lookAtVectorCache;
  29643. /**
  29644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29645. * @param targetPoint the position (must be in same space as current mesh) to look at
  29646. * @param yawCor optional yaw (y-axis) correction in radians
  29647. * @param pitchCor optional pitch (x-axis) correction in radians
  29648. * @param rollCor optional roll (z-axis) correction in radians
  29649. * @param space the choosen space of the target
  29650. * @returns the TransformNode.
  29651. */
  29652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29653. /**
  29654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29655. * This Vector3 is expressed in the World space.
  29656. * @param localAxis axis to rotate
  29657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29658. */
  29659. getDirection(localAxis: Vector3): Vector3;
  29660. /**
  29661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29662. * localAxis is expressed in the mesh local space.
  29663. * result is computed in the Wordl space from the mesh World matrix.
  29664. * @param localAxis axis to rotate
  29665. * @param result the resulting transformnode
  29666. * @returns this TransformNode.
  29667. */
  29668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29669. /**
  29670. * Sets this transform node rotation to the given local axis.
  29671. * @param localAxis the axis in local space
  29672. * @param yawCor optional yaw (y-axis) correction in radians
  29673. * @param pitchCor optional pitch (x-axis) correction in radians
  29674. * @param rollCor optional roll (z-axis) correction in radians
  29675. * @returns this TransformNode
  29676. */
  29677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29678. /**
  29679. * Sets a new pivot point to the current node
  29680. * @param point defines the new pivot point to use
  29681. * @param space defines if the point is in world or local space (local by default)
  29682. * @returns the current TransformNode
  29683. */
  29684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29685. /**
  29686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29687. * @returns the pivot point
  29688. */
  29689. getPivotPoint(): Vector3;
  29690. /**
  29691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29692. * @param result the vector3 to store the result
  29693. * @returns this TransformNode.
  29694. */
  29695. getPivotPointToRef(result: Vector3): TransformNode;
  29696. /**
  29697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29699. */
  29700. getAbsolutePivotPoint(): Vector3;
  29701. /**
  29702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29703. * @param result vector3 to store the result
  29704. * @returns this TransformNode.
  29705. */
  29706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29707. /**
  29708. * Defines the passed node as the parent of the current node.
  29709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29710. * @param node the node ot set as the parent
  29711. * @returns this TransformNode.
  29712. */
  29713. setParent(node: Nullable<Node>): TransformNode;
  29714. private _nonUniformScaling;
  29715. /**
  29716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29717. */
  29718. readonly nonUniformScaling: boolean;
  29719. /** @hidden */
  29720. _updateNonUniformScalingState(value: boolean): boolean;
  29721. /**
  29722. * Attach the current TransformNode to another TransformNode associated with a bone
  29723. * @param bone Bone affecting the TransformNode
  29724. * @param affectedTransformNode TransformNode associated with the bone
  29725. * @returns this object
  29726. */
  29727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29728. /**
  29729. * Detach the transform node if its associated with a bone
  29730. * @returns this object
  29731. */
  29732. detachFromBone(): TransformNode;
  29733. private static _rotationAxisCache;
  29734. /**
  29735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29736. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29738. * The passed axis is also normalized.
  29739. * @param axis the axis to rotate around
  29740. * @param amount the amount to rotate in radians
  29741. * @param space Space to rotate in (Default: local)
  29742. * @returns the TransformNode.
  29743. */
  29744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29745. /**
  29746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29748. * The passed axis is also normalized. .
  29749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29750. * @param point the point to rotate around
  29751. * @param axis the axis to rotate around
  29752. * @param amount the amount to rotate in radians
  29753. * @returns the TransformNode
  29754. */
  29755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29756. /**
  29757. * Translates the mesh along the axis vector for the passed distance in the given space.
  29758. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29759. * @param axis the axis to translate in
  29760. * @param distance the distance to translate
  29761. * @param space Space to rotate in (Default: local)
  29762. * @returns the TransformNode.
  29763. */
  29764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29765. /**
  29766. * Adds a rotation step to the mesh current rotation.
  29767. * x, y, z are Euler angles expressed in radians.
  29768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29769. * This means this rotation is made in the mesh local space only.
  29770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29772. * ```javascript
  29773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29774. * ```
  29775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29776. * 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.
  29777. * @param x Rotation to add
  29778. * @param y Rotation to add
  29779. * @param z Rotation to add
  29780. * @returns the TransformNode.
  29781. */
  29782. addRotation(x: number, y: number, z: number): TransformNode;
  29783. /**
  29784. * Computes the world matrix of the node
  29785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29786. * @returns the world matrix
  29787. */
  29788. computeWorldMatrix(force?: boolean): Matrix;
  29789. protected _afterComputeWorldMatrix(): void;
  29790. /**
  29791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29792. * @param func callback function to add
  29793. *
  29794. * @returns the TransformNode.
  29795. */
  29796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29797. /**
  29798. * Removes a registered callback function.
  29799. * @param func callback function to remove
  29800. * @returns the TransformNode.
  29801. */
  29802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29803. /**
  29804. * Gets the position of the current mesh in camera space
  29805. * @param camera defines the camera to use
  29806. * @returns a position
  29807. */
  29808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29809. /**
  29810. * Returns the distance from the mesh to the active camera
  29811. * @param camera defines the camera to use
  29812. * @returns the distance
  29813. */
  29814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29815. /**
  29816. * Clone the current transform node
  29817. * @param name Name of the new clone
  29818. * @param newParent New parent for the clone
  29819. * @param doNotCloneChildren Do not clone children hierarchy
  29820. * @returns the new transform node
  29821. */
  29822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29823. /**
  29824. * Serializes the objects information.
  29825. * @param currentSerializationObject defines the object to serialize in
  29826. * @returns the serialized object
  29827. */
  29828. serialize(currentSerializationObject?: any): any;
  29829. /**
  29830. * Returns a new TransformNode object parsed from the source provided.
  29831. * @param parsedTransformNode is the source.
  29832. * @param scene the scne the object belongs to
  29833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29834. * @returns a new TransformNode object parsed from the source provided.
  29835. */
  29836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29837. /**
  29838. * Releases resources associated with this transform node.
  29839. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29840. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29841. */
  29842. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29843. }
  29844. }
  29845. declare module BABYLON {
  29846. /**
  29847. * Specialized buffer used to store vertex data
  29848. */
  29849. class VertexBuffer {
  29850. /** @hidden */
  29851. _buffer: Buffer;
  29852. private _kind;
  29853. private _size;
  29854. private _ownsBuffer;
  29855. private _instanced;
  29856. private _instanceDivisor;
  29857. /**
  29858. * The byte type.
  29859. */
  29860. static readonly BYTE: number;
  29861. /**
  29862. * The unsigned byte type.
  29863. */
  29864. static readonly UNSIGNED_BYTE: number;
  29865. /**
  29866. * The short type.
  29867. */
  29868. static readonly SHORT: number;
  29869. /**
  29870. * The unsigned short type.
  29871. */
  29872. static readonly UNSIGNED_SHORT: number;
  29873. /**
  29874. * The integer type.
  29875. */
  29876. static readonly INT: number;
  29877. /**
  29878. * The unsigned integer type.
  29879. */
  29880. static readonly UNSIGNED_INT: number;
  29881. /**
  29882. * The float type.
  29883. */
  29884. static readonly FLOAT: number;
  29885. /**
  29886. * Gets or sets the instance divisor when in instanced mode
  29887. */
  29888. instanceDivisor: number;
  29889. /**
  29890. * Gets the byte stride.
  29891. */
  29892. readonly byteStride: number;
  29893. /**
  29894. * Gets the byte offset.
  29895. */
  29896. readonly byteOffset: number;
  29897. /**
  29898. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29899. */
  29900. readonly normalized: boolean;
  29901. /**
  29902. * Gets the data type of each component in the array.
  29903. */
  29904. readonly type: number;
  29905. /**
  29906. * Constructor
  29907. * @param engine the engine
  29908. * @param data the data to use for this vertex buffer
  29909. * @param kind the vertex buffer kind
  29910. * @param updatable whether the data is updatable
  29911. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29912. * @param stride the stride (optional)
  29913. * @param instanced whether the buffer is instanced (optional)
  29914. * @param offset the offset of the data (optional)
  29915. * @param size the number of components (optional)
  29916. * @param type the type of the component (optional)
  29917. * @param normalized whether the data contains normalized data (optional)
  29918. * @param useBytes set to true if stride and offset are in bytes (optional)
  29919. */
  29920. 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);
  29921. /** @hidden */
  29922. _rebuild(): void;
  29923. /**
  29924. * Returns the kind of the VertexBuffer (string)
  29925. * @returns a string
  29926. */
  29927. getKind(): string;
  29928. /**
  29929. * Gets a boolean indicating if the VertexBuffer is updatable?
  29930. * @returns true if the buffer is updatable
  29931. */
  29932. isUpdatable(): boolean;
  29933. /**
  29934. * Gets current buffer's data
  29935. * @returns a DataArray or null
  29936. */
  29937. getData(): Nullable<DataArray>;
  29938. /**
  29939. * Gets underlying native buffer
  29940. * @returns underlying native buffer
  29941. */
  29942. getBuffer(): Nullable<WebGLBuffer>;
  29943. /**
  29944. * Gets the stride in float32 units (i.e. byte stride / 4).
  29945. * May not be an integer if the byte stride is not divisible by 4.
  29946. * DEPRECATED. Use byteStride instead.
  29947. * @returns the stride in float32 units
  29948. */
  29949. getStrideSize(): number;
  29950. /**
  29951. * Returns the offset as a multiple of the type byte length.
  29952. * DEPRECATED. Use byteOffset instead.
  29953. * @returns the offset in bytes
  29954. */
  29955. getOffset(): number;
  29956. /**
  29957. * Returns the number of components per vertex attribute (integer)
  29958. * @returns the size in float
  29959. */
  29960. getSize(): number;
  29961. /**
  29962. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29963. * @returns true if this buffer is instanced
  29964. */
  29965. getIsInstanced(): boolean;
  29966. /**
  29967. * Returns the instancing divisor, zero for non-instanced (integer).
  29968. * @returns a number
  29969. */
  29970. getInstanceDivisor(): number;
  29971. /**
  29972. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29973. * @param data defines the data to store
  29974. */
  29975. create(data?: DataArray): void;
  29976. /**
  29977. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29978. * This function will create a new buffer if the current one is not updatable
  29979. * @param data defines the data to store
  29980. */
  29981. update(data: DataArray): void;
  29982. /**
  29983. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29984. * Returns the directly updated WebGLBuffer.
  29985. * @param data the new data
  29986. * @param offset the new offset
  29987. * @param useBytes set to true if the offset is in bytes
  29988. */
  29989. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29990. /**
  29991. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29992. */
  29993. dispose(): void;
  29994. /**
  29995. * Enumerates each value of this vertex buffer as numbers.
  29996. * @param count the number of values to enumerate
  29997. * @param callback the callback function called for each value
  29998. */
  29999. forEach(count: number, callback: (value: number, index: number) => void): void;
  30000. /**
  30001. * Positions
  30002. */
  30003. static readonly PositionKind: string;
  30004. /**
  30005. * Normals
  30006. */
  30007. static readonly NormalKind: string;
  30008. /**
  30009. * Tangents
  30010. */
  30011. static readonly TangentKind: string;
  30012. /**
  30013. * Texture coordinates
  30014. */
  30015. static readonly UVKind: string;
  30016. /**
  30017. * Texture coordinates 2
  30018. */
  30019. static readonly UV2Kind: string;
  30020. /**
  30021. * Texture coordinates 3
  30022. */
  30023. static readonly UV3Kind: string;
  30024. /**
  30025. * Texture coordinates 4
  30026. */
  30027. static readonly UV4Kind: string;
  30028. /**
  30029. * Texture coordinates 5
  30030. */
  30031. static readonly UV5Kind: string;
  30032. /**
  30033. * Texture coordinates 6
  30034. */
  30035. static readonly UV6Kind: string;
  30036. /**
  30037. * Colors
  30038. */
  30039. static readonly ColorKind: string;
  30040. /**
  30041. * Matrix indices (for bones)
  30042. */
  30043. static readonly MatricesIndicesKind: string;
  30044. /**
  30045. * Matrix weights (for bones)
  30046. */
  30047. static readonly MatricesWeightsKind: string;
  30048. /**
  30049. * Additional matrix indices (for bones)
  30050. */
  30051. static readonly MatricesIndicesExtraKind: string;
  30052. /**
  30053. * Additional matrix weights (for bones)
  30054. */
  30055. static readonly MatricesWeightsExtraKind: string;
  30056. /**
  30057. * Deduces the stride given a kind.
  30058. * @param kind The kind string to deduce
  30059. * @returns The deduced stride
  30060. */
  30061. static DeduceStride(kind: string): number;
  30062. /**
  30063. * Gets the byte length of the given type.
  30064. * @param type the type
  30065. * @returns the number of bytes
  30066. */
  30067. static GetTypeByteLength(type: number): number;
  30068. /**
  30069. * Enumerates each value of the given parameters as numbers.
  30070. * @param data the data to enumerate
  30071. * @param byteOffset the byte offset of the data
  30072. * @param byteStride the byte stride of the data
  30073. * @param componentCount the number of components per element
  30074. * @param componentType the type of the component
  30075. * @param count the total number of components
  30076. * @param normalized whether the data is normalized
  30077. * @param callback the callback function called for each value
  30078. */
  30079. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30080. private static _GetFloatValue;
  30081. }
  30082. }
  30083. declare module BABYLON {
  30084. /**
  30085. * Defines a target to use with MorphTargetManager
  30086. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30087. */
  30088. class MorphTarget implements IAnimatable {
  30089. /** defines the name of the target */
  30090. name: string;
  30091. /**
  30092. * Gets or sets the list of animations
  30093. */
  30094. animations: Animation[];
  30095. private _scene;
  30096. private _positions;
  30097. private _normals;
  30098. private _tangents;
  30099. private _influence;
  30100. /**
  30101. * Observable raised when the influence changes
  30102. */
  30103. onInfluenceChanged: Observable<boolean>;
  30104. /** @hidden */
  30105. _onDataLayoutChanged: Observable<void>;
  30106. /**
  30107. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30108. */
  30109. influence: number;
  30110. /**
  30111. * Gets or sets the id of the morph Target
  30112. */
  30113. id: string;
  30114. private _animationPropertiesOverride;
  30115. /**
  30116. * Gets or sets the animation properties override
  30117. */
  30118. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30119. /**
  30120. * Creates a new MorphTarget
  30121. * @param name defines the name of the target
  30122. * @param influence defines the influence to use
  30123. */
  30124. constructor(
  30125. /** defines the name of the target */
  30126. name: string, influence?: number, scene?: Nullable<Scene>);
  30127. /**
  30128. * Gets a boolean defining if the target contains position data
  30129. */
  30130. readonly hasPositions: boolean;
  30131. /**
  30132. * Gets a boolean defining if the target contains normal data
  30133. */
  30134. readonly hasNormals: boolean;
  30135. /**
  30136. * Gets a boolean defining if the target contains tangent data
  30137. */
  30138. readonly hasTangents: boolean;
  30139. /**
  30140. * Affects position data to this target
  30141. * @param data defines the position data to use
  30142. */
  30143. setPositions(data: Nullable<FloatArray>): void;
  30144. /**
  30145. * Gets the position data stored in this target
  30146. * @returns a FloatArray containing the position data (or null if not present)
  30147. */
  30148. getPositions(): Nullable<FloatArray>;
  30149. /**
  30150. * Affects normal data to this target
  30151. * @param data defines the normal data to use
  30152. */
  30153. setNormals(data: Nullable<FloatArray>): void;
  30154. /**
  30155. * Gets the normal data stored in this target
  30156. * @returns a FloatArray containing the normal data (or null if not present)
  30157. */
  30158. getNormals(): Nullable<FloatArray>;
  30159. /**
  30160. * Affects tangent data to this target
  30161. * @param data defines the tangent data to use
  30162. */
  30163. setTangents(data: Nullable<FloatArray>): void;
  30164. /**
  30165. * Gets the tangent data stored in this target
  30166. * @returns a FloatArray containing the tangent data (or null if not present)
  30167. */
  30168. getTangents(): Nullable<FloatArray>;
  30169. /**
  30170. * Serializes the current target into a Serialization object
  30171. * @returns the serialized object
  30172. */
  30173. serialize(): any;
  30174. /**
  30175. * Returns the string "MorphTarget"
  30176. * @returns "MorphTarget"
  30177. */
  30178. getClassName(): string;
  30179. /**
  30180. * Creates a new target from serialized data
  30181. * @param serializationObject defines the serialized data to use
  30182. * @returns a new MorphTarget
  30183. */
  30184. static Parse(serializationObject: any): MorphTarget;
  30185. /**
  30186. * Creates a MorphTarget from mesh data
  30187. * @param mesh defines the source mesh
  30188. * @param name defines the name to use for the new target
  30189. * @param influence defines the influence to attach to the target
  30190. * @returns a new MorphTarget
  30191. */
  30192. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30193. }
  30194. }
  30195. declare module BABYLON {
  30196. /**
  30197. * This class is used to deform meshes using morphing between different targets
  30198. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30199. */
  30200. class MorphTargetManager {
  30201. private _targets;
  30202. private _targetInfluenceChangedObservers;
  30203. private _targetDataLayoutChangedObservers;
  30204. private _activeTargets;
  30205. private _scene;
  30206. private _influences;
  30207. private _supportsNormals;
  30208. private _supportsTangents;
  30209. private _vertexCount;
  30210. private _uniqueId;
  30211. private _tempInfluences;
  30212. /**
  30213. * Creates a new MorphTargetManager
  30214. * @param scene defines the current scene
  30215. */
  30216. constructor(scene?: Nullable<Scene>);
  30217. /**
  30218. * Gets the unique ID of this manager
  30219. */
  30220. readonly uniqueId: number;
  30221. /**
  30222. * Gets the number of vertices handled by this manager
  30223. */
  30224. readonly vertexCount: number;
  30225. /**
  30226. * Gets a boolean indicating if this manager supports morphing of normals
  30227. */
  30228. readonly supportsNormals: boolean;
  30229. /**
  30230. * Gets a boolean indicating if this manager supports morphing of tangents
  30231. */
  30232. readonly supportsTangents: boolean;
  30233. /**
  30234. * Gets the number of targets stored in this manager
  30235. */
  30236. readonly numTargets: number;
  30237. /**
  30238. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30239. */
  30240. readonly numInfluencers: number;
  30241. /**
  30242. * Gets the list of influences (one per target)
  30243. */
  30244. readonly influences: Float32Array;
  30245. /**
  30246. * Gets the active target at specified index. An active target is a target with an influence > 0
  30247. * @param index defines the index to check
  30248. * @returns the requested target
  30249. */
  30250. getActiveTarget(index: number): MorphTarget;
  30251. /**
  30252. * Gets the target at specified index
  30253. * @param index defines the index to check
  30254. * @returns the requested target
  30255. */
  30256. getTarget(index: number): MorphTarget;
  30257. /**
  30258. * Add a new target to this manager
  30259. * @param target defines the target to add
  30260. */
  30261. addTarget(target: MorphTarget): void;
  30262. /**
  30263. * Removes a target from the manager
  30264. * @param target defines the target to remove
  30265. */
  30266. removeTarget(target: MorphTarget): void;
  30267. /**
  30268. * Serializes the current manager into a Serialization object
  30269. * @returns the serialized object
  30270. */
  30271. serialize(): any;
  30272. private _syncActiveTargets;
  30273. /**
  30274. * Syncrhonize the targets with all the meshes using this morph target manager
  30275. */
  30276. synchronize(): void;
  30277. /**
  30278. * Creates a new MorphTargetManager from serialized data
  30279. * @param serializationObject defines the serialized data
  30280. * @param scene defines the hosting scene
  30281. * @returns the new MorphTargetManager
  30282. */
  30283. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30284. }
  30285. }
  30286. declare module BABYLON {
  30287. /**
  30288. * Class used to enable access to IndexedDB
  30289. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30290. */
  30291. class Database implements IOfflineProvider {
  30292. private _callbackManifestChecked;
  30293. private _currentSceneUrl;
  30294. private _db;
  30295. private _enableSceneOffline;
  30296. private _enableTexturesOffline;
  30297. private _manifestVersionFound;
  30298. private _mustUpdateRessources;
  30299. private _hasReachedQuota;
  30300. private _isSupported;
  30301. private _idbFactory;
  30302. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30303. private static IsUASupportingBlobStorage;
  30304. /**
  30305. * Gets a boolean indicating if Database storate is enabled (off by default)
  30306. */
  30307. static IDBStorageEnabled: boolean;
  30308. /**
  30309. * Gets a boolean indicating if scene must be saved in the database
  30310. */
  30311. readonly enableSceneOffline: boolean;
  30312. /**
  30313. * Gets a boolean indicating if textures must be saved in the database
  30314. */
  30315. readonly enableTexturesOffline: boolean;
  30316. /**
  30317. * Creates a new Database
  30318. * @param urlToScene defines the url to load the scene
  30319. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30320. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30321. */
  30322. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30323. private static _ParseURL;
  30324. private static _ReturnFullUrlLocation;
  30325. private _checkManifestFile;
  30326. /**
  30327. * Open the database and make it available
  30328. * @param successCallback defines the callback to call on success
  30329. * @param errorCallback defines the callback to call on error
  30330. */
  30331. open(successCallback: () => void, errorCallback: () => void): void;
  30332. /**
  30333. * Loads an image from the database
  30334. * @param url defines the url to load from
  30335. * @param image defines the target DOM image
  30336. */
  30337. loadImage(url: string, image: HTMLImageElement): void;
  30338. private _loadImageFromDBAsync;
  30339. private _saveImageIntoDBAsync;
  30340. private _checkVersionFromDB;
  30341. private _loadVersionFromDBAsync;
  30342. private _saveVersionIntoDBAsync;
  30343. /**
  30344. * Loads a file from database
  30345. * @param url defines the URL to load from
  30346. * @param sceneLoaded defines a callback to call on success
  30347. * @param progressCallBack defines a callback to call when progress changed
  30348. * @param errorCallback defines a callback to call on error
  30349. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30350. */
  30351. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30352. private _loadFileAsync;
  30353. private _saveFileAsync;
  30354. }
  30355. }
  30356. declare module BABYLON {
  30357. /**
  30358. * Class used to enable access to offline support
  30359. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30360. */
  30361. interface IOfflineProvider {
  30362. /**
  30363. * Gets a boolean indicating if scene must be saved in the database
  30364. */
  30365. enableSceneOffline: boolean;
  30366. /**
  30367. * Gets a boolean indicating if textures must be saved in the database
  30368. */
  30369. enableTexturesOffline: boolean;
  30370. /**
  30371. * Open the offline support and make it available
  30372. * @param successCallback defines the callback to call on success
  30373. * @param errorCallback defines the callback to call on error
  30374. */
  30375. open(successCallback: () => void, errorCallback: () => void): void;
  30376. /**
  30377. * Loads an image from the offline support
  30378. * @param url defines the url to load from
  30379. * @param image defines the target DOM image
  30380. */
  30381. loadImage(url: string, image: HTMLImageElement): void;
  30382. /**
  30383. * Loads a file from offline support
  30384. * @param url defines the URL to load from
  30385. * @param sceneLoaded defines a callback to call on success
  30386. * @param progressCallBack defines a callback to call when progress changed
  30387. * @param errorCallback defines a callback to call on error
  30388. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30389. */
  30390. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30391. }
  30392. }
  30393. declare module BABYLON {
  30394. /**
  30395. * This represents the base class for particle system in Babylon.
  30396. * 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.
  30397. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30398. * @example https://doc.babylonjs.com/babylon101/particles
  30399. */
  30400. class BaseParticleSystem {
  30401. /**
  30402. * Source color is added to the destination color without alpha affecting the result
  30403. */
  30404. static BLENDMODE_ONEONE: number;
  30405. /**
  30406. * Blend current color and particle color using particle’s alpha
  30407. */
  30408. static BLENDMODE_STANDARD: number;
  30409. /**
  30410. * Add current color and particle color multiplied by particle’s alpha
  30411. */
  30412. static BLENDMODE_ADD: number;
  30413. /**
  30414. * Multiply current color with particle color
  30415. */
  30416. static BLENDMODE_MULTIPLY: number;
  30417. /**
  30418. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30419. */
  30420. static BLENDMODE_MULTIPLYADD: number;
  30421. /**
  30422. * List of animations used by the particle system.
  30423. */
  30424. animations: Animation[];
  30425. /**
  30426. * The id of the Particle system.
  30427. */
  30428. id: string;
  30429. /**
  30430. * The friendly name of the Particle system.
  30431. */
  30432. name: string;
  30433. /**
  30434. * The rendering group used by the Particle system to chose when to render.
  30435. */
  30436. renderingGroupId: number;
  30437. /**
  30438. * The emitter represents the Mesh or position we are attaching the particle system to.
  30439. */
  30440. emitter: Nullable<AbstractMesh | Vector3>;
  30441. /**
  30442. * The maximum number of particles to emit per frame
  30443. */
  30444. emitRate: number;
  30445. /**
  30446. * If you want to launch only a few particles at once, that can be done, as well.
  30447. */
  30448. manualEmitCount: number;
  30449. /**
  30450. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30451. */
  30452. updateSpeed: number;
  30453. /**
  30454. * The amount of time the particle system is running (depends of the overall update speed).
  30455. */
  30456. targetStopDuration: number;
  30457. /**
  30458. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30459. */
  30460. disposeOnStop: boolean;
  30461. /**
  30462. * Minimum power of emitting particles.
  30463. */
  30464. minEmitPower: number;
  30465. /**
  30466. * Maximum power of emitting particles.
  30467. */
  30468. maxEmitPower: number;
  30469. /**
  30470. * Minimum life time of emitting particles.
  30471. */
  30472. minLifeTime: number;
  30473. /**
  30474. * Maximum life time of emitting particles.
  30475. */
  30476. maxLifeTime: number;
  30477. /**
  30478. * Minimum Size of emitting particles.
  30479. */
  30480. minSize: number;
  30481. /**
  30482. * Maximum Size of emitting particles.
  30483. */
  30484. maxSize: number;
  30485. /**
  30486. * Minimum scale of emitting particles on X axis.
  30487. */
  30488. minScaleX: number;
  30489. /**
  30490. * Maximum scale of emitting particles on X axis.
  30491. */
  30492. maxScaleX: number;
  30493. /**
  30494. * Minimum scale of emitting particles on Y axis.
  30495. */
  30496. minScaleY: number;
  30497. /**
  30498. * Maximum scale of emitting particles on Y axis.
  30499. */
  30500. maxScaleY: number;
  30501. /**
  30502. * Gets or sets the minimal initial rotation in radians.
  30503. */
  30504. minInitialRotation: number;
  30505. /**
  30506. * Gets or sets the maximal initial rotation in radians.
  30507. */
  30508. maxInitialRotation: number;
  30509. /**
  30510. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30511. */
  30512. minAngularSpeed: number;
  30513. /**
  30514. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30515. */
  30516. maxAngularSpeed: number;
  30517. /**
  30518. * The texture used to render each particle. (this can be a spritesheet)
  30519. */
  30520. particleTexture: Nullable<Texture>;
  30521. /**
  30522. * The layer mask we are rendering the particles through.
  30523. */
  30524. layerMask: number;
  30525. /**
  30526. * This can help using your own shader to render the particle system.
  30527. * The according effect will be created
  30528. */
  30529. customShader: any;
  30530. /**
  30531. * By default particle system starts as soon as they are created. This prevents the
  30532. * automatic start to happen and let you decide when to start emitting particles.
  30533. */
  30534. preventAutoStart: boolean;
  30535. private _noiseTexture;
  30536. /**
  30537. * Gets or sets a texture used to add random noise to particle positions
  30538. */
  30539. noiseTexture: Nullable<ProceduralTexture>;
  30540. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30541. noiseStrength: Vector3;
  30542. /**
  30543. * Callback triggered when the particle animation is ending.
  30544. */
  30545. onAnimationEnd: Nullable<() => void>;
  30546. /**
  30547. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30548. */
  30549. blendMode: number;
  30550. /**
  30551. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30552. * to override the particles.
  30553. */
  30554. forceDepthWrite: boolean;
  30555. /** 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 */
  30556. preWarmCycles: number;
  30557. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30558. preWarmStepOffset: number;
  30559. /**
  30560. * 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)
  30561. */
  30562. spriteCellChangeSpeed: number;
  30563. /**
  30564. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30565. */
  30566. startSpriteCellID: number;
  30567. /**
  30568. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30569. */
  30570. endSpriteCellID: number;
  30571. /**
  30572. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30573. */
  30574. spriteCellWidth: number;
  30575. /**
  30576. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30577. */
  30578. spriteCellHeight: number;
  30579. /**
  30580. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30581. */
  30582. spriteRandomStartCell: boolean;
  30583. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30584. translationPivot: Vector2;
  30585. /** @hidden */
  30586. protected _isAnimationSheetEnabled: boolean;
  30587. /**
  30588. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30589. */
  30590. beginAnimationOnStart: boolean;
  30591. /**
  30592. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30593. */
  30594. beginAnimationFrom: number;
  30595. /**
  30596. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30597. */
  30598. beginAnimationTo: number;
  30599. /**
  30600. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30601. */
  30602. beginAnimationLoop: boolean;
  30603. /**
  30604. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30605. */
  30606. isAnimationSheetEnabled: boolean;
  30607. /**
  30608. * Get hosting scene
  30609. * @returns the scene
  30610. */
  30611. getScene(): Scene;
  30612. /**
  30613. * You can use gravity if you want to give an orientation to your particles.
  30614. */
  30615. gravity: Vector3;
  30616. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30617. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30618. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30619. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30620. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30621. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30622. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30623. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30624. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30625. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30626. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30627. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30628. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30629. /**
  30630. * Defines the delay in milliseconds before starting the system (0 by default)
  30631. */
  30632. startDelay: number;
  30633. /**
  30634. * Gets the current list of drag gradients.
  30635. * You must use addDragGradient and removeDragGradient to udpate this list
  30636. * @returns the list of drag gradients
  30637. */
  30638. getDragGradients(): Nullable<Array<FactorGradient>>;
  30639. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30640. limitVelocityDamping: number;
  30641. /**
  30642. * Gets the current list of limit velocity gradients.
  30643. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30644. * @returns the list of limit velocity gradients
  30645. */
  30646. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30647. /**
  30648. * Gets the current list of color gradients.
  30649. * You must use addColorGradient and removeColorGradient to udpate this list
  30650. * @returns the list of color gradients
  30651. */
  30652. getColorGradients(): Nullable<Array<ColorGradient>>;
  30653. /**
  30654. * Gets the current list of size gradients.
  30655. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30656. * @returns the list of size gradients
  30657. */
  30658. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30659. /**
  30660. * Gets the current list of color remap gradients.
  30661. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30662. * @returns the list of color remap gradients
  30663. */
  30664. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30665. /**
  30666. * Gets the current list of alpha remap gradients.
  30667. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30668. * @returns the list of alpha remap gradients
  30669. */
  30670. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30671. /**
  30672. * Gets the current list of life time gradients.
  30673. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30674. * @returns the list of life time gradients
  30675. */
  30676. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30677. /**
  30678. * Gets the current list of angular speed gradients.
  30679. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30680. * @returns the list of angular speed gradients
  30681. */
  30682. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30683. /**
  30684. * Gets the current list of velocity gradients.
  30685. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30686. * @returns the list of velocity gradients
  30687. */
  30688. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30689. /**
  30690. * Gets the current list of start size gradients.
  30691. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30692. * @returns the list of start size gradients
  30693. */
  30694. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30695. /**
  30696. * Gets the current list of emit rate gradients.
  30697. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30698. * @returns the list of emit rate gradients
  30699. */
  30700. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30701. /**
  30702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30703. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30704. */
  30705. direction1: Vector3;
  30706. /**
  30707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30708. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30709. */
  30710. direction2: Vector3;
  30711. /**
  30712. * 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.
  30713. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30714. */
  30715. minEmitBox: Vector3;
  30716. /**
  30717. * 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.
  30718. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30719. */
  30720. maxEmitBox: Vector3;
  30721. /**
  30722. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30723. */
  30724. color1: Color4;
  30725. /**
  30726. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30727. */
  30728. color2: Color4;
  30729. /**
  30730. * Color the particle will have at the end of its lifetime
  30731. */
  30732. colorDead: Color4;
  30733. /**
  30734. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30735. */
  30736. textureMask: Color4;
  30737. /**
  30738. * The particle emitter type defines the emitter used by the particle system.
  30739. * It can be for example box, sphere, or cone...
  30740. */
  30741. particleEmitterType: IParticleEmitterType;
  30742. /** @hidden */
  30743. _isSubEmitter: boolean;
  30744. /**
  30745. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30746. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30747. */
  30748. billboardMode: number;
  30749. protected _isBillboardBased: boolean;
  30750. /**
  30751. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30752. */
  30753. isBillboardBased: boolean;
  30754. /**
  30755. * The scene the particle system belongs to.
  30756. */
  30757. protected _scene: Scene;
  30758. /**
  30759. * Local cache of defines for image processing.
  30760. */
  30761. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30762. /**
  30763. * Default configuration related to image processing available in the standard Material.
  30764. */
  30765. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30766. /**
  30767. * Gets the image processing configuration used either in this material.
  30768. */
  30769. /**
  30770. * Sets the Default image processing configuration used either in the this material.
  30771. *
  30772. * If sets to null, the scene one is in use.
  30773. */
  30774. imageProcessingConfiguration: ImageProcessingConfiguration;
  30775. /**
  30776. * Attaches a new image processing configuration to the Standard Material.
  30777. * @param configuration
  30778. */
  30779. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30780. /** @hidden */
  30781. protected _reset(): void;
  30782. /** @hidden */
  30783. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30784. /**
  30785. * Instantiates a particle system.
  30786. * 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.
  30787. * @param name The name of the particle system
  30788. */
  30789. constructor(name: string);
  30790. /**
  30791. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30792. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30793. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30794. * @returns the emitter
  30795. */
  30796. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30797. /**
  30798. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30799. * @param radius The radius of the hemisphere to emit from
  30800. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30801. * @returns the emitter
  30802. */
  30803. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30804. /**
  30805. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30806. * @param radius The radius of the sphere to emit from
  30807. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30808. * @returns the emitter
  30809. */
  30810. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30811. /**
  30812. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30813. * @param radius The radius of the sphere to emit from
  30814. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30815. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30816. * @returns the emitter
  30817. */
  30818. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30819. /**
  30820. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30821. * @param radius The radius of the emission cylinder
  30822. * @param height The height of the emission cylinder
  30823. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30824. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30825. * @returns the emitter
  30826. */
  30827. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30828. /**
  30829. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30830. * @param radius The radius of the cylinder to emit from
  30831. * @param height The height of the emission cylinder
  30832. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30833. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30834. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30835. * @returns the emitter
  30836. */
  30837. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30838. /**
  30839. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30840. * @param radius The radius of the cone to emit from
  30841. * @param angle The base angle of the cone
  30842. * @returns the emitter
  30843. */
  30844. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30845. /**
  30846. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30847. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30848. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30849. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30850. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30851. * @returns the emitter
  30852. */
  30853. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30854. }
  30855. }
  30856. declare module BABYLON {
  30857. /**
  30858. * This represents a GPU particle system in Babylon
  30859. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30860. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30861. */
  30862. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30863. /**
  30864. * The layer mask we are rendering the particles through.
  30865. */
  30866. layerMask: number;
  30867. private _capacity;
  30868. private _activeCount;
  30869. private _currentActiveCount;
  30870. private _accumulatedCount;
  30871. private _renderEffect;
  30872. private _updateEffect;
  30873. private _buffer0;
  30874. private _buffer1;
  30875. private _spriteBuffer;
  30876. private _updateVAO;
  30877. private _renderVAO;
  30878. private _targetIndex;
  30879. private _sourceBuffer;
  30880. private _targetBuffer;
  30881. private _engine;
  30882. private _currentRenderId;
  30883. private _started;
  30884. private _stopped;
  30885. private _timeDelta;
  30886. private _randomTexture;
  30887. private _randomTexture2;
  30888. private _attributesStrideSize;
  30889. private _updateEffectOptions;
  30890. private _randomTextureSize;
  30891. private _actualFrame;
  30892. private readonly _rawTextureWidth;
  30893. /**
  30894. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30895. */
  30896. static readonly IsSupported: boolean;
  30897. /**
  30898. * An event triggered when the system is disposed.
  30899. */
  30900. onDisposeObservable: Observable<GPUParticleSystem>;
  30901. /**
  30902. * Gets the maximum number of particles active at the same time.
  30903. * @returns The max number of active particles.
  30904. */
  30905. getCapacity(): number;
  30906. /**
  30907. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30908. * to override the particles.
  30909. */
  30910. forceDepthWrite: boolean;
  30911. /**
  30912. * Gets or set the number of active particles
  30913. */
  30914. activeParticleCount: number;
  30915. private _preWarmDone;
  30916. /**
  30917. * Is this system ready to be used/rendered
  30918. * @return true if the system is ready
  30919. */
  30920. isReady(): boolean;
  30921. /**
  30922. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30923. * @returns True if it has been started, otherwise false.
  30924. */
  30925. isStarted(): boolean;
  30926. /**
  30927. * Starts the particle system and begins to emit
  30928. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30929. */
  30930. start(delay?: number): void;
  30931. /**
  30932. * Stops the particle system.
  30933. */
  30934. stop(): void;
  30935. /**
  30936. * Remove all active particles
  30937. */
  30938. reset(): void;
  30939. /**
  30940. * Returns the string "GPUParticleSystem"
  30941. * @returns a string containing the class name
  30942. */
  30943. getClassName(): string;
  30944. private _colorGradientsTexture;
  30945. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30946. /**
  30947. * Adds a new color gradient
  30948. * @param gradient defines the gradient to use (between 0 and 1)
  30949. * @param color1 defines the color to affect to the specified gradient
  30950. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30951. * @returns the current particle system
  30952. */
  30953. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30954. /**
  30955. * Remove a specific color gradient
  30956. * @param gradient defines the gradient to remove
  30957. * @returns the current particle system
  30958. */
  30959. removeColorGradient(gradient: number): GPUParticleSystem;
  30960. private _angularSpeedGradientsTexture;
  30961. private _sizeGradientsTexture;
  30962. private _velocityGradientsTexture;
  30963. private _limitVelocityGradientsTexture;
  30964. private _dragGradientsTexture;
  30965. private _addFactorGradient;
  30966. /**
  30967. * Adds a new size gradient
  30968. * @param gradient defines the gradient to use (between 0 and 1)
  30969. * @param factor defines the size factor to affect to the specified gradient
  30970. * @returns the current particle system
  30971. */
  30972. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30973. /**
  30974. * Remove a specific size gradient
  30975. * @param gradient defines the gradient to remove
  30976. * @returns the current particle system
  30977. */
  30978. removeSizeGradient(gradient: number): GPUParticleSystem;
  30979. /**
  30980. * Adds a new angular speed gradient
  30981. * @param gradient defines the gradient to use (between 0 and 1)
  30982. * @param factor defines the angular speed to affect to the specified gradient
  30983. * @returns the current particle system
  30984. */
  30985. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30986. /**
  30987. * Remove a specific angular speed gradient
  30988. * @param gradient defines the gradient to remove
  30989. * @returns the current particle system
  30990. */
  30991. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30992. /**
  30993. * Adds a new velocity gradient
  30994. * @param gradient defines the gradient to use (between 0 and 1)
  30995. * @param factor defines the velocity to affect to the specified gradient
  30996. * @returns the current particle system
  30997. */
  30998. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30999. /**
  31000. * Remove a specific velocity gradient
  31001. * @param gradient defines the gradient to remove
  31002. * @returns the current particle system
  31003. */
  31004. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31005. /**
  31006. * Adds a new limit velocity gradient
  31007. * @param gradient defines the gradient to use (between 0 and 1)
  31008. * @param factor defines the limit velocity value to affect to the specified gradient
  31009. * @returns the current particle system
  31010. */
  31011. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31012. /**
  31013. * Remove a specific limit velocity gradient
  31014. * @param gradient defines the gradient to remove
  31015. * @returns the current particle system
  31016. */
  31017. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31018. /**
  31019. * Adds a new drag gradient
  31020. * @param gradient defines the gradient to use (between 0 and 1)
  31021. * @param factor defines the drag value to affect to the specified gradient
  31022. * @returns the current particle system
  31023. */
  31024. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31025. /**
  31026. * Remove a specific drag gradient
  31027. * @param gradient defines the gradient to remove
  31028. * @returns the current particle system
  31029. */
  31030. removeDragGradient(gradient: number): GPUParticleSystem;
  31031. /**
  31032. * Not supported by GPUParticleSystem
  31033. * @param gradient defines the gradient to use (between 0 and 1)
  31034. * @param factor defines the emit rate value to affect to the specified gradient
  31035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31036. * @returns the current particle system
  31037. */
  31038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31039. /**
  31040. * Not supported by GPUParticleSystem
  31041. * @param gradient defines the gradient to remove
  31042. * @returns the current particle system
  31043. */
  31044. removeEmitRateGradient(gradient: number): IParticleSystem;
  31045. /**
  31046. * Not supported by GPUParticleSystem
  31047. * @param gradient defines the gradient to use (between 0 and 1)
  31048. * @param factor defines the start size value to affect to the specified gradient
  31049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31050. * @returns the current particle system
  31051. */
  31052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31053. /**
  31054. * Not supported by GPUParticleSystem
  31055. * @param gradient defines the gradient to remove
  31056. * @returns the current particle system
  31057. */
  31058. removeStartSizeGradient(gradient: number): IParticleSystem;
  31059. /**
  31060. * Not supported by GPUParticleSystem
  31061. * @param gradient defines the gradient to use (between 0 and 1)
  31062. * @param min defines the color remap minimal range
  31063. * @param max defines the color remap maximal range
  31064. * @returns the current particle system
  31065. */
  31066. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31067. /**
  31068. * Not supported by GPUParticleSystem
  31069. * @param gradient defines the gradient to remove
  31070. * @returns the current particle system
  31071. */
  31072. removeColorRemapGradient(gradient: number): IParticleSystem;
  31073. /**
  31074. * Not supported by GPUParticleSystem
  31075. * @param gradient defines the gradient to use (between 0 and 1)
  31076. * @param min defines the alpha remap minimal range
  31077. * @param max defines the alpha remap maximal range
  31078. * @returns the current particle system
  31079. */
  31080. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31081. /**
  31082. * Not supported by GPUParticleSystem
  31083. * @param gradient defines the gradient to remove
  31084. * @returns the current particle system
  31085. */
  31086. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31087. /**
  31088. * Not supported by GPUParticleSystem
  31089. * @param gradient defines the gradient to use (between 0 and 1)
  31090. * @param color defines the color to affect to the specified gradient
  31091. * @returns the current particle system
  31092. */
  31093. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31094. /**
  31095. * Not supported by GPUParticleSystem
  31096. * @param gradient defines the gradient to remove
  31097. * @returns the current particle system
  31098. */
  31099. removeRampGradient(gradient: number): IParticleSystem;
  31100. /**
  31101. * Not supported by GPUParticleSystem
  31102. * @returns the list of ramp gradients
  31103. */
  31104. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31105. /**
  31106. * Not supported by GPUParticleSystem
  31107. * Gets or sets a boolean indicating that ramp gradients must be used
  31108. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31109. */
  31110. useRampGradients: boolean;
  31111. /**
  31112. * Not supported by GPUParticleSystem
  31113. * @param gradient defines the gradient to use (between 0 and 1)
  31114. * @param factor defines the life time factor to affect to the specified gradient
  31115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31116. * @returns the current particle system
  31117. */
  31118. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31119. /**
  31120. * Not supported by GPUParticleSystem
  31121. * @param gradient defines the gradient to remove
  31122. * @returns the current particle system
  31123. */
  31124. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31125. /**
  31126. * Instantiates a GPU particle system.
  31127. * 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.
  31128. * @param name The name of the particle system
  31129. * @param options The options used to create the system
  31130. * @param scene The scene the particle system belongs to
  31131. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31132. */
  31133. constructor(name: string, options: Partial<{
  31134. capacity: number;
  31135. randomTextureSize: number;
  31136. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31137. protected _reset(): void;
  31138. private _createUpdateVAO;
  31139. private _createRenderVAO;
  31140. private _initialize;
  31141. /** @hidden */
  31142. _recreateUpdateEffect(): void;
  31143. /** @hidden */
  31144. _recreateRenderEffect(): void;
  31145. /**
  31146. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31147. * @param preWarm defines if we are in the pre-warmimg phase
  31148. */
  31149. animate(preWarm?: boolean): void;
  31150. private _createFactorGradientTexture;
  31151. private _createSizeGradientTexture;
  31152. private _createAngularSpeedGradientTexture;
  31153. private _createVelocityGradientTexture;
  31154. private _createLimitVelocityGradientTexture;
  31155. private _createDragGradientTexture;
  31156. private _createColorGradientTexture;
  31157. /**
  31158. * Renders the particle system in its current state
  31159. * @param preWarm defines if the system should only update the particles but not render them
  31160. * @returns the current number of particles
  31161. */
  31162. render(preWarm?: boolean): number;
  31163. /**
  31164. * Rebuilds the particle system
  31165. */
  31166. rebuild(): void;
  31167. private _releaseBuffers;
  31168. private _releaseVAOs;
  31169. /**
  31170. * Disposes the particle system and free the associated resources
  31171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31172. */
  31173. dispose(disposeTexture?: boolean): void;
  31174. /**
  31175. * Clones the particle system.
  31176. * @param name The name of the cloned object
  31177. * @param newEmitter The new emitter to use
  31178. * @returns the cloned particle system
  31179. */
  31180. clone(name: string, newEmitter: any): GPUParticleSystem;
  31181. /**
  31182. * Serializes the particle system to a JSON object.
  31183. * @returns the JSON object
  31184. */
  31185. serialize(): any;
  31186. /**
  31187. * Parses a JSON object to create a GPU particle system.
  31188. * @param parsedParticleSystem The JSON object to parse
  31189. * @param scene The scene to create the particle system in
  31190. * @param rootUrl The root url to use to load external dependencies like texture
  31191. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31192. * @returns the parsed GPU particle system
  31193. */
  31194. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31195. }
  31196. }
  31197. declare module BABYLON {
  31198. /**
  31199. * Interface representing a particle system in Babylon.js.
  31200. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31201. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31202. */
  31203. interface IParticleSystem {
  31204. /**
  31205. * List of animations used by the particle system.
  31206. */
  31207. animations: Animation[];
  31208. /**
  31209. * The id of the Particle system.
  31210. */
  31211. id: string;
  31212. /**
  31213. * The name of the Particle system.
  31214. */
  31215. name: string;
  31216. /**
  31217. * The emitter represents the Mesh or position we are attaching the particle system to.
  31218. */
  31219. emitter: Nullable<AbstractMesh | Vector3>;
  31220. /**
  31221. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31222. */
  31223. isBillboardBased: boolean;
  31224. /**
  31225. * The rendering group used by the Particle system to chose when to render.
  31226. */
  31227. renderingGroupId: number;
  31228. /**
  31229. * The layer mask we are rendering the particles through.
  31230. */
  31231. layerMask: number;
  31232. /**
  31233. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31234. */
  31235. updateSpeed: number;
  31236. /**
  31237. * The amount of time the particle system is running (depends of the overall update speed).
  31238. */
  31239. targetStopDuration: number;
  31240. /**
  31241. * The texture used to render each particle. (this can be a spritesheet)
  31242. */
  31243. particleTexture: Nullable<Texture>;
  31244. /**
  31245. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31246. */
  31247. blendMode: number;
  31248. /**
  31249. * Minimum life time of emitting particles.
  31250. */
  31251. minLifeTime: number;
  31252. /**
  31253. * Maximum life time of emitting particles.
  31254. */
  31255. maxLifeTime: number;
  31256. /**
  31257. * Minimum Size of emitting particles.
  31258. */
  31259. minSize: number;
  31260. /**
  31261. * Maximum Size of emitting particles.
  31262. */
  31263. maxSize: number;
  31264. /**
  31265. * Minimum scale of emitting particles on X axis.
  31266. */
  31267. minScaleX: number;
  31268. /**
  31269. * Maximum scale of emitting particles on X axis.
  31270. */
  31271. maxScaleX: number;
  31272. /**
  31273. * Minimum scale of emitting particles on Y axis.
  31274. */
  31275. minScaleY: number;
  31276. /**
  31277. * Maximum scale of emitting particles on Y axis.
  31278. */
  31279. maxScaleY: number;
  31280. /**
  31281. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31282. */
  31283. color1: Color4;
  31284. /**
  31285. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31286. */
  31287. color2: Color4;
  31288. /**
  31289. * Color the particle will have at the end of its lifetime.
  31290. */
  31291. colorDead: Color4;
  31292. /**
  31293. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31294. */
  31295. emitRate: number;
  31296. /**
  31297. * You can use gravity if you want to give an orientation to your particles.
  31298. */
  31299. gravity: Vector3;
  31300. /**
  31301. * Minimum power of emitting particles.
  31302. */
  31303. minEmitPower: number;
  31304. /**
  31305. * Maximum power of emitting particles.
  31306. */
  31307. maxEmitPower: number;
  31308. /**
  31309. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31310. */
  31311. minAngularSpeed: number;
  31312. /**
  31313. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31314. */
  31315. maxAngularSpeed: number;
  31316. /**
  31317. * Gets or sets the minimal initial rotation in radians.
  31318. */
  31319. minInitialRotation: number;
  31320. /**
  31321. * Gets or sets the maximal initial rotation in radians.
  31322. */
  31323. maxInitialRotation: number;
  31324. /**
  31325. * The particle emitter type defines the emitter used by the particle system.
  31326. * It can be for example box, sphere, or cone...
  31327. */
  31328. particleEmitterType: Nullable<IParticleEmitterType>;
  31329. /**
  31330. * Defines the delay in milliseconds before starting the system (0 by default)
  31331. */
  31332. startDelay: number;
  31333. /**
  31334. * 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
  31335. */
  31336. preWarmCycles: number;
  31337. /**
  31338. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31339. */
  31340. preWarmStepOffset: number;
  31341. /**
  31342. * 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)
  31343. */
  31344. spriteCellChangeSpeed: number;
  31345. /**
  31346. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31347. */
  31348. startSpriteCellID: number;
  31349. /**
  31350. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31351. */
  31352. endSpriteCellID: number;
  31353. /**
  31354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31355. */
  31356. spriteCellWidth: number;
  31357. /**
  31358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31359. */
  31360. spriteCellHeight: number;
  31361. /**
  31362. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31363. */
  31364. spriteRandomStartCell: boolean;
  31365. /**
  31366. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31367. */
  31368. isAnimationSheetEnabled: boolean;
  31369. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31370. translationPivot: Vector2;
  31371. /**
  31372. * Gets or sets a texture used to add random noise to particle positions
  31373. */
  31374. noiseTexture: Nullable<BaseTexture>;
  31375. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31376. noiseStrength: Vector3;
  31377. /**
  31378. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31379. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31380. */
  31381. billboardMode: number;
  31382. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31383. limitVelocityDamping: number;
  31384. /**
  31385. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31386. */
  31387. beginAnimationOnStart: boolean;
  31388. /**
  31389. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31390. */
  31391. beginAnimationFrom: number;
  31392. /**
  31393. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31394. */
  31395. beginAnimationTo: number;
  31396. /**
  31397. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31398. */
  31399. beginAnimationLoop: boolean;
  31400. /**
  31401. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31402. */
  31403. disposeOnStop: boolean;
  31404. /**
  31405. * Gets the maximum number of particles active at the same time.
  31406. * @returns The max number of active particles.
  31407. */
  31408. getCapacity(): number;
  31409. /**
  31410. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31411. * @returns True if it has been started, otherwise false.
  31412. */
  31413. isStarted(): boolean;
  31414. /**
  31415. * Animates the particle system for this frame.
  31416. */
  31417. animate(): void;
  31418. /**
  31419. * Renders the particle system in its current state.
  31420. * @returns the current number of particles
  31421. */
  31422. render(): number;
  31423. /**
  31424. * Dispose the particle system and frees its associated resources.
  31425. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31426. */
  31427. dispose(disposeTexture?: boolean): void;
  31428. /**
  31429. * Clones the particle system.
  31430. * @param name The name of the cloned object
  31431. * @param newEmitter The new emitter to use
  31432. * @returns the cloned particle system
  31433. */
  31434. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31435. /**
  31436. * Serializes the particle system to a JSON object.
  31437. * @returns the JSON object
  31438. */
  31439. serialize(): any;
  31440. /**
  31441. * Rebuild the particle system
  31442. */
  31443. rebuild(): void;
  31444. /**
  31445. * Starts the particle system and begins to emit
  31446. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31447. */
  31448. start(delay?: number): void;
  31449. /**
  31450. * Stops the particle system.
  31451. */
  31452. stop(): void;
  31453. /**
  31454. * Remove all active particles
  31455. */
  31456. reset(): void;
  31457. /**
  31458. * Is this system ready to be used/rendered
  31459. * @return true if the system is ready
  31460. */
  31461. isReady(): boolean;
  31462. /**
  31463. * Adds a new color gradient
  31464. * @param gradient defines the gradient to use (between 0 and 1)
  31465. * @param color1 defines the color to affect to the specified gradient
  31466. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31467. * @returns the current particle system
  31468. */
  31469. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31470. /**
  31471. * Remove a specific color gradient
  31472. * @param gradient defines the gradient to remove
  31473. * @returns the current particle system
  31474. */
  31475. removeColorGradient(gradient: number): IParticleSystem;
  31476. /**
  31477. * Adds a new size gradient
  31478. * @param gradient defines the gradient to use (between 0 and 1)
  31479. * @param factor defines the size factor to affect to the specified gradient
  31480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31481. * @returns the current particle system
  31482. */
  31483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31484. /**
  31485. * Remove a specific size gradient
  31486. * @param gradient defines the gradient to remove
  31487. * @returns the current particle system
  31488. */
  31489. removeSizeGradient(gradient: number): IParticleSystem;
  31490. /**
  31491. * Gets the current list of color gradients.
  31492. * You must use addColorGradient and removeColorGradient to udpate this list
  31493. * @returns the list of color gradients
  31494. */
  31495. getColorGradients(): Nullable<Array<ColorGradient>>;
  31496. /**
  31497. * Gets the current list of size gradients.
  31498. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31499. * @returns the list of size gradients
  31500. */
  31501. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31502. /**
  31503. * Gets the current list of angular speed gradients.
  31504. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31505. * @returns the list of angular speed gradients
  31506. */
  31507. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31508. /**
  31509. * Adds a new angular speed gradient
  31510. * @param gradient defines the gradient to use (between 0 and 1)
  31511. * @param factor defines the angular speed to affect to the specified gradient
  31512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31513. * @returns the current particle system
  31514. */
  31515. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31516. /**
  31517. * Remove a specific angular speed gradient
  31518. * @param gradient defines the gradient to remove
  31519. * @returns the current particle system
  31520. */
  31521. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31522. /**
  31523. * Gets the current list of velocity gradients.
  31524. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31525. * @returns the list of velocity gradients
  31526. */
  31527. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31528. /**
  31529. * Adds a new velocity gradient
  31530. * @param gradient defines the gradient to use (between 0 and 1)
  31531. * @param factor defines the velocity to affect to the specified gradient
  31532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31533. * @returns the current particle system
  31534. */
  31535. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31536. /**
  31537. * Remove a specific velocity gradient
  31538. * @param gradient defines the gradient to remove
  31539. * @returns the current particle system
  31540. */
  31541. removeVelocityGradient(gradient: number): IParticleSystem;
  31542. /**
  31543. * Gets the current list of limit velocity gradients.
  31544. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31545. * @returns the list of limit velocity gradients
  31546. */
  31547. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31548. /**
  31549. * Adds a new limit velocity gradient
  31550. * @param gradient defines the gradient to use (between 0 and 1)
  31551. * @param factor defines the limit velocity to affect to the specified gradient
  31552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31553. * @returns the current particle system
  31554. */
  31555. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31556. /**
  31557. * Remove a specific limit velocity gradient
  31558. * @param gradient defines the gradient to remove
  31559. * @returns the current particle system
  31560. */
  31561. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31562. /**
  31563. * Adds a new drag gradient
  31564. * @param gradient defines the gradient to use (between 0 and 1)
  31565. * @param factor defines the drag to affect to the specified gradient
  31566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31567. * @returns the current particle system
  31568. */
  31569. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31570. /**
  31571. * Remove a specific drag gradient
  31572. * @param gradient defines the gradient to remove
  31573. * @returns the current particle system
  31574. */
  31575. removeDragGradient(gradient: number): IParticleSystem;
  31576. /**
  31577. * Gets the current list of drag gradients.
  31578. * You must use addDragGradient and removeDragGradient to udpate this list
  31579. * @returns the list of drag gradients
  31580. */
  31581. getDragGradients(): Nullable<Array<FactorGradient>>;
  31582. /**
  31583. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31584. * @param gradient defines the gradient to use (between 0 and 1)
  31585. * @param factor defines the emit rate to affect to the specified gradient
  31586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31587. * @returns the current particle system
  31588. */
  31589. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31590. /**
  31591. * Remove a specific emit rate gradient
  31592. * @param gradient defines the gradient to remove
  31593. * @returns the current particle system
  31594. */
  31595. removeEmitRateGradient(gradient: number): IParticleSystem;
  31596. /**
  31597. * Gets the current list of emit rate gradients.
  31598. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31599. * @returns the list of emit rate gradients
  31600. */
  31601. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31602. /**
  31603. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31604. * @param gradient defines the gradient to use (between 0 and 1)
  31605. * @param factor defines the start size to affect to the specified gradient
  31606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31607. * @returns the current particle system
  31608. */
  31609. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31610. /**
  31611. * Remove a specific start size gradient
  31612. * @param gradient defines the gradient to remove
  31613. * @returns the current particle system
  31614. */
  31615. removeStartSizeGradient(gradient: number): IParticleSystem;
  31616. /**
  31617. * Gets the current list of start size gradients.
  31618. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31619. * @returns the list of start size gradients
  31620. */
  31621. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31622. /**
  31623. * Adds a new life time gradient
  31624. * @param gradient defines the gradient to use (between 0 and 1)
  31625. * @param factor defines the life time factor to affect to the specified gradient
  31626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31627. * @returns the current particle system
  31628. */
  31629. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31630. /**
  31631. * Remove a specific life time gradient
  31632. * @param gradient defines the gradient to remove
  31633. * @returns the current particle system
  31634. */
  31635. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31636. /**
  31637. * Gets the current list of life time gradients.
  31638. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31639. * @returns the list of life time gradients
  31640. */
  31641. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31642. /**
  31643. * Gets the current list of color gradients.
  31644. * You must use addColorGradient and removeColorGradient to udpate this list
  31645. * @returns the list of color gradients
  31646. */
  31647. getColorGradients(): Nullable<Array<ColorGradient>>;
  31648. /**
  31649. * Adds a new ramp gradient used to remap particle colors
  31650. * @param gradient defines the gradient to use (between 0 and 1)
  31651. * @param color defines the color to affect to the specified gradient
  31652. * @returns the current particle system
  31653. */
  31654. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31655. /**
  31656. * Gets the current list of ramp gradients.
  31657. * You must use addRampGradient and removeRampGradient to udpate this list
  31658. * @returns the list of ramp gradients
  31659. */
  31660. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31661. /** Gets or sets a boolean indicating that ramp gradients must be used
  31662. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31663. */
  31664. useRampGradients: boolean;
  31665. /**
  31666. * Adds a new color remap gradient
  31667. * @param gradient defines the gradient to use (between 0 and 1)
  31668. * @param min defines the color remap minimal range
  31669. * @param max defines the color remap maximal range
  31670. * @returns the current particle system
  31671. */
  31672. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31673. /**
  31674. * Gets the current list of color remap gradients.
  31675. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31676. * @returns the list of color remap gradients
  31677. */
  31678. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31679. /**
  31680. * Adds a new alpha remap gradient
  31681. * @param gradient defines the gradient to use (between 0 and 1)
  31682. * @param min defines the alpha remap minimal range
  31683. * @param max defines the alpha remap maximal range
  31684. * @returns the current particle system
  31685. */
  31686. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31687. /**
  31688. * Gets the current list of alpha remap gradients.
  31689. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31690. * @returns the list of alpha remap gradients
  31691. */
  31692. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31693. /**
  31694. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31697. * @returns the emitter
  31698. */
  31699. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31700. /**
  31701. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31702. * @param radius The radius of the hemisphere to emit from
  31703. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31704. * @returns the emitter
  31705. */
  31706. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31707. /**
  31708. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31709. * @param radius The radius of the sphere to emit from
  31710. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31711. * @returns the emitter
  31712. */
  31713. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31714. /**
  31715. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31716. * @param radius The radius of the sphere to emit from
  31717. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31718. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31719. * @returns the emitter
  31720. */
  31721. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31722. /**
  31723. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31724. * @param radius The radius of the emission cylinder
  31725. * @param height The height of the emission cylinder
  31726. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31727. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31728. * @returns the emitter
  31729. */
  31730. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31731. /**
  31732. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31733. * @param radius The radius of the cylinder to emit from
  31734. * @param height The height of the emission cylinder
  31735. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31736. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31737. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31738. * @returns the emitter
  31739. */
  31740. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31741. /**
  31742. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31743. * @param radius The radius of the cone to emit from
  31744. * @param angle The base angle of the cone
  31745. * @returns the emitter
  31746. */
  31747. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31748. /**
  31749. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31752. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31753. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31754. * @returns the emitter
  31755. */
  31756. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31757. /**
  31758. * Get hosting scene
  31759. * @returns the scene
  31760. */
  31761. getScene(): Scene;
  31762. }
  31763. }
  31764. declare module BABYLON {
  31765. /**
  31766. * A particle represents one of the element emitted by a particle system.
  31767. * This is mainly define by its coordinates, direction, velocity and age.
  31768. */
  31769. class Particle {
  31770. /**
  31771. * The particle system the particle belongs to.
  31772. */
  31773. particleSystem: ParticleSystem;
  31774. private static _Count;
  31775. /**
  31776. * Unique ID of the particle
  31777. */
  31778. id: number;
  31779. /**
  31780. * The world position of the particle in the scene.
  31781. */
  31782. position: Vector3;
  31783. /**
  31784. * The world direction of the particle in the scene.
  31785. */
  31786. direction: Vector3;
  31787. /**
  31788. * The color of the particle.
  31789. */
  31790. color: Color4;
  31791. /**
  31792. * The color change of the particle per step.
  31793. */
  31794. colorStep: Color4;
  31795. /**
  31796. * Defines how long will the life of the particle be.
  31797. */
  31798. lifeTime: number;
  31799. /**
  31800. * The current age of the particle.
  31801. */
  31802. age: number;
  31803. /**
  31804. * The current size of the particle.
  31805. */
  31806. size: number;
  31807. /**
  31808. * The current scale of the particle.
  31809. */
  31810. scale: Vector2;
  31811. /**
  31812. * The current angle of the particle.
  31813. */
  31814. angle: number;
  31815. /**
  31816. * Defines how fast is the angle changing.
  31817. */
  31818. angularSpeed: number;
  31819. /**
  31820. * Defines the cell index used by the particle to be rendered from a sprite.
  31821. */
  31822. cellIndex: number;
  31823. /**
  31824. * The information required to support color remapping
  31825. */
  31826. remapData: Vector4;
  31827. /** @hidden */
  31828. _randomCellOffset?: number;
  31829. /** @hidden */
  31830. _initialDirection: Nullable<Vector3>;
  31831. /** @hidden */
  31832. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31833. /** @hidden */
  31834. _initialStartSpriteCellID: number;
  31835. /** @hidden */
  31836. _initialEndSpriteCellID: number;
  31837. /** @hidden */
  31838. _currentColorGradient: Nullable<ColorGradient>;
  31839. /** @hidden */
  31840. _currentColor1: Color4;
  31841. /** @hidden */
  31842. _currentColor2: Color4;
  31843. /** @hidden */
  31844. _currentSizeGradient: Nullable<FactorGradient>;
  31845. /** @hidden */
  31846. _currentSize1: number;
  31847. /** @hidden */
  31848. _currentSize2: number;
  31849. /** @hidden */
  31850. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31851. /** @hidden */
  31852. _currentAngularSpeed1: number;
  31853. /** @hidden */
  31854. _currentAngularSpeed2: number;
  31855. /** @hidden */
  31856. _currentVelocityGradient: Nullable<FactorGradient>;
  31857. /** @hidden */
  31858. _currentVelocity1: number;
  31859. /** @hidden */
  31860. _currentVelocity2: number;
  31861. /** @hidden */
  31862. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31863. /** @hidden */
  31864. _currentLimitVelocity1: number;
  31865. /** @hidden */
  31866. _currentLimitVelocity2: number;
  31867. /** @hidden */
  31868. _currentDragGradient: Nullable<FactorGradient>;
  31869. /** @hidden */
  31870. _currentDrag1: number;
  31871. /** @hidden */
  31872. _currentDrag2: number;
  31873. /** @hidden */
  31874. _randomNoiseCoordinates1: Vector3;
  31875. /** @hidden */
  31876. _randomNoiseCoordinates2: Vector3;
  31877. /**
  31878. * Creates a new instance Particle
  31879. * @param particleSystem the particle system the particle belongs to
  31880. */
  31881. constructor(
  31882. /**
  31883. * The particle system the particle belongs to.
  31884. */
  31885. particleSystem: ParticleSystem);
  31886. private updateCellInfoFromSystem;
  31887. /**
  31888. * Defines how the sprite cell index is updated for the particle
  31889. */
  31890. updateCellIndex(): void;
  31891. /** @hidden */
  31892. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31893. /** @hidden */
  31894. _inheritParticleInfoToSubEmitters(): void;
  31895. /** @hidden */
  31896. _reset(): void;
  31897. /**
  31898. * Copy the properties of particle to another one.
  31899. * @param other the particle to copy the information to.
  31900. */
  31901. copyTo(other: Particle): void;
  31902. }
  31903. }
  31904. declare module BABYLON {
  31905. /**
  31906. * This class is made for on one-liner static method to help creating particle system set.
  31907. */
  31908. class ParticleHelper {
  31909. /**
  31910. * Gets or sets base Assets URL
  31911. */
  31912. static BaseAssetsUrl: string;
  31913. /**
  31914. * Create a default particle system that you can tweak
  31915. * @param emitter defines the emitter to use
  31916. * @param capacity defines the system capacity (default is 500 particles)
  31917. * @param scene defines the hosting scene
  31918. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31919. * @returns the new Particle system
  31920. */
  31921. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31922. /**
  31923. * This is the main static method (one-liner) of this helper to create different particle systems
  31924. * @param type This string represents the type to the particle system to create
  31925. * @param scene The scene where the particle system should live
  31926. * @param gpu If the system will use gpu
  31927. * @returns the ParticleSystemSet created
  31928. */
  31929. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31930. /**
  31931. * Static function used to export a particle system to a ParticleSystemSet variable.
  31932. * Please note that the emitter shape is not exported
  31933. * @param systems defines the particle systems to export
  31934. * @returns the created particle system set
  31935. */
  31936. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31937. }
  31938. }
  31939. declare module BABYLON {
  31940. /**
  31941. * This represents a particle system in Babylon.
  31942. * 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.
  31943. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31944. * @example https://doc.babylonjs.com/babylon101/particles
  31945. */
  31946. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31947. /**
  31948. * Billboard mode will only apply to Y axis
  31949. */
  31950. static readonly BILLBOARDMODE_Y: number;
  31951. /**
  31952. * Billboard mode will apply to all axes
  31953. */
  31954. static readonly BILLBOARDMODE_ALL: number;
  31955. /**
  31956. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31957. */
  31958. static readonly BILLBOARDMODE_STRETCHED: number;
  31959. /**
  31960. * This function can be defined to provide custom update for active particles.
  31961. * This function will be called instead of regular update (age, position, color, etc.).
  31962. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31963. */
  31964. updateFunction: (particles: Particle[]) => void;
  31965. private _emitterWorldMatrix;
  31966. /**
  31967. * This function can be defined to specify initial direction for every new particle.
  31968. * It by default use the emitterType defined function
  31969. */
  31970. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31971. /**
  31972. * This function can be defined to specify initial position for every new particle.
  31973. * It by default use the emitterType defined function
  31974. */
  31975. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31976. /**
  31977. * @hidden
  31978. */
  31979. _inheritedVelocityOffset: Vector3;
  31980. /**
  31981. * An event triggered when the system is disposed
  31982. */
  31983. onDisposeObservable: Observable<ParticleSystem>;
  31984. private _onDisposeObserver;
  31985. /**
  31986. * Sets a callback that will be triggered when the system is disposed
  31987. */
  31988. onDispose: () => void;
  31989. private _particles;
  31990. private _epsilon;
  31991. private _capacity;
  31992. private _stockParticles;
  31993. private _newPartsExcess;
  31994. private _vertexData;
  31995. private _vertexBuffer;
  31996. private _vertexBuffers;
  31997. private _spriteBuffer;
  31998. private _indexBuffer;
  31999. private _effect;
  32000. private _customEffect;
  32001. private _cachedDefines;
  32002. private _scaledColorStep;
  32003. private _colorDiff;
  32004. private _scaledDirection;
  32005. private _scaledGravity;
  32006. private _currentRenderId;
  32007. private _alive;
  32008. private _useInstancing;
  32009. private _started;
  32010. private _stopped;
  32011. private _actualFrame;
  32012. private _scaledUpdateSpeed;
  32013. private _vertexBufferSize;
  32014. /** @hidden */
  32015. _currentEmitRateGradient: Nullable<FactorGradient>;
  32016. /** @hidden */
  32017. _currentEmitRate1: number;
  32018. /** @hidden */
  32019. _currentEmitRate2: number;
  32020. /** @hidden */
  32021. _currentStartSizeGradient: Nullable<FactorGradient>;
  32022. /** @hidden */
  32023. _currentStartSize1: number;
  32024. /** @hidden */
  32025. _currentStartSize2: number;
  32026. private readonly _rawTextureWidth;
  32027. private _rampGradientsTexture;
  32028. private _useRampGradients;
  32029. /** Gets or sets a boolean indicating that ramp gradients must be used
  32030. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32031. */
  32032. useRampGradients: boolean;
  32033. /**
  32034. * 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.
  32035. * 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: [])
  32036. */
  32037. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32038. private _subEmitters;
  32039. /**
  32040. * @hidden
  32041. * If the particle systems emitter should be disposed when the particle system is disposed
  32042. */
  32043. _disposeEmitterOnDispose: boolean;
  32044. /**
  32045. * The current active Sub-systems, this property is used by the root particle system only.
  32046. */
  32047. activeSubSystems: Array<ParticleSystem>;
  32048. private _rootParticleSystem;
  32049. /**
  32050. * Gets the current list of active particles
  32051. */
  32052. readonly particles: Particle[];
  32053. /**
  32054. * Returns the string "ParticleSystem"
  32055. * @returns a string containing the class name
  32056. */
  32057. getClassName(): string;
  32058. /**
  32059. * Instantiates a particle system.
  32060. * 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.
  32061. * @param name The name of the particle system
  32062. * @param capacity The max number of particles alive at the same time
  32063. * @param scene The scene the particle system belongs to
  32064. * @param customEffect a custom effect used to change the way particles are rendered by default
  32065. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32066. * @param epsilon Offset used to render the particles
  32067. */
  32068. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32069. private _addFactorGradient;
  32070. private _removeFactorGradient;
  32071. /**
  32072. * Adds a new life time gradient
  32073. * @param gradient defines the gradient to use (between 0 and 1)
  32074. * @param factor defines the life time factor to affect to the specified gradient
  32075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32076. * @returns the current particle system
  32077. */
  32078. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32079. /**
  32080. * Remove a specific life time gradient
  32081. * @param gradient defines the gradient to remove
  32082. * @returns the current particle system
  32083. */
  32084. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32085. /**
  32086. * Adds a new size gradient
  32087. * @param gradient defines the gradient to use (between 0 and 1)
  32088. * @param factor defines the size factor to affect to the specified gradient
  32089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32090. * @returns the current particle system
  32091. */
  32092. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32093. /**
  32094. * Remove a specific size gradient
  32095. * @param gradient defines the gradient to remove
  32096. * @returns the current particle system
  32097. */
  32098. removeSizeGradient(gradient: number): IParticleSystem;
  32099. /**
  32100. * Adds a new color remap gradient
  32101. * @param gradient defines the gradient to use (between 0 and 1)
  32102. * @param min defines the color remap minimal range
  32103. * @param max defines the color remap maximal range
  32104. * @returns the current particle system
  32105. */
  32106. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32107. /**
  32108. * Remove a specific color remap gradient
  32109. * @param gradient defines the gradient to remove
  32110. * @returns the current particle system
  32111. */
  32112. removeColorRemapGradient(gradient: number): IParticleSystem;
  32113. /**
  32114. * Adds a new alpha remap gradient
  32115. * @param gradient defines the gradient to use (between 0 and 1)
  32116. * @param min defines the alpha remap minimal range
  32117. * @param max defines the alpha remap maximal range
  32118. * @returns the current particle system
  32119. */
  32120. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32121. /**
  32122. * Remove a specific alpha remap gradient
  32123. * @param gradient defines the gradient to remove
  32124. * @returns the current particle system
  32125. */
  32126. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32127. /**
  32128. * Adds a new angular speed gradient
  32129. * @param gradient defines the gradient to use (between 0 and 1)
  32130. * @param factor defines the angular speed to affect to the specified gradient
  32131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32132. * @returns the current particle system
  32133. */
  32134. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32135. /**
  32136. * Remove a specific angular speed gradient
  32137. * @param gradient defines the gradient to remove
  32138. * @returns the current particle system
  32139. */
  32140. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32141. /**
  32142. * Adds a new velocity gradient
  32143. * @param gradient defines the gradient to use (between 0 and 1)
  32144. * @param factor defines the velocity to affect to the specified gradient
  32145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32146. * @returns the current particle system
  32147. */
  32148. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32149. /**
  32150. * Remove a specific velocity gradient
  32151. * @param gradient defines the gradient to remove
  32152. * @returns the current particle system
  32153. */
  32154. removeVelocityGradient(gradient: number): IParticleSystem;
  32155. /**
  32156. * Adds a new limit velocity gradient
  32157. * @param gradient defines the gradient to use (between 0 and 1)
  32158. * @param factor defines the limit velocity value to affect to the specified gradient
  32159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32160. * @returns the current particle system
  32161. */
  32162. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32163. /**
  32164. * Remove a specific limit velocity gradient
  32165. * @param gradient defines the gradient to remove
  32166. * @returns the current particle system
  32167. */
  32168. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32169. /**
  32170. * Adds a new drag gradient
  32171. * @param gradient defines the gradient to use (between 0 and 1)
  32172. * @param factor defines the drag value to affect to the specified gradient
  32173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32174. * @returns the current particle system
  32175. */
  32176. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32177. /**
  32178. * Remove a specific drag gradient
  32179. * @param gradient defines the gradient to remove
  32180. * @returns the current particle system
  32181. */
  32182. removeDragGradient(gradient: number): IParticleSystem;
  32183. /**
  32184. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32185. * @param gradient defines the gradient to use (between 0 and 1)
  32186. * @param factor defines the emit rate value to affect to the specified gradient
  32187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32188. * @returns the current particle system
  32189. */
  32190. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32191. /**
  32192. * Remove a specific emit rate gradient
  32193. * @param gradient defines the gradient to remove
  32194. * @returns the current particle system
  32195. */
  32196. removeEmitRateGradient(gradient: number): IParticleSystem;
  32197. /**
  32198. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32199. * @param gradient defines the gradient to use (between 0 and 1)
  32200. * @param factor defines the start size value to affect to the specified gradient
  32201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32202. * @returns the current particle system
  32203. */
  32204. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32205. /**
  32206. * Remove a specific start size gradient
  32207. * @param gradient defines the gradient to remove
  32208. * @returns the current particle system
  32209. */
  32210. removeStartSizeGradient(gradient: number): IParticleSystem;
  32211. private _createRampGradientTexture;
  32212. /**
  32213. * Gets the current list of ramp gradients.
  32214. * You must use addRampGradient and removeRampGradient to udpate this list
  32215. * @returns the list of ramp gradients
  32216. */
  32217. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32218. /**
  32219. * Adds a new ramp gradient used to remap particle colors
  32220. * @param gradient defines the gradient to use (between 0 and 1)
  32221. * @param color defines the color to affect to the specified gradient
  32222. * @returns the current particle system
  32223. */
  32224. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32225. /**
  32226. * Remove a specific ramp gradient
  32227. * @param gradient defines the gradient to remove
  32228. * @returns the current particle system
  32229. */
  32230. removeRampGradient(gradient: number): ParticleSystem;
  32231. /**
  32232. * Adds a new color gradient
  32233. * @param gradient defines the gradient to use (between 0 and 1)
  32234. * @param color1 defines the color to affect to the specified gradient
  32235. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32236. * @returns this particle system
  32237. */
  32238. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32239. /**
  32240. * Remove a specific color gradient
  32241. * @param gradient defines the gradient to remove
  32242. * @returns this particle system
  32243. */
  32244. removeColorGradient(gradient: number): IParticleSystem;
  32245. private _fetchR;
  32246. protected _reset(): void;
  32247. private _resetEffect;
  32248. private _createVertexBuffers;
  32249. private _createIndexBuffer;
  32250. /**
  32251. * Gets the maximum number of particles active at the same time.
  32252. * @returns The max number of active particles.
  32253. */
  32254. getCapacity(): number;
  32255. /**
  32256. * Gets whether there are still active particles in the system.
  32257. * @returns True if it is alive, otherwise false.
  32258. */
  32259. isAlive(): boolean;
  32260. /**
  32261. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32262. * @returns True if it has been started, otherwise false.
  32263. */
  32264. isStarted(): boolean;
  32265. private _prepareSubEmitterInternalArray;
  32266. /**
  32267. * Starts the particle system and begins to emit
  32268. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32269. */
  32270. start(delay?: number): void;
  32271. /**
  32272. * Stops the particle system.
  32273. * @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.
  32274. */
  32275. stop(stopSubEmitters?: boolean): void;
  32276. /**
  32277. * Remove all active particles
  32278. */
  32279. reset(): void;
  32280. /**
  32281. * @hidden (for internal use only)
  32282. */
  32283. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32284. /**
  32285. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32286. * Its lifetime will start back at 0.
  32287. */
  32288. recycleParticle: (particle: Particle) => void;
  32289. private _stopSubEmitters;
  32290. private _createParticle;
  32291. private _removeFromRoot;
  32292. private _emitFromParticle;
  32293. private _update;
  32294. /** @hidden */
  32295. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32296. /** @hidden */
  32297. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32298. /** @hidden */
  32299. private _getEffect;
  32300. /**
  32301. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32302. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32303. */
  32304. animate(preWarmOnly?: boolean): void;
  32305. private _appendParticleVertices;
  32306. /**
  32307. * Rebuilds the particle system.
  32308. */
  32309. rebuild(): void;
  32310. /**
  32311. * Is this system ready to be used/rendered
  32312. * @return true if the system is ready
  32313. */
  32314. isReady(): boolean;
  32315. private _render;
  32316. /**
  32317. * Renders the particle system in its current state.
  32318. * @returns the current number of particles
  32319. */
  32320. render(): number;
  32321. /**
  32322. * Disposes the particle system and free the associated resources
  32323. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32324. */
  32325. dispose(disposeTexture?: boolean): void;
  32326. /**
  32327. * Clones the particle system.
  32328. * @param name The name of the cloned object
  32329. * @param newEmitter The new emitter to use
  32330. * @returns the cloned particle system
  32331. */
  32332. clone(name: string, newEmitter: any): ParticleSystem;
  32333. /**
  32334. * Serializes the particle system to a JSON object.
  32335. * @returns the JSON object
  32336. */
  32337. serialize(): any;
  32338. /** @hidden */
  32339. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32340. /** @hidden */
  32341. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32342. /**
  32343. * Parses a JSON object to create a particle system.
  32344. * @param parsedParticleSystem The JSON object to parse
  32345. * @param scene The scene to create the particle system in
  32346. * @param rootUrl The root url to use to load external dependencies like texture
  32347. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32348. * @returns the Parsed particle system
  32349. */
  32350. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32351. }
  32352. }
  32353. declare module BABYLON {
  32354. interface Engine {
  32355. /**
  32356. * Create an effect to use with particle systems.
  32357. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32358. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32359. * @param uniformsNames defines a list of attribute names
  32360. * @param samplers defines an array of string used to represent textures
  32361. * @param defines defines the string containing the defines to use to compile the shaders
  32362. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32363. * @param onCompiled defines a function to call when the effect creation is successful
  32364. * @param onError defines a function to call when the effect creation has failed
  32365. * @returns the new Effect
  32366. */
  32367. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32368. }
  32369. interface Mesh {
  32370. /**
  32371. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32372. * @returns an array of IParticleSystem
  32373. */
  32374. getEmittedParticleSystems(): IParticleSystem[];
  32375. /**
  32376. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32377. * @returns an array of IParticleSystem
  32378. */
  32379. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32380. }
  32381. }
  32382. declare module BABYLON {
  32383. /**
  32384. * Represents a set of particle systems working together to create a specific effect
  32385. */
  32386. class ParticleSystemSet implements IDisposable {
  32387. private _emitterCreationOptions;
  32388. private _emitterNode;
  32389. /**
  32390. * Gets the particle system list
  32391. */
  32392. systems: IParticleSystem[];
  32393. /**
  32394. * Gets the emitter node used with this set
  32395. */
  32396. readonly emitterNode: Nullable<TransformNode>;
  32397. /**
  32398. * Creates a new emitter mesh as a sphere
  32399. * @param options defines the options used to create the sphere
  32400. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32401. * @param scene defines the hosting scene
  32402. */
  32403. setEmitterAsSphere(options: {
  32404. diameter: number;
  32405. segments: number;
  32406. color: Color3;
  32407. }, renderingGroupId: number, scene: Scene): void;
  32408. /**
  32409. * Starts all particle systems of the set
  32410. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32411. */
  32412. start(emitter?: AbstractMesh): void;
  32413. /**
  32414. * Release all associated resources
  32415. */
  32416. dispose(): void;
  32417. /**
  32418. * Serialize the set into a JSON compatible object
  32419. * @returns a JSON compatible representation of the set
  32420. */
  32421. serialize(): any;
  32422. /**
  32423. * Parse a new ParticleSystemSet from a serialized source
  32424. * @param data defines a JSON compatible representation of the set
  32425. * @param scene defines the hosting scene
  32426. * @param gpu defines if we want GPU particles or CPU particles
  32427. * @returns a new ParticleSystemSet
  32428. */
  32429. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32430. }
  32431. }
  32432. declare module BABYLON {
  32433. /**
  32434. * Represents one particle of a solid particle system.
  32435. */
  32436. class SolidParticle {
  32437. /**
  32438. * particle global index
  32439. */
  32440. idx: number;
  32441. /**
  32442. * The color of the particle
  32443. */
  32444. color: Nullable<Color4>;
  32445. /**
  32446. * The world space position of the particle.
  32447. */
  32448. position: Vector3;
  32449. /**
  32450. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32451. */
  32452. rotation: Vector3;
  32453. /**
  32454. * The world space rotation quaternion of the particle.
  32455. */
  32456. rotationQuaternion: Nullable<Quaternion>;
  32457. /**
  32458. * The scaling of the particle.
  32459. */
  32460. scaling: Vector3;
  32461. /**
  32462. * The uvs of the particle.
  32463. */
  32464. uvs: Vector4;
  32465. /**
  32466. * The current speed of the particle.
  32467. */
  32468. velocity: Vector3;
  32469. /**
  32470. * The pivot point in the particle local space.
  32471. */
  32472. pivot: Vector3;
  32473. /**
  32474. * Must the particle be translated from its pivot point in its local space ?
  32475. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32476. * Default : false
  32477. */
  32478. translateFromPivot: boolean;
  32479. /**
  32480. * Is the particle active or not ?
  32481. */
  32482. alive: boolean;
  32483. /**
  32484. * Is the particle visible or not ?
  32485. */
  32486. isVisible: boolean;
  32487. /**
  32488. * Index of this particle in the global "positions" array (Internal use)
  32489. * @hidden
  32490. */
  32491. _pos: number;
  32492. /**
  32493. * @hidden Index of this particle in the global "indices" array (Internal use)
  32494. */
  32495. _ind: number;
  32496. /**
  32497. * @hidden ModelShape of this particle (Internal use)
  32498. */
  32499. _model: ModelShape;
  32500. /**
  32501. * ModelShape id of this particle
  32502. */
  32503. shapeId: number;
  32504. /**
  32505. * Index of the particle in its shape id (Internal use)
  32506. */
  32507. idxInShape: number;
  32508. /**
  32509. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32510. */
  32511. _modelBoundingInfo: BoundingInfo;
  32512. /**
  32513. * @hidden Particle BoundingInfo object (Internal use)
  32514. */
  32515. _boundingInfo: BoundingInfo;
  32516. /**
  32517. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32518. */
  32519. _sps: SolidParticleSystem;
  32520. /**
  32521. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32522. */
  32523. _stillInvisible: boolean;
  32524. /**
  32525. * @hidden Last computed particle rotation matrix
  32526. */
  32527. _rotationMatrix: number[];
  32528. /**
  32529. * Parent particle Id, if any.
  32530. * Default null.
  32531. */
  32532. parentId: Nullable<number>;
  32533. /**
  32534. * @hidden Internal global position in the SPS.
  32535. */
  32536. _globalPosition: Vector3;
  32537. /**
  32538. * Creates a Solid Particle object.
  32539. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32540. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32541. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32542. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32543. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32544. * @param shapeId (integer) is the model shape identifier in the SPS.
  32545. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32546. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32547. */
  32548. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32549. /**
  32550. * Legacy support, changed scale to scaling
  32551. */
  32552. /**
  32553. * Legacy support, changed scale to scaling
  32554. */
  32555. scale: Vector3;
  32556. /**
  32557. * Legacy support, changed quaternion to rotationQuaternion
  32558. */
  32559. /**
  32560. * Legacy support, changed quaternion to rotationQuaternion
  32561. */
  32562. quaternion: Nullable<Quaternion>;
  32563. /**
  32564. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32565. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32566. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32567. * @returns true if it intersects
  32568. */
  32569. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32570. /**
  32571. * get the rotation matrix of the particle
  32572. * @hidden
  32573. */
  32574. getRotationMatrix(m: Matrix): void;
  32575. }
  32576. /**
  32577. * Represents the shape of the model used by one particle of a solid particle system.
  32578. * SPS internal tool, don't use it manually.
  32579. */
  32580. class ModelShape {
  32581. /**
  32582. * The shape id
  32583. * @hidden
  32584. */
  32585. shapeID: number;
  32586. /**
  32587. * flat array of model positions (internal use)
  32588. * @hidden
  32589. */
  32590. _shape: Vector3[];
  32591. /**
  32592. * flat array of model UVs (internal use)
  32593. * @hidden
  32594. */
  32595. _shapeUV: number[];
  32596. /**
  32597. * length of the shape in the model indices array (internal use)
  32598. * @hidden
  32599. */
  32600. _indicesLength: number;
  32601. /**
  32602. * Custom position function (internal use)
  32603. * @hidden
  32604. */
  32605. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32606. /**
  32607. * Custom vertex function (internal use)
  32608. * @hidden
  32609. */
  32610. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32611. /**
  32612. * 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.
  32613. * SPS internal tool, don't use it manually.
  32614. * @hidden
  32615. */
  32616. 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>);
  32617. }
  32618. /**
  32619. * Represents a Depth Sorted Particle in the solid particle system.
  32620. */
  32621. class DepthSortedParticle {
  32622. /**
  32623. * Index of the particle in the "indices" array
  32624. */
  32625. ind: number;
  32626. /**
  32627. * Length of the particle shape in the "indices" array
  32628. */
  32629. indicesLength: number;
  32630. /**
  32631. * Squared distance from the particle to the camera
  32632. */
  32633. sqDistance: number;
  32634. }
  32635. }
  32636. declare module BABYLON {
  32637. /**
  32638. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32639. *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.
  32640. * The SPS is also a particle system. It provides some methods to manage the particles.
  32641. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32642. *
  32643. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32644. */
  32645. class SolidParticleSystem implements IDisposable {
  32646. /**
  32647. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32648. * Example : var p = SPS.particles[i];
  32649. */
  32650. particles: SolidParticle[];
  32651. /**
  32652. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32653. */
  32654. nbParticles: number;
  32655. /**
  32656. * If the particles must ever face the camera (default false). Useful for planar particles.
  32657. */
  32658. billboard: boolean;
  32659. /**
  32660. * Recompute normals when adding a shape
  32661. */
  32662. recomputeNormals: boolean;
  32663. /**
  32664. * This a counter ofr your own usage. It's not set by any SPS functions.
  32665. */
  32666. counter: number;
  32667. /**
  32668. * The SPS name. This name is also given to the underlying mesh.
  32669. */
  32670. name: string;
  32671. /**
  32672. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32673. */
  32674. mesh: Mesh;
  32675. /**
  32676. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32677. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32678. */
  32679. vars: any;
  32680. /**
  32681. * This array is populated when the SPS is set as 'pickable'.
  32682. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32683. * Each element of this array is an object `{idx: int, faceId: int}`.
  32684. * `idx` is the picked particle index in the `SPS.particles` array
  32685. * `faceId` is the picked face index counted within this particle.
  32686. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32687. */
  32688. pickedParticles: {
  32689. idx: number;
  32690. faceId: number;
  32691. }[];
  32692. /**
  32693. * This array is populated when `enableDepthSort` is set to true.
  32694. * Each element of this array is an instance of the class DepthSortedParticle.
  32695. */
  32696. depthSortedParticles: DepthSortedParticle[];
  32697. /**
  32698. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32699. * @hidden
  32700. */
  32701. _bSphereOnly: boolean;
  32702. /**
  32703. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32704. * @hidden
  32705. */
  32706. _bSphereRadiusFactor: number;
  32707. private _scene;
  32708. private _positions;
  32709. private _indices;
  32710. private _normals;
  32711. private _colors;
  32712. private _uvs;
  32713. private _indices32;
  32714. private _positions32;
  32715. private _normals32;
  32716. private _fixedNormal32;
  32717. private _colors32;
  32718. private _uvs32;
  32719. private _index;
  32720. private _updatable;
  32721. private _pickable;
  32722. private _isVisibilityBoxLocked;
  32723. private _alwaysVisible;
  32724. private _depthSort;
  32725. private _shapeCounter;
  32726. private _copy;
  32727. private _color;
  32728. private _computeParticleColor;
  32729. private _computeParticleTexture;
  32730. private _computeParticleRotation;
  32731. private _computeParticleVertex;
  32732. private _computeBoundingBox;
  32733. private _depthSortParticles;
  32734. private _camera;
  32735. private _mustUnrotateFixedNormals;
  32736. private _particlesIntersect;
  32737. private _needs32Bits;
  32738. /**
  32739. * Creates a SPS (Solid Particle System) object.
  32740. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32741. * @param scene (Scene) is the scene in which the SPS is added.
  32742. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32743. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32744. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32745. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32746. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32747. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32748. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32749. */
  32750. constructor(name: string, scene: Scene, options?: {
  32751. updatable?: boolean;
  32752. isPickable?: boolean;
  32753. enableDepthSort?: boolean;
  32754. particleIntersection?: boolean;
  32755. boundingSphereOnly?: boolean;
  32756. bSphereRadiusFactor?: number;
  32757. });
  32758. /**
  32759. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32760. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32761. * @returns the created mesh
  32762. */
  32763. buildMesh(): Mesh;
  32764. /**
  32765. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32766. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32767. * Thus the particles generated from `digest()` have their property `position` set yet.
  32768. * @param mesh ( Mesh ) is the mesh to be digested
  32769. * @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
  32770. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32771. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32772. * @returns the current SPS
  32773. */
  32774. digest(mesh: Mesh, options?: {
  32775. facetNb?: number;
  32776. number?: number;
  32777. delta?: number;
  32778. }): SolidParticleSystem;
  32779. private _unrotateFixedNormals;
  32780. private _resetCopy;
  32781. private _meshBuilder;
  32782. private _posToShape;
  32783. private _uvsToShapeUV;
  32784. private _addParticle;
  32785. /**
  32786. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32787. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32788. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32789. * @param nb (positive integer) the number of particles to be created from this model
  32790. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32791. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32792. * @returns the number of shapes in the system
  32793. */
  32794. addShape(mesh: Mesh, nb: number, options?: {
  32795. positionFunction?: any;
  32796. vertexFunction?: any;
  32797. }): number;
  32798. private _rebuildParticle;
  32799. /**
  32800. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32801. * @returns the SPS.
  32802. */
  32803. rebuildMesh(): SolidParticleSystem;
  32804. /**
  32805. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32806. * This method calls `updateParticle()` for each particle of the SPS.
  32807. * For an animated SPS, it is usually called within the render loop.
  32808. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32809. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32810. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32811. * @returns the SPS.
  32812. */
  32813. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32814. /**
  32815. * Disposes the SPS.
  32816. */
  32817. dispose(): void;
  32818. /**
  32819. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32820. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32821. * @returns the SPS.
  32822. */
  32823. refreshVisibleSize(): SolidParticleSystem;
  32824. /**
  32825. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32826. * @param size the size (float) of the visibility box
  32827. * note : this doesn't lock the SPS mesh bounding box.
  32828. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32829. */
  32830. setVisibilityBox(size: number): void;
  32831. /**
  32832. * Gets whether the SPS as always visible or not
  32833. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32834. */
  32835. /**
  32836. * Sets the SPS as always visible or not
  32837. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32838. */
  32839. isAlwaysVisible: boolean;
  32840. /**
  32841. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32842. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32843. */
  32844. /**
  32845. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32846. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32847. */
  32848. isVisibilityBoxLocked: boolean;
  32849. /**
  32850. * Tells to `setParticles()` to compute the particle rotations or not.
  32851. * Default value : true. The SPS is faster when it's set to false.
  32852. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32853. */
  32854. /**
  32855. * Gets if `setParticles()` computes the particle rotations or not.
  32856. * Default value : true. The SPS is faster when it's set to false.
  32857. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32858. */
  32859. computeParticleRotation: boolean;
  32860. /**
  32861. * Tells to `setParticles()` to compute the particle colors or not.
  32862. * Default value : true. The SPS is faster when it's set to false.
  32863. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32864. */
  32865. /**
  32866. * Gets if `setParticles()` computes the particle colors or not.
  32867. * Default value : true. The SPS is faster when it's set to false.
  32868. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32869. */
  32870. computeParticleColor: boolean;
  32871. /**
  32872. * Gets if `setParticles()` computes the particle textures or not.
  32873. * Default value : true. The SPS is faster when it's set to false.
  32874. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32875. */
  32876. computeParticleTexture: boolean;
  32877. /**
  32878. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32879. * Default value : false. The SPS is faster when it's set to false.
  32880. * Note : the particle custom vertex positions aren't stored values.
  32881. */
  32882. /**
  32883. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32884. * Default value : false. The SPS is faster when it's set to false.
  32885. * Note : the particle custom vertex positions aren't stored values.
  32886. */
  32887. computeParticleVertex: boolean;
  32888. /**
  32889. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32890. */
  32891. /**
  32892. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32893. */
  32894. computeBoundingBox: boolean;
  32895. /**
  32896. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32897. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32898. * Default : `true`
  32899. */
  32900. /**
  32901. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32902. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32903. * Default : `true`
  32904. */
  32905. depthSortParticles: boolean;
  32906. /**
  32907. * This function does nothing. It may be overwritten to set all the particle first values.
  32908. * The SPS doesn't call this function, you may have to call it by your own.
  32909. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32910. */
  32911. initParticles(): void;
  32912. /**
  32913. * This function does nothing. It may be overwritten to recycle a particle.
  32914. * The SPS doesn't call this function, you may have to call it by your own.
  32915. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32916. * @param particle The particle to recycle
  32917. * @returns the recycled particle
  32918. */
  32919. recycleParticle(particle: SolidParticle): SolidParticle;
  32920. /**
  32921. * Updates a particle : this function should be overwritten by the user.
  32922. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32923. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32924. * @example : just set a particle position or velocity and recycle conditions
  32925. * @param particle The particle to update
  32926. * @returns the updated particle
  32927. */
  32928. updateParticle(particle: SolidParticle): SolidParticle;
  32929. /**
  32930. * Updates a vertex of a particle : it can be overwritten by the user.
  32931. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32932. * @param particle the current particle
  32933. * @param vertex the current index of the current particle
  32934. * @param pt the index of the current vertex in the particle shape
  32935. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32936. * @example : just set a vertex particle position
  32937. * @returns the updated vertex
  32938. */
  32939. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32940. /**
  32941. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32942. * This does nothing and may be overwritten by the user.
  32943. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32944. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32945. * @param update the boolean update value actually passed to setParticles()
  32946. */
  32947. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32948. /**
  32949. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32950. * This will be passed three parameters.
  32951. * This does nothing and may be overwritten by the user.
  32952. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32953. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32954. * @param update the boolean update value actually passed to setParticles()
  32955. */
  32956. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32957. }
  32958. }
  32959. declare module BABYLON {
  32960. /**
  32961. * Type of sub emitter
  32962. */
  32963. enum SubEmitterType {
  32964. /**
  32965. * Attached to the particle over it's lifetime
  32966. */
  32967. ATTACHED = 0,
  32968. /**
  32969. * Created when the particle dies
  32970. */
  32971. END = 1
  32972. }
  32973. /**
  32974. * Sub emitter class used to emit particles from an existing particle
  32975. */
  32976. class SubEmitter {
  32977. /**
  32978. * the particle system to be used by the sub emitter
  32979. */
  32980. particleSystem: ParticleSystem;
  32981. /**
  32982. * Type of the submitter (Default: END)
  32983. */
  32984. type: SubEmitterType;
  32985. /**
  32986. * 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)
  32987. * Note: This only is supported when using an emitter of type Mesh
  32988. */
  32989. inheritDirection: boolean;
  32990. /**
  32991. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32992. */
  32993. inheritedVelocityAmount: number;
  32994. /**
  32995. * Creates a sub emitter
  32996. * @param particleSystem the particle system to be used by the sub emitter
  32997. */
  32998. constructor(
  32999. /**
  33000. * the particle system to be used by the sub emitter
  33001. */
  33002. particleSystem: ParticleSystem);
  33003. /**
  33004. * Clones the sub emitter
  33005. * @returns the cloned sub emitter
  33006. */
  33007. clone(): SubEmitter;
  33008. /**
  33009. * Serialize current object to a JSON object
  33010. * @returns the serialized object
  33011. */
  33012. serialize(): any;
  33013. /**
  33014. * Creates a new SubEmitter from a serialized JSON version
  33015. * @param serializationObject defines the JSON object to read from
  33016. * @param scene defines the hosting scene
  33017. * @param rootUrl defines the rootUrl for data loading
  33018. * @returns a new SubEmitter
  33019. */
  33020. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33021. /** Release associated resources */
  33022. dispose(): void;
  33023. }
  33024. }
  33025. declare module BABYLON {
  33026. /**
  33027. * Interface used to describe a physics joint
  33028. */
  33029. interface PhysicsImpostorJoint {
  33030. /** Defines the main impostor to which the joint is linked */
  33031. mainImpostor: PhysicsImpostor;
  33032. /** Defines the impostor that is connected to the main impostor using this joint */
  33033. connectedImpostor: PhysicsImpostor;
  33034. /** Defines the joint itself */
  33035. joint: PhysicsJoint;
  33036. }
  33037. /** @hidden */
  33038. interface IPhysicsEnginePlugin {
  33039. world: any;
  33040. name: string;
  33041. setGravity(gravity: Vector3): void;
  33042. setTimeStep(timeStep: number): void;
  33043. getTimeStep(): number;
  33044. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33045. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33046. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33047. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33048. removePhysicsBody(impostor: PhysicsImpostor): void;
  33049. generateJoint(joint: PhysicsImpostorJoint): void;
  33050. removeJoint(joint: PhysicsImpostorJoint): void;
  33051. isSupported(): boolean;
  33052. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33053. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33054. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33055. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33056. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33057. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33058. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33059. getBodyMass(impostor: PhysicsImpostor): number;
  33060. getBodyFriction(impostor: PhysicsImpostor): number;
  33061. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33062. getBodyRestitution(impostor: PhysicsImpostor): number;
  33063. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33064. sleepBody(impostor: PhysicsImpostor): void;
  33065. wakeUpBody(impostor: PhysicsImpostor): void;
  33066. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33067. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33068. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33069. getRadius(impostor: PhysicsImpostor): number;
  33070. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33071. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33072. dispose(): void;
  33073. }
  33074. /**
  33075. * Interface used to define a physics engine
  33076. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33077. */
  33078. interface IPhysicsEngine {
  33079. /**
  33080. * Gets the gravity vector used by the simulation
  33081. */
  33082. gravity: Vector3;
  33083. /**
  33084. * Sets the gravity vector used by the simulation
  33085. * @param gravity defines the gravity vector to use
  33086. */
  33087. setGravity(gravity: Vector3): void;
  33088. /**
  33089. * Set the time step of the physics engine.
  33090. * Default is 1/60.
  33091. * To slow it down, enter 1/600 for example.
  33092. * To speed it up, 1/30
  33093. * @param newTimeStep the new timestep to apply to this world.
  33094. */
  33095. setTimeStep(newTimeStep: number): void;
  33096. /**
  33097. * Get the time step of the physics engine.
  33098. * @returns the current time step
  33099. */
  33100. getTimeStep(): number;
  33101. /**
  33102. * Release all resources
  33103. */
  33104. dispose(): void;
  33105. /**
  33106. * Gets the name of the current physics plugin
  33107. * @returns the name of the plugin
  33108. */
  33109. getPhysicsPluginName(): string;
  33110. /**
  33111. * Adding a new impostor for the impostor tracking.
  33112. * This will be done by the impostor itself.
  33113. * @param impostor the impostor to add
  33114. */
  33115. addImpostor(impostor: PhysicsImpostor): void;
  33116. /**
  33117. * Remove an impostor from the engine.
  33118. * This impostor and its mesh will not longer be updated by the physics engine.
  33119. * @param impostor the impostor to remove
  33120. */
  33121. removeImpostor(impostor: PhysicsImpostor): void;
  33122. /**
  33123. * Add a joint to the physics engine
  33124. * @param mainImpostor defines the main impostor to which the joint is added.
  33125. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33126. * @param joint defines the joint that will connect both impostors.
  33127. */
  33128. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33129. /**
  33130. * Removes a joint from the simulation
  33131. * @param mainImpostor defines the impostor used with the joint
  33132. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33133. * @param joint defines the joint to remove
  33134. */
  33135. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33136. /**
  33137. * Gets the current plugin used to run the simulation
  33138. * @returns current plugin
  33139. */
  33140. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33141. /**
  33142. * Gets the list of physic impostors
  33143. * @returns an array of PhysicsImpostor
  33144. */
  33145. getImpostors(): Array<PhysicsImpostor>;
  33146. /**
  33147. * Gets the impostor for a physics enabled object
  33148. * @param object defines the object impersonated by the impostor
  33149. * @returns the PhysicsImpostor or null if not found
  33150. */
  33151. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33152. /**
  33153. * Gets the impostor for a physics body object
  33154. * @param body defines physics body used by the impostor
  33155. * @returns the PhysicsImpostor or null if not found
  33156. */
  33157. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33158. /**
  33159. * Called by the scene. No need to call it.
  33160. * @param delta defines the timespam between frames
  33161. */
  33162. _step(delta: number): void;
  33163. }
  33164. }
  33165. declare module BABYLON {
  33166. /**
  33167. * Class used to control physics engine
  33168. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33169. */
  33170. class PhysicsEngine implements IPhysicsEngine {
  33171. private _physicsPlugin;
  33172. /**
  33173. * Global value used to control the smallest number supported by the simulation
  33174. */
  33175. static Epsilon: number;
  33176. private _impostors;
  33177. private _joints;
  33178. /**
  33179. * Gets the gravity vector used by the simulation
  33180. */
  33181. gravity: Vector3;
  33182. /**
  33183. * Creates a new Physics Engine
  33184. * @param gravity defines the gravity vector used by the simulation
  33185. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33186. */
  33187. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33188. /**
  33189. * Sets the gravity vector used by the simulation
  33190. * @param gravity defines the gravity vector to use
  33191. */
  33192. setGravity(gravity: Vector3): void;
  33193. /**
  33194. * Set the time step of the physics engine.
  33195. * Default is 1/60.
  33196. * To slow it down, enter 1/600 for example.
  33197. * To speed it up, 1/30
  33198. * @param newTimeStep defines the new timestep to apply to this world.
  33199. */
  33200. setTimeStep(newTimeStep?: number): void;
  33201. /**
  33202. * Get the time step of the physics engine.
  33203. * @returns the current time step
  33204. */
  33205. getTimeStep(): number;
  33206. /**
  33207. * Release all resources
  33208. */
  33209. dispose(): void;
  33210. /**
  33211. * Gets the name of the current physics plugin
  33212. * @returns the name of the plugin
  33213. */
  33214. getPhysicsPluginName(): string;
  33215. /**
  33216. * Adding a new impostor for the impostor tracking.
  33217. * This will be done by the impostor itself.
  33218. * @param impostor the impostor to add
  33219. */
  33220. addImpostor(impostor: PhysicsImpostor): void;
  33221. /**
  33222. * Remove an impostor from the engine.
  33223. * This impostor and its mesh will not longer be updated by the physics engine.
  33224. * @param impostor the impostor to remove
  33225. */
  33226. removeImpostor(impostor: PhysicsImpostor): void;
  33227. /**
  33228. * Add a joint to the physics engine
  33229. * @param mainImpostor defines the main impostor to which the joint is added.
  33230. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33231. * @param joint defines the joint that will connect both impostors.
  33232. */
  33233. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33234. /**
  33235. * Removes a joint from the simulation
  33236. * @param mainImpostor defines the impostor used with the joint
  33237. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33238. * @param joint defines the joint to remove
  33239. */
  33240. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33241. /**
  33242. * Called by the scene. No need to call it.
  33243. * @param delta defines the timespam between frames
  33244. */
  33245. _step(delta: number): void;
  33246. /**
  33247. * Gets the current plugin used to run the simulation
  33248. * @returns current plugin
  33249. */
  33250. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33251. /**
  33252. * Gets the list of physic impostors
  33253. * @returns an array of PhysicsImpostor
  33254. */
  33255. getImpostors(): Array<PhysicsImpostor>;
  33256. /**
  33257. * Gets the impostor for a physics enabled object
  33258. * @param object defines the object impersonated by the impostor
  33259. * @returns the PhysicsImpostor or null if not found
  33260. */
  33261. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33262. /**
  33263. * Gets the impostor for a physics body object
  33264. * @param body defines physics body used by the impostor
  33265. * @returns the PhysicsImpostor or null if not found
  33266. */
  33267. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33268. }
  33269. }
  33270. declare module BABYLON {
  33271. interface Scene {
  33272. /** @hidden (Backing field) */
  33273. _physicsEngine: Nullable<IPhysicsEngine>;
  33274. /**
  33275. * Gets the current physics engine
  33276. * @returns a IPhysicsEngine or null if none attached
  33277. */
  33278. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33279. /**
  33280. * Enables physics to the current scene
  33281. * @param gravity defines the scene's gravity for the physics engine
  33282. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33283. * @return a boolean indicating if the physics engine was initialized
  33284. */
  33285. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33286. /**
  33287. * Disables and disposes the physics engine associated with the scene
  33288. */
  33289. disablePhysicsEngine(): void;
  33290. /**
  33291. * Gets a boolean indicating if there is an active physics engine
  33292. * @returns a boolean indicating if there is an active physics engine
  33293. */
  33294. isPhysicsEnabled(): boolean;
  33295. /**
  33296. * Deletes a physics compound impostor
  33297. * @param compound defines the compound to delete
  33298. */
  33299. deleteCompoundImpostor(compound: any): void;
  33300. /**
  33301. * An event triggered when physic simulation is about to be run
  33302. */
  33303. onBeforePhysicsObservable: Observable<Scene>;
  33304. /**
  33305. * An event triggered when physic simulation has been done
  33306. */
  33307. onAfterPhysicsObservable: Observable<Scene>;
  33308. }
  33309. interface AbstractMesh {
  33310. /** @hidden */
  33311. _physicsImpostor: Nullable<PhysicsImpostor>;
  33312. /**
  33313. * Gets or sets impostor used for physic simulation
  33314. * @see http://doc.babylonjs.com/features/physics_engine
  33315. */
  33316. physicsImpostor: Nullable<PhysicsImpostor>;
  33317. /**
  33318. * Gets the current physics impostor
  33319. * @see http://doc.babylonjs.com/features/physics_engine
  33320. * @returns a physics impostor or null
  33321. */
  33322. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33323. /** Apply a physic impulse to the mesh
  33324. * @param force defines the force to apply
  33325. * @param contactPoint defines where to apply the force
  33326. * @returns the current mesh
  33327. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33328. */
  33329. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33330. /**
  33331. * Creates a physic joint between two meshes
  33332. * @param otherMesh defines the other mesh to use
  33333. * @param pivot1 defines the pivot to use on this mesh
  33334. * @param pivot2 defines the pivot to use on the other mesh
  33335. * @param options defines additional options (can be plugin dependent)
  33336. * @returns the current mesh
  33337. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33338. */
  33339. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33340. /** @hidden */
  33341. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33342. }
  33343. /**
  33344. * Defines the physics engine scene component responsible to manage a physics engine
  33345. */
  33346. class PhysicsEngineSceneComponent implements ISceneComponent {
  33347. /**
  33348. * The component name helpful to identify the component in the list of scene components.
  33349. */
  33350. readonly name: string;
  33351. /**
  33352. * The scene the component belongs to.
  33353. */
  33354. scene: Scene;
  33355. /**
  33356. * Creates a new instance of the component for the given scene
  33357. * @param scene Defines the scene to register the component in
  33358. */
  33359. constructor(scene: Scene);
  33360. /**
  33361. * Registers the component in a given scene
  33362. */
  33363. register(): void;
  33364. /**
  33365. * Rebuilds the elements related to this component in case of
  33366. * context lost for instance.
  33367. */
  33368. rebuild(): void;
  33369. /**
  33370. * Disposes the component and the associated ressources
  33371. */
  33372. dispose(): void;
  33373. }
  33374. }
  33375. declare module BABYLON {
  33376. /**
  33377. * A helper for physics simulations
  33378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33379. */
  33380. class PhysicsHelper {
  33381. private _scene;
  33382. private _physicsEngine;
  33383. /**
  33384. * Initializes the Physics helper
  33385. * @param scene Babylon.js scene
  33386. */
  33387. constructor(scene: Scene);
  33388. /**
  33389. * Applies a radial explosion impulse
  33390. * @param origin the origin of the explosion
  33391. * @param radius the explosion radius
  33392. * @param strength the explosion strength
  33393. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33394. * @returns A physics radial explosion event, or null
  33395. */
  33396. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33397. /**
  33398. * Applies a radial explosion force
  33399. * @param origin the origin of the explosion
  33400. * @param radius the explosion radius
  33401. * @param strength the explosion strength
  33402. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33403. * @returns A physics radial explosion event, or null
  33404. */
  33405. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33406. /**
  33407. * Creates a gravitational field
  33408. * @param origin the origin of the explosion
  33409. * @param radius the explosion radius
  33410. * @param strength the explosion strength
  33411. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33412. * @returns A physics gravitational field event, or null
  33413. */
  33414. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33415. /**
  33416. * Creates a physics updraft event
  33417. * @param origin the origin of the updraft
  33418. * @param radius the radius of the updraft
  33419. * @param strength the strength of the updraft
  33420. * @param height the height of the updraft
  33421. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33422. * @returns A physics updraft event, or null
  33423. */
  33424. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33425. /**
  33426. * Creates a physics vortex event
  33427. * @param origin the of the vortex
  33428. * @param radius the radius of the vortex
  33429. * @param strength the strength of the vortex
  33430. * @param height the height of the vortex
  33431. * @returns a Physics vortex event, or null
  33432. * A physics vortex event or null
  33433. */
  33434. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33435. }
  33436. /**
  33437. * Represents a physics radial explosion event
  33438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33439. */
  33440. class PhysicsRadialExplosionEvent {
  33441. private _scene;
  33442. private _sphere;
  33443. private _sphereOptions;
  33444. private _rays;
  33445. private _dataFetched;
  33446. /**
  33447. * Initializes a radial explosioin event
  33448. * @param scene BabylonJS scene
  33449. */
  33450. constructor(scene: Scene);
  33451. /**
  33452. * Returns the data related to the radial explosion event (sphere & rays).
  33453. * @returns The radial explosion event data
  33454. */
  33455. getData(): PhysicsRadialExplosionEventData;
  33456. /**
  33457. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33458. * @param impostor A physics imposter
  33459. * @param origin the origin of the explosion
  33460. * @param radius the explosion radius
  33461. * @param strength the explosion strength
  33462. * @param falloff possible options: Constant & Linear
  33463. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33464. */
  33465. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33466. /**
  33467. * Disposes the sphere.
  33468. * @param force Specifies if the sphere should be disposed by force
  33469. */
  33470. dispose(force?: boolean): void;
  33471. /*** Helpers ***/
  33472. private _prepareSphere;
  33473. private _intersectsWithSphere;
  33474. }
  33475. /**
  33476. * Represents a gravitational field event
  33477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33478. */
  33479. class PhysicsGravitationalFieldEvent {
  33480. private _physicsHelper;
  33481. private _scene;
  33482. private _origin;
  33483. private _radius;
  33484. private _strength;
  33485. private _falloff;
  33486. private _tickCallback;
  33487. private _sphere;
  33488. private _dataFetched;
  33489. /**
  33490. * Initializes the physics gravitational field event
  33491. * @param physicsHelper A physics helper
  33492. * @param scene BabylonJS scene
  33493. * @param origin The origin position of the gravitational field event
  33494. * @param radius The radius of the gravitational field event
  33495. * @param strength The strength of the gravitational field event
  33496. * @param falloff The falloff for the gravitational field event
  33497. */
  33498. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33499. /**
  33500. * Returns the data related to the gravitational field event (sphere).
  33501. * @returns A gravitational field event
  33502. */
  33503. getData(): PhysicsGravitationalFieldEventData;
  33504. /**
  33505. * Enables the gravitational field.
  33506. */
  33507. enable(): void;
  33508. /**
  33509. * Disables the gravitational field.
  33510. */
  33511. disable(): void;
  33512. /**
  33513. * Disposes the sphere.
  33514. * @param force The force to dispose from the gravitational field event
  33515. */
  33516. dispose(force?: boolean): void;
  33517. private _tick;
  33518. }
  33519. /**
  33520. * Represents a physics updraft event
  33521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33522. */
  33523. class PhysicsUpdraftEvent {
  33524. private _scene;
  33525. private _origin;
  33526. private _radius;
  33527. private _strength;
  33528. private _height;
  33529. private _updraftMode;
  33530. private _physicsEngine;
  33531. private _originTop;
  33532. private _originDirection;
  33533. private _tickCallback;
  33534. private _cylinder;
  33535. private _cylinderPosition;
  33536. private _dataFetched;
  33537. /**
  33538. * Initializes the physics updraft event
  33539. * @param _scene BabylonJS scene
  33540. * @param _origin The origin position of the updraft
  33541. * @param _radius The radius of the updraft
  33542. * @param _strength The strength of the updraft
  33543. * @param _height The height of the updraft
  33544. * @param _updraftMode The mode of the updraft
  33545. */
  33546. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33547. /**
  33548. * Returns the data related to the updraft event (cylinder).
  33549. * @returns A physics updraft event
  33550. */
  33551. getData(): PhysicsUpdraftEventData;
  33552. /**
  33553. * Enables the updraft.
  33554. */
  33555. enable(): void;
  33556. /**
  33557. * Disables the cortex.
  33558. */
  33559. disable(): void;
  33560. /**
  33561. * Disposes the sphere.
  33562. * @param force Specifies if the updraft should be disposed by force
  33563. */
  33564. dispose(force?: boolean): void;
  33565. private getImpostorForceAndContactPoint;
  33566. private _tick;
  33567. /*** Helpers ***/
  33568. private _prepareCylinder;
  33569. private _intersectsWithCylinder;
  33570. }
  33571. /**
  33572. * Represents a physics vortex event
  33573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33574. */
  33575. class PhysicsVortexEvent {
  33576. private _scene;
  33577. private _origin;
  33578. private _radius;
  33579. private _strength;
  33580. private _height;
  33581. private _physicsEngine;
  33582. private _originTop;
  33583. private _centripetalForceThreshold;
  33584. private _updraftMultiplier;
  33585. private _tickCallback;
  33586. private _cylinder;
  33587. private _cylinderPosition;
  33588. private _dataFetched;
  33589. /**
  33590. * Initializes the physics vortex event
  33591. * @param _scene The BabylonJS scene
  33592. * @param _origin The origin position of the vortex
  33593. * @param _radius The radius of the vortex
  33594. * @param _strength The strength of the vortex
  33595. * @param _height The height of the vortex
  33596. */
  33597. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33598. /**
  33599. * Returns the data related to the vortex event (cylinder).
  33600. * @returns The physics vortex event data
  33601. */
  33602. getData(): PhysicsVortexEventData;
  33603. /**
  33604. * Enables the vortex.
  33605. */
  33606. enable(): void;
  33607. /**
  33608. * Disables the cortex.
  33609. */
  33610. disable(): void;
  33611. /**
  33612. * Disposes the sphere.
  33613. * @param force
  33614. */
  33615. dispose(force?: boolean): void;
  33616. private getImpostorForceAndContactPoint;
  33617. private _tick;
  33618. /*** Helpers ***/
  33619. private _prepareCylinder;
  33620. private _intersectsWithCylinder;
  33621. }
  33622. /**
  33623. * The strenght of the force in correspondence to the distance of the affected object
  33624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33625. */
  33626. enum PhysicsRadialImpulseFalloff {
  33627. /** Defines that impulse is constant in strength across it's whole radius */
  33628. Constant = 0,
  33629. /** DEfines that impulse gets weaker if it's further from the origin */
  33630. Linear = 1
  33631. }
  33632. /**
  33633. * The strength of the force in correspondence to the distance of the affected object
  33634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33635. */
  33636. enum PhysicsUpdraftMode {
  33637. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33638. Center = 0,
  33639. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33640. Perpendicular = 1
  33641. }
  33642. /**
  33643. * Interface for a physics force and contact point
  33644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33645. */
  33646. interface PhysicsForceAndContactPoint {
  33647. /**
  33648. * The force applied at the contact point
  33649. */
  33650. force: Vector3;
  33651. /**
  33652. * The contact point
  33653. */
  33654. contactPoint: Vector3;
  33655. }
  33656. /**
  33657. * Interface for radial explosion event data
  33658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33659. */
  33660. interface PhysicsRadialExplosionEventData {
  33661. /**
  33662. * A sphere used for the radial explosion event
  33663. */
  33664. sphere: Mesh;
  33665. /**
  33666. * An array of rays for the radial explosion event
  33667. */
  33668. rays: Array<Ray>;
  33669. }
  33670. /**
  33671. * Interface for gravitational field event data
  33672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33673. */
  33674. interface PhysicsGravitationalFieldEventData {
  33675. /**
  33676. * A sphere mesh used for the gravitational field event
  33677. */
  33678. sphere: Mesh;
  33679. }
  33680. /**
  33681. * Interface for updraft event data
  33682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33683. */
  33684. interface PhysicsUpdraftEventData {
  33685. /**
  33686. * A cylinder used for the updraft event
  33687. */
  33688. cylinder: Mesh;
  33689. }
  33690. /**
  33691. * Interface for vortex event data
  33692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33693. */
  33694. interface PhysicsVortexEventData {
  33695. /**
  33696. * A cylinder used for the vortex event
  33697. */
  33698. cylinder: Mesh;
  33699. }
  33700. }
  33701. declare module BABYLON {
  33702. /**
  33703. * The interface for the physics imposter parameters
  33704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33705. */
  33706. interface PhysicsImpostorParameters {
  33707. /**
  33708. * The mass of the physics imposter
  33709. */
  33710. mass: number;
  33711. /**
  33712. * The friction of the physics imposter
  33713. */
  33714. friction?: number;
  33715. /**
  33716. * The coefficient of restitution of the physics imposter
  33717. */
  33718. restitution?: number;
  33719. /**
  33720. * The native options of the physics imposter
  33721. */
  33722. nativeOptions?: any;
  33723. /**
  33724. * Specifies if the parent should be ignored
  33725. */
  33726. ignoreParent?: boolean;
  33727. /**
  33728. * Specifies if bi-directional transformations should be disabled
  33729. */
  33730. disableBidirectionalTransformation?: boolean;
  33731. }
  33732. /**
  33733. * Interface for a physics-enabled object
  33734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33735. */
  33736. interface IPhysicsEnabledObject {
  33737. /**
  33738. * The position of the physics-enabled object
  33739. */
  33740. position: Vector3;
  33741. /**
  33742. * The rotation of the physics-enabled object
  33743. */
  33744. rotationQuaternion: Nullable<Quaternion>;
  33745. /**
  33746. * The scale of the physics-enabled object
  33747. */
  33748. scaling: Vector3;
  33749. /**
  33750. * The rotation of the physics-enabled object
  33751. */
  33752. rotation?: Vector3;
  33753. /**
  33754. * The parent of the physics-enabled object
  33755. */
  33756. parent?: any;
  33757. /**
  33758. * The bounding info of the physics-enabled object
  33759. * @returns The bounding info of the physics-enabled object
  33760. */
  33761. getBoundingInfo(): BoundingInfo;
  33762. /**
  33763. * Computes the world matrix
  33764. * @param force Specifies if the world matrix should be computed by force
  33765. * @returns A world matrix
  33766. */
  33767. computeWorldMatrix(force: boolean): Matrix;
  33768. /**
  33769. * Gets the world matrix
  33770. * @returns A world matrix
  33771. */
  33772. getWorldMatrix?(): Matrix;
  33773. /**
  33774. * Gets the child meshes
  33775. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33776. * @returns An array of abstract meshes
  33777. */
  33778. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33779. /**
  33780. * Gets the vertex data
  33781. * @param kind The type of vertex data
  33782. * @returns A nullable array of numbers, or a float32 array
  33783. */
  33784. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33785. /**
  33786. * Gets the indices from the mesh
  33787. * @returns A nullable array of index arrays
  33788. */
  33789. getIndices?(): Nullable<IndicesArray>;
  33790. /**
  33791. * Gets the scene from the mesh
  33792. * @returns the indices array or null
  33793. */
  33794. getScene?(): Scene;
  33795. /**
  33796. * Gets the absolute position from the mesh
  33797. * @returns the absolute position
  33798. */
  33799. getAbsolutePosition(): Vector3;
  33800. /**
  33801. * Gets the absolute pivot point from the mesh
  33802. * @returns the absolute pivot point
  33803. */
  33804. getAbsolutePivotPoint(): Vector3;
  33805. /**
  33806. * Rotates the mesh
  33807. * @param axis The axis of rotation
  33808. * @param amount The amount of rotation
  33809. * @param space The space of the rotation
  33810. * @returns The rotation transform node
  33811. */
  33812. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33813. /**
  33814. * Translates the mesh
  33815. * @param axis The axis of translation
  33816. * @param distance The distance of translation
  33817. * @param space The space of the translation
  33818. * @returns The transform node
  33819. */
  33820. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33821. /**
  33822. * Sets the absolute position of the mesh
  33823. * @param absolutePosition The absolute position of the mesh
  33824. * @returns The transform node
  33825. */
  33826. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33827. /**
  33828. * Gets the class name of the mesh
  33829. * @returns The class name
  33830. */
  33831. getClassName(): string;
  33832. }
  33833. /**
  33834. * Represents a physics imposter
  33835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33836. */
  33837. class PhysicsImpostor {
  33838. /**
  33839. * The physics-enabled object used as the physics imposter
  33840. */
  33841. object: IPhysicsEnabledObject;
  33842. /**
  33843. * The type of the physics imposter
  33844. */
  33845. type: number;
  33846. private _options;
  33847. private _scene?;
  33848. /**
  33849. * The default object size of the imposter
  33850. */
  33851. static DEFAULT_OBJECT_SIZE: Vector3;
  33852. /**
  33853. * The identity quaternion of the imposter
  33854. */
  33855. static IDENTITY_QUATERNION: Quaternion;
  33856. /** @hidden */
  33857. _pluginData: any;
  33858. private _physicsEngine;
  33859. private _physicsBody;
  33860. private _bodyUpdateRequired;
  33861. private _onBeforePhysicsStepCallbacks;
  33862. private _onAfterPhysicsStepCallbacks;
  33863. /** @hidden */
  33864. _onPhysicsCollideCallbacks: Array<{
  33865. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33866. otherImpostors: Array<PhysicsImpostor>;
  33867. }>;
  33868. private _deltaPosition;
  33869. private _deltaRotation;
  33870. private _deltaRotationConjugated;
  33871. private _parent;
  33872. private _isDisposed;
  33873. private static _tmpVecs;
  33874. private static _tmpQuat;
  33875. /**
  33876. * Specifies if the physics imposter is disposed
  33877. */
  33878. readonly isDisposed: boolean;
  33879. /**
  33880. * Gets the mass of the physics imposter
  33881. */
  33882. mass: number;
  33883. /**
  33884. * Gets the coefficient of friction
  33885. */
  33886. /**
  33887. * Sets the coefficient of friction
  33888. */
  33889. friction: number;
  33890. /**
  33891. * Gets the coefficient of restitution
  33892. */
  33893. /**
  33894. * Sets the coefficient of restitution
  33895. */
  33896. restitution: number;
  33897. /**
  33898. * The unique id of the physics imposter
  33899. * set by the physics engine when adding this impostor to the array
  33900. */
  33901. uniqueId: number;
  33902. private _joints;
  33903. /**
  33904. * Initializes the physics imposter
  33905. * @param object The physics-enabled object used as the physics imposter
  33906. * @param type The type of the physics imposter
  33907. * @param _options The options for the physics imposter
  33908. * @param _scene The Babylon scene
  33909. */
  33910. constructor(
  33911. /**
  33912. * The physics-enabled object used as the physics imposter
  33913. */
  33914. object: IPhysicsEnabledObject,
  33915. /**
  33916. * The type of the physics imposter
  33917. */
  33918. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33919. /**
  33920. * This function will completly initialize this impostor.
  33921. * It will create a new body - but only if this mesh has no parent.
  33922. * If it has, this impostor will not be used other than to define the impostor
  33923. * of the child mesh.
  33924. * @hidden
  33925. */
  33926. _init(): void;
  33927. private _getPhysicsParent;
  33928. /**
  33929. * Should a new body be generated.
  33930. * @returns boolean specifying if body initialization is required
  33931. */
  33932. isBodyInitRequired(): boolean;
  33933. /**
  33934. * Sets the updated scaling
  33935. * @param updated Specifies if the scaling is updated
  33936. */
  33937. setScalingUpdated(updated: boolean): void;
  33938. /**
  33939. * Force a regeneration of this or the parent's impostor's body.
  33940. * Use under cautious - This will remove all joints already implemented.
  33941. */
  33942. forceUpdate(): void;
  33943. /**
  33944. * Gets the body that holds this impostor. Either its own, or its parent.
  33945. */
  33946. /**
  33947. * Set the physics body. Used mainly by the physics engine/plugin
  33948. */
  33949. physicsBody: any;
  33950. /**
  33951. * Get the parent of the physics imposter
  33952. * @returns Physics imposter or null
  33953. */
  33954. /**
  33955. * Sets the parent of the physics imposter
  33956. */
  33957. parent: Nullable<PhysicsImpostor>;
  33958. /**
  33959. * Resets the update flags
  33960. */
  33961. resetUpdateFlags(): void;
  33962. /**
  33963. * Gets the object extend size
  33964. * @returns the object extend size
  33965. */
  33966. getObjectExtendSize(): Vector3;
  33967. /**
  33968. * Gets the object center
  33969. * @returns The object center
  33970. */
  33971. getObjectCenter(): Vector3;
  33972. /**
  33973. * Get a specific parametes from the options parameter
  33974. * @param paramName The object parameter name
  33975. * @returns The object parameter
  33976. */
  33977. getParam(paramName: string): any;
  33978. /**
  33979. * Sets a specific parameter in the options given to the physics plugin
  33980. * @param paramName The parameter name
  33981. * @param value The value of the parameter
  33982. */
  33983. setParam(paramName: string, value: number): void;
  33984. /**
  33985. * Specifically change the body's mass option. Won't recreate the physics body object
  33986. * @param mass The mass of the physics imposter
  33987. */
  33988. setMass(mass: number): void;
  33989. /**
  33990. * Gets the linear velocity
  33991. * @returns linear velocity or null
  33992. */
  33993. getLinearVelocity(): Nullable<Vector3>;
  33994. /**
  33995. * Sets the linear velocity
  33996. * @param velocity linear velocity or null
  33997. */
  33998. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33999. /**
  34000. * Gets the angular velocity
  34001. * @returns angular velocity or null
  34002. */
  34003. getAngularVelocity(): Nullable<Vector3>;
  34004. /**
  34005. * Sets the angular velocity
  34006. * @param velocity The velocity or null
  34007. */
  34008. setAngularVelocity(velocity: Nullable<Vector3>): void;
  34009. /**
  34010. * Execute a function with the physics plugin native code
  34011. * Provide a function the will have two variables - the world object and the physics body object
  34012. * @param func The function to execute with the physics plugin native code
  34013. */
  34014. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  34015. /**
  34016. * Register a function that will be executed before the physics world is stepping forward
  34017. * @param func The function to execute before the physics world is stepped forward
  34018. */
  34019. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34020. /**
  34021. * Unregister a function that will be executed before the physics world is stepping forward
  34022. * @param func The function to execute before the physics world is stepped forward
  34023. */
  34024. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34025. /**
  34026. * Register a function that will be executed after the physics step
  34027. * @param func The function to execute after physics step
  34028. */
  34029. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34030. /**
  34031. * Unregisters a function that will be executed after the physics step
  34032. * @param func The function to execute after physics step
  34033. */
  34034. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34035. /**
  34036. * register a function that will be executed when this impostor collides against a different body
  34037. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34038. * @param func Callback that is executed on collision
  34039. */
  34040. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34041. /**
  34042. * Unregisters the physics imposter on contact
  34043. * @param collideAgainst The physics object to collide against
  34044. * @param func Callback to execute on collision
  34045. */
  34046. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34047. private _tmpQuat;
  34048. private _tmpQuat2;
  34049. /**
  34050. * Get the parent rotation
  34051. * @returns The parent rotation
  34052. */
  34053. getParentsRotation(): Quaternion;
  34054. /**
  34055. * this function is executed by the physics engine.
  34056. */
  34057. beforeStep: () => void;
  34058. /**
  34059. * this function is executed by the physics engine
  34060. */
  34061. afterStep: () => void;
  34062. /**
  34063. * Legacy collision detection event support
  34064. */
  34065. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34066. /**
  34067. * event and body object due to cannon's event-based architecture.
  34068. */
  34069. onCollide: (e: {
  34070. body: any;
  34071. }) => void;
  34072. /**
  34073. * Apply a force
  34074. * @param force The force to apply
  34075. * @param contactPoint The contact point for the force
  34076. * @returns The physics imposter
  34077. */
  34078. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34079. /**
  34080. * Apply an impulse
  34081. * @param force The impulse force
  34082. * @param contactPoint The contact point for the impulse force
  34083. * @returns The physics imposter
  34084. */
  34085. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34086. /**
  34087. * A help function to create a joint
  34088. * @param otherImpostor A physics imposter used to create a joint
  34089. * @param jointType The type of joint
  34090. * @param jointData The data for the joint
  34091. * @returns The physics imposter
  34092. */
  34093. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34094. /**
  34095. * Add a joint to this impostor with a different impostor
  34096. * @param otherImpostor A physics imposter used to add a joint
  34097. * @param joint The joint to add
  34098. * @returns The physics imposter
  34099. */
  34100. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34101. /**
  34102. * Will keep this body still, in a sleep mode.
  34103. * @returns the physics imposter
  34104. */
  34105. sleep(): PhysicsImpostor;
  34106. /**
  34107. * Wake the body up.
  34108. * @returns The physics imposter
  34109. */
  34110. wakeUp(): PhysicsImpostor;
  34111. /**
  34112. * Clones the physics imposter
  34113. * @param newObject The physics imposter clones to this physics-enabled object
  34114. * @returns A nullable physics imposter
  34115. */
  34116. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34117. /**
  34118. * Disposes the physics imposter
  34119. */
  34120. dispose(): void;
  34121. /**
  34122. * Sets the delta position
  34123. * @param position The delta position amount
  34124. */
  34125. setDeltaPosition(position: Vector3): void;
  34126. /**
  34127. * Sets the delta rotation
  34128. * @param rotation The delta rotation amount
  34129. */
  34130. setDeltaRotation(rotation: Quaternion): void;
  34131. /**
  34132. * Gets the box size of the physics imposter and stores the result in the input parameter
  34133. * @param result Stores the box size
  34134. * @returns The physics imposter
  34135. */
  34136. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34137. /**
  34138. * Gets the radius of the physics imposter
  34139. * @returns Radius of the physics imposter
  34140. */
  34141. getRadius(): number;
  34142. /**
  34143. * Sync a bone with this impostor
  34144. * @param bone The bone to sync to the impostor.
  34145. * @param boneMesh The mesh that the bone is influencing.
  34146. * @param jointPivot The pivot of the joint / bone in local space.
  34147. * @param distToJoint Optional distance from the impostor to the joint.
  34148. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34149. */
  34150. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34151. /**
  34152. * Sync impostor to a bone
  34153. * @param bone The bone that the impostor will be synced to.
  34154. * @param boneMesh The mesh that the bone is influencing.
  34155. * @param jointPivot The pivot of the joint / bone in local space.
  34156. * @param distToJoint Optional distance from the impostor to the joint.
  34157. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34158. * @param boneAxis Optional vector3 axis the bone is aligned with
  34159. */
  34160. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34161. /**
  34162. * No-Imposter type
  34163. */
  34164. static NoImpostor: number;
  34165. /**
  34166. * Sphere-Imposter type
  34167. */
  34168. static SphereImpostor: number;
  34169. /**
  34170. * Box-Imposter type
  34171. */
  34172. static BoxImpostor: number;
  34173. /**
  34174. * Plane-Imposter type
  34175. */
  34176. static PlaneImpostor: number;
  34177. /**
  34178. * Mesh-imposter type
  34179. */
  34180. static MeshImpostor: number;
  34181. /**
  34182. * Cylinder-Imposter type
  34183. */
  34184. static CylinderImpostor: number;
  34185. /**
  34186. * Particle-Imposter type
  34187. */
  34188. static ParticleImpostor: number;
  34189. /**
  34190. * Heightmap-Imposter type
  34191. */
  34192. static HeightmapImpostor: number;
  34193. }
  34194. }
  34195. declare module BABYLON {
  34196. /**
  34197. * Interface for Physics-Joint data
  34198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34199. */
  34200. interface PhysicsJointData {
  34201. /**
  34202. * The main pivot of the joint
  34203. */
  34204. mainPivot?: Vector3;
  34205. /**
  34206. * The connected pivot of the joint
  34207. */
  34208. connectedPivot?: Vector3;
  34209. /**
  34210. * The main axis of the joint
  34211. */
  34212. mainAxis?: Vector3;
  34213. /**
  34214. * The connected axis of the joint
  34215. */
  34216. connectedAxis?: Vector3;
  34217. /**
  34218. * The collision of the joint
  34219. */
  34220. collision?: boolean;
  34221. /**
  34222. * Native Oimo/Cannon/Energy data
  34223. */
  34224. nativeParams?: any;
  34225. }
  34226. /**
  34227. * This is a holder class for the physics joint created by the physics plugin
  34228. * It holds a set of functions to control the underlying joint
  34229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34230. */
  34231. class PhysicsJoint {
  34232. /**
  34233. * The type of the physics joint
  34234. */
  34235. type: number;
  34236. /**
  34237. * The data for the physics joint
  34238. */
  34239. jointData: PhysicsJointData;
  34240. private _physicsJoint;
  34241. protected _physicsPlugin: IPhysicsEnginePlugin;
  34242. /**
  34243. * Initializes the physics joint
  34244. * @param type The type of the physics joint
  34245. * @param jointData The data for the physics joint
  34246. */
  34247. constructor(
  34248. /**
  34249. * The type of the physics joint
  34250. */
  34251. type: number,
  34252. /**
  34253. * The data for the physics joint
  34254. */
  34255. jointData: PhysicsJointData);
  34256. /**
  34257. * Gets the physics joint
  34258. */
  34259. /**
  34260. * Sets the physics joint
  34261. */
  34262. physicsJoint: any;
  34263. /**
  34264. * Sets the physics plugin
  34265. */
  34266. physicsPlugin: IPhysicsEnginePlugin;
  34267. /**
  34268. * Execute a function that is physics-plugin specific.
  34269. * @param {Function} func the function that will be executed.
  34270. * It accepts two parameters: the physics world and the physics joint
  34271. */
  34272. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34273. /**
  34274. * Distance-Joint type
  34275. */
  34276. static DistanceJoint: number;
  34277. /**
  34278. * Hinge-Joint type
  34279. */
  34280. static HingeJoint: number;
  34281. /**
  34282. * Ball-and-Socket joint type
  34283. */
  34284. static BallAndSocketJoint: number;
  34285. /**
  34286. * Wheel-Joint type
  34287. */
  34288. static WheelJoint: number;
  34289. /**
  34290. * Slider-Joint type
  34291. */
  34292. static SliderJoint: number;
  34293. /**
  34294. * Prismatic-Joint type
  34295. */
  34296. static PrismaticJoint: number;
  34297. /**
  34298. * Universal-Joint type
  34299. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34300. */
  34301. static UniversalJoint: number;
  34302. /**
  34303. * Hinge-Joint 2 type
  34304. */
  34305. static Hinge2Joint: number;
  34306. /**
  34307. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34308. */
  34309. static PointToPointJoint: number;
  34310. /**
  34311. * Spring-Joint type
  34312. */
  34313. static SpringJoint: number;
  34314. /**
  34315. * Lock-Joint type
  34316. */
  34317. static LockJoint: number;
  34318. }
  34319. /**
  34320. * A class representing a physics distance joint
  34321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34322. */
  34323. class DistanceJoint extends PhysicsJoint {
  34324. /**
  34325. *
  34326. * @param jointData The data for the Distance-Joint
  34327. */
  34328. constructor(jointData: DistanceJointData);
  34329. /**
  34330. * Update the predefined distance.
  34331. * @param maxDistance The maximum preferred distance
  34332. * @param minDistance The minimum preferred distance
  34333. */
  34334. updateDistance(maxDistance: number, minDistance?: number): void;
  34335. }
  34336. /**
  34337. * Represents a Motor-Enabled Joint
  34338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34339. */
  34340. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34341. /**
  34342. * Initializes the Motor-Enabled Joint
  34343. * @param type The type of the joint
  34344. * @param jointData The physica joint data for the joint
  34345. */
  34346. constructor(type: number, jointData: PhysicsJointData);
  34347. /**
  34348. * Set the motor values.
  34349. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34350. * @param force the force to apply
  34351. * @param maxForce max force for this motor.
  34352. */
  34353. setMotor(force?: number, maxForce?: number): void;
  34354. /**
  34355. * Set the motor's limits.
  34356. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34357. * @param upperLimit The upper limit of the motor
  34358. * @param lowerLimit The lower limit of the motor
  34359. */
  34360. setLimit(upperLimit: number, lowerLimit?: number): void;
  34361. }
  34362. /**
  34363. * This class represents a single physics Hinge-Joint
  34364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34365. */
  34366. class HingeJoint extends MotorEnabledJoint {
  34367. /**
  34368. * Initializes the Hinge-Joint
  34369. * @param jointData The joint data for the Hinge-Joint
  34370. */
  34371. constructor(jointData: PhysicsJointData);
  34372. /**
  34373. * Set the motor values.
  34374. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34375. * @param {number} force the force to apply
  34376. * @param {number} maxForce max force for this motor.
  34377. */
  34378. setMotor(force?: number, maxForce?: number): void;
  34379. /**
  34380. * Set the motor's limits.
  34381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34382. * @param upperLimit The upper limit of the motor
  34383. * @param lowerLimit The lower limit of the motor
  34384. */
  34385. setLimit(upperLimit: number, lowerLimit?: number): void;
  34386. }
  34387. /**
  34388. * This class represents a dual hinge physics joint (same as wheel joint)
  34389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34390. */
  34391. class Hinge2Joint extends MotorEnabledJoint {
  34392. /**
  34393. * Initializes the Hinge2-Joint
  34394. * @param jointData The joint data for the Hinge2-Joint
  34395. */
  34396. constructor(jointData: PhysicsJointData);
  34397. /**
  34398. * Set the motor values.
  34399. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34400. * @param {number} force the force to apply
  34401. * @param {number} maxForce max force for this motor.
  34402. * @param {motorIndex} the motor's index, 0 or 1.
  34403. */
  34404. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34405. /**
  34406. * Set the motor limits.
  34407. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34408. * @param {number} upperLimit the upper limit
  34409. * @param {number} lowerLimit lower limit
  34410. * @param {motorIndex} the motor's index, 0 or 1.
  34411. */
  34412. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34413. }
  34414. /**
  34415. * Interface for a motor enabled joint
  34416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34417. */
  34418. interface IMotorEnabledJoint {
  34419. /**
  34420. * Physics joint
  34421. */
  34422. physicsJoint: any;
  34423. /**
  34424. * Sets the motor of the motor-enabled joint
  34425. * @param force The force of the motor
  34426. * @param maxForce The maximum force of the motor
  34427. * @param motorIndex The index of the motor
  34428. */
  34429. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34430. /**
  34431. * Sets the limit of the motor
  34432. * @param upperLimit The upper limit of the motor
  34433. * @param lowerLimit The lower limit of the motor
  34434. * @param motorIndex The index of the motor
  34435. */
  34436. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34437. }
  34438. /**
  34439. * Joint data for a Distance-Joint
  34440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34441. */
  34442. interface DistanceJointData extends PhysicsJointData {
  34443. /**
  34444. * Max distance the 2 joint objects can be apart
  34445. */
  34446. maxDistance: number;
  34447. }
  34448. /**
  34449. * Joint data from a spring joint
  34450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34451. */
  34452. interface SpringJointData extends PhysicsJointData {
  34453. /**
  34454. * Length of the spring
  34455. */
  34456. length: number;
  34457. /**
  34458. * Stiffness of the spring
  34459. */
  34460. stiffness: number;
  34461. /**
  34462. * Damping of the spring
  34463. */
  34464. damping: number;
  34465. /** this callback will be called when applying the force to the impostors. */
  34466. forceApplicationCallback: () => void;
  34467. }
  34468. }
  34469. declare module BABYLON {
  34470. interface AbstractScene {
  34471. /**
  34472. * The list of reflection probes added to the scene
  34473. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34474. */
  34475. reflectionProbes: Array<ReflectionProbe>;
  34476. /**
  34477. * Removes the given reflection probe from this scene.
  34478. * @param toRemove The reflection probe to remove
  34479. * @returns The index of the removed reflection probe
  34480. */
  34481. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34482. /**
  34483. * Adds the given reflection probe to this scene.
  34484. * @param newReflectionProbe The reflection probe to add
  34485. */
  34486. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34487. }
  34488. /**
  34489. * Class used to generate realtime reflection / refraction cube textures
  34490. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34491. */
  34492. class ReflectionProbe {
  34493. /** defines the name of the probe */
  34494. name: string;
  34495. private _scene;
  34496. private _renderTargetTexture;
  34497. private _projectionMatrix;
  34498. private _viewMatrix;
  34499. private _target;
  34500. private _add;
  34501. private _attachedMesh;
  34502. private _invertYAxis;
  34503. /** Gets or sets probe position (center of the cube map) */
  34504. position: Vector3;
  34505. /**
  34506. * Creates a new reflection probe
  34507. * @param name defines the name of the probe
  34508. * @param size defines the texture resolution (for each face)
  34509. * @param scene defines the hosting scene
  34510. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34511. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34512. */
  34513. constructor(
  34514. /** defines the name of the probe */
  34515. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34516. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34517. samples: number;
  34518. /** Gets or sets the refresh rate to use (on every frame by default) */
  34519. refreshRate: number;
  34520. /**
  34521. * Gets the hosting scene
  34522. * @returns a Scene
  34523. */
  34524. getScene(): Scene;
  34525. /** Gets the internal CubeTexture used to render to */
  34526. readonly cubeTexture: RenderTargetTexture;
  34527. /** Gets the list of meshes to render */
  34528. readonly renderList: Nullable<AbstractMesh[]>;
  34529. /**
  34530. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34531. * @param mesh defines the mesh to attach to
  34532. */
  34533. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34534. /**
  34535. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34536. * @param renderingGroupId The rendering group id corresponding to its index
  34537. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34538. */
  34539. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34540. /**
  34541. * Clean all associated resources
  34542. */
  34543. dispose(): void;
  34544. /**
  34545. * Converts the reflection probe information to a readable string for debug purpose.
  34546. * @param fullDetails Supports for multiple levels of logging within scene loading
  34547. * @returns the human readable reflection probe info
  34548. */
  34549. toString(fullDetails?: boolean): string;
  34550. /**
  34551. * Get the class name of the relfection probe.
  34552. * @returns "ReflectionProbe"
  34553. */
  34554. getClassName(): string;
  34555. /**
  34556. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34557. * @returns The JSON representation of the texture
  34558. */
  34559. serialize(): any;
  34560. /**
  34561. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34562. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34563. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34564. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34565. * @returns The parsed reflection probe if successful
  34566. */
  34567. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34568. }
  34569. }
  34570. declare module BABYLON {
  34571. /**
  34572. * Postprocess used to generate anaglyphic rendering
  34573. */
  34574. class AnaglyphPostProcess extends PostProcess {
  34575. private _passedProcess;
  34576. /**
  34577. * Creates a new AnaglyphPostProcess
  34578. * @param name defines postprocess name
  34579. * @param options defines creation options or target ratio scale
  34580. * @param rigCameras defines cameras using this postprocess
  34581. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34582. * @param engine defines hosting engine
  34583. * @param reusable defines if the postprocess will be reused multiple times per frame
  34584. */
  34585. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34586. }
  34587. }
  34588. declare module BABYLON {
  34589. /**
  34590. * Post process used to render in black and white
  34591. */
  34592. class BlackAndWhitePostProcess extends PostProcess {
  34593. /**
  34594. * Linear about to convert he result to black and white (default: 1)
  34595. */
  34596. degree: number;
  34597. /**
  34598. * Creates a black and white post process
  34599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34600. * @param name The name of the effect.
  34601. * @param options The required width/height ratio to downsize to before computing the render pass.
  34602. * @param camera The camera to apply the render pass to.
  34603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34604. * @param engine The engine which the post process will be applied. (default: current engine)
  34605. * @param reusable If the post process can be reused on the same frame. (default: false)
  34606. */
  34607. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34608. }
  34609. }
  34610. declare module BABYLON {
  34611. /**
  34612. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34613. */
  34614. class BloomEffect extends PostProcessRenderEffect {
  34615. private bloomScale;
  34616. /**
  34617. * @hidden Internal
  34618. */
  34619. _effects: Array<PostProcess>;
  34620. /**
  34621. * @hidden Internal
  34622. */
  34623. _downscale: ExtractHighlightsPostProcess;
  34624. private _blurX;
  34625. private _blurY;
  34626. private _merge;
  34627. /**
  34628. * The luminance threshold to find bright areas of the image to bloom.
  34629. */
  34630. threshold: number;
  34631. /**
  34632. * The strength of the bloom.
  34633. */
  34634. weight: number;
  34635. /**
  34636. * Specifies the size of the bloom blur kernel, relative to the final output size
  34637. */
  34638. kernel: number;
  34639. /**
  34640. * Creates a new instance of @see BloomEffect
  34641. * @param scene The scene the effect belongs to.
  34642. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34643. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34644. * @param bloomWeight The the strength of bloom.
  34645. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34646. * @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)
  34647. */
  34648. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34649. /**
  34650. * Disposes each of the internal effects for a given camera.
  34651. * @param camera The camera to dispose the effect on.
  34652. */
  34653. disposeEffects(camera: Camera): void;
  34654. /**
  34655. * @hidden Internal
  34656. */
  34657. _updateEffects(): void;
  34658. /**
  34659. * Internal
  34660. * @returns if all the contained post processes are ready.
  34661. * @hidden
  34662. */
  34663. _isReady(): boolean;
  34664. }
  34665. }
  34666. declare module BABYLON {
  34667. /**
  34668. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34669. */
  34670. class BloomMergePostProcess extends PostProcess {
  34671. /** Weight of the bloom to be added to the original input. */
  34672. weight: number;
  34673. /**
  34674. * Creates a new instance of @see BloomMergePostProcess
  34675. * @param name The name of the effect.
  34676. * @param originalFromInput Post process which's input will be used for the merge.
  34677. * @param blurred Blurred highlights post process which's output will be used.
  34678. * @param weight Weight of the bloom to be added to the original input.
  34679. * @param options The required width/height ratio to downsize to before computing the render pass.
  34680. * @param camera The camera to apply the render pass to.
  34681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34682. * @param engine The engine which the post process will be applied. (default: current engine)
  34683. * @param reusable If the post process can be reused on the same frame. (default: false)
  34684. * @param textureType Type of textures used when performing the post process. (default: 0)
  34685. * @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)
  34686. */
  34687. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34688. /** Weight of the bloom to be added to the original input. */
  34689. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34690. }
  34691. }
  34692. declare module BABYLON {
  34693. /**
  34694. * The Blur Post Process which blurs an image based on a kernel and direction.
  34695. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34696. */
  34697. class BlurPostProcess extends PostProcess {
  34698. /** The direction in which to blur the image. */
  34699. direction: Vector2;
  34700. private blockCompilation;
  34701. protected _kernel: number;
  34702. protected _idealKernel: number;
  34703. protected _packedFloat: boolean;
  34704. private _staticDefines;
  34705. /**
  34706. * Sets the length in pixels of the blur sample region
  34707. */
  34708. /**
  34709. * Gets the length in pixels of the blur sample region
  34710. */
  34711. kernel: number;
  34712. /**
  34713. * Sets wether or not the blur needs to unpack/repack floats
  34714. */
  34715. /**
  34716. * Gets wether or not the blur is unpacking/repacking floats
  34717. */
  34718. packedFloat: boolean;
  34719. /**
  34720. * Creates a new instance BlurPostProcess
  34721. * @param name The name of the effect.
  34722. * @param direction The direction in which to blur the image.
  34723. * @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.
  34724. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34725. * @param camera The camera to apply the render pass to.
  34726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34727. * @param engine The engine which the post process will be applied. (default: current engine)
  34728. * @param reusable If the post process can be reused on the same frame. (default: false)
  34729. * @param textureType Type of textures used when performing the post process. (default: 0)
  34730. * @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)
  34731. */
  34732. constructor(name: string,
  34733. /** The direction in which to blur the image. */
  34734. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34735. /**
  34736. * Updates the effect with the current post process compile time values and recompiles the shader.
  34737. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34738. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34739. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34740. * @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
  34741. * @param onCompiled Called when the shader has been compiled.
  34742. * @param onError Called if there is an error when compiling a shader.
  34743. */
  34744. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34745. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34746. /**
  34747. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34748. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34749. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34750. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34751. * The gaps between physical kernels are compensated for in the weighting of the samples
  34752. * @param idealKernel Ideal blur kernel.
  34753. * @return Nearest best kernel.
  34754. */
  34755. protected _nearestBestKernel(idealKernel: number): number;
  34756. /**
  34757. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34758. * @param x The point on the Gaussian distribution to sample.
  34759. * @return the value of the Gaussian function at x.
  34760. */
  34761. protected _gaussianWeight(x: number): number;
  34762. /**
  34763. * Generates a string that can be used as a floating point number in GLSL.
  34764. * @param x Value to print.
  34765. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34766. * @return GLSL float string.
  34767. */
  34768. protected _glslFloat(x: number, decimalFigures?: number): string;
  34769. }
  34770. }
  34771. declare module BABYLON {
  34772. /**
  34773. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34774. */
  34775. class ChromaticAberrationPostProcess extends PostProcess {
  34776. /**
  34777. * The amount of seperation of rgb channels (default: 30)
  34778. */
  34779. aberrationAmount: number;
  34780. /**
  34781. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34782. */
  34783. radialIntensity: number;
  34784. /**
  34785. * 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))
  34786. */
  34787. direction: Vector2;
  34788. /**
  34789. * 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))
  34790. */
  34791. centerPosition: Vector2;
  34792. /**
  34793. * Creates a new instance ChromaticAberrationPostProcess
  34794. * @param name The name of the effect.
  34795. * @param screenWidth The width of the screen to apply the effect on.
  34796. * @param screenHeight The height of the screen to apply the effect on.
  34797. * @param options The required width/height ratio to downsize to before computing the render pass.
  34798. * @param camera The camera to apply the render pass to.
  34799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34800. * @param engine The engine which the post process will be applied. (default: current engine)
  34801. * @param reusable If the post process can be reused on the same frame. (default: false)
  34802. * @param textureType Type of textures used when performing the post process. (default: 0)
  34803. * @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)
  34804. */
  34805. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34806. }
  34807. }
  34808. declare module BABYLON {
  34809. /**
  34810. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34811. */
  34812. class CircleOfConfusionPostProcess extends PostProcess {
  34813. /**
  34814. * 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.
  34815. */
  34816. lensSize: number;
  34817. /**
  34818. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34819. */
  34820. fStop: number;
  34821. /**
  34822. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34823. */
  34824. focusDistance: number;
  34825. /**
  34826. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34827. */
  34828. focalLength: number;
  34829. private _depthTexture;
  34830. /**
  34831. * Creates a new instance CircleOfConfusionPostProcess
  34832. * @param name The name of the effect.
  34833. * @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.
  34834. * @param options The required width/height ratio to downsize to before computing the render pass.
  34835. * @param camera The camera to apply the render pass to.
  34836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34837. * @param engine The engine which the post process will be applied. (default: current engine)
  34838. * @param reusable If the post process can be reused on the same frame. (default: false)
  34839. * @param textureType Type of textures used when performing the post process. (default: 0)
  34840. * @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)
  34841. */
  34842. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34843. /**
  34844. * 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.
  34845. */
  34846. depthTexture: RenderTargetTexture;
  34847. }
  34848. }
  34849. declare module BABYLON {
  34850. /**
  34851. *
  34852. * This post-process allows the modification of rendered colors by using
  34853. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34854. *
  34855. * The object needs to be provided an url to a texture containing the color
  34856. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34857. * Use an image editing software to tweak the LUT to match your needs.
  34858. *
  34859. * For an example of a color LUT, see here:
  34860. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34861. * For explanations on color grading, see here:
  34862. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34863. *
  34864. */
  34865. class ColorCorrectionPostProcess extends PostProcess {
  34866. private _colorTableTexture;
  34867. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34868. }
  34869. }
  34870. declare module BABYLON {
  34871. /**
  34872. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34873. * input texture to perform effects such as edge detection or sharpening
  34874. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34875. */
  34876. class ConvolutionPostProcess extends PostProcess {
  34877. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34878. kernel: number[];
  34879. /**
  34880. * Creates a new instance ConvolutionPostProcess
  34881. * @param name The name of the effect.
  34882. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34883. * @param options The required width/height ratio to downsize to before computing the render pass.
  34884. * @param camera The camera to apply the render pass to.
  34885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34886. * @param engine The engine which the post process will be applied. (default: current engine)
  34887. * @param reusable If the post process can be reused on the same frame. (default: false)
  34888. * @param textureType Type of textures used when performing the post process. (default: 0)
  34889. */
  34890. constructor(name: string,
  34891. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34892. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34893. /**
  34894. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34895. */
  34896. static EdgeDetect0Kernel: number[];
  34897. /**
  34898. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34899. */
  34900. static EdgeDetect1Kernel: number[];
  34901. /**
  34902. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34903. */
  34904. static EdgeDetect2Kernel: number[];
  34905. /**
  34906. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34907. */
  34908. static SharpenKernel: number[];
  34909. /**
  34910. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34911. */
  34912. static EmbossKernel: number[];
  34913. /**
  34914. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34915. */
  34916. static GaussianKernel: number[];
  34917. }
  34918. }
  34919. declare module BABYLON {
  34920. /**
  34921. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34922. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34923. * based on samples that have a large difference in distance than the center pixel.
  34924. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34925. */
  34926. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34927. direction: Vector2;
  34928. /**
  34929. * Creates a new instance CircleOfConfusionPostProcess
  34930. * @param name The name of the effect.
  34931. * @param scene The scene the effect belongs to.
  34932. * @param direction The direction the blur should be applied.
  34933. * @param kernel The size of the kernel used to blur.
  34934. * @param options The required width/height ratio to downsize to before computing the render pass.
  34935. * @param camera The camera to apply the render pass to.
  34936. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34937. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34939. * @param engine The engine which the post process will be applied. (default: current engine)
  34940. * @param reusable If the post process can be reused on the same frame. (default: false)
  34941. * @param textureType Type of textures used when performing the post process. (default: 0)
  34942. * @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)
  34943. */
  34944. 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);
  34945. }
  34946. }
  34947. declare module BABYLON {
  34948. /**
  34949. * Specifies the level of max blur that should be applied when using the depth of field effect
  34950. */
  34951. enum DepthOfFieldEffectBlurLevel {
  34952. /**
  34953. * Subtle blur
  34954. */
  34955. Low = 0,
  34956. /**
  34957. * Medium blur
  34958. */
  34959. Medium = 1,
  34960. /**
  34961. * Large blur
  34962. */
  34963. High = 2
  34964. }
  34965. /**
  34966. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34967. */
  34968. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34969. private _circleOfConfusion;
  34970. /**
  34971. * @hidden Internal, blurs from high to low
  34972. */
  34973. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34974. private _depthOfFieldBlurY;
  34975. private _dofMerge;
  34976. /**
  34977. * @hidden Internal post processes in depth of field effect
  34978. */
  34979. _effects: Array<PostProcess>;
  34980. /**
  34981. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34982. */
  34983. focalLength: number;
  34984. /**
  34985. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34986. */
  34987. fStop: number;
  34988. /**
  34989. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34990. */
  34991. focusDistance: number;
  34992. /**
  34993. * 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.
  34994. */
  34995. lensSize: number;
  34996. /**
  34997. * Creates a new instance DepthOfFieldEffect
  34998. * @param scene The scene the effect belongs to.
  34999. * @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.
  35000. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35001. * @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)
  35002. */
  35003. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35004. /**
  35005. * 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.
  35006. */
  35007. depthTexture: RenderTargetTexture;
  35008. /**
  35009. * Disposes each of the internal effects for a given camera.
  35010. * @param camera The camera to dispose the effect on.
  35011. */
  35012. disposeEffects(camera: Camera): void;
  35013. /**
  35014. * @hidden Internal
  35015. */
  35016. _updateEffects(): void;
  35017. /**
  35018. * Internal
  35019. * @returns if all the contained post processes are ready.
  35020. * @hidden
  35021. */
  35022. _isReady(): boolean;
  35023. }
  35024. }
  35025. declare module BABYLON {
  35026. /**
  35027. * Options to be set when merging outputs from the default pipeline.
  35028. */
  35029. class DepthOfFieldMergePostProcessOptions {
  35030. /**
  35031. * The original image to merge on top of
  35032. */
  35033. originalFromInput: PostProcess;
  35034. /**
  35035. * Parameters to perform the merge of the depth of field effect
  35036. */
  35037. depthOfField?: {
  35038. circleOfConfusion: PostProcess;
  35039. blurSteps: Array<PostProcess>;
  35040. };
  35041. /**
  35042. * Parameters to perform the merge of bloom effect
  35043. */
  35044. bloom?: {
  35045. blurred: PostProcess;
  35046. weight: number;
  35047. };
  35048. }
  35049. /**
  35050. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35051. */
  35052. class DepthOfFieldMergePostProcess extends PostProcess {
  35053. private blurSteps;
  35054. /**
  35055. * Creates a new instance of DepthOfFieldMergePostProcess
  35056. * @param name The name of the effect.
  35057. * @param originalFromInput Post process which's input will be used for the merge.
  35058. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35059. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35060. * @param options The required width/height ratio to downsize to before computing the render pass.
  35061. * @param camera The camera to apply the render pass to.
  35062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35063. * @param engine The engine which the post process will be applied. (default: current engine)
  35064. * @param reusable If the post process can be reused on the same frame. (default: false)
  35065. * @param textureType Type of textures used when performing the post process. (default: 0)
  35066. * @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)
  35067. */
  35068. 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);
  35069. /**
  35070. * Updates the effect with the current post process compile time values and recompiles the shader.
  35071. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35072. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35073. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35074. * @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
  35075. * @param onCompiled Called when the shader has been compiled.
  35076. * @param onError Called if there is an error when compiling a shader.
  35077. */
  35078. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35079. }
  35080. }
  35081. declare module BABYLON {
  35082. /**
  35083. * DisplayPassPostProcess which produces an output the same as it's input
  35084. */
  35085. class DisplayPassPostProcess extends PostProcess {
  35086. /**
  35087. * Creates the DisplayPassPostProcess
  35088. * @param name The name of the effect.
  35089. * @param options The required width/height ratio to downsize to before computing the render pass.
  35090. * @param camera The camera to apply the render pass to.
  35091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35092. * @param engine The engine which the post process will be applied. (default: current engine)
  35093. * @param reusable If the post process can be reused on the same frame. (default: false)
  35094. */
  35095. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35096. }
  35097. }
  35098. declare module BABYLON {
  35099. /**
  35100. * 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.
  35101. */
  35102. class ExtractHighlightsPostProcess extends PostProcess {
  35103. /**
  35104. * The luminance threshold, pixels below this value will be set to black.
  35105. */
  35106. threshold: number;
  35107. /** @hidden */
  35108. _exposure: number;
  35109. /**
  35110. * Post process which has the input texture to be used when performing highlight extraction
  35111. * @hidden
  35112. */
  35113. _inputPostProcess: Nullable<PostProcess>;
  35114. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35115. }
  35116. }
  35117. declare module BABYLON {
  35118. /**
  35119. * Applies a kernel filter to the image
  35120. */
  35121. class FilterPostProcess extends PostProcess {
  35122. /** The matrix to be applied to the image */
  35123. kernelMatrix: Matrix;
  35124. /**
  35125. *
  35126. * @param name The name of the effect.
  35127. * @param kernelMatrix The matrix to be applied to the image
  35128. * @param options The required width/height ratio to downsize to before computing the render pass.
  35129. * @param camera The camera to apply the render pass to.
  35130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35131. * @param engine The engine which the post process will be applied. (default: current engine)
  35132. * @param reusable If the post process can be reused on the same frame. (default: false)
  35133. */
  35134. constructor(name: string,
  35135. /** The matrix to be applied to the image */
  35136. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35137. }
  35138. }
  35139. declare module BABYLON {
  35140. /**
  35141. * Fxaa post process
  35142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35143. */
  35144. class FxaaPostProcess extends PostProcess {
  35145. /** @hidden */
  35146. texelWidth: number;
  35147. /** @hidden */
  35148. texelHeight: number;
  35149. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35150. private _getDefines;
  35151. }
  35152. }
  35153. declare module BABYLON {
  35154. /**
  35155. * The GrainPostProcess adds noise to the image at mid luminance levels
  35156. */
  35157. class GrainPostProcess extends PostProcess {
  35158. /**
  35159. * The intensity of the grain added (default: 30)
  35160. */
  35161. intensity: number;
  35162. /**
  35163. * If the grain should be randomized on every frame
  35164. */
  35165. animated: boolean;
  35166. /**
  35167. * Creates a new instance of @see GrainPostProcess
  35168. * @param name The name of the effect.
  35169. * @param options The required width/height ratio to downsize to before computing the render pass.
  35170. * @param camera The camera to apply the render pass to.
  35171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35172. * @param engine The engine which the post process will be applied. (default: current engine)
  35173. * @param reusable If the post process can be reused on the same frame. (default: false)
  35174. * @param textureType Type of textures used when performing the post process. (default: 0)
  35175. * @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)
  35176. */
  35177. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35178. }
  35179. }
  35180. declare module BABYLON {
  35181. /**
  35182. * Extracts highlights from the image
  35183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35184. */
  35185. class HighlightsPostProcess extends PostProcess {
  35186. /**
  35187. * Extracts highlights from the image
  35188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35189. * @param name The name of the effect.
  35190. * @param options The required width/height ratio to downsize to before computing the render pass.
  35191. * @param camera The camera to apply the render pass to.
  35192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35193. * @param engine The engine which the post process will be applied. (default: current engine)
  35194. * @param reusable If the post process can be reused on the same frame. (default: false)
  35195. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35196. */
  35197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35198. }
  35199. }
  35200. declare module BABYLON {
  35201. /**
  35202. * ImageProcessingPostProcess
  35203. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35204. */
  35205. class ImageProcessingPostProcess extends PostProcess {
  35206. /**
  35207. * Default configuration related to image processing available in the PBR Material.
  35208. */
  35209. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35210. /**
  35211. * Gets the image processing configuration used either in this material.
  35212. */
  35213. /**
  35214. * Sets the Default image processing configuration used either in the this material.
  35215. *
  35216. * If sets to null, the scene one is in use.
  35217. */
  35218. imageProcessingConfiguration: ImageProcessingConfiguration;
  35219. /**
  35220. * Keep track of the image processing observer to allow dispose and replace.
  35221. */
  35222. private _imageProcessingObserver;
  35223. /**
  35224. * Attaches a new image processing configuration to the PBR Material.
  35225. * @param configuration
  35226. */
  35227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35228. /**
  35229. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35230. */
  35231. /**
  35232. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35233. */
  35234. colorCurves: Nullable<ColorCurves>;
  35235. /**
  35236. * Gets wether the color curves effect is enabled.
  35237. */
  35238. /**
  35239. * Sets wether the color curves effect is enabled.
  35240. */
  35241. colorCurvesEnabled: boolean;
  35242. /**
  35243. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35244. */
  35245. /**
  35246. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35247. */
  35248. colorGradingTexture: Nullable<BaseTexture>;
  35249. /**
  35250. * Gets wether the color grading effect is enabled.
  35251. */
  35252. /**
  35253. * Gets wether the color grading effect is enabled.
  35254. */
  35255. colorGradingEnabled: boolean;
  35256. /**
  35257. * Gets exposure used in the effect.
  35258. */
  35259. /**
  35260. * Sets exposure used in the effect.
  35261. */
  35262. exposure: number;
  35263. /**
  35264. * Gets wether tonemapping is enabled or not.
  35265. */
  35266. /**
  35267. * Sets wether tonemapping is enabled or not
  35268. */
  35269. toneMappingEnabled: boolean;
  35270. /**
  35271. * Gets contrast used in the effect.
  35272. */
  35273. /**
  35274. * Sets contrast used in the effect.
  35275. */
  35276. contrast: number;
  35277. /**
  35278. * Gets Vignette stretch size.
  35279. */
  35280. /**
  35281. * Sets Vignette stretch size.
  35282. */
  35283. vignetteStretch: number;
  35284. /**
  35285. * Gets Vignette centre X Offset.
  35286. */
  35287. /**
  35288. * Sets Vignette centre X Offset.
  35289. */
  35290. vignetteCentreX: number;
  35291. /**
  35292. * Gets Vignette centre Y Offset.
  35293. */
  35294. /**
  35295. * Sets Vignette centre Y Offset.
  35296. */
  35297. vignetteCentreY: number;
  35298. /**
  35299. * Gets Vignette weight or intensity of the vignette effect.
  35300. */
  35301. /**
  35302. * Sets Vignette weight or intensity of the vignette effect.
  35303. */
  35304. vignetteWeight: number;
  35305. /**
  35306. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35307. * if vignetteEnabled is set to true.
  35308. */
  35309. /**
  35310. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35311. * if vignetteEnabled is set to true.
  35312. */
  35313. vignetteColor: Color4;
  35314. /**
  35315. * Gets Camera field of view used by the Vignette effect.
  35316. */
  35317. /**
  35318. * Sets Camera field of view used by the Vignette effect.
  35319. */
  35320. vignetteCameraFov: number;
  35321. /**
  35322. * Gets the vignette blend mode allowing different kind of effect.
  35323. */
  35324. /**
  35325. * Sets the vignette blend mode allowing different kind of effect.
  35326. */
  35327. vignetteBlendMode: number;
  35328. /**
  35329. * Gets wether the vignette effect is enabled.
  35330. */
  35331. /**
  35332. * Sets wether the vignette effect is enabled.
  35333. */
  35334. vignetteEnabled: boolean;
  35335. private _fromLinearSpace;
  35336. /**
  35337. * Gets wether the input of the processing is in Gamma or Linear Space.
  35338. */
  35339. /**
  35340. * Sets wether the input of the processing is in Gamma or Linear Space.
  35341. */
  35342. fromLinearSpace: boolean;
  35343. /**
  35344. * Defines cache preventing GC.
  35345. */
  35346. private _defines;
  35347. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35348. /**
  35349. * "ImageProcessingPostProcess"
  35350. * @returns "ImageProcessingPostProcess"
  35351. */
  35352. getClassName(): string;
  35353. protected _updateParameters(): void;
  35354. dispose(camera?: Camera): void;
  35355. }
  35356. }
  35357. declare module BABYLON {
  35358. /**
  35359. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35360. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35361. * As an example, all you have to do is to create the post-process:
  35362. * var mb = new BABYLON.MotionBlurPostProcess(
  35363. * 'mb', // The name of the effect.
  35364. * scene, // The scene containing the objects to blur according to their velocity.
  35365. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35366. * camera // The camera to apply the render pass to.
  35367. * );
  35368. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35369. */
  35370. class MotionBlurPostProcess extends PostProcess {
  35371. /**
  35372. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35373. */
  35374. motionStrength: number;
  35375. /**
  35376. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35377. */
  35378. /**
  35379. * Sets the number of iterations to be used for motion blur quality
  35380. */
  35381. motionBlurSamples: number;
  35382. private _motionBlurSamples;
  35383. private _geometryBufferRenderer;
  35384. /**
  35385. * Creates a new instance MotionBlurPostProcess
  35386. * @param name The name of the effect.
  35387. * @param scene The scene containing the objects to blur according to their velocity.
  35388. * @param options The required width/height ratio to downsize to before computing the render pass.
  35389. * @param camera The camera to apply the render pass to.
  35390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35391. * @param engine The engine which the post process will be applied. (default: current engine)
  35392. * @param reusable If the post process can be reused on the same frame. (default: false)
  35393. * @param textureType Type of textures used when performing the post process. (default: 0)
  35394. * @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)
  35395. */
  35396. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35397. /**
  35398. * Disposes the post process.
  35399. * @param camera The camera to dispose the post process on.
  35400. */
  35401. dispose(camera?: Camera): void;
  35402. }
  35403. }
  35404. declare module BABYLON {
  35405. /**
  35406. * PassPostProcess which produces an output the same as it's input
  35407. */
  35408. class PassPostProcess extends PostProcess {
  35409. /**
  35410. * Creates the PassPostProcess
  35411. * @param name The name of the effect.
  35412. * @param options The required width/height ratio to downsize to before computing the render pass.
  35413. * @param camera The camera to apply the render pass to.
  35414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35415. * @param engine The engine which the post process will be applied. (default: current engine)
  35416. * @param reusable If the post process can be reused on the same frame. (default: false)
  35417. * @param textureType The type of texture to be used when performing the post processing.
  35418. * @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)
  35419. */
  35420. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35421. }
  35422. /**
  35423. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35424. */
  35425. class PassCubePostProcess extends PostProcess {
  35426. private _face;
  35427. /**
  35428. * Gets or sets the cube face to display.
  35429. * * 0 is +X
  35430. * * 1 is -X
  35431. * * 2 is +Y
  35432. * * 3 is -Y
  35433. * * 4 is +Z
  35434. * * 5 is -Z
  35435. */
  35436. face: number;
  35437. /**
  35438. * Creates the PassCubePostProcess
  35439. * @param name The name of the effect.
  35440. * @param options The required width/height ratio to downsize to before computing the render pass.
  35441. * @param camera The camera to apply the render pass to.
  35442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35443. * @param engine The engine which the post process will be applied. (default: current engine)
  35444. * @param reusable If the post process can be reused on the same frame. (default: false)
  35445. * @param textureType The type of texture to be used when performing the post processing.
  35446. * @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)
  35447. */
  35448. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35449. }
  35450. }
  35451. declare module BABYLON {
  35452. /**
  35453. * Size options for a post process
  35454. */
  35455. type PostProcessOptions = {
  35456. width: number;
  35457. height: number;
  35458. };
  35459. /**
  35460. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35461. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35462. */
  35463. class PostProcess {
  35464. /** Name of the PostProcess. */
  35465. name: string;
  35466. /**
  35467. * Width of the texture to apply the post process on
  35468. */
  35469. width: number;
  35470. /**
  35471. * Height of the texture to apply the post process on
  35472. */
  35473. height: number;
  35474. /**
  35475. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35476. * @hidden
  35477. */
  35478. _outputTexture: Nullable<InternalTexture>;
  35479. /**
  35480. * Sampling mode used by the shader
  35481. * See https://doc.babylonjs.com/classes/3.1/texture
  35482. */
  35483. renderTargetSamplingMode: number;
  35484. /**
  35485. * Clear color to use when screen clearing
  35486. */
  35487. clearColor: Color4;
  35488. /**
  35489. * If the buffer needs to be cleared before applying the post process. (default: true)
  35490. * Should be set to false if shader will overwrite all previous pixels.
  35491. */
  35492. autoClear: boolean;
  35493. /**
  35494. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35495. */
  35496. alphaMode: number;
  35497. /**
  35498. * Sets the setAlphaBlendConstants of the babylon engine
  35499. */
  35500. alphaConstants: Color4;
  35501. /**
  35502. * Animations to be used for the post processing
  35503. */
  35504. animations: Animation[];
  35505. /**
  35506. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35507. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35508. */
  35509. enablePixelPerfectMode: boolean;
  35510. /**
  35511. * Force the postprocess to be applied without taking in account viewport
  35512. */
  35513. forceFullscreenViewport: boolean;
  35514. /**
  35515. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35516. *
  35517. * | Value | Type | Description |
  35518. * | ----- | ----------------------------------- | ----------- |
  35519. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35520. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35521. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35522. *
  35523. */
  35524. scaleMode: number;
  35525. /**
  35526. * Force textures to be a power of two (default: false)
  35527. */
  35528. alwaysForcePOT: boolean;
  35529. private _samples;
  35530. /**
  35531. * Number of sample textures (default: 1)
  35532. */
  35533. samples: number;
  35534. /**
  35535. * Modify the scale of the post process to be the same as the viewport (default: false)
  35536. */
  35537. adaptScaleToCurrentViewport: boolean;
  35538. private _camera;
  35539. private _scene;
  35540. private _engine;
  35541. private _options;
  35542. private _reusable;
  35543. private _textureType;
  35544. /**
  35545. * Smart array of input and output textures for the post process.
  35546. * @hidden
  35547. */
  35548. _textures: SmartArray<InternalTexture>;
  35549. /**
  35550. * The index in _textures that corresponds to the output texture.
  35551. * @hidden
  35552. */
  35553. _currentRenderTextureInd: number;
  35554. private _effect;
  35555. private _samplers;
  35556. private _fragmentUrl;
  35557. private _vertexUrl;
  35558. private _parameters;
  35559. private _scaleRatio;
  35560. protected _indexParameters: any;
  35561. private _shareOutputWithPostProcess;
  35562. private _texelSize;
  35563. private _forcedOutputTexture;
  35564. /**
  35565. * An event triggered when the postprocess is activated.
  35566. */
  35567. onActivateObservable: Observable<Camera>;
  35568. private _onActivateObserver;
  35569. /**
  35570. * A function that is added to the onActivateObservable
  35571. */
  35572. onActivate: Nullable<(camera: Camera) => void>;
  35573. /**
  35574. * An event triggered when the postprocess changes its size.
  35575. */
  35576. onSizeChangedObservable: Observable<PostProcess>;
  35577. private _onSizeChangedObserver;
  35578. /**
  35579. * A function that is added to the onSizeChangedObservable
  35580. */
  35581. onSizeChanged: (postProcess: PostProcess) => void;
  35582. /**
  35583. * An event triggered when the postprocess applies its effect.
  35584. */
  35585. onApplyObservable: Observable<Effect>;
  35586. private _onApplyObserver;
  35587. /**
  35588. * A function that is added to the onApplyObservable
  35589. */
  35590. onApply: (effect: Effect) => void;
  35591. /**
  35592. * An event triggered before rendering the postprocess
  35593. */
  35594. onBeforeRenderObservable: Observable<Effect>;
  35595. private _onBeforeRenderObserver;
  35596. /**
  35597. * A function that is added to the onBeforeRenderObservable
  35598. */
  35599. onBeforeRender: (effect: Effect) => void;
  35600. /**
  35601. * An event triggered after rendering the postprocess
  35602. */
  35603. onAfterRenderObservable: Observable<Effect>;
  35604. private _onAfterRenderObserver;
  35605. /**
  35606. * A function that is added to the onAfterRenderObservable
  35607. */
  35608. onAfterRender: (efect: Effect) => void;
  35609. /**
  35610. * 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
  35611. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35612. */
  35613. inputTexture: InternalTexture;
  35614. /**
  35615. * Gets the camera which post process is applied to.
  35616. * @returns The camera the post process is applied to.
  35617. */
  35618. getCamera(): Camera;
  35619. /**
  35620. * Gets the texel size of the postprocess.
  35621. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35622. */
  35623. readonly texelSize: Vector2;
  35624. /**
  35625. * Creates a new instance PostProcess
  35626. * @param name The name of the PostProcess.
  35627. * @param fragmentUrl The url of the fragment shader to be used.
  35628. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35629. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35630. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35631. * @param camera The camera to apply the render pass to.
  35632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35633. * @param engine The engine which the post process will be applied. (default: current engine)
  35634. * @param reusable If the post process can be reused on the same frame. (default: false)
  35635. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35636. * @param textureType Type of textures used when performing the post process. (default: 0)
  35637. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35638. * @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
  35639. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35640. */
  35641. constructor(
  35642. /** Name of the PostProcess. */
  35643. 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);
  35644. /**
  35645. * Gets the engine which this post process belongs to.
  35646. * @returns The engine the post process was enabled with.
  35647. */
  35648. getEngine(): Engine;
  35649. /**
  35650. * The effect that is created when initializing the post process.
  35651. * @returns The created effect corrisponding the the postprocess.
  35652. */
  35653. getEffect(): Effect;
  35654. /**
  35655. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35656. * @param postProcess The post process to share the output with.
  35657. * @returns This post process.
  35658. */
  35659. shareOutputWith(postProcess: PostProcess): PostProcess;
  35660. /**
  35661. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35662. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35663. */
  35664. useOwnOutput(): void;
  35665. /**
  35666. * Updates the effect with the current post process compile time values and recompiles the shader.
  35667. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35668. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35669. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35670. * @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
  35671. * @param onCompiled Called when the shader has been compiled.
  35672. * @param onError Called if there is an error when compiling a shader.
  35673. */
  35674. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35675. /**
  35676. * The post process is reusable if it can be used multiple times within one frame.
  35677. * @returns If the post process is reusable
  35678. */
  35679. isReusable(): boolean;
  35680. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35681. markTextureDirty(): void;
  35682. /**
  35683. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35684. * 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.
  35685. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35686. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35687. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35688. * @returns The target texture that was bound to be written to.
  35689. */
  35690. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35691. /**
  35692. * If the post process is supported.
  35693. */
  35694. readonly isSupported: boolean;
  35695. /**
  35696. * The aspect ratio of the output texture.
  35697. */
  35698. readonly aspectRatio: number;
  35699. /**
  35700. * Get a value indicating if the post-process is ready to be used
  35701. * @returns true if the post-process is ready (shader is compiled)
  35702. */
  35703. isReady(): boolean;
  35704. /**
  35705. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35706. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35707. */
  35708. apply(): Nullable<Effect>;
  35709. private _disposeTextures;
  35710. /**
  35711. * Disposes the post process.
  35712. * @param camera The camera to dispose the post process on.
  35713. */
  35714. dispose(camera?: Camera): void;
  35715. }
  35716. }
  35717. declare module BABYLON {
  35718. /**
  35719. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35721. */
  35722. class PostProcessManager {
  35723. private _scene;
  35724. private _indexBuffer;
  35725. private _vertexBuffers;
  35726. /**
  35727. * Creates a new instance PostProcess
  35728. * @param scene The scene that the post process is associated with.
  35729. */
  35730. constructor(scene: Scene);
  35731. private _prepareBuffers;
  35732. private _buildIndexBuffer;
  35733. /**
  35734. * Rebuilds the vertex buffers of the manager.
  35735. * @hidden
  35736. */
  35737. _rebuild(): void;
  35738. /**
  35739. * Prepares a frame to be run through a post process.
  35740. * @param sourceTexture The input texture to the post procesess. (default: null)
  35741. * @param postProcesses An array of post processes to be run. (default: null)
  35742. * @returns True if the post processes were able to be run.
  35743. * @hidden
  35744. */
  35745. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35746. /**
  35747. * Manually render a set of post processes to a texture.
  35748. * @param postProcesses An array of post processes to be run.
  35749. * @param targetTexture The target texture to render to.
  35750. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35751. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35752. * @param lodLevel defines which lod of the texture to render to
  35753. */
  35754. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35755. /**
  35756. * Finalize the result of the output of the postprocesses.
  35757. * @param doNotPresent If true the result will not be displayed to the screen.
  35758. * @param targetTexture The target texture to render to.
  35759. * @param faceIndex The index of the face to bind the target texture to.
  35760. * @param postProcesses The array of post processes to render.
  35761. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35762. * @hidden
  35763. */
  35764. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35765. /**
  35766. * Disposes of the post process manager.
  35767. */
  35768. dispose(): void;
  35769. }
  35770. }
  35771. declare module BABYLON {
  35772. /**
  35773. * Post process which applies a refractin texture
  35774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35775. */
  35776. class RefractionPostProcess extends PostProcess {
  35777. /** the base color of the refraction (used to taint the rendering) */
  35778. color: Color3;
  35779. /** simulated refraction depth */
  35780. depth: number;
  35781. /** the coefficient of the base color (0 to remove base color tainting) */
  35782. colorLevel: number;
  35783. private _refTexture;
  35784. private _ownRefractionTexture;
  35785. /**
  35786. * Gets or sets the refraction texture
  35787. * Please note that you are responsible for disposing the texture if you set it manually
  35788. */
  35789. refractionTexture: Texture;
  35790. /**
  35791. * Initializes the RefractionPostProcess
  35792. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35793. * @param name The name of the effect.
  35794. * @param refractionTextureUrl Url of the refraction texture to use
  35795. * @param color the base color of the refraction (used to taint the rendering)
  35796. * @param depth simulated refraction depth
  35797. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35798. * @param camera The camera to apply the render pass to.
  35799. * @param options The required width/height ratio to downsize to before computing the render pass.
  35800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35801. * @param engine The engine which the post process will be applied. (default: current engine)
  35802. * @param reusable If the post process can be reused on the same frame. (default: false)
  35803. */
  35804. constructor(name: string, refractionTextureUrl: string,
  35805. /** the base color of the refraction (used to taint the rendering) */
  35806. color: Color3,
  35807. /** simulated refraction depth */
  35808. depth: number,
  35809. /** the coefficient of the base color (0 to remove base color tainting) */
  35810. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35811. /**
  35812. * Disposes of the post process
  35813. * @param camera Camera to dispose post process on
  35814. */
  35815. dispose(camera: Camera): void;
  35816. }
  35817. }
  35818. declare module BABYLON {
  35819. /**
  35820. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35821. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35822. */
  35823. class SharpenPostProcess extends PostProcess {
  35824. /**
  35825. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35826. */
  35827. colorAmount: number;
  35828. /**
  35829. * How much sharpness should be applied (default: 0.3)
  35830. */
  35831. edgeAmount: number;
  35832. /**
  35833. * Creates a new instance ConvolutionPostProcess
  35834. * @param name The name of the effect.
  35835. * @param options The required width/height ratio to downsize to before computing the render pass.
  35836. * @param camera The camera to apply the render pass to.
  35837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35838. * @param engine The engine which the post process will be applied. (default: current engine)
  35839. * @param reusable If the post process can be reused on the same frame. (default: false)
  35840. * @param textureType Type of textures used when performing the post process. (default: 0)
  35841. * @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)
  35842. */
  35843. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35844. }
  35845. }
  35846. declare module BABYLON {
  35847. /**
  35848. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35849. */
  35850. class StereoscopicInterlacePostProcess extends PostProcess {
  35851. private _stepSize;
  35852. private _passedProcess;
  35853. /**
  35854. * Initializes a StereoscopicInterlacePostProcess
  35855. * @param name The name of the effect.
  35856. * @param rigCameras The rig cameras to be appled to the post process
  35857. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35859. * @param engine The engine which the post process will be applied. (default: current engine)
  35860. * @param reusable If the post process can be reused on the same frame. (default: false)
  35861. */
  35862. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35863. }
  35864. }
  35865. declare module BABYLON {
  35866. /** Defines operator used for tonemapping */
  35867. enum TonemappingOperator {
  35868. /** Hable */
  35869. Hable = 0,
  35870. /** Reinhard */
  35871. Reinhard = 1,
  35872. /** HejiDawson */
  35873. HejiDawson = 2,
  35874. /** Photographic */
  35875. Photographic = 3
  35876. }
  35877. /**
  35878. * Defines a post process to apply tone mapping
  35879. */
  35880. class TonemapPostProcess extends PostProcess {
  35881. private _operator;
  35882. /** Defines the required exposure adjustement */
  35883. exposureAdjustment: number;
  35884. /**
  35885. * Creates a new TonemapPostProcess
  35886. * @param name defines the name of the postprocess
  35887. * @param _operator defines the operator to use
  35888. * @param exposureAdjustment defines the required exposure adjustement
  35889. * @param camera defines the camera to use (can be null)
  35890. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35891. * @param engine defines the hosting engine (can be ignore if camera is set)
  35892. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35893. */
  35894. constructor(name: string, _operator: TonemappingOperator,
  35895. /** Defines the required exposure adjustement */
  35896. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35897. }
  35898. }
  35899. declare module BABYLON {
  35900. /**
  35901. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35902. */
  35903. class VolumetricLightScatteringPostProcess extends PostProcess {
  35904. private _volumetricLightScatteringPass;
  35905. private _volumetricLightScatteringRTT;
  35906. private _viewPort;
  35907. private _screenCoordinates;
  35908. private _cachedDefines;
  35909. /**
  35910. * If not undefined, the mesh position is computed from the attached node position
  35911. */
  35912. attachedNode: {
  35913. position: Vector3;
  35914. };
  35915. /**
  35916. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35917. */
  35918. customMeshPosition: Vector3;
  35919. /**
  35920. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35921. */
  35922. useCustomMeshPosition: boolean;
  35923. /**
  35924. * If the post-process should inverse the light scattering direction
  35925. */
  35926. invert: boolean;
  35927. /**
  35928. * The internal mesh used by the post-process
  35929. */
  35930. mesh: Mesh;
  35931. /**
  35932. * @hidden
  35933. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35934. */
  35935. useDiffuseColor: boolean;
  35936. /**
  35937. * Array containing the excluded meshes not rendered in the internal pass
  35938. */
  35939. excludedMeshes: AbstractMesh[];
  35940. /**
  35941. * Controls the overall intensity of the post-process
  35942. */
  35943. exposure: number;
  35944. /**
  35945. * Dissipates each sample's contribution in range [0, 1]
  35946. */
  35947. decay: number;
  35948. /**
  35949. * Controls the overall intensity of each sample
  35950. */
  35951. weight: number;
  35952. /**
  35953. * Controls the density of each sample
  35954. */
  35955. density: number;
  35956. /**
  35957. * @constructor
  35958. * @param name The post-process name
  35959. * @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)
  35960. * @param camera The camera that the post-process will be attached to
  35961. * @param mesh The mesh used to create the light scattering
  35962. * @param samples The post-process quality, default 100
  35963. * @param samplingModeThe post-process filtering mode
  35964. * @param engine The babylon engine
  35965. * @param reusable If the post-process is reusable
  35966. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35967. */
  35968. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35969. /**
  35970. * Returns the string "VolumetricLightScatteringPostProcess"
  35971. * @returns "VolumetricLightScatteringPostProcess"
  35972. */
  35973. getClassName(): string;
  35974. private _isReady;
  35975. /**
  35976. * Sets the new light position for light scattering effect
  35977. * @param position The new custom light position
  35978. */
  35979. setCustomMeshPosition(position: Vector3): void;
  35980. /**
  35981. * Returns the light position for light scattering effect
  35982. * @return Vector3 The custom light position
  35983. */
  35984. getCustomMeshPosition(): Vector3;
  35985. /**
  35986. * Disposes the internal assets and detaches the post-process from the camera
  35987. */
  35988. dispose(camera: Camera): void;
  35989. /**
  35990. * Returns the render target texture used by the post-process
  35991. * @return the render target texture used by the post-process
  35992. */
  35993. getPass(): RenderTargetTexture;
  35994. private _meshExcluded;
  35995. private _createPass;
  35996. private _updateMeshScreenCoordinates;
  35997. /**
  35998. * Creates a default mesh for the Volumeric Light Scattering post-process
  35999. * @param name The mesh name
  36000. * @param scene The scene where to create the mesh
  36001. * @return the default mesh
  36002. */
  36003. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36004. }
  36005. }
  36006. declare module BABYLON {
  36007. /**
  36008. * VRDistortionCorrectionPostProcess used for mobile VR
  36009. */
  36010. class VRDistortionCorrectionPostProcess extends PostProcess {
  36011. private _isRightEye;
  36012. private _distortionFactors;
  36013. private _postProcessScaleFactor;
  36014. private _lensCenterOffset;
  36015. private _scaleIn;
  36016. private _scaleFactor;
  36017. private _lensCenter;
  36018. /**
  36019. * Initializes the VRDistortionCorrectionPostProcess
  36020. * @param name The name of the effect.
  36021. * @param camera The camera to apply the render pass to.
  36022. * @param isRightEye If this is for the right eye distortion
  36023. * @param vrMetrics All the required metrics for the VR camera
  36024. */
  36025. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36026. }
  36027. }
  36028. declare module BABYLON {
  36029. interface Scene {
  36030. /** @hidden (Backing field) */
  36031. _boundingBoxRenderer: BoundingBoxRenderer;
  36032. /** @hidden (Backing field) */
  36033. _forceShowBoundingBoxes: boolean;
  36034. /**
  36035. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  36036. */
  36037. forceShowBoundingBoxes: boolean;
  36038. /**
  36039. * Gets the bounding box renderer associated with the scene
  36040. * @returns a BoundingBoxRenderer
  36041. */
  36042. getBoundingBoxRenderer(): BoundingBoxRenderer;
  36043. }
  36044. interface AbstractMesh {
  36045. /** @hidden (Backing field) */
  36046. _showBoundingBox: boolean;
  36047. /**
  36048. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  36049. */
  36050. showBoundingBox: boolean;
  36051. }
  36052. /**
  36053. * Component responsible of rendering the bounding box of the meshes in a scene.
  36054. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  36055. */
  36056. class BoundingBoxRenderer implements ISceneComponent {
  36057. /**
  36058. * The component name helpfull to identify the component in the list of scene components.
  36059. */
  36060. readonly name: string;
  36061. /**
  36062. * The scene the component belongs to.
  36063. */
  36064. scene: Scene;
  36065. /**
  36066. * Color of the bounding box lines placed in front of an object
  36067. */
  36068. frontColor: Color3;
  36069. /**
  36070. * Color of the bounding box lines placed behind an object
  36071. */
  36072. backColor: Color3;
  36073. /**
  36074. * Defines if the renderer should show the back lines or not
  36075. */
  36076. showBackLines: boolean;
  36077. /**
  36078. * @hidden
  36079. */
  36080. renderList: SmartArray<BoundingBox>;
  36081. private _colorShader;
  36082. private _vertexBuffers;
  36083. private _indexBuffer;
  36084. /**
  36085. * Instantiates a new bounding box renderer in a scene.
  36086. * @param scene the scene the renderer renders in
  36087. */
  36088. constructor(scene: Scene);
  36089. /**
  36090. * Registers the component in a given scene
  36091. */
  36092. register(): void;
  36093. private _evaluateSubMesh;
  36094. private _activeMesh;
  36095. private _prepareRessources;
  36096. private _createIndexBuffer;
  36097. /**
  36098. * Rebuilds the elements related to this component in case of
  36099. * context lost for instance.
  36100. */
  36101. rebuild(): void;
  36102. /**
  36103. * @hidden
  36104. */
  36105. reset(): void;
  36106. /**
  36107. * Render the bounding boxes of a specific rendering group
  36108. * @param renderingGroupId defines the rendering group to render
  36109. */
  36110. render(renderingGroupId: number): void;
  36111. /**
  36112. * In case of occlusion queries, we can render the occlusion bounding box through this method
  36113. * @param mesh Define the mesh to render the occlusion bounding box for
  36114. */
  36115. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  36116. /**
  36117. * Dispose and release the resources attached to this renderer.
  36118. */
  36119. dispose(): void;
  36120. }
  36121. }
  36122. declare module BABYLON {
  36123. /**
  36124. * This represents a depth renderer in Babylon.
  36125. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  36126. */
  36127. class DepthRenderer {
  36128. private _scene;
  36129. private _depthMap;
  36130. private _effect;
  36131. private _cachedDefines;
  36132. private _camera;
  36133. /**
  36134. * Specifiess that the depth renderer will only be used within
  36135. * the camera it is created for.
  36136. * This can help forcing its rendering during the camera processing.
  36137. */
  36138. useOnlyInActiveCamera: boolean;
  36139. /**
  36140. * Instantiates a depth renderer
  36141. * @param scene The scene the renderer belongs to
  36142. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  36143. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  36144. */
  36145. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  36146. /**
  36147. * Creates the depth rendering effect and checks if the effect is ready.
  36148. * @param subMesh The submesh to be used to render the depth map of
  36149. * @param useInstances If multiple world instances should be used
  36150. * @returns if the depth renderer is ready to render the depth map
  36151. */
  36152. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36153. /**
  36154. * Gets the texture which the depth map will be written to.
  36155. * @returns The depth map texture
  36156. */
  36157. getDepthMap(): RenderTargetTexture;
  36158. /**
  36159. * Disposes of the depth renderer.
  36160. */
  36161. dispose(): void;
  36162. }
  36163. }
  36164. declare module BABYLON {
  36165. interface Scene {
  36166. /** @hidden (Backing field) */
  36167. _depthRenderer: {
  36168. [id: string]: DepthRenderer;
  36169. };
  36170. /**
  36171. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  36172. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  36173. * @returns the created depth renderer
  36174. */
  36175. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  36176. /**
  36177. * Disables a depth renderer for a given camera
  36178. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  36179. */
  36180. disableDepthRenderer(camera?: Nullable<Camera>): void;
  36181. }
  36182. /**
  36183. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  36184. * in several rendering techniques.
  36185. */
  36186. class DepthRendererSceneComponent implements ISceneComponent {
  36187. /**
  36188. * The component name helpfull to identify the component in the list of scene components.
  36189. */
  36190. readonly name: string;
  36191. /**
  36192. * The scene the component belongs to.
  36193. */
  36194. scene: Scene;
  36195. /**
  36196. * Creates a new instance of the component for the given scene
  36197. * @param scene Defines the scene to register the component in
  36198. */
  36199. constructor(scene: Scene);
  36200. /**
  36201. * Registers the component in a given scene
  36202. */
  36203. register(): void;
  36204. /**
  36205. * Rebuilds the elements related to this component in case of
  36206. * context lost for instance.
  36207. */
  36208. rebuild(): void;
  36209. /**
  36210. * Disposes the component and the associated ressources
  36211. */
  36212. dispose(): void;
  36213. private _gatherRenderTargets;
  36214. private _gatherActiveCameraRenderTargets;
  36215. }
  36216. }
  36217. declare module BABYLON {
  36218. interface AbstractMesh {
  36219. /**
  36220. * Disables the mesh edge rendering mode
  36221. * @returns the currentAbstractMesh
  36222. */
  36223. disableEdgesRendering(): AbstractMesh;
  36224. /**
  36225. * Enables the edge rendering mode on the mesh.
  36226. * This mode makes the mesh edges visible
  36227. * @param epsilon defines the maximal distance between two angles to detect a face
  36228. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36229. * @returns the currentAbstractMesh
  36230. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36231. */
  36232. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36233. /**
  36234. * Gets the edgesRenderer associated with the mesh
  36235. */
  36236. edgesRenderer: Nullable<EdgesRenderer>;
  36237. }
  36238. interface LinesMesh {
  36239. /**
  36240. * Enables the edge rendering mode on the mesh.
  36241. * This mode makes the mesh edges visible
  36242. * @param epsilon defines the maximal distance between two angles to detect a face
  36243. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36244. * @returns the currentAbstractMesh
  36245. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36246. */
  36247. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36248. }
  36249. interface InstancedLinesMesh {
  36250. /**
  36251. * Enables the edge rendering mode on the mesh.
  36252. * This mode makes the mesh edges visible
  36253. * @param epsilon defines the maximal distance between two angles to detect a face
  36254. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36255. * @returns the current InstancedLinesMesh
  36256. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36257. */
  36258. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  36259. }
  36260. /**
  36261. * Defines the minimum contract an Edges renderer should follow.
  36262. */
  36263. interface IEdgesRenderer extends IDisposable {
  36264. /**
  36265. * Gets or sets a boolean indicating if the edgesRenderer is active
  36266. */
  36267. isEnabled: boolean;
  36268. /**
  36269. * Renders the edges of the attached mesh,
  36270. */
  36271. render(): void;
  36272. /**
  36273. * Checks wether or not the edges renderer is ready to render.
  36274. * @return true if ready, otherwise false.
  36275. */
  36276. isReady(): boolean;
  36277. }
  36278. /**
  36279. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  36280. */
  36281. class EdgesRenderer implements IEdgesRenderer {
  36282. /**
  36283. * Define the size of the edges with an orthographic camera
  36284. */
  36285. edgesWidthScalerForOrthographic: number;
  36286. /**
  36287. * Define the size of the edges with a perspective camera
  36288. */
  36289. edgesWidthScalerForPerspective: number;
  36290. protected _source: AbstractMesh;
  36291. protected _linesPositions: number[];
  36292. protected _linesNormals: number[];
  36293. protected _linesIndices: number[];
  36294. protected _epsilon: number;
  36295. protected _indicesCount: number;
  36296. protected _lineShader: ShaderMaterial;
  36297. protected _ib: WebGLBuffer;
  36298. protected _buffers: {
  36299. [key: string]: Nullable<VertexBuffer>;
  36300. };
  36301. protected _checkVerticesInsteadOfIndices: boolean;
  36302. private _meshRebuildObserver;
  36303. private _meshDisposeObserver;
  36304. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  36305. isEnabled: boolean;
  36306. /**
  36307. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36308. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36309. * @param source Mesh used to create edges
  36310. * @param epsilon sum of angles in adjacency to check for edge
  36311. * @param checkVerticesInsteadOfIndices
  36312. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36313. */
  36314. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36315. protected _prepareRessources(): void;
  36316. /** @hidden */
  36317. _rebuild(): void;
  36318. /**
  36319. * Releases the required resources for the edges renderer
  36320. */
  36321. dispose(): void;
  36322. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36323. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36324. /**
  36325. * Checks if the pair of p0 and p1 is en edge
  36326. * @param faceIndex
  36327. * @param edge
  36328. * @param faceNormals
  36329. * @param p0
  36330. * @param p1
  36331. * @private
  36332. */
  36333. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36334. /**
  36335. * push line into the position, normal and index buffer
  36336. * @protected
  36337. */
  36338. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36339. /**
  36340. * Generates lines edges from adjacencjes
  36341. * @private
  36342. */
  36343. _generateEdgesLines(): void;
  36344. /**
  36345. * Checks wether or not the edges renderer is ready to render.
  36346. * @return true if ready, otherwise false.
  36347. */
  36348. isReady(): boolean;
  36349. /**
  36350. * Renders the edges of the attached mesh,
  36351. */
  36352. render(): void;
  36353. }
  36354. }
  36355. declare module BABYLON {
  36356. /**
  36357. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36358. */
  36359. class GeometryBufferRenderer {
  36360. /**
  36361. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36362. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36363. */
  36364. static readonly POSITION_TEXTURE_TYPE: number;
  36365. /**
  36366. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36367. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36368. */
  36369. static readonly VELOCITY_TEXTURE_TYPE: number;
  36370. /**
  36371. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36372. * in order to compute objects velocities when enableVelocity is set to "true"
  36373. * @hidden
  36374. */
  36375. _previousTransformationMatrices: {
  36376. [index: number]: Matrix;
  36377. };
  36378. private _scene;
  36379. private _multiRenderTarget;
  36380. private _ratio;
  36381. private _enablePosition;
  36382. private _enableVelocity;
  36383. private _positionIndex;
  36384. private _velocityIndex;
  36385. protected _effect: Effect;
  36386. protected _cachedDefines: string;
  36387. /**
  36388. * Set the render list (meshes to be rendered) used in the G buffer.
  36389. */
  36390. renderList: Mesh[];
  36391. /**
  36392. * Gets wether or not G buffer are supported by the running hardware.
  36393. * This requires draw buffer supports
  36394. */
  36395. readonly isSupported: boolean;
  36396. /**
  36397. * Returns the index of the given texture type in the G-Buffer textures array
  36398. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36399. * @returns the index of the given texture type in the G-Buffer textures array
  36400. */
  36401. getTextureIndex(textureType: number): number;
  36402. /**
  36403. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36404. */
  36405. /**
  36406. * Sets whether or not objects positions are enabled for the G buffer.
  36407. */
  36408. enablePosition: boolean;
  36409. /**
  36410. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36411. */
  36412. /**
  36413. * Sets wether or not objects velocities are enabled for the G buffer.
  36414. */
  36415. enableVelocity: boolean;
  36416. /**
  36417. * Gets the scene associated with the buffer.
  36418. */
  36419. readonly scene: Scene;
  36420. /**
  36421. * Gets the ratio used by the buffer during its creation.
  36422. * How big is the buffer related to the main canvas.
  36423. */
  36424. readonly ratio: number;
  36425. /**
  36426. * Creates a new G Buffer for the scene
  36427. * @param scene The scene the buffer belongs to
  36428. * @param ratio How big is the buffer related to the main canvas.
  36429. */
  36430. constructor(scene: Scene, ratio?: number);
  36431. /**
  36432. * Checks wether everything is ready to render a submesh to the G buffer.
  36433. * @param subMesh the submesh to check readiness for
  36434. * @param useInstances is the mesh drawn using instance or not
  36435. * @returns true if ready otherwise false
  36436. */
  36437. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36438. /**
  36439. * Gets the current underlying G Buffer.
  36440. * @returns the buffer
  36441. */
  36442. getGBuffer(): MultiRenderTarget;
  36443. /**
  36444. * Gets the number of samples used to render the buffer (anti aliasing).
  36445. */
  36446. /**
  36447. * Sets the number of samples used to render the buffer (anti aliasing).
  36448. */
  36449. samples: number;
  36450. /**
  36451. * Disposes the renderer and frees up associated resources.
  36452. */
  36453. dispose(): void;
  36454. protected _createRenderTargets(): void;
  36455. }
  36456. }
  36457. declare module BABYLON {
  36458. interface Scene {
  36459. /** @hidden (Backing field) */
  36460. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36461. /**
  36462. * Gets or Sets the current geometry buffer associated to the scene.
  36463. */
  36464. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36465. /**
  36466. * Enables a GeometryBufferRender and associates it with the scene
  36467. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36468. * @returns the GeometryBufferRenderer
  36469. */
  36470. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36471. /**
  36472. * Disables the GeometryBufferRender associated with the scene
  36473. */
  36474. disableGeometryBufferRenderer(): void;
  36475. }
  36476. /**
  36477. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36478. * in several rendering techniques.
  36479. */
  36480. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36481. /**
  36482. * The component name helpful to identify the component in the list of scene components.
  36483. */
  36484. readonly name: string;
  36485. /**
  36486. * The scene the component belongs to.
  36487. */
  36488. scene: Scene;
  36489. /**
  36490. * Creates a new instance of the component for the given scene
  36491. * @param scene Defines the scene to register the component in
  36492. */
  36493. constructor(scene: Scene);
  36494. /**
  36495. * Registers the component in a given scene
  36496. */
  36497. register(): void;
  36498. /**
  36499. * Rebuilds the elements related to this component in case of
  36500. * context lost for instance.
  36501. */
  36502. rebuild(): void;
  36503. /**
  36504. * Disposes the component and the associated ressources
  36505. */
  36506. dispose(): void;
  36507. private _gatherRenderTargets;
  36508. }
  36509. }
  36510. declare module BABYLON {
  36511. /**
  36512. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36513. */
  36514. class LineEdgesRenderer extends EdgesRenderer {
  36515. /**
  36516. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36517. * @param source LineMesh used to generate edges
  36518. * @param epsilon not important (specified angle for edge detection)
  36519. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36520. */
  36521. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36522. /**
  36523. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36524. */
  36525. _generateEdgesLines(): void;
  36526. }
  36527. }
  36528. declare module BABYLON {
  36529. interface Scene {
  36530. /** @hidden */
  36531. _outlineRenderer: OutlineRenderer;
  36532. /**
  36533. * Gets the outline renderer associated with the scene
  36534. * @returns a OutlineRenderer
  36535. */
  36536. getOutlineRenderer(): OutlineRenderer;
  36537. }
  36538. interface AbstractMesh {
  36539. /** @hidden (Backing field) */
  36540. _renderOutline: boolean;
  36541. /**
  36542. * Gets or sets a boolean indicating if the outline must be rendered as well
  36543. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36544. */
  36545. renderOutline: boolean;
  36546. /** @hidden (Backing field) */
  36547. _renderOverlay: boolean;
  36548. /**
  36549. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36550. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36551. */
  36552. renderOverlay: boolean;
  36553. }
  36554. /**
  36555. * This class is responsible to draw bothe outline/overlay of meshes.
  36556. * It should not be used directly but through the available method on mesh.
  36557. */
  36558. class OutlineRenderer implements ISceneComponent {
  36559. /**
  36560. * The name of the component. Each component must have a unique name.
  36561. */
  36562. name: string;
  36563. /**
  36564. * The scene the component belongs to.
  36565. */
  36566. scene: Scene;
  36567. /**
  36568. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36569. */
  36570. zOffset: number;
  36571. private _engine;
  36572. private _effect;
  36573. private _cachedDefines;
  36574. private _savedDepthWrite;
  36575. /**
  36576. * Instantiates a new outline renderer. (There could be only one per scene).
  36577. * @param scene Defines the scene it belongs to
  36578. */
  36579. constructor(scene: Scene);
  36580. /**
  36581. * Register the component to one instance of a scene.
  36582. */
  36583. register(): void;
  36584. /**
  36585. * Rebuilds the elements related to this component in case of
  36586. * context lost for instance.
  36587. */
  36588. rebuild(): void;
  36589. /**
  36590. * Disposes the component and the associated ressources.
  36591. */
  36592. dispose(): void;
  36593. /**
  36594. * Renders the outline in the canvas.
  36595. * @param subMesh Defines the sumesh to render
  36596. * @param batch Defines the batch of meshes in case of instances
  36597. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36598. */
  36599. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36600. /**
  36601. * Returns whether or not the outline renderer is ready for a given submesh.
  36602. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36603. * @param subMesh Defines the submesh to check readyness for
  36604. * @param useInstances Defines wheter wee are trying to render instances or not
  36605. * @returns true if ready otherwise false
  36606. */
  36607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36608. private _beforeRenderingMesh;
  36609. private _afterRenderingMesh;
  36610. }
  36611. }
  36612. declare module BABYLON {
  36613. /**
  36614. * This represents the object necessary to create a rendering group.
  36615. * This is exclusively used and created by the rendering manager.
  36616. * To modify the behavior, you use the available helpers in your scene or meshes.
  36617. * @hidden
  36618. */
  36619. class RenderingGroup {
  36620. index: number;
  36621. private _scene;
  36622. private _opaqueSubMeshes;
  36623. private _transparentSubMeshes;
  36624. private _alphaTestSubMeshes;
  36625. private _depthOnlySubMeshes;
  36626. private _particleSystems;
  36627. private _spriteManagers;
  36628. private _opaqueSortCompareFn;
  36629. private _alphaTestSortCompareFn;
  36630. private _transparentSortCompareFn;
  36631. private _renderOpaque;
  36632. private _renderAlphaTest;
  36633. private _renderTransparent;
  36634. private _edgesRenderers;
  36635. onBeforeTransparentRendering: () => void;
  36636. /**
  36637. * Set the opaque sort comparison function.
  36638. * If null the sub meshes will be render in the order they were created
  36639. */
  36640. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36641. /**
  36642. * Set the alpha test sort comparison function.
  36643. * If null the sub meshes will be render in the order they were created
  36644. */
  36645. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36646. /**
  36647. * Set the transparent sort comparison function.
  36648. * If null the sub meshes will be render in the order they were created
  36649. */
  36650. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36651. /**
  36652. * Creates a new rendering group.
  36653. * @param index The rendering group index
  36654. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36655. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36656. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36657. */
  36658. 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>);
  36659. /**
  36660. * Render all the sub meshes contained in the group.
  36661. * @param customRenderFunction Used to override the default render behaviour of the group.
  36662. * @returns true if rendered some submeshes.
  36663. */
  36664. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36665. /**
  36666. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36667. * @param subMeshes The submeshes to render
  36668. */
  36669. private renderOpaqueSorted;
  36670. /**
  36671. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36672. * @param subMeshes The submeshes to render
  36673. */
  36674. private renderAlphaTestSorted;
  36675. /**
  36676. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36677. * @param subMeshes The submeshes to render
  36678. */
  36679. private renderTransparentSorted;
  36680. /**
  36681. * Renders the submeshes in a specified order.
  36682. * @param subMeshes The submeshes to sort before render
  36683. * @param sortCompareFn The comparison function use to sort
  36684. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36685. * @param transparent Specifies to activate blending if true
  36686. */
  36687. private static renderSorted;
  36688. /**
  36689. * Renders the submeshes in the order they were dispatched (no sort applied).
  36690. * @param subMeshes The submeshes to render
  36691. */
  36692. private static renderUnsorted;
  36693. /**
  36694. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36695. * are rendered back to front if in the same alpha index.
  36696. *
  36697. * @param a The first submesh
  36698. * @param b The second submesh
  36699. * @returns The result of the comparison
  36700. */
  36701. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36702. /**
  36703. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36704. * are rendered back to front.
  36705. *
  36706. * @param a The first submesh
  36707. * @param b The second submesh
  36708. * @returns The result of the comparison
  36709. */
  36710. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36711. /**
  36712. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36713. * are rendered front to back (prevent overdraw).
  36714. *
  36715. * @param a The first submesh
  36716. * @param b The second submesh
  36717. * @returns The result of the comparison
  36718. */
  36719. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36720. /**
  36721. * Resets the different lists of submeshes to prepare a new frame.
  36722. */
  36723. prepare(): void;
  36724. dispose(): void;
  36725. /**
  36726. * Inserts the submesh in its correct queue depending on its material.
  36727. * @param subMesh The submesh to dispatch
  36728. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36729. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36730. */
  36731. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36732. dispatchSprites(spriteManager: ISpriteManager): void;
  36733. dispatchParticles(particleSystem: IParticleSystem): void;
  36734. private _renderParticles;
  36735. private _renderSprites;
  36736. }
  36737. }
  36738. declare module BABYLON {
  36739. /**
  36740. * Interface describing the different options available in the rendering manager
  36741. * regarding Auto Clear between groups.
  36742. */
  36743. interface IRenderingManagerAutoClearSetup {
  36744. /**
  36745. * Defines whether or not autoclear is enable.
  36746. */
  36747. autoClear: boolean;
  36748. /**
  36749. * Defines whether or not to autoclear the depth buffer.
  36750. */
  36751. depth: boolean;
  36752. /**
  36753. * Defines whether or not to autoclear the stencil buffer.
  36754. */
  36755. stencil: boolean;
  36756. }
  36757. /**
  36758. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36759. * It is enable to manage the different groups as well as the different necessary sort functions.
  36760. * This should not be used directly aside of the few static configurations
  36761. */
  36762. class RenderingManager {
  36763. /**
  36764. * The max id used for rendering groups (not included)
  36765. */
  36766. static MAX_RENDERINGGROUPS: number;
  36767. /**
  36768. * The min id used for rendering groups (included)
  36769. */
  36770. static MIN_RENDERINGGROUPS: number;
  36771. /**
  36772. * Used to globally prevent autoclearing scenes.
  36773. */
  36774. static AUTOCLEAR: boolean;
  36775. /**
  36776. * @hidden
  36777. */
  36778. _useSceneAutoClearSetup: boolean;
  36779. private _scene;
  36780. private _renderingGroups;
  36781. private _depthStencilBufferAlreadyCleaned;
  36782. private _autoClearDepthStencil;
  36783. private _customOpaqueSortCompareFn;
  36784. private _customAlphaTestSortCompareFn;
  36785. private _customTransparentSortCompareFn;
  36786. private _renderingGroupInfo;
  36787. /**
  36788. * Instantiates a new rendering group for a particular scene
  36789. * @param scene Defines the scene the groups belongs to
  36790. */
  36791. constructor(scene: Scene);
  36792. private _clearDepthStencilBuffer;
  36793. /**
  36794. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36795. * @hidden
  36796. */
  36797. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36798. /**
  36799. * Resets the different information of the group to prepare a new frame
  36800. * @hidden
  36801. */
  36802. reset(): void;
  36803. /**
  36804. * Dispose and release the group and its associated resources.
  36805. * @hidden
  36806. */
  36807. dispose(): void;
  36808. /**
  36809. * Clear the info related to rendering groups preventing retention points during dispose.
  36810. */
  36811. freeRenderingGroups(): void;
  36812. private _prepareRenderingGroup;
  36813. /**
  36814. * Add a sprite manager to the rendering manager in order to render it this frame.
  36815. * @param spriteManager Define the sprite manager to render
  36816. */
  36817. dispatchSprites(spriteManager: ISpriteManager): void;
  36818. /**
  36819. * Add a particle system to the rendering manager in order to render it this frame.
  36820. * @param particleSystem Define the particle system to render
  36821. */
  36822. dispatchParticles(particleSystem: IParticleSystem): void;
  36823. /**
  36824. * Add a submesh to the manager in order to render it this frame
  36825. * @param subMesh The submesh to dispatch
  36826. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36827. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36828. */
  36829. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36830. /**
  36831. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36832. * This allowed control for front to back rendering or reversly depending of the special needs.
  36833. *
  36834. * @param renderingGroupId The rendering group id corresponding to its index
  36835. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36836. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36837. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36838. */
  36839. 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;
  36840. /**
  36841. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36842. *
  36843. * @param renderingGroupId The rendering group id corresponding to its index
  36844. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36845. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36846. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36847. */
  36848. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36849. /**
  36850. * Gets the current auto clear configuration for one rendering group of the rendering
  36851. * manager.
  36852. * @param index the rendering group index to get the information for
  36853. * @returns The auto clear setup for the requested rendering group
  36854. */
  36855. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36856. }
  36857. }
  36858. declare module BABYLON {
  36859. /**
  36860. * Renders a layer on top of an existing scene
  36861. */
  36862. class UtilityLayerRenderer implements IDisposable {
  36863. /** the original scene that will be rendered on top of */
  36864. originalScene: Scene;
  36865. private _pointerCaptures;
  36866. private _lastPointerEvents;
  36867. private static _DefaultUtilityLayer;
  36868. private static _DefaultKeepDepthUtilityLayer;
  36869. /**
  36870. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  36871. */
  36872. pickUtilitySceneFirst: boolean;
  36873. /**
  36874. * 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)
  36875. */
  36876. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36877. /**
  36878. * 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)
  36879. */
  36880. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36881. /**
  36882. * The scene that is rendered on top of the original scene
  36883. */
  36884. utilityLayerScene: Scene;
  36885. /**
  36886. * If the utility layer should automatically be rendered on top of existing scene
  36887. */
  36888. shouldRender: boolean;
  36889. /**
  36890. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36891. */
  36892. onlyCheckPointerDownEvents: boolean;
  36893. /**
  36894. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36895. */
  36896. processAllEvents: boolean;
  36897. /**
  36898. * Observable raised when the pointer move from the utility layer scene to the main scene
  36899. */
  36900. onPointerOutObservable: Observable<number>;
  36901. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36902. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36903. private _afterRenderObserver;
  36904. private _sceneDisposeObserver;
  36905. private _originalPointerObserver;
  36906. /**
  36907. * Instantiates a UtilityLayerRenderer
  36908. * @param originalScene the original scene that will be rendered on top of
  36909. * @param handleEvents boolean indicating if the utility layer should handle events
  36910. */
  36911. constructor(
  36912. /** the original scene that will be rendered on top of */
  36913. originalScene: Scene, handleEvents?: boolean);
  36914. private _notifyObservers;
  36915. /**
  36916. * Renders the utility layers scene on top of the original scene
  36917. */
  36918. render(): void;
  36919. /**
  36920. * Disposes of the renderer
  36921. */
  36922. dispose(): void;
  36923. private _updateCamera;
  36924. }
  36925. }
  36926. declare module BABYLON {
  36927. /**
  36928. * Class used to represent a sprite
  36929. * @see http://doc.babylonjs.com/babylon101/sprites
  36930. */
  36931. class Sprite {
  36932. /** defines the name */
  36933. name: string;
  36934. /** Gets or sets the current world position */
  36935. position: Vector3;
  36936. /** Gets or sets the main color */
  36937. color: Color4;
  36938. /** Gets or sets the width */
  36939. width: number;
  36940. /** Gets or sets the height */
  36941. height: number;
  36942. /** Gets or sets rotation angle */
  36943. angle: number;
  36944. /** Gets or sets the cell index in the sprite sheet */
  36945. cellIndex: number;
  36946. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36947. invertU: number;
  36948. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36949. invertV: number;
  36950. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36951. disposeWhenFinishedAnimating: boolean;
  36952. /** Gets the list of attached animations */
  36953. animations: Animation[];
  36954. /** Gets or sets a boolean indicating if the sprite can be picked */
  36955. isPickable: boolean;
  36956. /**
  36957. * Gets or sets the associated action manager
  36958. */
  36959. actionManager: Nullable<ActionManager>;
  36960. private _animationStarted;
  36961. private _loopAnimation;
  36962. private _fromIndex;
  36963. private _toIndex;
  36964. private _delay;
  36965. private _direction;
  36966. private _manager;
  36967. private _time;
  36968. private _onAnimationEnd;
  36969. /**
  36970. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36971. */
  36972. isVisible: boolean;
  36973. /**
  36974. * Gets or sets the sprite size
  36975. */
  36976. size: number;
  36977. /**
  36978. * Creates a new Sprite
  36979. * @param name defines the name
  36980. * @param manager defines the manager
  36981. */
  36982. constructor(
  36983. /** defines the name */
  36984. name: string, manager: ISpriteManager);
  36985. /**
  36986. * Starts an animation
  36987. * @param from defines the initial key
  36988. * @param to defines the end key
  36989. * @param loop defines if the animation must loop
  36990. * @param delay defines the start delay (in ms)
  36991. * @param onAnimationEnd defines a callback to call when animation ends
  36992. */
  36993. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36994. /** Stops current animation (if any) */
  36995. stopAnimation(): void;
  36996. /** @hidden */
  36997. _animate(deltaTime: number): void;
  36998. /** Release associated resources */
  36999. dispose(): void;
  37000. }
  37001. }
  37002. declare module BABYLON {
  37003. /**
  37004. * Defines the minimum interface to fullfil in order to be a sprite manager.
  37005. */
  37006. interface ISpriteManager extends IDisposable {
  37007. /**
  37008. * Restricts the camera to viewing objects with the same layerMask.
  37009. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  37010. */
  37011. layerMask: number;
  37012. /**
  37013. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37014. */
  37015. isPickable: boolean;
  37016. /**
  37017. * Specifies the rendering group id for this mesh (0 by default)
  37018. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37019. */
  37020. renderingGroupId: number;
  37021. /**
  37022. * Defines the list of sprites managed by the manager.
  37023. */
  37024. sprites: Array<Sprite>;
  37025. /**
  37026. * Tests the intersection of a sprite with a specific ray.
  37027. * @param ray The ray we are sending to test the collision
  37028. * @param camera The camera space we are sending rays in
  37029. * @param predicate A predicate allowing excluding sprites from the list of object to test
  37030. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  37031. * @returns picking info or null.
  37032. */
  37033. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37034. /**
  37035. * Renders the list of sprites on screen.
  37036. */
  37037. render(): void;
  37038. }
  37039. /**
  37040. * Class used to manage multiple sprites on the same spritesheet
  37041. * @see http://doc.babylonjs.com/babylon101/sprites
  37042. */
  37043. class SpriteManager implements ISpriteManager {
  37044. /** defines the manager's name */
  37045. name: string;
  37046. /** Gets the list of sprites */
  37047. sprites: Sprite[];
  37048. /** Gets or sets the rendering group id (0 by default) */
  37049. renderingGroupId: number;
  37050. /** Gets or sets camera layer mask */
  37051. layerMask: number;
  37052. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  37053. fogEnabled: boolean;
  37054. /** Gets or sets a boolean indicating if the sprites are pickable */
  37055. isPickable: boolean;
  37056. /** Defines the default width of a cell in the spritesheet */
  37057. cellWidth: number;
  37058. /** Defines the default height of a cell in the spritesheet */
  37059. cellHeight: number;
  37060. /**
  37061. * An event triggered when the manager is disposed.
  37062. */
  37063. onDisposeObservable: Observable<SpriteManager>;
  37064. private _onDisposeObserver;
  37065. /**
  37066. * Callback called when the manager is disposed
  37067. */
  37068. onDispose: () => void;
  37069. private _capacity;
  37070. private _spriteTexture;
  37071. private _epsilon;
  37072. private _scene;
  37073. private _vertexData;
  37074. private _buffer;
  37075. private _vertexBuffers;
  37076. private _indexBuffer;
  37077. private _effectBase;
  37078. private _effectFog;
  37079. /**
  37080. * Gets or sets the spritesheet texture
  37081. */
  37082. texture: Texture;
  37083. /**
  37084. * Creates a new sprite manager
  37085. * @param name defines the manager's name
  37086. * @param imgUrl defines the sprite sheet url
  37087. * @param capacity defines the maximum allowed number of sprites
  37088. * @param cellSize defines the size of a sprite cell
  37089. * @param scene defines the hosting scene
  37090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  37091. * @param samplingMode defines the smapling mode to use with spritesheet
  37092. */
  37093. constructor(
  37094. /** defines the manager's name */
  37095. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  37096. private _appendSpriteVertex;
  37097. /**
  37098. * Intersects the sprites with a ray
  37099. * @param ray defines the ray to intersect with
  37100. * @param camera defines the current active camera
  37101. * @param predicate defines a predicate used to select candidate sprites
  37102. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  37103. * @returns null if no hit or a PickingInfo
  37104. */
  37105. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37106. /**
  37107. * Render all child sprites
  37108. */
  37109. render(): void;
  37110. /**
  37111. * Release associated resources
  37112. */
  37113. dispose(): void;
  37114. }
  37115. }
  37116. declare module BABYLON {
  37117. interface Scene {
  37118. /** @hidden */
  37119. _pointerOverSprite: Nullable<Sprite>;
  37120. /** @hidden */
  37121. _pickedDownSprite: Nullable<Sprite>;
  37122. /** @hidden */
  37123. _tempSpritePickingRay: Nullable<Ray>;
  37124. /**
  37125. * All of the sprite managers added to this scene
  37126. * @see http://doc.babylonjs.com/babylon101/sprites
  37127. */
  37128. spriteManagers: Array<ISpriteManager>;
  37129. /**
  37130. * An event triggered when sprites rendering is about to start
  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. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37134. /**
  37135. * An event triggered when sprites rendering is done
  37136. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37137. */
  37138. onAfterSpritesRenderingObservable: Observable<Scene>;
  37139. /** @hidden */
  37140. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37141. /** Launch a ray to try to pick a sprite in the scene
  37142. * @param x position on screen
  37143. * @param y position on screen
  37144. * @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
  37145. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37146. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37147. * @returns a PickingInfo
  37148. */
  37149. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37150. /** Use the given ray to pick a sprite in the scene
  37151. * @param ray The ray (in world space) to use to pick meshes
  37152. * @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
  37153. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37154. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37155. * @returns a PickingInfo
  37156. */
  37157. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37158. /**
  37159. * Force the sprite under the pointer
  37160. * @param sprite defines the sprite to use
  37161. */
  37162. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37163. /**
  37164. * Gets the sprite under the pointer
  37165. * @returns a Sprite or null if no sprite is under the pointer
  37166. */
  37167. getPointerOverSprite(): Nullable<Sprite>;
  37168. }
  37169. /**
  37170. * Defines the sprite scene component responsible to manage sprites
  37171. * in a given scene.
  37172. */
  37173. class SpriteSceneComponent implements ISceneComponent {
  37174. /**
  37175. * The component name helpfull to identify the component in the list of scene components.
  37176. */
  37177. readonly name: string;
  37178. /**
  37179. * The scene the component belongs to.
  37180. */
  37181. scene: Scene;
  37182. /** @hidden */
  37183. private _spritePredicate;
  37184. /**
  37185. * Creates a new instance of the component for the given scene
  37186. * @param scene Defines the scene to register the component in
  37187. */
  37188. constructor(scene: Scene);
  37189. /**
  37190. * Registers the component in a given scene
  37191. */
  37192. register(): void;
  37193. /**
  37194. * Rebuilds the elements related to this component in case of
  37195. * context lost for instance.
  37196. */
  37197. rebuild(): void;
  37198. /**
  37199. * Disposes the component and the associated ressources.
  37200. */
  37201. dispose(): void;
  37202. private _pickSpriteButKeepRay;
  37203. private _pointerMove;
  37204. private _pointerDown;
  37205. private _pointerUp;
  37206. }
  37207. }
  37208. declare module BABYLON {
  37209. /**
  37210. * @hidden
  37211. **/
  37212. class _AlphaState {
  37213. private _isAlphaBlendDirty;
  37214. private _isBlendFunctionParametersDirty;
  37215. private _isBlendEquationParametersDirty;
  37216. private _isBlendConstantsDirty;
  37217. private _alphaBlend;
  37218. private _blendFunctionParameters;
  37219. private _blendEquationParameters;
  37220. private _blendConstants;
  37221. /**
  37222. * Initializes the state.
  37223. */
  37224. constructor();
  37225. readonly isDirty: boolean;
  37226. alphaBlend: boolean;
  37227. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37228. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37229. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37230. reset(): void;
  37231. apply(gl: WebGLRenderingContext): void;
  37232. }
  37233. }
  37234. declare module BABYLON {
  37235. /**
  37236. * @hidden
  37237. **/
  37238. class _DepthCullingState {
  37239. private _isDepthTestDirty;
  37240. private _isDepthMaskDirty;
  37241. private _isDepthFuncDirty;
  37242. private _isCullFaceDirty;
  37243. private _isCullDirty;
  37244. private _isZOffsetDirty;
  37245. private _isFrontFaceDirty;
  37246. private _depthTest;
  37247. private _depthMask;
  37248. private _depthFunc;
  37249. private _cull;
  37250. private _cullFace;
  37251. private _zOffset;
  37252. private _frontFace;
  37253. /**
  37254. * Initializes the state.
  37255. */
  37256. constructor();
  37257. readonly isDirty: boolean;
  37258. zOffset: number;
  37259. cullFace: Nullable<number>;
  37260. cull: Nullable<boolean>;
  37261. depthFunc: Nullable<number>;
  37262. depthMask: boolean;
  37263. depthTest: boolean;
  37264. frontFace: Nullable<number>;
  37265. reset(): void;
  37266. apply(gl: WebGLRenderingContext): void;
  37267. }
  37268. }
  37269. declare module BABYLON {
  37270. /**
  37271. * @hidden
  37272. **/
  37273. class _StencilState {
  37274. private _isStencilTestDirty;
  37275. private _isStencilMaskDirty;
  37276. private _isStencilFuncDirty;
  37277. private _isStencilOpDirty;
  37278. private _stencilTest;
  37279. private _stencilMask;
  37280. private _stencilFunc;
  37281. private _stencilFuncRef;
  37282. private _stencilFuncMask;
  37283. private _stencilOpStencilFail;
  37284. private _stencilOpDepthFail;
  37285. private _stencilOpStencilDepthPass;
  37286. readonly isDirty: boolean;
  37287. stencilFunc: number;
  37288. stencilFuncRef: number;
  37289. stencilFuncMask: number;
  37290. stencilOpStencilFail: number;
  37291. stencilOpDepthFail: number;
  37292. stencilOpStencilDepthPass: number;
  37293. stencilMask: number;
  37294. stencilTest: boolean;
  37295. constructor();
  37296. reset(): void;
  37297. apply(gl: WebGLRenderingContext): void;
  37298. }
  37299. }
  37300. declare module BABYLON {
  37301. /**
  37302. * Class used to evalaute queries containing `and` and `or` operators
  37303. */
  37304. class AndOrNotEvaluator {
  37305. /**
  37306. * Evaluate a query
  37307. * @param query defines the query to evaluate
  37308. * @param evaluateCallback defines the callback used to filter result
  37309. * @returns true if the query matches
  37310. */
  37311. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37312. private static _HandleParenthesisContent;
  37313. private static _SimplifyNegation;
  37314. }
  37315. }
  37316. declare module BABYLON {
  37317. /**
  37318. * Defines the list of states available for a task inside a AssetsManager
  37319. */
  37320. enum AssetTaskState {
  37321. /**
  37322. * Initialization
  37323. */
  37324. INIT = 0,
  37325. /**
  37326. * Running
  37327. */
  37328. RUNNING = 1,
  37329. /**
  37330. * Done
  37331. */
  37332. DONE = 2,
  37333. /**
  37334. * Error
  37335. */
  37336. ERROR = 3
  37337. }
  37338. /**
  37339. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37340. */
  37341. abstract class AbstractAssetTask {
  37342. /**
  37343. * Task name
  37344. */ name: string;
  37345. /**
  37346. * Callback called when the task is successful
  37347. */
  37348. onSuccess: (task: any) => void;
  37349. /**
  37350. * Callback called when the task is not successful
  37351. */
  37352. onError: (task: any, message?: string, exception?: any) => void;
  37353. /**
  37354. * Creates a new AssetsManager
  37355. * @param name defines the name of the task
  37356. */
  37357. constructor(
  37358. /**
  37359. * Task name
  37360. */ name: string);
  37361. private _isCompleted;
  37362. private _taskState;
  37363. private _errorObject;
  37364. /**
  37365. * Get if the task is completed
  37366. */
  37367. readonly isCompleted: boolean;
  37368. /**
  37369. * Gets the current state of the task
  37370. */
  37371. readonly taskState: AssetTaskState;
  37372. /**
  37373. * Gets the current error object (if task is in error)
  37374. */
  37375. readonly errorObject: {
  37376. message?: string;
  37377. exception?: any;
  37378. };
  37379. /**
  37380. * Internal only
  37381. * @hidden
  37382. */
  37383. _setErrorObject(message?: string, exception?: any): void;
  37384. /**
  37385. * Execute the current task
  37386. * @param scene defines the scene where you want your assets to be loaded
  37387. * @param onSuccess is a callback called when the task is successfully executed
  37388. * @param onError is a callback called if an error occurs
  37389. */
  37390. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37391. /**
  37392. * Execute the current task
  37393. * @param scene defines the scene where you want your assets to be loaded
  37394. * @param onSuccess is a callback called when the task is successfully executed
  37395. * @param onError is a callback called if an error occurs
  37396. */
  37397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37398. /**
  37399. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37400. * This can be used with failed tasks that have the reason for failure fixed.
  37401. */
  37402. reset(): void;
  37403. private onErrorCallback;
  37404. private onDoneCallback;
  37405. }
  37406. /**
  37407. * Define the interface used by progress events raised during assets loading
  37408. */
  37409. interface IAssetsProgressEvent {
  37410. /**
  37411. * Defines the number of remaining tasks to process
  37412. */
  37413. remainingCount: number;
  37414. /**
  37415. * Defines the total number of tasks
  37416. */
  37417. totalCount: number;
  37418. /**
  37419. * Defines the task that was just processed
  37420. */
  37421. task: AbstractAssetTask;
  37422. }
  37423. /**
  37424. * Class used to share progress information about assets loading
  37425. */
  37426. class AssetsProgressEvent implements IAssetsProgressEvent {
  37427. /**
  37428. * Defines the number of remaining tasks to process
  37429. */
  37430. remainingCount: number;
  37431. /**
  37432. * Defines the total number of tasks
  37433. */
  37434. totalCount: number;
  37435. /**
  37436. * Defines the task that was just processed
  37437. */
  37438. task: AbstractAssetTask;
  37439. /**
  37440. * Creates a AssetsProgressEvent
  37441. * @param remainingCount defines the number of remaining tasks to process
  37442. * @param totalCount defines the total number of tasks
  37443. * @param task defines the task that was just processed
  37444. */
  37445. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37446. }
  37447. /**
  37448. * Define a task used by AssetsManager to load meshes
  37449. */
  37450. class MeshAssetTask extends AbstractAssetTask {
  37451. /**
  37452. * Defines the name of the task
  37453. */
  37454. name: string;
  37455. /**
  37456. * Defines the list of mesh's names you want to load
  37457. */
  37458. meshesNames: any;
  37459. /**
  37460. * Defines the root url to use as a base to load your meshes and associated resources
  37461. */
  37462. rootUrl: string;
  37463. /**
  37464. * Defines the filename of the scene to load from
  37465. */
  37466. sceneFilename: string;
  37467. /**
  37468. * Gets the list of loaded meshes
  37469. */
  37470. loadedMeshes: Array<AbstractMesh>;
  37471. /**
  37472. * Gets the list of loaded particle systems
  37473. */
  37474. loadedParticleSystems: Array<IParticleSystem>;
  37475. /**
  37476. * Gets the list of loaded skeletons
  37477. */
  37478. loadedSkeletons: Array<Skeleton>;
  37479. /**
  37480. * Callback called when the task is successful
  37481. */
  37482. onSuccess: (task: MeshAssetTask) => void;
  37483. /**
  37484. * Callback called when the task is successful
  37485. */
  37486. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37487. /**
  37488. * Creates a new MeshAssetTask
  37489. * @param name defines the name of the task
  37490. * @param meshesNames defines the list of mesh's names you want to load
  37491. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37492. * @param sceneFilename defines the filename of the scene to load from
  37493. */
  37494. constructor(
  37495. /**
  37496. * Defines the name of the task
  37497. */
  37498. name: string,
  37499. /**
  37500. * Defines the list of mesh's names you want to load
  37501. */
  37502. meshesNames: any,
  37503. /**
  37504. * Defines the root url to use as a base to load your meshes and associated resources
  37505. */
  37506. rootUrl: string,
  37507. /**
  37508. * Defines the filename of the scene to load from
  37509. */
  37510. sceneFilename: string);
  37511. /**
  37512. * Execute the current task
  37513. * @param scene defines the scene where you want your assets to be loaded
  37514. * @param onSuccess is a callback called when the task is successfully executed
  37515. * @param onError is a callback called if an error occurs
  37516. */
  37517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37518. }
  37519. /**
  37520. * Define a task used by AssetsManager to load text content
  37521. */
  37522. class TextFileAssetTask extends AbstractAssetTask {
  37523. /**
  37524. * Defines the name of the task
  37525. */
  37526. name: string;
  37527. /**
  37528. * Defines the location of the file to load
  37529. */
  37530. url: string;
  37531. /**
  37532. * Gets the loaded text string
  37533. */
  37534. text: string;
  37535. /**
  37536. * Callback called when the task is successful
  37537. */
  37538. onSuccess: (task: TextFileAssetTask) => void;
  37539. /**
  37540. * Callback called when the task is successful
  37541. */
  37542. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37543. /**
  37544. * Creates a new TextFileAssetTask object
  37545. * @param name defines the name of the task
  37546. * @param url defines the location of the file to load
  37547. */
  37548. constructor(
  37549. /**
  37550. * Defines the name of the task
  37551. */
  37552. name: string,
  37553. /**
  37554. * Defines the location of the file to load
  37555. */
  37556. url: string);
  37557. /**
  37558. * Execute the current task
  37559. * @param scene defines the scene where you want your assets to be loaded
  37560. * @param onSuccess is a callback called when the task is successfully executed
  37561. * @param onError is a callback called if an error occurs
  37562. */
  37563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37564. }
  37565. /**
  37566. * Define a task used by AssetsManager to load binary data
  37567. */
  37568. class BinaryFileAssetTask extends AbstractAssetTask {
  37569. /**
  37570. * Defines the name of the task
  37571. */
  37572. name: string;
  37573. /**
  37574. * Defines the location of the file to load
  37575. */
  37576. url: string;
  37577. /**
  37578. * Gets the lodaded data (as an array buffer)
  37579. */
  37580. data: ArrayBuffer;
  37581. /**
  37582. * Callback called when the task is successful
  37583. */
  37584. onSuccess: (task: BinaryFileAssetTask) => void;
  37585. /**
  37586. * Callback called when the task is successful
  37587. */
  37588. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37589. /**
  37590. * Creates a new BinaryFileAssetTask object
  37591. * @param name defines the name of the new task
  37592. * @param url defines the location of the file to load
  37593. */
  37594. constructor(
  37595. /**
  37596. * Defines the name of the task
  37597. */
  37598. name: string,
  37599. /**
  37600. * Defines the location of the file to load
  37601. */
  37602. url: string);
  37603. /**
  37604. * Execute the current task
  37605. * @param scene defines the scene where you want your assets to be loaded
  37606. * @param onSuccess is a callback called when the task is successfully executed
  37607. * @param onError is a callback called if an error occurs
  37608. */
  37609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37610. }
  37611. /**
  37612. * Define a task used by AssetsManager to load images
  37613. */
  37614. class ImageAssetTask extends AbstractAssetTask {
  37615. /**
  37616. * Defines the name of the task
  37617. */
  37618. name: string;
  37619. /**
  37620. * Defines the location of the image to load
  37621. */
  37622. url: string;
  37623. /**
  37624. * Gets the loaded images
  37625. */
  37626. image: HTMLImageElement;
  37627. /**
  37628. * Callback called when the task is successful
  37629. */
  37630. onSuccess: (task: ImageAssetTask) => void;
  37631. /**
  37632. * Callback called when the task is successful
  37633. */
  37634. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37635. /**
  37636. * Creates a new ImageAssetTask
  37637. * @param name defines the name of the task
  37638. * @param url defines the location of the image to load
  37639. */
  37640. constructor(
  37641. /**
  37642. * Defines the name of the task
  37643. */
  37644. name: string,
  37645. /**
  37646. * Defines the location of the image to load
  37647. */
  37648. url: string);
  37649. /**
  37650. * Execute the current task
  37651. * @param scene defines the scene where you want your assets to be loaded
  37652. * @param onSuccess is a callback called when the task is successfully executed
  37653. * @param onError is a callback called if an error occurs
  37654. */
  37655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37656. }
  37657. /**
  37658. * Defines the interface used by texture loading tasks
  37659. */
  37660. interface ITextureAssetTask<TEX extends BaseTexture> {
  37661. /**
  37662. * Gets the loaded texture
  37663. */
  37664. texture: TEX;
  37665. }
  37666. /**
  37667. * Define a task used by AssetsManager to load 2D textures
  37668. */
  37669. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37670. /**
  37671. * Defines the name of the task
  37672. */
  37673. name: string;
  37674. /**
  37675. * Defines the location of the file to load
  37676. */
  37677. url: string;
  37678. /**
  37679. * Defines if mipmap should not be generated (default is false)
  37680. */
  37681. noMipmap?: boolean | undefined;
  37682. /**
  37683. * Defines if texture must be inverted on Y axis (default is false)
  37684. */
  37685. invertY?: boolean | undefined;
  37686. /**
  37687. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37688. */
  37689. samplingMode: number;
  37690. /**
  37691. * Gets the loaded texture
  37692. */
  37693. texture: Texture;
  37694. /**
  37695. * Callback called when the task is successful
  37696. */
  37697. onSuccess: (task: TextureAssetTask) => void;
  37698. /**
  37699. * Callback called when the task is successful
  37700. */
  37701. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37702. /**
  37703. * Creates a new TextureAssetTask object
  37704. * @param name defines the name of the task
  37705. * @param url defines the location of the file to load
  37706. * @param noMipmap defines if mipmap should not be generated (default is false)
  37707. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37708. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37709. */
  37710. constructor(
  37711. /**
  37712. * Defines the name of the task
  37713. */
  37714. name: string,
  37715. /**
  37716. * Defines the location of the file to load
  37717. */
  37718. url: string,
  37719. /**
  37720. * Defines if mipmap should not be generated (default is false)
  37721. */
  37722. noMipmap?: boolean | undefined,
  37723. /**
  37724. * Defines if texture must be inverted on Y axis (default is false)
  37725. */
  37726. invertY?: boolean | undefined,
  37727. /**
  37728. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37729. */
  37730. samplingMode?: number);
  37731. /**
  37732. * Execute the current task
  37733. * @param scene defines the scene where you want your assets to be loaded
  37734. * @param onSuccess is a callback called when the task is successfully executed
  37735. * @param onError is a callback called if an error occurs
  37736. */
  37737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37738. }
  37739. /**
  37740. * Define a task used by AssetsManager to load cube textures
  37741. */
  37742. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37743. /**
  37744. * Defines the name of the task
  37745. */
  37746. name: string;
  37747. /**
  37748. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37749. */
  37750. url: string;
  37751. /**
  37752. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37753. */
  37754. extensions?: string[] | undefined;
  37755. /**
  37756. * Defines if mipmaps should not be generated (default is false)
  37757. */
  37758. noMipmap?: boolean | undefined;
  37759. /**
  37760. * Defines the explicit list of files (undefined by default)
  37761. */
  37762. files?: string[] | undefined;
  37763. /**
  37764. * Gets the loaded texture
  37765. */
  37766. texture: CubeTexture;
  37767. /**
  37768. * Callback called when the task is successful
  37769. */
  37770. onSuccess: (task: CubeTextureAssetTask) => void;
  37771. /**
  37772. * Callback called when the task is successful
  37773. */
  37774. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37775. /**
  37776. * Creates a new CubeTextureAssetTask
  37777. * @param name defines the name of the task
  37778. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37779. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37780. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37781. * @param files defines the explicit list of files (undefined by default)
  37782. */
  37783. constructor(
  37784. /**
  37785. * Defines the name of the task
  37786. */
  37787. name: string,
  37788. /**
  37789. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37790. */
  37791. url: string,
  37792. /**
  37793. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37794. */
  37795. extensions?: string[] | undefined,
  37796. /**
  37797. * Defines if mipmaps should not be generated (default is false)
  37798. */
  37799. noMipmap?: boolean | undefined,
  37800. /**
  37801. * Defines the explicit list of files (undefined by default)
  37802. */
  37803. files?: string[] | undefined);
  37804. /**
  37805. * Execute the current task
  37806. * @param scene defines the scene where you want your assets to be loaded
  37807. * @param onSuccess is a callback called when the task is successfully executed
  37808. * @param onError is a callback called if an error occurs
  37809. */
  37810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37811. }
  37812. /**
  37813. * Define a task used by AssetsManager to load HDR cube textures
  37814. */
  37815. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37816. /**
  37817. * Defines the name of the task
  37818. */
  37819. name: string;
  37820. /**
  37821. * Defines the location of the file to load
  37822. */
  37823. url: string;
  37824. /**
  37825. * Defines the desired size (the more it increases the longer the generation will be)
  37826. */
  37827. size: number;
  37828. /**
  37829. * Defines if mipmaps should not be generated (default is false)
  37830. */
  37831. noMipmap: boolean;
  37832. /**
  37833. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37834. */
  37835. generateHarmonics: boolean;
  37836. /**
  37837. * 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)
  37838. */
  37839. gammaSpace: boolean;
  37840. /**
  37841. * Internal Use Only
  37842. */
  37843. reserved: boolean;
  37844. /**
  37845. * Gets the loaded texture
  37846. */
  37847. texture: HDRCubeTexture;
  37848. /**
  37849. * Callback called when the task is successful
  37850. */
  37851. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37852. /**
  37853. * Callback called when the task is successful
  37854. */
  37855. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37856. /**
  37857. * Creates a new HDRCubeTextureAssetTask object
  37858. * @param name defines the name of the task
  37859. * @param url defines the location of the file to load
  37860. * @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.
  37861. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37862. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37863. * @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)
  37864. * @param reserved Internal use only
  37865. */
  37866. constructor(
  37867. /**
  37868. * Defines the name of the task
  37869. */
  37870. name: string,
  37871. /**
  37872. * Defines the location of the file to load
  37873. */
  37874. url: string,
  37875. /**
  37876. * Defines the desired size (the more it increases the longer the generation will be)
  37877. */
  37878. size: number,
  37879. /**
  37880. * Defines if mipmaps should not be generated (default is false)
  37881. */
  37882. noMipmap?: boolean,
  37883. /**
  37884. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37885. */
  37886. generateHarmonics?: boolean,
  37887. /**
  37888. * 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)
  37889. */
  37890. gammaSpace?: boolean,
  37891. /**
  37892. * Internal Use Only
  37893. */
  37894. reserved?: boolean);
  37895. /**
  37896. * Execute the current task
  37897. * @param scene defines the scene where you want your assets to be loaded
  37898. * @param onSuccess is a callback called when the task is successfully executed
  37899. * @param onError is a callback called if an error occurs
  37900. */
  37901. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37902. }
  37903. /**
  37904. * This class can be used to easily import assets into a scene
  37905. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37906. */
  37907. class AssetsManager {
  37908. private _scene;
  37909. private _isLoading;
  37910. protected _tasks: AbstractAssetTask[];
  37911. protected _waitingTasksCount: number;
  37912. protected _totalTasksCount: number;
  37913. /**
  37914. * Callback called when all tasks are processed
  37915. */
  37916. onFinish: (tasks: AbstractAssetTask[]) => void;
  37917. /**
  37918. * Callback called when a task is successful
  37919. */
  37920. onTaskSuccess: (task: AbstractAssetTask) => void;
  37921. /**
  37922. * Callback called when a task had an error
  37923. */
  37924. onTaskError: (task: AbstractAssetTask) => void;
  37925. /**
  37926. * Callback called when a task is done (whatever the result is)
  37927. */
  37928. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37929. /**
  37930. * Observable called when all tasks are processed
  37931. */
  37932. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37933. /**
  37934. * Observable called when a task had an error
  37935. */
  37936. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37937. /**
  37938. * Observable called when a task is successful
  37939. */
  37940. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37941. /**
  37942. * Observable called when a task is done (whatever the result is)
  37943. */
  37944. onProgressObservable: Observable<IAssetsProgressEvent>;
  37945. /**
  37946. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37948. */
  37949. useDefaultLoadingScreen: boolean;
  37950. /**
  37951. * Creates a new AssetsManager
  37952. * @param scene defines the scene to work on
  37953. */
  37954. constructor(scene: Scene);
  37955. /**
  37956. * Add a MeshAssetTask to the list of active tasks
  37957. * @param taskName defines the name of the new task
  37958. * @param meshesNames defines the name of meshes to load
  37959. * @param rootUrl defines the root url to use to locate files
  37960. * @param sceneFilename defines the filename of the scene file
  37961. * @returns a new MeshAssetTask object
  37962. */
  37963. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37964. /**
  37965. * Add a TextFileAssetTask to the list of active tasks
  37966. * @param taskName defines the name of the new task
  37967. * @param url defines the url of the file to load
  37968. * @returns a new TextFileAssetTask object
  37969. */
  37970. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37971. /**
  37972. * Add a BinaryFileAssetTask to the list of active tasks
  37973. * @param taskName defines the name of the new task
  37974. * @param url defines the url of the file to load
  37975. * @returns a new BinaryFileAssetTask object
  37976. */
  37977. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37978. /**
  37979. * Add a ImageAssetTask to the list of active tasks
  37980. * @param taskName defines the name of the new task
  37981. * @param url defines the url of the file to load
  37982. * @returns a new ImageAssetTask object
  37983. */
  37984. addImageTask(taskName: string, url: string): ImageAssetTask;
  37985. /**
  37986. * Add a TextureAssetTask to the list of active tasks
  37987. * @param taskName defines the name of the new task
  37988. * @param url defines the url of the file to load
  37989. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37990. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37991. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37992. * @returns a new TextureAssetTask object
  37993. */
  37994. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37995. /**
  37996. * Add a CubeTextureAssetTask to the list of active tasks
  37997. * @param taskName defines the name of the new task
  37998. * @param url defines the url of the file to load
  37999. * @param extensions defines the extension to use to load the cube map (can be null)
  38000. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38001. * @param files defines the list of files to load (can be null)
  38002. * @returns a new CubeTextureAssetTask object
  38003. */
  38004. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  38005. /**
  38006. *
  38007. * Add a HDRCubeTextureAssetTask to the list of active tasks
  38008. * @param taskName defines the name of the new task
  38009. * @param url defines the url of the file to load
  38010. * @param size defines the size you want for the cubemap (can be null)
  38011. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38012. * @param generateHarmonics defines if you want to automatically generate (true by default)
  38013. * @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)
  38014. * @param reserved Internal use only
  38015. * @returns a new HDRCubeTextureAssetTask object
  38016. */
  38017. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  38018. /**
  38019. * Remove a task from the assets manager.
  38020. * @param task the task to remove
  38021. */
  38022. removeTask(task: AbstractAssetTask): void;
  38023. private _decreaseWaitingTasksCount;
  38024. private _runTask;
  38025. /**
  38026. * Reset the AssetsManager and remove all tasks
  38027. * @return the current instance of the AssetsManager
  38028. */
  38029. reset(): AssetsManager;
  38030. /**
  38031. * Start the loading process
  38032. * @return the current instance of the AssetsManager
  38033. */
  38034. load(): AssetsManager;
  38035. }
  38036. }
  38037. declare module BABYLON {
  38038. /**
  38039. * Direct draw surface info
  38040. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  38041. */
  38042. interface DDSInfo {
  38043. /**
  38044. * Width of the texture
  38045. */
  38046. width: number;
  38047. /**
  38048. * Width of the texture
  38049. */
  38050. height: number;
  38051. /**
  38052. * Number of Mipmaps for the texture
  38053. * @see https://en.wikipedia.org/wiki/Mipmap
  38054. */
  38055. mipmapCount: number;
  38056. /**
  38057. * If the textures format is a known fourCC format
  38058. * @see https://www.fourcc.org/
  38059. */
  38060. isFourCC: boolean;
  38061. /**
  38062. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  38063. */
  38064. isRGB: boolean;
  38065. /**
  38066. * If the texture is a lumincance format
  38067. */
  38068. isLuminance: boolean;
  38069. /**
  38070. * If this is a cube texture
  38071. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  38072. */
  38073. isCube: boolean;
  38074. /**
  38075. * If the texture is a compressed format eg. FOURCC_DXT1
  38076. */
  38077. isCompressed: boolean;
  38078. /**
  38079. * The dxgiFormat of the texture
  38080. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38081. */
  38082. dxgiFormat: number;
  38083. /**
  38084. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38085. */
  38086. textureType: number;
  38087. /**
  38088. * Sphericle polynomial created for the dds texture
  38089. */
  38090. sphericalPolynomial?: SphericalPolynomial;
  38091. }
  38092. /**
  38093. * Class used to provide DDS decompression tools
  38094. */
  38095. class DDSTools {
  38096. /**
  38097. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38098. */
  38099. static StoreLODInAlphaChannel: boolean;
  38100. /**
  38101. * Gets DDS information from an array buffer
  38102. * @param arrayBuffer defines the array buffer to read data from
  38103. * @returns the DDS information
  38104. */
  38105. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38106. private static _FloatView;
  38107. private static _Int32View;
  38108. private static _ToHalfFloat;
  38109. private static _FromHalfFloat;
  38110. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38111. private static _GetHalfFloatRGBAArrayBuffer;
  38112. private static _GetFloatRGBAArrayBuffer;
  38113. private static _GetFloatAsUIntRGBAArrayBuffer;
  38114. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38115. private static _GetRGBAArrayBuffer;
  38116. private static _ExtractLongWordOrder;
  38117. private static _GetRGBArrayBuffer;
  38118. private static _GetLuminanceArrayBuffer;
  38119. /**
  38120. * Uploads DDS Levels to a Babylon Texture
  38121. * @hidden
  38122. */
  38123. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38124. }
  38125. }
  38126. declare module BABYLON {
  38127. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38128. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38129. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38130. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38131. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38132. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38133. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38134. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38135. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38136. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38137. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38138. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38139. /**
  38140. * Decorator used to define property that can be serialized as reference to a camera
  38141. * @param sourceName defines the name of the property to decorate
  38142. */
  38143. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38144. /**
  38145. * Class used to help serialization objects
  38146. */
  38147. class SerializationHelper {
  38148. /**
  38149. * Static function used to serialized a specific entity
  38150. * @param entity defines the entity to serialize
  38151. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38152. * @returns a JSON compatible object representing the serialization of the entity
  38153. */
  38154. static Serialize<T>(entity: T, serializationObject?: any): any;
  38155. /**
  38156. * Creates a new entity from a serialization data object
  38157. * @param creationFunction defines a function used to instanciated the new entity
  38158. * @param source defines the source serialization data
  38159. * @param scene defines the hosting scene
  38160. * @param rootUrl defines the root url for resources
  38161. * @returns a new entity
  38162. */
  38163. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38164. /**
  38165. * Clones an object
  38166. * @param creationFunction defines the function used to instanciate the new object
  38167. * @param source defines the source object
  38168. * @returns the cloned object
  38169. */
  38170. static Clone<T>(creationFunction: () => T, source: T): T;
  38171. /**
  38172. * Instanciates a new object based on a source one (some data will be shared between both object)
  38173. * @param creationFunction defines the function used to instanciate the new object
  38174. * @param source defines the source object
  38175. * @returns the new object
  38176. */
  38177. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38178. }
  38179. }
  38180. declare module BABYLON {
  38181. /**
  38182. * Wrapper class for promise with external resolve and reject.
  38183. */
  38184. class Deferred<T> {
  38185. /**
  38186. * The promise associated with this deferred object.
  38187. */
  38188. readonly promise: Promise<T>;
  38189. private _resolve;
  38190. private _reject;
  38191. /**
  38192. * The resolve method of the promise associated with this deferred object.
  38193. */
  38194. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38195. /**
  38196. * The reject method of the promise associated with this deferred object.
  38197. */
  38198. readonly reject: (reason?: any) => void;
  38199. /**
  38200. * Constructor for this deferred object.
  38201. */
  38202. constructor();
  38203. }
  38204. }
  38205. declare module BABYLON {
  38206. /**
  38207. * Raw texture data and descriptor sufficient for WebGL texture upload
  38208. */
  38209. interface EnvironmentTextureInfo {
  38210. /**
  38211. * Version of the environment map
  38212. */
  38213. version: number;
  38214. /**
  38215. * Width of image
  38216. */
  38217. width: number;
  38218. /**
  38219. * Irradiance information stored in the file.
  38220. */
  38221. irradiance: any;
  38222. /**
  38223. * Specular information stored in the file.
  38224. */
  38225. specular: any;
  38226. }
  38227. /**
  38228. * Sets of helpers addressing the serialization and deserialization of environment texture
  38229. * stored in a BabylonJS env file.
  38230. * Those files are usually stored as .env files.
  38231. */
  38232. class EnvironmentTextureTools {
  38233. /**
  38234. * Magic number identifying the env file.
  38235. */
  38236. private static _MagicBytes;
  38237. /**
  38238. * Gets the environment info from an env file.
  38239. * @param data The array buffer containing the .env bytes.
  38240. * @returns the environment file info (the json header) if successfully parsed.
  38241. */
  38242. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38243. /**
  38244. * Creates an environment texture from a loaded cube texture.
  38245. * @param texture defines the cube texture to convert in env file
  38246. * @return a promise containing the environment data if succesfull.
  38247. */
  38248. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38249. /**
  38250. * Creates a JSON representation of the spherical data.
  38251. * @param texture defines the texture containing the polynomials
  38252. * @return the JSON representation of the spherical info
  38253. */
  38254. private static _CreateEnvTextureIrradiance;
  38255. /**
  38256. * Uploads the texture info contained in the env file to the GPU.
  38257. * @param texture defines the internal texture to upload to
  38258. * @param arrayBuffer defines the buffer cotaining the data to load
  38259. * @param info defines the texture info retrieved through the GetEnvInfo method
  38260. * @returns a promise
  38261. */
  38262. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38263. /**
  38264. * Uploads the levels of image data to the GPU.
  38265. * @param texture defines the internal texture to upload to
  38266. * @param imageData defines the array buffer views of image data [mipmap][face]
  38267. * @returns a promise
  38268. */
  38269. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38270. /**
  38271. * Uploads spherical polynomials information to the texture.
  38272. * @param texture defines the texture we are trying to upload the information to
  38273. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38274. */
  38275. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38276. }
  38277. }
  38278. declare module BABYLON {
  38279. /**
  38280. * Class used to help managing file picking and drag'n'drop
  38281. */
  38282. class FilesInput {
  38283. /**
  38284. * List of files ready to be loaded
  38285. */
  38286. static FilesToLoad: {
  38287. [key: string]: File;
  38288. };
  38289. /**
  38290. * Callback called when a file is processed
  38291. */
  38292. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38293. private _engine;
  38294. private _currentScene;
  38295. private _sceneLoadedCallback;
  38296. private _progressCallback;
  38297. private _additionalRenderLoopLogicCallback;
  38298. private _textureLoadingCallback;
  38299. private _startingProcessingFilesCallback;
  38300. private _onReloadCallback;
  38301. private _errorCallback;
  38302. private _elementToMonitor;
  38303. private _sceneFileToLoad;
  38304. private _filesToLoad;
  38305. /**
  38306. * Creates a new FilesInput
  38307. * @param engine defines the rendering engine
  38308. * @param scene defines the hosting scene
  38309. * @param sceneLoadedCallback callback called when scene is loaded
  38310. * @param progressCallback callback called to track progress
  38311. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38312. * @param textureLoadingCallback callback called when a texture is loading
  38313. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38314. * @param onReloadCallback callback called when a reload is requested
  38315. * @param errorCallback callback call if an error occurs
  38316. */
  38317. 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);
  38318. private _dragEnterHandler;
  38319. private _dragOverHandler;
  38320. private _dropHandler;
  38321. /**
  38322. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38323. * @param elementToMonitor defines the DOM element to track
  38324. */
  38325. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38326. /**
  38327. * Release all associated resources
  38328. */
  38329. dispose(): void;
  38330. private renderFunction;
  38331. private drag;
  38332. private drop;
  38333. private _traverseFolder;
  38334. private _processFiles;
  38335. /**
  38336. * Load files from a drop event
  38337. * @param event defines the drop event to use as source
  38338. */
  38339. loadFiles(event: any): void;
  38340. private _processReload;
  38341. /**
  38342. * Reload the current scene from the loaded files
  38343. */
  38344. reload(): void;
  38345. }
  38346. }
  38347. declare module BABYLON {
  38348. /**
  38349. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38350. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38351. */
  38352. class KhronosTextureContainer {
  38353. /** contents of the KTX container file */
  38354. arrayBuffer: any;
  38355. private static HEADER_LEN;
  38356. private static COMPRESSED_2D;
  38357. private static COMPRESSED_3D;
  38358. private static TEX_2D;
  38359. private static TEX_3D;
  38360. /**
  38361. * Gets the openGL type
  38362. */
  38363. glType: number;
  38364. /**
  38365. * Gets the openGL type size
  38366. */
  38367. glTypeSize: number;
  38368. /**
  38369. * Gets the openGL format
  38370. */
  38371. glFormat: number;
  38372. /**
  38373. * Gets the openGL internal format
  38374. */
  38375. glInternalFormat: number;
  38376. /**
  38377. * Gets the base internal format
  38378. */
  38379. glBaseInternalFormat: number;
  38380. /**
  38381. * Gets image width in pixel
  38382. */
  38383. pixelWidth: number;
  38384. /**
  38385. * Gets image height in pixel
  38386. */
  38387. pixelHeight: number;
  38388. /**
  38389. * Gets image depth in pixels
  38390. */
  38391. pixelDepth: number;
  38392. /**
  38393. * Gets the number of array elements
  38394. */
  38395. numberOfArrayElements: number;
  38396. /**
  38397. * Gets the number of faces
  38398. */
  38399. numberOfFaces: number;
  38400. /**
  38401. * Gets the number of mipmap levels
  38402. */
  38403. numberOfMipmapLevels: number;
  38404. /**
  38405. * Gets the bytes of key value data
  38406. */
  38407. bytesOfKeyValueData: number;
  38408. /**
  38409. * Gets the load type
  38410. */
  38411. loadType: number;
  38412. /**
  38413. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38414. */
  38415. isInvalid: boolean;
  38416. /**
  38417. * Creates a new KhronosTextureContainer
  38418. * @param arrayBuffer contents of the KTX container file
  38419. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38420. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38421. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38422. */
  38423. constructor(
  38424. /** contents of the KTX container file */
  38425. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38426. /**
  38427. * Uploads KTX content to a Babylon Texture.
  38428. * It is assumed that the texture has already been created & is currently bound
  38429. * @hidden
  38430. */
  38431. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38432. private _upload2DCompressedLevels;
  38433. }
  38434. }
  38435. declare module BABYLON {
  38436. /**
  38437. * A class serves as a medium between the observable and its observers
  38438. */
  38439. class EventState {
  38440. /**
  38441. * Create a new EventState
  38442. * @param mask defines the mask associated with this state
  38443. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38444. * @param target defines the original target of the state
  38445. * @param currentTarget defines the current target of the state
  38446. */
  38447. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38448. /**
  38449. * Initialize the current event state
  38450. * @param mask defines the mask associated with this state
  38451. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38452. * @param target defines the original target of the state
  38453. * @param currentTarget defines the current target of the state
  38454. * @returns the current event state
  38455. */
  38456. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38457. /**
  38458. * An Observer can set this property to true to prevent subsequent observers of being notified
  38459. */
  38460. skipNextObservers: boolean;
  38461. /**
  38462. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38463. */
  38464. mask: number;
  38465. /**
  38466. * The object that originally notified the event
  38467. */
  38468. target?: any;
  38469. /**
  38470. * The current object in the bubbling phase
  38471. */
  38472. currentTarget?: any;
  38473. /**
  38474. * This will be populated with the return value of the last function that was executed.
  38475. * If it is the first function in the callback chain it will be the event data.
  38476. */
  38477. lastReturnValue?: any;
  38478. }
  38479. /**
  38480. * Represent an Observer registered to a given Observable object.
  38481. */
  38482. class Observer<T> {
  38483. /**
  38484. * Defines the callback to call when the observer is notified
  38485. */
  38486. callback: (eventData: T, eventState: EventState) => void;
  38487. /**
  38488. * Defines the mask of the observer (used to filter notifications)
  38489. */
  38490. mask: number;
  38491. /**
  38492. * Defines the current scope used to restore the JS context
  38493. */
  38494. scope: any;
  38495. /** @hidden */
  38496. _willBeUnregistered: boolean;
  38497. /**
  38498. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38499. */
  38500. unregisterOnNextCall: boolean;
  38501. /**
  38502. * Creates a new observer
  38503. * @param callback defines the callback to call when the observer is notified
  38504. * @param mask defines the mask of the observer (used to filter notifications)
  38505. * @param scope defines the current scope used to restore the JS context
  38506. */
  38507. constructor(
  38508. /**
  38509. * Defines the callback to call when the observer is notified
  38510. */
  38511. callback: (eventData: T, eventState: EventState) => void,
  38512. /**
  38513. * Defines the mask of the observer (used to filter notifications)
  38514. */
  38515. mask: number,
  38516. /**
  38517. * Defines the current scope used to restore the JS context
  38518. */
  38519. scope?: any);
  38520. }
  38521. /**
  38522. * Represent a list of observers registered to multiple Observables object.
  38523. */
  38524. class MultiObserver<T> {
  38525. private _observers;
  38526. private _observables;
  38527. /**
  38528. * Release associated resources
  38529. */
  38530. dispose(): void;
  38531. /**
  38532. * Raise a callback when one of the observable will notify
  38533. * @param observables defines a list of observables to watch
  38534. * @param callback defines the callback to call on notification
  38535. * @param mask defines the mask used to filter notifications
  38536. * @param scope defines the current scope used to restore the JS context
  38537. * @returns the new MultiObserver
  38538. */
  38539. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38540. }
  38541. /**
  38542. * The Observable class is a simple implementation of the Observable pattern.
  38543. *
  38544. * 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.
  38545. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38546. * 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).
  38547. * 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.
  38548. */
  38549. class Observable<T> {
  38550. private _observers;
  38551. private _eventState;
  38552. private _onObserverAdded;
  38553. /**
  38554. * Creates a new observable
  38555. * @param onObserverAdded defines a callback to call when a new observer is added
  38556. */
  38557. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38558. /**
  38559. * Create a new Observer with the specified callback
  38560. * @param callback the callback that will be executed for that Observer
  38561. * @param mask the mask used to filter observers
  38562. * @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.
  38563. * @param scope optional scope for the callback to be called from
  38564. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38565. * @returns the new observer created for the callback
  38566. */
  38567. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38568. /**
  38569. * Create a new Observer with the specified callback and unregisters after the next notification
  38570. * @param callback the callback that will be executed for that Observer
  38571. * @returns the new observer created for the callback
  38572. */
  38573. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38574. /**
  38575. * Remove an Observer from the Observable object
  38576. * @param observer the instance of the Observer to remove
  38577. * @returns false if it doesn't belong to this Observable
  38578. */
  38579. remove(observer: Nullable<Observer<T>>): boolean;
  38580. /**
  38581. * Remove a callback from the Observable object
  38582. * @param callback the callback to remove
  38583. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38584. * @returns false if it doesn't belong to this Observable
  38585. */
  38586. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38587. private _deferUnregister;
  38588. private _remove;
  38589. /**
  38590. * Notify all Observers by calling their respective callback with the given data
  38591. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38592. * @param eventData defines the data to send to all observers
  38593. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38594. * @param target defines the original target of the state
  38595. * @param currentTarget defines the current target of the state
  38596. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38597. */
  38598. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38599. /**
  38600. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38601. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38602. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38603. * and it is crucial that all callbacks will be executed.
  38604. * The order of the callbacks is kept, callbacks are not executed parallel.
  38605. *
  38606. * @param eventData The data to be sent to each callback
  38607. * @param mask is used to filter observers defaults to -1
  38608. * @param target defines the callback target (see EventState)
  38609. * @param currentTarget defines he current object in the bubbling phase
  38610. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38611. */
  38612. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38613. /**
  38614. * Notify a specific observer
  38615. * @param observer defines the observer to notify
  38616. * @param eventData defines the data to be sent to each callback
  38617. * @param mask is used to filter observers defaults to -1
  38618. */
  38619. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38620. /**
  38621. * Gets a boolean indicating if the observable has at least one observer
  38622. * @returns true is the Observable has at least one Observer registered
  38623. */
  38624. hasObservers(): boolean;
  38625. /**
  38626. * Clear the list of observers
  38627. */
  38628. clear(): void;
  38629. /**
  38630. * Clone the current observable
  38631. * @returns a new observable
  38632. */
  38633. clone(): Observable<T>;
  38634. /**
  38635. * Does this observable handles observer registered with a given mask
  38636. * @param mask defines the mask to be tested
  38637. * @return whether or not one observer registered with the given mask is handeled
  38638. **/
  38639. hasSpecificMask(mask?: number): boolean;
  38640. }
  38641. }
  38642. declare module BABYLON {
  38643. /**
  38644. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38645. */
  38646. class PerformanceMonitor {
  38647. private _enabled;
  38648. private _rollingFrameTime;
  38649. private _lastFrameTimeMs;
  38650. /**
  38651. * constructor
  38652. * @param frameSampleSize The number of samples required to saturate the sliding window
  38653. */
  38654. constructor(frameSampleSize?: number);
  38655. /**
  38656. * Samples current frame
  38657. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38658. */
  38659. sampleFrame(timeMs?: number): void;
  38660. /**
  38661. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38662. */
  38663. readonly averageFrameTime: number;
  38664. /**
  38665. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38666. */
  38667. readonly averageFrameTimeVariance: number;
  38668. /**
  38669. * Returns the frame time of the most recent frame
  38670. */
  38671. readonly instantaneousFrameTime: number;
  38672. /**
  38673. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38674. */
  38675. readonly averageFPS: number;
  38676. /**
  38677. * Returns the average framerate in frames per second using the most recent frame time
  38678. */
  38679. readonly instantaneousFPS: number;
  38680. /**
  38681. * Returns true if enough samples have been taken to completely fill the sliding window
  38682. */
  38683. readonly isSaturated: boolean;
  38684. /**
  38685. * Enables contributions to the sliding window sample set
  38686. */
  38687. enable(): void;
  38688. /**
  38689. * Disables contributions to the sliding window sample set
  38690. * Samples will not be interpolated over the disabled period
  38691. */
  38692. disable(): void;
  38693. /**
  38694. * Returns true if sampling is enabled
  38695. */
  38696. readonly isEnabled: boolean;
  38697. /**
  38698. * Resets performance monitor
  38699. */
  38700. reset(): void;
  38701. }
  38702. /**
  38703. * RollingAverage
  38704. *
  38705. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38706. */
  38707. class RollingAverage {
  38708. /**
  38709. * Current average
  38710. */
  38711. average: number;
  38712. /**
  38713. * Current variance
  38714. */
  38715. variance: number;
  38716. protected _samples: Array<number>;
  38717. protected _sampleCount: number;
  38718. protected _pos: number;
  38719. protected _m2: number;
  38720. /**
  38721. * constructor
  38722. * @param length The number of samples required to saturate the sliding window
  38723. */
  38724. constructor(length: number);
  38725. /**
  38726. * Adds a sample to the sample set
  38727. * @param v The sample value
  38728. */
  38729. add(v: number): void;
  38730. /**
  38731. * Returns previously added values or null if outside of history or outside the sliding window domain
  38732. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38733. * @return Value previously recorded with add() or null if outside of range
  38734. */
  38735. history(i: number): number;
  38736. /**
  38737. * Returns true if enough samples have been taken to completely fill the sliding window
  38738. * @return true if sample-set saturated
  38739. */
  38740. isSaturated(): boolean;
  38741. /**
  38742. * Resets the rolling average (equivalent to 0 samples taken so far)
  38743. */
  38744. reset(): void;
  38745. /**
  38746. * Wraps a value around the sample range boundaries
  38747. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38748. * @return Wrapped position in sample range
  38749. */
  38750. protected _wrapPosition(i: number): number;
  38751. }
  38752. }
  38753. declare module BABYLON {
  38754. /**
  38755. * Helper class that provides a small promise polyfill
  38756. */
  38757. class PromisePolyfill {
  38758. /**
  38759. * Static function used to check if the polyfill is required
  38760. * If this is the case then the function will inject the polyfill to window.Promise
  38761. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38762. */
  38763. static Apply(force?: boolean): void;
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /**
  38768. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38769. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38770. */
  38771. class SceneOptimization {
  38772. /**
  38773. * Defines the priority of this optimization (0 by default which means first in the list)
  38774. */
  38775. priority: number;
  38776. /**
  38777. * Gets a string describing the action executed by the current optimization
  38778. * @returns description string
  38779. */
  38780. getDescription(): string;
  38781. /**
  38782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38783. * @param scene defines the current scene where to apply this optimization
  38784. * @param optimizer defines the current optimizer
  38785. * @returns true if everything that can be done was applied
  38786. */
  38787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38788. /**
  38789. * Creates the SceneOptimization object
  38790. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38791. * @param desc defines the description associated with the optimization
  38792. */
  38793. constructor(
  38794. /**
  38795. * Defines the priority of this optimization (0 by default which means first in the list)
  38796. */
  38797. priority?: number);
  38798. }
  38799. /**
  38800. * Defines an optimization used to reduce the size of render target textures
  38801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38802. */
  38803. class TextureOptimization extends SceneOptimization {
  38804. /**
  38805. * Defines the priority of this optimization (0 by default which means first in the list)
  38806. */
  38807. priority: number;
  38808. /**
  38809. * 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
  38810. */
  38811. maximumSize: number;
  38812. /**
  38813. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38814. */
  38815. step: number;
  38816. /**
  38817. * Gets a string describing the action executed by the current optimization
  38818. * @returns description string
  38819. */
  38820. getDescription(): string;
  38821. /**
  38822. * Creates the TextureOptimization object
  38823. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38824. * @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
  38825. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38826. */
  38827. constructor(
  38828. /**
  38829. * Defines the priority of this optimization (0 by default which means first in the list)
  38830. */
  38831. priority?: number,
  38832. /**
  38833. * 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
  38834. */
  38835. maximumSize?: number,
  38836. /**
  38837. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38838. */
  38839. step?: number);
  38840. /**
  38841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38842. * @param scene defines the current scene where to apply this optimization
  38843. * @param optimizer defines the current optimizer
  38844. * @returns true if everything that can be done was applied
  38845. */
  38846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38847. }
  38848. /**
  38849. * Defines an optimization used to increase or decrease the rendering resolution
  38850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38851. */
  38852. class HardwareScalingOptimization extends SceneOptimization {
  38853. /**
  38854. * Defines the priority of this optimization (0 by default which means first in the list)
  38855. */
  38856. priority: number;
  38857. /**
  38858. * Defines the maximum scale to use (2 by default)
  38859. */
  38860. maximumScale: number;
  38861. /**
  38862. * Defines the step to use between two passes (0.5 by default)
  38863. */
  38864. step: number;
  38865. private _currentScale;
  38866. private _directionOffset;
  38867. /**
  38868. * Gets a string describing the action executed by the current optimization
  38869. * @return description string
  38870. */
  38871. getDescription(): string;
  38872. /**
  38873. * Creates the HardwareScalingOptimization object
  38874. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38875. * @param maximumScale defines the maximum scale to use (2 by default)
  38876. * @param step defines the step to use between two passes (0.5 by default)
  38877. */
  38878. constructor(
  38879. /**
  38880. * Defines the priority of this optimization (0 by default which means first in the list)
  38881. */
  38882. priority?: number,
  38883. /**
  38884. * Defines the maximum scale to use (2 by default)
  38885. */
  38886. maximumScale?: number,
  38887. /**
  38888. * Defines the step to use between two passes (0.5 by default)
  38889. */
  38890. step?: number);
  38891. /**
  38892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38893. * @param scene defines the current scene where to apply this optimization
  38894. * @param optimizer defines the current optimizer
  38895. * @returns true if everything that can be done was applied
  38896. */
  38897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38898. }
  38899. /**
  38900. * Defines an optimization used to remove shadows
  38901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38902. */
  38903. class ShadowsOptimization extends SceneOptimization {
  38904. /**
  38905. * Gets a string describing the action executed by the current optimization
  38906. * @return description string
  38907. */
  38908. getDescription(): string;
  38909. /**
  38910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38911. * @param scene defines the current scene where to apply this optimization
  38912. * @param optimizer defines the current optimizer
  38913. * @returns true if everything that can be done was applied
  38914. */
  38915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38916. }
  38917. /**
  38918. * Defines an optimization used to turn post-processes off
  38919. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38920. */
  38921. class PostProcessesOptimization extends SceneOptimization {
  38922. /**
  38923. * Gets a string describing the action executed by the current optimization
  38924. * @return description string
  38925. */
  38926. getDescription(): string;
  38927. /**
  38928. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38929. * @param scene defines the current scene where to apply this optimization
  38930. * @param optimizer defines the current optimizer
  38931. * @returns true if everything that can be done was applied
  38932. */
  38933. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38934. }
  38935. /**
  38936. * Defines an optimization used to turn lens flares off
  38937. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38938. */
  38939. class LensFlaresOptimization extends SceneOptimization {
  38940. /**
  38941. * Gets a string describing the action executed by the current optimization
  38942. * @return description string
  38943. */
  38944. getDescription(): string;
  38945. /**
  38946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38947. * @param scene defines the current scene where to apply this optimization
  38948. * @param optimizer defines the current optimizer
  38949. * @returns true if everything that can be done was applied
  38950. */
  38951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38952. }
  38953. /**
  38954. * Defines an optimization based on user defined callback.
  38955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38956. */
  38957. class CustomOptimization extends SceneOptimization {
  38958. /**
  38959. * Callback called to apply the custom optimization.
  38960. */
  38961. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38962. /**
  38963. * Callback called to get custom description
  38964. */
  38965. onGetDescription: () => string;
  38966. /**
  38967. * Gets a string describing the action executed by the current optimization
  38968. * @returns description string
  38969. */
  38970. getDescription(): string;
  38971. /**
  38972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38973. * @param scene defines the current scene where to apply this optimization
  38974. * @param optimizer defines the current optimizer
  38975. * @returns true if everything that can be done was applied
  38976. */
  38977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38978. }
  38979. /**
  38980. * Defines an optimization used to turn particles off
  38981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38982. */
  38983. class ParticlesOptimization extends SceneOptimization {
  38984. /**
  38985. * Gets a string describing the action executed by the current optimization
  38986. * @return description string
  38987. */
  38988. getDescription(): string;
  38989. /**
  38990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38991. * @param scene defines the current scene where to apply this optimization
  38992. * @param optimizer defines the current optimizer
  38993. * @returns true if everything that can be done was applied
  38994. */
  38995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38996. }
  38997. /**
  38998. * Defines an optimization used to turn render targets off
  38999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39000. */
  39001. class RenderTargetsOptimization extends SceneOptimization {
  39002. /**
  39003. * Gets a string describing the action executed by the current optimization
  39004. * @return description string
  39005. */
  39006. getDescription(): string;
  39007. /**
  39008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39009. * @param scene defines the current scene where to apply this optimization
  39010. * @param optimizer defines the current optimizer
  39011. * @returns true if everything that can be done was applied
  39012. */
  39013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39014. }
  39015. /**
  39016. * Defines an optimization used to merge meshes with compatible materials
  39017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39018. */
  39019. class MergeMeshesOptimization extends SceneOptimization {
  39020. private static _UpdateSelectionTree;
  39021. /**
  39022. * Gets or sets a boolean which defines if optimization octree has to be updated
  39023. */
  39024. /**
  39025. * Gets or sets a boolean which defines if optimization octree has to be updated
  39026. */
  39027. static UpdateSelectionTree: boolean;
  39028. /**
  39029. * Gets a string describing the action executed by the current optimization
  39030. * @return description string
  39031. */
  39032. getDescription(): string;
  39033. private _canBeMerged;
  39034. /**
  39035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39036. * @param scene defines the current scene where to apply this optimization
  39037. * @param optimizer defines the current optimizer
  39038. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  39039. * @returns true if everything that can be done was applied
  39040. */
  39041. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  39042. }
  39043. /**
  39044. * Defines a list of options used by SceneOptimizer
  39045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39046. */
  39047. class SceneOptimizerOptions {
  39048. /**
  39049. * Defines the target frame rate to reach (60 by default)
  39050. */
  39051. targetFrameRate: number;
  39052. /**
  39053. * Defines the interval between two checkes (2000ms by default)
  39054. */
  39055. trackerDuration: number;
  39056. /**
  39057. * Gets the list of optimizations to apply
  39058. */
  39059. optimizations: SceneOptimization[];
  39060. /**
  39061. * Creates a new list of options used by SceneOptimizer
  39062. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  39063. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  39064. */
  39065. constructor(
  39066. /**
  39067. * Defines the target frame rate to reach (60 by default)
  39068. */
  39069. targetFrameRate?: number,
  39070. /**
  39071. * Defines the interval between two checkes (2000ms by default)
  39072. */
  39073. trackerDuration?: number);
  39074. /**
  39075. * Add a new optimization
  39076. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39077. * @returns the current SceneOptimizerOptions
  39078. */
  39079. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39080. /**
  39081. * Add a new custom optimization
  39082. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39083. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39084. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39085. * @returns the current SceneOptimizerOptions
  39086. */
  39087. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39088. /**
  39089. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39090. * @param targetFrameRate defines the target frame rate (60 by default)
  39091. * @returns a SceneOptimizerOptions object
  39092. */
  39093. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39094. /**
  39095. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39096. * @param targetFrameRate defines the target frame rate (60 by default)
  39097. * @returns a SceneOptimizerOptions object
  39098. */
  39099. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39100. /**
  39101. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39102. * @param targetFrameRate defines the target frame rate (60 by default)
  39103. * @returns a SceneOptimizerOptions object
  39104. */
  39105. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39106. }
  39107. /**
  39108. * Class used to run optimizations in order to reach a target frame rate
  39109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39110. */
  39111. class SceneOptimizer implements IDisposable {
  39112. private _isRunning;
  39113. private _options;
  39114. private _scene;
  39115. private _currentPriorityLevel;
  39116. private _targetFrameRate;
  39117. private _trackerDuration;
  39118. private _currentFrameRate;
  39119. private _sceneDisposeObserver;
  39120. private _improvementMode;
  39121. /**
  39122. * Defines an observable called when the optimizer reaches the target frame rate
  39123. */
  39124. onSuccessObservable: Observable<SceneOptimizer>;
  39125. /**
  39126. * Defines an observable called when the optimizer enables an optimization
  39127. */
  39128. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39129. /**
  39130. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39131. */
  39132. onFailureObservable: Observable<SceneOptimizer>;
  39133. /**
  39134. * Gets a boolean indicating if the optimizer is in improvement mode
  39135. */
  39136. readonly isInImprovementMode: boolean;
  39137. /**
  39138. * Gets the current priority level (0 at start)
  39139. */
  39140. readonly currentPriorityLevel: number;
  39141. /**
  39142. * Gets the current frame rate checked by the SceneOptimizer
  39143. */
  39144. readonly currentFrameRate: number;
  39145. /**
  39146. * Gets or sets the current target frame rate (60 by default)
  39147. */
  39148. /**
  39149. * Gets or sets the current target frame rate (60 by default)
  39150. */
  39151. targetFrameRate: number;
  39152. /**
  39153. * Gets or sets the current interval between two checks (every 2000ms by default)
  39154. */
  39155. /**
  39156. * Gets or sets the current interval between two checks (every 2000ms by default)
  39157. */
  39158. trackerDuration: number;
  39159. /**
  39160. * Gets the list of active optimizations
  39161. */
  39162. readonly optimizations: SceneOptimization[];
  39163. /**
  39164. * Creates a new SceneOptimizer
  39165. * @param scene defines the scene to work on
  39166. * @param options defines the options to use with the SceneOptimizer
  39167. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39168. * @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)
  39169. */
  39170. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39171. /**
  39172. * Stops the current optimizer
  39173. */
  39174. stop(): void;
  39175. /**
  39176. * Reset the optimizer to initial step (current priority level = 0)
  39177. */
  39178. reset(): void;
  39179. /**
  39180. * Start the optimizer. By default it will try to reach a specific framerate
  39181. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39182. */
  39183. start(): void;
  39184. private _checkCurrentState;
  39185. /**
  39186. * Release all resources
  39187. */
  39188. dispose(): void;
  39189. /**
  39190. * Helper function to create a SceneOptimizer with one single line of code
  39191. * @param scene defines the scene to work on
  39192. * @param options defines the options to use with the SceneOptimizer
  39193. * @param onSuccess defines a callback to call on success
  39194. * @param onFailure defines a callback to call on failure
  39195. * @returns the new SceneOptimizer object
  39196. */
  39197. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39198. }
  39199. }
  39200. declare module BABYLON {
  39201. /**
  39202. * Class used to serialize a scene into a string
  39203. */
  39204. class SceneSerializer {
  39205. /**
  39206. * Clear cache used by a previous serialization
  39207. */
  39208. static ClearCache(): void;
  39209. /**
  39210. * Serialize a scene into a JSON compatible object
  39211. * @param scene defines the scene to serialize
  39212. * @returns a JSON compatible object
  39213. */
  39214. static Serialize(scene: Scene): any;
  39215. /**
  39216. * Serialize a mesh into a JSON compatible object
  39217. * @param toSerialize defines the mesh to serialize
  39218. * @param withParents defines if parents must be serialized as well
  39219. * @param withChildren defines if children must be serialized as well
  39220. * @returns a JSON compatible object
  39221. */
  39222. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39223. }
  39224. }
  39225. declare module BABYLON {
  39226. /**
  39227. * Defines an array and its length.
  39228. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39229. */
  39230. interface ISmartArrayLike<T> {
  39231. /**
  39232. * The data of the array.
  39233. */
  39234. data: Array<T>;
  39235. /**
  39236. * The active length of the array.
  39237. */
  39238. length: number;
  39239. }
  39240. /**
  39241. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39242. */
  39243. class SmartArray<T> implements ISmartArrayLike<T> {
  39244. /**
  39245. * The full set of data from the array.
  39246. */
  39247. data: Array<T>;
  39248. /**
  39249. * The active length of the array.
  39250. */
  39251. length: number;
  39252. protected _id: number;
  39253. /**
  39254. * Instantiates a Smart Array.
  39255. * @param capacity defines the default capacity of the array.
  39256. */
  39257. constructor(capacity: number);
  39258. /**
  39259. * Pushes a value at the end of the active data.
  39260. * @param value defines the object to push in the array.
  39261. */
  39262. push(value: T): void;
  39263. /**
  39264. * Iterates over the active data and apply the lambda to them.
  39265. * @param func defines the action to apply on each value.
  39266. */
  39267. forEach(func: (content: T) => void): void;
  39268. /**
  39269. * Sorts the full sets of data.
  39270. * @param compareFn defines the comparison function to apply.
  39271. */
  39272. sort(compareFn: (a: T, b: T) => number): void;
  39273. /**
  39274. * Resets the active data to an empty array.
  39275. */
  39276. reset(): void;
  39277. /**
  39278. * Releases all the data from the array as well as the array.
  39279. */
  39280. dispose(): void;
  39281. /**
  39282. * Concats the active data with a given array.
  39283. * @param array defines the data to concatenate with.
  39284. */
  39285. concat(array: any): void;
  39286. /**
  39287. * Returns the position of a value in the active data.
  39288. * @param value defines the value to find the index for
  39289. * @returns the index if found in the active data otherwise -1
  39290. */
  39291. indexOf(value: T): number;
  39292. /**
  39293. * Returns whether an element is part of the active data.
  39294. * @param value defines the value to look for
  39295. * @returns true if found in the active data otherwise false
  39296. */
  39297. contains(value: T): boolean;
  39298. private static _GlobalId;
  39299. }
  39300. /**
  39301. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39302. * The data in this array can only be present once
  39303. */
  39304. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39305. private _duplicateId;
  39306. /**
  39307. * Pushes a value at the end of the active data.
  39308. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39309. * @param value defines the object to push in the array.
  39310. */
  39311. push(value: T): void;
  39312. /**
  39313. * Pushes a value at the end of the active data.
  39314. * If the data is already present, it won t be added again
  39315. * @param value defines the object to push in the array.
  39316. * @returns true if added false if it was already present
  39317. */
  39318. pushNoDuplicate(value: T): boolean;
  39319. /**
  39320. * Resets the active data to an empty array.
  39321. */
  39322. reset(): void;
  39323. /**
  39324. * Concats the active data with a given array.
  39325. * This ensures no dupplicate will be present in the result.
  39326. * @param array defines the data to concatenate with.
  39327. */
  39328. concatWithNoDuplicate(array: any): void;
  39329. }
  39330. }
  39331. declare module BABYLON {
  39332. /**
  39333. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39334. * The underlying implementation relies on an associative array to ensure the best performances.
  39335. * The value can be anything including 'null' but except 'undefined'
  39336. */
  39337. class StringDictionary<T> {
  39338. /**
  39339. * This will clear this dictionary and copy the content from the 'source' one.
  39340. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39341. * @param source the dictionary to take the content from and copy to this dictionary
  39342. */
  39343. copyFrom(source: StringDictionary<T>): void;
  39344. /**
  39345. * Get a value based from its key
  39346. * @param key the given key to get the matching value from
  39347. * @return the value if found, otherwise undefined is returned
  39348. */
  39349. get(key: string): T | undefined;
  39350. /**
  39351. * Get a value from its key or add it if it doesn't exist.
  39352. * This method will ensure you that a given key/data will be present in the dictionary.
  39353. * @param key the given key to get the matching value from
  39354. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39355. * The factory will only be invoked if there's no data for the given key.
  39356. * @return the value corresponding to the key.
  39357. */
  39358. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39359. /**
  39360. * Get a value from its key if present in the dictionary otherwise add it
  39361. * @param key the key to get the value from
  39362. * @param val if there's no such key/value pair in the dictionary add it with this value
  39363. * @return the value corresponding to the key
  39364. */
  39365. getOrAdd(key: string, val: T): T;
  39366. /**
  39367. * Check if there's a given key in the dictionary
  39368. * @param key the key to check for
  39369. * @return true if the key is present, false otherwise
  39370. */
  39371. contains(key: string): boolean;
  39372. /**
  39373. * Add a new key and its corresponding value
  39374. * @param key the key to add
  39375. * @param value the value corresponding to the key
  39376. * @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
  39377. */
  39378. add(key: string, value: T): boolean;
  39379. /**
  39380. * Update a specific value associated to a key
  39381. * @param key defines the key to use
  39382. * @param value defines the value to store
  39383. * @returns true if the value was updated (or false if the key was not found)
  39384. */
  39385. set(key: string, value: T): boolean;
  39386. /**
  39387. * Get the element of the given key and remove it from the dictionary
  39388. * @param key defines the key to search
  39389. * @returns the value associated with the key or null if not found
  39390. */
  39391. getAndRemove(key: string): Nullable<T>;
  39392. /**
  39393. * Remove a key/value from the dictionary.
  39394. * @param key the key to remove
  39395. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39396. */
  39397. remove(key: string): boolean;
  39398. /**
  39399. * Clear the whole content of the dictionary
  39400. */
  39401. clear(): void;
  39402. /**
  39403. * Gets the current count
  39404. */
  39405. readonly count: number;
  39406. /**
  39407. * Execute a callback on each key/val of the dictionary.
  39408. * Note that you can remove any element in this dictionary in the callback implementation
  39409. * @param callback the callback to execute on a given key/value pair
  39410. */
  39411. forEach(callback: (key: string, val: T) => void): void;
  39412. /**
  39413. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39414. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39415. * Note that you can remove any element in this dictionary in the callback implementation
  39416. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39417. * @returns the first item
  39418. */
  39419. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39420. private _count;
  39421. private _data;
  39422. }
  39423. }
  39424. declare module BABYLON {
  39425. /**
  39426. * Class used to store custom tags
  39427. */
  39428. class Tags {
  39429. /**
  39430. * Adds support for tags on the given object
  39431. * @param obj defines the object to use
  39432. */
  39433. static EnableFor(obj: any): void;
  39434. /**
  39435. * Removes tags support
  39436. * @param obj defines the object to use
  39437. */
  39438. static DisableFor(obj: any): void;
  39439. /**
  39440. * Gets a boolean indicating if the given object has tags
  39441. * @param obj defines the object to use
  39442. * @returns a boolean
  39443. */
  39444. static HasTags(obj: any): boolean;
  39445. /**
  39446. * Gets the tags available on a given object
  39447. * @param obj defines the object to use
  39448. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39449. * @returns the tags
  39450. */
  39451. static GetTags(obj: any, asString?: boolean): any;
  39452. /**
  39453. * Adds tags to an object
  39454. * @param obj defines the object to use
  39455. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39456. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39457. */
  39458. static AddTagsTo(obj: any, tagsString: string): void;
  39459. /**
  39460. * @hidden
  39461. */
  39462. static _AddTagTo(obj: any, tag: string): void;
  39463. /**
  39464. * Removes specific tags from a specific object
  39465. * @param obj defines the object to use
  39466. * @param tagsString defines the tags to remove
  39467. */
  39468. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39469. /**
  39470. * @hidden
  39471. */
  39472. static _RemoveTagFrom(obj: any, tag: string): void;
  39473. /**
  39474. * Defines if tags hosted on an object match a given query
  39475. * @param obj defines the object to use
  39476. * @param tagsQuery defines the tag query
  39477. * @returns a boolean
  39478. */
  39479. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39480. }
  39481. }
  39482. declare module BABYLON {
  39483. /**
  39484. * Class used to host texture specific utilities
  39485. */
  39486. class TextureTools {
  39487. /**
  39488. * Uses the GPU to create a copy texture rescaled at a given size
  39489. * @param texture Texture to copy from
  39490. * @param width defines the desired width
  39491. * @param height defines the desired height
  39492. * @param useBilinearMode defines if bilinear mode has to be used
  39493. * @return the generated texture
  39494. */
  39495. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39496. /**
  39497. * Gets an environment BRDF texture for a given scene
  39498. * @param scene defines the hosting scene
  39499. * @returns the environment BRDF texture
  39500. */
  39501. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39502. private static _environmentBRDFBase64Texture;
  39503. }
  39504. }
  39505. declare module BABYLON {
  39506. /**
  39507. * Based on jsTGALoader - Javascript loader for TGA file
  39508. * By Vincent Thibault
  39509. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39510. */
  39511. class TGATools {
  39512. private static _TYPE_INDEXED;
  39513. private static _TYPE_RGB;
  39514. private static _TYPE_GREY;
  39515. private static _TYPE_RLE_INDEXED;
  39516. private static _TYPE_RLE_RGB;
  39517. private static _TYPE_RLE_GREY;
  39518. private static _ORIGIN_MASK;
  39519. private static _ORIGIN_SHIFT;
  39520. private static _ORIGIN_BL;
  39521. private static _ORIGIN_BR;
  39522. private static _ORIGIN_UL;
  39523. private static _ORIGIN_UR;
  39524. /**
  39525. * Gets the header of a TGA file
  39526. * @param data defines the TGA data
  39527. * @returns the header
  39528. */
  39529. static GetTGAHeader(data: Uint8Array): any;
  39530. /**
  39531. * Uploads TGA content to a Babylon Texture
  39532. * @hidden
  39533. */
  39534. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39535. /** @hidden */
  39536. 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;
  39537. /** @hidden */
  39538. 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;
  39539. /** @hidden */
  39540. 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;
  39541. /** @hidden */
  39542. 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;
  39543. /** @hidden */
  39544. 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;
  39545. /** @hidden */
  39546. 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;
  39547. }
  39548. }
  39549. declare module BABYLON {
  39550. /**
  39551. * Interface for any object that can request an animation frame
  39552. */
  39553. interface ICustomAnimationFrameRequester {
  39554. /**
  39555. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39556. */
  39557. renderFunction?: Function;
  39558. /**
  39559. * Called to request the next frame to render to
  39560. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39561. */
  39562. requestAnimationFrame: Function;
  39563. /**
  39564. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39565. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39566. */
  39567. requestID?: number;
  39568. }
  39569. /**
  39570. * Interface containing an array of animations
  39571. */
  39572. interface IAnimatable {
  39573. /**
  39574. * Array of animations
  39575. */
  39576. animations: Array<Animation>;
  39577. }
  39578. /** Interface used by value gradients (color, factor, ...) */
  39579. interface IValueGradient {
  39580. /**
  39581. * Gets or sets the gradient value (between 0 and 1)
  39582. */
  39583. gradient: number;
  39584. }
  39585. /** Class used to store color4 gradient */
  39586. class ColorGradient implements IValueGradient {
  39587. /**
  39588. * Gets or sets the gradient value (between 0 and 1)
  39589. */
  39590. gradient: number;
  39591. /**
  39592. * Gets or sets first associated color
  39593. */
  39594. color1: Color4;
  39595. /**
  39596. * Gets or sets second associated color
  39597. */
  39598. color2?: Color4;
  39599. /**
  39600. * Will get a color picked randomly between color1 and color2.
  39601. * If color2 is undefined then color1 will be used
  39602. * @param result defines the target Color4 to store the result in
  39603. */
  39604. getColorToRef(result: Color4): void;
  39605. }
  39606. /** Class used to store color 3 gradient */
  39607. class Color3Gradient implements IValueGradient {
  39608. /**
  39609. * Gets or sets the gradient value (between 0 and 1)
  39610. */
  39611. gradient: number;
  39612. /**
  39613. * Gets or sets the associated color
  39614. */
  39615. color: Color3;
  39616. }
  39617. /** Class used to store factor gradient */
  39618. class FactorGradient implements IValueGradient {
  39619. /**
  39620. * Gets or sets the gradient value (between 0 and 1)
  39621. */
  39622. gradient: number;
  39623. /**
  39624. * Gets or sets first associated factor
  39625. */
  39626. factor1: number;
  39627. /**
  39628. * Gets or sets second associated factor
  39629. */
  39630. factor2?: number;
  39631. /**
  39632. * Will get a number picked randomly between factor1 and factor2.
  39633. * If factor2 is undefined then factor1 will be used
  39634. * @returns the picked number
  39635. */
  39636. getFactor(): number;
  39637. }
  39638. /**
  39639. * @ignore
  39640. * Application error to support additional information when loading a file
  39641. */
  39642. class LoadFileError extends Error {
  39643. /** defines the optional XHR request */
  39644. request?: XMLHttpRequest | undefined;
  39645. private static _setPrototypeOf;
  39646. /**
  39647. * Creates a new LoadFileError
  39648. * @param message defines the message of the error
  39649. * @param request defines the optional XHR request
  39650. */
  39651. constructor(message: string,
  39652. /** defines the optional XHR request */
  39653. request?: XMLHttpRequest | undefined);
  39654. }
  39655. /**
  39656. * Class used to define a retry strategy when error happens while loading assets
  39657. */
  39658. class RetryStrategy {
  39659. /**
  39660. * Function used to defines an exponential back off strategy
  39661. * @param maxRetries defines the maximum number of retries (3 by default)
  39662. * @param baseInterval defines the interval between retries
  39663. * @returns the strategy function to use
  39664. */
  39665. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39666. }
  39667. /**
  39668. * File request interface
  39669. */
  39670. interface IFileRequest {
  39671. /**
  39672. * Raised when the request is complete (success or error).
  39673. */
  39674. onCompleteObservable: Observable<IFileRequest>;
  39675. /**
  39676. * Aborts the request for a file.
  39677. */
  39678. abort: () => void;
  39679. }
  39680. /**
  39681. * Class containing a set of static utilities functions
  39682. */
  39683. class Tools {
  39684. /**
  39685. * Gets or sets the base URL to use to load assets
  39686. */
  39687. static BaseUrl: string;
  39688. /**
  39689. * Enable/Disable Custom HTTP Request Headers globally.
  39690. * default = false
  39691. * @see CustomRequestHeaders
  39692. */
  39693. static UseCustomRequestHeaders: boolean;
  39694. /**
  39695. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39696. * i.e. when loading files, where the server/service expects an Authorization header.
  39697. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39698. */
  39699. static CustomRequestHeaders: {
  39700. [key: string]: string;
  39701. };
  39702. /**
  39703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39704. */
  39705. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39706. /**
  39707. * Default behaviour for cors in the application.
  39708. * It can be a string if the expected behavior is identical in the entire app.
  39709. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39710. */
  39711. static CorsBehavior: string | ((url: string | string[]) => string);
  39712. /**
  39713. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39714. * @ignorenaming
  39715. */
  39716. static UseFallbackTexture: boolean;
  39717. /**
  39718. * Use this object to register external classes like custom textures or material
  39719. * to allow the laoders to instantiate them
  39720. */
  39721. static RegisteredExternalClasses: {
  39722. [key: string]: Object;
  39723. };
  39724. /**
  39725. * Texture content used if a texture cannot loaded
  39726. * @ignorenaming
  39727. */
  39728. static fallbackTexture: string;
  39729. /**
  39730. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39731. * @param u defines the coordinate on X axis
  39732. * @param v defines the coordinate on Y axis
  39733. * @param width defines the width of the source data
  39734. * @param height defines the height of the source data
  39735. * @param pixels defines the source byte array
  39736. * @param color defines the output color
  39737. */
  39738. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39739. /**
  39740. * Interpolates between a and b via alpha
  39741. * @param a The lower value (returned when alpha = 0)
  39742. * @param b The upper value (returned when alpha = 1)
  39743. * @param alpha The interpolation-factor
  39744. * @return The mixed value
  39745. */
  39746. static Mix(a: number, b: number, alpha: number): number;
  39747. /**
  39748. * Tries to instantiate a new object from a given class name
  39749. * @param className defines the class name to instantiate
  39750. * @returns the new object or null if the system was not able to do the instantiation
  39751. */
  39752. static Instantiate(className: string): any;
  39753. /**
  39754. * Provides a slice function that will work even on IE
  39755. * @param data defines the array to slice
  39756. * @param start defines the start of the data (optional)
  39757. * @param end defines the end of the data (optional)
  39758. * @returns the new sliced array
  39759. */
  39760. static Slice<T>(data: T, start?: number, end?: number): T;
  39761. /**
  39762. * Polyfill for setImmediate
  39763. * @param action defines the action to execute after the current execution block
  39764. */
  39765. static SetImmediate(action: () => void): void;
  39766. /**
  39767. * Function indicating if a number is an exponent of 2
  39768. * @param value defines the value to test
  39769. * @returns true if the value is an exponent of 2
  39770. */
  39771. static IsExponentOfTwo(value: number): boolean;
  39772. private static _tmpFloatArray;
  39773. /**
  39774. * Returns the nearest 32-bit single precision float representation of a Number
  39775. * @param value A Number. If the parameter is of a different type, it will get converted
  39776. * to a number or to NaN if it cannot be converted
  39777. * @returns number
  39778. */
  39779. static FloatRound(value: number): number;
  39780. /**
  39781. * Find the next highest power of two.
  39782. * @param x Number to start search from.
  39783. * @return Next highest power of two.
  39784. */
  39785. static CeilingPOT(x: number): number;
  39786. /**
  39787. * Find the next lowest power of two.
  39788. * @param x Number to start search from.
  39789. * @return Next lowest power of two.
  39790. */
  39791. static FloorPOT(x: number): number;
  39792. /**
  39793. * Find the nearest power of two.
  39794. * @param x Number to start search from.
  39795. * @return Next nearest power of two.
  39796. */
  39797. static NearestPOT(x: number): number;
  39798. /**
  39799. * Get the closest exponent of two
  39800. * @param value defines the value to approximate
  39801. * @param max defines the maximum value to return
  39802. * @param mode defines how to define the closest value
  39803. * @returns closest exponent of two of the given value
  39804. */
  39805. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39806. /**
  39807. * Extracts the filename from a path
  39808. * @param path defines the path to use
  39809. * @returns the filename
  39810. */
  39811. static GetFilename(path: string): string;
  39812. /**
  39813. * Extracts the "folder" part of a path (everything before the filename).
  39814. * @param uri The URI to extract the info from
  39815. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39816. * @returns The "folder" part of the path
  39817. */
  39818. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39819. /**
  39820. * Extracts text content from a DOM element hierarchy
  39821. * @param element defines the root element
  39822. * @returns a string
  39823. */
  39824. static GetDOMTextContent(element: HTMLElement): string;
  39825. /**
  39826. * Convert an angle in radians to degrees
  39827. * @param angle defines the angle to convert
  39828. * @returns the angle in degrees
  39829. */
  39830. static ToDegrees(angle: number): number;
  39831. /**
  39832. * Convert an angle in degrees to radians
  39833. * @param angle defines the angle to convert
  39834. * @returns the angle in radians
  39835. */
  39836. static ToRadians(angle: number): number;
  39837. /**
  39838. * Encode a buffer to a base64 string
  39839. * @param buffer defines the buffer to encode
  39840. * @returns the encoded string
  39841. */
  39842. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39843. /**
  39844. * Extracts minimum and maximum values from a list of indexed positions
  39845. * @param positions defines the positions to use
  39846. * @param indices defines the indices to the positions
  39847. * @param indexStart defines the start index
  39848. * @param indexCount defines the end index
  39849. * @param bias defines bias value to add to the result
  39850. * @return minimum and maximum values
  39851. */
  39852. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39853. minimum: Vector3;
  39854. maximum: Vector3;
  39855. };
  39856. /**
  39857. * Extracts minimum and maximum values from a list of positions
  39858. * @param positions defines the positions to use
  39859. * @param start defines the start index in the positions array
  39860. * @param count defines the number of positions to handle
  39861. * @param bias defines bias value to add to the result
  39862. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39863. * @return minimum and maximum values
  39864. */
  39865. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39866. minimum: Vector3;
  39867. maximum: Vector3;
  39868. };
  39869. /**
  39870. * Returns an array if obj is not an array
  39871. * @param obj defines the object to evaluate as an array
  39872. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39873. * @returns either obj directly if obj is an array or a new array containing obj
  39874. */
  39875. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39876. /**
  39877. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39878. * @param size the number of element to construct and put in the array
  39879. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39880. * @returns a new array filled with new objects
  39881. */
  39882. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39883. /**
  39884. * Gets the pointer prefix to use
  39885. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39886. */
  39887. static GetPointerPrefix(): string;
  39888. /**
  39889. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39890. * @param func - the function to be called
  39891. * @param requester - the object that will request the next frame. Falls back to window.
  39892. * @returns frame number
  39893. */
  39894. static QueueNewFrame(func: () => void, requester?: any): number;
  39895. /**
  39896. * Ask the browser to promote the current element to fullscreen rendering mode
  39897. * @param element defines the DOM element to promote
  39898. */
  39899. static RequestFullscreen(element: HTMLElement): void;
  39900. /**
  39901. * Asks the browser to exit fullscreen mode
  39902. */
  39903. static ExitFullscreen(): void;
  39904. /**
  39905. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39906. * @param url define the url we are trying
  39907. * @param element define the dom element where to configure the cors policy
  39908. */
  39909. static SetCorsBehavior(url: string | string[], element: {
  39910. crossOrigin: string | null;
  39911. }): void;
  39912. /**
  39913. * Removes unwanted characters from an url
  39914. * @param url defines the url to clean
  39915. * @returns the cleaned url
  39916. */
  39917. static CleanUrl(url: string): string;
  39918. /**
  39919. * Gets or sets a function used to pre-process url before using them to load assets
  39920. */
  39921. static PreprocessUrl: (url: string) => string;
  39922. /**
  39923. * Loads an image as an HTMLImageElement.
  39924. * @param input url string, ArrayBuffer, or Blob to load
  39925. * @param onLoad callback called when the image successfully loads
  39926. * @param onError callback called when the image fails to load
  39927. * @param offlineProvider offline provider for caching
  39928. * @returns the HTMLImageElement of the loaded image
  39929. */
  39930. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39931. /**
  39932. * Loads a file
  39933. * @param url url string, ArrayBuffer, or Blob to load
  39934. * @param onSuccess callback called when the file successfully loads
  39935. * @param onProgress callback called while file is loading (if the server supports this mode)
  39936. * @param offlineProvider defines the offline provider for caching
  39937. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39938. * @param onError callback called when the file fails to load
  39939. * @returns a file request object
  39940. */
  39941. 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;
  39942. /**
  39943. * Load a script (identified by an url). When the url returns, the
  39944. * content of this file is added into a new script element, attached to the DOM (body element)
  39945. * @param scriptUrl defines the url of the script to laod
  39946. * @param onSuccess defines the callback called when the script is loaded
  39947. * @param onError defines the callback to call if an error occurs
  39948. */
  39949. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39950. /**
  39951. * Loads a file from a blob
  39952. * @param fileToLoad defines the blob to use
  39953. * @param callback defines the callback to call when data is loaded
  39954. * @param progressCallback defines the callback to call during loading process
  39955. * @returns a file request object
  39956. */
  39957. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39958. /**
  39959. * Loads a file
  39960. * @param fileToLoad defines the file to load
  39961. * @param callback defines the callback to call when data is loaded
  39962. * @param progressCallBack defines the callback to call during loading process
  39963. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39964. * @returns a file request object
  39965. */
  39966. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39967. /**
  39968. * Creates a data url from a given string content
  39969. * @param content defines the content to convert
  39970. * @returns the new data url link
  39971. */
  39972. static FileAsURL(content: string): string;
  39973. /**
  39974. * Format the given number to a specific decimal format
  39975. * @param value defines the number to format
  39976. * @param decimals defines the number of decimals to use
  39977. * @returns the formatted string
  39978. */
  39979. static Format(value: number, decimals?: number): string;
  39980. /**
  39981. * Checks if a given vector is inside a specific range
  39982. * @param v defines the vector to test
  39983. * @param min defines the minimum range
  39984. * @param max defines the maximum range
  39985. */
  39986. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39987. /**
  39988. * Tries to copy an object by duplicating every property
  39989. * @param source defines the source object
  39990. * @param destination defines the target object
  39991. * @param doNotCopyList defines a list of properties to avoid
  39992. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39993. */
  39994. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39995. /**
  39996. * Gets a boolean indicating if the given object has no own property
  39997. * @param obj defines the object to test
  39998. * @returns true if object has no own property
  39999. */
  40000. static IsEmpty(obj: any): boolean;
  40001. /**
  40002. * Function used to register events at window level
  40003. * @param events defines the events to register
  40004. */
  40005. static RegisterTopRootEvents(events: {
  40006. name: string;
  40007. handler: Nullable<(e: FocusEvent) => any>;
  40008. }[]): void;
  40009. /**
  40010. * Function used to unregister events from window level
  40011. * @param events defines the events to unregister
  40012. */
  40013. static UnregisterTopRootEvents(events: {
  40014. name: string;
  40015. handler: Nullable<(e: FocusEvent) => any>;
  40016. }[]): void;
  40017. /**
  40018. * Dumps the current bound framebuffer
  40019. * @param width defines the rendering width
  40020. * @param height defines the rendering height
  40021. * @param engine defines the hosting engine
  40022. * @param successCallback defines the callback triggered once the data are available
  40023. * @param mimeType defines the mime type of the result
  40024. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40025. */
  40026. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40027. /**
  40028. * Converts the canvas data to blob.
  40029. * This acts as a polyfill for browsers not supporting the to blob function.
  40030. * @param canvas Defines the canvas to extract the data from
  40031. * @param successCallback Defines the callback triggered once the data are available
  40032. * @param mimeType Defines the mime type of the result
  40033. */
  40034. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40035. /**
  40036. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40037. * @param successCallback defines the callback triggered once the data are available
  40038. * @param mimeType defines the mime type of the result
  40039. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40040. */
  40041. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40042. /**
  40043. * Downloads a blob in the browser
  40044. * @param blob defines the blob to download
  40045. * @param fileName defines the name of the downloaded file
  40046. */
  40047. static Download(blob: Blob, fileName: string): void;
  40048. /**
  40049. * Captures a screenshot of the current rendering
  40050. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40051. * @param engine defines the rendering engine
  40052. * @param camera defines the source camera
  40053. * @param size This parameter can be set to a single number or to an object with the
  40054. * following (optional) properties: precision, width, height. If a single number is passed,
  40055. * it will be used for both width and height. If an object is passed, the screenshot size
  40056. * will be derived from the parameters. The precision property is a multiplier allowing
  40057. * rendering at a higher or lower resolution
  40058. * @param successCallback defines the callback receives a single parameter which contains the
  40059. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40060. * src parameter of an <img> to display it
  40061. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40062. * Check your browser for supported MIME types
  40063. */
  40064. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  40065. /**
  40066. * Generates an image screenshot from the specified camera.
  40067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40068. * @param engine The engine to use for rendering
  40069. * @param camera The camera to use for rendering
  40070. * @param size This parameter can be set to a single number or to an object with the
  40071. * following (optional) properties: precision, width, height. If a single number is passed,
  40072. * it will be used for both width and height. If an object is passed, the screenshot size
  40073. * will be derived from the parameters. The precision property is a multiplier allowing
  40074. * rendering at a higher or lower resolution
  40075. * @param successCallback The callback receives a single parameter which contains the
  40076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40077. * src parameter of an <img> to display it
  40078. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40079. * Check your browser for supported MIME types
  40080. * @param samples Texture samples (default: 1)
  40081. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40082. * @param fileName A name for for the downloaded file.
  40083. */
  40084. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40085. /**
  40086. * Validates if xhr data is correct
  40087. * @param xhr defines the request to validate
  40088. * @param dataType defines the expected data type
  40089. * @returns true if data is correct
  40090. */
  40091. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40092. /**
  40093. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40094. * Be aware Math.random() could cause collisions, but:
  40095. * "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"
  40096. * @returns a pseudo random id
  40097. */
  40098. static RandomId(): string;
  40099. /**
  40100. * Test if the given uri is a base64 string
  40101. * @param uri The uri to test
  40102. * @return True if the uri is a base64 string or false otherwise
  40103. */
  40104. static IsBase64(uri: string): boolean;
  40105. /**
  40106. * Decode the given base64 uri.
  40107. * @param uri The uri to decode
  40108. * @return The decoded base64 data.
  40109. */
  40110. static DecodeBase64(uri: string): ArrayBuffer;
  40111. /**
  40112. * No log
  40113. */
  40114. static readonly NoneLogLevel: number;
  40115. /**
  40116. * Only message logs
  40117. */
  40118. static readonly MessageLogLevel: number;
  40119. /**
  40120. * Only warning logs
  40121. */
  40122. static readonly WarningLogLevel: number;
  40123. /**
  40124. * Only error logs
  40125. */
  40126. static readonly ErrorLogLevel: number;
  40127. /**
  40128. * All logs
  40129. */
  40130. static readonly AllLogLevel: number;
  40131. private static _LogCache;
  40132. /**
  40133. * Gets a value indicating the number of loading errors
  40134. * @ignorenaming
  40135. */
  40136. static errorsCount: number;
  40137. /**
  40138. * Callback called when a new log is added
  40139. */
  40140. static OnNewCacheEntry: (entry: string) => void;
  40141. private static _AddLogEntry;
  40142. private static _FormatMessage;
  40143. private static _LogDisabled;
  40144. private static _LogEnabled;
  40145. private static _WarnDisabled;
  40146. private static _WarnEnabled;
  40147. private static _ErrorDisabled;
  40148. private static _ErrorEnabled;
  40149. /**
  40150. * Log a message to the console
  40151. */
  40152. static Log: (message: string) => void;
  40153. /**
  40154. * Write a warning message to the console
  40155. */
  40156. static Warn: (message: string) => void;
  40157. /**
  40158. * Write an error message to the console
  40159. */
  40160. static Error: (message: string) => void;
  40161. /**
  40162. * Gets current log cache (list of logs)
  40163. */
  40164. static readonly LogCache: string;
  40165. /**
  40166. * Clears the log cache
  40167. */
  40168. static ClearLogCache(): void;
  40169. /**
  40170. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40171. */
  40172. static LogLevels: number;
  40173. /**
  40174. * Checks if the loaded document was accessed via `file:`-Protocol.
  40175. * @returns boolean
  40176. */
  40177. static IsFileURL(): boolean;
  40178. /**
  40179. * Checks if the window object exists
  40180. * @returns true if the window object exists
  40181. */
  40182. static IsWindowObjectExist(): boolean;
  40183. /**
  40184. * No performance log
  40185. */
  40186. static readonly PerformanceNoneLogLevel: number;
  40187. /**
  40188. * Use user marks to log performance
  40189. */
  40190. static readonly PerformanceUserMarkLogLevel: number;
  40191. /**
  40192. * Log performance to the console
  40193. */
  40194. static readonly PerformanceConsoleLogLevel: number;
  40195. private static _performance;
  40196. /**
  40197. * Sets the current performance log level
  40198. */
  40199. static PerformanceLogLevel: number;
  40200. private static _StartPerformanceCounterDisabled;
  40201. private static _EndPerformanceCounterDisabled;
  40202. private static _StartUserMark;
  40203. private static _EndUserMark;
  40204. private static _StartPerformanceConsole;
  40205. private static _EndPerformanceConsole;
  40206. /**
  40207. * Injects the @see CustomRequestHeaders into the given request
  40208. * @param request the request that should be used for injection
  40209. */
  40210. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40211. /**
  40212. * Starts a performance counter
  40213. */
  40214. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40215. /**
  40216. * Ends a specific performance coutner
  40217. */
  40218. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40219. /**
  40220. * Gets either window.performance.now() if supported or Date.now() else
  40221. */
  40222. static readonly Now: number;
  40223. /**
  40224. * This method will return the name of the class used to create the instance of the given object.
  40225. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40226. * @param object the object to get the class name from
  40227. * @param isType defines if the object is actually a type
  40228. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40229. */
  40230. static GetClassName(object: any, isType?: boolean): string;
  40231. /**
  40232. * Gets the first element of an array satisfying a given predicate
  40233. * @param array defines the array to browse
  40234. * @param predicate defines the predicate to use
  40235. * @returns null if not found or the element
  40236. */
  40237. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40238. /**
  40239. * This method will return the name of the full name of the class, including its owning module (if any).
  40240. * 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).
  40241. * @param object the object to get the class name from
  40242. * @param isType defines if the object is actually a type
  40243. * @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.
  40244. * @ignorenaming
  40245. */
  40246. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40247. /**
  40248. * Returns a promise that resolves after the given amount of time.
  40249. * @param delay Number of milliseconds to delay
  40250. * @returns Promise that resolves after the given amount of time
  40251. */
  40252. static DelayAsync(delay: number): Promise<void>;
  40253. /**
  40254. * Gets the current gradient from an array of IValueGradient
  40255. * @param ratio defines the current ratio to get
  40256. * @param gradients defines the array of IValueGradient
  40257. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40258. */
  40259. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40260. }
  40261. /**
  40262. * This class is used to track a performance counter which is number based.
  40263. * The user has access to many properties which give statistics of different nature.
  40264. *
  40265. * The implementer can track two kinds of Performance Counter: time and count.
  40266. * 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.
  40267. * 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.
  40268. */
  40269. class PerfCounter {
  40270. /**
  40271. * Gets or sets a global boolean to turn on and off all the counters
  40272. */
  40273. static Enabled: boolean;
  40274. /**
  40275. * Returns the smallest value ever
  40276. */
  40277. readonly min: number;
  40278. /**
  40279. * Returns the biggest value ever
  40280. */
  40281. readonly max: number;
  40282. /**
  40283. * Returns the average value since the performance counter is running
  40284. */
  40285. readonly average: number;
  40286. /**
  40287. * Returns the average value of the last second the counter was monitored
  40288. */
  40289. readonly lastSecAverage: number;
  40290. /**
  40291. * Returns the current value
  40292. */
  40293. readonly current: number;
  40294. /**
  40295. * Gets the accumulated total
  40296. */
  40297. readonly total: number;
  40298. /**
  40299. * Gets the total value count
  40300. */
  40301. readonly count: number;
  40302. /**
  40303. * Creates a new counter
  40304. */
  40305. constructor();
  40306. /**
  40307. * Call this method to start monitoring a new frame.
  40308. * 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.
  40309. */
  40310. fetchNewFrame(): void;
  40311. /**
  40312. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40313. * @param newCount the count value to add to the monitored count
  40314. * @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.
  40315. */
  40316. addCount(newCount: number, fetchResult: boolean): void;
  40317. /**
  40318. * Start monitoring this performance counter
  40319. */
  40320. beginMonitoring(): void;
  40321. /**
  40322. * Compute the time lapsed since the previous beginMonitoring() call.
  40323. * @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
  40324. */
  40325. endMonitoring(newFrame?: boolean): void;
  40326. private _fetchResult;
  40327. private _startMonitoringTime;
  40328. private _min;
  40329. private _max;
  40330. private _average;
  40331. private _current;
  40332. private _totalValueCount;
  40333. private _totalAccumulated;
  40334. private _lastSecAverage;
  40335. private _lastSecAccumulated;
  40336. private _lastSecTime;
  40337. private _lastSecValueCount;
  40338. }
  40339. /**
  40340. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40341. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40342. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40343. * @param name The name of the class, case should be preserved
  40344. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40345. */
  40346. function className(name: string, module?: string): (target: Object) => void;
  40347. /**
  40348. * An implementation of a loop for asynchronous functions.
  40349. */
  40350. class AsyncLoop {
  40351. /**
  40352. * Defines the number of iterations for the loop
  40353. */
  40354. iterations: number;
  40355. /**
  40356. * Defines the current index of the loop.
  40357. */
  40358. index: number;
  40359. private _done;
  40360. private _fn;
  40361. private _successCallback;
  40362. /**
  40363. * Constructor.
  40364. * @param iterations the number of iterations.
  40365. * @param func the function to run each iteration
  40366. * @param successCallback the callback that will be called upon succesful execution
  40367. * @param offset starting offset.
  40368. */
  40369. constructor(
  40370. /**
  40371. * Defines the number of iterations for the loop
  40372. */
  40373. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40374. /**
  40375. * Execute the next iteration. Must be called after the last iteration was finished.
  40376. */
  40377. executeNext(): void;
  40378. /**
  40379. * Break the loop and run the success callback.
  40380. */
  40381. breakLoop(): void;
  40382. /**
  40383. * Create and run an async loop.
  40384. * @param iterations the number of iterations.
  40385. * @param fn the function to run each iteration
  40386. * @param successCallback the callback that will be called upon succesful execution
  40387. * @param offset starting offset.
  40388. * @returns the created async loop object
  40389. */
  40390. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40391. /**
  40392. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40393. * @param iterations total number of iterations
  40394. * @param syncedIterations number of synchronous iterations in each async iteration.
  40395. * @param fn the function to call each iteration.
  40396. * @param callback a success call back that will be called when iterating stops.
  40397. * @param breakFunction a break condition (optional)
  40398. * @param timeout timeout settings for the setTimeout function. default - 0.
  40399. * @returns the created async loop object
  40400. */
  40401. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40402. }
  40403. }
  40404. interface HTMLCanvasElement {
  40405. /** Track wether a record is in progress */
  40406. isRecording: boolean;
  40407. /** Capture Stream method defined by some browsers */
  40408. captureStream(fps?: number): MediaStream;
  40409. }
  40410. interface MediaRecorder {
  40411. /** Starts recording */
  40412. start(timeSlice: number): void;
  40413. /** Stops recording */
  40414. stop(): void;
  40415. /** Event raised when an error arised. */
  40416. onerror: (event: ErrorEvent) => void;
  40417. /** Event raised when the recording stops. */
  40418. onstop: (event: Event) => void;
  40419. /** Event raised when a new chunk of data is available and should be tracked. */
  40420. ondataavailable: (event: Event) => void;
  40421. }
  40422. interface MediaRecorderOptions {
  40423. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40424. mimeType?: string;
  40425. /** The chosen bitrate for the audio component of the media. */
  40426. audioBitsPerSecond?: number;
  40427. /** The chosen bitrate for the video component of the media. */
  40428. videoBitsPerSecond?: number;
  40429. /** 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. */
  40430. bitsPerSecond?: number;
  40431. }
  40432. interface MediaRecorderConstructor {
  40433. /**
  40434. * A reference to the prototype.
  40435. */
  40436. readonly prototype: MediaRecorder;
  40437. /**
  40438. * Creates a new MediaRecorder.
  40439. * @param stream Defines the stream to record.
  40440. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40441. */
  40442. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40443. }
  40444. /**
  40445. * MediaRecoreder object available in some browsers.
  40446. */
  40447. declare var MediaRecorder: MediaRecorderConstructor;
  40448. declare module BABYLON {
  40449. /**
  40450. * This represents the different options avilable for the video capture.
  40451. */
  40452. interface VideoRecorderOptions {
  40453. /** Defines the mime type of the video */
  40454. mimeType: string;
  40455. /** Defines the video the video should be recorded at */
  40456. fps: number;
  40457. /** Defines the chunk size for the recording data */
  40458. recordChunckSize: number;
  40459. }
  40460. /**
  40461. * This can helps recording videos from BabylonJS.
  40462. * This is based on the available WebRTC functionalities of the browser.
  40463. *
  40464. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40465. */
  40466. class VideoRecorder {
  40467. private static readonly _defaultOptions;
  40468. /**
  40469. * Returns wehther or not the VideoRecorder is available in your browser.
  40470. * @param engine Defines the Babylon Engine to check the support for
  40471. * @returns true if supported otherwise false
  40472. */
  40473. static IsSupported(engine: Engine): boolean;
  40474. private readonly _options;
  40475. private _canvas;
  40476. private _mediaRecorder;
  40477. private _recordedChunks;
  40478. private _fileName;
  40479. private _resolve;
  40480. private _reject;
  40481. /**
  40482. * True wether a recording is already in progress.
  40483. */
  40484. readonly isRecording: boolean;
  40485. /**
  40486. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40487. * a video file.
  40488. * @param engine Defines the BabylonJS Engine you wish to record
  40489. * @param options Defines options that can be used to customized the capture
  40490. */
  40491. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40492. /**
  40493. * Stops the current recording before the default capture timeout passed in the startRecording
  40494. * functions.
  40495. */
  40496. stopRecording(): void;
  40497. /**
  40498. * Starts recording the canvas for a max duration specified in parameters.
  40499. * @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.
  40500. * @param maxDuration Defines the maximum recording time in seconds.
  40501. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40502. * @return a promise callback at the end of the recording with the video data in Blob.
  40503. */
  40504. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40505. /**
  40506. * Releases internal resources used during the recording.
  40507. */
  40508. dispose(): void;
  40509. private _handleDataAvailable;
  40510. private _handleError;
  40511. private _handleStop;
  40512. }
  40513. }
  40514. declare module BABYLON {
  40515. /**
  40516. * Defines the potential axis of a Joystick
  40517. */
  40518. enum JoystickAxis {
  40519. /** X axis */
  40520. X = 0,
  40521. /** Y axis */
  40522. Y = 1,
  40523. /** Z axis */
  40524. Z = 2
  40525. }
  40526. /**
  40527. * Class used to define virtual joystick (used in touch mode)
  40528. */
  40529. class VirtualJoystick {
  40530. /**
  40531. * Gets or sets a boolean indicating that left and right values must be inverted
  40532. */
  40533. reverseLeftRight: boolean;
  40534. /**
  40535. * Gets or sets a boolean indicating that up and down values must be inverted
  40536. */
  40537. reverseUpDown: boolean;
  40538. /**
  40539. * Gets the offset value for the position (ie. the change of the position value)
  40540. */
  40541. deltaPosition: Vector3;
  40542. /**
  40543. * Gets a boolean indicating if the virtual joystick was pressed
  40544. */
  40545. pressed: boolean;
  40546. /**
  40547. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40548. */
  40549. static Canvas: Nullable<HTMLCanvasElement>;
  40550. private static _globalJoystickIndex;
  40551. private static vjCanvasContext;
  40552. private static vjCanvasWidth;
  40553. private static vjCanvasHeight;
  40554. private static halfWidth;
  40555. private _action;
  40556. private _axisTargetedByLeftAndRight;
  40557. private _axisTargetedByUpAndDown;
  40558. private _joystickSensibility;
  40559. private _inversedSensibility;
  40560. private _joystickPointerID;
  40561. private _joystickColor;
  40562. private _joystickPointerPos;
  40563. private _joystickPreviousPointerPos;
  40564. private _joystickPointerStartPos;
  40565. private _deltaJoystickVector;
  40566. private _leftJoystick;
  40567. private _touches;
  40568. private _onPointerDownHandlerRef;
  40569. private _onPointerMoveHandlerRef;
  40570. private _onPointerUpHandlerRef;
  40571. private _onResize;
  40572. /**
  40573. * Creates a new virtual joystick
  40574. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40575. */
  40576. constructor(leftJoystick?: boolean);
  40577. /**
  40578. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40579. * @param newJoystickSensibility defines the new sensibility
  40580. */
  40581. setJoystickSensibility(newJoystickSensibility: number): void;
  40582. private _onPointerDown;
  40583. private _onPointerMove;
  40584. private _onPointerUp;
  40585. /**
  40586. * Change the color of the virtual joystick
  40587. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40588. */
  40589. setJoystickColor(newColor: string): void;
  40590. /**
  40591. * Defines a callback to call when the joystick is touched
  40592. * @param action defines the callback
  40593. */
  40594. setActionOnTouch(action: () => any): void;
  40595. /**
  40596. * Defines which axis you'd like to control for left & right
  40597. * @param axis defines the axis to use
  40598. */
  40599. setAxisForLeftRight(axis: JoystickAxis): void;
  40600. /**
  40601. * Defines which axis you'd like to control for up & down
  40602. * @param axis defines the axis to use
  40603. */
  40604. setAxisForUpDown(axis: JoystickAxis): void;
  40605. private _drawVirtualJoystick;
  40606. /**
  40607. * Release internal HTML canvas
  40608. */
  40609. releaseCanvas(): void;
  40610. }
  40611. }
  40612. declare module BABYLON {
  40613. /**
  40614. * Helper class to push actions to a pool of workers.
  40615. */
  40616. class WorkerPool implements IDisposable {
  40617. private _workerInfos;
  40618. private _pendingActions;
  40619. /**
  40620. * Constructor
  40621. * @param workers Array of workers to use for actions
  40622. */
  40623. constructor(workers: Array<Worker>);
  40624. /**
  40625. * Terminates all workers and clears any pending actions.
  40626. */
  40627. dispose(): void;
  40628. /**
  40629. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40630. * pended until a worker has completed its action.
  40631. * @param action The action to perform. Call onComplete when the action is complete.
  40632. */
  40633. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40634. private _execute;
  40635. }
  40636. }
  40637. declare module BABYLON {
  40638. /**
  40639. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40640. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40641. */
  40642. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40643. /**
  40644. * Gets the name of the behavior.
  40645. */
  40646. readonly name: string;
  40647. private _zoomStopsAnimation;
  40648. private _idleRotationSpeed;
  40649. private _idleRotationWaitTime;
  40650. private _idleRotationSpinupTime;
  40651. /**
  40652. * Sets the flag that indicates if user zooming should stop animation.
  40653. */
  40654. /**
  40655. * Gets the flag that indicates if user zooming should stop animation.
  40656. */
  40657. zoomStopsAnimation: boolean;
  40658. /**
  40659. * Sets the default speed at which the camera rotates around the model.
  40660. */
  40661. /**
  40662. * Gets the default speed at which the camera rotates around the model.
  40663. */
  40664. idleRotationSpeed: number;
  40665. /**
  40666. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40667. */
  40668. /**
  40669. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40670. */
  40671. idleRotationWaitTime: number;
  40672. /**
  40673. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40674. */
  40675. /**
  40676. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40677. */
  40678. idleRotationSpinupTime: number;
  40679. /**
  40680. * Gets a value indicating if the camera is currently rotating because of this behavior
  40681. */
  40682. readonly rotationInProgress: boolean;
  40683. private _onPrePointerObservableObserver;
  40684. private _onAfterCheckInputsObserver;
  40685. private _attachedCamera;
  40686. private _isPointerDown;
  40687. private _lastFrameTime;
  40688. private _lastInteractionTime;
  40689. private _cameraRotationSpeed;
  40690. /**
  40691. * Initializes the behavior.
  40692. */
  40693. init(): void;
  40694. /**
  40695. * Attaches the behavior to its arc rotate camera.
  40696. * @param camera Defines the camera to attach the behavior to
  40697. */
  40698. attach(camera: ArcRotateCamera): void;
  40699. /**
  40700. * Detaches the behavior from its current arc rotate camera.
  40701. */
  40702. detach(): void;
  40703. /**
  40704. * Returns true if user is scrolling.
  40705. * @return true if user is scrolling.
  40706. */
  40707. private _userIsZooming;
  40708. private _lastFrameRadius;
  40709. private _shouldAnimationStopForInteraction;
  40710. /**
  40711. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40712. */
  40713. private _applyUserInteraction;
  40714. private _userIsMoving;
  40715. }
  40716. }
  40717. declare module BABYLON {
  40718. /**
  40719. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40720. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40721. */
  40722. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40723. /**
  40724. * Gets the name of the behavior.
  40725. */
  40726. readonly name: string;
  40727. /**
  40728. * The easing function used by animations
  40729. */
  40730. static EasingFunction: BackEase;
  40731. /**
  40732. * The easing mode used by animations
  40733. */
  40734. static EasingMode: number;
  40735. /**
  40736. * The duration of the animation, in milliseconds
  40737. */
  40738. transitionDuration: number;
  40739. /**
  40740. * Length of the distance animated by the transition when lower radius is reached
  40741. */
  40742. lowerRadiusTransitionRange: number;
  40743. /**
  40744. * Length of the distance animated by the transition when upper radius is reached
  40745. */
  40746. upperRadiusTransitionRange: number;
  40747. private _autoTransitionRange;
  40748. /**
  40749. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40750. */
  40751. /**
  40752. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40753. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40754. */
  40755. autoTransitionRange: boolean;
  40756. private _attachedCamera;
  40757. private _onAfterCheckInputsObserver;
  40758. private _onMeshTargetChangedObserver;
  40759. /**
  40760. * Initializes the behavior.
  40761. */
  40762. init(): void;
  40763. /**
  40764. * Attaches the behavior to its arc rotate camera.
  40765. * @param camera Defines the camera to attach the behavior to
  40766. */
  40767. attach(camera: ArcRotateCamera): void;
  40768. /**
  40769. * Detaches the behavior from its current arc rotate camera.
  40770. */
  40771. detach(): void;
  40772. private _radiusIsAnimating;
  40773. private _radiusBounceTransition;
  40774. private _animatables;
  40775. private _cachedWheelPrecision;
  40776. /**
  40777. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40778. * @param radiusLimit The limit to check against.
  40779. * @return Bool to indicate if at limit.
  40780. */
  40781. private _isRadiusAtLimit;
  40782. /**
  40783. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40784. * @param radiusDelta The delta by which to animate to. Can be negative.
  40785. */
  40786. private _applyBoundRadiusAnimation;
  40787. /**
  40788. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40789. */
  40790. protected _clearAnimationLocks(): void;
  40791. /**
  40792. * Stops and removes all animations that have been applied to the camera
  40793. */
  40794. stopAllAnimations(): void;
  40795. }
  40796. }
  40797. declare module BABYLON {
  40798. /**
  40799. * 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.
  40800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40801. */
  40802. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40803. /**
  40804. * Gets the name of the behavior.
  40805. */
  40806. readonly name: string;
  40807. private _mode;
  40808. private _radiusScale;
  40809. private _positionScale;
  40810. private _defaultElevation;
  40811. private _elevationReturnTime;
  40812. private _elevationReturnWaitTime;
  40813. private _zoomStopsAnimation;
  40814. private _framingTime;
  40815. /**
  40816. * The easing function used by animations
  40817. */
  40818. static EasingFunction: ExponentialEase;
  40819. /**
  40820. * The easing mode used by animations
  40821. */
  40822. static EasingMode: number;
  40823. /**
  40824. * Sets the current mode used by the behavior
  40825. */
  40826. /**
  40827. * Gets current mode used by the behavior.
  40828. */
  40829. mode: number;
  40830. /**
  40831. * Sets the scale applied to the radius (1 by default)
  40832. */
  40833. /**
  40834. * Gets the scale applied to the radius
  40835. */
  40836. radiusScale: number;
  40837. /**
  40838. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40839. */
  40840. /**
  40841. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40842. */
  40843. positionScale: number;
  40844. /**
  40845. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40846. * behaviour is triggered, in radians.
  40847. */
  40848. /**
  40849. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40850. * behaviour is triggered, in radians.
  40851. */
  40852. defaultElevation: number;
  40853. /**
  40854. * Sets the time (in milliseconds) taken to return to the default beta position.
  40855. * Negative value indicates camera should not return to default.
  40856. */
  40857. /**
  40858. * Gets the time (in milliseconds) taken to return to the default beta position.
  40859. * Negative value indicates camera should not return to default.
  40860. */
  40861. elevationReturnTime: number;
  40862. /**
  40863. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40864. */
  40865. /**
  40866. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40867. */
  40868. elevationReturnWaitTime: number;
  40869. /**
  40870. * Sets the flag that indicates if user zooming should stop animation.
  40871. */
  40872. /**
  40873. * Gets the flag that indicates if user zooming should stop animation.
  40874. */
  40875. zoomStopsAnimation: boolean;
  40876. /**
  40877. * Sets the transition time when framing the mesh, in milliseconds
  40878. */
  40879. /**
  40880. * Gets the transition time when framing the mesh, in milliseconds
  40881. */
  40882. framingTime: number;
  40883. /**
  40884. * Define if the behavior should automatically change the configured
  40885. * camera limits and sensibilities.
  40886. */
  40887. autoCorrectCameraLimitsAndSensibility: boolean;
  40888. private _onPrePointerObservableObserver;
  40889. private _onAfterCheckInputsObserver;
  40890. private _onMeshTargetChangedObserver;
  40891. private _attachedCamera;
  40892. private _isPointerDown;
  40893. private _lastInteractionTime;
  40894. /**
  40895. * Initializes the behavior.
  40896. */
  40897. init(): void;
  40898. /**
  40899. * Attaches the behavior to its arc rotate camera.
  40900. * @param camera Defines the camera to attach the behavior to
  40901. */
  40902. attach(camera: ArcRotateCamera): void;
  40903. /**
  40904. * Detaches the behavior from its current arc rotate camera.
  40905. */
  40906. detach(): void;
  40907. private _animatables;
  40908. private _betaIsAnimating;
  40909. private _betaTransition;
  40910. private _radiusTransition;
  40911. private _vectorTransition;
  40912. /**
  40913. * Targets the given mesh and updates zoom level accordingly.
  40914. * @param mesh The mesh to target.
  40915. * @param radius Optional. If a cached radius position already exists, overrides default.
  40916. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40917. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40918. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40919. */
  40920. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40921. /**
  40922. * Targets the given mesh with its children and updates zoom level accordingly.
  40923. * @param mesh The mesh to target.
  40924. * @param radius Optional. If a cached radius position already exists, overrides default.
  40925. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40926. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40927. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40928. */
  40929. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40930. /**
  40931. * Targets the given meshes with their children and updates zoom level accordingly.
  40932. * @param meshes The mesh to target.
  40933. * @param radius Optional. If a cached radius position already exists, overrides default.
  40934. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40935. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40936. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40937. */
  40938. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40939. /**
  40940. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40941. * @param minimumWorld Determines the smaller position of the bounding box extend
  40942. * @param maximumWorld Determines the bigger position of the bounding box extend
  40943. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40944. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40945. */
  40946. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40947. /**
  40948. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40949. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40950. * frustum width.
  40951. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40952. * to fully enclose the mesh in the viewing frustum.
  40953. */
  40954. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40955. /**
  40956. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40957. * is automatically returned to its default position (expected to be above ground plane).
  40958. */
  40959. private _maintainCameraAboveGround;
  40960. /**
  40961. * Returns the frustum slope based on the canvas ratio and camera FOV
  40962. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40963. */
  40964. private _getFrustumSlope;
  40965. /**
  40966. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40967. */
  40968. private _clearAnimationLocks;
  40969. /**
  40970. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40971. */
  40972. private _applyUserInteraction;
  40973. /**
  40974. * Stops and removes all animations that have been applied to the camera
  40975. */
  40976. stopAllAnimations(): void;
  40977. /**
  40978. * Gets a value indicating if the user is moving the camera
  40979. */
  40980. readonly isUserIsMoving: boolean;
  40981. /**
  40982. * The camera can move all the way towards the mesh.
  40983. */
  40984. static IgnoreBoundsSizeMode: number;
  40985. /**
  40986. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40987. */
  40988. static FitFrustumSidesMode: number;
  40989. }
  40990. }
  40991. declare module BABYLON {
  40992. /**
  40993. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40994. */
  40995. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40996. private ui;
  40997. /**
  40998. * The name of the behavior
  40999. */
  41000. name: string;
  41001. /**
  41002. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  41003. */
  41004. distanceAwayFromFace: number;
  41005. /**
  41006. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  41007. */
  41008. distanceAwayFromBottomOfFace: number;
  41009. private _faceVectors;
  41010. private _target;
  41011. private _scene;
  41012. private _onRenderObserver;
  41013. private _tmpMatrix;
  41014. private _tmpVector;
  41015. /**
  41016. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  41017. * @param ui The transform node that should be attched to the mesh
  41018. */
  41019. constructor(ui: BABYLON.TransformNode);
  41020. /**
  41021. * Initializes the behavior
  41022. */
  41023. init(): void;
  41024. private _closestFace;
  41025. private _zeroVector;
  41026. private _lookAtTmpMatrix;
  41027. private _lookAtToRef;
  41028. /**
  41029. * Attaches the AttachToBoxBehavior to the passed in mesh
  41030. * @param target The mesh that the specified node will be attached to
  41031. */
  41032. attach(target: BABYLON.Mesh): void;
  41033. /**
  41034. * Detaches the behavior from the mesh
  41035. */
  41036. detach(): void;
  41037. }
  41038. }
  41039. declare module BABYLON {
  41040. /**
  41041. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  41042. */
  41043. class FadeInOutBehavior implements Behavior<Mesh> {
  41044. /**
  41045. * Time in milliseconds to delay before fading in (Default: 0)
  41046. */
  41047. delay: number;
  41048. /**
  41049. * Time in milliseconds for the mesh to fade in (Default: 300)
  41050. */
  41051. fadeInTime: number;
  41052. private _millisecondsPerFrame;
  41053. private _hovered;
  41054. private _hoverValue;
  41055. private _ownerNode;
  41056. /**
  41057. * Instatiates the FadeInOutBehavior
  41058. */
  41059. constructor();
  41060. /**
  41061. * The name of the behavior
  41062. */
  41063. readonly name: string;
  41064. /**
  41065. * Initializes the behavior
  41066. */
  41067. init(): void;
  41068. /**
  41069. * Attaches the fade behavior on the passed in mesh
  41070. * @param ownerNode The mesh that will be faded in/out once attached
  41071. */
  41072. attach(ownerNode: Mesh): void;
  41073. /**
  41074. * Detaches the behavior from the mesh
  41075. */
  41076. detach(): void;
  41077. /**
  41078. * Triggers the mesh to begin fading in or out
  41079. * @param value if the object should fade in or out (true to fade in)
  41080. */
  41081. fadeIn(value: boolean): void;
  41082. private _update;
  41083. private _setAllVisibility;
  41084. }
  41085. }
  41086. declare module BABYLON {
  41087. /**
  41088. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41089. */
  41090. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41091. private _dragBehaviorA;
  41092. private _dragBehaviorB;
  41093. private _startDistance;
  41094. private _initialScale;
  41095. private _targetScale;
  41096. private _ownerNode;
  41097. private _sceneRenderObserver;
  41098. /**
  41099. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41100. */
  41101. constructor();
  41102. /**
  41103. * The name of the behavior
  41104. */
  41105. readonly name: string;
  41106. /**
  41107. * Initializes the behavior
  41108. */
  41109. init(): void;
  41110. private _getCurrentDistance;
  41111. /**
  41112. * Attaches the scale behavior the passed in mesh
  41113. * @param ownerNode The mesh that will be scaled around once attached
  41114. */
  41115. attach(ownerNode: Mesh): void;
  41116. /**
  41117. * Detaches the behavior from the mesh
  41118. */
  41119. detach(): void;
  41120. }
  41121. }
  41122. declare module BABYLON {
  41123. /**
  41124. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41125. */
  41126. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41127. private static _AnyMouseID;
  41128. private _attachedNode;
  41129. private _dragPlane;
  41130. private _scene;
  41131. private _pointerObserver;
  41132. private _beforeRenderObserver;
  41133. private static _planeScene;
  41134. /**
  41135. * 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)
  41136. */
  41137. maxDragAngle: number;
  41138. /**
  41139. * @hidden
  41140. */
  41141. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41142. /**
  41143. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41144. */
  41145. currentDraggingPointerID: number;
  41146. /**
  41147. * The last position where the pointer hit the drag plane in world space
  41148. */
  41149. lastDragPosition: Vector3;
  41150. /**
  41151. * If the behavior is currently in a dragging state
  41152. */
  41153. dragging: boolean;
  41154. /**
  41155. * 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)
  41156. */
  41157. dragDeltaRatio: number;
  41158. /**
  41159. * If the drag plane orientation should be updated during the dragging (Default: true)
  41160. */
  41161. updateDragPlane: boolean;
  41162. private _debugMode;
  41163. private _moving;
  41164. /**
  41165. * Fires each time the attached mesh is dragged with the pointer
  41166. * * delta between last drag position and current drag position in world space
  41167. * * dragDistance along the drag axis
  41168. * * dragPlaneNormal normal of the current drag plane used during the drag
  41169. * * dragPlanePoint in world space where the drag intersects the drag plane
  41170. */
  41171. onDragObservable: Observable<{
  41172. delta: Vector3;
  41173. dragPlanePoint: Vector3;
  41174. dragPlaneNormal: Vector3;
  41175. dragDistance: number;
  41176. pointerId: number;
  41177. }>;
  41178. /**
  41179. * Fires each time a drag begins (eg. mouse down on mesh)
  41180. */
  41181. onDragStartObservable: Observable<{
  41182. dragPlanePoint: Vector3;
  41183. pointerId: number;
  41184. }>;
  41185. /**
  41186. * Fires each time a drag ends (eg. mouse release after drag)
  41187. */
  41188. onDragEndObservable: Observable<{
  41189. dragPlanePoint: Vector3;
  41190. pointerId: number;
  41191. }>;
  41192. /**
  41193. * If the attached mesh should be moved when dragged
  41194. */
  41195. moveAttached: boolean;
  41196. /**
  41197. * If the drag behavior will react to drag events (Default: true)
  41198. */
  41199. enabled: boolean;
  41200. /**
  41201. * If camera controls should be detached during the drag
  41202. */
  41203. detachCameraControls: boolean;
  41204. /**
  41205. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41206. */
  41207. useObjectOrienationForDragging: boolean;
  41208. private _options;
  41209. /**
  41210. * Creates a pointer drag behavior that can be attached to a mesh
  41211. * @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)
  41212. */
  41213. constructor(options?: {
  41214. dragAxis?: Vector3;
  41215. dragPlaneNormal?: Vector3;
  41216. });
  41217. /**
  41218. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41219. */
  41220. validateDrag: (targetPosition: Vector3) => boolean;
  41221. /**
  41222. * The name of the behavior
  41223. */
  41224. readonly name: string;
  41225. /**
  41226. * Initializes the behavior
  41227. */
  41228. init(): void;
  41229. private _tmpVector;
  41230. private _alternatePickedPoint;
  41231. private _worldDragAxis;
  41232. private _targetPosition;
  41233. private _attachedElement;
  41234. /**
  41235. * Attaches the drag behavior the passed in mesh
  41236. * @param ownerNode The mesh that will be dragged around once attached
  41237. */
  41238. attach(ownerNode: AbstractMesh): void;
  41239. /**
  41240. * Force relase the drag action by code.
  41241. */
  41242. releaseDrag(): void;
  41243. private _startDragRay;
  41244. private _lastPointerRay;
  41245. /**
  41246. * Simulates the start of a pointer drag event on the behavior
  41247. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41248. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41249. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41250. */
  41251. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41252. private _startDrag;
  41253. private _dragDelta;
  41254. private _moveDrag;
  41255. private _pickWithRayOnDragPlane;
  41256. private _pointA;
  41257. private _pointB;
  41258. private _pointC;
  41259. private _lineA;
  41260. private _lineB;
  41261. private _localAxis;
  41262. private _lookAt;
  41263. private _updateDragPlanePosition;
  41264. /**
  41265. * Detaches the behavior from the mesh
  41266. */
  41267. detach(): void;
  41268. }
  41269. }
  41270. declare module BABYLON {
  41271. /**
  41272. * 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
  41273. */
  41274. class SixDofDragBehavior implements Behavior<Mesh> {
  41275. private static _virtualScene;
  41276. private _ownerNode;
  41277. private _sceneRenderObserver;
  41278. private _scene;
  41279. private _targetPosition;
  41280. private _virtualOriginMesh;
  41281. private _virtualDragMesh;
  41282. private _pointerObserver;
  41283. private _moving;
  41284. private _startingOrientation;
  41285. /**
  41286. * 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)
  41287. */
  41288. private zDragFactor;
  41289. /**
  41290. * If the object should rotate to face the drag origin
  41291. */
  41292. rotateDraggedObject: boolean;
  41293. /**
  41294. * If the behavior is currently in a dragging state
  41295. */
  41296. dragging: boolean;
  41297. /**
  41298. * 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)
  41299. */
  41300. dragDeltaRatio: number;
  41301. /**
  41302. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41303. */
  41304. currentDraggingPointerID: number;
  41305. /**
  41306. * If camera controls should be detached during the drag
  41307. */
  41308. detachCameraControls: boolean;
  41309. /**
  41310. * Fires each time a drag starts
  41311. */
  41312. onDragStartObservable: Observable<{}>;
  41313. /**
  41314. * Fires each time a drag ends (eg. mouse release after drag)
  41315. */
  41316. onDragEndObservable: Observable<{}>;
  41317. /**
  41318. * 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
  41319. */
  41320. constructor();
  41321. /**
  41322. * The name of the behavior
  41323. */
  41324. readonly name: string;
  41325. /**
  41326. * Initializes the behavior
  41327. */
  41328. init(): void;
  41329. /**
  41330. * Attaches the scale behavior the passed in mesh
  41331. * @param ownerNode The mesh that will be scaled around once attached
  41332. */
  41333. attach(ownerNode: Mesh): void;
  41334. /**
  41335. * Detaches the behavior from the mesh
  41336. */
  41337. detach(): void;
  41338. }
  41339. }
  41340. declare module BABYLON {
  41341. /**
  41342. * Manage the gamepad inputs to control an arc rotate camera.
  41343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41344. */
  41345. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41346. /**
  41347. * Defines the camera the input is attached to.
  41348. */
  41349. camera: ArcRotateCamera;
  41350. /**
  41351. * Defines the gamepad the input is gathering event from.
  41352. */
  41353. gamepad: Nullable<Gamepad>;
  41354. /**
  41355. * Defines the gamepad rotation sensiblity.
  41356. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41357. */
  41358. gamepadRotationSensibility: number;
  41359. /**
  41360. * Defines the gamepad move sensiblity.
  41361. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41362. */
  41363. gamepadMoveSensibility: number;
  41364. private _onGamepadConnectedObserver;
  41365. private _onGamepadDisconnectedObserver;
  41366. /**
  41367. * Attach the input controls to a specific dom element to get the input from.
  41368. * @param element Defines the element the controls should be listened from
  41369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41370. */
  41371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41372. /**
  41373. * Detach the current controls from the specified dom element.
  41374. * @param element Defines the element to stop listening the inputs from
  41375. */
  41376. detachControl(element: Nullable<HTMLElement>): void;
  41377. /**
  41378. * Update the current camera state depending on the inputs that have been used this frame.
  41379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41380. */
  41381. checkInputs(): void;
  41382. /**
  41383. * Gets the class name of the current intput.
  41384. * @returns the class name
  41385. */
  41386. getClassName(): string;
  41387. /**
  41388. * Get the friendly name associated with the input class.
  41389. * @returns the input friendly name
  41390. */
  41391. getSimpleName(): string;
  41392. }
  41393. }
  41394. declare module BABYLON {
  41395. /**
  41396. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41398. */
  41399. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41400. /**
  41401. * Defines the camera the input is attached to.
  41402. */
  41403. camera: ArcRotateCamera;
  41404. /**
  41405. * Defines the list of key codes associated with the up action (increase alpha)
  41406. */
  41407. keysUp: number[];
  41408. /**
  41409. * Defines the list of key codes associated with the down action (decrease alpha)
  41410. */
  41411. keysDown: number[];
  41412. /**
  41413. * Defines the list of key codes associated with the left action (increase beta)
  41414. */
  41415. keysLeft: number[];
  41416. /**
  41417. * Defines the list of key codes associated with the right action (decrease beta)
  41418. */
  41419. keysRight: number[];
  41420. /**
  41421. * Defines the list of key codes associated with the reset action.
  41422. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41423. */
  41424. keysReset: number[];
  41425. /**
  41426. * Defines the panning sensibility of the inputs.
  41427. * (How fast is the camera paning)
  41428. */
  41429. panningSensibility: number;
  41430. /**
  41431. * Defines the zooming sensibility of the inputs.
  41432. * (How fast is the camera zooming)
  41433. */
  41434. zoomingSensibility: number;
  41435. /**
  41436. * Defines wether maintaining the alt key down switch the movement mode from
  41437. * orientation to zoom.
  41438. */
  41439. useAltToZoom: boolean;
  41440. /**
  41441. * Rotation speed of the camera
  41442. */
  41443. angularSpeed: number;
  41444. private _keys;
  41445. private _ctrlPressed;
  41446. private _altPressed;
  41447. private _onCanvasBlurObserver;
  41448. private _onKeyboardObserver;
  41449. private _engine;
  41450. private _scene;
  41451. /**
  41452. * Attach the input controls to a specific dom element to get the input from.
  41453. * @param element Defines the element the controls should be listened from
  41454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41455. */
  41456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41457. /**
  41458. * Detach the current controls from the specified dom element.
  41459. * @param element Defines the element to stop listening the inputs from
  41460. */
  41461. detachControl(element: Nullable<HTMLElement>): void;
  41462. /**
  41463. * Update the current camera state depending on the inputs that have been used this frame.
  41464. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41465. */
  41466. checkInputs(): void;
  41467. /**
  41468. * Gets the class name of the current intput.
  41469. * @returns the class name
  41470. */
  41471. getClassName(): string;
  41472. /**
  41473. * Get the friendly name associated with the input class.
  41474. * @returns the input friendly name
  41475. */
  41476. getSimpleName(): string;
  41477. }
  41478. }
  41479. declare module BABYLON {
  41480. /**
  41481. * Manage the mouse wheel inputs to control an arc rotate camera.
  41482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41483. */
  41484. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41485. /**
  41486. * Defines the camera the input is attached to.
  41487. */
  41488. camera: ArcRotateCamera;
  41489. /**
  41490. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41491. */
  41492. wheelPrecision: number;
  41493. /**
  41494. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41495. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41496. */
  41497. wheelDeltaPercentage: number;
  41498. private _wheel;
  41499. private _observer;
  41500. /**
  41501. * Attach the input controls to a specific dom element to get the input from.
  41502. * @param element Defines the element the controls should be listened from
  41503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41504. */
  41505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41506. /**
  41507. * Detach the current controls from the specified dom element.
  41508. * @param element Defines the element to stop listening the inputs from
  41509. */
  41510. detachControl(element: Nullable<HTMLElement>): void;
  41511. /**
  41512. * Gets the class name of the current intput.
  41513. * @returns the class name
  41514. */
  41515. getClassName(): string;
  41516. /**
  41517. * Get the friendly name associated with the input class.
  41518. * @returns the input friendly name
  41519. */
  41520. getSimpleName(): string;
  41521. }
  41522. }
  41523. declare module BABYLON {
  41524. /**
  41525. * Manage the pointers inputs to control an arc rotate camera.
  41526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41527. */
  41528. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41529. /**
  41530. * Defines the camera the input is attached to.
  41531. */
  41532. camera: ArcRotateCamera;
  41533. /**
  41534. * Defines the buttons associated with the input to handle camera move.
  41535. */
  41536. buttons: number[];
  41537. /**
  41538. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41539. */
  41540. angularSensibilityX: number;
  41541. /**
  41542. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41543. */
  41544. angularSensibilityY: number;
  41545. /**
  41546. * Defines the pointer pinch precision or how fast is the camera zooming.
  41547. */
  41548. pinchPrecision: number;
  41549. /**
  41550. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41551. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41552. */
  41553. pinchDeltaPercentage: number;
  41554. /**
  41555. * Defines the pointer panning sensibility or how fast is the camera moving.
  41556. */
  41557. panningSensibility: number;
  41558. /**
  41559. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41560. */
  41561. multiTouchPanning: boolean;
  41562. /**
  41563. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41564. */
  41565. multiTouchPanAndZoom: boolean;
  41566. /**
  41567. * Revers pinch action direction.
  41568. */
  41569. pinchInwards: boolean;
  41570. private _isPanClick;
  41571. private _pointerInput;
  41572. private _observer;
  41573. private _onMouseMove;
  41574. private _onGestureStart;
  41575. private _onGesture;
  41576. private _MSGestureHandler;
  41577. private _onLostFocus;
  41578. private _onContextMenu;
  41579. /**
  41580. * Attach the input controls to a specific dom element to get the input from.
  41581. * @param element Defines the element the controls should be listened from
  41582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41583. */
  41584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41585. /**
  41586. * Detach the current controls from the specified dom element.
  41587. * @param element Defines the element to stop listening the inputs from
  41588. */
  41589. detachControl(element: Nullable<HTMLElement>): void;
  41590. /**
  41591. * Gets the class name of the current intput.
  41592. * @returns the class name
  41593. */
  41594. getClassName(): string;
  41595. /**
  41596. * Get the friendly name associated with the input class.
  41597. * @returns the input friendly name
  41598. */
  41599. getSimpleName(): string;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41606. */
  41607. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41608. /**
  41609. * Defines the camera the input is attached to.
  41610. */
  41611. camera: ArcRotateCamera;
  41612. /**
  41613. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41614. */
  41615. alphaCorrection: number;
  41616. /**
  41617. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41618. */
  41619. gammaCorrection: number;
  41620. private _alpha;
  41621. private _gamma;
  41622. private _dirty;
  41623. private _deviceOrientationHandler;
  41624. /**
  41625. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41626. */
  41627. constructor();
  41628. /**
  41629. * Attach the input controls to a specific dom element to get the input from.
  41630. * @param element Defines the element the controls should be listened from
  41631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41632. */
  41633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41634. /** @hidden */
  41635. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41636. /**
  41637. * Update the current camera state depending on the inputs that have been used this frame.
  41638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41639. */
  41640. checkInputs(): void;
  41641. /**
  41642. * Detach the current controls from the specified dom element.
  41643. * @param element Defines the element to stop listening the inputs from
  41644. */
  41645. detachControl(element: Nullable<HTMLElement>): void;
  41646. /**
  41647. * Gets the class name of the current intput.
  41648. * @returns the class name
  41649. */
  41650. getClassName(): string;
  41651. /**
  41652. * Get the friendly name associated with the input class.
  41653. * @returns the input friendly name
  41654. */
  41655. getSimpleName(): string;
  41656. }
  41657. }
  41658. declare module BABYLON {
  41659. /**
  41660. * Listen to keyboard events to control the camera.
  41661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41662. */
  41663. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41664. /**
  41665. * Defines the camera the input is attached to.
  41666. */
  41667. camera: FlyCamera;
  41668. /**
  41669. * The list of keyboard keys used to control the forward move of the camera.
  41670. */
  41671. keysForward: number[];
  41672. /**
  41673. * The list of keyboard keys used to control the backward move of the camera.
  41674. */
  41675. keysBackward: number[];
  41676. /**
  41677. * The list of keyboard keys used to control the forward move of the camera.
  41678. */
  41679. keysUp: number[];
  41680. /**
  41681. * The list of keyboard keys used to control the backward move of the camera.
  41682. */
  41683. keysDown: number[];
  41684. /**
  41685. * The list of keyboard keys used to control the right strafe move of the camera.
  41686. */
  41687. keysRight: number[];
  41688. /**
  41689. * The list of keyboard keys used to control the left strafe move of the camera.
  41690. */
  41691. keysLeft: number[];
  41692. private _keys;
  41693. private _onCanvasBlurObserver;
  41694. private _onKeyboardObserver;
  41695. private _engine;
  41696. private _scene;
  41697. /**
  41698. * Attach the input controls to a specific dom element to get the input from.
  41699. * @param element Defines the element the controls should be listened from
  41700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41701. */
  41702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41703. /**
  41704. * Detach the current controls from the specified dom element.
  41705. * @param element Defines the element to stop listening the inputs from
  41706. */
  41707. detachControl(element: Nullable<HTMLElement>): void;
  41708. /**
  41709. * Gets the class name of the current intput.
  41710. * @returns the class name
  41711. */
  41712. getClassName(): string;
  41713. /** @hidden */
  41714. _onLostFocus(e: FocusEvent): void;
  41715. /**
  41716. * Get the friendly name associated with the input class.
  41717. * @returns the input friendly name
  41718. */
  41719. getSimpleName(): string;
  41720. /**
  41721. * Update the current camera state depending on the inputs that have been used this frame.
  41722. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41723. */
  41724. checkInputs(): void;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Listen to mouse events to control the camera.
  41730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41731. */
  41732. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41733. /**
  41734. * Defines the camera the input is attached to.
  41735. */
  41736. camera: FlyCamera;
  41737. /**
  41738. * Defines if touch is enabled. (Default is true.)
  41739. */
  41740. touchEnabled: boolean;
  41741. /**
  41742. * Defines the buttons associated with the input to handle camera rotation.
  41743. */
  41744. buttons: number[];
  41745. /**
  41746. * Assign buttons for Yaw control.
  41747. */
  41748. buttonsYaw: number[];
  41749. /**
  41750. * Assign buttons for Pitch control.
  41751. */
  41752. buttonsPitch: number[];
  41753. /**
  41754. * Assign buttons for Roll control.
  41755. */
  41756. buttonsRoll: number[];
  41757. /**
  41758. * Detect if any button is being pressed while mouse is moved.
  41759. * -1 = Mouse locked.
  41760. * 0 = Left button.
  41761. * 1 = Middle Button.
  41762. * 2 = Right Button.
  41763. */
  41764. activeButton: number;
  41765. /**
  41766. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41767. * Higher values reduce its sensitivity.
  41768. */
  41769. angularSensibility: number;
  41770. private _mousemoveCallback;
  41771. private _observer;
  41772. private _rollObserver;
  41773. private previousPosition;
  41774. private noPreventDefault;
  41775. private element;
  41776. /**
  41777. * Listen to mouse events to control the camera.
  41778. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41780. */
  41781. constructor(touchEnabled?: boolean);
  41782. /**
  41783. * Attach the mouse control to the HTML DOM element.
  41784. * @param element Defines the element that listens to the input events.
  41785. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41786. */
  41787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41788. /**
  41789. * Detach the current controls from the specified dom element.
  41790. * @param element Defines the element to stop listening the inputs from
  41791. */
  41792. detachControl(element: Nullable<HTMLElement>): void;
  41793. /**
  41794. * Gets the class name of the current input.
  41795. * @returns the class name.
  41796. */
  41797. getClassName(): string;
  41798. /**
  41799. * Get the friendly name associated with the input class.
  41800. * @returns the input's friendly name.
  41801. */
  41802. getSimpleName(): string;
  41803. private _pointerInput;
  41804. private _onMouseMove;
  41805. /**
  41806. * Rotate camera by mouse offset.
  41807. */
  41808. private rotateCamera;
  41809. }
  41810. }
  41811. declare module BABYLON {
  41812. /**
  41813. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41814. * Screen rotation is taken into account.
  41815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41816. */
  41817. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41818. private _camera;
  41819. private _screenOrientationAngle;
  41820. private _constantTranform;
  41821. private _screenQuaternion;
  41822. private _alpha;
  41823. private _beta;
  41824. private _gamma;
  41825. /**
  41826. * Instantiates a new input
  41827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41828. */
  41829. constructor();
  41830. /**
  41831. * Define the camera controlled by the input.
  41832. */
  41833. camera: FreeCamera;
  41834. /**
  41835. * Attach the input controls to a specific dom element to get the input from.
  41836. * @param element Defines the element the controls should be listened from
  41837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41838. */
  41839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41840. private _orientationChanged;
  41841. private _deviceOrientation;
  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. * Update the current camera state depending on the inputs that have been used this frame.
  41849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41850. */
  41851. checkInputs(): void;
  41852. /**
  41853. * Gets the class name of the current intput.
  41854. * @returns the class name
  41855. */
  41856. getClassName(): string;
  41857. /**
  41858. * Get the friendly name associated with the input class.
  41859. * @returns the input friendly name
  41860. */
  41861. getSimpleName(): string;
  41862. }
  41863. }
  41864. declare module BABYLON {
  41865. /**
  41866. * Manage the gamepad inputs to control a free camera.
  41867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41868. */
  41869. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41870. /**
  41871. * Define the camera the input is attached to.
  41872. */
  41873. camera: FreeCamera;
  41874. /**
  41875. * Define the Gamepad controlling the input
  41876. */
  41877. gamepad: Nullable<Gamepad>;
  41878. /**
  41879. * Defines the gamepad rotation sensiblity.
  41880. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41881. */
  41882. gamepadAngularSensibility: number;
  41883. /**
  41884. * Defines the gamepad move sensiblity.
  41885. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41886. */
  41887. gamepadMoveSensibility: number;
  41888. private _onGamepadConnectedObserver;
  41889. private _onGamepadDisconnectedObserver;
  41890. private _cameraTransform;
  41891. private _deltaTransform;
  41892. private _vector3;
  41893. private _vector2;
  41894. /**
  41895. * Attach the input controls to a specific dom element to get the input from.
  41896. * @param element Defines the element the controls should be listened from
  41897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41898. */
  41899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41900. /**
  41901. * Detach the current controls from the specified dom element.
  41902. * @param element Defines the element to stop listening the inputs from
  41903. */
  41904. detachControl(element: Nullable<HTMLElement>): void;
  41905. /**
  41906. * Update the current camera state depending on the inputs that have been used this frame.
  41907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41908. */
  41909. checkInputs(): void;
  41910. /**
  41911. * Gets the class name of the current intput.
  41912. * @returns the class name
  41913. */
  41914. getClassName(): string;
  41915. /**
  41916. * Get the friendly name associated with the input class.
  41917. * @returns the input friendly name
  41918. */
  41919. getSimpleName(): string;
  41920. }
  41921. }
  41922. declare module BABYLON {
  41923. /**
  41924. * Manage the keyboard inputs to control the movement of a free camera.
  41925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41926. */
  41927. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41928. /**
  41929. * Defines the camera the input is attached to.
  41930. */
  41931. camera: FreeCamera;
  41932. /**
  41933. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41934. */
  41935. keysUp: number[];
  41936. /**
  41937. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41938. */
  41939. keysDown: number[];
  41940. /**
  41941. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41942. */
  41943. keysLeft: number[];
  41944. /**
  41945. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41946. */
  41947. keysRight: number[];
  41948. private _keys;
  41949. private _onCanvasBlurObserver;
  41950. private _onKeyboardObserver;
  41951. private _engine;
  41952. private _scene;
  41953. /**
  41954. * Attach the input controls to a specific dom element to get the input from.
  41955. * @param element Defines the element the controls should be listened from
  41956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41957. */
  41958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41959. /**
  41960. * Detach the current controls from the specified dom element.
  41961. * @param element Defines the element to stop listening the inputs from
  41962. */
  41963. detachControl(element: Nullable<HTMLElement>): void;
  41964. /**
  41965. * Update the current camera state depending on the inputs that have been used this frame.
  41966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41967. */
  41968. checkInputs(): void;
  41969. /**
  41970. * Gets the class name of the current intput.
  41971. * @returns the class name
  41972. */
  41973. getClassName(): string;
  41974. /** @hidden */
  41975. _onLostFocus(e: FocusEvent): void;
  41976. /**
  41977. * Get the friendly name associated with the input class.
  41978. * @returns the input friendly name
  41979. */
  41980. getSimpleName(): string;
  41981. }
  41982. }
  41983. declare module BABYLON {
  41984. /**
  41985. * Manage the mouse inputs to control the movement of a free camera.
  41986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41987. */
  41988. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41989. /**
  41990. * Define if touch is enabled in the mouse input
  41991. */
  41992. touchEnabled: boolean;
  41993. /**
  41994. * Defines the camera the input is attached to.
  41995. */
  41996. camera: FreeCamera;
  41997. /**
  41998. * Defines the buttons associated with the input to handle camera move.
  41999. */
  42000. buttons: number[];
  42001. /**
  42002. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42003. */
  42004. angularSensibility: number;
  42005. private _pointerInput;
  42006. private _onMouseMove;
  42007. private _observer;
  42008. private previousPosition;
  42009. /**
  42010. * Manage the mouse inputs to control the movement of a free camera.
  42011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42012. * @param touchEnabled Defines if touch is enabled or not
  42013. */
  42014. constructor(
  42015. /**
  42016. * Define if touch is enabled in the mouse input
  42017. */
  42018. touchEnabled?: boolean);
  42019. /**
  42020. * Attach the input controls to a specific dom element to get the input from.
  42021. * @param element Defines the element the controls should be listened from
  42022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42023. */
  42024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42025. /**
  42026. * Detach the current controls from the specified dom element.
  42027. * @param element Defines the element to stop listening the inputs from
  42028. */
  42029. detachControl(element: Nullable<HTMLElement>): void;
  42030. /**
  42031. * Gets the class name of the current intput.
  42032. * @returns the class name
  42033. */
  42034. getClassName(): string;
  42035. /**
  42036. * Get the friendly name associated with the input class.
  42037. * @returns the input friendly name
  42038. */
  42039. getSimpleName(): string;
  42040. }
  42041. }
  42042. declare module BABYLON {
  42043. /**
  42044. * Manage the touch inputs to control the movement of a free camera.
  42045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42046. */
  42047. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42048. /**
  42049. * Defines the camera the input is attached to.
  42050. */
  42051. camera: FreeCamera;
  42052. /**
  42053. * Defines the touch sensibility for rotation.
  42054. * The higher the faster.
  42055. */
  42056. touchAngularSensibility: number;
  42057. /**
  42058. * Defines the touch sensibility for move.
  42059. * The higher the faster.
  42060. */
  42061. touchMoveSensibility: number;
  42062. private _offsetX;
  42063. private _offsetY;
  42064. private _pointerPressed;
  42065. private _pointerInput;
  42066. private _observer;
  42067. private _onLostFocus;
  42068. /**
  42069. * Attach the input controls to a specific dom element to get the input from.
  42070. * @param element Defines the element the controls should be listened from
  42071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42072. */
  42073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42074. /**
  42075. * Detach the current controls from the specified dom element.
  42076. * @param element Defines the element to stop listening the inputs from
  42077. */
  42078. detachControl(element: Nullable<HTMLElement>): void;
  42079. /**
  42080. * Update the current camera state depending on the inputs that have been used this frame.
  42081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42082. */
  42083. checkInputs(): void;
  42084. /**
  42085. * Gets the class name of the current intput.
  42086. * @returns the class name
  42087. */
  42088. getClassName(): string;
  42089. /**
  42090. * Get the friendly name associated with the input class.
  42091. * @returns the input friendly name
  42092. */
  42093. getSimpleName(): string;
  42094. }
  42095. }
  42096. declare module BABYLON {
  42097. /**
  42098. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42100. */
  42101. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42102. /**
  42103. * Defines the camera the input is attached to.
  42104. */
  42105. camera: FreeCamera;
  42106. private _leftjoystick;
  42107. private _rightjoystick;
  42108. /**
  42109. * Gets the left stick of the virtual joystick.
  42110. * @returns The virtual Joystick
  42111. */
  42112. getLeftJoystick(): VirtualJoystick;
  42113. /**
  42114. * Gets the right stick of the virtual joystick.
  42115. * @returns The virtual Joystick
  42116. */
  42117. getRightJoystick(): VirtualJoystick;
  42118. /**
  42119. * Update the current camera state depending on the inputs that have been used this frame.
  42120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42121. */
  42122. checkInputs(): void;
  42123. /**
  42124. * Attach the input controls to a specific dom element to get the input from.
  42125. * @param element Defines the element the controls should be listened from
  42126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42127. */
  42128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42129. /**
  42130. * Detach the current controls from the specified dom element.
  42131. * @param element Defines the element to stop listening the inputs from
  42132. */
  42133. detachControl(element: Nullable<HTMLElement>): void;
  42134. /**
  42135. * Gets the class name of the current intput.
  42136. * @returns the class name
  42137. */
  42138. getClassName(): string;
  42139. /**
  42140. * Get the friendly name associated with the input class.
  42141. * @returns the input friendly name
  42142. */
  42143. getSimpleName(): string;
  42144. }
  42145. }
  42146. declare module BABYLON {
  42147. /**
  42148. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42149. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42150. */
  42151. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42152. /**
  42153. * Creates a new AnaglyphArcRotateCamera
  42154. * @param name defines camera name
  42155. * @param alpha defines alpha angle (in radians)
  42156. * @param beta defines beta angle (in radians)
  42157. * @param radius defines radius
  42158. * @param target defines camera target
  42159. * @param interaxialDistance defines distance between each color axis
  42160. * @param scene defines the hosting scene
  42161. */
  42162. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42163. /**
  42164. * Gets camera class name
  42165. * @returns AnaglyphArcRotateCamera
  42166. */
  42167. getClassName(): string;
  42168. }
  42169. }
  42170. declare module BABYLON {
  42171. /**
  42172. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42173. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42174. */
  42175. class AnaglyphFreeCamera extends FreeCamera {
  42176. /**
  42177. * Creates a new AnaglyphFreeCamera
  42178. * @param name defines camera name
  42179. * @param position defines initial position
  42180. * @param interaxialDistance defines distance between each color axis
  42181. * @param scene defines the hosting scene
  42182. */
  42183. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42184. /**
  42185. * Gets camera class name
  42186. * @returns AnaglyphFreeCamera
  42187. */
  42188. getClassName(): string;
  42189. }
  42190. }
  42191. declare module BABYLON {
  42192. /**
  42193. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42194. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42195. */
  42196. class AnaglyphGamepadCamera extends GamepadCamera {
  42197. /**
  42198. * Creates a new AnaglyphGamepadCamera
  42199. * @param name defines camera name
  42200. * @param position defines initial position
  42201. * @param interaxialDistance defines distance between each color axis
  42202. * @param scene defines the hosting scene
  42203. */
  42204. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42205. /**
  42206. * Gets camera class name
  42207. * @returns AnaglyphGamepadCamera
  42208. */
  42209. getClassName(): string;
  42210. }
  42211. }
  42212. declare module BABYLON {
  42213. /**
  42214. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42215. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42216. */
  42217. class AnaglyphUniversalCamera extends UniversalCamera {
  42218. /**
  42219. * Creates a new AnaglyphUniversalCamera
  42220. * @param name defines camera name
  42221. * @param position defines initial position
  42222. * @param interaxialDistance defines distance between each color axis
  42223. * @param scene defines the hosting scene
  42224. */
  42225. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42226. /**
  42227. * Gets camera class name
  42228. * @returns AnaglyphUniversalCamera
  42229. */
  42230. getClassName(): string;
  42231. }
  42232. }
  42233. declare module BABYLON {
  42234. /**
  42235. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42236. * @see http://doc.babylonjs.com/features/cameras
  42237. */
  42238. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42239. /**
  42240. * Creates a new StereoscopicArcRotateCamera
  42241. * @param name defines camera name
  42242. * @param alpha defines alpha angle (in radians)
  42243. * @param beta defines beta angle (in radians)
  42244. * @param radius defines radius
  42245. * @param target defines camera target
  42246. * @param interaxialDistance defines distance between each color axis
  42247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42248. * @param scene defines the hosting scene
  42249. */
  42250. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42251. /**
  42252. * Gets camera class name
  42253. * @returns StereoscopicArcRotateCamera
  42254. */
  42255. getClassName(): string;
  42256. }
  42257. }
  42258. declare module BABYLON {
  42259. /**
  42260. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42261. * @see http://doc.babylonjs.com/features/cameras
  42262. */
  42263. class StereoscopicFreeCamera extends FreeCamera {
  42264. /**
  42265. * Creates a new StereoscopicFreeCamera
  42266. * @param name defines camera name
  42267. * @param position defines initial position
  42268. * @param interaxialDistance defines distance between each color axis
  42269. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42270. * @param scene defines the hosting scene
  42271. */
  42272. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42273. /**
  42274. * Gets camera class name
  42275. * @returns StereoscopicFreeCamera
  42276. */
  42277. getClassName(): string;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42283. * @see http://doc.babylonjs.com/features/cameras
  42284. */
  42285. class StereoscopicGamepadCamera extends GamepadCamera {
  42286. /**
  42287. * Creates a new StereoscopicGamepadCamera
  42288. * @param name defines camera name
  42289. * @param position defines initial position
  42290. * @param interaxialDistance defines distance between each color axis
  42291. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42292. * @param scene defines the hosting scene
  42293. */
  42294. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42295. /**
  42296. * Gets camera class name
  42297. * @returns StereoscopicGamepadCamera
  42298. */
  42299. getClassName(): string;
  42300. }
  42301. }
  42302. declare module BABYLON {
  42303. /**
  42304. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42305. * @see http://doc.babylonjs.com/features/cameras
  42306. */
  42307. class StereoscopicUniversalCamera extends UniversalCamera {
  42308. /**
  42309. * Creates a new StereoscopicUniversalCamera
  42310. * @param name defines camera name
  42311. * @param position defines initial position
  42312. * @param interaxialDistance defines distance between each color axis
  42313. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42314. * @param scene defines the hosting scene
  42315. */
  42316. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42317. /**
  42318. * Gets camera class name
  42319. * @returns StereoscopicUniversalCamera
  42320. */
  42321. getClassName(): string;
  42322. }
  42323. }
  42324. declare module BABYLON {
  42325. /**
  42326. * This represents all the required metrics to create a VR camera.
  42327. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42328. */
  42329. class VRCameraMetrics {
  42330. /**
  42331. * Define the horizontal resolution off the screen.
  42332. */
  42333. hResolution: number;
  42334. /**
  42335. * Define the vertical resolution off the screen.
  42336. */
  42337. vResolution: number;
  42338. /**
  42339. * Define the horizontal screen size.
  42340. */
  42341. hScreenSize: number;
  42342. /**
  42343. * Define the vertical screen size.
  42344. */
  42345. vScreenSize: number;
  42346. /**
  42347. * Define the vertical screen center position.
  42348. */
  42349. vScreenCenter: number;
  42350. /**
  42351. * Define the distance of the eyes to the screen.
  42352. */
  42353. eyeToScreenDistance: number;
  42354. /**
  42355. * Define the distance between both lenses
  42356. */
  42357. lensSeparationDistance: number;
  42358. /**
  42359. * Define the distance between both viewer's eyes.
  42360. */
  42361. interpupillaryDistance: number;
  42362. /**
  42363. * Define the distortion factor of the VR postprocess.
  42364. * Please, touch with care.
  42365. */
  42366. distortionK: number[];
  42367. /**
  42368. * Define the chromatic aberration correction factors for the VR post process.
  42369. */
  42370. chromaAbCorrection: number[];
  42371. /**
  42372. * Define the scale factor of the post process.
  42373. * The smaller the better but the slower.
  42374. */
  42375. postProcessScaleFactor: number;
  42376. /**
  42377. * Define an offset for the lens center.
  42378. */
  42379. lensCenterOffset: number;
  42380. /**
  42381. * Define if the current vr camera should compensate the distortion of the lense or not.
  42382. */
  42383. compensateDistortion: boolean;
  42384. /**
  42385. * Gets the rendering aspect ratio based on the provided resolutions.
  42386. */
  42387. readonly aspectRatio: number;
  42388. /**
  42389. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42390. */
  42391. readonly aspectRatioFov: number;
  42392. /**
  42393. * @hidden
  42394. */
  42395. readonly leftHMatrix: Matrix;
  42396. /**
  42397. * @hidden
  42398. */
  42399. readonly rightHMatrix: Matrix;
  42400. /**
  42401. * @hidden
  42402. */
  42403. readonly leftPreViewMatrix: Matrix;
  42404. /**
  42405. * @hidden
  42406. */
  42407. readonly rightPreViewMatrix: Matrix;
  42408. /**
  42409. * Get the default VRMetrics based on the most generic setup.
  42410. * @returns the default vr metrics
  42411. */
  42412. static GetDefault(): VRCameraMetrics;
  42413. }
  42414. }
  42415. declare module BABYLON {
  42416. /**
  42417. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42418. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42419. */
  42420. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42421. /**
  42422. * Creates a new VRDeviceOrientationArcRotateCamera
  42423. * @param name defines camera name
  42424. * @param alpha defines the camera rotation along the logitudinal axis
  42425. * @param beta defines the camera rotation along the latitudinal axis
  42426. * @param radius defines the camera distance from its target
  42427. * @param target defines the camera target
  42428. * @param scene defines the scene the camera belongs to
  42429. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42430. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42431. */
  42432. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42433. /**
  42434. * Gets camera class name
  42435. * @returns VRDeviceOrientationArcRotateCamera
  42436. */
  42437. getClassName(): string;
  42438. }
  42439. }
  42440. declare module BABYLON {
  42441. /**
  42442. * Camera used to simulate VR rendering (based on FreeCamera)
  42443. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42444. */
  42445. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42446. /**
  42447. * Creates a new VRDeviceOrientationFreeCamera
  42448. * @param name defines camera name
  42449. * @param position defines the start position of the camera
  42450. * @param scene defines the scene the camera belongs to
  42451. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42452. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42453. */
  42454. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42455. /**
  42456. * Gets camera class name
  42457. * @returns VRDeviceOrientationFreeCamera
  42458. */
  42459. getClassName(): string;
  42460. }
  42461. }
  42462. declare module BABYLON {
  42463. /**
  42464. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42465. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42466. */
  42467. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42468. /**
  42469. * Creates a new VRDeviceOrientationGamepadCamera
  42470. * @param name defines camera name
  42471. * @param position defines the start position of the camera
  42472. * @param scene defines the scene the camera belongs to
  42473. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42474. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42475. */
  42476. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42477. /**
  42478. * Gets camera class name
  42479. * @returns VRDeviceOrientationGamepadCamera
  42480. */
  42481. getClassName(): string;
  42482. }
  42483. }
  42484. declare module BABYLON {
  42485. /**
  42486. * Options to modify the vr teleportation behavior.
  42487. */
  42488. interface VRTeleportationOptions {
  42489. /**
  42490. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42491. */
  42492. floorMeshName?: string;
  42493. /**
  42494. * A list of meshes to be used as the teleportation floor. (default: empty)
  42495. */
  42496. floorMeshes?: Mesh[];
  42497. }
  42498. /**
  42499. * Options to modify the vr experience helper's behavior.
  42500. */
  42501. interface VRExperienceHelperOptions extends WebVROptions {
  42502. /**
  42503. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42504. */
  42505. createDeviceOrientationCamera?: boolean;
  42506. /**
  42507. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42508. */
  42509. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42510. /**
  42511. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42512. */
  42513. laserToggle?: boolean;
  42514. /**
  42515. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42516. */
  42517. floorMeshes?: Mesh[];
  42518. }
  42519. /**
  42520. * Helps to quickly add VR support to an existing scene.
  42521. * See http://doc.babylonjs.com/how_to/webvr_helper
  42522. */
  42523. class VRExperienceHelper {
  42524. /** Options to modify the vr experience helper's behavior. */
  42525. webVROptions: VRExperienceHelperOptions;
  42526. private _scene;
  42527. private _position;
  42528. private _btnVR;
  42529. private _btnVRDisplayed;
  42530. private _webVRsupported;
  42531. private _webVRready;
  42532. private _webVRrequesting;
  42533. private _webVRpresenting;
  42534. private _hasEnteredVR;
  42535. private _fullscreenVRpresenting;
  42536. private _canvas;
  42537. private _webVRCamera;
  42538. private _vrDeviceOrientationCamera;
  42539. private _deviceOrientationCamera;
  42540. private _existingCamera;
  42541. private _onKeyDown;
  42542. private _onVrDisplayPresentChange;
  42543. private _onVRDisplayChanged;
  42544. private _onVRRequestPresentStart;
  42545. private _onVRRequestPresentComplete;
  42546. /**
  42547. * Observable raised when entering VR.
  42548. */
  42549. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42550. /**
  42551. * Observable raised when exiting VR.
  42552. */
  42553. onExitingVRObservable: Observable<VRExperienceHelper>;
  42554. /**
  42555. * Observable raised when controller mesh is loaded.
  42556. */
  42557. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42558. /** Return this.onEnteringVRObservable
  42559. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42560. */
  42561. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42562. /** Return this.onExitingVRObservable
  42563. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42564. */
  42565. readonly onExitingVR: Observable<VRExperienceHelper>;
  42566. /** Return this.onControllerMeshLoadedObservable
  42567. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42568. */
  42569. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42570. private _rayLength;
  42571. private _useCustomVRButton;
  42572. private _teleportationRequested;
  42573. private _teleportActive;
  42574. private _floorMeshName;
  42575. private _floorMeshesCollection;
  42576. private _rotationAllowed;
  42577. private _teleportBackwardsVector;
  42578. private _teleportationTarget;
  42579. private _isDefaultTeleportationTarget;
  42580. private _postProcessMove;
  42581. private _teleportationFillColor;
  42582. private _teleportationBorderColor;
  42583. private _rotationAngle;
  42584. private _haloCenter;
  42585. private _cameraGazer;
  42586. private _padSensibilityUp;
  42587. private _padSensibilityDown;
  42588. private _leftController;
  42589. private _rightController;
  42590. /**
  42591. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42592. */
  42593. onNewMeshSelected: Observable<AbstractMesh>;
  42594. /**
  42595. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42596. */
  42597. onNewMeshPicked: Observable<PickingInfo>;
  42598. private _circleEase;
  42599. /**
  42600. * Observable raised before camera teleportation
  42601. */
  42602. onBeforeCameraTeleport: Observable<Vector3>;
  42603. /**
  42604. * Observable raised after camera teleportation
  42605. */
  42606. onAfterCameraTeleport: Observable<Vector3>;
  42607. /**
  42608. * Observable raised when current selected mesh gets unselected
  42609. */
  42610. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42611. private _raySelectionPredicate;
  42612. /**
  42613. * To be optionaly changed by user to define custom ray selection
  42614. */
  42615. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42616. /**
  42617. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42618. */
  42619. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42620. /**
  42621. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42622. */
  42623. teleportationEnabled: boolean;
  42624. private _defaultHeight;
  42625. private _teleportationInitialized;
  42626. private _interactionsEnabled;
  42627. private _interactionsRequested;
  42628. private _displayGaze;
  42629. private _displayLaserPointer;
  42630. /**
  42631. * The mesh used to display where the user is going to teleport.
  42632. */
  42633. /**
  42634. * Sets the mesh to be used to display where the user is going to teleport.
  42635. */
  42636. teleportationTarget: Mesh;
  42637. /**
  42638. * 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
  42639. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42640. * See http://doc.babylonjs.com/resources/baking_transformations
  42641. */
  42642. gazeTrackerMesh: Mesh;
  42643. /**
  42644. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42645. */
  42646. updateGazeTrackerScale: boolean;
  42647. /**
  42648. * If the gaze trackers color should be updated when selecting meshes
  42649. */
  42650. updateGazeTrackerColor: boolean;
  42651. /**
  42652. * The gaze tracking mesh corresponding to the left controller
  42653. */
  42654. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42655. /**
  42656. * The gaze tracking mesh corresponding to the right controller
  42657. */
  42658. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42659. /**
  42660. * If the ray of the gaze should be displayed.
  42661. */
  42662. /**
  42663. * Sets if the ray of the gaze should be displayed.
  42664. */
  42665. displayGaze: boolean;
  42666. /**
  42667. * If the ray of the LaserPointer should be displayed.
  42668. */
  42669. /**
  42670. * Sets if the ray of the LaserPointer should be displayed.
  42671. */
  42672. displayLaserPointer: boolean;
  42673. /**
  42674. * The deviceOrientationCamera used as the camera when not in VR.
  42675. */
  42676. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42677. /**
  42678. * Based on the current WebVR support, returns the current VR camera used.
  42679. */
  42680. readonly currentVRCamera: Nullable<Camera>;
  42681. /**
  42682. * The webVRCamera which is used when in VR.
  42683. */
  42684. readonly webVRCamera: WebVRFreeCamera;
  42685. /**
  42686. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42687. */
  42688. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42689. private readonly _teleportationRequestInitiated;
  42690. /**
  42691. * Instantiates a VRExperienceHelper.
  42692. * Helps to quickly add VR support to an existing scene.
  42693. * @param scene The scene the VRExperienceHelper belongs to.
  42694. * @param webVROptions Options to modify the vr experience helper's behavior.
  42695. */
  42696. constructor(scene: Scene,
  42697. /** Options to modify the vr experience helper's behavior. */
  42698. webVROptions?: VRExperienceHelperOptions);
  42699. private _onDefaultMeshLoaded;
  42700. private _onResize;
  42701. private _onFullscreenChange;
  42702. /**
  42703. * Gets a value indicating if we are currently in VR mode.
  42704. */
  42705. readonly isInVRMode: boolean;
  42706. private onVrDisplayPresentChange;
  42707. private onVRDisplayChanged;
  42708. private moveButtonToBottomRight;
  42709. private displayVRButton;
  42710. private updateButtonVisibility;
  42711. private _cachedAngularSensibility;
  42712. /**
  42713. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42714. * Otherwise, will use the fullscreen API.
  42715. */
  42716. enterVR(): void;
  42717. /**
  42718. * Attempt to exit VR, or fullscreen.
  42719. */
  42720. exitVR(): void;
  42721. /**
  42722. * The position of the vr experience helper.
  42723. */
  42724. /**
  42725. * Sets the position of the vr experience helper.
  42726. */
  42727. position: Vector3;
  42728. /**
  42729. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42730. */
  42731. enableInteractions(): void;
  42732. private readonly _noControllerIsActive;
  42733. private beforeRender;
  42734. private _isTeleportationFloor;
  42735. /**
  42736. * Adds a floor mesh to be used for teleportation.
  42737. * @param floorMesh the mesh to be used for teleportation.
  42738. */
  42739. addFloorMesh(floorMesh: Mesh): void;
  42740. /**
  42741. * Removes a floor mesh from being used for teleportation.
  42742. * @param floorMesh the mesh to be removed.
  42743. */
  42744. removeFloorMesh(floorMesh: Mesh): void;
  42745. /**
  42746. * Enables interactions and teleportation using the VR controllers and gaze.
  42747. * @param vrTeleportationOptions options to modify teleportation behavior.
  42748. */
  42749. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42750. private _onNewGamepadConnected;
  42751. private _tryEnableInteractionOnController;
  42752. private _onNewGamepadDisconnected;
  42753. private _enableInteractionOnController;
  42754. private _checkTeleportWithRay;
  42755. private _checkRotate;
  42756. private _checkTeleportBackwards;
  42757. private _enableTeleportationOnController;
  42758. private _createTeleportationCircles;
  42759. private _displayTeleportationTarget;
  42760. private _hideTeleportationTarget;
  42761. private _rotateCamera;
  42762. private _moveTeleportationSelectorTo;
  42763. private _workingVector;
  42764. private _workingQuaternion;
  42765. private _workingMatrix;
  42766. /**
  42767. * Teleports the users feet to the desired location
  42768. * @param location The location where the user's feet should be placed
  42769. */
  42770. teleportCamera(location: Vector3): void;
  42771. private _convertNormalToDirectionOfRay;
  42772. private _castRayAndSelectObject;
  42773. private _notifySelectedMeshUnselected;
  42774. /**
  42775. * Sets the color of the laser ray from the vr controllers.
  42776. * @param color new color for the ray.
  42777. */
  42778. changeLaserColor(color: Color3): void;
  42779. /**
  42780. * Sets the color of the ray from the vr headsets gaze.
  42781. * @param color new color for the ray.
  42782. */
  42783. changeGazeColor(color: Color3): void;
  42784. /**
  42785. * Exits VR and disposes of the vr experience helper
  42786. */
  42787. dispose(): void;
  42788. /**
  42789. * Gets the name of the VRExperienceHelper class
  42790. * @returns "VRExperienceHelper"
  42791. */
  42792. getClassName(): string;
  42793. }
  42794. }
  42795. declare module BABYLON {
  42796. /**
  42797. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42798. * IMPORTANT!! The data is right-hand data.
  42799. * @export
  42800. * @interface DevicePose
  42801. */
  42802. interface DevicePose {
  42803. /**
  42804. * The position of the device, values in array are [x,y,z].
  42805. */
  42806. readonly position: Nullable<Float32Array>;
  42807. /**
  42808. * The linearVelocity of the device, values in array are [x,y,z].
  42809. */
  42810. readonly linearVelocity: Nullable<Float32Array>;
  42811. /**
  42812. * The linearAcceleration of the device, values in array are [x,y,z].
  42813. */
  42814. readonly linearAcceleration: Nullable<Float32Array>;
  42815. /**
  42816. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42817. */
  42818. readonly orientation: Nullable<Float32Array>;
  42819. /**
  42820. * The angularVelocity of the device, values in array are [x,y,z].
  42821. */
  42822. readonly angularVelocity: Nullable<Float32Array>;
  42823. /**
  42824. * The angularAcceleration of the device, values in array are [x,y,z].
  42825. */
  42826. readonly angularAcceleration: Nullable<Float32Array>;
  42827. }
  42828. /**
  42829. * Interface representing a pose controlled object in Babylon.
  42830. * A pose controlled object has both regular pose values as well as pose values
  42831. * from an external device such as a VR head mounted display
  42832. */
  42833. interface PoseControlled {
  42834. /**
  42835. * The position of the object in babylon space.
  42836. */
  42837. position: Vector3;
  42838. /**
  42839. * The rotation quaternion of the object in babylon space.
  42840. */
  42841. rotationQuaternion: Quaternion;
  42842. /**
  42843. * The position of the device in babylon space.
  42844. */
  42845. devicePosition?: Vector3;
  42846. /**
  42847. * The rotation quaternion of the device in babylon space.
  42848. */
  42849. deviceRotationQuaternion: Quaternion;
  42850. /**
  42851. * The raw pose coming from the device.
  42852. */
  42853. rawPose: Nullable<DevicePose>;
  42854. /**
  42855. * The scale of the device to be used when translating from device space to babylon space.
  42856. */
  42857. deviceScaleFactor: number;
  42858. /**
  42859. * Updates the poseControlled values based on the input device pose.
  42860. * @param poseData the pose data to update the object with
  42861. */
  42862. updateFromDevice(poseData: DevicePose): void;
  42863. }
  42864. /**
  42865. * Set of options to customize the webVRCamera
  42866. */
  42867. interface WebVROptions {
  42868. /**
  42869. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42870. */
  42871. trackPosition?: boolean;
  42872. /**
  42873. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42874. */
  42875. positionScale?: number;
  42876. /**
  42877. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42878. */
  42879. displayName?: string;
  42880. /**
  42881. * Should the native controller meshes be initialized. (default: true)
  42882. */
  42883. controllerMeshes?: boolean;
  42884. /**
  42885. * Creating a default HemiLight only on controllers. (default: true)
  42886. */
  42887. defaultLightingOnControllers?: boolean;
  42888. /**
  42889. * If you don't want to use the default VR button of the helper. (default: false)
  42890. */
  42891. useCustomVRButton?: boolean;
  42892. /**
  42893. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42894. */
  42895. customVRButton?: HTMLButtonElement;
  42896. /**
  42897. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42898. */
  42899. rayLength?: number;
  42900. /**
  42901. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42902. */
  42903. defaultHeight?: number;
  42904. }
  42905. /**
  42906. * This represents a WebVR camera.
  42907. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42908. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42909. */
  42910. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42911. private webVROptions;
  42912. /**
  42913. * @hidden
  42914. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42915. */
  42916. _vrDevice: any;
  42917. /**
  42918. * The rawPose of the vrDevice.
  42919. */
  42920. rawPose: Nullable<DevicePose>;
  42921. private _onVREnabled;
  42922. private _specsVersion;
  42923. private _attached;
  42924. private _frameData;
  42925. protected _descendants: Array<Node>;
  42926. private _deviceRoomPosition;
  42927. /** @hidden */
  42928. _deviceRoomRotationQuaternion: Quaternion;
  42929. private _standingMatrix;
  42930. /**
  42931. * Represents device position in babylon space.
  42932. */
  42933. devicePosition: Vector3;
  42934. /**
  42935. * Represents device rotation in babylon space.
  42936. */
  42937. deviceRotationQuaternion: Quaternion;
  42938. /**
  42939. * The scale of the device to be used when translating from device space to babylon space.
  42940. */
  42941. deviceScaleFactor: number;
  42942. private _deviceToWorld;
  42943. private _worldToDevice;
  42944. /**
  42945. * References to the webVR controllers for the vrDevice.
  42946. */
  42947. controllers: Array<WebVRController>;
  42948. /**
  42949. * Emits an event when a controller is attached.
  42950. */
  42951. onControllersAttachedObservable: Observable<WebVRController[]>;
  42952. /**
  42953. * Emits an event when a controller's mesh has been loaded;
  42954. */
  42955. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42956. /**
  42957. * Emits an event when the HMD's pose has been updated.
  42958. */
  42959. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42960. private _poseSet;
  42961. /**
  42962. * If the rig cameras be used as parent instead of this camera.
  42963. */
  42964. rigParenting: boolean;
  42965. private _lightOnControllers;
  42966. private _defaultHeight?;
  42967. /**
  42968. * Instantiates a WebVRFreeCamera.
  42969. * @param name The name of the WebVRFreeCamera
  42970. * @param position The starting anchor position for the camera
  42971. * @param scene The scene the camera belongs to
  42972. * @param webVROptions a set of customizable options for the webVRCamera
  42973. */
  42974. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42975. /**
  42976. * Gets the device distance from the ground in meters.
  42977. * @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.
  42978. */
  42979. deviceDistanceToRoomGround(): number;
  42980. /**
  42981. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42982. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42983. */
  42984. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42985. /**
  42986. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42987. * @returns A promise with a boolean set to if the standing matrix is supported.
  42988. */
  42989. useStandingMatrixAsync(): Promise<boolean>;
  42990. /**
  42991. * Disposes the camera
  42992. */
  42993. dispose(): void;
  42994. /**
  42995. * Gets a vrController by name.
  42996. * @param name The name of the controller to retreive
  42997. * @returns the controller matching the name specified or null if not found
  42998. */
  42999. getControllerByName(name: string): Nullable<WebVRController>;
  43000. private _leftController;
  43001. /**
  43002. * The controller corrisponding to the users left hand.
  43003. */
  43004. readonly leftController: Nullable<WebVRController>;
  43005. private _rightController;
  43006. /**
  43007. * The controller corrisponding to the users right hand.
  43008. */
  43009. readonly rightController: Nullable<WebVRController>;
  43010. /**
  43011. * Casts a ray forward from the vrCamera's gaze.
  43012. * @param length Length of the ray (default: 100)
  43013. * @returns the ray corrisponding to the gaze
  43014. */
  43015. getForwardRay(length?: number): Ray;
  43016. /**
  43017. * @hidden
  43018. * Updates the camera based on device's frame data
  43019. */
  43020. _checkInputs(): void;
  43021. /**
  43022. * Updates the poseControlled values based on the input device pose.
  43023. * @param poseData Pose coming from the device
  43024. */
  43025. updateFromDevice(poseData: DevicePose): void;
  43026. private _htmlElementAttached;
  43027. private _detachIfAttached;
  43028. /**
  43029. * WebVR's attach control will start broadcasting frames to the device.
  43030. * Note that in certain browsers (chrome for example) this function must be called
  43031. * within a user-interaction callback. Example:
  43032. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43033. *
  43034. * @param element html element to attach the vrDevice to
  43035. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43036. */
  43037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43038. /**
  43039. * Detaches the camera from the html element and disables VR
  43040. *
  43041. * @param element html element to detach from
  43042. */
  43043. detachControl(element: HTMLElement): void;
  43044. /**
  43045. * @returns the name of this class
  43046. */
  43047. getClassName(): string;
  43048. /**
  43049. * Calls resetPose on the vrDisplay
  43050. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43051. */
  43052. resetToCurrentRotation(): void;
  43053. /**
  43054. * @hidden
  43055. * Updates the rig cameras (left and right eye)
  43056. */
  43057. _updateRigCameras(): void;
  43058. private _workingVector;
  43059. private _oneVector;
  43060. private _workingMatrix;
  43061. private updateCacheCalled;
  43062. private _correctPositionIfNotTrackPosition;
  43063. /**
  43064. * @hidden
  43065. * Updates the cached values of the camera
  43066. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43067. */
  43068. _updateCache(ignoreParentClass?: boolean): void;
  43069. /**
  43070. * @hidden
  43071. * Get current device position in babylon world
  43072. */
  43073. _computeDevicePosition(): void;
  43074. /**
  43075. * Updates the current device position and rotation in the babylon world
  43076. */
  43077. update(): void;
  43078. /**
  43079. * @hidden
  43080. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43081. * @returns an identity matrix
  43082. */
  43083. _getViewMatrix(): Matrix;
  43084. private _tmpMatrix;
  43085. /**
  43086. * This function is called by the two RIG cameras.
  43087. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43088. */
  43089. protected _getWebVRViewMatrix(): Matrix;
  43090. protected _getWebVRProjectionMatrix(): Matrix;
  43091. private _onGamepadConnectedObserver;
  43092. private _onGamepadDisconnectedObserver;
  43093. private _updateCacheWhenTrackingDisabledObserver;
  43094. /**
  43095. * Initializes the controllers and their meshes
  43096. */
  43097. initControllers(): void;
  43098. }
  43099. }
  43100. declare module BABYLON {
  43101. /**
  43102. * WebXR Camera which holds the views for the xrSession
  43103. * @see https://doc.babylonjs.com/how_to/webxr
  43104. */
  43105. class WebXRCamera extends FreeCamera {
  43106. private static _TmpMatrix;
  43107. /**
  43108. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43109. * @param name the name of the camera
  43110. * @param scene the scene to add the camera to
  43111. */
  43112. constructor(name: string, scene: BABYLON.Scene);
  43113. private _updateNumberOfRigCameras;
  43114. /** @hidden */
  43115. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43116. /**
  43117. * Updates the cameras position from the current pose information of the XR session
  43118. * @param xrSessionManager the session containing pose information
  43119. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43120. */
  43121. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * Button which can be used to enter a different mode of XR
  43127. */
  43128. class WebXREnterExitUIButton {
  43129. /** button element */
  43130. element: HTMLElement;
  43131. /** XR initialization options for the button */
  43132. initializationOptions: XRSessionCreationOptions;
  43133. /**
  43134. * Creates a WebXREnterExitUIButton
  43135. * @param element button element
  43136. * @param initializationOptions XR initialization options for the button
  43137. */
  43138. constructor(
  43139. /** button element */
  43140. element: HTMLElement,
  43141. /** XR initialization options for the button */
  43142. initializationOptions: XRSessionCreationOptions);
  43143. /**
  43144. * Overwritable function which can be used to update the button's visuals when the state changes
  43145. * @param activeButton the current active button in the UI
  43146. */
  43147. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43148. }
  43149. /**
  43150. * Options to create the webXR UI
  43151. */
  43152. class WebXREnterExitUIOptions {
  43153. /**
  43154. * Context to enter xr with
  43155. */
  43156. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43157. /**
  43158. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43159. */
  43160. customButtons?: Array<WebXREnterExitUIButton>;
  43161. }
  43162. /**
  43163. * UI to allow the user to enter/exit XR mode
  43164. */
  43165. class WebXREnterExitUI implements IDisposable {
  43166. private scene;
  43167. private _overlay;
  43168. private _buttons;
  43169. private _activeButton;
  43170. /**
  43171. * Fired every time the active button is changed.
  43172. *
  43173. * When xr is entered via a button that launches xr that button will be the callback parameter
  43174. *
  43175. * When exiting xr the callback parameter will be null)
  43176. */
  43177. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43178. /**
  43179. * Creates UI to allow the user to enter/exit XR mode
  43180. * @param scene the scene to add the ui to
  43181. * @param helper the xr experience helper to enter/exit xr with
  43182. * @param options options to configure the UI
  43183. * @returns the created ui
  43184. */
  43185. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43186. private constructor();
  43187. private _updateButtons;
  43188. /**
  43189. * Disposes of the object
  43190. */
  43191. dispose(): void;
  43192. }
  43193. }
  43194. declare module BABYLON {
  43195. /**
  43196. * States of the webXR experience
  43197. */
  43198. enum WebXRState {
  43199. /**
  43200. * Transitioning to being in XR mode
  43201. */
  43202. ENTERING_XR = 0,
  43203. /**
  43204. * Transitioning to non XR mode
  43205. */
  43206. EXITING_XR = 1,
  43207. /**
  43208. * In XR mode and presenting
  43209. */
  43210. IN_XR = 2,
  43211. /**
  43212. * Not entered XR mode
  43213. */
  43214. NOT_IN_XR = 3
  43215. }
  43216. /**
  43217. * Helper class used to enable XR
  43218. * @see https://doc.babylonjs.com/how_to/webxr
  43219. */
  43220. class WebXRExperienceHelper implements IDisposable {
  43221. private scene;
  43222. /**
  43223. * 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
  43224. */
  43225. container: AbstractMesh;
  43226. /**
  43227. * Camera used to render xr content
  43228. */
  43229. camera: WebXRCamera;
  43230. /**
  43231. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43232. */
  43233. state: WebXRState;
  43234. private _setState;
  43235. private static _TmpVector;
  43236. /**
  43237. * Fires when the state of the experience helper has changed
  43238. */
  43239. onStateChangedObservable: Observable<WebXRState>;
  43240. /** @hidden */
  43241. _sessionManager: WebXRSessionManager;
  43242. private _nonVRCamera;
  43243. private _originalSceneAutoClear;
  43244. private _supported;
  43245. /**
  43246. * Creates the experience helper
  43247. * @param scene the scene to attach the experience helper to
  43248. * @returns a promise for the experience helper
  43249. */
  43250. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43251. /**
  43252. * Creates a WebXRExperienceHelper
  43253. * @param scene The scene the helper should be created in
  43254. */
  43255. private constructor();
  43256. /**
  43257. * Exits XR mode and returns the scene to its original state
  43258. * @returns promise that resolves after xr mode has exited
  43259. */
  43260. exitXRAsync(): Promise<void>;
  43261. /**
  43262. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43263. * @param sessionCreationOptions options for the XR session
  43264. * @param frameOfReference frame of reference of the XR session
  43265. * @returns promise that resolves after xr mode has entered
  43266. */
  43267. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43268. /**
  43269. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43270. * @param ray ray to cast into the environment
  43271. * @returns Promise which resolves with a collision point in the environment if it exists
  43272. */
  43273. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43274. /**
  43275. * Updates the global position of the camera by moving the camera's container
  43276. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43277. * @param position The desired global position of the camera
  43278. */
  43279. setPositionOfCameraUsingContainer(position: Vector3): void;
  43280. /**
  43281. * Rotates the xr camera by rotating the camera's container around the camera's position
  43282. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43283. * @param rotation the desired quaternion rotation to apply to the camera
  43284. */
  43285. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43286. /**
  43287. * Checks if the creation options are supported by the xr session
  43288. * @param options creation options
  43289. * @returns true if supported
  43290. */
  43291. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43292. /**
  43293. * Disposes of the experience helper
  43294. */
  43295. dispose(): void;
  43296. }
  43297. }
  43298. declare module BABYLON {
  43299. /**
  43300. * Represents an XR input
  43301. */
  43302. class WebXRController {
  43303. /**
  43304. * 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
  43305. */
  43306. grip?: BABYLON.AbstractMesh;
  43307. /**
  43308. * Pointer which can be used to select objects or attach a visible laser to
  43309. */
  43310. pointer: BABYLON.AbstractMesh;
  43311. /**
  43312. * Creates the controller
  43313. * @see https://doc.babylonjs.com/how_to/webxr
  43314. * @param scene the scene which the controller should be associated to
  43315. */
  43316. constructor(scene: BABYLON.Scene);
  43317. /**
  43318. * Disposes of the object
  43319. */
  43320. dispose(): void;
  43321. }
  43322. /**
  43323. * XR input used to track XR inputs such as controllers/rays
  43324. */
  43325. class WebXRInput implements IDisposable {
  43326. private helper;
  43327. /**
  43328. * XR controllers being tracked
  43329. */
  43330. controllers: Array<WebXRController>;
  43331. private _tmpMatrix;
  43332. private _frameObserver;
  43333. /**
  43334. * Initializes the WebXRInput
  43335. * @param helper experience helper which the input should be created for
  43336. */
  43337. constructor(helper: WebXRExperienceHelper);
  43338. /**
  43339. * Disposes of the object
  43340. */
  43341. dispose(): void;
  43342. }
  43343. }
  43344. declare module BABYLON {
  43345. /**
  43346. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43347. */
  43348. class WebXRManagedOutputCanvas implements IDisposable {
  43349. private _canvas;
  43350. /**
  43351. * xrpresent context of the canvas which can be used to display/mirror xr content
  43352. */
  43353. canvasContext: Nullable<WebGLRenderingContext>;
  43354. /**
  43355. * Initializes the canvas to be added/removed upon entering/exiting xr
  43356. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43357. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43358. */
  43359. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43360. /**
  43361. * Disposes of the object
  43362. */
  43363. dispose(): void;
  43364. private _setManagedOutputCanvas;
  43365. private _addCanvas;
  43366. private _removeCanvas;
  43367. }
  43368. }
  43369. declare module BABYLON {
  43370. /**
  43371. * Manages an XRSession
  43372. * @see https://doc.babylonjs.com/how_to/webxr
  43373. */
  43374. class WebXRSessionManager implements IDisposable {
  43375. private scene;
  43376. /**
  43377. * Fires every time a new xrFrame arrives which can be used to update the camera
  43378. */
  43379. onXRFrameObservable: Observable<any>;
  43380. /**
  43381. * Fires when the xr session is ended either by the device or manually done
  43382. */
  43383. onXRSessionEnded: Observable<any>;
  43384. /** @hidden */
  43385. _xrSession: XRSession;
  43386. /** @hidden */
  43387. _frameOfReference: XRFrameOfReference;
  43388. /** @hidden */
  43389. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43390. /** @hidden */
  43391. _currentXRFrame: Nullable<XRFrame>;
  43392. private _xrNavigator;
  43393. private _xrDevice;
  43394. private _tmpMatrix;
  43395. /**
  43396. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43397. * @param scene The scene which the session should be created for
  43398. */
  43399. constructor(scene: BABYLON.Scene);
  43400. /**
  43401. * Initializes the manager
  43402. * After initialization enterXR can be called to start an XR session
  43403. * @returns Promise which resolves after it is initialized
  43404. */
  43405. initializeAsync(): Promise<void>;
  43406. /**
  43407. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43408. * @param sessionCreationOptions xr options to create the session with
  43409. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43410. * @returns Promise which resolves after it enters XR
  43411. */
  43412. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43413. /**
  43414. * Stops the xrSession and restores the renderloop
  43415. * @returns Promise which resolves after it exits XR
  43416. */
  43417. exitXRAsync(): Promise<void>;
  43418. /**
  43419. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43420. * @param ray ray to cast into the environment
  43421. * @returns Promise which resolves with a collision point in the environment if it exists
  43422. */
  43423. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43424. /**
  43425. * Checks if a session would be supported for the creation options specified
  43426. * @param options creation options to check if they are supported
  43427. * @returns true if supported
  43428. */
  43429. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43430. /**
  43431. * @hidden
  43432. * Converts the render layer of xrSession to a render target
  43433. * @param session session to create render target for
  43434. * @param scene scene the new render target should be created for
  43435. */
  43436. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43437. /**
  43438. * Disposes of the session manager
  43439. */
  43440. dispose(): void;
  43441. }
  43442. }
  43443. declare module BABYLON {
  43444. /**
  43445. * Contains an array of blocks representing the octree
  43446. */
  43447. interface IOctreeContainer<T> {
  43448. /**
  43449. * Blocks within the octree
  43450. */
  43451. blocks: Array<OctreeBlock<T>>;
  43452. }
  43453. /**
  43454. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43455. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43456. */
  43457. class Octree<T> {
  43458. /** 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.) */
  43459. maxDepth: number;
  43460. /**
  43461. * Blocks within the octree containing objects
  43462. */
  43463. blocks: Array<OctreeBlock<T>>;
  43464. /**
  43465. * Content stored in the octree
  43466. */
  43467. dynamicContent: T[];
  43468. private _maxBlockCapacity;
  43469. private _selectionContent;
  43470. private _creationFunc;
  43471. /**
  43472. * Creates a octree
  43473. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43474. * @param creationFunc function to be used to instatiate the octree
  43475. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43476. * @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.)
  43477. */
  43478. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43479. /** 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.) */
  43480. maxDepth?: number);
  43481. /**
  43482. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43483. * @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);
  43484. * @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);
  43485. * @param entries meshes to be added to the octree blocks
  43486. */
  43487. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43488. /**
  43489. * Adds a mesh to the octree
  43490. * @param entry Mesh to add to the octree
  43491. */
  43492. addMesh(entry: T): void;
  43493. /**
  43494. * Remove an element from the octree
  43495. * @param entry defines the element to remove
  43496. */
  43497. removeMesh(entry: T): void;
  43498. /**
  43499. * Selects an array of meshes within the frustum
  43500. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43501. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43502. * @returns array of meshes within the frustum
  43503. */
  43504. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43505. /**
  43506. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43507. * @param sphereCenter defines the bounding sphere center
  43508. * @param sphereRadius defines the bounding sphere radius
  43509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43510. * @returns an array of objects that intersect the sphere
  43511. */
  43512. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43513. /**
  43514. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43515. * @param ray defines the ray to test with
  43516. * @returns array of intersected objects
  43517. */
  43518. intersectsRay(ray: Ray): SmartArray<T>;
  43519. /**
  43520. * @hidden
  43521. */
  43522. 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;
  43523. /**
  43524. * Adds a mesh into the octree block if it intersects the block
  43525. */
  43526. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43527. /**
  43528. * Adds a submesh into the octree block if it intersects the block
  43529. */
  43530. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * Class used to store a cell in an octree
  43536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43537. */
  43538. class OctreeBlock<T> {
  43539. /**
  43540. * Gets the content of the current block
  43541. */
  43542. entries: T[];
  43543. /**
  43544. * Gets the list of block children
  43545. */
  43546. blocks: Array<OctreeBlock<T>>;
  43547. private _depth;
  43548. private _maxDepth;
  43549. private _capacity;
  43550. private _minPoint;
  43551. private _maxPoint;
  43552. private _boundingVectors;
  43553. private _creationFunc;
  43554. /**
  43555. * Creates a new block
  43556. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43557. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43558. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43559. * @param depth defines the current depth of this block in the octree
  43560. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43561. * @param creationFunc defines a callback to call when an element is added to the block
  43562. */
  43563. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43564. /**
  43565. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43566. */
  43567. readonly capacity: number;
  43568. /**
  43569. * Gets the minimum vector (in world space) of the block's bounding box
  43570. */
  43571. readonly minPoint: Vector3;
  43572. /**
  43573. * Gets the maximum vector (in world space) of the block's bounding box
  43574. */
  43575. readonly maxPoint: Vector3;
  43576. /**
  43577. * Add a new element to this block
  43578. * @param entry defines the element to add
  43579. */
  43580. addEntry(entry: T): void;
  43581. /**
  43582. * Remove an element from this block
  43583. * @param entry defines the element to remove
  43584. */
  43585. removeEntry(entry: T): void;
  43586. /**
  43587. * Add an array of elements to this block
  43588. * @param entries defines the array of elements to add
  43589. */
  43590. addEntries(entries: T[]): void;
  43591. /**
  43592. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43593. * @param frustumPlanes defines the frustum planes to test
  43594. * @param selection defines the array to store current content if selection is positive
  43595. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43596. */
  43597. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43598. /**
  43599. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43600. * @param sphereCenter defines the bounding sphere center
  43601. * @param sphereRadius defines the bounding sphere radius
  43602. * @param selection defines the array to store current content if selection is positive
  43603. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43604. */
  43605. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43606. /**
  43607. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43608. * @param ray defines the ray to test with
  43609. * @param selection defines the array to store current content if selection is positive
  43610. */
  43611. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43612. /**
  43613. * Subdivide the content into child blocks (this block will then be empty)
  43614. */
  43615. createInnerBlocks(): void;
  43616. }
  43617. }
  43618. declare module BABYLON {
  43619. interface Scene {
  43620. /**
  43621. * @hidden
  43622. * Backing Filed
  43623. */
  43624. _selectionOctree: Octree<AbstractMesh>;
  43625. /**
  43626. * Gets the octree used to boost mesh selection (picking)
  43627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43628. */
  43629. selectionOctree: Octree<AbstractMesh>;
  43630. /**
  43631. * Creates or updates the octree used to boost selection (picking)
  43632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43633. * @param maxCapacity defines the maximum capacity per leaf
  43634. * @param maxDepth defines the maximum depth of the octree
  43635. * @returns an octree of AbstractMesh
  43636. */
  43637. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43638. }
  43639. interface AbstractMesh {
  43640. /**
  43641. * @hidden
  43642. * Backing Field
  43643. */
  43644. _submeshesOctree: Octree<SubMesh>;
  43645. /**
  43646. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43647. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43648. * @param maxCapacity defines the maximum size of each block (64 by default)
  43649. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43650. * @returns the new octree
  43651. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43653. */
  43654. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43655. }
  43656. /**
  43657. * Defines the octree scene component responsible to manage any octrees
  43658. * in a given scene.
  43659. */
  43660. class OctreeSceneComponent {
  43661. /**
  43662. * The component name helpfull to identify the component in the list of scene components.
  43663. */
  43664. readonly name: string;
  43665. /**
  43666. * The scene the component belongs to.
  43667. */
  43668. scene: Scene;
  43669. /**
  43670. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43671. */
  43672. readonly checksIsEnabled: boolean;
  43673. /**
  43674. * Creates a new instance of the component for the given scene
  43675. * @param scene Defines the scene to register the component in
  43676. */
  43677. constructor(scene: Scene);
  43678. /**
  43679. * Registers the component in a given scene
  43680. */
  43681. register(): void;
  43682. /**
  43683. * Return the list of active meshes
  43684. * @returns the list of active meshes
  43685. */
  43686. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43687. /**
  43688. * Return the list of active sub meshes
  43689. * @param mesh The mesh to get the candidates sub meshes from
  43690. * @returns the list of active sub meshes
  43691. */
  43692. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43693. private _tempRay;
  43694. /**
  43695. * Return the list of sub meshes intersecting with a given local ray
  43696. * @param mesh defines the mesh to find the submesh for
  43697. * @param localRay defines the ray in local space
  43698. * @returns the list of intersecting sub meshes
  43699. */
  43700. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43701. /**
  43702. * Return the list of sub meshes colliding with a collider
  43703. * @param mesh defines the mesh to find the submesh for
  43704. * @param collider defines the collider to evaluate the collision against
  43705. * @returns the list of colliding sub meshes
  43706. */
  43707. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43708. /**
  43709. * Rebuilds the elements related to this component in case of
  43710. * context lost for instance.
  43711. */
  43712. rebuild(): void;
  43713. /**
  43714. * Disposes the component and the associated ressources.
  43715. */
  43716. dispose(): void;
  43717. }
  43718. }
  43719. declare module BABYLON {
  43720. /** @hidden */
  43721. class _OcclusionDataStorage {
  43722. /** @hidden */
  43723. occlusionInternalRetryCounter: number;
  43724. /** @hidden */
  43725. isOcclusionQueryInProgress: boolean;
  43726. /** @hidden */
  43727. isOccluded: boolean;
  43728. /** @hidden */
  43729. occlusionRetryCount: number;
  43730. /** @hidden */
  43731. occlusionType: number;
  43732. /** @hidden */
  43733. occlusionQueryAlgorithmType: number;
  43734. }
  43735. interface Engine {
  43736. /**
  43737. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43738. * @return the new query
  43739. */
  43740. createQuery(): WebGLQuery;
  43741. /**
  43742. * Delete and release a webGL query
  43743. * @param query defines the query to delete
  43744. * @return the current engine
  43745. */
  43746. deleteQuery(query: WebGLQuery): Engine;
  43747. /**
  43748. * Check if a given query has resolved and got its value
  43749. * @param query defines the query to check
  43750. * @returns true if the query got its value
  43751. */
  43752. isQueryResultAvailable(query: WebGLQuery): boolean;
  43753. /**
  43754. * Gets the value of a given query
  43755. * @param query defines the query to check
  43756. * @returns the value of the query
  43757. */
  43758. getQueryResult(query: WebGLQuery): number;
  43759. /**
  43760. * Initiates an occlusion query
  43761. * @param algorithmType defines the algorithm to use
  43762. * @param query defines the query to use
  43763. * @returns the current engine
  43764. * @see http://doc.babylonjs.com/features/occlusionquery
  43765. */
  43766. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43767. /**
  43768. * Ends an occlusion query
  43769. * @see http://doc.babylonjs.com/features/occlusionquery
  43770. * @param algorithmType defines the algorithm to use
  43771. * @returns the current engine
  43772. */
  43773. endOcclusionQuery(algorithmType: number): Engine;
  43774. /**
  43775. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43776. * Please note that only one query can be issued at a time
  43777. * @returns a time token used to track the time span
  43778. */
  43779. startTimeQuery(): Nullable<_TimeToken>;
  43780. /**
  43781. * Ends a time query
  43782. * @param token defines the token used to measure the time span
  43783. * @returns the time spent (in ns)
  43784. */
  43785. endTimeQuery(token: _TimeToken): int;
  43786. /** @hidden */
  43787. _currentNonTimestampToken: Nullable<_TimeToken>;
  43788. /** @hidden */
  43789. _createTimeQuery(): WebGLQuery;
  43790. /** @hidden */
  43791. _deleteTimeQuery(query: WebGLQuery): void;
  43792. /** @hidden */
  43793. _getGlAlgorithmType(algorithmType: number): number;
  43794. /** @hidden */
  43795. _getTimeQueryResult(query: WebGLQuery): any;
  43796. /** @hidden */
  43797. _getTimeQueryAvailability(query: WebGLQuery): any;
  43798. }
  43799. interface AbstractMesh {
  43800. /**
  43801. * Backing filed
  43802. * @hidden
  43803. */
  43804. __occlusionDataStorage: _OcclusionDataStorage;
  43805. /**
  43806. * Access property
  43807. * @hidden
  43808. */
  43809. _occlusionDataStorage: _OcclusionDataStorage;
  43810. /**
  43811. * 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.
  43812. * The default value is -1 which means don't break the query and wait till the result
  43813. * @see http://doc.babylonjs.com/features/occlusionquery
  43814. */
  43815. occlusionRetryCount: number;
  43816. /**
  43817. * 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:
  43818. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43819. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43820. * * 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.
  43821. * @see http://doc.babylonjs.com/features/occlusionquery
  43822. */
  43823. occlusionType: number;
  43824. /**
  43825. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43826. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43827. * * 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.
  43828. * @see http://doc.babylonjs.com/features/occlusionquery
  43829. */
  43830. occlusionQueryAlgorithmType: number;
  43831. /**
  43832. * 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
  43833. * @see http://doc.babylonjs.com/features/occlusionquery
  43834. */
  43835. isOccluded: boolean;
  43836. /**
  43837. * Flag to check the progress status of the query
  43838. * @see http://doc.babylonjs.com/features/occlusionquery
  43839. */
  43840. isOcclusionQueryInProgress: boolean;
  43841. }
  43842. }
  43843. declare module BABYLON {
  43844. interface Engine {
  43845. /**
  43846. * Creates a webGL transform feedback object
  43847. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43848. * @returns the webGL transform feedback object
  43849. */
  43850. createTransformFeedback(): WebGLTransformFeedback;
  43851. /**
  43852. * Delete a webGL transform feedback object
  43853. * @param value defines the webGL transform feedback object to delete
  43854. */
  43855. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43856. /**
  43857. * Bind a webGL transform feedback object to the webgl context
  43858. * @param value defines the webGL transform feedback object to bind
  43859. */
  43860. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43861. /**
  43862. * Begins a transform feedback operation
  43863. * @param usePoints defines if points or triangles must be used
  43864. */
  43865. beginTransformFeedback(usePoints: boolean): void;
  43866. /**
  43867. * Ends a transform feedback operation
  43868. */
  43869. endTransformFeedback(): void;
  43870. /**
  43871. * Specify the varyings to use with transform feedback
  43872. * @param program defines the associated webGL program
  43873. * @param value defines the list of strings representing the varying names
  43874. */
  43875. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43876. /**
  43877. * Bind a webGL buffer for a transform feedback operation
  43878. * @param value defines the webGL buffer to bind
  43879. */
  43880. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43881. }
  43882. }
  43883. declare module BABYLON {
  43884. /**
  43885. * Google Daydream controller
  43886. */
  43887. class DaydreamController extends WebVRController {
  43888. /**
  43889. * Base Url for the controller model.
  43890. */
  43891. static MODEL_BASE_URL: string;
  43892. /**
  43893. * File name for the controller model.
  43894. */
  43895. static MODEL_FILENAME: string;
  43896. /**
  43897. * Gamepad Id prefix used to identify Daydream Controller.
  43898. */
  43899. static readonly GAMEPAD_ID_PREFIX: string;
  43900. /**
  43901. * Creates a new DaydreamController from a gamepad
  43902. * @param vrGamepad the gamepad that the controller should be created from
  43903. */
  43904. constructor(vrGamepad: any);
  43905. /**
  43906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43907. * @param scene scene in which to add meshes
  43908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43909. */
  43910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43911. /**
  43912. * Called once for each button that changed state since the last frame
  43913. * @param buttonIdx Which button index changed
  43914. * @param state New state of the button
  43915. * @param changes Which properties on the state changed since last frame
  43916. */
  43917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43918. }
  43919. }
  43920. declare module BABYLON {
  43921. /**
  43922. * Gear VR Controller
  43923. */
  43924. class GearVRController extends WebVRController {
  43925. /**
  43926. * Base Url for the controller model.
  43927. */
  43928. static MODEL_BASE_URL: string;
  43929. /**
  43930. * File name for the controller model.
  43931. */
  43932. static MODEL_FILENAME: string;
  43933. /**
  43934. * Gamepad Id prefix used to identify this controller.
  43935. */
  43936. static readonly GAMEPAD_ID_PREFIX: string;
  43937. private readonly _buttonIndexToObservableNameMap;
  43938. /**
  43939. * Creates a new GearVRController from a gamepad
  43940. * @param vrGamepad the gamepad that the controller should be created from
  43941. */
  43942. constructor(vrGamepad: any);
  43943. /**
  43944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43945. * @param scene scene in which to add meshes
  43946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43947. */
  43948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43949. /**
  43950. * Called once for each button that changed state since the last frame
  43951. * @param buttonIdx Which button index changed
  43952. * @param state New state of the button
  43953. * @param changes Which properties on the state changed since last frame
  43954. */
  43955. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43956. }
  43957. }
  43958. declare module BABYLON {
  43959. /**
  43960. * Generic Controller
  43961. */
  43962. class GenericController extends WebVRController {
  43963. /**
  43964. * Base Url for the controller model.
  43965. */
  43966. static readonly MODEL_BASE_URL: string;
  43967. /**
  43968. * File name for the controller model.
  43969. */
  43970. static readonly MODEL_FILENAME: string;
  43971. /**
  43972. * Creates a new GenericController from a gamepad
  43973. * @param vrGamepad the gamepad that the controller should be created from
  43974. */
  43975. constructor(vrGamepad: any);
  43976. /**
  43977. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43978. * @param scene scene in which to add meshes
  43979. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43980. */
  43981. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43982. /**
  43983. * Called once for each button that changed state since the last frame
  43984. * @param buttonIdx Which button index changed
  43985. * @param state New state of the button
  43986. * @param changes Which properties on the state changed since last frame
  43987. */
  43988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43989. }
  43990. }
  43991. declare module BABYLON {
  43992. /**
  43993. * Oculus Touch Controller
  43994. */
  43995. class OculusTouchController extends WebVRController {
  43996. /**
  43997. * Base Url for the controller model.
  43998. */
  43999. static MODEL_BASE_URL: string;
  44000. /**
  44001. * File name for the left controller model.
  44002. */
  44003. static MODEL_LEFT_FILENAME: string;
  44004. /**
  44005. * File name for the right controller model.
  44006. */
  44007. static MODEL_RIGHT_FILENAME: string;
  44008. /**
  44009. * Fired when the secondary trigger on this controller is modified
  44010. */
  44011. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44012. /**
  44013. * Fired when the thumb rest on this controller is modified
  44014. */
  44015. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44016. /**
  44017. * Creates a new OculusTouchController from a gamepad
  44018. * @param vrGamepad the gamepad that the controller should be created from
  44019. */
  44020. constructor(vrGamepad: any);
  44021. /**
  44022. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44023. * @param scene scene in which to add meshes
  44024. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44025. */
  44026. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44027. /**
  44028. * Fired when the A button on this controller is modified
  44029. */
  44030. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44031. /**
  44032. * Fired when the B button on this controller is modified
  44033. */
  44034. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44035. /**
  44036. * Fired when the X button on this controller is modified
  44037. */
  44038. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44039. /**
  44040. * Fired when the Y button on this controller is modified
  44041. */
  44042. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44043. /**
  44044. * Called once for each button that changed state since the last frame
  44045. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44046. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44047. * 2) secondary trigger (same)
  44048. * 3) A (right) X (left), touch, pressed = value
  44049. * 4) B / Y
  44050. * 5) thumb rest
  44051. * @param buttonIdx Which button index changed
  44052. * @param state New state of the button
  44053. * @param changes Which properties on the state changed since last frame
  44054. */
  44055. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44056. }
  44057. }
  44058. declare module BABYLON {
  44059. /**
  44060. * Defines the types of pose enabled controllers that are supported
  44061. */
  44062. enum PoseEnabledControllerType {
  44063. /**
  44064. * HTC Vive
  44065. */
  44066. VIVE = 0,
  44067. /**
  44068. * Oculus Rift
  44069. */
  44070. OCULUS = 1,
  44071. /**
  44072. * Windows mixed reality
  44073. */
  44074. WINDOWS = 2,
  44075. /**
  44076. * Samsung gear VR
  44077. */
  44078. GEAR_VR = 3,
  44079. /**
  44080. * Google Daydream
  44081. */
  44082. DAYDREAM = 4,
  44083. /**
  44084. * Generic
  44085. */
  44086. GENERIC = 5
  44087. }
  44088. /**
  44089. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44090. */
  44091. interface MutableGamepadButton {
  44092. /**
  44093. * Value of the button/trigger
  44094. */
  44095. value: number;
  44096. /**
  44097. * If the button/trigger is currently touched
  44098. */
  44099. touched: boolean;
  44100. /**
  44101. * If the button/trigger is currently pressed
  44102. */
  44103. pressed: boolean;
  44104. }
  44105. /**
  44106. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44107. * @hidden
  44108. */
  44109. interface ExtendedGamepadButton extends GamepadButton {
  44110. /**
  44111. * If the button/trigger is currently pressed
  44112. */
  44113. readonly pressed: boolean;
  44114. /**
  44115. * If the button/trigger is currently touched
  44116. */
  44117. readonly touched: boolean;
  44118. /**
  44119. * Value of the button/trigger
  44120. */
  44121. readonly value: number;
  44122. }
  44123. /**
  44124. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44125. */
  44126. class PoseEnabledControllerHelper {
  44127. /**
  44128. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44129. * @param vrGamepad the gamepad to initialized
  44130. * @returns a vr controller of the type the gamepad identified as
  44131. */
  44132. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44133. }
  44134. /**
  44135. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44136. */
  44137. class PoseEnabledController extends Gamepad implements PoseControlled {
  44138. private _deviceRoomPosition;
  44139. private _deviceRoomRotationQuaternion;
  44140. /**
  44141. * The device position in babylon space
  44142. */
  44143. devicePosition: Vector3;
  44144. /**
  44145. * The device rotation in babylon space
  44146. */
  44147. deviceRotationQuaternion: Quaternion;
  44148. /**
  44149. * The scale factor of the device in babylon space
  44150. */
  44151. deviceScaleFactor: number;
  44152. /**
  44153. * (Likely devicePosition should be used instead) The device position in its room space
  44154. */
  44155. position: Vector3;
  44156. /**
  44157. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44158. */
  44159. rotationQuaternion: Quaternion;
  44160. /**
  44161. * The type of controller (Eg. Windows mixed reality)
  44162. */
  44163. controllerType: PoseEnabledControllerType;
  44164. protected _calculatedPosition: Vector3;
  44165. private _calculatedRotation;
  44166. /**
  44167. * The raw pose from the device
  44168. */
  44169. rawPose: DevicePose;
  44170. private _trackPosition;
  44171. private _maxRotationDistFromHeadset;
  44172. private _draggedRoomRotation;
  44173. /**
  44174. * @hidden
  44175. */
  44176. _disableTrackPosition(fixedPosition: Vector3): void;
  44177. /**
  44178. * Internal, the mesh attached to the controller
  44179. * @hidden
  44180. */
  44181. _mesh: Nullable<AbstractMesh>;
  44182. private _poseControlledCamera;
  44183. private _leftHandSystemQuaternion;
  44184. /**
  44185. * Internal, matrix used to convert room space to babylon space
  44186. * @hidden
  44187. */
  44188. _deviceToWorld: Matrix;
  44189. /**
  44190. * Node to be used when casting a ray from the controller
  44191. * @hidden
  44192. */
  44193. _pointingPoseNode: Nullable<TransformNode>;
  44194. /**
  44195. * Name of the child mesh that can be used to cast a ray from the controller
  44196. */
  44197. static readonly POINTING_POSE: string;
  44198. /**
  44199. * Creates a new PoseEnabledController from a gamepad
  44200. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44201. */
  44202. constructor(browserGamepad: any);
  44203. private _workingMatrix;
  44204. /**
  44205. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44206. */
  44207. update(): void;
  44208. /**
  44209. * Updates only the pose device and mesh without doing any button event checking
  44210. */
  44211. protected _updatePoseAndMesh(): void;
  44212. /**
  44213. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44214. * @param poseData raw pose fromthe device
  44215. */
  44216. updateFromDevice(poseData: DevicePose): void;
  44217. /**
  44218. * @hidden
  44219. */
  44220. _meshAttachedObservable: Observable<AbstractMesh>;
  44221. /**
  44222. * Attaches a mesh to the controller
  44223. * @param mesh the mesh to be attached
  44224. */
  44225. attachToMesh(mesh: AbstractMesh): void;
  44226. /**
  44227. * Attaches the controllers mesh to a camera
  44228. * @param camera the camera the mesh should be attached to
  44229. */
  44230. attachToPoseControlledCamera(camera: TargetCamera): void;
  44231. /**
  44232. * Disposes of the controller
  44233. */
  44234. dispose(): void;
  44235. /**
  44236. * The mesh that is attached to the controller
  44237. */
  44238. readonly mesh: Nullable<AbstractMesh>;
  44239. /**
  44240. * Gets the ray of the controller in the direction the controller is pointing
  44241. * @param length the length the resulting ray should be
  44242. * @returns a ray in the direction the controller is pointing
  44243. */
  44244. getForwardRay(length?: number): Ray;
  44245. }
  44246. }
  44247. declare module BABYLON {
  44248. /**
  44249. * Vive Controller
  44250. */
  44251. class ViveController extends WebVRController {
  44252. /**
  44253. * Base Url for the controller model.
  44254. */
  44255. static MODEL_BASE_URL: string;
  44256. /**
  44257. * File name for the controller model.
  44258. */
  44259. static MODEL_FILENAME: string;
  44260. /**
  44261. * Creates a new ViveController from a gamepad
  44262. * @param vrGamepad the gamepad that the controller should be created from
  44263. */
  44264. constructor(vrGamepad: any);
  44265. /**
  44266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44267. * @param scene scene in which to add meshes
  44268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44269. */
  44270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44271. /**
  44272. * Fired when the left button on this controller is modified
  44273. */
  44274. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44275. /**
  44276. * Fired when the right button on this controller is modified
  44277. */
  44278. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44279. /**
  44280. * Fired when the menu button on this controller is modified
  44281. */
  44282. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44283. /**
  44284. * Called once for each button that changed state since the last frame
  44285. * Vive mapping:
  44286. * 0: touchpad
  44287. * 1: trigger
  44288. * 2: left AND right buttons
  44289. * 3: menu button
  44290. * @param buttonIdx Which button index changed
  44291. * @param state New state of the button
  44292. * @param changes Which properties on the state changed since last frame
  44293. */
  44294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44295. }
  44296. }
  44297. declare module BABYLON {
  44298. /**
  44299. * Defines the WebVRController object that represents controllers tracked in 3D space
  44300. */
  44301. abstract class WebVRController extends PoseEnabledController {
  44302. /**
  44303. * Internal, the default controller model for the controller
  44304. */
  44305. protected _defaultModel: AbstractMesh;
  44306. /**
  44307. * Fired when the trigger state has changed
  44308. */
  44309. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44310. /**
  44311. * Fired when the main button state has changed
  44312. */
  44313. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44314. /**
  44315. * Fired when the secondary button state has changed
  44316. */
  44317. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44318. /**
  44319. * Fired when the pad state has changed
  44320. */
  44321. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44322. /**
  44323. * Fired when controllers stick values have changed
  44324. */
  44325. onPadValuesChangedObservable: Observable<StickValues>;
  44326. /**
  44327. * Array of button availible on the controller
  44328. */
  44329. protected _buttons: Array<MutableGamepadButton>;
  44330. private _onButtonStateChange;
  44331. /**
  44332. * Fired when a controller button's state has changed
  44333. * @param callback the callback containing the button that was modified
  44334. */
  44335. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44336. /**
  44337. * X and Y axis corrisponding to the controllers joystick
  44338. */
  44339. pad: StickValues;
  44340. /**
  44341. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44342. */
  44343. hand: string;
  44344. /**
  44345. * The default controller model for the controller
  44346. */
  44347. readonly defaultModel: AbstractMesh;
  44348. /**
  44349. * Creates a new WebVRController from a gamepad
  44350. * @param vrGamepad the gamepad that the WebVRController should be created from
  44351. */
  44352. constructor(vrGamepad: any);
  44353. /**
  44354. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44355. */
  44356. update(): void;
  44357. /**
  44358. * Function to be called when a button is modified
  44359. */
  44360. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44361. /**
  44362. * Loads a mesh and attaches it to the controller
  44363. * @param scene the scene the mesh should be added to
  44364. * @param meshLoaded callback for when the mesh has been loaded
  44365. */
  44366. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44367. private _setButtonValue;
  44368. private _changes;
  44369. private _checkChanges;
  44370. /**
  44371. * Disposes of th webVRCOntroller
  44372. */
  44373. dispose(): void;
  44374. }
  44375. }
  44376. declare module BABYLON {
  44377. /**
  44378. * Defines the WindowsMotionController object that the state of the windows motion controller
  44379. */
  44380. class WindowsMotionController extends WebVRController {
  44381. /**
  44382. * The base url used to load the left and right controller models
  44383. */
  44384. static MODEL_BASE_URL: string;
  44385. /**
  44386. * The name of the left controller model file
  44387. */
  44388. static MODEL_LEFT_FILENAME: string;
  44389. /**
  44390. * The name of the right controller model file
  44391. */
  44392. static MODEL_RIGHT_FILENAME: string;
  44393. /**
  44394. * The controller name prefix for this controller type
  44395. */
  44396. static readonly GAMEPAD_ID_PREFIX: string;
  44397. /**
  44398. * The controller id pattern for this controller type
  44399. */
  44400. private static readonly GAMEPAD_ID_PATTERN;
  44401. private _loadedMeshInfo;
  44402. private readonly _mapping;
  44403. /**
  44404. * Fired when the trackpad on this controller is clicked
  44405. */
  44406. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44407. /**
  44408. * Fired when the trackpad on this controller is modified
  44409. */
  44410. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44411. /**
  44412. * The current x and y values of this controller's trackpad
  44413. */
  44414. trackpad: StickValues;
  44415. /**
  44416. * Creates a new WindowsMotionController from a gamepad
  44417. * @param vrGamepad the gamepad that the controller should be created from
  44418. */
  44419. constructor(vrGamepad: any);
  44420. /**
  44421. * Fired when the trigger on this controller is modified
  44422. */
  44423. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44424. /**
  44425. * Fired when the menu button on this controller is modified
  44426. */
  44427. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44428. /**
  44429. * Fired when the grip button on this controller is modified
  44430. */
  44431. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44432. /**
  44433. * Fired when the thumbstick button on this controller is modified
  44434. */
  44435. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44436. /**
  44437. * Fired when the touchpad button on this controller is modified
  44438. */
  44439. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44440. /**
  44441. * Fired when the touchpad values on this controller are modified
  44442. */
  44443. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44444. private _updateTrackpad;
  44445. /**
  44446. * Called once per frame by the engine.
  44447. */
  44448. update(): void;
  44449. /**
  44450. * Called once for each button that changed state since the last frame
  44451. * @param buttonIdx Which button index changed
  44452. * @param state New state of the button
  44453. * @param changes Which properties on the state changed since last frame
  44454. */
  44455. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44456. /**
  44457. * Moves the buttons on the controller mesh based on their current state
  44458. * @param buttonName the name of the button to move
  44459. * @param buttonValue the value of the button which determines the buttons new position
  44460. */
  44461. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44462. /**
  44463. * Moves the axis on the controller mesh based on its current state
  44464. * @param axis the index of the axis
  44465. * @param axisValue the value of the axis which determines the meshes new position
  44466. * @hidden
  44467. */
  44468. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44469. /**
  44470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44471. * @param scene scene in which to add meshes
  44472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44473. */
  44474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44475. /**
  44476. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44477. * can be transformed by button presses and axes values, based on this._mapping.
  44478. *
  44479. * @param scene scene in which the meshes exist
  44480. * @param meshes list of meshes that make up the controller model to process
  44481. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44482. */
  44483. private processModel;
  44484. private createMeshInfo;
  44485. /**
  44486. * Gets the ray of the controller in the direction the controller is pointing
  44487. * @param length the length the resulting ray should be
  44488. * @returns a ray in the direction the controller is pointing
  44489. */
  44490. getForwardRay(length?: number): Ray;
  44491. /**
  44492. * Disposes of the controller
  44493. */
  44494. dispose(): void;
  44495. }
  44496. }
  44497. declare module BABYLON {
  44498. /**
  44499. * Interface to implement to create a shadow generator compatible with BJS.
  44500. */
  44501. interface IShadowGenerator {
  44502. /**
  44503. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44504. * @returns The render target texture if present otherwise, null
  44505. */
  44506. getShadowMap(): Nullable<RenderTargetTexture>;
  44507. /**
  44508. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44509. * @returns The render target texture if the shadow map is present otherwise, null
  44510. */
  44511. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44512. /**
  44513. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44514. * @param subMesh The submesh we want to render in the shadow map
  44515. * @param useInstances Defines wether will draw in the map using instances
  44516. * @returns true if ready otherwise, false
  44517. */
  44518. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44519. /**
  44520. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44521. * @param defines Defines of the material we want to update
  44522. * @param lightIndex Index of the light in the enabled light list of the material
  44523. */
  44524. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44525. /**
  44526. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44527. * defined in the generator but impacting the effect).
  44528. * It implies the unifroms available on the materials are the standard BJS ones.
  44529. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44530. * @param effect The effect we are binfing the information for
  44531. */
  44532. bindShadowLight(lightIndex: string, effect: Effect): void;
  44533. /**
  44534. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44535. * (eq to shadow prjection matrix * light transform matrix)
  44536. * @returns The transform matrix used to create the shadow map
  44537. */
  44538. getTransformMatrix(): Matrix;
  44539. /**
  44540. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44541. * Cube and 2D textures for instance.
  44542. */
  44543. recreateShadowMap(): void;
  44544. /**
  44545. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44546. * @param onCompiled Callback triggered at the and of the effects compilation
  44547. * @param options Sets of optional options forcing the compilation with different modes
  44548. */
  44549. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44550. useInstances: boolean;
  44551. }>): void;
  44552. /**
  44553. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44554. * @param options Sets of optional options forcing the compilation with different modes
  44555. * @returns A promise that resolves when the compilation completes
  44556. */
  44557. forceCompilationAsync(options?: Partial<{
  44558. useInstances: boolean;
  44559. }>): Promise<void>;
  44560. /**
  44561. * Serializes the shadow generator setup to a json object.
  44562. * @returns The serialized JSON object
  44563. */
  44564. serialize(): any;
  44565. /**
  44566. * Disposes the Shadow map and related Textures and effects.
  44567. */
  44568. dispose(): void;
  44569. }
  44570. /**
  44571. * Default implementation IShadowGenerator.
  44572. * This is the main object responsible of generating shadows in the framework.
  44573. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44574. */
  44575. class ShadowGenerator implements IShadowGenerator {
  44576. /**
  44577. * Shadow generator mode None: no filtering applied.
  44578. */
  44579. static readonly FILTER_NONE: number;
  44580. /**
  44581. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44583. */
  44584. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44585. /**
  44586. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44587. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44588. */
  44589. static readonly FILTER_POISSONSAMPLING: number;
  44590. /**
  44591. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44592. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44593. */
  44594. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44595. /**
  44596. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44597. * edge artifacts on steep falloff.
  44598. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44599. */
  44600. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44601. /**
  44602. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44603. * edge artifacts on steep falloff.
  44604. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44605. */
  44606. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44607. /**
  44608. * Shadow generator mode PCF: Percentage Closer Filtering
  44609. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44610. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44611. */
  44612. static readonly FILTER_PCF: number;
  44613. /**
  44614. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44615. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44616. * Contact Hardening
  44617. */
  44618. static readonly FILTER_PCSS: number;
  44619. /**
  44620. * Reserved for PCF and PCSS
  44621. * Highest Quality.
  44622. *
  44623. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44624. *
  44625. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44626. */
  44627. static readonly QUALITY_HIGH: number;
  44628. /**
  44629. * Reserved for PCF and PCSS
  44630. * Good tradeoff for quality/perf cross devices
  44631. *
  44632. * Execute PCF on a 3*3 kernel.
  44633. *
  44634. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44635. */
  44636. static readonly QUALITY_MEDIUM: number;
  44637. /**
  44638. * Reserved for PCF and PCSS
  44639. * The lowest quality but the fastest.
  44640. *
  44641. * Execute PCF on a 1*1 kernel.
  44642. *
  44643. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44644. */
  44645. static readonly QUALITY_LOW: number;
  44646. private _bias;
  44647. /**
  44648. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44649. */
  44650. /**
  44651. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44652. */
  44653. bias: number;
  44654. private _normalBias;
  44655. /**
  44656. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44657. */
  44658. /**
  44659. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44660. */
  44661. normalBias: number;
  44662. private _blurBoxOffset;
  44663. /**
  44664. * Gets the blur box offset: offset applied during the blur pass.
  44665. * Only useful if useKernelBlur = false
  44666. */
  44667. /**
  44668. * Sets the blur box offset: offset applied during the blur pass.
  44669. * Only useful if useKernelBlur = false
  44670. */
  44671. blurBoxOffset: number;
  44672. private _blurScale;
  44673. /**
  44674. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44675. * 2 means half of the size.
  44676. */
  44677. /**
  44678. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44679. * 2 means half of the size.
  44680. */
  44681. blurScale: number;
  44682. private _blurKernel;
  44683. /**
  44684. * Gets the blur kernel: kernel size of the blur pass.
  44685. * Only useful if useKernelBlur = true
  44686. */
  44687. /**
  44688. * Sets the blur kernel: kernel size of the blur pass.
  44689. * Only useful if useKernelBlur = true
  44690. */
  44691. blurKernel: number;
  44692. private _useKernelBlur;
  44693. /**
  44694. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44695. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44696. */
  44697. /**
  44698. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44699. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44700. */
  44701. useKernelBlur: boolean;
  44702. private _depthScale;
  44703. /**
  44704. * Gets the depth scale used in ESM mode.
  44705. */
  44706. /**
  44707. * Sets the depth scale used in ESM mode.
  44708. * This can override the scale stored on the light.
  44709. */
  44710. depthScale: number;
  44711. private _filter;
  44712. /**
  44713. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44714. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44715. */
  44716. /**
  44717. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44718. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44719. */
  44720. filter: number;
  44721. /**
  44722. * Gets if the current filter is set to Poisson Sampling.
  44723. */
  44724. /**
  44725. * Sets the current filter to Poisson Sampling.
  44726. */
  44727. usePoissonSampling: boolean;
  44728. /**
  44729. * Gets if the current filter is set to ESM.
  44730. */
  44731. /**
  44732. * Sets the current filter is to ESM.
  44733. */
  44734. useExponentialShadowMap: boolean;
  44735. /**
  44736. * Gets if the current filter is set to filtered ESM.
  44737. */
  44738. /**
  44739. * Gets if the current filter is set to filtered ESM.
  44740. */
  44741. useBlurExponentialShadowMap: boolean;
  44742. /**
  44743. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44744. * exponential to prevent steep falloff artifacts).
  44745. */
  44746. /**
  44747. * Sets the current filter to "close ESM" (using the inverse of the
  44748. * exponential to prevent steep falloff artifacts).
  44749. */
  44750. useCloseExponentialShadowMap: boolean;
  44751. /**
  44752. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44753. * exponential to prevent steep falloff artifacts).
  44754. */
  44755. /**
  44756. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44757. * exponential to prevent steep falloff artifacts).
  44758. */
  44759. useBlurCloseExponentialShadowMap: boolean;
  44760. /**
  44761. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44762. */
  44763. /**
  44764. * Sets the current filter to "PCF" (percentage closer filtering).
  44765. */
  44766. usePercentageCloserFiltering: boolean;
  44767. private _filteringQuality;
  44768. /**
  44769. * Gets the PCF or PCSS Quality.
  44770. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44771. */
  44772. /**
  44773. * Sets the PCF or PCSS Quality.
  44774. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44775. */
  44776. filteringQuality: number;
  44777. /**
  44778. * Gets if the current filter is set to "PCSS" (contact hardening).
  44779. */
  44780. /**
  44781. * Sets the current filter to "PCSS" (contact hardening).
  44782. */
  44783. useContactHardeningShadow: boolean;
  44784. private _contactHardeningLightSizeUVRatio;
  44785. /**
  44786. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44787. * Using a ratio helps keeping shape stability independently of the map size.
  44788. *
  44789. * It does not account for the light projection as it was having too much
  44790. * instability during the light setup or during light position changes.
  44791. *
  44792. * Only valid if useContactHardeningShadow is true.
  44793. */
  44794. /**
  44795. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44796. * Using a ratio helps keeping shape stability independently of the map size.
  44797. *
  44798. * It does not account for the light projection as it was having too much
  44799. * instability during the light setup or during light position changes.
  44800. *
  44801. * Only valid if useContactHardeningShadow is true.
  44802. */
  44803. contactHardeningLightSizeUVRatio: number;
  44804. private _darkness;
  44805. /**
  44806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44807. * 0 means strongest and 1 would means no shadow.
  44808. * @returns the darkness.
  44809. */
  44810. getDarkness(): number;
  44811. /**
  44812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44814. * @returns the shadow generator allowing fluent coding.
  44815. */
  44816. setDarkness(darkness: number): ShadowGenerator;
  44817. private _transparencyShadow;
  44818. /**
  44819. * Sets the ability to have transparent shadow (boolean).
  44820. * @param transparent True if transparent else False
  44821. * @returns the shadow generator allowing fluent coding
  44822. */
  44823. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44824. private _shadowMap;
  44825. private _shadowMap2;
  44826. /**
  44827. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44828. * @returns The render target texture if present otherwise, null
  44829. */
  44830. getShadowMap(): Nullable<RenderTargetTexture>;
  44831. /**
  44832. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44833. * @returns The render target texture if the shadow map is present otherwise, null
  44834. */
  44835. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44836. /**
  44837. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44838. * @param mesh Mesh to add
  44839. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44840. * @returns the Shadow Generator itself
  44841. */
  44842. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44843. /**
  44844. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44845. * @param mesh Mesh to remove
  44846. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44847. * @returns the Shadow Generator itself
  44848. */
  44849. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44850. /**
  44851. * Controls the extent to which the shadows fade out at the edge of the frustum
  44852. * Used only by directionals and spots
  44853. */
  44854. frustumEdgeFalloff: number;
  44855. private _light;
  44856. /**
  44857. * Returns the associated light object.
  44858. * @returns the light generating the shadow
  44859. */
  44860. getLight(): IShadowLight;
  44861. /**
  44862. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44863. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44864. * It might on the other hand introduce peter panning.
  44865. */
  44866. forceBackFacesOnly: boolean;
  44867. private _scene;
  44868. private _lightDirection;
  44869. private _effect;
  44870. private _viewMatrix;
  44871. private _projectionMatrix;
  44872. private _transformMatrix;
  44873. private _cachedPosition;
  44874. private _cachedDirection;
  44875. private _cachedDefines;
  44876. private _currentRenderID;
  44877. private _boxBlurPostprocess;
  44878. private _kernelBlurXPostprocess;
  44879. private _kernelBlurYPostprocess;
  44880. private _blurPostProcesses;
  44881. private _mapSize;
  44882. private _currentFaceIndex;
  44883. private _currentFaceIndexCache;
  44884. private _textureType;
  44885. private _defaultTextureMatrix;
  44886. /**
  44887. * Creates a ShadowGenerator object.
  44888. * A ShadowGenerator is the required tool to use the shadows.
  44889. * Each light casting shadows needs to use its own ShadowGenerator.
  44890. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44891. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44892. * @param light The light object generating the shadows.
  44893. * @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.
  44894. */
  44895. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44896. private _initializeGenerator;
  44897. private _initializeShadowMap;
  44898. private _initializeBlurRTTAndPostProcesses;
  44899. private _renderForShadowMap;
  44900. private _renderSubMeshForShadowMap;
  44901. private _applyFilterValues;
  44902. /**
  44903. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44904. * @param onCompiled Callback triggered at the and of the effects compilation
  44905. * @param options Sets of optional options forcing the compilation with different modes
  44906. */
  44907. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44908. useInstances: boolean;
  44909. }>): void;
  44910. /**
  44911. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44912. * @param options Sets of optional options forcing the compilation with different modes
  44913. * @returns A promise that resolves when the compilation completes
  44914. */
  44915. forceCompilationAsync(options?: Partial<{
  44916. useInstances: boolean;
  44917. }>): Promise<void>;
  44918. /**
  44919. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44920. * @param subMesh The submesh we want to render in the shadow map
  44921. * @param useInstances Defines wether will draw in the map using instances
  44922. * @returns true if ready otherwise, false
  44923. */
  44924. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44925. /**
  44926. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44927. * @param defines Defines of the material we want to update
  44928. * @param lightIndex Index of the light in the enabled light list of the material
  44929. */
  44930. prepareDefines(defines: any, lightIndex: number): void;
  44931. /**
  44932. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44933. * defined in the generator but impacting the effect).
  44934. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44935. * @param effect The effect we are binfing the information for
  44936. */
  44937. bindShadowLight(lightIndex: string, effect: Effect): void;
  44938. /**
  44939. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44940. * (eq to shadow prjection matrix * light transform matrix)
  44941. * @returns The transform matrix used to create the shadow map
  44942. */
  44943. getTransformMatrix(): Matrix;
  44944. /**
  44945. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44946. * Cube and 2D textures for instance.
  44947. */
  44948. recreateShadowMap(): void;
  44949. private _disposeBlurPostProcesses;
  44950. private _disposeRTTandPostProcesses;
  44951. /**
  44952. * Disposes the ShadowGenerator.
  44953. * Returns nothing.
  44954. */
  44955. dispose(): void;
  44956. /**
  44957. * Serializes the shadow generator setup to a json object.
  44958. * @returns The serialized JSON object
  44959. */
  44960. serialize(): any;
  44961. /**
  44962. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44963. * @param parsedShadowGenerator The JSON object to parse
  44964. * @param scene The scene to create the shadow map for
  44965. * @returns The parsed shadow generator
  44966. */
  44967. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44968. }
  44969. }
  44970. declare module BABYLON {
  44971. /**
  44972. * Defines the shadow generator component responsible to manage any shadow generators
  44973. * in a given scene.
  44974. */
  44975. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44976. /**
  44977. * The component name helpfull to identify the component in the list of scene components.
  44978. */
  44979. readonly name: string;
  44980. /**
  44981. * The scene the component belongs to.
  44982. */
  44983. scene: Scene;
  44984. /**
  44985. * Creates a new instance of the component for the given scene
  44986. * @param scene Defines the scene to register the component in
  44987. */
  44988. constructor(scene: Scene);
  44989. /**
  44990. * Registers the component in a given scene
  44991. */
  44992. register(): void;
  44993. /**
  44994. * Rebuilds the elements related to this component in case of
  44995. * context lost for instance.
  44996. */
  44997. rebuild(): void;
  44998. /**
  44999. * Serializes the component data to the specified json object
  45000. * @param serializationObject The object to serialize to
  45001. */
  45002. serialize(serializationObject: any): void;
  45003. /**
  45004. * Adds all the element from the container to the scene
  45005. * @param container the container holding the elements
  45006. */
  45007. addFromContainer(container: AbstractScene): void;
  45008. /**
  45009. * Removes all the elements in the container from the scene
  45010. * @param container contains the elements to remove
  45011. */
  45012. removeFromContainer(container: AbstractScene): void;
  45013. /**
  45014. * Rebuilds the elements related to this component in case of
  45015. * context lost for instance.
  45016. */
  45017. dispose(): void;
  45018. private _gatherRenderTargets;
  45019. }
  45020. }
  45021. declare module BABYLON {
  45022. }
  45023. declare module BABYLON {
  45024. /**
  45025. * Background material used to create an efficient environement around your scene.
  45026. */
  45027. class BackgroundMaterial extends PushMaterial {
  45028. /**
  45029. * Standard reflectance value at parallel view angle.
  45030. */
  45031. static StandardReflectance0: number;
  45032. /**
  45033. * Standard reflectance value at grazing angle.
  45034. */
  45035. static StandardReflectance90: number;
  45036. protected _primaryColor: Color3;
  45037. /**
  45038. * Key light Color (multiply against the environement texture)
  45039. */
  45040. primaryColor: Color3;
  45041. protected __perceptualColor: Nullable<Color3>;
  45042. /**
  45043. * Experimental Internal Use Only.
  45044. *
  45045. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45046. * This acts as a helper to set the primary color to a more "human friendly" value.
  45047. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45048. * output color as close as possible from the chosen value.
  45049. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45050. * part of lighting setup.)
  45051. */
  45052. _perceptualColor: Nullable<Color3>;
  45053. protected _primaryColorShadowLevel: float;
  45054. /**
  45055. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45056. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45057. */
  45058. primaryColorShadowLevel: float;
  45059. protected _primaryColorHighlightLevel: float;
  45060. /**
  45061. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45062. * The primary color is used at the level chosen to define what the white area would look.
  45063. */
  45064. primaryColorHighlightLevel: float;
  45065. protected _reflectionTexture: Nullable<BaseTexture>;
  45066. /**
  45067. * Reflection Texture used in the material.
  45068. * Should be author in a specific way for the best result (refer to the documentation).
  45069. */
  45070. reflectionTexture: Nullable<BaseTexture>;
  45071. protected _reflectionBlur: float;
  45072. /**
  45073. * Reflection Texture level of blur.
  45074. *
  45075. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45076. * texture twice.
  45077. */
  45078. reflectionBlur: float;
  45079. protected _diffuseTexture: Nullable<BaseTexture>;
  45080. /**
  45081. * Diffuse Texture used in the material.
  45082. * Should be author in a specific way for the best result (refer to the documentation).
  45083. */
  45084. diffuseTexture: Nullable<BaseTexture>;
  45085. protected _shadowLights: Nullable<IShadowLight[]>;
  45086. /**
  45087. * Specify the list of lights casting shadow on the material.
  45088. * All scene shadow lights will be included if null.
  45089. */
  45090. shadowLights: Nullable<IShadowLight[]>;
  45091. protected _shadowLevel: float;
  45092. /**
  45093. * Helps adjusting the shadow to a softer level if required.
  45094. * 0 means black shadows and 1 means no shadows.
  45095. */
  45096. shadowLevel: float;
  45097. protected _sceneCenter: Vector3;
  45098. /**
  45099. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45100. * It is usually zero but might be interesting to modify according to your setup.
  45101. */
  45102. sceneCenter: Vector3;
  45103. protected _opacityFresnel: boolean;
  45104. /**
  45105. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45106. * This helps ensuring a nice transition when the camera goes under the ground.
  45107. */
  45108. opacityFresnel: boolean;
  45109. protected _reflectionFresnel: boolean;
  45110. /**
  45111. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45112. * This helps adding a mirror texture on the ground.
  45113. */
  45114. reflectionFresnel: boolean;
  45115. protected _reflectionFalloffDistance: number;
  45116. /**
  45117. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45118. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45119. */
  45120. reflectionFalloffDistance: number;
  45121. protected _reflectionAmount: number;
  45122. /**
  45123. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45124. */
  45125. reflectionAmount: number;
  45126. protected _reflectionReflectance0: number;
  45127. /**
  45128. * This specifies the weight of the reflection at grazing angle.
  45129. */
  45130. reflectionReflectance0: number;
  45131. protected _reflectionReflectance90: number;
  45132. /**
  45133. * This specifies the weight of the reflection at a perpendicular point of view.
  45134. */
  45135. reflectionReflectance90: number;
  45136. /**
  45137. * Sets the reflection reflectance fresnel values according to the default standard
  45138. * empirically know to work well :-)
  45139. */
  45140. reflectionStandardFresnelWeight: number;
  45141. protected _useRGBColor: boolean;
  45142. /**
  45143. * Helps to directly use the maps channels instead of their level.
  45144. */
  45145. useRGBColor: boolean;
  45146. protected _enableNoise: boolean;
  45147. /**
  45148. * This helps reducing the banding effect that could occur on the background.
  45149. */
  45150. enableNoise: boolean;
  45151. /**
  45152. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45153. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45154. * Recommended to be keep at 1.0 except for special cases.
  45155. */
  45156. fovMultiplier: number;
  45157. private _fovMultiplier;
  45158. /**
  45159. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45160. */
  45161. useEquirectangularFOV: boolean;
  45162. private _maxSimultaneousLights;
  45163. /**
  45164. * Number of Simultaneous lights allowed on the material.
  45165. */
  45166. maxSimultaneousLights: int;
  45167. /**
  45168. * Default configuration related to image processing available in the Background Material.
  45169. */
  45170. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45171. /**
  45172. * Keep track of the image processing observer to allow dispose and replace.
  45173. */
  45174. private _imageProcessingObserver;
  45175. /**
  45176. * Attaches a new image processing configuration to the PBR Material.
  45177. * @param configuration (if null the scene configuration will be use)
  45178. */
  45179. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45180. /**
  45181. * Gets the image processing configuration used either in this material.
  45182. */
  45183. /**
  45184. * Sets the Default image processing configuration used either in the this material.
  45185. *
  45186. * If sets to null, the scene one is in use.
  45187. */
  45188. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45189. /**
  45190. * Gets wether the color curves effect is enabled.
  45191. */
  45192. /**
  45193. * Sets wether the color curves effect is enabled.
  45194. */
  45195. cameraColorCurvesEnabled: boolean;
  45196. /**
  45197. * Gets wether the color grading effect is enabled.
  45198. */
  45199. /**
  45200. * Gets wether the color grading effect is enabled.
  45201. */
  45202. cameraColorGradingEnabled: boolean;
  45203. /**
  45204. * Gets wether tonemapping is enabled or not.
  45205. */
  45206. /**
  45207. * Sets wether tonemapping is enabled or not
  45208. */
  45209. cameraToneMappingEnabled: boolean;
  45210. /**
  45211. * The camera exposure used on this material.
  45212. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45213. * This corresponds to a photographic exposure.
  45214. */
  45215. /**
  45216. * The camera exposure used on this material.
  45217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45218. * This corresponds to a photographic exposure.
  45219. */
  45220. cameraExposure: float;
  45221. /**
  45222. * Gets The camera contrast used on this material.
  45223. */
  45224. /**
  45225. * Sets The camera contrast used on this material.
  45226. */
  45227. cameraContrast: float;
  45228. /**
  45229. * Gets the Color Grading 2D Lookup Texture.
  45230. */
  45231. /**
  45232. * Sets the Color Grading 2D Lookup Texture.
  45233. */
  45234. cameraColorGradingTexture: Nullable<BaseTexture>;
  45235. /**
  45236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45238. * 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;
  45239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45240. */
  45241. /**
  45242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45244. * 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;
  45245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45246. */
  45247. cameraColorCurves: Nullable<ColorCurves>;
  45248. /**
  45249. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45250. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45251. */
  45252. switchToBGR: boolean;
  45253. private _renderTargets;
  45254. private _reflectionControls;
  45255. private _white;
  45256. private _primaryShadowColor;
  45257. private _primaryHighlightColor;
  45258. /**
  45259. * Instantiates a Background Material in the given scene
  45260. * @param name The friendly name of the material
  45261. * @param scene The scene to add the material to
  45262. */
  45263. constructor(name: string, scene: Scene);
  45264. /**
  45265. * Gets a boolean indicating that current material needs to register RTT
  45266. */
  45267. readonly hasRenderTargetTextures: boolean;
  45268. /**
  45269. * The entire material has been created in order to prevent overdraw.
  45270. * @returns false
  45271. */
  45272. needAlphaTesting(): boolean;
  45273. /**
  45274. * The entire material has been created in order to prevent overdraw.
  45275. * @returns true if blending is enable
  45276. */
  45277. needAlphaBlending(): boolean;
  45278. /**
  45279. * Checks wether the material is ready to be rendered for a given mesh.
  45280. * @param mesh The mesh to render
  45281. * @param subMesh The submesh to check against
  45282. * @param useInstances Specify wether or not the material is used with instances
  45283. * @returns true if all the dependencies are ready (Textures, Effects...)
  45284. */
  45285. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45286. /**
  45287. * Compute the primary color according to the chosen perceptual color.
  45288. */
  45289. private _computePrimaryColorFromPerceptualColor;
  45290. /**
  45291. * Compute the highlights and shadow colors according to their chosen levels.
  45292. */
  45293. private _computePrimaryColors;
  45294. /**
  45295. * Build the uniform buffer used in the material.
  45296. */
  45297. buildUniformLayout(): void;
  45298. /**
  45299. * Unbind the material.
  45300. */
  45301. unbind(): void;
  45302. /**
  45303. * Bind only the world matrix to the material.
  45304. * @param world The world matrix to bind.
  45305. */
  45306. bindOnlyWorldMatrix(world: Matrix): void;
  45307. /**
  45308. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45309. * @param world The world matrix to bind.
  45310. * @param subMesh The submesh to bind for.
  45311. */
  45312. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45313. /**
  45314. * Dispose the material.
  45315. * @param forceDisposeEffect Force disposal of the associated effect.
  45316. * @param forceDisposeTextures Force disposal of the associated textures.
  45317. */
  45318. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45319. /**
  45320. * Clones the material.
  45321. * @param name The cloned name.
  45322. * @returns The cloned material.
  45323. */
  45324. clone(name: string): BackgroundMaterial;
  45325. /**
  45326. * Serializes the current material to its JSON representation.
  45327. * @returns The JSON representation.
  45328. */
  45329. serialize(): any;
  45330. /**
  45331. * Gets the class name of the material
  45332. * @returns "BackgroundMaterial"
  45333. */
  45334. getClassName(): string;
  45335. /**
  45336. * Parse a JSON input to create back a background material.
  45337. * @param source The JSON data to parse
  45338. * @param scene The scene to create the parsed material in
  45339. * @param rootUrl The root url of the assets the material depends upon
  45340. * @returns the instantiated BackgroundMaterial.
  45341. */
  45342. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45343. }
  45344. }
  45345. declare module BABYLON {
  45346. /**
  45347. * The Physically based material base class of BJS.
  45348. *
  45349. * This offers the main features of a standard PBR material.
  45350. * For more information, please refer to the documentation :
  45351. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45352. */
  45353. abstract class PBRBaseMaterial extends PushMaterial {
  45354. /**
  45355. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45356. */
  45357. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45358. /**
  45359. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45360. * to enhance interoperability with other engines.
  45361. */
  45362. static readonly LIGHTFALLOFF_GLTF: number;
  45363. /**
  45364. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45365. * to enhance interoperability with other materials.
  45366. */
  45367. static readonly LIGHTFALLOFF_STANDARD: number;
  45368. /**
  45369. * Intensity of the direct lights e.g. the four lights available in your scene.
  45370. * This impacts both the direct diffuse and specular highlights.
  45371. */
  45372. protected _directIntensity: number;
  45373. /**
  45374. * Intensity of the emissive part of the material.
  45375. * This helps controlling the emissive effect without modifying the emissive color.
  45376. */
  45377. protected _emissiveIntensity: number;
  45378. /**
  45379. * Intensity of the environment e.g. how much the environment will light the object
  45380. * either through harmonics for rough material or through the refelction for shiny ones.
  45381. */
  45382. protected _environmentIntensity: number;
  45383. /**
  45384. * This is a special control allowing the reduction of the specular highlights coming from the
  45385. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45386. */
  45387. protected _specularIntensity: number;
  45388. /**
  45389. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45390. */
  45391. private _lightingInfos;
  45392. /**
  45393. * Debug Control allowing disabling the bump map on this material.
  45394. */
  45395. protected _disableBumpMap: boolean;
  45396. /**
  45397. * AKA Diffuse Texture in standard nomenclature.
  45398. */
  45399. protected _albedoTexture: BaseTexture;
  45400. /**
  45401. * AKA Occlusion Texture in other nomenclature.
  45402. */
  45403. protected _ambientTexture: BaseTexture;
  45404. /**
  45405. * AKA Occlusion Texture Intensity in other nomenclature.
  45406. */
  45407. protected _ambientTextureStrength: number;
  45408. /**
  45409. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45410. * 1 means it completely occludes it
  45411. * 0 mean it has no impact
  45412. */
  45413. protected _ambientTextureImpactOnAnalyticalLights: number;
  45414. /**
  45415. * Stores the alpha values in a texture.
  45416. */
  45417. protected _opacityTexture: BaseTexture;
  45418. /**
  45419. * Stores the reflection values in a texture.
  45420. */
  45421. protected _reflectionTexture: BaseTexture;
  45422. /**
  45423. * Stores the refraction values in a texture.
  45424. */
  45425. protected _refractionTexture: BaseTexture;
  45426. /**
  45427. * Stores the emissive values in a texture.
  45428. */
  45429. protected _emissiveTexture: BaseTexture;
  45430. /**
  45431. * AKA Specular texture in other nomenclature.
  45432. */
  45433. protected _reflectivityTexture: BaseTexture;
  45434. /**
  45435. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45436. */
  45437. protected _metallicTexture: BaseTexture;
  45438. /**
  45439. * Specifies the metallic scalar of the metallic/roughness workflow.
  45440. * Can also be used to scale the metalness values of the metallic texture.
  45441. */
  45442. protected _metallic: Nullable<number>;
  45443. /**
  45444. * Specifies the roughness scalar of the metallic/roughness workflow.
  45445. * Can also be used to scale the roughness values of the metallic texture.
  45446. */
  45447. protected _roughness: Nullable<number>;
  45448. /**
  45449. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45450. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45451. */
  45452. protected _microSurfaceTexture: BaseTexture;
  45453. /**
  45454. * Stores surface normal data used to displace a mesh in a texture.
  45455. */
  45456. protected _bumpTexture: BaseTexture;
  45457. /**
  45458. * Stores the pre-calculated light information of a mesh in a texture.
  45459. */
  45460. protected _lightmapTexture: BaseTexture;
  45461. /**
  45462. * The color of a material in ambient lighting.
  45463. */
  45464. protected _ambientColor: Color3;
  45465. /**
  45466. * AKA Diffuse Color in other nomenclature.
  45467. */
  45468. protected _albedoColor: Color3;
  45469. /**
  45470. * AKA Specular Color in other nomenclature.
  45471. */
  45472. protected _reflectivityColor: Color3;
  45473. /**
  45474. * The color applied when light is reflected from a material.
  45475. */
  45476. protected _reflectionColor: Color3;
  45477. /**
  45478. * The color applied when light is emitted from a material.
  45479. */
  45480. protected _emissiveColor: Color3;
  45481. /**
  45482. * AKA Glossiness in other nomenclature.
  45483. */
  45484. protected _microSurface: number;
  45485. /**
  45486. * source material index of refraction (IOR)' / 'destination material IOR.
  45487. */
  45488. protected _indexOfRefraction: number;
  45489. /**
  45490. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45491. */
  45492. protected _invertRefractionY: boolean;
  45493. /**
  45494. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45495. * Materials half opaque for instance using refraction could benefit from this control.
  45496. */
  45497. protected _linkRefractionWithTransparency: boolean;
  45498. /**
  45499. * Specifies that the material will use the light map as a show map.
  45500. */
  45501. protected _useLightmapAsShadowmap: boolean;
  45502. /**
  45503. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45504. * makes the reflect vector face the model (under horizon).
  45505. */
  45506. protected _useHorizonOcclusion: boolean;
  45507. /**
  45508. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45509. * too much the area relying on ambient texture to define their ambient occlusion.
  45510. */
  45511. protected _useRadianceOcclusion: boolean;
  45512. /**
  45513. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45514. */
  45515. protected _useAlphaFromAlbedoTexture: boolean;
  45516. /**
  45517. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45518. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45519. */
  45520. protected _useSpecularOverAlpha: boolean;
  45521. /**
  45522. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45523. */
  45524. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45525. /**
  45526. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45527. */
  45528. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45529. /**
  45530. * Specifies if the metallic texture contains the roughness information in its green channel.
  45531. */
  45532. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45533. /**
  45534. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45535. */
  45536. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45537. /**
  45538. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45539. */
  45540. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45541. /**
  45542. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45543. */
  45544. protected _useAmbientInGrayScale: boolean;
  45545. /**
  45546. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45547. * The material will try to infer what glossiness each pixel should be.
  45548. */
  45549. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45550. /**
  45551. * Defines the falloff type used in this material.
  45552. * It by default is Physical.
  45553. */
  45554. protected _lightFalloff: number;
  45555. /**
  45556. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45557. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45558. */
  45559. protected _useRadianceOverAlpha: boolean;
  45560. /**
  45561. * Allows using an object space normal map (instead of tangent space).
  45562. */
  45563. protected _useObjectSpaceNormalMap: boolean;
  45564. /**
  45565. * Allows using the bump map in parallax mode.
  45566. */
  45567. protected _useParallax: boolean;
  45568. /**
  45569. * Allows using the bump map in parallax occlusion mode.
  45570. */
  45571. protected _useParallaxOcclusion: boolean;
  45572. /**
  45573. * Controls the scale bias of the parallax mode.
  45574. */
  45575. protected _parallaxScaleBias: number;
  45576. /**
  45577. * If sets to true, disables all the lights affecting the material.
  45578. */
  45579. protected _disableLighting: boolean;
  45580. /**
  45581. * Number of Simultaneous lights allowed on the material.
  45582. */
  45583. protected _maxSimultaneousLights: number;
  45584. /**
  45585. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45586. */
  45587. protected _invertNormalMapX: boolean;
  45588. /**
  45589. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45590. */
  45591. protected _invertNormalMapY: boolean;
  45592. /**
  45593. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45594. */
  45595. protected _twoSidedLighting: boolean;
  45596. /**
  45597. * Defines the alpha limits in alpha test mode.
  45598. */
  45599. protected _alphaCutOff: number;
  45600. /**
  45601. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45602. */
  45603. protected _forceAlphaTest: boolean;
  45604. /**
  45605. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45606. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45607. */
  45608. protected _useAlphaFresnel: boolean;
  45609. /**
  45610. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45611. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45612. */
  45613. protected _useLinearAlphaFresnel: boolean;
  45614. /**
  45615. * The transparency mode of the material.
  45616. */
  45617. protected _transparencyMode: Nullable<number>;
  45618. /**
  45619. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45620. * from cos thetav and roughness:
  45621. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45622. */
  45623. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45624. /**
  45625. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45626. */
  45627. protected _forceIrradianceInFragment: boolean;
  45628. /**
  45629. * Force normal to face away from face.
  45630. */
  45631. protected _forceNormalForward: boolean;
  45632. /**
  45633. * Enables specular anti aliasing in the PBR shader.
  45634. * It will both interacts on the Geometry for analytical and IBL lighting.
  45635. * It also prefilter the roughness map based on the bump values.
  45636. */
  45637. protected _enableSpecularAntiAliasing: boolean;
  45638. /**
  45639. * Default configuration related to image processing available in the PBR Material.
  45640. */
  45641. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45642. /**
  45643. * Keep track of the image processing observer to allow dispose and replace.
  45644. */
  45645. private _imageProcessingObserver;
  45646. /**
  45647. * Attaches a new image processing configuration to the PBR Material.
  45648. * @param configuration
  45649. */
  45650. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45651. /**
  45652. * Stores the available render targets.
  45653. */
  45654. private _renderTargets;
  45655. /**
  45656. * Sets the global ambient color for the material used in lighting calculations.
  45657. */
  45658. private _globalAmbientColor;
  45659. /**
  45660. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45661. */
  45662. private _useLogarithmicDepth;
  45663. /**
  45664. * If set to true, no lighting calculations will be applied.
  45665. */
  45666. private _unlit;
  45667. /**
  45668. * Instantiates a new PBRMaterial instance.
  45669. *
  45670. * @param name The material name
  45671. * @param scene The scene the material will be use in.
  45672. */
  45673. constructor(name: string, scene: Scene);
  45674. /**
  45675. * Gets a boolean indicating that current material needs to register RTT
  45676. */
  45677. readonly hasRenderTargetTextures: boolean;
  45678. /**
  45679. * Gets the name of the material class.
  45680. */
  45681. getClassName(): string;
  45682. /**
  45683. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45684. */
  45685. /**
  45686. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45687. */
  45688. useLogarithmicDepth: boolean;
  45689. /**
  45690. * Gets the current transparency mode.
  45691. */
  45692. /**
  45693. * Sets the transparency mode of the material.
  45694. *
  45695. * | Value | Type | Description |
  45696. * | ----- | ----------------------------------- | ----------- |
  45697. * | 0 | OPAQUE | |
  45698. * | 1 | ALPHATEST | |
  45699. * | 2 | ALPHABLEND | |
  45700. * | 3 | ALPHATESTANDBLEND | |
  45701. *
  45702. */
  45703. transparencyMode: Nullable<number>;
  45704. /**
  45705. * Returns true if alpha blending should be disabled.
  45706. */
  45707. private readonly _disableAlphaBlending;
  45708. /**
  45709. * Specifies whether or not this material should be rendered in alpha blend mode.
  45710. */
  45711. needAlphaBlending(): boolean;
  45712. /**
  45713. * Specifies if the mesh will require alpha blending.
  45714. * @param mesh - BJS mesh.
  45715. */
  45716. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45717. /**
  45718. * Specifies whether or not this material should be rendered in alpha test mode.
  45719. */
  45720. needAlphaTesting(): boolean;
  45721. /**
  45722. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45723. */
  45724. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45725. /**
  45726. * Gets the texture used for the alpha test.
  45727. */
  45728. getAlphaTestTexture(): BaseTexture;
  45729. /**
  45730. * Stores the reflectivity values based on metallic roughness workflow.
  45731. */
  45732. private static _scaledReflectivity;
  45733. /**
  45734. * Specifies that the submesh is ready to be used.
  45735. * @param mesh - BJS mesh.
  45736. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45737. * @param useInstances - Specifies that instances should be used.
  45738. * @returns - boolean indicating that the submesh is ready or not.
  45739. */
  45740. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45741. /**
  45742. * Specifies if the material uses metallic roughness workflow.
  45743. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45744. */
  45745. isMetallicWorkflow(): boolean;
  45746. private _prepareEffect;
  45747. private _prepareDefines;
  45748. /**
  45749. * Force shader compilation
  45750. */
  45751. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45752. clipPlane: boolean;
  45753. }>): void;
  45754. /**
  45755. * Initializes the uniform buffer layout for the shader.
  45756. */
  45757. buildUniformLayout(): void;
  45758. /**
  45759. * Unbinds the textures.
  45760. */
  45761. unbind(): void;
  45762. /**
  45763. * Binds the submesh data.
  45764. * @param world - The world matrix.
  45765. * @param mesh - The BJS mesh.
  45766. * @param subMesh - A submesh of the BJS mesh.
  45767. */
  45768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45769. /**
  45770. * Returns the animatable textures.
  45771. * @returns - Array of animatable textures.
  45772. */
  45773. getAnimatables(): IAnimatable[];
  45774. /**
  45775. * Returns the texture used for reflections.
  45776. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45777. */
  45778. private _getReflectionTexture;
  45779. /**
  45780. * Returns the texture used for refraction or null if none is used.
  45781. * @returns - Refection texture if present. If no refraction texture and refraction
  45782. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45783. */
  45784. private _getRefractionTexture;
  45785. /**
  45786. * Disposes the resources of the material.
  45787. * @param forceDisposeEffect - Forces the disposal of effects.
  45788. * @param forceDisposeTextures - Forces the disposal of all textures.
  45789. */
  45790. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45791. }
  45792. }
  45793. declare module BABYLON {
  45794. /**
  45795. * The Physically based simple base material of BJS.
  45796. *
  45797. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45798. * It is used as the base class for both the specGloss and metalRough conventions.
  45799. */
  45800. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45801. /**
  45802. * Number of Simultaneous lights allowed on the material.
  45803. */
  45804. maxSimultaneousLights: number;
  45805. /**
  45806. * If sets to true, disables all the lights affecting the material.
  45807. */
  45808. disableLighting: boolean;
  45809. /**
  45810. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45811. */
  45812. environmentTexture: BaseTexture;
  45813. /**
  45814. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45815. */
  45816. invertNormalMapX: boolean;
  45817. /**
  45818. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45819. */
  45820. invertNormalMapY: boolean;
  45821. /**
  45822. * Normal map used in the model.
  45823. */
  45824. normalTexture: BaseTexture;
  45825. /**
  45826. * Emissivie color used to self-illuminate the model.
  45827. */
  45828. emissiveColor: Color3;
  45829. /**
  45830. * Emissivie texture used to self-illuminate the model.
  45831. */
  45832. emissiveTexture: BaseTexture;
  45833. /**
  45834. * Occlusion Channel Strenght.
  45835. */
  45836. occlusionStrength: number;
  45837. /**
  45838. * Occlusion Texture of the material (adding extra occlusion effects).
  45839. */
  45840. occlusionTexture: BaseTexture;
  45841. /**
  45842. * Defines the alpha limits in alpha test mode.
  45843. */
  45844. alphaCutOff: number;
  45845. /**
  45846. * Gets the current double sided mode.
  45847. */
  45848. /**
  45849. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45850. */
  45851. doubleSided: boolean;
  45852. /**
  45853. * Stores the pre-calculated light information of a mesh in a texture.
  45854. */
  45855. lightmapTexture: BaseTexture;
  45856. /**
  45857. * If true, the light map contains occlusion information instead of lighting info.
  45858. */
  45859. useLightmapAsShadowmap: boolean;
  45860. /**
  45861. * Return the active textures of the material.
  45862. */
  45863. getActiveTextures(): BaseTexture[];
  45864. hasTexture(texture: BaseTexture): boolean;
  45865. /**
  45866. * Instantiates a new PBRMaterial instance.
  45867. *
  45868. * @param name The material name
  45869. * @param scene The scene the material will be use in.
  45870. */
  45871. constructor(name: string, scene: Scene);
  45872. getClassName(): string;
  45873. }
  45874. }
  45875. declare module BABYLON {
  45876. /**
  45877. * The Physically based material of BJS.
  45878. *
  45879. * This offers the main features of a standard PBR material.
  45880. * For more information, please refer to the documentation :
  45881. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45882. */
  45883. class PBRMaterial extends PBRBaseMaterial {
  45884. /**
  45885. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45886. */
  45887. static readonly PBRMATERIAL_OPAQUE: number;
  45888. /**
  45889. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45890. */
  45891. static readonly PBRMATERIAL_ALPHATEST: number;
  45892. /**
  45893. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45894. */
  45895. static readonly PBRMATERIAL_ALPHABLEND: number;
  45896. /**
  45897. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45898. * They are also discarded below the alpha cutoff threshold to improve performances.
  45899. */
  45900. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45901. /**
  45902. * Defines the default value of how much AO map is occluding the analytical lights
  45903. * (point spot...).
  45904. */
  45905. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45906. /**
  45907. * Intensity of the direct lights e.g. the four lights available in your scene.
  45908. * This impacts both the direct diffuse and specular highlights.
  45909. */
  45910. directIntensity: number;
  45911. /**
  45912. * Intensity of the emissive part of the material.
  45913. * This helps controlling the emissive effect without modifying the emissive color.
  45914. */
  45915. emissiveIntensity: number;
  45916. /**
  45917. * Intensity of the environment e.g. how much the environment will light the object
  45918. * either through harmonics for rough material or through the refelction for shiny ones.
  45919. */
  45920. environmentIntensity: number;
  45921. /**
  45922. * This is a special control allowing the reduction of the specular highlights coming from the
  45923. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45924. */
  45925. specularIntensity: number;
  45926. /**
  45927. * Debug Control allowing disabling the bump map on this material.
  45928. */
  45929. disableBumpMap: boolean;
  45930. /**
  45931. * AKA Diffuse Texture in standard nomenclature.
  45932. */
  45933. albedoTexture: BaseTexture;
  45934. /**
  45935. * AKA Occlusion Texture in other nomenclature.
  45936. */
  45937. ambientTexture: BaseTexture;
  45938. /**
  45939. * AKA Occlusion Texture Intensity in other nomenclature.
  45940. */
  45941. ambientTextureStrength: number;
  45942. /**
  45943. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45944. * 1 means it completely occludes it
  45945. * 0 mean it has no impact
  45946. */
  45947. ambientTextureImpactOnAnalyticalLights: number;
  45948. /**
  45949. * Stores the alpha values in a texture.
  45950. */
  45951. opacityTexture: BaseTexture;
  45952. /**
  45953. * Stores the reflection values in a texture.
  45954. */
  45955. reflectionTexture: Nullable<BaseTexture>;
  45956. /**
  45957. * Stores the emissive values in a texture.
  45958. */
  45959. emissiveTexture: BaseTexture;
  45960. /**
  45961. * AKA Specular texture in other nomenclature.
  45962. */
  45963. reflectivityTexture: BaseTexture;
  45964. /**
  45965. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45966. */
  45967. metallicTexture: BaseTexture;
  45968. /**
  45969. * Specifies the metallic scalar of the metallic/roughness workflow.
  45970. * Can also be used to scale the metalness values of the metallic texture.
  45971. */
  45972. metallic: Nullable<number>;
  45973. /**
  45974. * Specifies the roughness scalar of the metallic/roughness workflow.
  45975. * Can also be used to scale the roughness values of the metallic texture.
  45976. */
  45977. roughness: Nullable<number>;
  45978. /**
  45979. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45980. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45981. */
  45982. microSurfaceTexture: BaseTexture;
  45983. /**
  45984. * Stores surface normal data used to displace a mesh in a texture.
  45985. */
  45986. bumpTexture: BaseTexture;
  45987. /**
  45988. * Stores the pre-calculated light information of a mesh in a texture.
  45989. */
  45990. lightmapTexture: BaseTexture;
  45991. /**
  45992. * Stores the refracted light information in a texture.
  45993. */
  45994. refractionTexture: BaseTexture;
  45995. /**
  45996. * The color of a material in ambient lighting.
  45997. */
  45998. ambientColor: Color3;
  45999. /**
  46000. * AKA Diffuse Color in other nomenclature.
  46001. */
  46002. albedoColor: Color3;
  46003. /**
  46004. * AKA Specular Color in other nomenclature.
  46005. */
  46006. reflectivityColor: Color3;
  46007. /**
  46008. * The color reflected from the material.
  46009. */
  46010. reflectionColor: Color3;
  46011. /**
  46012. * The color emitted from the material.
  46013. */
  46014. emissiveColor: Color3;
  46015. /**
  46016. * AKA Glossiness in other nomenclature.
  46017. */
  46018. microSurface: number;
  46019. /**
  46020. * source material index of refraction (IOR)' / 'destination material IOR.
  46021. */
  46022. indexOfRefraction: number;
  46023. /**
  46024. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46025. */
  46026. invertRefractionY: boolean;
  46027. /**
  46028. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46029. * Materials half opaque for instance using refraction could benefit from this control.
  46030. */
  46031. linkRefractionWithTransparency: boolean;
  46032. /**
  46033. * If true, the light map contains occlusion information instead of lighting info.
  46034. */
  46035. useLightmapAsShadowmap: boolean;
  46036. /**
  46037. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46038. */
  46039. useAlphaFromAlbedoTexture: boolean;
  46040. /**
  46041. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46042. */
  46043. forceAlphaTest: boolean;
  46044. /**
  46045. * Defines the alpha limits in alpha test mode.
  46046. */
  46047. alphaCutOff: number;
  46048. /**
  46049. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46050. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46051. */
  46052. useSpecularOverAlpha: boolean;
  46053. /**
  46054. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46055. */
  46056. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46057. /**
  46058. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46059. */
  46060. useRoughnessFromMetallicTextureAlpha: boolean;
  46061. /**
  46062. * Specifies if the metallic texture contains the roughness information in its green channel.
  46063. */
  46064. useRoughnessFromMetallicTextureGreen: boolean;
  46065. /**
  46066. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46067. */
  46068. useMetallnessFromMetallicTextureBlue: boolean;
  46069. /**
  46070. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46071. */
  46072. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46073. /**
  46074. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46075. */
  46076. useAmbientInGrayScale: boolean;
  46077. /**
  46078. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46079. * The material will try to infer what glossiness each pixel should be.
  46080. */
  46081. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46082. /**
  46083. * BJS is using an harcoded light falloff based on a manually sets up range.
  46084. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46085. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46086. */
  46087. /**
  46088. * BJS is using an harcoded light falloff based on a manually sets up range.
  46089. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46090. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46091. */
  46092. usePhysicalLightFalloff: boolean;
  46093. /**
  46094. * In order to support the falloff compatibility with gltf, a special mode has been added
  46095. * to reproduce the gltf light falloff.
  46096. */
  46097. /**
  46098. * In order to support the falloff compatibility with gltf, a special mode has been added
  46099. * to reproduce the gltf light falloff.
  46100. */
  46101. useGLTFLightFalloff: boolean;
  46102. /**
  46103. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46104. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46105. */
  46106. useRadianceOverAlpha: boolean;
  46107. /**
  46108. * Allows using an object space normal map (instead of tangent space).
  46109. */
  46110. useObjectSpaceNormalMap: boolean;
  46111. /**
  46112. * Allows using the bump map in parallax mode.
  46113. */
  46114. useParallax: boolean;
  46115. /**
  46116. * Allows using the bump map in parallax occlusion mode.
  46117. */
  46118. useParallaxOcclusion: boolean;
  46119. /**
  46120. * Controls the scale bias of the parallax mode.
  46121. */
  46122. parallaxScaleBias: number;
  46123. /**
  46124. * If sets to true, disables all the lights affecting the material.
  46125. */
  46126. disableLighting: boolean;
  46127. /**
  46128. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46129. */
  46130. forceIrradianceInFragment: boolean;
  46131. /**
  46132. * Number of Simultaneous lights allowed on the material.
  46133. */
  46134. maxSimultaneousLights: number;
  46135. /**
  46136. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46137. */
  46138. invertNormalMapX: boolean;
  46139. /**
  46140. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46141. */
  46142. invertNormalMapY: boolean;
  46143. /**
  46144. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46145. */
  46146. twoSidedLighting: boolean;
  46147. /**
  46148. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46149. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46150. */
  46151. useAlphaFresnel: boolean;
  46152. /**
  46153. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46154. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46155. */
  46156. useLinearAlphaFresnel: boolean;
  46157. /**
  46158. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46159. * And/Or occlude the blended part.
  46160. */
  46161. environmentBRDFTexture: Nullable<BaseTexture>;
  46162. /**
  46163. * Force normal to face away from face.
  46164. */
  46165. forceNormalForward: boolean;
  46166. /**
  46167. * Enables specular anti aliasing in the PBR shader.
  46168. * It will both interacts on the Geometry for analytical and IBL lighting.
  46169. * It also prefilter the roughness map based on the bump values.
  46170. */
  46171. enableSpecularAntiAliasing: boolean;
  46172. /**
  46173. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46174. * makes the reflect vector face the model (under horizon).
  46175. */
  46176. useHorizonOcclusion: boolean;
  46177. /**
  46178. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46179. * too much the area relying on ambient texture to define their ambient occlusion.
  46180. */
  46181. useRadianceOcclusion: boolean;
  46182. /**
  46183. * If set to true, no lighting calculations will be applied.
  46184. */
  46185. unlit: boolean;
  46186. /**
  46187. * Gets the image processing configuration used either in this material.
  46188. */
  46189. /**
  46190. * Sets the Default image processing configuration used either in the this material.
  46191. *
  46192. * If sets to null, the scene one is in use.
  46193. */
  46194. imageProcessingConfiguration: ImageProcessingConfiguration;
  46195. /**
  46196. * Gets wether the color curves effect is enabled.
  46197. */
  46198. /**
  46199. * Sets wether the color curves effect is enabled.
  46200. */
  46201. cameraColorCurvesEnabled: boolean;
  46202. /**
  46203. * Gets wether the color grading effect is enabled.
  46204. */
  46205. /**
  46206. * Gets wether the color grading effect is enabled.
  46207. */
  46208. cameraColorGradingEnabled: boolean;
  46209. /**
  46210. * Gets wether tonemapping is enabled or not.
  46211. */
  46212. /**
  46213. * Sets wether tonemapping is enabled or not
  46214. */
  46215. cameraToneMappingEnabled: boolean;
  46216. /**
  46217. * The camera exposure used on this material.
  46218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46219. * This corresponds to a photographic exposure.
  46220. */
  46221. /**
  46222. * The camera exposure used on this material.
  46223. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46224. * This corresponds to a photographic exposure.
  46225. */
  46226. cameraExposure: number;
  46227. /**
  46228. * Gets The camera contrast used on this material.
  46229. */
  46230. /**
  46231. * Sets The camera contrast used on this material.
  46232. */
  46233. cameraContrast: number;
  46234. /**
  46235. * Gets the Color Grading 2D Lookup Texture.
  46236. */
  46237. /**
  46238. * Sets the Color Grading 2D Lookup Texture.
  46239. */
  46240. cameraColorGradingTexture: Nullable<BaseTexture>;
  46241. /**
  46242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46244. * 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;
  46245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46246. */
  46247. /**
  46248. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46249. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46250. * 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;
  46251. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46252. */
  46253. cameraColorCurves: Nullable<ColorCurves>;
  46254. /**
  46255. * Instantiates a new PBRMaterial instance.
  46256. *
  46257. * @param name The material name
  46258. * @param scene The scene the material will be use in.
  46259. */
  46260. constructor(name: string, scene: Scene);
  46261. /**
  46262. * Returns the name of this material class.
  46263. */
  46264. getClassName(): string;
  46265. /**
  46266. * Returns an array of the actively used textures.
  46267. * @returns - Array of BaseTextures
  46268. */
  46269. getActiveTextures(): BaseTexture[];
  46270. /**
  46271. * Checks to see if a texture is used in the material.
  46272. * @param texture - Base texture to use.
  46273. * @returns - Boolean specifying if a texture is used in the material.
  46274. */
  46275. hasTexture(texture: BaseTexture): boolean;
  46276. /**
  46277. * Makes a duplicate of the current material.
  46278. * @param name - name to use for the new material.
  46279. */
  46280. clone(name: string): PBRMaterial;
  46281. /**
  46282. * Serializes this PBR Material.
  46283. * @returns - An object with the serialized material.
  46284. */
  46285. serialize(): any;
  46286. /**
  46287. * Parses a PBR Material from a serialized object.
  46288. * @param source - Serialized object.
  46289. * @param scene - BJS scene instance.
  46290. * @param rootUrl - url for the scene object
  46291. * @returns - PBRMaterial
  46292. */
  46293. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46294. }
  46295. }
  46296. declare module BABYLON {
  46297. /**
  46298. * The PBR material of BJS following the metal roughness convention.
  46299. *
  46300. * This fits to the PBR convention in the GLTF definition:
  46301. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46302. */
  46303. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46304. /**
  46305. * The base color has two different interpretations depending on the value of metalness.
  46306. * When the material is a metal, the base color is the specific measured reflectance value
  46307. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46308. * of the material.
  46309. */
  46310. baseColor: Color3;
  46311. /**
  46312. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46313. * well as opacity information in the alpha channel.
  46314. */
  46315. baseTexture: BaseTexture;
  46316. /**
  46317. * Specifies the metallic scalar value of the material.
  46318. * Can also be used to scale the metalness values of the metallic texture.
  46319. */
  46320. metallic: number;
  46321. /**
  46322. * Specifies the roughness scalar value of the material.
  46323. * Can also be used to scale the roughness values of the metallic texture.
  46324. */
  46325. roughness: number;
  46326. /**
  46327. * Texture containing both the metallic value in the B channel and the
  46328. * roughness value in the G channel to keep better precision.
  46329. */
  46330. metallicRoughnessTexture: BaseTexture;
  46331. /**
  46332. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46333. *
  46334. * @param name The material name
  46335. * @param scene The scene the material will be use in.
  46336. */
  46337. constructor(name: string, scene: Scene);
  46338. /**
  46339. * Return the currrent class name of the material.
  46340. */
  46341. getClassName(): string;
  46342. /**
  46343. * Return the active textures of the material.
  46344. */
  46345. getActiveTextures(): BaseTexture[];
  46346. /**
  46347. * Checks to see if a texture is used in the material.
  46348. * @param texture - Base texture to use.
  46349. * @returns - Boolean specifying if a texture is used in the material.
  46350. */
  46351. hasTexture(texture: BaseTexture): boolean;
  46352. /**
  46353. * Makes a duplicate of the current material.
  46354. * @param name - name to use for the new material.
  46355. */
  46356. clone(name: string): PBRMetallicRoughnessMaterial;
  46357. /**
  46358. * Serialize the material to a parsable JSON object.
  46359. */
  46360. serialize(): any;
  46361. /**
  46362. * Parses a JSON object correponding to the serialize function.
  46363. */
  46364. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46365. }
  46366. }
  46367. declare module BABYLON {
  46368. /**
  46369. * The PBR material of BJS following the specular glossiness convention.
  46370. *
  46371. * This fits to the PBR convention in the GLTF definition:
  46372. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46373. */
  46374. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46375. /**
  46376. * Specifies the diffuse color of the material.
  46377. */
  46378. diffuseColor: Color3;
  46379. /**
  46380. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46381. * channel.
  46382. */
  46383. diffuseTexture: BaseTexture;
  46384. /**
  46385. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46386. */
  46387. specularColor: Color3;
  46388. /**
  46389. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46390. */
  46391. glossiness: number;
  46392. /**
  46393. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46394. */
  46395. specularGlossinessTexture: BaseTexture;
  46396. /**
  46397. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46398. *
  46399. * @param name The material name
  46400. * @param scene The scene the material will be use in.
  46401. */
  46402. constructor(name: string, scene: Scene);
  46403. /**
  46404. * Return the currrent class name of the material.
  46405. */
  46406. getClassName(): string;
  46407. /**
  46408. * Return the active textures of the material.
  46409. */
  46410. getActiveTextures(): BaseTexture[];
  46411. /**
  46412. * Checks to see if a texture is used in the material.
  46413. * @param texture - Base texture to use.
  46414. * @returns - Boolean specifying if a texture is used in the material.
  46415. */
  46416. hasTexture(texture: BaseTexture): boolean;
  46417. /**
  46418. * Makes a duplicate of the current material.
  46419. * @param name - name to use for the new material.
  46420. */
  46421. clone(name: string): PBRSpecularGlossinessMaterial;
  46422. /**
  46423. * Serialize the material to a parsable JSON object.
  46424. */
  46425. serialize(): any;
  46426. /**
  46427. * Parses a JSON object correponding to the serialize function.
  46428. */
  46429. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46430. }
  46431. }
  46432. declare module BABYLON {
  46433. /**
  46434. * Base class of all the textures in babylon.
  46435. * It groups all the common properties the materials, post process, lights... might need
  46436. * in order to make a correct use of the texture.
  46437. */
  46438. class BaseTexture {
  46439. /**
  46440. * Default anisotropic filtering level for the application.
  46441. * It is set to 4 as a good tradeoff between perf and quality.
  46442. */
  46443. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46444. /**
  46445. * Gets or sets the unique id of the texture
  46446. */
  46447. uniqueId: number;
  46448. /**
  46449. * Define the name of the texture.
  46450. */
  46451. name: string;
  46452. /**
  46453. * Gets or sets an object used to store user defined information.
  46454. */
  46455. metadata: any;
  46456. /**
  46457. * For internal use only. Please do not use.
  46458. */
  46459. reservedDataStore: any;
  46460. private _hasAlpha;
  46461. /**
  46462. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46463. */
  46464. hasAlpha: boolean;
  46465. /**
  46466. * Defines if the alpha value should be determined via the rgb values.
  46467. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46468. */
  46469. getAlphaFromRGB: boolean;
  46470. /**
  46471. * Intensity or strength of the texture.
  46472. * It is commonly used by materials to fine tune the intensity of the texture
  46473. */
  46474. level: number;
  46475. /**
  46476. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46477. * This is part of the texture as textures usually maps to one uv set.
  46478. */
  46479. coordinatesIndex: number;
  46480. private _coordinatesMode;
  46481. /**
  46482. * How a texture is mapped.
  46483. *
  46484. * | Value | Type | Description |
  46485. * | ----- | ----------------------------------- | ----------- |
  46486. * | 0 | EXPLICIT_MODE | |
  46487. * | 1 | SPHERICAL_MODE | |
  46488. * | 2 | PLANAR_MODE | |
  46489. * | 3 | CUBIC_MODE | |
  46490. * | 4 | PROJECTION_MODE | |
  46491. * | 5 | SKYBOX_MODE | |
  46492. * | 6 | INVCUBIC_MODE | |
  46493. * | 7 | EQUIRECTANGULAR_MODE | |
  46494. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46495. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46496. */
  46497. coordinatesMode: number;
  46498. /**
  46499. * | Value | Type | Description |
  46500. * | ----- | ------------------ | ----------- |
  46501. * | 0 | CLAMP_ADDRESSMODE | |
  46502. * | 1 | WRAP_ADDRESSMODE | |
  46503. * | 2 | MIRROR_ADDRESSMODE | |
  46504. */
  46505. wrapU: number;
  46506. /**
  46507. * | Value | Type | Description |
  46508. * | ----- | ------------------ | ----------- |
  46509. * | 0 | CLAMP_ADDRESSMODE | |
  46510. * | 1 | WRAP_ADDRESSMODE | |
  46511. * | 2 | MIRROR_ADDRESSMODE | |
  46512. */
  46513. wrapV: number;
  46514. /**
  46515. * | Value | Type | Description |
  46516. * | ----- | ------------------ | ----------- |
  46517. * | 0 | CLAMP_ADDRESSMODE | |
  46518. * | 1 | WRAP_ADDRESSMODE | |
  46519. * | 2 | MIRROR_ADDRESSMODE | |
  46520. */
  46521. wrapR: number;
  46522. /**
  46523. * With compliant hardware and browser (supporting anisotropic filtering)
  46524. * this defines the level of anisotropic filtering in the texture.
  46525. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46526. */
  46527. anisotropicFilteringLevel: number;
  46528. /**
  46529. * Define if the texture is a cube texture or if false a 2d texture.
  46530. */
  46531. isCube: boolean;
  46532. /**
  46533. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46534. */
  46535. is3D: boolean;
  46536. /**
  46537. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46538. * HDR texture are usually stored in linear space.
  46539. * This only impacts the PBR and Background materials
  46540. */
  46541. gammaSpace: boolean;
  46542. /**
  46543. * Gets whether or not the texture contains RGBD data.
  46544. */
  46545. readonly isRGBD: boolean;
  46546. /**
  46547. * Is Z inverted in the texture (useful in a cube texture).
  46548. */
  46549. invertZ: boolean;
  46550. /**
  46551. * Are mip maps generated for this texture or not.
  46552. */
  46553. readonly noMipmap: boolean;
  46554. /**
  46555. * @hidden
  46556. */
  46557. lodLevelInAlpha: boolean;
  46558. /**
  46559. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46560. */
  46561. lodGenerationOffset: number;
  46562. /**
  46563. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46564. */
  46565. lodGenerationScale: number;
  46566. /**
  46567. * Define if the texture is a render target.
  46568. */
  46569. isRenderTarget: boolean;
  46570. /**
  46571. * Define the unique id of the texture in the scene.
  46572. */
  46573. readonly uid: string;
  46574. /**
  46575. * Return a string representation of the texture.
  46576. * @returns the texture as a string
  46577. */
  46578. toString(): string;
  46579. /**
  46580. * Get the class name of the texture.
  46581. * @returns "BaseTexture"
  46582. */
  46583. getClassName(): string;
  46584. /**
  46585. * Define the list of animation attached to the texture.
  46586. */
  46587. animations: Animation[];
  46588. /**
  46589. * An event triggered when the texture is disposed.
  46590. */
  46591. onDisposeObservable: Observable<BaseTexture>;
  46592. private _onDisposeObserver;
  46593. /**
  46594. * Callback triggered when the texture has been disposed.
  46595. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46596. */
  46597. onDispose: () => void;
  46598. /**
  46599. * Define the current state of the loading sequence when in delayed load mode.
  46600. */
  46601. delayLoadState: number;
  46602. private _scene;
  46603. /** @hidden */
  46604. _texture: Nullable<InternalTexture>;
  46605. private _uid;
  46606. /**
  46607. * Define if the texture is preventinga material to render or not.
  46608. * If not and the texture is not ready, the engine will use a default black texture instead.
  46609. */
  46610. readonly isBlocking: boolean;
  46611. /**
  46612. * Instantiates a new BaseTexture.
  46613. * Base class of all the textures in babylon.
  46614. * It groups all the common properties the materials, post process, lights... might need
  46615. * in order to make a correct use of the texture.
  46616. * @param scene Define the scene the texture blongs to
  46617. */
  46618. constructor(scene: Nullable<Scene>);
  46619. /**
  46620. * Get the scene the texture belongs to.
  46621. * @returns the scene or null if undefined
  46622. */
  46623. getScene(): Nullable<Scene>;
  46624. /**
  46625. * Get the texture transform matrix used to offset tile the texture for istance.
  46626. * @returns the transformation matrix
  46627. */
  46628. getTextureMatrix(): Matrix;
  46629. /**
  46630. * Get the texture reflection matrix used to rotate/transform the reflection.
  46631. * @returns the reflection matrix
  46632. */
  46633. getReflectionTextureMatrix(): Matrix;
  46634. /**
  46635. * Get the underlying lower level texture from Babylon.
  46636. * @returns the insternal texture
  46637. */
  46638. getInternalTexture(): Nullable<InternalTexture>;
  46639. /**
  46640. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46641. * @returns true if ready or not blocking
  46642. */
  46643. isReadyOrNotBlocking(): boolean;
  46644. /**
  46645. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46646. * @returns true if fully ready
  46647. */
  46648. isReady(): boolean;
  46649. private _cachedSize;
  46650. /**
  46651. * Get the size of the texture.
  46652. * @returns the texture size.
  46653. */
  46654. getSize(): ISize;
  46655. /**
  46656. * Get the base size of the texture.
  46657. * It can be different from the size if the texture has been resized for POT for instance
  46658. * @returns the base size
  46659. */
  46660. getBaseSize(): ISize;
  46661. /**
  46662. * Update the sampling mode of the texture.
  46663. * Default is Trilinear mode.
  46664. *
  46665. * | Value | Type | Description |
  46666. * | ----- | ------------------ | ----------- |
  46667. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46668. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46669. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46670. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46671. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46672. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46673. * | 7 | NEAREST_LINEAR | |
  46674. * | 8 | NEAREST_NEAREST | |
  46675. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46676. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46677. * | 11 | LINEAR_LINEAR | |
  46678. * | 12 | LINEAR_NEAREST | |
  46679. *
  46680. * > _mag_: magnification filter (close to the viewer)
  46681. * > _min_: minification filter (far from the viewer)
  46682. * > _mip_: filter used between mip map levels
  46683. *@param samplingMode Define the new sampling mode of the texture
  46684. */
  46685. updateSamplingMode(samplingMode: number): void;
  46686. /**
  46687. * Scales the texture if is `canRescale()`
  46688. * @param ratio the resize factor we want to use to rescale
  46689. */
  46690. scale(ratio: number): void;
  46691. /**
  46692. * Get if the texture can rescale.
  46693. */
  46694. readonly canRescale: boolean;
  46695. /** @hidden */
  46696. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46697. /** @hidden */
  46698. _rebuild(): void;
  46699. /**
  46700. * Triggers the load sequence in delayed load mode.
  46701. */
  46702. delayLoad(): void;
  46703. /**
  46704. * Clones the texture.
  46705. * @returns the cloned texture
  46706. */
  46707. clone(): Nullable<BaseTexture>;
  46708. /**
  46709. * Get the texture underlying type (INT, FLOAT...)
  46710. */
  46711. readonly textureType: number;
  46712. /**
  46713. * Get the texture underlying format (RGB, RGBA...)
  46714. */
  46715. readonly textureFormat: number;
  46716. /**
  46717. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46718. * This will returns an RGBA array buffer containing either in values (0-255) or
  46719. * float values (0-1) depending of the underlying buffer type.
  46720. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46721. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46722. * @param buffer defines a user defined buffer to fill with data (can be null)
  46723. * @returns The Array buffer containing the pixels data.
  46724. */
  46725. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46726. /**
  46727. * Release and destroy the underlying lower level texture aka internalTexture.
  46728. */
  46729. releaseInternalTexture(): void;
  46730. /**
  46731. * Get the polynomial representation of the texture data.
  46732. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46733. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46734. */
  46735. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46736. /** @hidden */
  46737. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46738. /** @hidden */
  46739. readonly _lodTextureMid: Nullable<BaseTexture>;
  46740. /** @hidden */
  46741. readonly _lodTextureLow: Nullable<BaseTexture>;
  46742. /**
  46743. * Dispose the texture and release its associated resources.
  46744. */
  46745. dispose(): void;
  46746. /**
  46747. * Serialize the texture into a JSON representation that can be parsed later on.
  46748. * @returns the JSON representation of the texture
  46749. */
  46750. serialize(): any;
  46751. /**
  46752. * Helper function to be called back once a list of texture contains only ready textures.
  46753. * @param textures Define the list of textures to wait for
  46754. * @param callback Define the callback triggered once the entire list will be ready
  46755. */
  46756. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46757. }
  46758. }
  46759. declare module BABYLON {
  46760. /**
  46761. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46762. * It can help converting any input color in a desired output one. This can then be used to create effects
  46763. * from sepia, black and white to sixties or futuristic rendering...
  46764. *
  46765. * The only supported format is currently 3dl.
  46766. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46767. */
  46768. class ColorGradingTexture extends BaseTexture {
  46769. /**
  46770. * The current texture matrix. (will always be identity in color grading texture)
  46771. */
  46772. private _textureMatrix;
  46773. /**
  46774. * The texture URL.
  46775. */
  46776. url: string;
  46777. /**
  46778. * Empty line regex stored for GC.
  46779. */
  46780. private static _noneEmptyLineRegex;
  46781. private _engine;
  46782. /**
  46783. * Instantiates a ColorGradingTexture from the following parameters.
  46784. *
  46785. * @param url The location of the color gradind data (currently only supporting 3dl)
  46786. * @param scene The scene the texture will be used in
  46787. */
  46788. constructor(url: string, scene: Scene);
  46789. /**
  46790. * Returns the texture matrix used in most of the material.
  46791. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46792. */
  46793. getTextureMatrix(): Matrix;
  46794. /**
  46795. * Occurs when the file being loaded is a .3dl LUT file.
  46796. */
  46797. private load3dlTexture;
  46798. /**
  46799. * Starts the loading process of the texture.
  46800. */
  46801. private loadTexture;
  46802. /**
  46803. * Clones the color gradind texture.
  46804. */
  46805. clone(): ColorGradingTexture;
  46806. /**
  46807. * Called during delayed load for textures.
  46808. */
  46809. delayLoad(): void;
  46810. /**
  46811. * Parses a color grading texture serialized by Babylon.
  46812. * @param parsedTexture The texture information being parsedTexture
  46813. * @param scene The scene to load the texture in
  46814. * @param rootUrl The root url of the data assets to load
  46815. * @return A color gradind texture
  46816. */
  46817. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46818. /**
  46819. * Serializes the LUT texture to json format.
  46820. */
  46821. serialize(): any;
  46822. }
  46823. }
  46824. declare module BABYLON {
  46825. /**
  46826. * Class for creating a cube texture
  46827. */
  46828. class CubeTexture extends BaseTexture {
  46829. private _delayedOnLoad;
  46830. /**
  46831. * The url of the texture
  46832. */
  46833. url: string;
  46834. /**
  46835. * Gets or sets the center of the bounding box associated with the cube texture.
  46836. * It must define where the camera used to render the texture was set
  46837. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46838. */
  46839. boundingBoxPosition: Vector3;
  46840. private _boundingBoxSize;
  46841. /**
  46842. * Gets or sets the size of the bounding box associated with the cube texture
  46843. * When defined, the cubemap will switch to local mode
  46844. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46845. * @example https://www.babylonjs-playground.com/#RNASML
  46846. */
  46847. /**
  46848. * Returns the bounding box size
  46849. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46850. */
  46851. boundingBoxSize: Vector3;
  46852. protected _rotationY: number;
  46853. /**
  46854. * Sets texture matrix rotation angle around Y axis in radians.
  46855. */
  46856. /**
  46857. * Gets texture matrix rotation angle around Y axis radians.
  46858. */
  46859. rotationY: number;
  46860. /**
  46861. * Are mip maps generated for this texture or not.
  46862. */
  46863. readonly noMipmap: boolean;
  46864. private _noMipmap;
  46865. private _files;
  46866. private _extensions;
  46867. private _textureMatrix;
  46868. private _format;
  46869. private _createPolynomials;
  46870. /** @hidden */
  46871. _prefiltered: boolean;
  46872. /**
  46873. * Creates a cube texture from an array of image urls
  46874. * @param files defines an array of image urls
  46875. * @param scene defines the hosting scene
  46876. * @param noMipmap specifies if mip maps are not used
  46877. * @returns a cube texture
  46878. */
  46879. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46880. /**
  46881. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46882. * @param url defines the url of the prefiltered texture
  46883. * @param scene defines the scene the texture is attached to
  46884. * @param forcedExtension defines the extension of the file if different from the url
  46885. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46886. * @return the prefiltered texture
  46887. */
  46888. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46889. /**
  46890. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46891. * as prefiltered data.
  46892. * @param rootUrl defines the url of the texture or the root name of the six images
  46893. * @param scene defines the scene the texture is attached to
  46894. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46895. * @param noMipmap defines if mipmaps should be created or not
  46896. * @param files defines the six files to load for the different faces
  46897. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46898. * @param onError defines a callback triggered in case of error during load
  46899. * @param format defines the internal format to use for the texture once loaded
  46900. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46901. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46902. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46903. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46904. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46905. * @return the cube texture
  46906. */
  46907. 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);
  46908. /**
  46909. * Get the current class name of the texture useful for serialization or dynamic coding.
  46910. * @returns "CubeTexture"
  46911. */
  46912. getClassName(): string;
  46913. /**
  46914. * Update the url (and optional buffer) of this texture if url was null during construction.
  46915. * @param url the url of the texture
  46916. * @param forcedExtension defines the extension to use
  46917. * @param onLoad callback called when the texture is loaded (defaults to null)
  46918. */
  46919. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46920. /**
  46921. * Delays loading of the cube texture
  46922. * @param forcedExtension defines the extension to use
  46923. */
  46924. delayLoad(forcedExtension?: string): void;
  46925. /**
  46926. * Returns the reflection texture matrix
  46927. * @returns the reflection texture matrix
  46928. */
  46929. getReflectionTextureMatrix(): Matrix;
  46930. /**
  46931. * Sets the reflection texture matrix
  46932. * @param value Reflection texture matrix
  46933. */
  46934. setReflectionTextureMatrix(value: Matrix): void;
  46935. /**
  46936. * Parses text to create a cube texture
  46937. * @param parsedTexture define the serialized text to read from
  46938. * @param scene defines the hosting scene
  46939. * @param rootUrl defines the root url of the cube texture
  46940. * @returns a cube texture
  46941. */
  46942. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46943. /**
  46944. * Makes a clone, or deep copy, of the cube texture
  46945. * @returns a new cube texture
  46946. */
  46947. clone(): CubeTexture;
  46948. }
  46949. }
  46950. declare module BABYLON {
  46951. /**
  46952. * A class extending Texture allowing drawing on a texture
  46953. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46954. */
  46955. class DynamicTexture extends Texture {
  46956. private _generateMipMaps;
  46957. private _canvas;
  46958. private _context;
  46959. private _engine;
  46960. /**
  46961. * Creates a DynamicTexture
  46962. * @param name defines the name of the texture
  46963. * @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
  46964. * @param scene defines the scene where you want the texture
  46965. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46966. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46967. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46968. */
  46969. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46970. /**
  46971. * Get the current class name of the texture useful for serialization or dynamic coding.
  46972. * @returns "DynamicTexture"
  46973. */
  46974. getClassName(): string;
  46975. /**
  46976. * Gets the current state of canRescale
  46977. */
  46978. readonly canRescale: boolean;
  46979. private _recreate;
  46980. /**
  46981. * Scales the texture
  46982. * @param ratio the scale factor to apply to both width and height
  46983. */
  46984. scale(ratio: number): void;
  46985. /**
  46986. * Resizes the texture
  46987. * @param width the new width
  46988. * @param height the new height
  46989. */
  46990. scaleTo(width: number, height: number): void;
  46991. /**
  46992. * Gets the context of the canvas used by the texture
  46993. * @returns the canvas context of the dynamic texture
  46994. */
  46995. getContext(): CanvasRenderingContext2D;
  46996. /**
  46997. * Clears the texture
  46998. */
  46999. clear(): void;
  47000. /**
  47001. * Updates the texture
  47002. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47003. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47004. */
  47005. update(invertY?: boolean, premulAlpha?: boolean): void;
  47006. /**
  47007. * Draws text onto the texture
  47008. * @param text defines the text to be drawn
  47009. * @param x defines the placement of the text from the left
  47010. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47011. * @param font defines the font to be used with font-style, font-size, font-name
  47012. * @param color defines the color used for the text
  47013. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47014. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47015. * @param update defines whether texture is immediately update (default is true)
  47016. */
  47017. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  47018. /**
  47019. * Clones the texture
  47020. * @returns the clone of the texture.
  47021. */
  47022. clone(): DynamicTexture;
  47023. /**
  47024. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47025. * @returns a serialized dynamic texture object
  47026. */
  47027. serialize(): any;
  47028. /** @hidden */
  47029. _rebuild(): void;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /**
  47034. * This represents a texture coming from an HDR input.
  47035. *
  47036. * The only supported format is currently panorama picture stored in RGBE format.
  47037. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47038. */
  47039. class HDRCubeTexture extends BaseTexture {
  47040. private static _facesMapping;
  47041. private _generateHarmonics;
  47042. private _noMipmap;
  47043. private _textureMatrix;
  47044. private _size;
  47045. private _onLoad;
  47046. private _onError;
  47047. /**
  47048. * The texture URL.
  47049. */
  47050. url: string;
  47051. /**
  47052. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47053. */
  47054. coordinatesMode: number;
  47055. protected _isBlocking: boolean;
  47056. /**
  47057. * Sets wether or not the texture is blocking during loading.
  47058. */
  47059. /**
  47060. * Gets wether or not the texture is blocking during loading.
  47061. */
  47062. isBlocking: boolean;
  47063. protected _rotationY: number;
  47064. /**
  47065. * Sets texture matrix rotation angle around Y axis in radians.
  47066. */
  47067. /**
  47068. * Gets texture matrix rotation angle around Y axis radians.
  47069. */
  47070. rotationY: number;
  47071. /**
  47072. * Gets or sets the center of the bounding box associated with the cube texture
  47073. * It must define where the camera used to render the texture was set
  47074. */
  47075. boundingBoxPosition: Vector3;
  47076. private _boundingBoxSize;
  47077. /**
  47078. * Gets or sets the size of the bounding box associated with the cube texture
  47079. * When defined, the cubemap will switch to local mode
  47080. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47081. * @example https://www.babylonjs-playground.com/#RNASML
  47082. */
  47083. boundingBoxSize: Vector3;
  47084. /**
  47085. * Instantiates an HDRTexture from the following parameters.
  47086. *
  47087. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47088. * @param scene The scene the texture will be used in
  47089. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47090. * @param noMipmap Forces to not generate the mipmap if true
  47091. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47092. * @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)
  47093. * @param reserved Reserved flag for internal use.
  47094. */
  47095. 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>);
  47096. /**
  47097. * Get the current class name of the texture useful for serialization or dynamic coding.
  47098. * @returns "HDRCubeTexture"
  47099. */
  47100. getClassName(): string;
  47101. /**
  47102. * Occurs when the file is raw .hdr file.
  47103. */
  47104. private loadTexture;
  47105. clone(): HDRCubeTexture;
  47106. delayLoad(): void;
  47107. /**
  47108. * Get the texture reflection matrix used to rotate/transform the reflection.
  47109. * @returns the reflection matrix
  47110. */
  47111. getReflectionTextureMatrix(): Matrix;
  47112. /**
  47113. * Set the texture reflection matrix used to rotate/transform the reflection.
  47114. * @param value Define the reflection matrix to set
  47115. */
  47116. setReflectionTextureMatrix(value: Matrix): void;
  47117. /**
  47118. * Parses a JSON representation of an HDR Texture in order to create the texture
  47119. * @param parsedTexture Define the JSON representation
  47120. * @param scene Define the scene the texture should be created in
  47121. * @param rootUrl Define the root url in case we need to load relative dependencies
  47122. * @returns the newly created texture after parsing
  47123. */
  47124. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47125. serialize(): any;
  47126. }
  47127. }
  47128. declare module BABYLON {
  47129. /**
  47130. * Class used to store data associated with WebGL texture data for the engine
  47131. * This class should not be used directly
  47132. */
  47133. class InternalTexture implements IInternalTextureTracker {
  47134. /**
  47135. * The source of the texture data is unknown
  47136. */
  47137. static DATASOURCE_UNKNOWN: number;
  47138. /**
  47139. * Texture data comes from an URL
  47140. */
  47141. static DATASOURCE_URL: number;
  47142. /**
  47143. * Texture data is only used for temporary storage
  47144. */
  47145. static DATASOURCE_TEMP: number;
  47146. /**
  47147. * Texture data comes from raw data (ArrayBuffer)
  47148. */
  47149. static DATASOURCE_RAW: number;
  47150. /**
  47151. * Texture content is dynamic (video or dynamic texture)
  47152. */
  47153. static DATASOURCE_DYNAMIC: number;
  47154. /**
  47155. * Texture content is generated by rendering to it
  47156. */
  47157. static DATASOURCE_RENDERTARGET: number;
  47158. /**
  47159. * Texture content is part of a multi render target process
  47160. */
  47161. static DATASOURCE_MULTIRENDERTARGET: number;
  47162. /**
  47163. * Texture data comes from a cube data file
  47164. */
  47165. static DATASOURCE_CUBE: number;
  47166. /**
  47167. * Texture data comes from a raw cube data
  47168. */
  47169. static DATASOURCE_CUBERAW: number;
  47170. /**
  47171. * Texture data come from a prefiltered cube data file
  47172. */
  47173. static DATASOURCE_CUBEPREFILTERED: number;
  47174. /**
  47175. * Texture content is raw 3D data
  47176. */
  47177. static DATASOURCE_RAW3D: number;
  47178. /**
  47179. * Texture content is a depth texture
  47180. */
  47181. static DATASOURCE_DEPTHTEXTURE: number;
  47182. /**
  47183. * Texture data comes from a raw cube data encoded with RGBD
  47184. */
  47185. static DATASOURCE_CUBERAW_RGBD: number;
  47186. /**
  47187. * Defines if the texture is ready
  47188. */
  47189. isReady: boolean;
  47190. /**
  47191. * Defines if the texture is a cube texture
  47192. */
  47193. isCube: boolean;
  47194. /**
  47195. * Defines if the texture contains 3D data
  47196. */
  47197. is3D: boolean;
  47198. /**
  47199. * Gets the URL used to load this texture
  47200. */
  47201. url: string;
  47202. /**
  47203. * Gets the sampling mode of the texture
  47204. */
  47205. samplingMode: number;
  47206. /**
  47207. * Gets a boolean indicating if the texture needs mipmaps generation
  47208. */
  47209. generateMipMaps: boolean;
  47210. /**
  47211. * Gets the number of samples used by the texture (WebGL2+ only)
  47212. */
  47213. samples: number;
  47214. /**
  47215. * Gets the type of the texture (int, float...)
  47216. */
  47217. type: number;
  47218. /**
  47219. * Gets the format of the texture (RGB, RGBA...)
  47220. */
  47221. format: number;
  47222. /**
  47223. * Observable called when the texture is loaded
  47224. */
  47225. onLoadedObservable: Observable<InternalTexture>;
  47226. /**
  47227. * Gets the width of the texture
  47228. */
  47229. width: number;
  47230. /**
  47231. * Gets the height of the texture
  47232. */
  47233. height: number;
  47234. /**
  47235. * Gets the depth of the texture
  47236. */
  47237. depth: number;
  47238. /**
  47239. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47240. */
  47241. baseWidth: number;
  47242. /**
  47243. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47244. */
  47245. baseHeight: number;
  47246. /**
  47247. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47248. */
  47249. baseDepth: number;
  47250. /**
  47251. * Gets a boolean indicating if the texture is inverted on Y axis
  47252. */
  47253. invertY: boolean;
  47254. /**
  47255. * Gets or set the previous tracker in the list
  47256. */
  47257. previous: Nullable<IInternalTextureTracker>;
  47258. /**
  47259. * Gets or set the next tracker in the list
  47260. */
  47261. next: Nullable<IInternalTextureTracker>;
  47262. /** @hidden */
  47263. _invertVScale: boolean;
  47264. /** @hidden */
  47265. _initialSlot: number;
  47266. /** @hidden */
  47267. _designatedSlot: number;
  47268. /** @hidden */
  47269. _dataSource: number;
  47270. /** @hidden */
  47271. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47272. /** @hidden */
  47273. _bufferView: Nullable<ArrayBufferView>;
  47274. /** @hidden */
  47275. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47276. /** @hidden */
  47277. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47278. /** @hidden */
  47279. _size: number;
  47280. /** @hidden */
  47281. _extension: string;
  47282. /** @hidden */
  47283. _files: Nullable<string[]>;
  47284. /** @hidden */
  47285. _workingCanvas: HTMLCanvasElement;
  47286. /** @hidden */
  47287. _workingContext: CanvasRenderingContext2D;
  47288. /** @hidden */
  47289. _framebuffer: Nullable<WebGLFramebuffer>;
  47290. /** @hidden */
  47291. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47292. /** @hidden */
  47293. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47294. /** @hidden */
  47295. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47296. /** @hidden */
  47297. _attachments: Nullable<number[]>;
  47298. /** @hidden */
  47299. _cachedCoordinatesMode: Nullable<number>;
  47300. /** @hidden */
  47301. _cachedWrapU: Nullable<number>;
  47302. /** @hidden */
  47303. _cachedWrapV: Nullable<number>;
  47304. /** @hidden */
  47305. _cachedWrapR: Nullable<number>;
  47306. /** @hidden */
  47307. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47308. /** @hidden */
  47309. _isDisabled: boolean;
  47310. /** @hidden */
  47311. _compression: Nullable<string>;
  47312. /** @hidden */
  47313. _generateStencilBuffer: boolean;
  47314. /** @hidden */
  47315. _generateDepthBuffer: boolean;
  47316. /** @hidden */
  47317. _comparisonFunction: number;
  47318. /** @hidden */
  47319. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47320. /** @hidden */
  47321. _lodGenerationScale: number;
  47322. /** @hidden */
  47323. _lodGenerationOffset: number;
  47324. /** @hidden */
  47325. _lodTextureHigh: BaseTexture;
  47326. /** @hidden */
  47327. _lodTextureMid: BaseTexture;
  47328. /** @hidden */
  47329. _lodTextureLow: BaseTexture;
  47330. /** @hidden */
  47331. _isRGBD: boolean;
  47332. /** @hidden */
  47333. _webGLTexture: Nullable<WebGLTexture>;
  47334. /** @hidden */
  47335. _references: number;
  47336. private _engine;
  47337. /**
  47338. * Gets the Engine the texture belongs to.
  47339. * @returns The babylon engine
  47340. */
  47341. getEngine(): Engine;
  47342. /**
  47343. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47344. */
  47345. readonly dataSource: number;
  47346. /**
  47347. * Creates a new InternalTexture
  47348. * @param engine defines the engine to use
  47349. * @param dataSource defines the type of data that will be used
  47350. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47351. */
  47352. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47353. /**
  47354. * Increments the number of references (ie. the number of Texture that point to it)
  47355. */
  47356. incrementReferences(): void;
  47357. /**
  47358. * Change the size of the texture (not the size of the content)
  47359. * @param width defines the new width
  47360. * @param height defines the new height
  47361. * @param depth defines the new depth (1 by default)
  47362. */
  47363. updateSize(width: int, height: int, depth?: int): void;
  47364. /** @hidden */
  47365. _rebuild(): void;
  47366. /** @hidden */
  47367. _swapAndDie(target: InternalTexture): void;
  47368. /**
  47369. * Dispose the current allocated resources
  47370. */
  47371. dispose(): void;
  47372. }
  47373. }
  47374. declare module BABYLON {
  47375. /**
  47376. * This represents the required contract to create a new type of texture loader.
  47377. */
  47378. interface IInternalTextureLoader {
  47379. /**
  47380. * Defines wether the loader supports cascade loading the different faces.
  47381. */
  47382. supportCascades: boolean;
  47383. /**
  47384. * This returns if the loader support the current file information.
  47385. * @param extension defines the file extension of the file being loaded
  47386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47387. * @param fallback defines the fallback internal texture if any
  47388. * @param isBase64 defines whether the texture is encoded as a base64
  47389. * @param isBuffer defines whether the texture data are stored as a buffer
  47390. * @returns true if the loader can load the specified file
  47391. */
  47392. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47393. /**
  47394. * Transform the url before loading if required.
  47395. * @param rootUrl the url of the texture
  47396. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47397. * @returns the transformed texture
  47398. */
  47399. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47400. /**
  47401. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47402. * @param rootUrl the url of the texture
  47403. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47404. * @returns the fallback texture
  47405. */
  47406. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47407. /**
  47408. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47409. * @param data contains the texture data
  47410. * @param texture defines the BabylonJS internal texture
  47411. * @param createPolynomials will be true if polynomials have been requested
  47412. * @param onLoad defines the callback to trigger once the texture is ready
  47413. * @param onError defines the callback to trigger in case of error
  47414. */
  47415. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47416. /**
  47417. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47418. * @param data contains the texture data
  47419. * @param texture defines the BabylonJS internal texture
  47420. * @param callback defines the method to call once ready to upload
  47421. */
  47422. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47423. }
  47424. }
  47425. declare module BABYLON {
  47426. /**
  47427. * Internal interface used to track InternalTexture already bound to the GL context
  47428. */
  47429. interface IInternalTextureTracker {
  47430. /**
  47431. * Gets or set the previous tracker in the list
  47432. */
  47433. previous: Nullable<IInternalTextureTracker>;
  47434. /**
  47435. * Gets or set the next tracker in the list
  47436. */
  47437. next: Nullable<IInternalTextureTracker>;
  47438. }
  47439. /**
  47440. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47441. */
  47442. class DummyInternalTextureTracker {
  47443. /**
  47444. * Gets or set the previous tracker in the list
  47445. */
  47446. previous: Nullable<IInternalTextureTracker>;
  47447. /**
  47448. * Gets or set the next tracker in the list
  47449. */
  47450. next: Nullable<IInternalTextureTracker>;
  47451. }
  47452. }
  47453. declare module BABYLON {
  47454. /**
  47455. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47456. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47457. * You can then easily use it as a reflectionTexture on a flat surface.
  47458. * In case the surface is not a plane, please consider relying on reflection probes.
  47459. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47460. */
  47461. class MirrorTexture extends RenderTargetTexture {
  47462. private scene;
  47463. /**
  47464. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47465. * 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.
  47466. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47467. */
  47468. mirrorPlane: Plane;
  47469. /**
  47470. * Define the blur ratio used to blur the reflection if needed.
  47471. */
  47472. blurRatio: number;
  47473. /**
  47474. * Define the adaptive blur kernel used to blur the reflection if needed.
  47475. * This will autocompute the closest best match for the `blurKernel`
  47476. */
  47477. adaptiveBlurKernel: number;
  47478. /**
  47479. * Define the blur kernel used to blur the reflection if needed.
  47480. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47481. */
  47482. blurKernel: number;
  47483. /**
  47484. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47485. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47486. */
  47487. blurKernelX: number;
  47488. /**
  47489. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47490. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47491. */
  47492. blurKernelY: number;
  47493. private _autoComputeBlurKernel;
  47494. protected _onRatioRescale(): void;
  47495. private _updateGammaSpace;
  47496. private _imageProcessingConfigChangeObserver;
  47497. private _transformMatrix;
  47498. private _mirrorMatrix;
  47499. private _savedViewMatrix;
  47500. private _blurX;
  47501. private _blurY;
  47502. private _adaptiveBlurKernel;
  47503. private _blurKernelX;
  47504. private _blurKernelY;
  47505. private _blurRatio;
  47506. /**
  47507. * Instantiates a Mirror Texture.
  47508. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47509. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47510. * You can then easily use it as a reflectionTexture on a flat surface.
  47511. * In case the surface is not a plane, please consider relying on reflection probes.
  47512. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47513. * @param name
  47514. * @param size
  47515. * @param scene
  47516. * @param generateMipMaps
  47517. * @param type
  47518. * @param samplingMode
  47519. * @param generateDepthBuffer
  47520. */
  47521. constructor(name: string, size: number | {
  47522. width: number;
  47523. height: number;
  47524. } | {
  47525. ratio: number;
  47526. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47527. private _preparePostProcesses;
  47528. /**
  47529. * Clone the mirror texture.
  47530. * @returns the cloned texture
  47531. */
  47532. clone(): MirrorTexture;
  47533. /**
  47534. * Serialize the texture to a JSON representation you could use in Parse later on
  47535. * @returns the serialized JSON representation
  47536. */
  47537. serialize(): any;
  47538. /**
  47539. * Dispose the texture and release its associated resources.
  47540. */
  47541. dispose(): void;
  47542. }
  47543. }
  47544. declare module BABYLON {
  47545. /**
  47546. * Creation options of the multi render target texture.
  47547. */
  47548. interface IMultiRenderTargetOptions {
  47549. /**
  47550. * Define if the texture needs to create mip maps after render.
  47551. */
  47552. generateMipMaps?: boolean;
  47553. /**
  47554. * Define the types of all the draw buffers we want to create
  47555. */
  47556. types?: number[];
  47557. /**
  47558. * Define the sampling modes of all the draw buffers we want to create
  47559. */
  47560. samplingModes?: number[];
  47561. /**
  47562. * Define if a depth buffer is required
  47563. */
  47564. generateDepthBuffer?: boolean;
  47565. /**
  47566. * Define if a stencil buffer is required
  47567. */
  47568. generateStencilBuffer?: boolean;
  47569. /**
  47570. * Define if a depth texture is required instead of a depth buffer
  47571. */
  47572. generateDepthTexture?: boolean;
  47573. /**
  47574. * Define the number of desired draw buffers
  47575. */
  47576. textureCount?: number;
  47577. /**
  47578. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47579. */
  47580. doNotChangeAspectRatio?: boolean;
  47581. /**
  47582. * Define the default type of the buffers we are creating
  47583. */
  47584. defaultType?: number;
  47585. }
  47586. /**
  47587. * A multi render target, like a render target provides the ability to render to a texture.
  47588. * Unlike the render target, it can render to several draw buffers in one draw.
  47589. * This is specially interesting in deferred rendering or for any effects requiring more than
  47590. * just one color from a single pass.
  47591. */
  47592. class MultiRenderTarget extends RenderTargetTexture {
  47593. private _internalTextures;
  47594. private _textures;
  47595. private _multiRenderTargetOptions;
  47596. /**
  47597. * Get if draw buffers are currently supported by the used hardware and browser.
  47598. */
  47599. readonly isSupported: boolean;
  47600. /**
  47601. * Get the list of textures generated by the multi render target.
  47602. */
  47603. readonly textures: Texture[];
  47604. /**
  47605. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47606. */
  47607. readonly depthTexture: Texture;
  47608. /**
  47609. * Set the wrapping mode on U of all the textures we are rendering to.
  47610. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47611. */
  47612. wrapU: number;
  47613. /**
  47614. * Set the wrapping mode on V of all the textures we are rendering to.
  47615. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47616. */
  47617. wrapV: number;
  47618. /**
  47619. * Instantiate a new multi render target texture.
  47620. * A multi render target, like a render target provides the ability to render to a texture.
  47621. * Unlike the render target, it can render to several draw buffers in one draw.
  47622. * This is specially interesting in deferred rendering or for any effects requiring more than
  47623. * just one color from a single pass.
  47624. * @param name Define the name of the texture
  47625. * @param size Define the size of the buffers to render to
  47626. * @param count Define the number of target we are rendering into
  47627. * @param scene Define the scene the texture belongs to
  47628. * @param options Define the options used to create the multi render target
  47629. */
  47630. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47631. /** @hidden */
  47632. _rebuild(): void;
  47633. private _createInternalTextures;
  47634. private _createTextures;
  47635. /**
  47636. * Define the number of samples used if MSAA is enabled.
  47637. */
  47638. samples: number;
  47639. /**
  47640. * Resize all the textures in the multi render target.
  47641. * Be carrefull as it will recreate all the data in the new texture.
  47642. * @param size Define the new size
  47643. */
  47644. resize(size: any): void;
  47645. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47646. /**
  47647. * Dispose the render targets and their associated resources
  47648. */
  47649. dispose(): void;
  47650. /**
  47651. * Release all the underlying texture used as draw buffers.
  47652. */
  47653. releaseInternalTextures(): void;
  47654. }
  47655. }
  47656. declare module BABYLON {
  47657. /**
  47658. * Raw cube texture where the raw buffers are passed in
  47659. */
  47660. class RawCubeTexture extends CubeTexture {
  47661. /**
  47662. * Creates a cube texture where the raw buffers are passed in.
  47663. * @param scene defines the scene the texture is attached to
  47664. * @param data defines the array of data to use to create each face
  47665. * @param size defines the size of the textures
  47666. * @param format defines the format of the data
  47667. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47668. * @param generateMipMaps defines if the engine should generate the mip levels
  47669. * @param invertY defines if data must be stored with Y axis inverted
  47670. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47671. * @param compression defines the compression used (null by default)
  47672. */
  47673. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47674. /**
  47675. * Updates the raw cube texture.
  47676. * @param data defines the data to store
  47677. * @param format defines the data format
  47678. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47679. * @param invertY defines if data must be stored with Y axis inverted
  47680. * @param compression defines the compression used (null by default)
  47681. * @param level defines which level of the texture to update
  47682. */
  47683. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47684. /**
  47685. * Updates a raw cube texture with RGBD encoded data.
  47686. * @param data defines the array of data [mipmap][face] to use to create each face
  47687. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47688. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47689. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47690. * @returns a promsie that resolves when the operation is complete
  47691. */
  47692. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47693. /**
  47694. * Clones the raw cube texture.
  47695. * @return a new cube texture
  47696. */
  47697. clone(): CubeTexture;
  47698. /** @hidden */
  47699. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47700. }
  47701. }
  47702. declare module BABYLON {
  47703. /**
  47704. * Raw texture can help creating a texture directly from an array of data.
  47705. * This can be super useful if you either get the data from an uncompressed source or
  47706. * if you wish to create your texture pixel by pixel.
  47707. */
  47708. class RawTexture extends Texture {
  47709. /**
  47710. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47711. */
  47712. format: number;
  47713. private _engine;
  47714. /**
  47715. * Instantiates a new RawTexture.
  47716. * Raw texture can help creating a texture directly from an array of data.
  47717. * This can be super useful if you either get the data from an uncompressed source or
  47718. * if you wish to create your texture pixel by pixel.
  47719. * @param data define the array of data to use to create the texture
  47720. * @param width define the width of the texture
  47721. * @param height define the height of the texture
  47722. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47723. * @param scene define the scene the texture belongs to
  47724. * @param generateMipMaps define whether mip maps should be generated or not
  47725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47727. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47728. */
  47729. constructor(data: ArrayBufferView, width: number, height: number,
  47730. /**
  47731. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47732. */
  47733. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47734. /**
  47735. * Updates the texture underlying data.
  47736. * @param data Define the new data of the texture
  47737. */
  47738. update(data: ArrayBufferView): void;
  47739. /**
  47740. * Creates a luminance texture from some data.
  47741. * @param data Define the texture data
  47742. * @param width Define the width of the texture
  47743. * @param height Define the height of the texture
  47744. * @param scene Define the scene the texture belongs to
  47745. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47748. * @returns the luminance texture
  47749. */
  47750. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47751. /**
  47752. * Creates a luminance alpha texture from some data.
  47753. * @param data Define the texture data
  47754. * @param width Define the width of the texture
  47755. * @param height Define the height of the texture
  47756. * @param scene Define the scene the texture belongs to
  47757. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47758. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47759. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47760. * @returns the luminance alpha texture
  47761. */
  47762. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47763. /**
  47764. * Creates an alpha texture from some data.
  47765. * @param data Define the texture data
  47766. * @param width Define the width of the texture
  47767. * @param height Define the height of the texture
  47768. * @param scene Define the scene the texture belongs to
  47769. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47770. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47771. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47772. * @returns the alpha texture
  47773. */
  47774. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47775. /**
  47776. * Creates a RGB texture from some data.
  47777. * @param data Define the texture data
  47778. * @param width Define the width of the texture
  47779. * @param height Define the height of the texture
  47780. * @param scene Define the scene the texture belongs to
  47781. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47782. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47783. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47784. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47785. * @returns the RGB alpha texture
  47786. */
  47787. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47788. /**
  47789. * Creates a RGBA texture from some data.
  47790. * @param data Define the texture data
  47791. * @param width Define the width of the texture
  47792. * @param height Define the height of the texture
  47793. * @param scene Define the scene the texture belongs to
  47794. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47798. * @returns the RGBA texture
  47799. */
  47800. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47801. /**
  47802. * Creates a R texture from some data.
  47803. * @param data Define the texture data
  47804. * @param width Define the width of the texture
  47805. * @param height Define the height of the texture
  47806. * @param scene Define the scene the texture belongs to
  47807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47811. * @returns the R texture
  47812. */
  47813. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47814. }
  47815. }
  47816. declare module BABYLON {
  47817. /**
  47818. * Class used to store 3D textures containing user data
  47819. */
  47820. class RawTexture3D extends Texture {
  47821. /** Gets or sets the texture format to use */
  47822. format: number;
  47823. private _engine;
  47824. /**
  47825. * Create a new RawTexture3D
  47826. * @param data defines the data of the texture
  47827. * @param width defines the width of the texture
  47828. * @param height defines the height of the texture
  47829. * @param depth defines the depth of the texture
  47830. * @param format defines the texture format to use
  47831. * @param scene defines the hosting scene
  47832. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47833. * @param invertY defines if texture must be stored with Y axis inverted
  47834. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47835. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47836. */
  47837. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47838. /** Gets or sets the texture format to use */
  47839. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47840. /**
  47841. * Update the texture with new data
  47842. * @param data defines the data to store in the texture
  47843. */
  47844. update(data: ArrayBufferView): void;
  47845. }
  47846. }
  47847. declare module BABYLON {
  47848. /**
  47849. * Creates a refraction texture used by refraction channel of the standard material.
  47850. * It is like a mirror but to see through a material.
  47851. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47852. */
  47853. class RefractionTexture extends RenderTargetTexture {
  47854. /**
  47855. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47856. * 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.
  47857. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47858. */
  47859. refractionPlane: Plane;
  47860. /**
  47861. * Define how deep under the surface we should see.
  47862. */
  47863. depth: number;
  47864. /**
  47865. * Creates a refraction texture used by refraction channel of the standard material.
  47866. * It is like a mirror but to see through a material.
  47867. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47868. * @param name Define the texture name
  47869. * @param size Define the size of the underlying texture
  47870. * @param scene Define the scene the refraction belongs to
  47871. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47872. */
  47873. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47874. /**
  47875. * Clone the refraction texture.
  47876. * @returns the cloned texture
  47877. */
  47878. clone(): RefractionTexture;
  47879. /**
  47880. * Serialize the texture to a JSON representation you could use in Parse later on
  47881. * @returns the serialized JSON representation
  47882. */
  47883. serialize(): any;
  47884. }
  47885. }
  47886. declare module BABYLON {
  47887. /**
  47888. * This Helps creating a texture that will be created from a camera in your scene.
  47889. * It is basically a dynamic texture that could be used to create special effects for instance.
  47890. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47891. */
  47892. class RenderTargetTexture extends Texture {
  47893. isCube: boolean;
  47894. /**
  47895. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47896. */
  47897. static readonly REFRESHRATE_RENDER_ONCE: number;
  47898. /**
  47899. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47900. */
  47901. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47902. /**
  47903. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47904. * the central point of your effect and can save a lot of performances.
  47905. */
  47906. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47907. /**
  47908. * Use this predicate to dynamically define the list of mesh you want to render.
  47909. * If set, the renderList property will be overwritten.
  47910. */
  47911. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47912. private _renderList;
  47913. /**
  47914. * Use this list to define the list of mesh you want to render.
  47915. */
  47916. renderList: Nullable<Array<AbstractMesh>>;
  47917. private _hookArray;
  47918. /**
  47919. * Define if particles should be rendered in your texture.
  47920. */
  47921. renderParticles: boolean;
  47922. /**
  47923. * Define if sprites should be rendered in your texture.
  47924. */
  47925. renderSprites: boolean;
  47926. /**
  47927. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47928. */
  47929. coordinatesMode: number;
  47930. /**
  47931. * Define the camera used to render the texture.
  47932. */
  47933. activeCamera: Nullable<Camera>;
  47934. /**
  47935. * Override the render function of the texture with your own one.
  47936. */
  47937. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47938. /**
  47939. * Define if camera post processes should be use while rendering the texture.
  47940. */
  47941. useCameraPostProcesses: boolean;
  47942. /**
  47943. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47944. */
  47945. ignoreCameraViewport: boolean;
  47946. private _postProcessManager;
  47947. private _postProcesses;
  47948. private _resizeObserver;
  47949. /**
  47950. * An event triggered when the texture is unbind.
  47951. */
  47952. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47953. /**
  47954. * An event triggered when the texture is unbind.
  47955. */
  47956. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47957. private _onAfterUnbindObserver;
  47958. /**
  47959. * Set a after unbind callback in the texture.
  47960. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47961. */
  47962. onAfterUnbind: () => void;
  47963. /**
  47964. * An event triggered before rendering the texture
  47965. */
  47966. onBeforeRenderObservable: Observable<number>;
  47967. private _onBeforeRenderObserver;
  47968. /**
  47969. * Set a before render callback in the texture.
  47970. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47971. */
  47972. onBeforeRender: (faceIndex: number) => void;
  47973. /**
  47974. * An event triggered after rendering the texture
  47975. */
  47976. onAfterRenderObservable: Observable<number>;
  47977. private _onAfterRenderObserver;
  47978. /**
  47979. * Set a after render callback in the texture.
  47980. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47981. */
  47982. onAfterRender: (faceIndex: number) => void;
  47983. /**
  47984. * An event triggered after the texture clear
  47985. */
  47986. onClearObservable: Observable<Engine>;
  47987. private _onClearObserver;
  47988. /**
  47989. * Set a clear callback in the texture.
  47990. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47991. */
  47992. onClear: (Engine: Engine) => void;
  47993. /**
  47994. * Define the clear color of the Render Target if it should be different from the scene.
  47995. */
  47996. clearColor: Color4;
  47997. protected _size: number | {
  47998. width: number;
  47999. height: number;
  48000. };
  48001. protected _initialSizeParameter: number | {
  48002. width: number;
  48003. height: number;
  48004. } | {
  48005. ratio: number;
  48006. };
  48007. protected _sizeRatio: Nullable<number>;
  48008. /** @hidden */
  48009. _generateMipMaps: boolean;
  48010. protected _renderingManager: RenderingManager;
  48011. /** @hidden */
  48012. _waitingRenderList: string[];
  48013. protected _doNotChangeAspectRatio: boolean;
  48014. protected _currentRefreshId: number;
  48015. protected _refreshRate: number;
  48016. protected _textureMatrix: Matrix;
  48017. protected _samples: number;
  48018. protected _renderTargetOptions: RenderTargetCreationOptions;
  48019. /**
  48020. * Gets render target creation options that were used.
  48021. */
  48022. readonly renderTargetOptions: RenderTargetCreationOptions;
  48023. protected _engine: Engine;
  48024. protected _onRatioRescale(): void;
  48025. /**
  48026. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  48027. * It must define where the camera used to render the texture is set
  48028. */
  48029. boundingBoxPosition: Vector3;
  48030. private _boundingBoxSize;
  48031. /**
  48032. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  48033. * When defined, the cubemap will switch to local mode
  48034. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48035. * @example https://www.babylonjs-playground.com/#RNASML
  48036. */
  48037. boundingBoxSize: Vector3;
  48038. /**
  48039. * In case the RTT has been created with a depth texture, get the associated
  48040. * depth texture.
  48041. * Otherwise, return null.
  48042. */
  48043. depthStencilTexture: Nullable<InternalTexture>;
  48044. /**
  48045. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  48046. * or used a shadow, depth texture...
  48047. * @param name The friendly name of the texture
  48048. * @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)
  48049. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  48050. * @param generateMipMaps True if mip maps need to be generated after render.
  48051. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  48052. * @param type The type of the buffer in the RTT (int, half float, float...)
  48053. * @param isCube True if a cube texture needs to be created
  48054. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  48055. * @param generateDepthBuffer True to generate a depth buffer
  48056. * @param generateStencilBuffer True to generate a stencil buffer
  48057. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  48058. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  48059. * @param delayAllocation if the texture allocation should be delayed (default: false)
  48060. */
  48061. constructor(name: string, size: number | {
  48062. width: number;
  48063. height: number;
  48064. } | {
  48065. ratio: number;
  48066. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  48067. /**
  48068. * Creates a depth stencil texture.
  48069. * This is only available in WebGL 2 or with the depth texture extension available.
  48070. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48071. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48072. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48073. */
  48074. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48075. private _processSizeParameter;
  48076. /**
  48077. * Define the number of samples to use in case of MSAA.
  48078. * It defaults to one meaning no MSAA has been enabled.
  48079. */
  48080. samples: number;
  48081. /**
  48082. * Resets the refresh counter of the texture and start bak from scratch.
  48083. * Could be useful to regenerate the texture if it is setup to render only once.
  48084. */
  48085. resetRefreshCounter(): void;
  48086. /**
  48087. * Define the refresh rate of the texture or the rendering frequency.
  48088. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48089. */
  48090. refreshRate: number;
  48091. /**
  48092. * Adds a post process to the render target rendering passes.
  48093. * @param postProcess define the post process to add
  48094. */
  48095. addPostProcess(postProcess: PostProcess): void;
  48096. /**
  48097. * Clear all the post processes attached to the render target
  48098. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48099. */
  48100. clearPostProcesses(dispose?: boolean): void;
  48101. /**
  48102. * Remove one of the post process from the list of attached post processes to the texture
  48103. * @param postProcess define the post process to remove from the list
  48104. */
  48105. removePostProcess(postProcess: PostProcess): void;
  48106. /** @hidden */
  48107. _shouldRender(): boolean;
  48108. /**
  48109. * Gets the actual render size of the texture.
  48110. * @returns the width of the render size
  48111. */
  48112. getRenderSize(): number;
  48113. /**
  48114. * Gets the actual render width of the texture.
  48115. * @returns the width of the render size
  48116. */
  48117. getRenderWidth(): number;
  48118. /**
  48119. * Gets the actual render height of the texture.
  48120. * @returns the height of the render size
  48121. */
  48122. getRenderHeight(): number;
  48123. /**
  48124. * Get if the texture can be rescaled or not.
  48125. */
  48126. readonly canRescale: boolean;
  48127. /**
  48128. * Resize the texture using a ratio.
  48129. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48130. */
  48131. scale(ratio: number): void;
  48132. /**
  48133. * Get the texture reflection matrix used to rotate/transform the reflection.
  48134. * @returns the reflection matrix
  48135. */
  48136. getReflectionTextureMatrix(): Matrix;
  48137. /**
  48138. * Resize the texture to a new desired size.
  48139. * Be carrefull as it will recreate all the data in the new texture.
  48140. * @param size Define the new size. It can be:
  48141. * - a number for squared texture,
  48142. * - an object containing { width: number, height: number }
  48143. * - or an object containing a ratio { ratio: number }
  48144. */
  48145. resize(size: number | {
  48146. width: number;
  48147. height: number;
  48148. } | {
  48149. ratio: number;
  48150. }): void;
  48151. /**
  48152. * Renders all the objects from the render list into the texture.
  48153. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48154. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48155. */
  48156. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48157. private _bestReflectionRenderTargetDimension;
  48158. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48159. private renderToTarget;
  48160. /**
  48161. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48162. * This allowed control for front to back rendering or reversly depending of the special needs.
  48163. *
  48164. * @param renderingGroupId The rendering group id corresponding to its index
  48165. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48166. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48167. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48168. */
  48169. 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;
  48170. /**
  48171. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48172. *
  48173. * @param renderingGroupId The rendering group id corresponding to its index
  48174. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48175. */
  48176. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48177. /**
  48178. * Clones the texture.
  48179. * @returns the cloned texture
  48180. */
  48181. clone(): RenderTargetTexture;
  48182. /**
  48183. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48184. * @returns The JSON representation of the texture
  48185. */
  48186. serialize(): any;
  48187. /**
  48188. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48189. */
  48190. disposeFramebufferObjects(): void;
  48191. /**
  48192. * Dispose the texture and release its associated resources.
  48193. */
  48194. dispose(): void;
  48195. /** @hidden */
  48196. _rebuild(): void;
  48197. /**
  48198. * Clear the info related to rendering groups preventing retention point in material dispose.
  48199. */
  48200. freeRenderingGroups(): void;
  48201. }
  48202. }
  48203. declare module BABYLON {
  48204. /**
  48205. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48206. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48207. */
  48208. class Texture extends BaseTexture {
  48209. /** nearest is mag = nearest and min = nearest and mip = linear */
  48210. static readonly NEAREST_SAMPLINGMODE: number;
  48211. /** nearest is mag = nearest and min = nearest and mip = linear */
  48212. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48213. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48214. static readonly BILINEAR_SAMPLINGMODE: number;
  48215. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48216. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48217. /** Trilinear is mag = linear and min = linear and mip = linear */
  48218. static readonly TRILINEAR_SAMPLINGMODE: number;
  48219. /** Trilinear is mag = linear and min = linear and mip = linear */
  48220. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48221. /** mag = nearest and min = nearest and mip = nearest */
  48222. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48223. /** mag = nearest and min = linear and mip = nearest */
  48224. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48225. /** mag = nearest and min = linear and mip = linear */
  48226. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48227. /** mag = nearest and min = linear and mip = none */
  48228. static readonly NEAREST_LINEAR: number;
  48229. /** mag = nearest and min = nearest and mip = none */
  48230. static readonly NEAREST_NEAREST: number;
  48231. /** mag = linear and min = nearest and mip = nearest */
  48232. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48233. /** mag = linear and min = nearest and mip = linear */
  48234. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48235. /** mag = linear and min = linear and mip = none */
  48236. static readonly LINEAR_LINEAR: number;
  48237. /** mag = linear and min = nearest and mip = none */
  48238. static readonly LINEAR_NEAREST: number;
  48239. /** Explicit coordinates mode */
  48240. static readonly EXPLICIT_MODE: number;
  48241. /** Spherical coordinates mode */
  48242. static readonly SPHERICAL_MODE: number;
  48243. /** Planar coordinates mode */
  48244. static readonly PLANAR_MODE: number;
  48245. /** Cubic coordinates mode */
  48246. static readonly CUBIC_MODE: number;
  48247. /** Projection coordinates mode */
  48248. static readonly PROJECTION_MODE: number;
  48249. /** Inverse Cubic coordinates mode */
  48250. static readonly SKYBOX_MODE: number;
  48251. /** Inverse Cubic coordinates mode */
  48252. static readonly INVCUBIC_MODE: number;
  48253. /** Equirectangular coordinates mode */
  48254. static readonly EQUIRECTANGULAR_MODE: number;
  48255. /** Equirectangular Fixed coordinates mode */
  48256. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48257. /** Equirectangular Fixed Mirrored coordinates mode */
  48258. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48259. /** Texture is not repeating outside of 0..1 UVs */
  48260. static readonly CLAMP_ADDRESSMODE: number;
  48261. /** Texture is repeating outside of 0..1 UVs */
  48262. static readonly WRAP_ADDRESSMODE: number;
  48263. /** Texture is repeating and mirrored */
  48264. static readonly MIRROR_ADDRESSMODE: number;
  48265. /**
  48266. * 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
  48267. */
  48268. static UseSerializedUrlIfAny: boolean;
  48269. /**
  48270. * Define the url of the texture.
  48271. */
  48272. url: Nullable<string>;
  48273. /**
  48274. * Define an offset on the texture to offset the u coordinates of the UVs
  48275. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48276. */
  48277. uOffset: number;
  48278. /**
  48279. * Define an offset on the texture to offset the v coordinates of the UVs
  48280. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48281. */
  48282. vOffset: number;
  48283. /**
  48284. * Define an offset on the texture to scale the u coordinates of the UVs
  48285. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48286. */
  48287. uScale: number;
  48288. /**
  48289. * Define an offset on the texture to scale the v coordinates of the UVs
  48290. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48291. */
  48292. vScale: number;
  48293. /**
  48294. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48295. * @see http://doc.babylonjs.com/how_to/more_materials
  48296. */
  48297. uAng: number;
  48298. /**
  48299. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48300. * @see http://doc.babylonjs.com/how_to/more_materials
  48301. */
  48302. vAng: number;
  48303. /**
  48304. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48305. * @see http://doc.babylonjs.com/how_to/more_materials
  48306. */
  48307. wAng: number;
  48308. /**
  48309. * Defines the center of rotation (U)
  48310. */
  48311. uRotationCenter: number;
  48312. /**
  48313. * Defines the center of rotation (V)
  48314. */
  48315. vRotationCenter: number;
  48316. /**
  48317. * Defines the center of rotation (W)
  48318. */
  48319. wRotationCenter: number;
  48320. /**
  48321. * Are mip maps generated for this texture or not.
  48322. */
  48323. readonly noMipmap: boolean;
  48324. private _noMipmap;
  48325. /** @hidden */
  48326. _invertY: boolean;
  48327. private _rowGenerationMatrix;
  48328. private _cachedTextureMatrix;
  48329. private _projectionModeMatrix;
  48330. private _t0;
  48331. private _t1;
  48332. private _t2;
  48333. private _cachedUOffset;
  48334. private _cachedVOffset;
  48335. private _cachedUScale;
  48336. private _cachedVScale;
  48337. private _cachedUAng;
  48338. private _cachedVAng;
  48339. private _cachedWAng;
  48340. private _cachedProjectionMatrixId;
  48341. private _cachedCoordinatesMode;
  48342. /** @hidden */
  48343. protected _initialSamplingMode: number;
  48344. /** @hidden */
  48345. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48346. private _deleteBuffer;
  48347. protected _format: Nullable<number>;
  48348. private _delayedOnLoad;
  48349. private _delayedOnError;
  48350. /**
  48351. * Observable triggered once the texture has been loaded.
  48352. */
  48353. onLoadObservable: Observable<Texture>;
  48354. protected _isBlocking: boolean;
  48355. /**
  48356. * Is the texture preventing material to render while loading.
  48357. * If false, a default texture will be used instead of the loading one during the preparation step.
  48358. */
  48359. isBlocking: boolean;
  48360. /**
  48361. * Get the current sampling mode associated with the texture.
  48362. */
  48363. readonly samplingMode: number;
  48364. /**
  48365. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48366. */
  48367. readonly invertY: boolean;
  48368. /**
  48369. * Instantiates a new texture.
  48370. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48371. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48372. * @param url define the url of the picture to load as a texture
  48373. * @param scene define the scene the texture will belong to
  48374. * @param noMipmap define if the texture will require mip maps or not
  48375. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48376. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48377. * @param onLoad define a callback triggered when the texture has been loaded
  48378. * @param onError define a callback triggered when an error occurred during the loading session
  48379. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48380. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48381. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48382. */
  48383. 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);
  48384. /**
  48385. * Update the url (and optional buffer) of this texture if url was null during construction.
  48386. * @param url the url of the texture
  48387. * @param buffer the buffer of the texture (defaults to null)
  48388. * @param onLoad callback called when the texture is loaded (defaults to null)
  48389. */
  48390. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48391. /**
  48392. * Finish the loading sequence of a texture flagged as delayed load.
  48393. * @hidden
  48394. */
  48395. delayLoad(): void;
  48396. private _prepareRowForTextureGeneration;
  48397. /**
  48398. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48399. * @returns the transform matrix of the texture.
  48400. */
  48401. getTextureMatrix(): Matrix;
  48402. /**
  48403. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48404. * @returns The reflection texture transform
  48405. */
  48406. getReflectionTextureMatrix(): Matrix;
  48407. /**
  48408. * Clones the texture.
  48409. * @returns the cloned texture
  48410. */
  48411. clone(): Texture;
  48412. /**
  48413. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48414. * @returns The JSON representation of the texture
  48415. */
  48416. serialize(): any;
  48417. /**
  48418. * Get the current class name of the texture useful for serialization or dynamic coding.
  48419. * @returns "Texture"
  48420. */
  48421. getClassName(): string;
  48422. /**
  48423. * Dispose the texture and release its associated resources.
  48424. */
  48425. dispose(): void;
  48426. /**
  48427. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48428. * @param parsedTexture Define the JSON representation of the texture
  48429. * @param scene Define the scene the parsed texture should be instantiated in
  48430. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48431. * @returns The parsed texture if successful
  48432. */
  48433. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48434. /**
  48435. * Creates a texture from its base 64 representation.
  48436. * @param data Define the base64 payload without the data: prefix
  48437. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48438. * @param scene Define the scene the texture should belong to
  48439. * @param noMipmap Forces the texture to not create mip map information if true
  48440. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48441. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48442. * @param onLoad define a callback triggered when the texture has been loaded
  48443. * @param onError define a callback triggered when an error occurred during the loading session
  48444. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48445. * @returns the created texture
  48446. */
  48447. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48448. /**
  48449. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48450. * @param data Define the base64 payload without the data: prefix
  48451. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48452. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48453. * @param scene Define the scene the texture should belong to
  48454. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48455. * @param noMipmap Forces the texture to not create mip map information if true
  48456. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48457. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48458. * @param onLoad define a callback triggered when the texture has been loaded
  48459. * @param onError define a callback triggered when an error occurred during the loading session
  48460. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48461. * @returns the created texture
  48462. */
  48463. 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;
  48464. }
  48465. }
  48466. declare module BABYLON {
  48467. /**
  48468. * Settings for finer control over video usage
  48469. */
  48470. interface VideoTextureSettings {
  48471. /**
  48472. * Applies `autoplay` to video, if specified
  48473. */
  48474. autoPlay?: boolean;
  48475. /**
  48476. * Applies `loop` to video, if specified
  48477. */
  48478. loop?: boolean;
  48479. /**
  48480. * Automatically updates internal texture from video at every frame in the render loop
  48481. */
  48482. autoUpdateTexture: boolean;
  48483. /**
  48484. * Image src displayed during the video loading or until the user interacts with the video.
  48485. */
  48486. poster?: string;
  48487. }
  48488. /**
  48489. * If you want to display a video in your scene, this is the special texture for that.
  48490. * This special texture works similar to other textures, with the exception of a few parameters.
  48491. * @see https://doc.babylonjs.com/how_to/video_texture
  48492. */
  48493. class VideoTexture extends Texture {
  48494. /**
  48495. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48496. */
  48497. readonly autoUpdateTexture: boolean;
  48498. /**
  48499. * The video instance used by the texture internally
  48500. */
  48501. readonly video: HTMLVideoElement;
  48502. private _onUserActionRequestedObservable;
  48503. /**
  48504. * Event triggerd when a dom action is required by the user to play the video.
  48505. * This happens due to recent changes in browser policies preventing video to auto start.
  48506. */
  48507. readonly onUserActionRequestedObservable: Observable<Texture>;
  48508. private _generateMipMaps;
  48509. private _engine;
  48510. private _stillImageCaptured;
  48511. private _displayingPosterTexture;
  48512. private _settings;
  48513. private _createInternalTextureOnEvent;
  48514. /**
  48515. * Creates a video texture.
  48516. * If you want to display a video in your scene, this is the special texture for that.
  48517. * This special texture works similar to other textures, with the exception of a few parameters.
  48518. * @see https://doc.babylonjs.com/how_to/video_texture
  48519. * @param name optional name, will detect from video source, if not defined
  48520. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48521. * @param scene is obviously the current scene.
  48522. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48523. * @param invertY is false by default but can be used to invert video on Y axis
  48524. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48525. * @param settings allows finer control over video usage
  48526. */
  48527. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48528. private _getName;
  48529. private _getVideo;
  48530. private _createInternalTexture;
  48531. private reset;
  48532. /**
  48533. * @hidden Internal method to initiate `update`.
  48534. */
  48535. _rebuild(): void;
  48536. /**
  48537. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48538. */
  48539. update(): void;
  48540. /**
  48541. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48542. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48543. */
  48544. updateTexture(isVisible: boolean): void;
  48545. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48546. /**
  48547. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48548. * @param url New url.
  48549. */
  48550. updateURL(url: string): void;
  48551. /**
  48552. * Dispose the texture and release its associated resources.
  48553. */
  48554. dispose(): void;
  48555. /**
  48556. * Creates a video texture straight from your WebCam video feed.
  48557. * @param scene Define the scene the texture should be created in
  48558. * @param onReady Define a callback to triggered once the texture will be ready
  48559. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48560. */
  48561. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48562. minWidth: number;
  48563. maxWidth: number;
  48564. minHeight: number;
  48565. maxHeight: number;
  48566. deviceId: string;
  48567. }): void;
  48568. }
  48569. }
  48570. declare var DracoDecoderModule: any;
  48571. declare var WebAssembly: any;
  48572. declare module BABYLON {
  48573. /**
  48574. * Configuration for Draco compression
  48575. */
  48576. interface IDracoCompressionConfiguration {
  48577. /**
  48578. * Configuration for the decoder.
  48579. */
  48580. decoder?: {
  48581. /**
  48582. * The url to the WebAssembly module.
  48583. */
  48584. wasmUrl?: string;
  48585. /**
  48586. * The url to the WebAssembly binary.
  48587. */
  48588. wasmBinaryUrl?: string;
  48589. /**
  48590. * The url to the fallback JavaScript module.
  48591. */
  48592. fallbackUrl?: string;
  48593. };
  48594. }
  48595. /**
  48596. * Draco compression (https://google.github.io/draco/)
  48597. *
  48598. * This class wraps the Draco module.
  48599. *
  48600. * **Encoder**
  48601. *
  48602. * The encoder is not currently implemented.
  48603. *
  48604. * **Decoder**
  48605. *
  48606. * 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.
  48607. *
  48608. * To update the configuration, use the following code:
  48609. * ```javascript
  48610. * BABYLON.DracoCompression.Configuration = {
  48611. * decoder: {
  48612. * wasmUrl: "<url to the WebAssembly library>",
  48613. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48614. * fallbackUrl: "<url to the fallback JavaScript library>",
  48615. * }
  48616. * };
  48617. * ```
  48618. *
  48619. * 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.
  48620. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48621. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48622. *
  48623. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48624. * ```javascript
  48625. * var dracoCompression = new BABYLON.DracoCompression();
  48626. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48627. * [BABYLON.VertexBuffer.PositionKind]: 0
  48628. * });
  48629. * ```
  48630. *
  48631. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48632. */
  48633. class DracoCompression implements IDisposable {
  48634. private static _DecoderModulePromise;
  48635. /**
  48636. * The configuration. Defaults to the following urls:
  48637. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48638. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48639. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48640. */
  48641. static Configuration: IDracoCompressionConfiguration;
  48642. /**
  48643. * Returns true if the decoder is available.
  48644. */
  48645. static readonly DecoderAvailable: boolean;
  48646. /**
  48647. * Constructor
  48648. */
  48649. constructor();
  48650. /**
  48651. * Stop all async operations and release resources.
  48652. */
  48653. dispose(): void;
  48654. /**
  48655. * Decode Draco compressed mesh data to vertex data.
  48656. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48657. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48658. * @returns A promise that resolves with the decoded vertex data
  48659. */
  48660. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48661. [kind: string]: number;
  48662. }): Promise<VertexData>;
  48663. private static _GetDecoderModule;
  48664. private static _LoadScriptAsync;
  48665. private static _LoadFileAsync;
  48666. }
  48667. }
  48668. declare module BABYLON {
  48669. /**
  48670. * Particle emitter emitting particles from the inside of a box.
  48671. * It emits the particles randomly between 2 given directions.
  48672. */
  48673. class BoxParticleEmitter implements IParticleEmitterType {
  48674. /**
  48675. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48676. */
  48677. direction1: Vector3;
  48678. /**
  48679. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48680. */
  48681. direction2: Vector3;
  48682. /**
  48683. * 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.
  48684. */
  48685. minEmitBox: Vector3;
  48686. /**
  48687. * 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.
  48688. */
  48689. maxEmitBox: Vector3;
  48690. /**
  48691. * Creates a new instance BoxParticleEmitter
  48692. */
  48693. constructor();
  48694. /**
  48695. * Called by the particle System when the direction is computed for the created particle.
  48696. * @param worldMatrix is the world matrix of the particle system
  48697. * @param directionToUpdate is the direction vector to update with the result
  48698. * @param particle is the particle we are computed the direction for
  48699. */
  48700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48701. /**
  48702. * Called by the particle System when the position is computed for the created particle.
  48703. * @param worldMatrix is the world matrix of the particle system
  48704. * @param positionToUpdate is the position vector to update with the result
  48705. * @param particle is the particle we are computed the position for
  48706. */
  48707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48708. /**
  48709. * Clones the current emitter and returns a copy of it
  48710. * @returns the new emitter
  48711. */
  48712. clone(): BoxParticleEmitter;
  48713. /**
  48714. * Called by the GPUParticleSystem to setup the update shader
  48715. * @param effect defines the update shader
  48716. */
  48717. applyToShader(effect: Effect): void;
  48718. /**
  48719. * Returns a string to use to update the GPU particles update shader
  48720. * @returns a string containng the defines string
  48721. */
  48722. getEffectDefines(): string;
  48723. /**
  48724. * Returns the string "BoxParticleEmitter"
  48725. * @returns a string containing the class name
  48726. */
  48727. getClassName(): string;
  48728. /**
  48729. * Serializes the particle system to a JSON object.
  48730. * @returns the JSON object
  48731. */
  48732. serialize(): any;
  48733. /**
  48734. * Parse properties from a JSON object
  48735. * @param serializationObject defines the JSON object
  48736. */
  48737. parse(serializationObject: any): void;
  48738. }
  48739. }
  48740. declare module BABYLON {
  48741. /**
  48742. * Particle emitter emitting particles from the inside of a cone.
  48743. * It emits the particles alongside the cone volume from the base to the particle.
  48744. * The emission direction might be randomized.
  48745. */
  48746. class ConeParticleEmitter implements IParticleEmitterType {
  48747. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48748. directionRandomizer: number;
  48749. private _radius;
  48750. private _angle;
  48751. private _height;
  48752. /**
  48753. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48754. */
  48755. radiusRange: number;
  48756. /**
  48757. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48758. */
  48759. heightRange: number;
  48760. /**
  48761. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48762. */
  48763. emitFromSpawnPointOnly: boolean;
  48764. /**
  48765. * Gets or sets the radius of the emission cone
  48766. */
  48767. radius: number;
  48768. /**
  48769. * Gets or sets the angle of the emission cone
  48770. */
  48771. angle: number;
  48772. private _buildHeight;
  48773. /**
  48774. * Creates a new instance ConeParticleEmitter
  48775. * @param radius the radius of the emission cone (1 by default)
  48776. * @param angles the cone base angle (PI by default)
  48777. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48778. */
  48779. constructor(radius?: number, angle?: number,
  48780. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48781. directionRandomizer?: number);
  48782. /**
  48783. * Called by the particle System when the direction is computed for the created particle.
  48784. * @param worldMatrix is the world matrix of the particle system
  48785. * @param directionToUpdate is the direction vector to update with the result
  48786. * @param particle is the particle we are computed the direction for
  48787. */
  48788. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48789. /**
  48790. * Called by the particle System when the position is computed for the created particle.
  48791. * @param worldMatrix is the world matrix of the particle system
  48792. * @param positionToUpdate is the position vector to update with the result
  48793. * @param particle is the particle we are computed the position for
  48794. */
  48795. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48796. /**
  48797. * Clones the current emitter and returns a copy of it
  48798. * @returns the new emitter
  48799. */
  48800. clone(): ConeParticleEmitter;
  48801. /**
  48802. * Called by the GPUParticleSystem to setup the update shader
  48803. * @param effect defines the update shader
  48804. */
  48805. applyToShader(effect: Effect): void;
  48806. /**
  48807. * Returns a string to use to update the GPU particles update shader
  48808. * @returns a string containng the defines string
  48809. */
  48810. getEffectDefines(): string;
  48811. /**
  48812. * Returns the string "ConeParticleEmitter"
  48813. * @returns a string containing the class name
  48814. */
  48815. getClassName(): string;
  48816. /**
  48817. * Serializes the particle system to a JSON object.
  48818. * @returns the JSON object
  48819. */
  48820. serialize(): any;
  48821. /**
  48822. * Parse properties from a JSON object
  48823. * @param serializationObject defines the JSON object
  48824. */
  48825. parse(serializationObject: any): void;
  48826. }
  48827. }
  48828. declare module BABYLON {
  48829. /**
  48830. * Particle emitter emitting particles from the inside of a cylinder.
  48831. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48832. */
  48833. class CylinderParticleEmitter implements IParticleEmitterType {
  48834. /**
  48835. * The radius of the emission cylinder.
  48836. */
  48837. radius: number;
  48838. /**
  48839. * The height of the emission cylinder.
  48840. */
  48841. height: number;
  48842. /**
  48843. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48844. */
  48845. radiusRange: number;
  48846. /**
  48847. * How much to randomize the particle direction [0-1].
  48848. */
  48849. directionRandomizer: number;
  48850. /**
  48851. * Creates a new instance CylinderParticleEmitter
  48852. * @param radius the radius of the emission cylinder (1 by default)
  48853. * @param height the height of the emission cylinder (1 by default)
  48854. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48855. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48856. */
  48857. constructor(
  48858. /**
  48859. * The radius of the emission cylinder.
  48860. */
  48861. radius?: number,
  48862. /**
  48863. * The height of the emission cylinder.
  48864. */
  48865. height?: number,
  48866. /**
  48867. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48868. */
  48869. radiusRange?: number,
  48870. /**
  48871. * How much to randomize the particle direction [0-1].
  48872. */
  48873. directionRandomizer?: number);
  48874. /**
  48875. * Called by the particle System when the direction is computed for the created particle.
  48876. * @param worldMatrix is the world matrix of the particle system
  48877. * @param directionToUpdate is the direction vector to update with the result
  48878. * @param particle is the particle we are computed the direction for
  48879. */
  48880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48881. /**
  48882. * Called by the particle System when the position is computed for the created particle.
  48883. * @param worldMatrix is the world matrix of the particle system
  48884. * @param positionToUpdate is the position vector to update with the result
  48885. * @param particle is the particle we are computed the position for
  48886. */
  48887. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48888. /**
  48889. * Clones the current emitter and returns a copy of it
  48890. * @returns the new emitter
  48891. */
  48892. clone(): CylinderParticleEmitter;
  48893. /**
  48894. * Called by the GPUParticleSystem to setup the update shader
  48895. * @param effect defines the update shader
  48896. */
  48897. applyToShader(effect: Effect): void;
  48898. /**
  48899. * Returns a string to use to update the GPU particles update shader
  48900. * @returns a string containng the defines string
  48901. */
  48902. getEffectDefines(): string;
  48903. /**
  48904. * Returns the string "CylinderParticleEmitter"
  48905. * @returns a string containing the class name
  48906. */
  48907. getClassName(): string;
  48908. /**
  48909. * Serializes the particle system to a JSON object.
  48910. * @returns the JSON object
  48911. */
  48912. serialize(): any;
  48913. /**
  48914. * Parse properties from a JSON object
  48915. * @param serializationObject defines the JSON object
  48916. */
  48917. parse(serializationObject: any): void;
  48918. }
  48919. /**
  48920. * Particle emitter emitting particles from the inside of a cylinder.
  48921. * It emits the particles randomly between two vectors.
  48922. */
  48923. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48924. /**
  48925. * The min limit of the emission direction.
  48926. */
  48927. direction1: Vector3;
  48928. /**
  48929. * The max limit of the emission direction.
  48930. */
  48931. direction2: Vector3;
  48932. /**
  48933. * Creates a new instance CylinderDirectedParticleEmitter
  48934. * @param radius the radius of the emission cylinder (1 by default)
  48935. * @param height the height of the emission cylinder (1 by default)
  48936. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48937. * @param direction1 the min limit of the emission direction (up vector by default)
  48938. * @param direction2 the max limit of the emission direction (up vector by default)
  48939. */
  48940. constructor(radius?: number, height?: number, radiusRange?: number,
  48941. /**
  48942. * The min limit of the emission direction.
  48943. */
  48944. direction1?: Vector3,
  48945. /**
  48946. * The max limit of the emission direction.
  48947. */
  48948. direction2?: Vector3);
  48949. /**
  48950. * Called by the particle System when the direction is computed for the created particle.
  48951. * @param worldMatrix is the world matrix of the particle system
  48952. * @param directionToUpdate is the direction vector to update with the result
  48953. * @param particle is the particle we are computed the direction for
  48954. */
  48955. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48956. /**
  48957. * Clones the current emitter and returns a copy of it
  48958. * @returns the new emitter
  48959. */
  48960. clone(): CylinderDirectedParticleEmitter;
  48961. /**
  48962. * Called by the GPUParticleSystem to setup the update shader
  48963. * @param effect defines the update shader
  48964. */
  48965. applyToShader(effect: Effect): void;
  48966. /**
  48967. * Returns a string to use to update the GPU particles update shader
  48968. * @returns a string containng the defines string
  48969. */
  48970. getEffectDefines(): string;
  48971. /**
  48972. * Returns the string "CylinderDirectedParticleEmitter"
  48973. * @returns a string containing the class name
  48974. */
  48975. getClassName(): string;
  48976. /**
  48977. * Serializes the particle system to a JSON object.
  48978. * @returns the JSON object
  48979. */
  48980. serialize(): any;
  48981. /**
  48982. * Parse properties from a JSON object
  48983. * @param serializationObject defines the JSON object
  48984. */
  48985. parse(serializationObject: any): void;
  48986. }
  48987. }
  48988. declare module BABYLON {
  48989. /**
  48990. * Particle emitter emitting particles from the inside of a hemisphere.
  48991. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48992. */
  48993. class HemisphericParticleEmitter implements IParticleEmitterType {
  48994. /**
  48995. * The radius of the emission hemisphere.
  48996. */
  48997. radius: number;
  48998. /**
  48999. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49000. */
  49001. radiusRange: number;
  49002. /**
  49003. * How much to randomize the particle direction [0-1].
  49004. */
  49005. directionRandomizer: number;
  49006. /**
  49007. * Creates a new instance HemisphericParticleEmitter
  49008. * @param radius the radius of the emission hemisphere (1 by default)
  49009. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49010. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49011. */
  49012. constructor(
  49013. /**
  49014. * The radius of the emission hemisphere.
  49015. */
  49016. radius?: number,
  49017. /**
  49018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49019. */
  49020. radiusRange?: number,
  49021. /**
  49022. * How much to randomize the particle direction [0-1].
  49023. */
  49024. directionRandomizer?: number);
  49025. /**
  49026. * Called by the particle System when the direction is computed for the created particle.
  49027. * @param worldMatrix is the world matrix of the particle system
  49028. * @param directionToUpdate is the direction vector to update with the result
  49029. * @param particle is the particle we are computed the direction for
  49030. */
  49031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49032. /**
  49033. * Called by the particle System when the position is computed for the created particle.
  49034. * @param worldMatrix is the world matrix of the particle system
  49035. * @param positionToUpdate is the position vector to update with the result
  49036. * @param particle is the particle we are computed the position for
  49037. */
  49038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49039. /**
  49040. * Clones the current emitter and returns a copy of it
  49041. * @returns the new emitter
  49042. */
  49043. clone(): HemisphericParticleEmitter;
  49044. /**
  49045. * Called by the GPUParticleSystem to setup the update shader
  49046. * @param effect defines the update shader
  49047. */
  49048. applyToShader(effect: Effect): void;
  49049. /**
  49050. * Returns a string to use to update the GPU particles update shader
  49051. * @returns a string containng the defines string
  49052. */
  49053. getEffectDefines(): string;
  49054. /**
  49055. * Returns the string "HemisphericParticleEmitter"
  49056. * @returns a string containing the class name
  49057. */
  49058. getClassName(): string;
  49059. /**
  49060. * Serializes the particle system to a JSON object.
  49061. * @returns the JSON object
  49062. */
  49063. serialize(): any;
  49064. /**
  49065. * Parse properties from a JSON object
  49066. * @param serializationObject defines the JSON object
  49067. */
  49068. parse(serializationObject: any): void;
  49069. }
  49070. }
  49071. declare module BABYLON {
  49072. /**
  49073. * Particle emitter represents a volume emitting particles.
  49074. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49075. */
  49076. interface IParticleEmitterType {
  49077. /**
  49078. * Called by the particle System when the direction is computed for the created particle.
  49079. * @param worldMatrix is the world matrix of the particle system
  49080. * @param directionToUpdate is the direction vector to update with the result
  49081. * @param particle is the particle we are computed the direction for
  49082. */
  49083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49084. /**
  49085. * Called by the particle System when the position is computed for the created particle.
  49086. * @param worldMatrix is the world matrix of the particle system
  49087. * @param positionToUpdate is the position vector to update with the result
  49088. * @param particle is the particle we are computed the position for
  49089. */
  49090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49091. /**
  49092. * Clones the current emitter and returns a copy of it
  49093. * @returns the new emitter
  49094. */
  49095. clone(): IParticleEmitterType;
  49096. /**
  49097. * Called by the GPUParticleSystem to setup the update shader
  49098. * @param effect defines the update shader
  49099. */
  49100. applyToShader(effect: Effect): void;
  49101. /**
  49102. * Returns a string to use to update the GPU particles update shader
  49103. * @returns the effect defines string
  49104. */
  49105. getEffectDefines(): string;
  49106. /**
  49107. * Returns a string representing the class name
  49108. * @returns a string containing the class name
  49109. */
  49110. getClassName(): string;
  49111. /**
  49112. * Serializes the particle system to a JSON object.
  49113. * @returns the JSON object
  49114. */
  49115. serialize(): any;
  49116. /**
  49117. * Parse properties from a JSON object
  49118. * @param serializationObject defines the JSON object
  49119. */
  49120. parse(serializationObject: any): void;
  49121. }
  49122. }
  49123. declare module BABYLON {
  49124. /**
  49125. * Particle emitter emitting particles from a point.
  49126. * It emits the particles randomly between 2 given directions.
  49127. */
  49128. class PointParticleEmitter implements IParticleEmitterType {
  49129. /**
  49130. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49131. */
  49132. direction1: Vector3;
  49133. /**
  49134. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49135. */
  49136. direction2: Vector3;
  49137. /**
  49138. * Creates a new instance PointParticleEmitter
  49139. */
  49140. constructor();
  49141. /**
  49142. * Called by the particle System when the direction is computed for the created particle.
  49143. * @param worldMatrix is the world matrix of the particle system
  49144. * @param directionToUpdate is the direction vector to update with the result
  49145. * @param particle is the particle we are computed the direction for
  49146. */
  49147. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49148. /**
  49149. * Called by the particle System when the position is computed for the created particle.
  49150. * @param worldMatrix is the world matrix of the particle system
  49151. * @param positionToUpdate is the position vector to update with the result
  49152. * @param particle is the particle we are computed the position for
  49153. */
  49154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49155. /**
  49156. * Clones the current emitter and returns a copy of it
  49157. * @returns the new emitter
  49158. */
  49159. clone(): PointParticleEmitter;
  49160. /**
  49161. * Called by the GPUParticleSystem to setup the update shader
  49162. * @param effect defines the update shader
  49163. */
  49164. applyToShader(effect: Effect): void;
  49165. /**
  49166. * Returns a string to use to update the GPU particles update shader
  49167. * @returns a string containng the defines string
  49168. */
  49169. getEffectDefines(): string;
  49170. /**
  49171. * Returns the string "PointParticleEmitter"
  49172. * @returns a string containing the class name
  49173. */
  49174. getClassName(): string;
  49175. /**
  49176. * Serializes the particle system to a JSON object.
  49177. * @returns the JSON object
  49178. */
  49179. serialize(): any;
  49180. /**
  49181. * Parse properties from a JSON object
  49182. * @param serializationObject defines the JSON object
  49183. */
  49184. parse(serializationObject: any): void;
  49185. }
  49186. }
  49187. declare module BABYLON {
  49188. /**
  49189. * Particle emitter emitting particles from the inside of a sphere.
  49190. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49191. */
  49192. class SphereParticleEmitter implements IParticleEmitterType {
  49193. /**
  49194. * The radius of the emission sphere.
  49195. */
  49196. radius: number;
  49197. /**
  49198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49199. */
  49200. radiusRange: number;
  49201. /**
  49202. * How much to randomize the particle direction [0-1].
  49203. */
  49204. directionRandomizer: number;
  49205. /**
  49206. * Creates a new instance SphereParticleEmitter
  49207. * @param radius the radius of the emission sphere (1 by default)
  49208. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49209. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49210. */
  49211. constructor(
  49212. /**
  49213. * The radius of the emission sphere.
  49214. */
  49215. radius?: number,
  49216. /**
  49217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49218. */
  49219. radiusRange?: number,
  49220. /**
  49221. * How much to randomize the particle direction [0-1].
  49222. */
  49223. directionRandomizer?: number);
  49224. /**
  49225. * Called by the particle System when the direction is computed for the created particle.
  49226. * @param worldMatrix is the world matrix of the particle system
  49227. * @param directionToUpdate is the direction vector to update with the result
  49228. * @param particle is the particle we are computed the direction for
  49229. */
  49230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49231. /**
  49232. * Called by the particle System when the position is computed for the created particle.
  49233. * @param worldMatrix is the world matrix of the particle system
  49234. * @param positionToUpdate is the position vector to update with the result
  49235. * @param particle is the particle we are computed the position for
  49236. */
  49237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49238. /**
  49239. * Clones the current emitter and returns a copy of it
  49240. * @returns the new emitter
  49241. */
  49242. clone(): SphereParticleEmitter;
  49243. /**
  49244. * Called by the GPUParticleSystem to setup the update shader
  49245. * @param effect defines the update shader
  49246. */
  49247. applyToShader(effect: Effect): void;
  49248. /**
  49249. * Returns a string to use to update the GPU particles update shader
  49250. * @returns a string containng the defines string
  49251. */
  49252. getEffectDefines(): string;
  49253. /**
  49254. * Returns the string "SphereParticleEmitter"
  49255. * @returns a string containing the class name
  49256. */
  49257. getClassName(): string;
  49258. /**
  49259. * Serializes the particle system to a JSON object.
  49260. * @returns the JSON object
  49261. */
  49262. serialize(): any;
  49263. /**
  49264. * Parse properties from a JSON object
  49265. * @param serializationObject defines the JSON object
  49266. */
  49267. parse(serializationObject: any): void;
  49268. }
  49269. /**
  49270. * Particle emitter emitting particles from the inside of a sphere.
  49271. * It emits the particles randomly between two vectors.
  49272. */
  49273. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49274. /**
  49275. * The min limit of the emission direction.
  49276. */
  49277. direction1: Vector3;
  49278. /**
  49279. * The max limit of the emission direction.
  49280. */
  49281. direction2: Vector3;
  49282. /**
  49283. * Creates a new instance SphereDirectedParticleEmitter
  49284. * @param radius the radius of the emission sphere (1 by default)
  49285. * @param direction1 the min limit of the emission direction (up vector by default)
  49286. * @param direction2 the max limit of the emission direction (up vector by default)
  49287. */
  49288. constructor(radius?: number,
  49289. /**
  49290. * The min limit of the emission direction.
  49291. */
  49292. direction1?: Vector3,
  49293. /**
  49294. * The max limit of the emission direction.
  49295. */
  49296. direction2?: Vector3);
  49297. /**
  49298. * Called by the particle System when the direction is computed for the created particle.
  49299. * @param worldMatrix is the world matrix of the particle system
  49300. * @param directionToUpdate is the direction vector to update with the result
  49301. * @param particle is the particle we are computed the direction for
  49302. */
  49303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49304. /**
  49305. * Clones the current emitter and returns a copy of it
  49306. * @returns the new emitter
  49307. */
  49308. clone(): SphereDirectedParticleEmitter;
  49309. /**
  49310. * Called by the GPUParticleSystem to setup the update shader
  49311. * @param effect defines the update shader
  49312. */
  49313. applyToShader(effect: Effect): void;
  49314. /**
  49315. * Returns a string to use to update the GPU particles update shader
  49316. * @returns a string containng the defines string
  49317. */
  49318. getEffectDefines(): string;
  49319. /**
  49320. * Returns the string "SphereDirectedParticleEmitter"
  49321. * @returns a string containing the class name
  49322. */
  49323. getClassName(): string;
  49324. /**
  49325. * Serializes the particle system to a JSON object.
  49326. * @returns the JSON object
  49327. */
  49328. serialize(): any;
  49329. /**
  49330. * Parse properties from a JSON object
  49331. * @param serializationObject defines the JSON object
  49332. */
  49333. parse(serializationObject: any): void;
  49334. }
  49335. }
  49336. declare module BABYLON {
  49337. /**
  49338. * AmmoJS Physics plugin
  49339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49340. * @see https://github.com/kripken/ammo.js/
  49341. */
  49342. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49343. private _useDeltaForWorldStep;
  49344. /**
  49345. * Reference to the Ammo library
  49346. */
  49347. bjsAMMO: any;
  49348. /**
  49349. * Created ammoJS world which physics bodies are added to
  49350. */
  49351. world: any;
  49352. /**
  49353. * Name of the plugin
  49354. */
  49355. name: string;
  49356. private _timeStep;
  49357. private _fixedTimeStep;
  49358. private _maxSteps;
  49359. private _tmpQuaternion;
  49360. private _tmpAmmoTransform;
  49361. private _tmpAmmoQuaternion;
  49362. private _tmpAmmoConcreteContactResultCallback;
  49363. private _collisionConfiguration;
  49364. private _dispatcher;
  49365. private _overlappingPairCache;
  49366. private _solver;
  49367. private _tmpAmmoVectorA;
  49368. private _tmpAmmoVectorB;
  49369. private _tmpAmmoVectorC;
  49370. private _tmpContactCallbackResult;
  49371. private static readonly DISABLE_COLLISION_FLAG;
  49372. private static readonly KINEMATIC_FLAG;
  49373. private static readonly DISABLE_DEACTIVATION_FLAG;
  49374. /**
  49375. * Initializes the ammoJS plugin
  49376. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49377. */
  49378. constructor(_useDeltaForWorldStep?: boolean);
  49379. /**
  49380. * Sets the gravity of the physics world (m/(s^2))
  49381. * @param gravity Gravity to set
  49382. */
  49383. setGravity(gravity: Vector3): void;
  49384. /**
  49385. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49386. * @param timeStep timestep to use in seconds
  49387. */
  49388. setTimeStep(timeStep: number): void;
  49389. /**
  49390. * 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)
  49391. * @param fixedTimeStep fixedTimeStep to use in seconds
  49392. */
  49393. setFixedTimeStep(fixedTimeStep: number): void;
  49394. /**
  49395. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49396. * @param maxSteps the maximum number of steps by the physics engine per frame
  49397. */
  49398. setMaxSteps(maxSteps: number): void;
  49399. /**
  49400. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49401. * @returns the current timestep in seconds
  49402. */
  49403. getTimeStep(): number;
  49404. private _isImpostorInContact;
  49405. private _isImpostorPairInContact;
  49406. private _stepSimulation;
  49407. /**
  49408. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49409. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49410. * After the step the babylon meshes are set to the position of the physics imposters
  49411. * @param delta amount of time to step forward
  49412. * @param impostors array of imposters to update before/after the step
  49413. */
  49414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49415. /**
  49416. * Applies an implulse on the imposter
  49417. * @param impostor imposter to apply impulse
  49418. * @param force amount of force to be applied to the imposter
  49419. * @param contactPoint the location to apply the impulse on the imposter
  49420. */
  49421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49422. /**
  49423. * Applies a force on the imposter
  49424. * @param impostor imposter to apply force
  49425. * @param force amount of force to be applied to the imposter
  49426. * @param contactPoint the location to apply the force on the imposter
  49427. */
  49428. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49429. /**
  49430. * Creates a physics body using the plugin
  49431. * @param impostor the imposter to create the physics body on
  49432. */
  49433. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49434. /**
  49435. * Removes the physics body from the imposter and disposes of the body's memory
  49436. * @param impostor imposter to remove the physics body from
  49437. */
  49438. removePhysicsBody(impostor: PhysicsImpostor): void;
  49439. /**
  49440. * Generates a joint
  49441. * @param impostorJoint the imposter joint to create the joint with
  49442. */
  49443. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49444. /**
  49445. * Removes a joint
  49446. * @param impostorJoint the imposter joint to remove the joint from
  49447. */
  49448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49449. private _addMeshVerts;
  49450. private _createShape;
  49451. /**
  49452. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49453. * @param impostor imposter containing the physics body and babylon object
  49454. */
  49455. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49456. /**
  49457. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49458. * @param impostor imposter containing the physics body and babylon object
  49459. * @param newPosition new position
  49460. * @param newRotation new rotation
  49461. */
  49462. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49463. /**
  49464. * If this plugin is supported
  49465. * @returns true if its supported
  49466. */
  49467. isSupported(): boolean;
  49468. /**
  49469. * Sets the linear velocity of the physics body
  49470. * @param impostor imposter to set the velocity on
  49471. * @param velocity velocity to set
  49472. */
  49473. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49474. /**
  49475. * Sets the angular velocity of the physics body
  49476. * @param impostor imposter to set the velocity on
  49477. * @param velocity velocity to set
  49478. */
  49479. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49480. /**
  49481. * gets the linear velocity
  49482. * @param impostor imposter to get linear velocity from
  49483. * @returns linear velocity
  49484. */
  49485. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49486. /**
  49487. * gets the angular velocity
  49488. * @param impostor imposter to get angular velocity from
  49489. * @returns angular velocity
  49490. */
  49491. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49492. /**
  49493. * Sets the mass of physics body
  49494. * @param impostor imposter to set the mass on
  49495. * @param mass mass to set
  49496. */
  49497. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49498. /**
  49499. * Gets the mass of the physics body
  49500. * @param impostor imposter to get the mass from
  49501. * @returns mass
  49502. */
  49503. getBodyMass(impostor: PhysicsImpostor): number;
  49504. /**
  49505. * Gets friction of the impostor
  49506. * @param impostor impostor to get friction from
  49507. * @returns friction value
  49508. */
  49509. getBodyFriction(impostor: PhysicsImpostor): number;
  49510. /**
  49511. * Sets friction of the impostor
  49512. * @param impostor impostor to set friction on
  49513. * @param friction friction value
  49514. */
  49515. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49516. /**
  49517. * Gets restitution of the impostor
  49518. * @param impostor impostor to get restitution from
  49519. * @returns restitution value
  49520. */
  49521. getBodyRestitution(impostor: PhysicsImpostor): number;
  49522. /**
  49523. * Sets resitution of the impostor
  49524. * @param impostor impostor to set resitution on
  49525. * @param restitution resitution value
  49526. */
  49527. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49528. /**
  49529. * Sleeps the physics body and stops it from being active
  49530. * @param impostor impostor to sleep
  49531. */
  49532. sleepBody(impostor: PhysicsImpostor): void;
  49533. /**
  49534. * Activates the physics body
  49535. * @param impostor impostor to activate
  49536. */
  49537. wakeUpBody(impostor: PhysicsImpostor): void;
  49538. /**
  49539. * Updates the distance parameters of the joint
  49540. * @param joint joint to update
  49541. * @param maxDistance maximum distance of the joint
  49542. * @param minDistance minimum distance of the joint
  49543. */
  49544. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49545. /**
  49546. * Sets a motor on the joint
  49547. * @param joint joint to set motor on
  49548. * @param speed speed of the motor
  49549. * @param maxForce maximum force of the motor
  49550. * @param motorIndex index of the motor
  49551. */
  49552. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49553. /**
  49554. * Sets the motors limit
  49555. * @param joint joint to set limit on
  49556. * @param upperLimit upper limit
  49557. * @param lowerLimit lower limit
  49558. */
  49559. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49560. /**
  49561. * Syncs the position and rotation of a mesh with the impostor
  49562. * @param mesh mesh to sync
  49563. * @param impostor impostor to update the mesh with
  49564. */
  49565. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49566. /**
  49567. * Gets the radius of the impostor
  49568. * @param impostor impostor to get radius from
  49569. * @returns the radius
  49570. */
  49571. getRadius(impostor: PhysicsImpostor): number;
  49572. /**
  49573. * Gets the box size of the impostor
  49574. * @param impostor impostor to get box size from
  49575. * @param result the resulting box size
  49576. */
  49577. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49578. /**
  49579. * Disposes of the impostor
  49580. */
  49581. dispose(): void;
  49582. }
  49583. }
  49584. declare module BABYLON {
  49585. /** @hidden */
  49586. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49587. private _useDeltaForWorldStep;
  49588. world: any;
  49589. name: string;
  49590. private _physicsMaterials;
  49591. private _fixedTimeStep;
  49592. BJSCANNON: any;
  49593. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49594. setGravity(gravity: Vector3): void;
  49595. setTimeStep(timeStep: number): void;
  49596. getTimeStep(): number;
  49597. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49598. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49599. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49600. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49601. private _processChildMeshes;
  49602. removePhysicsBody(impostor: PhysicsImpostor): void;
  49603. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49604. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49605. private _addMaterial;
  49606. private _checkWithEpsilon;
  49607. private _createShape;
  49608. private _createHeightmap;
  49609. private _minus90X;
  49610. private _plus90X;
  49611. private _tmpPosition;
  49612. private _tmpDeltaPosition;
  49613. private _tmpUnityRotation;
  49614. private _updatePhysicsBodyTransformation;
  49615. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49616. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49617. isSupported(): boolean;
  49618. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49619. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49620. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49621. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49622. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49623. getBodyMass(impostor: PhysicsImpostor): number;
  49624. getBodyFriction(impostor: PhysicsImpostor): number;
  49625. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49626. getBodyRestitution(impostor: PhysicsImpostor): number;
  49627. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49628. sleepBody(impostor: PhysicsImpostor): void;
  49629. wakeUpBody(impostor: PhysicsImpostor): void;
  49630. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49631. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49632. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49633. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49634. getRadius(impostor: PhysicsImpostor): number;
  49635. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49636. dispose(): void;
  49637. private _extendNamespace;
  49638. }
  49639. }
  49640. declare module BABYLON {
  49641. /** @hidden */
  49642. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49643. world: any;
  49644. name: string;
  49645. BJSOIMO: any;
  49646. constructor(iterations?: number);
  49647. setGravity(gravity: Vector3): void;
  49648. setTimeStep(timeStep: number): void;
  49649. getTimeStep(): number;
  49650. private _tmpImpostorsArray;
  49651. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49652. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49653. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49654. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49655. private _tmpPositionVector;
  49656. removePhysicsBody(impostor: PhysicsImpostor): void;
  49657. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49658. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49659. isSupported(): boolean;
  49660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49667. getBodyMass(impostor: PhysicsImpostor): number;
  49668. getBodyFriction(impostor: PhysicsImpostor): number;
  49669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49670. getBodyRestitution(impostor: PhysicsImpostor): number;
  49671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49672. sleepBody(impostor: PhysicsImpostor): void;
  49673. wakeUpBody(impostor: PhysicsImpostor): void;
  49674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49675. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49676. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49677. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49678. getRadius(impostor: PhysicsImpostor): number;
  49679. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49680. dispose(): void;
  49681. }
  49682. }
  49683. declare module BABYLON {
  49684. /**
  49685. * This represents a set of one or more post processes in Babylon.
  49686. * A post process can be used to apply a shader to a texture after it is rendered.
  49687. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49688. */
  49689. class PostProcessRenderEffect {
  49690. private _postProcesses;
  49691. private _getPostProcesses;
  49692. private _singleInstance;
  49693. private _cameras;
  49694. private _indicesForCamera;
  49695. /**
  49696. * Name of the effect
  49697. * @hidden
  49698. */
  49699. _name: string;
  49700. /**
  49701. * Instantiates a post process render effect.
  49702. * A post process can be used to apply a shader to a texture after it is rendered.
  49703. * @param engine The engine the effect is tied to
  49704. * @param name The name of the effect
  49705. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49706. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49707. */
  49708. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49709. /**
  49710. * Checks if all the post processes in the effect are supported.
  49711. */
  49712. readonly isSupported: boolean;
  49713. /**
  49714. * Updates the current state of the effect
  49715. * @hidden
  49716. */
  49717. _update(): void;
  49718. /**
  49719. * Attaches the effect on cameras
  49720. * @param cameras The camera to attach to.
  49721. * @hidden
  49722. */
  49723. _attachCameras(cameras: Camera): void;
  49724. /**
  49725. * Attaches the effect on cameras
  49726. * @param cameras The camera to attach to.
  49727. * @hidden
  49728. */
  49729. _attachCameras(cameras: Camera[]): void;
  49730. /**
  49731. * Detatches the effect on cameras
  49732. * @param cameras The camera to detatch from.
  49733. * @hidden
  49734. */
  49735. _detachCameras(cameras: Camera): void;
  49736. /**
  49737. * Detatches the effect on cameras
  49738. * @param cameras The camera to detatch from.
  49739. * @hidden
  49740. */
  49741. _detachCameras(cameras: Camera[]): void;
  49742. /**
  49743. * Enables the effect on given cameras
  49744. * @param cameras The camera to enable.
  49745. * @hidden
  49746. */
  49747. _enable(cameras: Camera): void;
  49748. /**
  49749. * Enables the effect on given cameras
  49750. * @param cameras The camera to enable.
  49751. * @hidden
  49752. */
  49753. _enable(cameras: Nullable<Camera[]>): void;
  49754. /**
  49755. * Disables the effect on the given cameras
  49756. * @param cameras The camera to disable.
  49757. * @hidden
  49758. */
  49759. _disable(cameras: Camera): void;
  49760. /**
  49761. * Disables the effect on the given cameras
  49762. * @param cameras The camera to disable.
  49763. * @hidden
  49764. */
  49765. _disable(cameras: Nullable<Camera[]>): void;
  49766. /**
  49767. * Gets a list of the post processes contained in the effect.
  49768. * @param camera The camera to get the post processes on.
  49769. * @returns The list of the post processes in the effect.
  49770. */
  49771. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49772. }
  49773. }
  49774. declare module BABYLON {
  49775. /**
  49776. * PostProcessRenderPipeline
  49777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49778. */
  49779. class PostProcessRenderPipeline {
  49780. private engine;
  49781. private _renderEffects;
  49782. private _renderEffectsForIsolatedPass;
  49783. /**
  49784. * @hidden
  49785. */
  49786. protected _cameras: Camera[];
  49787. /** @hidden */
  49788. _name: string;
  49789. /**
  49790. * Initializes a PostProcessRenderPipeline
  49791. * @param engine engine to add the pipeline to
  49792. * @param name name of the pipeline
  49793. */
  49794. constructor(engine: Engine, name: string);
  49795. /**
  49796. * "PostProcessRenderPipeline"
  49797. * @returns "PostProcessRenderPipeline"
  49798. */
  49799. getClassName(): string;
  49800. /**
  49801. * If all the render effects in the pipeline are support
  49802. */
  49803. readonly isSupported: boolean;
  49804. /**
  49805. * Adds an effect to the pipeline
  49806. * @param renderEffect the effect to add
  49807. */
  49808. addEffect(renderEffect: PostProcessRenderEffect): void;
  49809. /** @hidden */
  49810. _rebuild(): void;
  49811. /** @hidden */
  49812. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49813. /** @hidden */
  49814. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49815. /** @hidden */
  49816. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49817. /** @hidden */
  49818. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49819. /** @hidden */
  49820. _attachCameras(cameras: Camera, unique: boolean): void;
  49821. /** @hidden */
  49822. _attachCameras(cameras: Camera[], unique: boolean): void;
  49823. /** @hidden */
  49824. _detachCameras(cameras: Camera): void;
  49825. /** @hidden */
  49826. _detachCameras(cameras: Nullable<Camera[]>): void;
  49827. /** @hidden */
  49828. _update(): void;
  49829. /** @hidden */
  49830. _reset(): void;
  49831. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49832. /**
  49833. * Disposes of the pipeline
  49834. */
  49835. dispose(): void;
  49836. }
  49837. }
  49838. declare module BABYLON {
  49839. /**
  49840. * PostProcessRenderPipelineManager class
  49841. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49842. */
  49843. class PostProcessRenderPipelineManager {
  49844. private _renderPipelines;
  49845. /**
  49846. * Initializes a PostProcessRenderPipelineManager
  49847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49848. */
  49849. constructor();
  49850. /**
  49851. * Adds a pipeline to the manager
  49852. * @param renderPipeline The pipeline to add
  49853. */
  49854. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49855. /**
  49856. * Attaches a camera to the pipeline
  49857. * @param renderPipelineName The name of the pipeline to attach to
  49858. * @param cameras the camera to attach
  49859. * @param unique if the camera can be attached multiple times to the pipeline
  49860. */
  49861. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49862. /**
  49863. * Detaches a camera from the pipeline
  49864. * @param renderPipelineName The name of the pipeline to detach from
  49865. * @param cameras the camera to detach
  49866. */
  49867. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49868. /**
  49869. * Enables an effect by name on a pipeline
  49870. * @param renderPipelineName the name of the pipeline to enable the effect in
  49871. * @param renderEffectName the name of the effect to enable
  49872. * @param cameras the cameras that the effect should be enabled on
  49873. */
  49874. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49875. /**
  49876. * Disables an effect by name on a pipeline
  49877. * @param renderPipelineName the name of the pipeline to disable the effect in
  49878. * @param renderEffectName the name of the effect to disable
  49879. * @param cameras the cameras that the effect should be disabled on
  49880. */
  49881. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49882. /**
  49883. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49884. */
  49885. update(): void;
  49886. /** @hidden */
  49887. _rebuild(): void;
  49888. /**
  49889. * Disposes of the manager and pipelines
  49890. */
  49891. dispose(): void;
  49892. }
  49893. }
  49894. declare module BABYLON {
  49895. interface Scene {
  49896. /** @hidden (Backing field) */
  49897. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49898. /**
  49899. * Gets the postprocess render pipeline manager
  49900. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49901. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49902. */
  49903. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49904. }
  49905. /**
  49906. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49907. */
  49908. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49909. /**
  49910. * The component name helpfull to identify the component in the list of scene components.
  49911. */
  49912. readonly name: string;
  49913. /**
  49914. * The scene the component belongs to.
  49915. */
  49916. scene: Scene;
  49917. /**
  49918. * Creates a new instance of the component for the given scene
  49919. * @param scene Defines the scene to register the component in
  49920. */
  49921. constructor(scene: Scene);
  49922. /**
  49923. * Registers the component in a given scene
  49924. */
  49925. register(): void;
  49926. /**
  49927. * Rebuilds the elements related to this component in case of
  49928. * context lost for instance.
  49929. */
  49930. rebuild(): void;
  49931. /**
  49932. * Disposes the component and the associated ressources
  49933. */
  49934. dispose(): void;
  49935. private _gatherRenderTargets;
  49936. }
  49937. }
  49938. declare module BABYLON {
  49939. /**
  49940. * Helper class dealing with the extraction of spherical polynomial dataArray
  49941. * from a cube map.
  49942. */
  49943. class CubeMapToSphericalPolynomialTools {
  49944. private static FileFaces;
  49945. /**
  49946. * Converts a texture to the according Spherical Polynomial data.
  49947. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49948. *
  49949. * @param texture The texture to extract the information from.
  49950. * @return The Spherical Polynomial data.
  49951. */
  49952. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49953. /**
  49954. * Converts a cubemap to the according Spherical Polynomial data.
  49955. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49956. *
  49957. * @param cubeInfo The Cube map to extract the information from.
  49958. * @return The Spherical Polynomial data.
  49959. */
  49960. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49961. }
  49962. }
  49963. declare module BABYLON {
  49964. /**
  49965. * Header information of HDR texture files.
  49966. */
  49967. interface HDRInfo {
  49968. /**
  49969. * The height of the texture in pixels.
  49970. */
  49971. height: number;
  49972. /**
  49973. * The width of the texture in pixels.
  49974. */
  49975. width: number;
  49976. /**
  49977. * The index of the beginning of the data in the binary file.
  49978. */
  49979. dataPosition: number;
  49980. }
  49981. /**
  49982. * This groups tools to convert HDR texture to native colors array.
  49983. */
  49984. class HDRTools {
  49985. private static Ldexp;
  49986. private static Rgbe2float;
  49987. private static readStringLine;
  49988. /**
  49989. * Reads header information from an RGBE texture stored in a native array.
  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 native array.
  49994. * @return The header information.
  49995. */
  49996. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49997. /**
  49998. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49999. * This RGBE texture needs to store the information as a panorama.
  50000. *
  50001. * More information on this format are available here:
  50002. * https://en.wikipedia.org/wiki/RGBE_image_format
  50003. *
  50004. * @param buffer The binary file stored in an array buffer.
  50005. * @param size The expected size of the extracted cubemap.
  50006. * @return The Cube Map information.
  50007. */
  50008. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50009. /**
  50010. * Returns the pixels data extracted from an RGBE texture.
  50011. * This pixels will be stored left to right up to down in the R G B order in one array.
  50012. *
  50013. * More information on this format are available here:
  50014. * https://en.wikipedia.org/wiki/RGBE_image_format
  50015. *
  50016. * @param uint8array The binary file stored in an array buffer.
  50017. * @param hdrInfo The header information of the file.
  50018. * @return The pixels data in RGB right to left up to down order.
  50019. */
  50020. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50021. private static RGBE_ReadPixels_RLE;
  50022. }
  50023. }
  50024. declare module BABYLON {
  50025. /**
  50026. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50027. */
  50028. interface CubeMapInfo {
  50029. /**
  50030. * The pixel array for the front face.
  50031. * This is stored in format, left to right, up to down format.
  50032. */
  50033. front: Nullable<ArrayBufferView>;
  50034. /**
  50035. * The pixel array for the back face.
  50036. * This is stored in format, left to right, up to down format.
  50037. */
  50038. back: Nullable<ArrayBufferView>;
  50039. /**
  50040. * The pixel array for the left face.
  50041. * This is stored in format, left to right, up to down format.
  50042. */
  50043. left: Nullable<ArrayBufferView>;
  50044. /**
  50045. * The pixel array for the right face.
  50046. * This is stored in format, left to right, up to down format.
  50047. */
  50048. right: Nullable<ArrayBufferView>;
  50049. /**
  50050. * The pixel array for the up face.
  50051. * This is stored in format, left to right, up to down format.
  50052. */
  50053. up: Nullable<ArrayBufferView>;
  50054. /**
  50055. * The pixel array for the down face.
  50056. * This is stored in format, left to right, up to down format.
  50057. */
  50058. down: Nullable<ArrayBufferView>;
  50059. /**
  50060. * The size of the cubemap stored.
  50061. *
  50062. * Each faces will be size * size pixels.
  50063. */
  50064. size: number;
  50065. /**
  50066. * The format of the texture.
  50067. *
  50068. * RGBA, RGB.
  50069. */
  50070. format: number;
  50071. /**
  50072. * The type of the texture data.
  50073. *
  50074. * UNSIGNED_INT, FLOAT.
  50075. */
  50076. type: number;
  50077. /**
  50078. * Specifies whether the texture is in gamma space.
  50079. */
  50080. gammaSpace: boolean;
  50081. }
  50082. /**
  50083. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50084. */
  50085. class PanoramaToCubeMapTools {
  50086. private static FACE_FRONT;
  50087. private static FACE_BACK;
  50088. private static FACE_RIGHT;
  50089. private static FACE_LEFT;
  50090. private static FACE_DOWN;
  50091. private static FACE_UP;
  50092. /**
  50093. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50094. *
  50095. * @param float32Array The source data.
  50096. * @param inputWidth The width of the input panorama.
  50097. * @param inputHeight The height of the input panorama.
  50098. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50099. * @return The cubemap data
  50100. */
  50101. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50102. private static CreateCubemapTexture;
  50103. private static CalcProjectionSpherical;
  50104. }
  50105. }
  50106. declare module BABYLON {
  50107. }
  50108. declare module BABYLON {
  50109. }
  50110. declare module BABYLON {
  50111. }
  50112. declare module BABYLON {
  50113. }
  50114. declare module BABYLON {
  50115. /**
  50116. * 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.
  50117. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50118. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50119. */
  50120. class CustomProceduralTexture extends ProceduralTexture {
  50121. private _animate;
  50122. private _time;
  50123. private _config;
  50124. private _texturePath;
  50125. /**
  50126. * Instantiates a new Custom Procedural Texture.
  50127. * 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.
  50128. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50129. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50130. * @param name Define the name of the texture
  50131. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50132. * @param size Define the size of the texture to create
  50133. * @param scene Define the scene the texture belongs to
  50134. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50135. * @param generateMipMaps Define if the texture should creates mip maps or not
  50136. */
  50137. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50138. private _loadJson;
  50139. /**
  50140. * Is the texture ready to be used ? (rendered at least once)
  50141. * @returns true if ready, otherwise, false.
  50142. */
  50143. isReady(): boolean;
  50144. /**
  50145. * Render the texture to its associated render target.
  50146. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50147. */
  50148. render(useCameraPostProcess?: boolean): void;
  50149. /**
  50150. * Update the list of dependant textures samplers in the shader.
  50151. */
  50152. updateTextures(): void;
  50153. /**
  50154. * Update the uniform values of the procedural texture in the shader.
  50155. */
  50156. updateShaderUniforms(): void;
  50157. /**
  50158. * Define if the texture animates or not.
  50159. */
  50160. animate: boolean;
  50161. }
  50162. }
  50163. declare module BABYLON {
  50164. /**
  50165. * Class used to generate noise procedural textures
  50166. */
  50167. class NoiseProceduralTexture extends ProceduralTexture {
  50168. private _time;
  50169. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50170. brightness: number;
  50171. /** Defines the number of octaves to process */
  50172. octaves: number;
  50173. /** Defines the level of persistence (0.8 by default) */
  50174. persistence: number;
  50175. /** Gets or sets animation speed factor (default is 1) */
  50176. animationSpeedFactor: number;
  50177. /**
  50178. * Creates a new NoiseProceduralTexture
  50179. * @param name defines the name fo the texture
  50180. * @param size defines the size of the texture (default is 256)
  50181. * @param scene defines the hosting scene
  50182. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50183. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50184. */
  50185. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50186. private _updateShaderUniforms;
  50187. protected _getDefines(): string;
  50188. /** Generate the current state of the procedural texture */
  50189. render(useCameraPostProcess?: boolean): void;
  50190. /**
  50191. * Serializes this noise procedural texture
  50192. * @returns a serialized noise procedural texture object
  50193. */
  50194. serialize(): any;
  50195. /**
  50196. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50197. * @param parsedTexture defines parsed texture data
  50198. * @param scene defines the current scene
  50199. * @param rootUrl defines the root URL containing noise procedural texture information
  50200. * @returns a parsed NoiseProceduralTexture
  50201. */
  50202. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50203. }
  50204. }
  50205. declare module BABYLON {
  50206. /**
  50207. * 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.
  50208. * This is the base class of any Procedural texture and contains most of the shareable code.
  50209. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50210. */
  50211. class ProceduralTexture extends Texture {
  50212. isCube: boolean;
  50213. /**
  50214. * Define if the texture is enabled or not (disabled texture will not render)
  50215. */
  50216. isEnabled: boolean;
  50217. /**
  50218. * Define if the texture must be cleared before rendering (default is true)
  50219. */
  50220. autoClear: boolean;
  50221. /**
  50222. * Callback called when the texture is generated
  50223. */
  50224. onGenerated: () => void;
  50225. /**
  50226. * Event raised when the texture is generated
  50227. */
  50228. onGeneratedObservable: Observable<ProceduralTexture>;
  50229. /** @hidden */
  50230. _generateMipMaps: boolean;
  50231. /** @hidden **/
  50232. _effect: Effect;
  50233. /** @hidden */
  50234. _textures: {
  50235. [key: string]: Texture;
  50236. };
  50237. private _size;
  50238. private _currentRefreshId;
  50239. private _refreshRate;
  50240. private _vertexBuffers;
  50241. private _indexBuffer;
  50242. private _uniforms;
  50243. private _samplers;
  50244. private _fragment;
  50245. private _floats;
  50246. private _ints;
  50247. private _floatsArrays;
  50248. private _colors3;
  50249. private _colors4;
  50250. private _vectors2;
  50251. private _vectors3;
  50252. private _matrices;
  50253. private _fallbackTexture;
  50254. private _fallbackTextureUsed;
  50255. private _engine;
  50256. private _cachedDefines;
  50257. private _contentUpdateId;
  50258. private _contentData;
  50259. /**
  50260. * Instantiates a new procedural texture.
  50261. * 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.
  50262. * This is the base class of any Procedural texture and contains most of the shareable code.
  50263. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50264. * @param name Define the name of the texture
  50265. * @param size Define the size of the texture to create
  50266. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50267. * @param scene Define the scene the texture belongs to
  50268. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50269. * @param generateMipMaps Define if the texture should creates mip maps or not
  50270. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50271. */
  50272. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50273. /**
  50274. * The effect that is created when initializing the post process.
  50275. * @returns The created effect corrisponding the the postprocess.
  50276. */
  50277. getEffect(): Effect;
  50278. /**
  50279. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50280. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50281. */
  50282. getContent(): Nullable<ArrayBufferView>;
  50283. private _createIndexBuffer;
  50284. /** @hidden */
  50285. _rebuild(): void;
  50286. /**
  50287. * Resets the texture in order to recreate its associated resources.
  50288. * This can be called in case of context loss
  50289. */
  50290. reset(): void;
  50291. protected _getDefines(): string;
  50292. /**
  50293. * Is the texture ready to be used ? (rendered at least once)
  50294. * @returns true if ready, otherwise, false.
  50295. */
  50296. isReady(): boolean;
  50297. /**
  50298. * Resets the refresh counter of the texture and start bak from scratch.
  50299. * Could be useful to regenerate the texture if it is setup to render only once.
  50300. */
  50301. resetRefreshCounter(): void;
  50302. /**
  50303. * Set the fragment shader to use in order to render the texture.
  50304. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50305. */
  50306. setFragment(fragment: any): void;
  50307. /**
  50308. * Define the refresh rate of the texture or the rendering frequency.
  50309. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50310. */
  50311. refreshRate: number;
  50312. /** @hidden */
  50313. _shouldRender(): boolean;
  50314. /**
  50315. * Get the size the texture is rendering at.
  50316. * @returns the size (texture is always squared)
  50317. */
  50318. getRenderSize(): number;
  50319. /**
  50320. * Resize the texture to new value.
  50321. * @param size Define the new size the texture should have
  50322. * @param generateMipMaps Define whether the new texture should create mip maps
  50323. */
  50324. resize(size: number, generateMipMaps: boolean): void;
  50325. private _checkUniform;
  50326. /**
  50327. * Set a texture in the shader program used to render.
  50328. * @param name Define the name of the uniform samplers as defined in the shader
  50329. * @param texture Define the texture to bind to this sampler
  50330. * @return the texture itself allowing "fluent" like uniform updates
  50331. */
  50332. setTexture(name: string, texture: Texture): ProceduralTexture;
  50333. /**
  50334. * Set a float in the shader.
  50335. * @param name Define the name of the uniform as defined in the shader
  50336. * @param value Define the value to give to the uniform
  50337. * @return the texture itself allowing "fluent" like uniform updates
  50338. */
  50339. setFloat(name: string, value: number): ProceduralTexture;
  50340. /**
  50341. * Set a int in the shader.
  50342. * @param name Define the name of the uniform as defined in the shader
  50343. * @param value Define the value to give to the uniform
  50344. * @return the texture itself allowing "fluent" like uniform updates
  50345. */
  50346. setInt(name: string, value: number): ProceduralTexture;
  50347. /**
  50348. * Set an array of floats in the shader.
  50349. * @param name Define the name of the uniform as defined in the shader
  50350. * @param value Define the value to give to the uniform
  50351. * @return the texture itself allowing "fluent" like uniform updates
  50352. */
  50353. setFloats(name: string, value: number[]): ProceduralTexture;
  50354. /**
  50355. * Set a vec3 in the shader from a Color3.
  50356. * @param name Define the name of the uniform as defined in the shader
  50357. * @param value Define the value to give to the uniform
  50358. * @return the texture itself allowing "fluent" like uniform updates
  50359. */
  50360. setColor3(name: string, value: Color3): ProceduralTexture;
  50361. /**
  50362. * Set a vec4 in the shader from a Color4.
  50363. * @param name Define the name of the uniform as defined in the shader
  50364. * @param value Define the value to give to the uniform
  50365. * @return the texture itself allowing "fluent" like uniform updates
  50366. */
  50367. setColor4(name: string, value: Color4): ProceduralTexture;
  50368. /**
  50369. * Set a vec2 in the shader from a Vector2.
  50370. * @param name Define the name of the uniform as defined in the shader
  50371. * @param value Define the value to give to the uniform
  50372. * @return the texture itself allowing "fluent" like uniform updates
  50373. */
  50374. setVector2(name: string, value: Vector2): ProceduralTexture;
  50375. /**
  50376. * Set a vec3 in the shader from a Vector3.
  50377. * @param name Define the name of the uniform as defined in the shader
  50378. * @param value Define the value to give to the uniform
  50379. * @return the texture itself allowing "fluent" like uniform updates
  50380. */
  50381. setVector3(name: string, value: Vector3): ProceduralTexture;
  50382. /**
  50383. * Set a mat4 in the shader from a MAtrix.
  50384. * @param name Define the name of the uniform as defined in the shader
  50385. * @param value Define the value to give to the uniform
  50386. * @return the texture itself allowing "fluent" like uniform updates
  50387. */
  50388. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50389. /**
  50390. * Render the texture to its associated render target.
  50391. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50392. */
  50393. render(useCameraPostProcess?: boolean): void;
  50394. /**
  50395. * Clone the texture.
  50396. * @returns the cloned texture
  50397. */
  50398. clone(): ProceduralTexture;
  50399. /**
  50400. * Dispose the texture and release its asoociated resources.
  50401. */
  50402. dispose(): void;
  50403. }
  50404. }
  50405. declare module BABYLON {
  50406. interface AbstractScene {
  50407. /**
  50408. * The list of procedural textures added to the scene
  50409. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50410. */
  50411. proceduralTextures: Array<ProceduralTexture>;
  50412. }
  50413. /**
  50414. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50415. * in a given scene.
  50416. */
  50417. class ProceduralTextureSceneComponent implements ISceneComponent {
  50418. /**
  50419. * The component name helpfull to identify the component in the list of scene components.
  50420. */
  50421. readonly name: string;
  50422. /**
  50423. * The scene the component belongs to.
  50424. */
  50425. scene: Scene;
  50426. /**
  50427. * Creates a new instance of the component for the given scene
  50428. * @param scene Defines the scene to register the component in
  50429. */
  50430. constructor(scene: Scene);
  50431. /**
  50432. * Registers the component in a given scene
  50433. */
  50434. register(): void;
  50435. /**
  50436. * Rebuilds the elements related to this component in case of
  50437. * context lost for instance.
  50438. */
  50439. rebuild(): void;
  50440. /**
  50441. * Disposes the component and the associated ressources.
  50442. */
  50443. dispose(): void;
  50444. private _beforeClear;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. /**
  50449. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50450. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50451. */
  50452. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50453. private _scene;
  50454. private _camerasToBeAttached;
  50455. /**
  50456. * ID of the sharpen post process,
  50457. */
  50458. private readonly SharpenPostProcessId;
  50459. /**
  50460. * @ignore
  50461. * ID of the image processing post process;
  50462. */
  50463. readonly ImageProcessingPostProcessId: string;
  50464. /**
  50465. * @ignore
  50466. * ID of the Fast Approximate Anti-Aliasing post process;
  50467. */
  50468. readonly FxaaPostProcessId: string;
  50469. /**
  50470. * ID of the chromatic aberration post process,
  50471. */
  50472. private readonly ChromaticAberrationPostProcessId;
  50473. /**
  50474. * ID of the grain post process
  50475. */
  50476. private readonly GrainPostProcessId;
  50477. /**
  50478. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50479. */
  50480. sharpen: SharpenPostProcess;
  50481. private _sharpenEffect;
  50482. private bloom;
  50483. /**
  50484. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50485. */
  50486. depthOfField: DepthOfFieldEffect;
  50487. /**
  50488. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50489. */
  50490. fxaa: FxaaPostProcess;
  50491. /**
  50492. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50493. */
  50494. imageProcessing: ImageProcessingPostProcess;
  50495. /**
  50496. * Chromatic aberration post process which will shift rgb colors in the image
  50497. */
  50498. chromaticAberration: ChromaticAberrationPostProcess;
  50499. private _chromaticAberrationEffect;
  50500. /**
  50501. * Grain post process which add noise to the image
  50502. */
  50503. grain: GrainPostProcess;
  50504. private _grainEffect;
  50505. /**
  50506. * Glow post process which adds a glow to emmisive areas of the image
  50507. */
  50508. private _glowLayer;
  50509. /**
  50510. * Animations which can be used to tweak settings over a period of time
  50511. */
  50512. animations: Animation[];
  50513. private _imageProcessingConfigurationObserver;
  50514. private _sharpenEnabled;
  50515. private _bloomEnabled;
  50516. private _depthOfFieldEnabled;
  50517. private _depthOfFieldBlurLevel;
  50518. private _fxaaEnabled;
  50519. private _imageProcessingEnabled;
  50520. private _defaultPipelineTextureType;
  50521. private _bloomScale;
  50522. private _chromaticAberrationEnabled;
  50523. private _grainEnabled;
  50524. private _buildAllowed;
  50525. /**
  50526. * Enable or disable the sharpen process from the pipeline
  50527. */
  50528. sharpenEnabled: boolean;
  50529. private _resizeObserver;
  50530. private _hardwareScaleLevel;
  50531. private _bloomKernel;
  50532. /**
  50533. * Specifies the size of the bloom blur kernel, relative to the final output size
  50534. */
  50535. bloomKernel: number;
  50536. /**
  50537. * Specifies the weight of the bloom in the final rendering
  50538. */
  50539. private _bloomWeight;
  50540. /**
  50541. * Specifies the luma threshold for the area that will be blurred by the bloom
  50542. */
  50543. private _bloomThreshold;
  50544. private _hdr;
  50545. /**
  50546. * The strength of the bloom.
  50547. */
  50548. bloomWeight: number;
  50549. /**
  50550. * The strength of the bloom.
  50551. */
  50552. bloomThreshold: number;
  50553. /**
  50554. * The scale of the bloom, lower value will provide better performance.
  50555. */
  50556. bloomScale: number;
  50557. /**
  50558. * Enable or disable the bloom from the pipeline
  50559. */
  50560. bloomEnabled: boolean;
  50561. private _rebuildBloom;
  50562. /**
  50563. * If the depth of field is enabled.
  50564. */
  50565. depthOfFieldEnabled: boolean;
  50566. /**
  50567. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50568. */
  50569. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50570. /**
  50571. * If the anti aliasing is enabled.
  50572. */
  50573. fxaaEnabled: boolean;
  50574. private _samples;
  50575. /**
  50576. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50577. */
  50578. samples: number;
  50579. /**
  50580. * If image processing is enabled.
  50581. */
  50582. imageProcessingEnabled: boolean;
  50583. /**
  50584. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50585. */
  50586. glowLayerEnabled: boolean;
  50587. /**
  50588. * Enable or disable the chromaticAberration process from the pipeline
  50589. */
  50590. chromaticAberrationEnabled: boolean;
  50591. /**
  50592. * Enable or disable the grain process from the pipeline
  50593. */
  50594. grainEnabled: boolean;
  50595. /**
  50596. * @constructor
  50597. * @param name - The rendering pipeline name (default: "")
  50598. * @param hdr - If high dynamic range textures should be used (default: true)
  50599. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50600. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50601. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50602. */
  50603. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50604. /**
  50605. * Force the compilation of the entire pipeline.
  50606. */
  50607. prepare(): void;
  50608. private _hasCleared;
  50609. private _prevPostProcess;
  50610. private _prevPrevPostProcess;
  50611. private _setAutoClearAndTextureSharing;
  50612. private _depthOfFieldSceneObserver;
  50613. private _buildPipeline;
  50614. private _disposePostProcesses;
  50615. /**
  50616. * Adds a camera to the pipeline
  50617. * @param camera the camera to be added
  50618. */
  50619. addCamera(camera: Camera): void;
  50620. /**
  50621. * Removes a camera from the pipeline
  50622. * @param camera the camera to remove
  50623. */
  50624. removeCamera(camera: Camera): void;
  50625. /**
  50626. * Dispose of the pipeline and stop all post processes
  50627. */
  50628. dispose(): void;
  50629. /**
  50630. * Serialize the rendering pipeline (Used when exporting)
  50631. * @returns the serialized object
  50632. */
  50633. serialize(): any;
  50634. /**
  50635. * Parse the serialized pipeline
  50636. * @param source Source pipeline.
  50637. * @param scene The scene to load the pipeline to.
  50638. * @param rootUrl The URL of the serialized pipeline.
  50639. * @returns An instantiated pipeline from the serialized object.
  50640. */
  50641. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50642. }
  50643. }
  50644. declare module BABYLON {
  50645. /**
  50646. * BABYLON.JS Chromatic Aberration GLSL Shader
  50647. * Author: Olivier Guyot
  50648. * Separates very slightly R, G and B colors on the edges of the screen
  50649. * Inspired by Francois Tarlier & Martins Upitis
  50650. */
  50651. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50652. /**
  50653. * @ignore
  50654. * The chromatic aberration PostProcess id in the pipeline
  50655. */
  50656. LensChromaticAberrationEffect: string;
  50657. /**
  50658. * @ignore
  50659. * The highlights enhancing PostProcess id in the pipeline
  50660. */
  50661. HighlightsEnhancingEffect: string;
  50662. /**
  50663. * @ignore
  50664. * The depth-of-field PostProcess id in the pipeline
  50665. */
  50666. LensDepthOfFieldEffect: string;
  50667. private _scene;
  50668. private _depthTexture;
  50669. private _grainTexture;
  50670. private _chromaticAberrationPostProcess;
  50671. private _highlightsPostProcess;
  50672. private _depthOfFieldPostProcess;
  50673. private _edgeBlur;
  50674. private _grainAmount;
  50675. private _chromaticAberration;
  50676. private _distortion;
  50677. private _highlightsGain;
  50678. private _highlightsThreshold;
  50679. private _dofDistance;
  50680. private _dofAperture;
  50681. private _dofDarken;
  50682. private _dofPentagon;
  50683. private _blurNoise;
  50684. /**
  50685. * @constructor
  50686. *
  50687. * Effect parameters are as follow:
  50688. * {
  50689. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50690. * edge_blur: number; // from 0 to x (1 for realism)
  50691. * distortion: number; // from 0 to x (1 for realism)
  50692. * grain_amount: number; // from 0 to 1
  50693. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50694. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50695. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50696. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50697. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50698. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50699. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50700. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50701. * }
  50702. * Note: if an effect parameter is unset, effect is disabled
  50703. *
  50704. * @param name The rendering pipeline name
  50705. * @param parameters - An object containing all parameters (see above)
  50706. * @param scene The scene linked to this pipeline
  50707. * @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)
  50708. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50709. */
  50710. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50711. /**
  50712. * Sets the amount of blur at the edges
  50713. * @param amount blur amount
  50714. */
  50715. setEdgeBlur(amount: number): void;
  50716. /**
  50717. * Sets edge blur to 0
  50718. */
  50719. disableEdgeBlur(): void;
  50720. /**
  50721. * Sets the amout of grain
  50722. * @param amount Amount of grain
  50723. */
  50724. setGrainAmount(amount: number): void;
  50725. /**
  50726. * Set grain amount to 0
  50727. */
  50728. disableGrain(): void;
  50729. /**
  50730. * Sets the chromatic aberration amount
  50731. * @param amount amount of chromatic aberration
  50732. */
  50733. setChromaticAberration(amount: number): void;
  50734. /**
  50735. * Sets chromatic aberration amount to 0
  50736. */
  50737. disableChromaticAberration(): void;
  50738. /**
  50739. * Sets the EdgeDistortion amount
  50740. * @param amount amount of EdgeDistortion
  50741. */
  50742. setEdgeDistortion(amount: number): void;
  50743. /**
  50744. * Sets edge distortion to 0
  50745. */
  50746. disableEdgeDistortion(): void;
  50747. /**
  50748. * Sets the FocusDistance amount
  50749. * @param amount amount of FocusDistance
  50750. */
  50751. setFocusDistance(amount: number): void;
  50752. /**
  50753. * Disables depth of field
  50754. */
  50755. disableDepthOfField(): void;
  50756. /**
  50757. * Sets the Aperture amount
  50758. * @param amount amount of Aperture
  50759. */
  50760. setAperture(amount: number): void;
  50761. /**
  50762. * Sets the DarkenOutOfFocus amount
  50763. * @param amount amount of DarkenOutOfFocus
  50764. */
  50765. setDarkenOutOfFocus(amount: number): void;
  50766. /**
  50767. * Creates a pentagon bokeh effect
  50768. */
  50769. enablePentagonBokeh(): void;
  50770. /**
  50771. * Disables the pentagon bokeh effect
  50772. */
  50773. disablePentagonBokeh(): void;
  50774. /**
  50775. * Enables noise blur
  50776. */
  50777. enableNoiseBlur(): void;
  50778. /**
  50779. * Disables noise blur
  50780. */
  50781. disableNoiseBlur(): void;
  50782. /**
  50783. * Sets the HighlightsGain amount
  50784. * @param amount amount of HighlightsGain
  50785. */
  50786. setHighlightsGain(amount: number): void;
  50787. /**
  50788. * Sets the HighlightsThreshold amount
  50789. * @param amount amount of HighlightsThreshold
  50790. */
  50791. setHighlightsThreshold(amount: number): void;
  50792. /**
  50793. * Disables highlights
  50794. */
  50795. disableHighlights(): void;
  50796. /**
  50797. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50798. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50799. */
  50800. dispose(disableDepthRender?: boolean): void;
  50801. private _createChromaticAberrationPostProcess;
  50802. private _createHighlightsPostProcess;
  50803. private _createDepthOfFieldPostProcess;
  50804. private _createGrainTexture;
  50805. }
  50806. }
  50807. declare module BABYLON {
  50808. /**
  50809. * Render pipeline to produce ssao effect
  50810. */
  50811. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50812. /**
  50813. * @ignore
  50814. * The PassPostProcess id in the pipeline that contains the original scene color
  50815. */
  50816. SSAOOriginalSceneColorEffect: string;
  50817. /**
  50818. * @ignore
  50819. * The SSAO PostProcess id in the pipeline
  50820. */
  50821. SSAORenderEffect: string;
  50822. /**
  50823. * @ignore
  50824. * The horizontal blur PostProcess id in the pipeline
  50825. */
  50826. SSAOBlurHRenderEffect: string;
  50827. /**
  50828. * @ignore
  50829. * The vertical blur PostProcess id in the pipeline
  50830. */
  50831. SSAOBlurVRenderEffect: string;
  50832. /**
  50833. * @ignore
  50834. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50835. */
  50836. SSAOCombineRenderEffect: string;
  50837. /**
  50838. * The output strength of the SSAO post-process. Default value is 1.0.
  50839. */
  50840. totalStrength: number;
  50841. /**
  50842. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50843. */
  50844. maxZ: number;
  50845. /**
  50846. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50847. */
  50848. minZAspect: number;
  50849. private _samples;
  50850. /**
  50851. * Number of samples used for the SSAO calculations. Default value is 8
  50852. */
  50853. samples: number;
  50854. private _textureSamples;
  50855. /**
  50856. * Number of samples to use for antialiasing
  50857. */
  50858. textureSamples: number;
  50859. /**
  50860. * Ratio object used for SSAO ratio and blur ratio
  50861. */
  50862. private _ratio;
  50863. /**
  50864. * Dynamically generated sphere sampler.
  50865. */
  50866. private _sampleSphere;
  50867. /**
  50868. * Blur filter offsets
  50869. */
  50870. private _samplerOffsets;
  50871. private _expensiveBlur;
  50872. /**
  50873. * If bilateral blur should be used
  50874. */
  50875. expensiveBlur: boolean;
  50876. /**
  50877. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50878. */
  50879. radius: number;
  50880. /**
  50881. * The base color of the SSAO post-process
  50882. * The final result is "base + ssao" between [0, 1]
  50883. */
  50884. base: number;
  50885. /**
  50886. * Support test.
  50887. */
  50888. static readonly IsSupported: boolean;
  50889. private _scene;
  50890. private _depthTexture;
  50891. private _normalTexture;
  50892. private _randomTexture;
  50893. private _originalColorPostProcess;
  50894. private _ssaoPostProcess;
  50895. private _blurHPostProcess;
  50896. private _blurVPostProcess;
  50897. private _ssaoCombinePostProcess;
  50898. private _firstUpdate;
  50899. /**
  50900. * @constructor
  50901. * @param name The rendering pipeline name
  50902. * @param scene The scene linked to this pipeline
  50903. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  50904. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50905. */
  50906. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50907. /**
  50908. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50909. */
  50910. dispose(disableGeometryBufferRenderer?: boolean): void;
  50911. private _createBlurPostProcess;
  50912. /** @hidden */
  50913. _rebuild(): void;
  50914. private _bits;
  50915. private _radicalInverse_VdC;
  50916. private _hammersley;
  50917. private _hemisphereSample_uniform;
  50918. private _generateHemisphere;
  50919. private _createSSAOPostProcess;
  50920. private _createSSAOCombinePostProcess;
  50921. private _createRandomTexture;
  50922. /**
  50923. * Serialize the rendering pipeline (Used when exporting)
  50924. * @returns the serialized object
  50925. */
  50926. serialize(): any;
  50927. /**
  50928. * Parse the serialized pipeline
  50929. * @param source Source pipeline.
  50930. * @param scene The scene to load the pipeline to.
  50931. * @param rootUrl The URL of the serialized pipeline.
  50932. * @returns An instantiated pipeline from the serialized object.
  50933. */
  50934. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50935. }
  50936. }
  50937. declare module BABYLON {
  50938. /**
  50939. * Render pipeline to produce ssao effect
  50940. */
  50941. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50942. /**
  50943. * @ignore
  50944. * The PassPostProcess id in the pipeline that contains the original scene color
  50945. */
  50946. SSAOOriginalSceneColorEffect: string;
  50947. /**
  50948. * @ignore
  50949. * The SSAO PostProcess id in the pipeline
  50950. */
  50951. SSAORenderEffect: string;
  50952. /**
  50953. * @ignore
  50954. * The horizontal blur PostProcess id in the pipeline
  50955. */
  50956. SSAOBlurHRenderEffect: string;
  50957. /**
  50958. * @ignore
  50959. * The vertical blur PostProcess id in the pipeline
  50960. */
  50961. SSAOBlurVRenderEffect: string;
  50962. /**
  50963. * @ignore
  50964. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50965. */
  50966. SSAOCombineRenderEffect: string;
  50967. /**
  50968. * The output strength of the SSAO post-process. Default value is 1.0.
  50969. */
  50970. totalStrength: number;
  50971. /**
  50972. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50973. */
  50974. radius: number;
  50975. /**
  50976. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50977. * Must not be equal to fallOff and superior to fallOff.
  50978. * Default value is 0.975
  50979. */
  50980. area: number;
  50981. /**
  50982. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50983. * Must not be equal to area and inferior to area.
  50984. * Default value is 0.0
  50985. */
  50986. fallOff: number;
  50987. /**
  50988. * The base color of the SSAO post-process
  50989. * The final result is "base + ssao" between [0, 1]
  50990. */
  50991. base: number;
  50992. private _scene;
  50993. private _depthTexture;
  50994. private _randomTexture;
  50995. private _originalColorPostProcess;
  50996. private _ssaoPostProcess;
  50997. private _blurHPostProcess;
  50998. private _blurVPostProcess;
  50999. private _ssaoCombinePostProcess;
  51000. private _firstUpdate;
  51001. /**
  51002. * @constructor
  51003. * @param name - The rendering pipeline name
  51004. * @param scene - The scene linked to this pipeline
  51005. * @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 }
  51006. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  51007. */
  51008. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51009. /**
  51010. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51011. */
  51012. dispose(disableDepthRender?: boolean): void;
  51013. private _createBlurPostProcess;
  51014. /** @hidden */
  51015. _rebuild(): void;
  51016. private _createSSAOPostProcess;
  51017. private _createSSAOCombinePostProcess;
  51018. private _createRandomTexture;
  51019. }
  51020. }
  51021. declare module BABYLON {
  51022. /**
  51023. * Standard rendering pipeline
  51024. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51025. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51026. */
  51027. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51028. /**
  51029. * Public members
  51030. */
  51031. /**
  51032. * Post-process which contains the original scene color before the pipeline applies all the effects
  51033. */
  51034. originalPostProcess: Nullable<PostProcess>;
  51035. /**
  51036. * Post-process used to down scale an image x4
  51037. */
  51038. downSampleX4PostProcess: Nullable<PostProcess>;
  51039. /**
  51040. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51041. */
  51042. brightPassPostProcess: Nullable<PostProcess>;
  51043. /**
  51044. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51045. */
  51046. blurHPostProcesses: PostProcess[];
  51047. /**
  51048. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51049. */
  51050. blurVPostProcesses: PostProcess[];
  51051. /**
  51052. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51053. */
  51054. textureAdderPostProcess: Nullable<PostProcess>;
  51055. /**
  51056. * Post-process used to create volumetric lighting effect
  51057. */
  51058. volumetricLightPostProcess: Nullable<PostProcess>;
  51059. /**
  51060. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51061. */
  51062. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51063. /**
  51064. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51065. */
  51066. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51067. /**
  51068. * Post-process used to merge the volumetric light effect and the real scene color
  51069. */
  51070. volumetricLightMergePostProces: Nullable<PostProcess>;
  51071. /**
  51072. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51073. */
  51074. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51075. /**
  51076. * Base post-process used to calculate the average luminance of the final image for HDR
  51077. */
  51078. luminancePostProcess: Nullable<PostProcess>;
  51079. /**
  51080. * Post-processes used to create down sample post-processes in order to get
  51081. * the average luminance of the final image for HDR
  51082. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51083. */
  51084. luminanceDownSamplePostProcesses: PostProcess[];
  51085. /**
  51086. * Post-process used to create a HDR effect (light adaptation)
  51087. */
  51088. hdrPostProcess: Nullable<PostProcess>;
  51089. /**
  51090. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51091. */
  51092. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51093. /**
  51094. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51095. */
  51096. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51097. /**
  51098. * Post-process used to merge the final HDR post-process and the real scene color
  51099. */
  51100. hdrFinalPostProcess: Nullable<PostProcess>;
  51101. /**
  51102. * Post-process used to create a lens flare effect
  51103. */
  51104. lensFlarePostProcess: Nullable<PostProcess>;
  51105. /**
  51106. * Post-process that merges the result of the lens flare post-process and the real scene color
  51107. */
  51108. lensFlareComposePostProcess: Nullable<PostProcess>;
  51109. /**
  51110. * Post-process used to create a motion blur effect
  51111. */
  51112. motionBlurPostProcess: Nullable<PostProcess>;
  51113. /**
  51114. * Post-process used to create a depth of field effect
  51115. */
  51116. depthOfFieldPostProcess: Nullable<PostProcess>;
  51117. /**
  51118. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51119. */
  51120. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51121. /**
  51122. * Represents the brightness threshold in order to configure the illuminated surfaces
  51123. */
  51124. brightThreshold: number;
  51125. /**
  51126. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51127. */
  51128. blurWidth: number;
  51129. /**
  51130. * Sets if the blur for highlighted surfaces must be only horizontal
  51131. */
  51132. horizontalBlur: boolean;
  51133. /**
  51134. * Sets the overall exposure used by the pipeline
  51135. */
  51136. exposure: number;
  51137. /**
  51138. * Texture used typically to simulate "dirty" on camera lens
  51139. */
  51140. lensTexture: Nullable<Texture>;
  51141. /**
  51142. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51143. */
  51144. volumetricLightCoefficient: number;
  51145. /**
  51146. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51147. */
  51148. volumetricLightPower: number;
  51149. /**
  51150. * Used the set the blur intensity to smooth the volumetric lights
  51151. */
  51152. volumetricLightBlurScale: number;
  51153. /**
  51154. * Light (spot or directional) used to generate the volumetric lights rays
  51155. * The source light must have a shadow generate so the pipeline can get its
  51156. * depth map
  51157. */
  51158. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51159. /**
  51160. * For eye adaptation, represents the minimum luminance the eye can see
  51161. */
  51162. hdrMinimumLuminance: number;
  51163. /**
  51164. * For eye adaptation, represents the decrease luminance speed
  51165. */
  51166. hdrDecreaseRate: number;
  51167. /**
  51168. * For eye adaptation, represents the increase luminance speed
  51169. */
  51170. hdrIncreaseRate: number;
  51171. /**
  51172. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51173. */
  51174. lensColorTexture: Nullable<Texture>;
  51175. /**
  51176. * The overall strengh for the lens flare effect
  51177. */
  51178. lensFlareStrength: number;
  51179. /**
  51180. * Dispersion coefficient for lens flare ghosts
  51181. */
  51182. lensFlareGhostDispersal: number;
  51183. /**
  51184. * Main lens flare halo width
  51185. */
  51186. lensFlareHaloWidth: number;
  51187. /**
  51188. * Based on the lens distortion effect, defines how much the lens flare result
  51189. * is distorted
  51190. */
  51191. lensFlareDistortionStrength: number;
  51192. /**
  51193. * Lens star texture must be used to simulate rays on the flares and is available
  51194. * in the documentation
  51195. */
  51196. lensStarTexture: Nullable<Texture>;
  51197. /**
  51198. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51199. * flare effect by taking account of the dirt texture
  51200. */
  51201. lensFlareDirtTexture: Nullable<Texture>;
  51202. /**
  51203. * Represents the focal length for the depth of field effect
  51204. */
  51205. depthOfFieldDistance: number;
  51206. /**
  51207. * Represents the blur intensity for the blurred part of the depth of field effect
  51208. */
  51209. depthOfFieldBlurWidth: number;
  51210. /**
  51211. * For motion blur, defines how much the image is blurred by the movement
  51212. */
  51213. motionStrength: number;
  51214. /**
  51215. * List of animations for the pipeline (IAnimatable implementation)
  51216. */
  51217. animations: Animation[];
  51218. /**
  51219. * Private members
  51220. */
  51221. private _scene;
  51222. private _currentDepthOfFieldSource;
  51223. private _basePostProcess;
  51224. private _hdrCurrentLuminance;
  51225. private _floatTextureType;
  51226. private _ratio;
  51227. private _bloomEnabled;
  51228. private _depthOfFieldEnabled;
  51229. private _vlsEnabled;
  51230. private _lensFlareEnabled;
  51231. private _hdrEnabled;
  51232. private _motionBlurEnabled;
  51233. private _fxaaEnabled;
  51234. private _motionBlurSamples;
  51235. private _volumetricLightStepsCount;
  51236. private _samples;
  51237. /**
  51238. * @ignore
  51239. * Specifies if the bloom pipeline is enabled
  51240. */
  51241. BloomEnabled: boolean;
  51242. /**
  51243. * @ignore
  51244. * Specifies if the depth of field pipeline is enabed
  51245. */
  51246. DepthOfFieldEnabled: boolean;
  51247. /**
  51248. * @ignore
  51249. * Specifies if the lens flare pipeline is enabed
  51250. */
  51251. LensFlareEnabled: boolean;
  51252. /**
  51253. * @ignore
  51254. * Specifies if the HDR pipeline is enabled
  51255. */
  51256. HDREnabled: boolean;
  51257. /**
  51258. * @ignore
  51259. * Specifies if the volumetric lights scattering effect is enabled
  51260. */
  51261. VLSEnabled: boolean;
  51262. /**
  51263. * @ignore
  51264. * Specifies if the motion blur effect is enabled
  51265. */
  51266. MotionBlurEnabled: boolean;
  51267. /**
  51268. * Specifies if anti-aliasing is enabled
  51269. */
  51270. fxaaEnabled: boolean;
  51271. /**
  51272. * Specifies the number of steps used to calculate the volumetric lights
  51273. * Typically in interval [50, 200]
  51274. */
  51275. volumetricLightStepsCount: number;
  51276. /**
  51277. * Specifies the number of samples used for the motion blur effect
  51278. * Typically in interval [16, 64]
  51279. */
  51280. motionBlurSamples: number;
  51281. /**
  51282. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51283. */
  51284. samples: number;
  51285. /**
  51286. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51287. * @constructor
  51288. * @param name The rendering pipeline name
  51289. * @param scene The scene linked to this pipeline
  51290. * @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)
  51291. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51292. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51293. */
  51294. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51295. private _buildPipeline;
  51296. private _createDownSampleX4PostProcess;
  51297. private _createBrightPassPostProcess;
  51298. private _createBlurPostProcesses;
  51299. private _createTextureAdderPostProcess;
  51300. private _createVolumetricLightPostProcess;
  51301. private _createLuminancePostProcesses;
  51302. private _createHdrPostProcess;
  51303. private _createLensFlarePostProcess;
  51304. private _createDepthOfFieldPostProcess;
  51305. private _createMotionBlurPostProcess;
  51306. private _getDepthTexture;
  51307. private _disposePostProcesses;
  51308. /**
  51309. * Dispose of the pipeline and stop all post processes
  51310. */
  51311. dispose(): void;
  51312. /**
  51313. * Serialize the rendering pipeline (Used when exporting)
  51314. * @returns the serialized object
  51315. */
  51316. serialize(): any;
  51317. /**
  51318. * Parse the serialized pipeline
  51319. * @param source Source pipeline.
  51320. * @param scene The scene to load the pipeline to.
  51321. * @param rootUrl The URL of the serialized pipeline.
  51322. * @returns An instantiated pipeline from the serialized object.
  51323. */
  51324. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51325. /**
  51326. * Luminance steps
  51327. */
  51328. static LuminanceSteps: number;
  51329. }
  51330. }