babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649
  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. /** @hidden */
  6806. class Collider {
  6807. /** Define if a collision was found */
  6808. collisionFound: boolean;
  6809. /**
  6810. * Define last intersection point in local space
  6811. */
  6812. intersectionPoint: Vector3;
  6813. /**
  6814. * Define last collided mesh
  6815. */
  6816. collidedMesh: Nullable<AbstractMesh>;
  6817. private _collisionPoint;
  6818. private _planeIntersectionPoint;
  6819. private _tempVector;
  6820. private _tempVector2;
  6821. private _tempVector3;
  6822. private _tempVector4;
  6823. private _edge;
  6824. private _baseToVertex;
  6825. private _destinationPoint;
  6826. private _slidePlaneNormal;
  6827. private _displacementVector;
  6828. /** @hidden */
  6829. _radius: Vector3;
  6830. /** @hidden */
  6831. _retry: number;
  6832. private _velocity;
  6833. private _basePoint;
  6834. private _epsilon;
  6835. /** @hidden */
  6836. _velocityWorldLength: number;
  6837. /** @hidden */
  6838. _basePointWorld: Vector3;
  6839. private _velocityWorld;
  6840. private _normalizedVelocity;
  6841. /** @hidden */
  6842. _initialVelocity: Vector3;
  6843. /** @hidden */
  6844. _initialPosition: Vector3;
  6845. private _nearestDistance;
  6846. private _collisionMask;
  6847. collisionMask: number;
  6848. /**
  6849. * Gets the plane normal used to compute the sliding response (in local space)
  6850. */
  6851. readonly slidePlaneNormal: Vector3;
  6852. /** @hidden */
  6853. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6854. /** @hidden */
  6855. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6856. /** @hidden */
  6857. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6858. /** @hidden */
  6859. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6860. /** @hidden */
  6861. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6862. /** @hidden */
  6863. _getResponse(pos: Vector3, vel: Vector3): void;
  6864. }
  6865. }
  6866. declare module BABYLON {
  6867. /** @hidden */
  6868. var CollisionWorker: string;
  6869. /** @hidden */
  6870. interface ICollisionCoordinator {
  6871. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6872. init(scene: Scene): void;
  6873. destroy(): void;
  6874. onMeshAdded(mesh: AbstractMesh): void;
  6875. onMeshUpdated(mesh: AbstractMesh): void;
  6876. onMeshRemoved(mesh: AbstractMesh): void;
  6877. onGeometryAdded(geometry: Geometry): void;
  6878. onGeometryUpdated(geometry: Geometry): void;
  6879. onGeometryDeleted(geometry: Geometry): void;
  6880. }
  6881. /** @hidden */
  6882. interface SerializedMesh {
  6883. id: string;
  6884. name: string;
  6885. uniqueId: number;
  6886. geometryId: Nullable<string>;
  6887. sphereCenter: Array<number>;
  6888. sphereRadius: number;
  6889. boxMinimum: Array<number>;
  6890. boxMaximum: Array<number>;
  6891. worldMatrixFromCache: any;
  6892. subMeshes: Array<SerializedSubMesh>;
  6893. checkCollisions: boolean;
  6894. }
  6895. /** @hidden */
  6896. interface SerializedSubMesh {
  6897. position: number;
  6898. verticesStart: number;
  6899. verticesCount: number;
  6900. indexStart: number;
  6901. indexCount: number;
  6902. hasMaterial: boolean;
  6903. sphereCenter: Array<number>;
  6904. sphereRadius: number;
  6905. boxMinimum: Array<number>;
  6906. boxMaximum: Array<number>;
  6907. }
  6908. /**
  6909. * Interface describing the value associated with a geometry.
  6910. * @hidden
  6911. */
  6912. interface SerializedGeometry {
  6913. /**
  6914. * Defines the unique ID of the geometry
  6915. */
  6916. id: string;
  6917. /**
  6918. * Defines the array containing the positions
  6919. */
  6920. positions: Float32Array;
  6921. /**
  6922. * Defines the array containing the indices
  6923. */
  6924. indices: Uint32Array;
  6925. /**
  6926. * Defines the array containing the normals
  6927. */
  6928. normals: Float32Array;
  6929. }
  6930. /** @hidden */
  6931. interface BabylonMessage {
  6932. taskType: WorkerTaskType;
  6933. payload: InitPayload | CollidePayload | UpdatePayload;
  6934. }
  6935. /** @hidden */
  6936. interface SerializedColliderToWorker {
  6937. position: Array<number>;
  6938. velocity: Array<number>;
  6939. radius: Array<number>;
  6940. }
  6941. /** Defines supported task for worker process */
  6942. enum WorkerTaskType {
  6943. /** Initialization */
  6944. INIT = 0,
  6945. /** Update of geometry */
  6946. UPDATE = 1,
  6947. /** Evaluate collision */
  6948. COLLIDE = 2
  6949. }
  6950. /** @hidden */
  6951. interface WorkerReply {
  6952. error: WorkerReplyType;
  6953. taskType: WorkerTaskType;
  6954. payload?: any;
  6955. }
  6956. /** @hidden */
  6957. interface CollisionReplyPayload {
  6958. newPosition: Array<number>;
  6959. collisionId: number;
  6960. collidedMeshUniqueId: number;
  6961. }
  6962. /** @hidden */
  6963. interface InitPayload {
  6964. }
  6965. /** @hidden */
  6966. interface CollidePayload {
  6967. collisionId: number;
  6968. collider: SerializedColliderToWorker;
  6969. maximumRetry: number;
  6970. excludedMeshUniqueId: Nullable<number>;
  6971. }
  6972. /** @hidden */
  6973. interface UpdatePayload {
  6974. updatedMeshes: {
  6975. [n: number]: SerializedMesh;
  6976. };
  6977. updatedGeometries: {
  6978. [s: string]: SerializedGeometry;
  6979. };
  6980. removedMeshes: Array<number>;
  6981. removedGeometries: Array<string>;
  6982. }
  6983. /** Defines kind of replies returned by worker */
  6984. enum WorkerReplyType {
  6985. /** Success */
  6986. SUCCESS = 0,
  6987. /** Unkown error */
  6988. UNKNOWN_ERROR = 1
  6989. }
  6990. /** @hidden */
  6991. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6992. private _scene;
  6993. private _scaledPosition;
  6994. private _scaledVelocity;
  6995. private _collisionsCallbackArray;
  6996. private _init;
  6997. private _runningUpdated;
  6998. private _worker;
  6999. private _addUpdateMeshesList;
  7000. private _addUpdateGeometriesList;
  7001. private _toRemoveMeshesArray;
  7002. private _toRemoveGeometryArray;
  7003. constructor();
  7004. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  7005. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  7006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7007. init(scene: Scene): void;
  7008. destroy(): void;
  7009. onMeshAdded(mesh: AbstractMesh): void;
  7010. onMeshUpdated: (transformNode: TransformNode) => void;
  7011. onMeshRemoved(mesh: AbstractMesh): void;
  7012. onGeometryAdded(geometry: Geometry): void;
  7013. onGeometryUpdated: (geometry: Geometry) => void;
  7014. onGeometryDeleted(geometry: Geometry): void;
  7015. private _afterRender;
  7016. private _onMessageFromWorker;
  7017. }
  7018. /** @hidden */
  7019. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  7020. private _scene;
  7021. private _scaledPosition;
  7022. private _scaledVelocity;
  7023. private _finalPosition;
  7024. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7025. init(scene: Scene): void;
  7026. destroy(): void;
  7027. onMeshAdded(mesh: AbstractMesh): void;
  7028. onMeshUpdated(mesh: AbstractMesh): void;
  7029. onMeshRemoved(mesh: AbstractMesh): void;
  7030. onGeometryAdded(geometry: Geometry): void;
  7031. onGeometryUpdated(geometry: Geometry): void;
  7032. onGeometryDeleted(geometry: Geometry): void;
  7033. private _collideWithWorld;
  7034. }
  7035. }
  7036. declare function importScripts(...urls: string[]): void;
  7037. declare const safePostMessage: any;
  7038. declare module BABYLON {
  7039. /** @hidden */
  7040. var WorkerIncluded: boolean;
  7041. /** @hidden */
  7042. class CollisionCache {
  7043. private _meshes;
  7044. private _geometries;
  7045. getMeshes(): {
  7046. [n: number]: SerializedMesh;
  7047. };
  7048. getGeometries(): {
  7049. [s: number]: SerializedGeometry;
  7050. };
  7051. getMesh(id: any): SerializedMesh;
  7052. addMesh(mesh: SerializedMesh): void;
  7053. removeMesh(uniqueId: number): void;
  7054. getGeometry(id: string): SerializedGeometry;
  7055. addGeometry(geometry: SerializedGeometry): void;
  7056. removeGeometry(id: string): void;
  7057. }
  7058. /** @hidden */
  7059. class CollideWorker {
  7060. collider: Collider;
  7061. private _collisionCache;
  7062. private finalPosition;
  7063. private collisionsScalingMatrix;
  7064. private collisionTranformationMatrix;
  7065. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7066. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7067. private checkCollision;
  7068. private processCollisionsForSubMeshes;
  7069. private collideForSubMesh;
  7070. private checkSubmeshCollision;
  7071. }
  7072. /** @hidden */
  7073. interface ICollisionDetector {
  7074. onInit(payload: InitPayload): void;
  7075. onUpdate(payload: UpdatePayload): void;
  7076. onCollision(payload: CollidePayload): void;
  7077. }
  7078. /** @hidden */
  7079. class CollisionDetectorTransferable implements ICollisionDetector {
  7080. private _collisionCache;
  7081. onInit(payload: InitPayload): void;
  7082. onUpdate(payload: UpdatePayload): void;
  7083. onCollision(payload: CollidePayload): void;
  7084. }
  7085. }
  7086. declare module BABYLON {
  7087. /**
  7088. * @hidden
  7089. */
  7090. class IntersectionInfo {
  7091. bu: Nullable<number>;
  7092. bv: Nullable<number>;
  7093. distance: number;
  7094. faceId: number;
  7095. subMeshId: number;
  7096. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7097. }
  7098. /**
  7099. * Information about the result of picking within a scene
  7100. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7101. */
  7102. class PickingInfo {
  7103. /**
  7104. * If the pick collided with an object
  7105. */
  7106. hit: boolean;
  7107. /**
  7108. * Distance away where the pick collided
  7109. */
  7110. distance: number;
  7111. /**
  7112. * The location of pick collision
  7113. */
  7114. pickedPoint: Nullable<Vector3>;
  7115. /**
  7116. * The mesh corresponding the the pick collision
  7117. */
  7118. pickedMesh: Nullable<AbstractMesh>;
  7119. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7120. bu: number;
  7121. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7122. bv: number;
  7123. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  7124. faceId: number;
  7125. /** Id of the the submesh that was picked */
  7126. subMeshId: number;
  7127. /** If a sprite was picked, this will be the sprite the pick collided with */
  7128. pickedSprite: Nullable<Sprite>;
  7129. /**
  7130. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7131. */
  7132. originMesh: Nullable<AbstractMesh>;
  7133. /**
  7134. * The ray that was used to perform the picking.
  7135. */
  7136. ray: Nullable<Ray>;
  7137. /**
  7138. * Gets the normal correspodning to the face the pick collided with
  7139. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7140. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7141. * @returns The normal correspodning to the face the pick collided with
  7142. */
  7143. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7144. /**
  7145. * Gets the texture coordinates of where the pick occured
  7146. * @returns the vector containing the coordnates of the texture
  7147. */
  7148. getTextureCoordinates(): Nullable<Vector2>;
  7149. }
  7150. }
  7151. declare module BABYLON {
  7152. /**
  7153. * Class used to store bounding box information
  7154. */
  7155. class BoundingBox implements ICullable {
  7156. /**
  7157. * Gets the 8 vectors representing the bounding box in local space
  7158. */
  7159. readonly vectors: Vector3[];
  7160. /**
  7161. * Gets the center of the bounding box in local space
  7162. */
  7163. readonly center: Vector3;
  7164. /**
  7165. * Gets the center of the bounding box in world space
  7166. */
  7167. readonly centerWorld: Vector3;
  7168. /**
  7169. * Gets the extend size in local space
  7170. */
  7171. readonly extendSize: Vector3;
  7172. /**
  7173. * Gets the extend size in world space
  7174. */
  7175. readonly extendSizeWorld: Vector3;
  7176. /**
  7177. * Gets the OBB (object bounding box) directions
  7178. */
  7179. readonly directions: Vector3[];
  7180. /**
  7181. * Gets the 8 vectors representing the bounding box in world space
  7182. */
  7183. readonly vectorsWorld: Vector3[];
  7184. /**
  7185. * Gets the minimum vector in world space
  7186. */
  7187. readonly minimumWorld: Vector3;
  7188. /**
  7189. * Gets the maximum vector in world space
  7190. */
  7191. readonly maximumWorld: Vector3;
  7192. /**
  7193. * Gets the minimum vector in local space
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * Gets the maximum vector in local space
  7198. */
  7199. readonly maximum: Vector3;
  7200. private _worldMatrix;
  7201. private static readonly TmpVector3;
  7202. /**
  7203. * @hidden
  7204. */
  7205. _tag: number;
  7206. /**
  7207. * Creates a new bounding box
  7208. * @param min defines the minimum vector (in local space)
  7209. * @param max defines the maximum vector (in local space)
  7210. * @param worldMatrix defines the new world matrix
  7211. */
  7212. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7213. /**
  7214. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7215. * @param min defines the new minimum vector (in local space)
  7216. * @param max defines the new maximum vector (in local space)
  7217. * @param worldMatrix defines the new world matrix
  7218. */
  7219. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7220. /**
  7221. * Scale the current bounding box by applying a scale factor
  7222. * @param factor defines the scale factor to apply
  7223. * @returns the current bounding box
  7224. */
  7225. scale(factor: number): BoundingBox;
  7226. /**
  7227. * Gets the world matrix of the bounding box
  7228. * @returns a matrix
  7229. */
  7230. getWorldMatrix(): DeepImmutable<Matrix>;
  7231. /** @hidden */
  7232. _update(world: DeepImmutable<Matrix>): void;
  7233. /**
  7234. * Tests if the bounding box is intersecting the frustum planes
  7235. * @param frustumPlanes defines the frustum planes to test
  7236. * @returns true if there is an intersection
  7237. */
  7238. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7239. /**
  7240. * Tests if the bounding box is entirely inside the frustum planes
  7241. * @param frustumPlanes defines the frustum planes to test
  7242. * @returns true if there is an inclusion
  7243. */
  7244. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7245. /**
  7246. * Tests if a point is inside the bounding box
  7247. * @param point defines the point to test
  7248. * @returns true if the point is inside the bounding box
  7249. */
  7250. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7251. /**
  7252. * Tests if the bounding box intersects with a bounding sphere
  7253. * @param sphere defines the sphere to test
  7254. * @returns true if there is an intersection
  7255. */
  7256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7257. /**
  7258. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7259. * @param min defines the min vector to use
  7260. * @param max defines the max vector to use
  7261. * @returns true if there is an intersection
  7262. */
  7263. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7264. /**
  7265. * Tests if two bounding boxes are intersections
  7266. * @param box0 defines the first box to test
  7267. * @param box1 defines the second box to test
  7268. * @returns true if there is an intersection
  7269. */
  7270. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7271. /**
  7272. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7273. * @param minPoint defines the minimum vector of the bounding box
  7274. * @param maxPoint defines the maximum vector of the bounding box
  7275. * @param sphereCenter defines the sphere center
  7276. * @param sphereRadius defines the sphere radius
  7277. * @returns true if there is an intersection
  7278. */
  7279. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7280. /**
  7281. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7282. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7283. * @param frustumPlanes defines the frustum planes to test
  7284. * @return true if there is an inclusion
  7285. */
  7286. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7287. /**
  7288. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7289. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7290. * @param frustumPlanes defines the frustum planes to test
  7291. * @return true if there is an intersection
  7292. */
  7293. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7294. }
  7295. }
  7296. declare module BABYLON {
  7297. /**
  7298. * Interface for cullable objects
  7299. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7300. */
  7301. interface ICullable {
  7302. /**
  7303. * Checks if the object or part of the object is in the frustum
  7304. * @param frustumPlanes Camera near/planes
  7305. * @returns true if the object is in frustum otherwise false
  7306. */
  7307. isInFrustum(frustumPlanes: Plane[]): boolean;
  7308. /**
  7309. * Checks if a cullable object (mesh...) is in the camera frustum
  7310. * Unlike isInFrustum this cheks the full bounding box
  7311. * @param frustumPlanes Camera near/planes
  7312. * @returns true if the object is in frustum otherwise false
  7313. */
  7314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7315. }
  7316. /**
  7317. * Info for a bounding data of a mesh
  7318. */
  7319. class BoundingInfo implements ICullable {
  7320. /**
  7321. * Bounding box for the mesh
  7322. */
  7323. readonly boundingBox: BoundingBox;
  7324. /**
  7325. * Bounding sphere for the mesh
  7326. */
  7327. readonly boundingSphere: BoundingSphere;
  7328. private _isLocked;
  7329. private static readonly TmpVector3;
  7330. /**
  7331. * Constructs bounding info
  7332. * @param minimum min vector of the bounding box/sphere
  7333. * @param maximum max vector of the bounding box/sphere
  7334. * @param worldMatrix defines the new world matrix
  7335. */
  7336. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7337. /**
  7338. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7339. * @param min defines the new minimum vector (in local space)
  7340. * @param max defines the new maximum vector (in local space)
  7341. * @param worldMatrix defines the new world matrix
  7342. */
  7343. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7344. /**
  7345. * min vector of the bounding box/sphere
  7346. */
  7347. readonly minimum: Vector3;
  7348. /**
  7349. * max vector of the bounding box/sphere
  7350. */
  7351. readonly maximum: Vector3;
  7352. /**
  7353. * If the info is locked and won't be updated to avoid perf overhead
  7354. */
  7355. isLocked: boolean;
  7356. /**
  7357. * Updates the bounding sphere and box
  7358. * @param world world matrix to be used to update
  7359. */
  7360. update(world: DeepImmutable<Matrix>): void;
  7361. /**
  7362. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7363. * @param center New center of the bounding info
  7364. * @param extend New extend of the bounding info
  7365. * @returns the current bounding info
  7366. */
  7367. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7368. /**
  7369. * Scale the current bounding info by applying a scale factor
  7370. * @param factor defines the scale factor to apply
  7371. * @returns the current bounding info
  7372. */
  7373. scale(factor: number): BoundingInfo;
  7374. /**
  7375. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7376. * @param frustumPlanes defines the frustum to test
  7377. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7378. * @returns true if the bounding info is in the frustum planes
  7379. */
  7380. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7381. /**
  7382. * Gets the world distance between the min and max points of the bounding box
  7383. */
  7384. readonly diagonalLength: number;
  7385. /**
  7386. * Checks if a cullable object (mesh...) is in the camera frustum
  7387. * Unlike isInFrustum this cheks the full bounding box
  7388. * @param frustumPlanes Camera near/planes
  7389. * @returns true if the object is in frustum otherwise false
  7390. */
  7391. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7392. /** @hidden */
  7393. _checkCollision(collider: Collider): boolean;
  7394. /**
  7395. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7396. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7397. * @param point the point to check intersection with
  7398. * @returns if the point intersects
  7399. */
  7400. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7401. /**
  7402. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7403. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7404. * @param boundingInfo the bounding info to check intersection with
  7405. * @param precise if the intersection should be done using OBB
  7406. * @returns if the bounding info intersects
  7407. */
  7408. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7409. }
  7410. }
  7411. declare module BABYLON {
  7412. /**
  7413. * Class used to store bounding sphere information
  7414. */
  7415. class BoundingSphere {
  7416. /**
  7417. * Gets the center of the bounding sphere in local space
  7418. */
  7419. readonly center: Vector3;
  7420. /**
  7421. * Radius of the bounding sphere in local space
  7422. */
  7423. radius: number;
  7424. /**
  7425. * Gets the center of the bounding sphere in world space
  7426. */
  7427. readonly centerWorld: Vector3;
  7428. /**
  7429. * Radius of the bounding sphere in world space
  7430. */
  7431. radiusWorld: number;
  7432. /**
  7433. * Gets the minimum vector in local space
  7434. */
  7435. readonly minimum: Vector3;
  7436. /**
  7437. * Gets the maximum vector in local space
  7438. */
  7439. readonly maximum: Vector3;
  7440. private _worldMatrix;
  7441. private static readonly TmpVector3;
  7442. /**
  7443. * Creates a new bounding sphere
  7444. * @param min defines the minimum vector (in local space)
  7445. * @param max defines the maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7449. /**
  7450. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7451. * @param min defines the new minimum vector (in local space)
  7452. * @param max defines the new maximum vector (in local space)
  7453. * @param worldMatrix defines the new world matrix
  7454. */
  7455. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7456. /**
  7457. * Scale the current bounding sphere by applying a scale factor
  7458. * @param factor defines the scale factor to apply
  7459. * @returns the current bounding box
  7460. */
  7461. scale(factor: number): BoundingSphere;
  7462. /**
  7463. * Gets the world matrix of the bounding box
  7464. * @returns a matrix
  7465. */
  7466. getWorldMatrix(): DeepImmutable<Matrix>;
  7467. /** @hidden */
  7468. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7469. /**
  7470. * Tests if the bounding sphere is intersecting the frustum planes
  7471. * @param frustumPlanes defines the frustum planes to test
  7472. * @returns true if there is an intersection
  7473. */
  7474. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7475. /**
  7476. * Tests if the bounding sphere center is in between the frustum planes.
  7477. * Used for optimistic fast inclusion.
  7478. * @param frustumPlanes defines the frustum planes to test
  7479. * @returns true if the sphere center is in between the frustum planes
  7480. */
  7481. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7482. /**
  7483. * Tests if a point is inside the bounding sphere
  7484. * @param point defines the point to test
  7485. * @returns true if the point is inside the bounding sphere
  7486. */
  7487. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7488. /**
  7489. * Checks if two sphere intersct
  7490. * @param sphere0 sphere 0
  7491. * @param sphere1 sphere 1
  7492. * @returns true if the speres intersect
  7493. */
  7494. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7495. }
  7496. }
  7497. declare module BABYLON {
  7498. /**
  7499. * Class representing a ray with position and direction
  7500. */
  7501. class Ray {
  7502. /** origin point */
  7503. origin: Vector3;
  7504. /** direction */
  7505. direction: Vector3;
  7506. /** length of the ray */
  7507. length: number;
  7508. private static readonly TmpVector3;
  7509. private _tmpRay;
  7510. /**
  7511. * Creates a new ray
  7512. * @param origin origin point
  7513. * @param direction direction
  7514. * @param length length of the ray
  7515. */
  7516. constructor(
  7517. /** origin point */
  7518. origin: Vector3,
  7519. /** direction */
  7520. direction: Vector3,
  7521. /** length of the ray */
  7522. length?: number);
  7523. /**
  7524. * Checks if the ray intersects a box
  7525. * @param minimum bound of the box
  7526. * @param maximum bound of the box
  7527. * @param intersectionTreshold extra extend to be added to the box in all direction
  7528. * @returns if the box was hit
  7529. */
  7530. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7531. /**
  7532. * Checks if the ray intersects a box
  7533. * @param box the bounding box to check
  7534. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7535. * @returns if the box was hit
  7536. */
  7537. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7538. /**
  7539. * If the ray hits a sphere
  7540. * @param sphere the bounding sphere to check
  7541. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7542. * @returns true if it hits the sphere
  7543. */
  7544. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7545. /**
  7546. * If the ray hits a triange
  7547. * @param vertex0 triangle vertex
  7548. * @param vertex1 triangle vertex
  7549. * @param vertex2 triangle vertex
  7550. * @returns intersection information if hit
  7551. */
  7552. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7553. /**
  7554. * Checks if ray intersects a plane
  7555. * @param plane the plane to check
  7556. * @returns the distance away it was hit
  7557. */
  7558. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7559. /**
  7560. * Checks if ray intersects a mesh
  7561. * @param mesh the mesh to check
  7562. * @param fastCheck if only the bounding box should checked
  7563. * @returns picking info of the intersecton
  7564. */
  7565. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7566. /**
  7567. * Checks if ray intersects a mesh
  7568. * @param meshes the meshes to check
  7569. * @param fastCheck if only the bounding box should checked
  7570. * @param results array to store result in
  7571. * @returns Array of picking infos
  7572. */
  7573. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7574. private _comparePickingInfo;
  7575. private static smallnum;
  7576. private static rayl;
  7577. /**
  7578. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7579. * @param sega the first point of the segment to test the intersection against
  7580. * @param segb the second point of the segment to test the intersection against
  7581. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7582. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7583. */
  7584. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7585. /**
  7586. * Update the ray from viewport position
  7587. * @param x position
  7588. * @param y y position
  7589. * @param viewportWidth viewport width
  7590. * @param viewportHeight viewport height
  7591. * @param world world matrix
  7592. * @param view view matrix
  7593. * @param projection projection matrix
  7594. * @returns this ray updated
  7595. */
  7596. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7597. /**
  7598. * Creates a ray with origin and direction of 0,0,0
  7599. * @returns the new ray
  7600. */
  7601. static Zero(): Ray;
  7602. /**
  7603. * Creates a new ray from screen space and viewport
  7604. * @param x position
  7605. * @param y y position
  7606. * @param viewportWidth viewport width
  7607. * @param viewportHeight viewport height
  7608. * @param world world matrix
  7609. * @param view view matrix
  7610. * @param projection projection matrix
  7611. * @returns new ray
  7612. */
  7613. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7614. /**
  7615. * 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
  7616. * transformed to the given world matrix.
  7617. * @param origin The origin point
  7618. * @param end The end point
  7619. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7620. * @returns the new ray
  7621. */
  7622. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7623. /**
  7624. * Transforms a ray by a matrix
  7625. * @param ray ray to transform
  7626. * @param matrix matrix to apply
  7627. * @returns the resulting new ray
  7628. */
  7629. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7630. /**
  7631. * Transforms a ray by a matrix
  7632. * @param ray ray to transform
  7633. * @param matrix matrix to apply
  7634. * @param result ray to store result in
  7635. */
  7636. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7637. }
  7638. }
  7639. /**
  7640. * Module Debug contains the (visual) components to debug a scene correctly
  7641. */
  7642. declare module BABYLON.Debug {
  7643. /**
  7644. * The Axes viewer will show 3 axes in a specific point in space
  7645. */
  7646. class AxesViewer {
  7647. private _xAxis;
  7648. private _yAxis;
  7649. private _zAxis;
  7650. private _scaleLinesFactor;
  7651. private _instanced;
  7652. /**
  7653. * Gets the hosting scene
  7654. */
  7655. scene: Scene;
  7656. /**
  7657. * Gets or sets a number used to scale line length
  7658. */
  7659. scaleLines: number;
  7660. /** Gets the node hierarchy used to render x-axis */
  7661. readonly xAxis: TransformNode;
  7662. /** Gets the node hierarchy used to render y-axis */
  7663. readonly yAxis: TransformNode;
  7664. /** Gets the node hierarchy used to render z-axis */
  7665. readonly zAxis: TransformNode;
  7666. /**
  7667. * Creates a new AxesViewer
  7668. * @param scene defines the hosting scene
  7669. * @param scaleLines defines a number used to scale line length (1 by default)
  7670. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  7671. * @param xAxis defines the node hierarchy used to render the x-axis
  7672. * @param yAxis defines the node hierarchy used to render the y-axis
  7673. * @param zAxis defines the node hierarchy used to render the z-axis
  7674. */
  7675. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  7676. /**
  7677. * Force the viewer to update
  7678. * @param position defines the position of the viewer
  7679. * @param xaxis defines the x axis of the viewer
  7680. * @param yaxis defines the y axis of the viewer
  7681. * @param zaxis defines the z axis of the viewer
  7682. */
  7683. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  7684. /**
  7685. * Creates an instance of this axes viewer.
  7686. * @returns a new axes viewer with instanced meshes
  7687. */
  7688. createInstance(): AxesViewer;
  7689. /** Releases resources */
  7690. dispose(): void;
  7691. private static _SetRenderingGroupId;
  7692. }
  7693. }
  7694. declare module BABYLON.Debug {
  7695. /**
  7696. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  7697. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  7698. */
  7699. class BoneAxesViewer extends AxesViewer {
  7700. /**
  7701. * Gets or sets the target mesh where to display the axes viewer
  7702. */
  7703. mesh: Nullable<Mesh>;
  7704. /**
  7705. * Gets or sets the target bone where to display the axes viewer
  7706. */
  7707. bone: Nullable<Bone>;
  7708. /** Gets current position */
  7709. pos: Vector3;
  7710. /** Gets direction of X axis */
  7711. xaxis: Vector3;
  7712. /** Gets direction of Y axis */
  7713. yaxis: Vector3;
  7714. /** Gets direction of Z axis */
  7715. zaxis: Vector3;
  7716. /**
  7717. * Creates a new BoneAxesViewer
  7718. * @param scene defines the hosting scene
  7719. * @param bone defines the target bone
  7720. * @param mesh defines the target mesh
  7721. * @param scaleLines defines a scaling factor for line length (1 by default)
  7722. */
  7723. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7724. /**
  7725. * Force the viewer to update
  7726. */
  7727. update(): void;
  7728. /** Releases resources */
  7729. dispose(): void;
  7730. }
  7731. }
  7732. declare module BABYLON {
  7733. /**
  7734. * Interface used to define scene explorer extensibility option
  7735. */
  7736. interface IExplorerExtensibilityOption {
  7737. /**
  7738. * Define the option label
  7739. */
  7740. label: string;
  7741. /**
  7742. * Defines the action to execute on click
  7743. */
  7744. action: (entity: any) => void;
  7745. }
  7746. /**
  7747. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  7748. */
  7749. interface IExplorerExtensibilityGroup {
  7750. /**
  7751. * Defines a predicate to test if a given type mut be extended
  7752. */
  7753. predicate: (entity: any) => boolean;
  7754. /**
  7755. * Gets the list of options added to a type
  7756. */
  7757. entries: IExplorerExtensibilityOption[];
  7758. }
  7759. /**
  7760. * Interface used to define the options to use to create the Inspector
  7761. */
  7762. interface IInspectorOptions {
  7763. /**
  7764. * Display in overlay mode (default: false)
  7765. */
  7766. overlay?: boolean;
  7767. /**
  7768. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  7769. */
  7770. globalRoot?: HTMLElement;
  7771. /**
  7772. * Display the Scene explorer
  7773. */
  7774. showExplorer?: boolean;
  7775. /**
  7776. * Display the property inspector
  7777. */
  7778. showInspector?: boolean;
  7779. /**
  7780. * Display in embed mode (both panes on the right)
  7781. */
  7782. embedMode?: boolean;
  7783. /**
  7784. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  7785. */
  7786. handleResize?: boolean;
  7787. /**
  7788. * Allow the panes to popup (default: true)
  7789. */
  7790. enablePopup?: boolean;
  7791. /**
  7792. * Allow the panes to be closed by users (default: true)
  7793. */
  7794. enableClose?: boolean;
  7795. /**
  7796. * Optional list of extensibility entries
  7797. */
  7798. explorerExtensibility?: IExplorerExtensibilityGroup[];
  7799. }
  7800. interface Scene {
  7801. /**
  7802. * @hidden
  7803. * Backing field
  7804. */
  7805. _debugLayer: DebugLayer;
  7806. /**
  7807. * Gets the debug layer (aka Inspector) associated with the scene
  7808. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7809. */
  7810. debugLayer: DebugLayer;
  7811. }
  7812. /**
  7813. * The debug layer (aka Inspector) is the go to tool in order to better understand
  7814. * what is happening in your scene
  7815. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7816. */
  7817. class DebugLayer {
  7818. /**
  7819. * Define the url to get the inspector script from.
  7820. * By default it uses the babylonjs CDN.
  7821. * @ignoreNaming
  7822. */
  7823. static InspectorURL: string;
  7824. private _scene;
  7825. private BJSINSPECTOR;
  7826. /**
  7827. * Observable triggered when a property is changed through the inspector.
  7828. */
  7829. onPropertyChangedObservable: Observable<{
  7830. object: any;
  7831. property: string;
  7832. value: any;
  7833. initialValue: any;
  7834. }>;
  7835. /**
  7836. * Instantiates a new debug layer.
  7837. * The debug layer (aka Inspector) is the go to tool in order to better understand
  7838. * what is happening in your scene
  7839. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7840. * @param scene Defines the scene to inspect
  7841. */
  7842. constructor(scene: Scene);
  7843. /** Creates the inspector window. */
  7844. private _createInspector;
  7845. /** Get the inspector from bundle or global */
  7846. private _getGlobalInspector;
  7847. /**
  7848. * Get if the inspector is visible or not.
  7849. * @returns true if visible otherwise, false
  7850. */
  7851. isVisible(): boolean;
  7852. /**
  7853. * Hide the inspector and close its window.
  7854. */
  7855. hide(): void;
  7856. /**
  7857. * Launch the debugLayer.
  7858. * @param config Define the configuration of the inspector
  7859. */
  7860. show(config?: IInspectorOptions): void;
  7861. }
  7862. }
  7863. declare module BABYLON.Debug {
  7864. /**
  7865. * Used to show the physics impostor around the specific mesh
  7866. */
  7867. class PhysicsViewer {
  7868. /** @hidden */
  7869. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7870. /** @hidden */
  7871. protected _meshes: Array<Nullable<AbstractMesh>>;
  7872. /** @hidden */
  7873. protected _scene: Nullable<Scene>;
  7874. /** @hidden */
  7875. protected _numMeshes: number;
  7876. /** @hidden */
  7877. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7878. private _renderFunction;
  7879. private _utilityLayer;
  7880. private _debugBoxMesh;
  7881. private _debugSphereMesh;
  7882. private _debugMaterial;
  7883. /**
  7884. * Creates a new PhysicsViewer
  7885. * @param scene defines the hosting scene
  7886. */
  7887. constructor(scene: Scene);
  7888. /** @hidden */
  7889. protected _updateDebugMeshes(): void;
  7890. /**
  7891. * Renders a specified physic impostor
  7892. * @param impostor defines the impostor to render
  7893. * @returns the new debug mesh used to render the impostor
  7894. */
  7895. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  7896. /**
  7897. * Hides a specified physic impostor
  7898. * @param impostor defines the impostor to hide
  7899. */
  7900. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7901. private _getDebugMaterial;
  7902. private _getDebugBoxMesh;
  7903. private _getDebugSphereMesh;
  7904. private _getDebugMesh;
  7905. /** Releases all resources */
  7906. dispose(): void;
  7907. }
  7908. }
  7909. declare module BABYLON {
  7910. /**
  7911. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  7912. * in order to better appreciate the issue one might have.
  7913. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  7914. */
  7915. class RayHelper {
  7916. /**
  7917. * Defines the ray we are currently tryin to visualize.
  7918. */
  7919. ray: Nullable<Ray>;
  7920. private _renderPoints;
  7921. private _renderLine;
  7922. private _renderFunction;
  7923. private _scene;
  7924. private _updateToMeshFunction;
  7925. private _attachedToMesh;
  7926. private _meshSpaceDirection;
  7927. private _meshSpaceOrigin;
  7928. /**
  7929. * Helper function to create a colored helper in a scene in one line.
  7930. * @param ray Defines the ray we are currently tryin to visualize
  7931. * @param scene Defines the scene the ray is used in
  7932. * @param color Defines the color we want to see the ray in
  7933. * @returns The newly created ray helper.
  7934. */
  7935. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7936. /**
  7937. * Instantiate a new ray helper.
  7938. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  7939. * in order to better appreciate the issue one might have.
  7940. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  7941. * @param ray Defines the ray we are currently tryin to visualize
  7942. */
  7943. constructor(ray: Ray);
  7944. /**
  7945. * Shows the ray we are willing to debug.
  7946. * @param scene Defines the scene the ray needs to be rendered in
  7947. * @param color Defines the color the ray needs to be rendered in
  7948. */
  7949. show(scene: Scene, color?: Color3): void;
  7950. /**
  7951. * Hides the ray we are debugging.
  7952. */
  7953. hide(): void;
  7954. private _render;
  7955. /**
  7956. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  7957. * @param mesh Defines the mesh we want the helper attached to
  7958. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  7959. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  7960. * @param length Defines the length of the ray
  7961. */
  7962. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7963. /**
  7964. * Detach the ray helper from the mesh it has previously been attached to.
  7965. */
  7966. detachFromMesh(): void;
  7967. private _updateToMesh;
  7968. /**
  7969. * Dispose the helper and release its associated resources.
  7970. */
  7971. dispose(): void;
  7972. }
  7973. }
  7974. declare module BABYLON.Debug {
  7975. /**
  7976. * Class used to render a debug view of a given skeleton
  7977. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7978. */
  7979. class SkeletonViewer {
  7980. /** defines the skeleton to render */
  7981. skeleton: Skeleton;
  7982. /** defines the mesh attached to the skeleton */
  7983. mesh: AbstractMesh;
  7984. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7985. autoUpdateBonesMatrices: boolean;
  7986. /** defines the rendering group id to use with the viewer */
  7987. renderingGroupId: number;
  7988. /** Gets or sets the color used to render the skeleton */
  7989. color: Color3;
  7990. private _scene;
  7991. private _debugLines;
  7992. private _debugMesh;
  7993. private _isEnabled;
  7994. private _renderFunction;
  7995. private _utilityLayer;
  7996. /**
  7997. * Returns the mesh used to render the bones
  7998. */
  7999. readonly debugMesh: Nullable<LinesMesh>;
  8000. /**
  8001. * Creates a new SkeletonViewer
  8002. * @param skeleton defines the skeleton to render
  8003. * @param mesh defines the mesh attached to the skeleton
  8004. * @param scene defines the hosting scene
  8005. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  8006. * @param renderingGroupId defines the rendering group id to use with the viewer
  8007. */
  8008. constructor(
  8009. /** defines the skeleton to render */
  8010. skeleton: Skeleton,
  8011. /** defines the mesh attached to the skeleton */
  8012. mesh: AbstractMesh, scene: Scene,
  8013. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8014. autoUpdateBonesMatrices?: boolean,
  8015. /** defines the rendering group id to use with the viewer */
  8016. renderingGroupId?: number);
  8017. /** Gets or sets a boolean indicating if the viewer is enabled */
  8018. isEnabled: boolean;
  8019. private _getBonePosition;
  8020. private _getLinesForBonesWithLength;
  8021. private _getLinesForBonesNoLength;
  8022. /** Update the viewer to sync with current skeleton state */
  8023. update(): void;
  8024. /** Release associated resources */
  8025. dispose(): void;
  8026. }
  8027. }
  8028. declare module BABYLON {
  8029. /**
  8030. * This represents an orbital type of camera.
  8031. *
  8032. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  8033. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  8034. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  8035. */
  8036. class ArcRotateCamera extends TargetCamera {
  8037. /**
  8038. * Defines the rotation angle of the camera along the longitudinal axis.
  8039. */
  8040. alpha: number;
  8041. /**
  8042. * Defines the rotation angle of the camera along the latitudinal axis.
  8043. */
  8044. beta: number;
  8045. /**
  8046. * Defines the radius of the camera from it s target point.
  8047. */
  8048. radius: number;
  8049. protected _target: Vector3;
  8050. protected _targetHost: Nullable<AbstractMesh>;
  8051. /**
  8052. * Defines the target point of the camera.
  8053. * The camera looks towards it form the radius distance.
  8054. */
  8055. target: Vector3;
  8056. /**
  8057. * Current inertia value on the longitudinal axis.
  8058. * The bigger this number the longer it will take for the camera to stop.
  8059. */
  8060. inertialAlphaOffset: number;
  8061. /**
  8062. * Current inertia value on the latitudinal axis.
  8063. * The bigger this number the longer it will take for the camera to stop.
  8064. */
  8065. inertialBetaOffset: number;
  8066. /**
  8067. * Current inertia value on the radius axis.
  8068. * The bigger this number the longer it will take for the camera to stop.
  8069. */
  8070. inertialRadiusOffset: number;
  8071. /**
  8072. * Minimum allowed angle on the longitudinal axis.
  8073. * This can help limiting how the Camera is able to move in the scene.
  8074. */
  8075. lowerAlphaLimit: Nullable<number>;
  8076. /**
  8077. * Maximum allowed angle on the longitudinal axis.
  8078. * This can help limiting how the Camera is able to move in the scene.
  8079. */
  8080. upperAlphaLimit: Nullable<number>;
  8081. /**
  8082. * Minimum allowed angle on the latitudinal axis.
  8083. * This can help limiting how the Camera is able to move in the scene.
  8084. */
  8085. lowerBetaLimit: number;
  8086. /**
  8087. * Maximum allowed angle on the latitudinal axis.
  8088. * This can help limiting how the Camera is able to move in the scene.
  8089. */
  8090. upperBetaLimit: number;
  8091. /**
  8092. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  8093. * This can help limiting how the Camera is able to move in the scene.
  8094. */
  8095. lowerRadiusLimit: Nullable<number>;
  8096. /**
  8097. * Maximum allowed distance of the camera to the target (The camera can not get further).
  8098. * This can help limiting how the Camera is able to move in the scene.
  8099. */
  8100. upperRadiusLimit: Nullable<number>;
  8101. /**
  8102. * Defines the current inertia value used during panning of the camera along the X axis.
  8103. */
  8104. inertialPanningX: number;
  8105. /**
  8106. * Defines the current inertia value used during panning of the camera along the Y axis.
  8107. */
  8108. inertialPanningY: number;
  8109. /**
  8110. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  8111. * Basically if your fingers moves away from more than this distance you will be considered
  8112. * in pinch mode.
  8113. */
  8114. pinchToPanMaxDistance: number;
  8115. /**
  8116. * Defines the maximum distance the camera can pan.
  8117. * This could help keeping the cammera always in your scene.
  8118. */
  8119. panningDistanceLimit: Nullable<number>;
  8120. /**
  8121. * Defines the target of the camera before paning.
  8122. */
  8123. panningOriginTarget: Vector3;
  8124. /**
  8125. * Defines the value of the inertia used during panning.
  8126. * 0 would mean stop inertia and one would mean no decelleration at all.
  8127. */
  8128. panningInertia: number;
  8129. /**
  8130. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  8131. */
  8132. angularSensibilityX: number;
  8133. /**
  8134. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  8135. */
  8136. angularSensibilityY: number;
  8137. /**
  8138. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  8139. */
  8140. pinchPrecision: number;
  8141. /**
  8142. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  8143. * It will be used instead of pinchDeltaPrecision if different from 0.
  8144. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  8145. */
  8146. pinchDeltaPercentage: number;
  8147. /**
  8148. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  8149. */
  8150. panningSensibility: number;
  8151. /**
  8152. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  8153. */
  8154. keysUp: number[];
  8155. /**
  8156. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  8157. */
  8158. keysDown: number[];
  8159. /**
  8160. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  8161. */
  8162. keysLeft: number[];
  8163. /**
  8164. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  8165. */
  8166. keysRight: number[];
  8167. /**
  8168. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  8169. */
  8170. wheelPrecision: number;
  8171. /**
  8172. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  8173. * It will be used instead of pinchDeltaPrecision if different from 0.
  8174. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  8175. */
  8176. wheelDeltaPercentage: number;
  8177. /**
  8178. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  8179. */
  8180. zoomOnFactor: number;
  8181. /**
  8182. * Defines a screen offset for the camera position.
  8183. */
  8184. targetScreenOffset: Vector2;
  8185. /**
  8186. * Allows the camera to be completely reversed.
  8187. * If false the camera can not arrive upside down.
  8188. */
  8189. allowUpsideDown: boolean;
  8190. /**
  8191. * Define if double tap/click is used to restore the previously saved state of the camera.
  8192. */
  8193. useInputToRestoreState: boolean;
  8194. /** @hidden */
  8195. _viewMatrix: Matrix;
  8196. /** @hidden */
  8197. _useCtrlForPanning: boolean;
  8198. /** @hidden */
  8199. _panningMouseButton: number;
  8200. /**
  8201. * Defines the inpute associated to the camera.
  8202. */
  8203. inputs: ArcRotateCameraInputsManager;
  8204. /** @hidden */
  8205. _reset: () => void;
  8206. /**
  8207. * Defines the allowed panning axis.
  8208. */
  8209. panningAxis: Vector3;
  8210. protected _localDirection: Vector3;
  8211. protected _transformedDirection: Vector3;
  8212. private _bouncingBehavior;
  8213. /**
  8214. * Gets the bouncing behavior of the camera if it has been enabled.
  8215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8216. */
  8217. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  8218. /**
  8219. * Defines if the bouncing behavior of the camera is enabled on the camera.
  8220. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8221. */
  8222. useBouncingBehavior: boolean;
  8223. private _framingBehavior;
  8224. /**
  8225. * Gets the framing behavior of the camera if it has been enabled.
  8226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8227. */
  8228. readonly framingBehavior: Nullable<FramingBehavior>;
  8229. /**
  8230. * Defines if the framing behavior of the camera is enabled on the camera.
  8231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8232. */
  8233. useFramingBehavior: boolean;
  8234. private _autoRotationBehavior;
  8235. /**
  8236. * Gets the auto rotation behavior of the camera if it has been enabled.
  8237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  8238. */
  8239. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  8240. /**
  8241. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  8242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  8243. */
  8244. useAutoRotationBehavior: boolean;
  8245. /**
  8246. * Observable triggered when the mesh target has been changed on the camera.
  8247. */
  8248. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  8249. /**
  8250. * Event raised when the camera is colliding with a mesh.
  8251. */
  8252. onCollide: (collidedMesh: AbstractMesh) => void;
  8253. /**
  8254. * Defines whether the camera should check collision with the objects oh the scene.
  8255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  8256. */
  8257. checkCollisions: boolean;
  8258. /**
  8259. * Defines the collision radius of the camera.
  8260. * This simulates a sphere around the camera.
  8261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8262. */
  8263. collisionRadius: Vector3;
  8264. protected _collider: Collider;
  8265. protected _previousPosition: Vector3;
  8266. protected _collisionVelocity: Vector3;
  8267. protected _newPosition: Vector3;
  8268. protected _previousAlpha: number;
  8269. protected _previousBeta: number;
  8270. protected _previousRadius: number;
  8271. protected _collisionTriggered: boolean;
  8272. protected _targetBoundingCenter: Nullable<Vector3>;
  8273. private _computationVector;
  8274. private _tempAxisVector;
  8275. private _tempAxisRotationMatrix;
  8276. /**
  8277. * Instantiates a new ArcRotateCamera in a given scene
  8278. * @param name Defines the name of the camera
  8279. * @param alpha Defines the camera rotation along the logitudinal axis
  8280. * @param beta Defines the camera rotation along the latitudinal axis
  8281. * @param radius Defines the camera distance from its target
  8282. * @param target Defines the camera target
  8283. * @param scene Defines the scene the camera belongs to
  8284. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8285. */
  8286. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8287. /** @hidden */
  8288. _initCache(): void;
  8289. /** @hidden */
  8290. _updateCache(ignoreParentClass?: boolean): void;
  8291. protected _getTargetPosition(): Vector3;
  8292. private _storedAlpha;
  8293. private _storedBeta;
  8294. private _storedRadius;
  8295. private _storedTarget;
  8296. /**
  8297. * Stores the current state of the camera (alpha, beta, radius and target)
  8298. * @returns the camera itself
  8299. */
  8300. storeState(): Camera;
  8301. /**
  8302. * @hidden
  8303. * Restored camera state. You must call storeState() first
  8304. */
  8305. _restoreStateValues(): boolean;
  8306. /** @hidden */
  8307. _isSynchronizedViewMatrix(): boolean;
  8308. /**
  8309. * Attached controls to the current camera.
  8310. * @param element Defines the element the controls should be listened from
  8311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8312. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  8313. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  8314. */
  8315. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  8316. /**
  8317. * Detach the current controls from the camera.
  8318. * The camera will stop reacting to inputs.
  8319. * @param element Defines the element to stop listening the inputs from
  8320. */
  8321. detachControl(element: HTMLElement): void;
  8322. /** @hidden */
  8323. _checkInputs(): void;
  8324. protected _checkLimits(): void;
  8325. /**
  8326. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  8327. */
  8328. rebuildAnglesAndRadius(): void;
  8329. /**
  8330. * Use a position to define the current camera related information like aplha, beta and radius
  8331. * @param position Defines the position to set the camera at
  8332. */
  8333. setPosition(position: Vector3): void;
  8334. /**
  8335. * Defines the target the camera should look at.
  8336. * This will automatically adapt alpha beta and radius to fit within the new target.
  8337. * @param target Defines the new target as a Vector or a mesh
  8338. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  8339. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  8340. */
  8341. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  8342. /** @hidden */
  8343. _getViewMatrix(): Matrix;
  8344. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  8345. /**
  8346. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  8347. * @param meshes Defines the mesh to zoom on
  8348. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  8349. */
  8350. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  8351. /**
  8352. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  8353. * The target will be changed but the radius
  8354. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  8355. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  8356. */
  8357. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  8358. min: Vector3;
  8359. max: Vector3;
  8360. distance: number;
  8361. }, doNotUpdateMaxZ?: boolean): void;
  8362. /**
  8363. * @override
  8364. * Override Camera.createRigCamera
  8365. */
  8366. createRigCamera(name: string, cameraIndex: number): Camera;
  8367. /**
  8368. * @hidden
  8369. * @override
  8370. * Override Camera._updateRigCameras
  8371. */
  8372. _updateRigCameras(): void;
  8373. /**
  8374. * Destroy the camera and release the current resources hold by it.
  8375. */
  8376. dispose(): void;
  8377. /**
  8378. * Gets the current object class name.
  8379. * @return the class name
  8380. */
  8381. getClassName(): string;
  8382. }
  8383. }
  8384. declare module BABYLON {
  8385. /**
  8386. * Default Inputs manager for the ArcRotateCamera.
  8387. * It groups all the default supported inputs for ease of use.
  8388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8389. */
  8390. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  8391. /**
  8392. * Instantiates a new ArcRotateCameraInputsManager.
  8393. * @param camera Defines the camera the inputs belong to
  8394. */
  8395. constructor(camera: ArcRotateCamera);
  8396. /**
  8397. * Add mouse wheel input support to the input manager.
  8398. * @returns the current input manager
  8399. */
  8400. addMouseWheel(): ArcRotateCameraInputsManager;
  8401. /**
  8402. * Add pointers input support to the input manager.
  8403. * @returns the current input manager
  8404. */
  8405. addPointers(): ArcRotateCameraInputsManager;
  8406. /**
  8407. * Add keyboard input support to the input manager.
  8408. * @returns the current input manager
  8409. */
  8410. addKeyboard(): ArcRotateCameraInputsManager;
  8411. /**
  8412. * Add orientation input support to the input manager.
  8413. * @returns the current input manager
  8414. */
  8415. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  8416. }
  8417. }
  8418. declare module BABYLON {
  8419. /**
  8420. * This is the base class of all the camera used in the application.
  8421. * @see http://doc.babylonjs.com/features/cameras
  8422. */
  8423. class Camera extends Node {
  8424. /**
  8425. * This is the default projection mode used by the cameras.
  8426. * It helps recreating a feeling of perspective and better appreciate depth.
  8427. * This is the best way to simulate real life cameras.
  8428. */
  8429. static readonly PERSPECTIVE_CAMERA: number;
  8430. /**
  8431. * This helps creating camera with an orthographic mode.
  8432. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  8433. */
  8434. static readonly ORTHOGRAPHIC_CAMERA: number;
  8435. /**
  8436. * This is the default FOV mode for perspective cameras.
  8437. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8438. */
  8439. static readonly FOVMODE_VERTICAL_FIXED: number;
  8440. /**
  8441. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8442. */
  8443. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8444. /**
  8445. * This specifies ther is no need for a camera rig.
  8446. * Basically only one eye is rendered corresponding to the camera.
  8447. */
  8448. static readonly RIG_MODE_NONE: number;
  8449. /**
  8450. * Simulates a camera Rig with one blue eye and one red eye.
  8451. * This can be use with 3d blue and red glasses.
  8452. */
  8453. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8454. /**
  8455. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  8456. */
  8457. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8458. /**
  8459. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  8460. */
  8461. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8462. /**
  8463. * Defines that both eyes of the camera will be rendered over under each other.
  8464. */
  8465. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8466. /**
  8467. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  8468. */
  8469. static readonly RIG_MODE_VR: number;
  8470. /**
  8471. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  8472. */
  8473. static readonly RIG_MODE_WEBVR: number;
  8474. /**
  8475. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  8476. */
  8477. static readonly RIG_MODE_CUSTOM: number;
  8478. /**
  8479. * Defines if by default attaching controls should prevent the default javascript event to continue.
  8480. */
  8481. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8482. /**
  8483. * @hidden
  8484. * Might be removed once multiview will be a thing
  8485. */
  8486. static UseAlternateWebVRRendering: boolean;
  8487. /**
  8488. * Define the input manager associated with the camera.
  8489. */
  8490. inputs: CameraInputsManager<Camera>;
  8491. /**
  8492. * Define the current local position of the camera in the scene
  8493. */
  8494. position: Vector3;
  8495. /**
  8496. * The vector the camera should consider as up.
  8497. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8498. */
  8499. upVector: Vector3;
  8500. /**
  8501. * Define the current limit on the left side for an orthographic camera
  8502. * In scene unit
  8503. */
  8504. orthoLeft: Nullable<number>;
  8505. /**
  8506. * Define the current limit on the right side for an orthographic camera
  8507. * In scene unit
  8508. */
  8509. orthoRight: Nullable<number>;
  8510. /**
  8511. * Define the current limit on the bottom side for an orthographic camera
  8512. * In scene unit
  8513. */
  8514. orthoBottom: Nullable<number>;
  8515. /**
  8516. * Define the current limit on the top side for an orthographic camera
  8517. * In scene unit
  8518. */
  8519. orthoTop: Nullable<number>;
  8520. /**
  8521. * Field Of View is set in Radians. (default is 0.8)
  8522. */
  8523. fov: number;
  8524. /**
  8525. * Define the minimum distance the camera can see from.
  8526. * This is important to note that the depth buffer are not infinite and the closer it starts
  8527. * the more your scene might encounter depth fighting issue.
  8528. */
  8529. minZ: number;
  8530. /**
  8531. * Define the maximum distance the camera can see to.
  8532. * This is important to note that the depth buffer are not infinite and the further it end
  8533. * the more your scene might encounter depth fighting issue.
  8534. */
  8535. maxZ: number;
  8536. /**
  8537. * Define the default inertia of the camera.
  8538. * This helps giving a smooth feeling to the camera movement.
  8539. */
  8540. inertia: number;
  8541. /**
  8542. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8543. */
  8544. mode: number;
  8545. /**
  8546. * Define wether the camera is intermediate.
  8547. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  8548. */
  8549. isIntermediate: boolean;
  8550. /**
  8551. * Define the viewport of the camera.
  8552. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8553. */
  8554. viewport: Viewport;
  8555. /**
  8556. * Restricts the camera to viewing objects with the same layerMask.
  8557. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8558. */
  8559. layerMask: number;
  8560. /**
  8561. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8562. */
  8563. fovMode: number;
  8564. /**
  8565. * Rig mode of the camera.
  8566. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8567. * This is normally controlled byt the camera themselves as internal use.
  8568. */
  8569. cameraRigMode: number;
  8570. /**
  8571. * Defines the distance between both "eyes" in case of a RIG
  8572. */
  8573. interaxialDistance: number;
  8574. /**
  8575. * Defines if stereoscopic rendering is done side by side or over under.
  8576. */
  8577. isStereoscopicSideBySide: boolean;
  8578. /**
  8579. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  8580. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8581. * else in the scene.
  8582. */
  8583. customRenderTargets: RenderTargetTexture[];
  8584. /**
  8585. * When set, the camera will render to this render target instead of the default canvas
  8586. */
  8587. outputRenderTarget: Nullable<RenderTargetTexture>;
  8588. /**
  8589. * Observable triggered when the camera view matrix has changed.
  8590. */
  8591. onViewMatrixChangedObservable: Observable<Camera>;
  8592. /**
  8593. * Observable triggered when the camera Projection matrix has changed.
  8594. */
  8595. onProjectionMatrixChangedObservable: Observable<Camera>;
  8596. /**
  8597. * Observable triggered when the inputs have been processed.
  8598. */
  8599. onAfterCheckInputsObservable: Observable<Camera>;
  8600. /**
  8601. * Observable triggered when reset has been called and applied to the camera.
  8602. */
  8603. onRestoreStateObservable: Observable<Camera>;
  8604. /** @hidden */
  8605. _cameraRigParams: any;
  8606. /** @hidden */
  8607. _rigCameras: Camera[];
  8608. /** @hidden */
  8609. _rigPostProcess: Nullable<PostProcess>;
  8610. protected _webvrViewMatrix: Matrix;
  8611. /** @hidden */
  8612. _skipRendering: boolean;
  8613. /** @hidden */
  8614. _alternateCamera: Camera;
  8615. /** @hidden */
  8616. _projectionMatrix: Matrix;
  8617. /** @hidden */
  8618. _postProcesses: Nullable<PostProcess>[];
  8619. /** @hidden */
  8620. _activeMeshes: SmartArray<AbstractMesh>;
  8621. protected _globalPosition: Vector3;
  8622. /** hidden */
  8623. _computedViewMatrix: Matrix;
  8624. private _doNotComputeProjectionMatrix;
  8625. private _transformMatrix;
  8626. private _frustumPlanes;
  8627. private _refreshFrustumPlanes;
  8628. private _storedFov;
  8629. private _stateStored;
  8630. /**
  8631. * Instantiates a new camera object.
  8632. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8633. * @see http://doc.babylonjs.com/features/cameras
  8634. * @param name Defines the name of the camera in the scene
  8635. * @param position Defines the position of the camera
  8636. * @param scene Defines the scene the camera belongs too
  8637. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8638. */
  8639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8640. /**
  8641. * Store current camera state (fov, position, etc..)
  8642. * @returns the camera
  8643. */
  8644. storeState(): Camera;
  8645. /**
  8646. * Restores the camera state values if it has been stored. You must call storeState() first
  8647. */
  8648. protected _restoreStateValues(): boolean;
  8649. /**
  8650. * Restored camera state. You must call storeState() first.
  8651. * @returns true if restored and false otherwise
  8652. */
  8653. restoreState(): boolean;
  8654. /**
  8655. * Gets the class name of the camera.
  8656. * @returns the class name
  8657. */
  8658. getClassName(): string;
  8659. /**
  8660. * Gets a string representation of the camera useful for debug purpose.
  8661. * @param fullDetails Defines that a more verboe level of logging is required
  8662. * @returns the string representation
  8663. */
  8664. toString(fullDetails?: boolean): string;
  8665. /**
  8666. * Gets the current world space position of the camera.
  8667. */
  8668. readonly globalPosition: Vector3;
  8669. /**
  8670. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8671. * @returns the active meshe list
  8672. */
  8673. getActiveMeshes(): SmartArray<AbstractMesh>;
  8674. /**
  8675. * Check wether a mesh is part of the current active mesh list of the camera
  8676. * @param mesh Defines the mesh to check
  8677. * @returns true if active, false otherwise
  8678. */
  8679. isActiveMesh(mesh: Mesh): boolean;
  8680. /**
  8681. * Is this camera ready to be used/rendered
  8682. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8683. * @return true if the camera is ready
  8684. */
  8685. isReady(completeCheck?: boolean): boolean;
  8686. /** @hidden */
  8687. _initCache(): void;
  8688. /** @hidden */
  8689. _updateCache(ignoreParentClass?: boolean): void;
  8690. /** @hidden */
  8691. _isSynchronized(): boolean;
  8692. /** @hidden */
  8693. _isSynchronizedViewMatrix(): boolean;
  8694. /** @hidden */
  8695. _isSynchronizedProjectionMatrix(): boolean;
  8696. /**
  8697. * Attach the input controls to a specific dom element to get the input from.
  8698. * @param element Defines the element the controls should be listened from
  8699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8700. */
  8701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8702. /**
  8703. * Detach the current controls from the specified dom element.
  8704. * @param element Defines the element to stop listening the inputs from
  8705. */
  8706. detachControl(element: HTMLElement): void;
  8707. /**
  8708. * Update the camera state according to the different inputs gathered during the frame.
  8709. */
  8710. update(): void;
  8711. /** @hidden */
  8712. _checkInputs(): void;
  8713. /** @hidden */
  8714. readonly rigCameras: Camera[];
  8715. /**
  8716. * Gets the post process used by the rig cameras
  8717. */
  8718. readonly rigPostProcess: Nullable<PostProcess>;
  8719. /**
  8720. * Internal, gets the first post proces.
  8721. * @returns the first post process to be run on this camera.
  8722. */
  8723. _getFirstPostProcess(): Nullable<PostProcess>;
  8724. private _cascadePostProcessesToRigCams;
  8725. /**
  8726. * Attach a post process to the camera.
  8727. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8728. * @param postProcess The post process to attach to the camera
  8729. * @param insertAt The position of the post process in case several of them are in use in the scene
  8730. * @returns the position the post process has been inserted at
  8731. */
  8732. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8733. /**
  8734. * Detach a post process to the camera.
  8735. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8736. * @param postProcess The post process to detach from the camera
  8737. */
  8738. detachPostProcess(postProcess: PostProcess): void;
  8739. /**
  8740. * Gets the current world matrix of the camera
  8741. */
  8742. getWorldMatrix(): Matrix;
  8743. /** @hidden */
  8744. protected _getViewMatrix(): Matrix;
  8745. /**
  8746. * Gets the current view matrix of the camera.
  8747. * @param force forces the camera to recompute the matrix without looking at the cached state
  8748. * @returns the view matrix
  8749. */
  8750. getViewMatrix(force?: boolean): Matrix;
  8751. /**
  8752. * Freeze the projection matrix.
  8753. * It will prevent the cache check of the camera projection compute and can speed up perf
  8754. * if no parameter of the camera are meant to change
  8755. * @param projection Defines manually a projection if necessary
  8756. */
  8757. freezeProjectionMatrix(projection?: Matrix): void;
  8758. /**
  8759. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8760. */
  8761. unfreezeProjectionMatrix(): void;
  8762. /**
  8763. * Gets the current projection matrix of the camera.
  8764. * @param force forces the camera to recompute the matrix without looking at the cached state
  8765. * @returns the projection matrix
  8766. */
  8767. getProjectionMatrix(force?: boolean): Matrix;
  8768. /**
  8769. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8770. * @returns a Matrix
  8771. */
  8772. getTransformationMatrix(): Matrix;
  8773. private _updateFrustumPlanes;
  8774. /**
  8775. * Checks if a cullable object (mesh...) is in the camera frustum
  8776. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8777. * @param target The object to check
  8778. * @returns true if the object is in frustum otherwise false
  8779. */
  8780. isInFrustum(target: ICullable): boolean;
  8781. /**
  8782. * Checks if a cullable object (mesh...) is in the camera frustum
  8783. * Unlike isInFrustum this cheks the full bounding box
  8784. * @param target The object to check
  8785. * @returns true if the object is in frustum otherwise false
  8786. */
  8787. isCompletelyInFrustum(target: ICullable): boolean;
  8788. /**
  8789. * Gets a ray in the forward direction from the camera.
  8790. * @param length Defines the length of the ray to create
  8791. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8792. * @param origin Defines the start point of the ray which defaults to the camera position
  8793. * @returns the forward ray
  8794. */
  8795. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8796. /**
  8797. * Releases resources associated with this node.
  8798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8800. */
  8801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8802. /**
  8803. * Gets the left camera of a rig setup in case of Rigged Camera
  8804. */
  8805. readonly leftCamera: Nullable<FreeCamera>;
  8806. /**
  8807. * Gets the right camera of a rig setup in case of Rigged Camera
  8808. */
  8809. readonly rightCamera: Nullable<FreeCamera>;
  8810. /**
  8811. * Gets the left camera target of a rig setup in case of Rigged Camera
  8812. * @returns the target position
  8813. */
  8814. getLeftTarget(): Nullable<Vector3>;
  8815. /**
  8816. * Gets the right camera target of a rig setup in case of Rigged Camera
  8817. * @returns the target position
  8818. */
  8819. getRightTarget(): Nullable<Vector3>;
  8820. /**
  8821. * @hidden
  8822. */
  8823. setCameraRigMode(mode: number, rigParams: any): void;
  8824. private _getVRProjectionMatrix;
  8825. protected _updateCameraRotationMatrix(): void;
  8826. protected _updateWebVRCameraRotationMatrix(): void;
  8827. /**
  8828. * This function MUST be overwritten by the different WebVR cameras available.
  8829. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8830. */
  8831. protected _getWebVRProjectionMatrix(): Matrix;
  8832. /**
  8833. * This function MUST be overwritten by the different WebVR cameras available.
  8834. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8835. */
  8836. protected _getWebVRViewMatrix(): Matrix;
  8837. /** @hidden */
  8838. setCameraRigParameter(name: string, value: any): void;
  8839. /**
  8840. * needs to be overridden by children so sub has required properties to be copied
  8841. * @hidden
  8842. */
  8843. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8844. /**
  8845. * May need to be overridden by children
  8846. * @hidden
  8847. */
  8848. _updateRigCameras(): void;
  8849. /** @hidden */
  8850. _setupInputs(): void;
  8851. /**
  8852. * Serialiaze the camera setup to a json represention
  8853. * @returns the JSON representation
  8854. */
  8855. serialize(): any;
  8856. /**
  8857. * Clones the current camera.
  8858. * @param name The cloned camera name
  8859. * @returns the cloned camera
  8860. */
  8861. clone(name: string): Camera;
  8862. /**
  8863. * Gets the direction of the camera relative to a given local axis.
  8864. * @param localAxis Defines the reference axis to provide a relative direction.
  8865. * @return the direction
  8866. */
  8867. getDirection(localAxis: Vector3): Vector3;
  8868. /**
  8869. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8870. * @param localAxis Defines the reference axis to provide a relative direction.
  8871. * @param result Defines the vector to store the result in
  8872. */
  8873. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8874. /**
  8875. * Gets a camera constructor for a given camera type
  8876. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8877. * @param name The name of the camera the result will be able to instantiate
  8878. * @param scene The scene the result will construct the camera in
  8879. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8880. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8881. * @returns a factory method to construc the camera
  8882. */
  8883. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8884. /**
  8885. * Compute the world matrix of the camera.
  8886. * @returns the camera workd matrix
  8887. */
  8888. computeWorldMatrix(): Matrix;
  8889. /**
  8890. * Parse a JSON and creates the camera from the parsed information
  8891. * @param parsedCamera The JSON to parse
  8892. * @param scene The scene to instantiate the camera in
  8893. * @returns the newly constructed camera
  8894. */
  8895. static Parse(parsedCamera: any, scene: Scene): Camera;
  8896. }
  8897. }
  8898. declare module BABYLON {
  8899. /**
  8900. * @ignore
  8901. * This is a list of all the different input types that are available in the application.
  8902. * Fo instance: ArcRotateCameraGamepadInput...
  8903. */
  8904. var CameraInputTypes: {};
  8905. /**
  8906. * This is the contract to implement in order to create a new input class.
  8907. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8908. */
  8909. interface ICameraInput<TCamera extends Camera> {
  8910. /**
  8911. * Defines the camera the input is attached to.
  8912. */
  8913. camera: Nullable<TCamera>;
  8914. /**
  8915. * Gets the class name of the current intput.
  8916. * @returns the class name
  8917. */
  8918. getClassName(): string;
  8919. /**
  8920. * Get the friendly name associated with the input class.
  8921. * @returns the input friendly name
  8922. */
  8923. getSimpleName(): string;
  8924. /**
  8925. * Attach the input controls to a specific dom element to get the input from.
  8926. * @param element Defines the element the controls should be listened from
  8927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8928. */
  8929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8930. /**
  8931. * Detach the current controls from the specified dom element.
  8932. * @param element Defines the element to stop listening the inputs from
  8933. */
  8934. detachControl(element: Nullable<HTMLElement>): void;
  8935. /**
  8936. * Update the current camera state depending on the inputs that have been used this frame.
  8937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8938. */
  8939. checkInputs?: () => void;
  8940. }
  8941. /**
  8942. * Represents a map of input types to input instance or input index to input instance.
  8943. */
  8944. interface CameraInputsMap<TCamera extends Camera> {
  8945. /**
  8946. * Accessor to the input by input type.
  8947. */
  8948. [name: string]: ICameraInput<TCamera>;
  8949. /**
  8950. * Accessor to the input by input index.
  8951. */
  8952. [idx: number]: ICameraInput<TCamera>;
  8953. }
  8954. /**
  8955. * This represents the input manager used within a camera.
  8956. * It helps dealing with all the different kind of input attached to a camera.
  8957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8958. */
  8959. class CameraInputsManager<TCamera extends Camera> {
  8960. /**
  8961. * Defines the list of inputs attahed to the camera.
  8962. */
  8963. attached: CameraInputsMap<TCamera>;
  8964. /**
  8965. * Defines the dom element the camera is collecting inputs from.
  8966. * This is null if the controls have not been attached.
  8967. */
  8968. attachedElement: Nullable<HTMLElement>;
  8969. /**
  8970. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8971. */
  8972. noPreventDefault: boolean;
  8973. /**
  8974. * Defined the camera the input manager belongs to.
  8975. */
  8976. camera: TCamera;
  8977. /**
  8978. * Update the current camera state depending on the inputs that have been used this frame.
  8979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8980. */
  8981. checkInputs: () => void;
  8982. /**
  8983. * Instantiate a new Camera Input Manager.
  8984. * @param camera Defines the camera the input manager blongs to
  8985. */
  8986. constructor(camera: TCamera);
  8987. /**
  8988. * Add an input method to a camera
  8989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8990. * @param input camera input method
  8991. */
  8992. add(input: ICameraInput<TCamera>): void;
  8993. /**
  8994. * Remove a specific input method from a camera
  8995. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8996. * @param inputToRemove camera input method
  8997. */
  8998. remove(inputToRemove: ICameraInput<TCamera>): void;
  8999. /**
  9000. * Remove a specific input type from a camera
  9001. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9002. * @param inputType the type of the input to remove
  9003. */
  9004. removeByType(inputType: string): void;
  9005. private _addCheckInputs;
  9006. /**
  9007. * Attach the input controls to the currently attached dom element to listen the events from.
  9008. * @param input Defines the input to attach
  9009. */
  9010. attachInput(input: ICameraInput<TCamera>): void;
  9011. /**
  9012. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9013. * @param element Defines the dom element to collect the events from
  9014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9015. */
  9016. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9017. /**
  9018. * Detach the current manager inputs controls from a specific dom element.
  9019. * @param element Defines the dom element to collect the events from
  9020. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9021. */
  9022. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9023. /**
  9024. * Rebuild the dynamic inputCheck function from the current list of
  9025. * defined inputs in the manager.
  9026. */
  9027. rebuildInputCheck(): void;
  9028. /**
  9029. * Remove all attached input methods from a camera
  9030. */
  9031. clear(): void;
  9032. /**
  9033. * Serialize the current input manager attached to a camera.
  9034. * This ensures than once parsed,
  9035. * the input associated to the camera will be identical to the current ones
  9036. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9037. */
  9038. serialize(serializedCamera: any): void;
  9039. /**
  9040. * Parses an input manager serialized JSON to restore the previous list of inputs
  9041. * and states associated to a camera.
  9042. * @param parsedCamera Defines the JSON to parse
  9043. */
  9044. parse(parsedCamera: any): void;
  9045. }
  9046. }
  9047. declare module BABYLON {
  9048. /**
  9049. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  9050. * being tilted forward or back and left or right.
  9051. */
  9052. class DeviceOrientationCamera extends FreeCamera {
  9053. private _initialQuaternion;
  9054. private _quaternionCache;
  9055. /**
  9056. * Creates a new device orientation camera
  9057. * @param name The name of the camera
  9058. * @param position The start position camera
  9059. * @param scene The scene the camera belongs to
  9060. */
  9061. constructor(name: string, position: Vector3, scene: Scene);
  9062. /**
  9063. * Gets the current instance class name ("DeviceOrientationCamera").
  9064. * This helps avoiding instanceof at run time.
  9065. * @returns the class name
  9066. */
  9067. getClassName(): string;
  9068. /**
  9069. * @hidden
  9070. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  9071. */
  9072. _checkInputs(): void;
  9073. /**
  9074. * Reset the camera to its default orientation on the specified axis only.
  9075. * @param axis The axis to reset
  9076. */
  9077. resetToCurrentRotation(axis?: Axis): void;
  9078. }
  9079. }
  9080. declare module BABYLON {
  9081. /**
  9082. * This is a flying camera, designed for 3D movement and rotation in all directions,
  9083. * such as in a 3D Space Shooter or a Flight Simulator.
  9084. */
  9085. class FlyCamera extends TargetCamera {
  9086. /**
  9087. * Define the collision ellipsoid of the camera.
  9088. * This is helpful for simulating a camera body, like a player's body.
  9089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  9090. */
  9091. ellipsoid: Vector3;
  9092. /**
  9093. * Define an offset for the position of the ellipsoid around the camera.
  9094. * This can be helpful if the camera is attached away from the player's body center,
  9095. * such as at its head.
  9096. */
  9097. ellipsoidOffset: Vector3;
  9098. /**
  9099. * Enable or disable collisions of the camera with the rest of the scene objects.
  9100. */
  9101. checkCollisions: boolean;
  9102. /**
  9103. * Enable or disable gravity on the camera.
  9104. */
  9105. applyGravity: boolean;
  9106. /**
  9107. * Define the current direction the camera is moving to.
  9108. */
  9109. cameraDirection: Vector3;
  9110. /**
  9111. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  9112. * This overrides and empties cameraRotation.
  9113. */
  9114. rotationQuaternion: BABYLON.Quaternion;
  9115. /**
  9116. * Track Roll to maintain the wanted Rolling when looking around.
  9117. */
  9118. _trackRoll: number;
  9119. /**
  9120. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  9121. */
  9122. rollCorrect: number;
  9123. /**
  9124. * Mimic a banked turn, Rolling the camera when Yawing.
  9125. * It's recommended to use rollCorrect = 10 for faster banking correction.
  9126. */
  9127. bankedTurn: boolean;
  9128. /**
  9129. * Limit in radians for how much Roll banking will add. (Default: 90°)
  9130. */
  9131. bankedTurnLimit: number;
  9132. /**
  9133. * Value of 0 disables the banked Roll.
  9134. * Value of 1 is equal to the Yaw angle in radians.
  9135. */
  9136. bankedTurnMultiplier: number;
  9137. /**
  9138. * The inputs manager loads all the input sources, such as keyboard and mouse.
  9139. */
  9140. inputs: FlyCameraInputsManager;
  9141. /**
  9142. * Gets the input sensibility for mouse input.
  9143. * Higher values reduce sensitivity.
  9144. */
  9145. /**
  9146. * Sets the input sensibility for a mouse input.
  9147. * Higher values reduce sensitivity.
  9148. */
  9149. angularSensibility: number;
  9150. /**
  9151. * Get the keys for camera movement forward.
  9152. */
  9153. /**
  9154. * Set the keys for camera movement forward.
  9155. */
  9156. keysForward: number[];
  9157. /**
  9158. * Get the keys for camera movement backward.
  9159. */
  9160. keysBackward: number[];
  9161. /**
  9162. * Get the keys for camera movement up.
  9163. */
  9164. /**
  9165. * Set the keys for camera movement up.
  9166. */
  9167. keysUp: number[];
  9168. /**
  9169. * Get the keys for camera movement down.
  9170. */
  9171. /**
  9172. * Set the keys for camera movement down.
  9173. */
  9174. keysDown: number[];
  9175. /**
  9176. * Get the keys for camera movement left.
  9177. */
  9178. /**
  9179. * Set the keys for camera movement left.
  9180. */
  9181. keysLeft: number[];
  9182. /**
  9183. * Set the keys for camera movement right.
  9184. */
  9185. /**
  9186. * Set the keys for camera movement right.
  9187. */
  9188. keysRight: number[];
  9189. /**
  9190. * Event raised when the camera collides with a mesh in the scene.
  9191. */
  9192. onCollide: (collidedMesh: AbstractMesh) => void;
  9193. private _collider;
  9194. private _needMoveForGravity;
  9195. private _oldPosition;
  9196. private _diffPosition;
  9197. private _newPosition;
  9198. /** @hidden */
  9199. _localDirection: Vector3;
  9200. /** @hidden */
  9201. _transformedDirection: Vector3;
  9202. /**
  9203. * Instantiates a FlyCamera.
  9204. * This is a flying camera, designed for 3D movement and rotation in all directions,
  9205. * such as in a 3D Space Shooter or a Flight Simulator.
  9206. * @param name Define the name of the camera in the scene.
  9207. * @param position Define the starting position of the camera in the scene.
  9208. * @param scene Define the scene the camera belongs to.
  9209. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  9210. */
  9211. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9212. /**
  9213. * Attach a control to the HTML DOM element.
  9214. * @param element Defines the element that listens to the input events.
  9215. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  9216. */
  9217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9218. /**
  9219. * Detach a control from the HTML DOM element.
  9220. * The camera will stop reacting to that input.
  9221. * @param element Defines the element that listens to the input events.
  9222. */
  9223. detachControl(element: HTMLElement): void;
  9224. private _collisionMask;
  9225. /**
  9226. * Get the mask that the camera ignores in collision events.
  9227. */
  9228. /**
  9229. * Set the mask that the camera ignores in collision events.
  9230. */
  9231. collisionMask: number;
  9232. /** @hidden */
  9233. _collideWithWorld(displacement: Vector3): void;
  9234. /** @hidden */
  9235. private _onCollisionPositionChange;
  9236. /** @hidden */
  9237. _checkInputs(): void;
  9238. /** @hidden */
  9239. _decideIfNeedsToMove(): boolean;
  9240. /** @hidden */
  9241. _updatePosition(): void;
  9242. /**
  9243. * Restore the Roll to its target value at the rate specified.
  9244. * @param rate - Higher means slower restoring.
  9245. * @hidden
  9246. */
  9247. restoreRoll(rate: number): void;
  9248. /**
  9249. * Destroy the camera and release the current resources held by it.
  9250. */
  9251. dispose(): void;
  9252. /**
  9253. * Get the current object class name.
  9254. * @returns the class name.
  9255. */
  9256. getClassName(): string;
  9257. }
  9258. }
  9259. declare module BABYLON {
  9260. /**
  9261. * Default Inputs manager for the FlyCamera.
  9262. * It groups all the default supported inputs for ease of use.
  9263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9264. */
  9265. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  9266. /**
  9267. * Instantiates a new FlyCameraInputsManager.
  9268. * @param camera Defines the camera the inputs belong to.
  9269. */
  9270. constructor(camera: FlyCamera);
  9271. /**
  9272. * Add keyboard input support to the input manager.
  9273. * @returns the new FlyCameraKeyboardMoveInput().
  9274. */
  9275. addKeyboard(): FlyCameraInputsManager;
  9276. /**
  9277. * Add mouse input support to the input manager.
  9278. * @param touchEnabled Enable touch screen support.
  9279. * @returns the new FlyCameraMouseInput().
  9280. */
  9281. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  9282. }
  9283. }
  9284. declare module BABYLON {
  9285. /**
  9286. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  9287. * an arc rotate version arcFollowCamera are available.
  9288. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9289. */
  9290. class FollowCamera extends TargetCamera {
  9291. /**
  9292. * Distance the follow camera should follow an object at
  9293. */
  9294. radius: number;
  9295. /**
  9296. * Define a rotation offset between the camera and the object it follows
  9297. */
  9298. rotationOffset: number;
  9299. /**
  9300. * Define a height offset between the camera and the object it follows.
  9301. * It can help following an object from the top (like a car chaing a plane)
  9302. */
  9303. heightOffset: number;
  9304. /**
  9305. * Define how fast the camera can accelerate to follow it s target.
  9306. */
  9307. cameraAcceleration: number;
  9308. /**
  9309. * Define the speed limit of the camera following an object.
  9310. */
  9311. maxCameraSpeed: number;
  9312. /**
  9313. * Define the target of the camera.
  9314. */
  9315. lockedTarget: Nullable<AbstractMesh>;
  9316. /**
  9317. * Instantiates the follow camera.
  9318. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9319. * @param name Define the name of the camera in the scene
  9320. * @param position Define the position of the camera
  9321. * @param scene Define the scene the camera belong to
  9322. * @param lockedTarget Define the target of the camera
  9323. */
  9324. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  9325. private _follow;
  9326. /** @hidden */
  9327. _checkInputs(): void;
  9328. /**
  9329. * Gets the camera class name.
  9330. * @returns the class name
  9331. */
  9332. getClassName(): string;
  9333. }
  9334. /**
  9335. * Arc Rotate version of the follow camera.
  9336. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  9337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9338. */
  9339. class ArcFollowCamera extends TargetCamera {
  9340. /** The longitudinal angle of the camera */
  9341. alpha: number;
  9342. /** The latitudinal angle of the camera */
  9343. beta: number;
  9344. /** The radius of the camera from its target */
  9345. radius: number;
  9346. /** Define the camera target (the messh it should follow) */
  9347. target: Nullable<AbstractMesh>;
  9348. private _cartesianCoordinates;
  9349. /**
  9350. * Instantiates a new ArcFollowCamera
  9351. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9352. * @param name Define the name of the camera
  9353. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  9354. * @param beta Define the rotation angle of the camera around the elevation axis
  9355. * @param radius Define the radius of the camera from its target point
  9356. * @param target Define the target of the camera
  9357. * @param scene Define the scene the camera belongs to
  9358. */
  9359. constructor(name: string,
  9360. /** The longitudinal angle of the camera */
  9361. alpha: number,
  9362. /** The latitudinal angle of the camera */
  9363. beta: number,
  9364. /** The radius of the camera from its target */
  9365. radius: number,
  9366. /** Define the camera target (the messh it should follow) */
  9367. target: Nullable<AbstractMesh>, scene: Scene);
  9368. private _follow;
  9369. /** @hidden */
  9370. _checkInputs(): void;
  9371. /**
  9372. * Returns the class name of the object.
  9373. * It is mostly used internally for serialization purposes.
  9374. */
  9375. getClassName(): string;
  9376. }
  9377. }
  9378. declare module BABYLON {
  9379. /**
  9380. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9381. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  9382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9383. */
  9384. class FreeCamera extends TargetCamera {
  9385. /**
  9386. * Define the collision ellipsoid of the camera.
  9387. * This is helpful to simulate a camera body like the player body around the camera
  9388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  9389. */
  9390. ellipsoid: Vector3;
  9391. /**
  9392. * Define an offset for the position of the ellipsoid around the camera.
  9393. * This can be helpful to determine the center of the body near the gravity center of the body
  9394. * instead of its head.
  9395. */
  9396. ellipsoidOffset: Vector3;
  9397. /**
  9398. * Enable or disable collisions of the camera with the rest of the scene objects.
  9399. */
  9400. checkCollisions: boolean;
  9401. /**
  9402. * Enable or disable gravity on the camera.
  9403. */
  9404. applyGravity: boolean;
  9405. /**
  9406. * Define the input manager associated to the camera.
  9407. */
  9408. inputs: FreeCameraInputsManager;
  9409. /**
  9410. * Gets the input sensibility for a mouse input. (default is 2000.0)
  9411. * Higher values reduce sensitivity.
  9412. */
  9413. /**
  9414. * Sets the input sensibility for a mouse input. (default is 2000.0)
  9415. * Higher values reduce sensitivity.
  9416. */
  9417. angularSensibility: number;
  9418. /**
  9419. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9420. */
  9421. keysUp: number[];
  9422. /**
  9423. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9424. */
  9425. keysDown: number[];
  9426. /**
  9427. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9428. */
  9429. keysLeft: number[];
  9430. /**
  9431. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9432. */
  9433. keysRight: number[];
  9434. /**
  9435. * Event raised when the camera collide with a mesh in the scene.
  9436. */
  9437. onCollide: (collidedMesh: AbstractMesh) => void;
  9438. private _collider;
  9439. private _needMoveForGravity;
  9440. private _oldPosition;
  9441. private _diffPosition;
  9442. private _newPosition;
  9443. /** @hidden */
  9444. _localDirection: Vector3;
  9445. /** @hidden */
  9446. _transformedDirection: Vector3;
  9447. /**
  9448. * Instantiates a Free Camera.
  9449. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9450. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  9451. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9452. * @param name Define the name of the camera in the scene
  9453. * @param position Define the start position of the camera in the scene
  9454. * @param scene Define the scene the camera belongs to
  9455. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9456. */
  9457. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9458. /**
  9459. * Attached controls to the current camera.
  9460. * @param element Defines the element the controls should be listened from
  9461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9462. */
  9463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9464. /**
  9465. * Detach the current controls from the camera.
  9466. * The camera will stop reacting to inputs.
  9467. * @param element Defines the element to stop listening the inputs from
  9468. */
  9469. detachControl(element: HTMLElement): void;
  9470. private _collisionMask;
  9471. /**
  9472. * Define a collision mask to limit the list of object the camera can collide with
  9473. */
  9474. collisionMask: number;
  9475. /** @hidden */
  9476. _collideWithWorld(displacement: Vector3): void;
  9477. private _onCollisionPositionChange;
  9478. /** @hidden */
  9479. _checkInputs(): void;
  9480. /** @hidden */
  9481. _decideIfNeedsToMove(): boolean;
  9482. /** @hidden */
  9483. _updatePosition(): void;
  9484. /**
  9485. * Destroy the camera and release the current resources hold by it.
  9486. */
  9487. dispose(): void;
  9488. /**
  9489. * Gets the current object class name.
  9490. * @return the class name
  9491. */
  9492. getClassName(): string;
  9493. }
  9494. }
  9495. declare module BABYLON {
  9496. /**
  9497. * Default Inputs manager for the FreeCamera.
  9498. * It groups all the default supported inputs for ease of use.
  9499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9500. */
  9501. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9502. /**
  9503. * Instantiates a new FreeCameraInputsManager.
  9504. * @param camera Defines the camera the inputs belong to
  9505. */
  9506. constructor(camera: FreeCamera);
  9507. /**
  9508. * Add keyboard input support to the input manager.
  9509. * @returns the current input manager
  9510. */
  9511. addKeyboard(): FreeCameraInputsManager;
  9512. /**
  9513. * Add mouse input support to the input manager.
  9514. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9515. * @returns the current input manager
  9516. */
  9517. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9518. /**
  9519. * Add orientation input support to the input manager.
  9520. * @returns the current input manager
  9521. */
  9522. addDeviceOrientation(): FreeCameraInputsManager;
  9523. /**
  9524. * Add touch input support to the input manager.
  9525. * @returns the current input manager
  9526. */
  9527. addTouch(): FreeCameraInputsManager;
  9528. /**
  9529. * Add virtual joystick input support to the input manager.
  9530. * @returns the current input manager
  9531. */
  9532. addVirtualJoystick(): FreeCameraInputsManager;
  9533. }
  9534. }
  9535. declare module BABYLON {
  9536. /**
  9537. * This represents a FPS type of camera. This is only here for back compat purpose.
  9538. * Please use the UniversalCamera instead as both are identical.
  9539. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9540. */
  9541. class GamepadCamera extends UniversalCamera {
  9542. /**
  9543. * Instantiates a new Gamepad Camera
  9544. * This represents a FPS type of camera. This is only here for back compat purpose.
  9545. * Please use the UniversalCamera instead as both are identical.
  9546. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9547. * @param name Define the name of the camera in the scene
  9548. * @param position Define the start position of the camera in the scene
  9549. * @param scene Define the scene the camera belongs to
  9550. */
  9551. constructor(name: string, position: Vector3, scene: Scene);
  9552. /**
  9553. * Gets the current object class name.
  9554. * @return the class name
  9555. */
  9556. getClassName(): string;
  9557. }
  9558. }
  9559. declare module BABYLON {
  9560. /**
  9561. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9562. * This is the base of the follow, arc rotate cameras and Free camera
  9563. * @see http://doc.babylonjs.com/features/cameras
  9564. */
  9565. class TargetCamera extends Camera {
  9566. private static _RigCamTransformMatrix;
  9567. private static _TargetTransformMatrix;
  9568. private static _TargetFocalPoint;
  9569. /**
  9570. * Define the current direction the camera is moving to
  9571. */
  9572. cameraDirection: Vector3;
  9573. /**
  9574. * Define the current rotation the camera is rotating to
  9575. */
  9576. cameraRotation: Vector2;
  9577. /**
  9578. * When set, the up vector of the camera will be updated by the rotation of the camera
  9579. */
  9580. updateUpVectorFromRotation: boolean;
  9581. private _tmpQuaternion;
  9582. /**
  9583. * Define the current rotation of the camera
  9584. */
  9585. rotation: Vector3;
  9586. /**
  9587. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9588. */
  9589. rotationQuaternion: Quaternion;
  9590. /**
  9591. * Define the current speed of the camera
  9592. */
  9593. speed: number;
  9594. /**
  9595. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9596. * around all axis.
  9597. */
  9598. noRotationConstraint: boolean;
  9599. /**
  9600. * Define the current target of the camera as an object or a position.
  9601. */
  9602. lockedTarget: any;
  9603. /** @hidden */
  9604. _currentTarget: Vector3;
  9605. /** @hidden */
  9606. _initialFocalDistance: number;
  9607. /** @hidden */
  9608. _viewMatrix: Matrix;
  9609. /** @hidden */
  9610. _camMatrix: Matrix;
  9611. /** @hidden */
  9612. _cameraTransformMatrix: Matrix;
  9613. /** @hidden */
  9614. _cameraRotationMatrix: Matrix;
  9615. /** @hidden */
  9616. _referencePoint: Vector3;
  9617. /** @hidden */
  9618. _transformedReferencePoint: Vector3;
  9619. protected _globalCurrentTarget: Vector3;
  9620. protected _globalCurrentUpVector: Vector3;
  9621. /** @hidden */
  9622. _reset: () => void;
  9623. private _defaultUp;
  9624. /**
  9625. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9626. * This is the base of the follow, arc rotate cameras and Free camera
  9627. * @see http://doc.babylonjs.com/features/cameras
  9628. * @param name Defines the name of the camera in the scene
  9629. * @param position Defines the start position of the camera in the scene
  9630. * @param scene Defines the scene the camera belongs to
  9631. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9632. */
  9633. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9634. /**
  9635. * Gets the position in front of the camera at a given distance.
  9636. * @param distance The distance from the camera we want the position to be
  9637. * @returns the position
  9638. */
  9639. getFrontPosition(distance: number): Vector3;
  9640. /** @hidden */
  9641. _getLockedTargetPosition(): Nullable<Vector3>;
  9642. private _storedPosition;
  9643. private _storedRotation;
  9644. private _storedRotationQuaternion;
  9645. /**
  9646. * Store current camera state of the camera (fov, position, rotation, etc..)
  9647. * @returns the camera
  9648. */
  9649. storeState(): Camera;
  9650. /**
  9651. * Restored camera state. You must call storeState() first
  9652. * @returns whether it was successful or not
  9653. * @hidden
  9654. */
  9655. _restoreStateValues(): boolean;
  9656. /** @hidden */
  9657. _initCache(): void;
  9658. /** @hidden */
  9659. _updateCache(ignoreParentClass?: boolean): void;
  9660. /** @hidden */
  9661. _isSynchronizedViewMatrix(): boolean;
  9662. /** @hidden */
  9663. _computeLocalCameraSpeed(): number;
  9664. /** @hidden */
  9665. setTarget(target: Vector3): void;
  9666. /**
  9667. * Return the current target position of the camera. This value is expressed in local space.
  9668. * @returns the target position
  9669. */
  9670. getTarget(): Vector3;
  9671. /** @hidden */
  9672. _decideIfNeedsToMove(): boolean;
  9673. /** @hidden */
  9674. _updatePosition(): void;
  9675. /** @hidden */
  9676. _checkInputs(): void;
  9677. protected _updateCameraRotationMatrix(): void;
  9678. /**
  9679. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  9680. * @returns the current camera
  9681. */
  9682. private _rotateUpVectorWithCameraRotationMatrix;
  9683. private _cachedRotationZ;
  9684. private _cachedQuaternionRotationZ;
  9685. /** @hidden */
  9686. _getViewMatrix(): Matrix;
  9687. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9688. /**
  9689. * @hidden
  9690. */
  9691. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9692. /**
  9693. * @hidden
  9694. */
  9695. _updateRigCameras(): void;
  9696. private _getRigCamPositionAndTarget;
  9697. /**
  9698. * Gets the current object class name.
  9699. * @return the class name
  9700. */
  9701. getClassName(): string;
  9702. }
  9703. }
  9704. declare module BABYLON {
  9705. /**
  9706. * This represents a FPS type of camera controlled by touch.
  9707. * This is like a universal camera minus the Gamepad controls.
  9708. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9709. */
  9710. class TouchCamera extends FreeCamera {
  9711. /**
  9712. * Defines the touch sensibility for rotation.
  9713. * The higher the faster.
  9714. */
  9715. touchAngularSensibility: number;
  9716. /**
  9717. * Defines the touch sensibility for move.
  9718. * The higher the faster.
  9719. */
  9720. touchMoveSensibility: number;
  9721. /**
  9722. * Instantiates a new touch camera.
  9723. * This represents a FPS type of camera controlled by touch.
  9724. * This is like a universal camera minus the Gamepad controls.
  9725. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9726. * @param name Define the name of the camera in the scene
  9727. * @param position Define the start position of the camera in the scene
  9728. * @param scene Define the scene the camera belongs to
  9729. */
  9730. constructor(name: string, position: Vector3, scene: Scene);
  9731. /**
  9732. * Gets the current object class name.
  9733. * @return the class name
  9734. */
  9735. getClassName(): string;
  9736. /** @hidden */
  9737. _setupInputs(): void;
  9738. }
  9739. }
  9740. declare module BABYLON {
  9741. /**
  9742. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  9743. * which still works and will still be found in many Playgrounds.
  9744. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9745. */
  9746. class UniversalCamera extends TouchCamera {
  9747. /**
  9748. * Defines the gamepad rotation sensiblity.
  9749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9750. */
  9751. gamepadAngularSensibility: number;
  9752. /**
  9753. * Defines the gamepad move sensiblity.
  9754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9755. */
  9756. gamepadMoveSensibility: number;
  9757. /**
  9758. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  9759. * which still works and will still be found in many Playgrounds.
  9760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9761. * @param name Define the name of the camera in the scene
  9762. * @param position Define the start position of the camera in the scene
  9763. * @param scene Define the scene the camera belongs to
  9764. */
  9765. constructor(name: string, position: Vector3, scene: Scene);
  9766. /**
  9767. * Gets the current object class name.
  9768. * @return the class name
  9769. */
  9770. getClassName(): string;
  9771. }
  9772. }
  9773. declare module BABYLON {
  9774. /**
  9775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9776. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9777. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9778. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9779. */
  9780. class VirtualJoysticksCamera extends FreeCamera {
  9781. /**
  9782. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  9783. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9784. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9785. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9786. * @param name Define the name of the camera in the scene
  9787. * @param position Define the start position of the camera in the scene
  9788. * @param scene Define the scene the camera belongs to
  9789. */
  9790. constructor(name: string, position: Vector3, scene: Scene);
  9791. /**
  9792. * Gets the current object class name.
  9793. * @return the class name
  9794. */
  9795. getClassName(): string;
  9796. }
  9797. }
  9798. interface VRDisplay extends EventTarget {
  9799. /**
  9800. * Dictionary of capabilities describing the VRDisplay.
  9801. */
  9802. readonly capabilities: VRDisplayCapabilities;
  9803. /**
  9804. * z-depth defining the far plane of the eye view frustum
  9805. * enables mapping of values in the render target depth
  9806. * attachment to scene coordinates. Initially set to 10000.0.
  9807. */
  9808. depthFar: number;
  9809. /**
  9810. * z-depth defining the near plane of the eye view frustum
  9811. * enables mapping of values in the render target depth
  9812. * attachment to scene coordinates. Initially set to 0.01.
  9813. */
  9814. depthNear: number;
  9815. /**
  9816. * An identifier for this distinct VRDisplay. Used as an
  9817. * association point in the Gamepad API.
  9818. */
  9819. readonly displayId: number;
  9820. /**
  9821. * A display name, a user-readable name identifying it.
  9822. */
  9823. readonly displayName: string;
  9824. readonly isConnected: boolean;
  9825. readonly isPresenting: boolean;
  9826. /**
  9827. * If this VRDisplay supports room-scale experiences, the optional
  9828. * stage attribute contains details on the room-scale parameters.
  9829. */
  9830. readonly stageParameters: VRStageParameters | null;
  9831. /**
  9832. * Passing the value returned by `requestAnimationFrame` to
  9833. * `cancelAnimationFrame` will unregister the callback.
  9834. * @param handle Define the hanle of the request to cancel
  9835. */
  9836. cancelAnimationFrame(handle: number): void;
  9837. /**
  9838. * Stops presenting to the VRDisplay.
  9839. * @returns a promise to know when it stopped
  9840. */
  9841. exitPresent(): Promise<void>;
  9842. /**
  9843. * Return the current VREyeParameters for the given eye.
  9844. * @param whichEye Define the eye we want the parameter for
  9845. * @returns the eye parameters
  9846. */
  9847. getEyeParameters(whichEye: string): VREyeParameters;
  9848. /**
  9849. * Populates the passed VRFrameData with the information required to render
  9850. * the current frame.
  9851. * @param frameData Define the data structure to populate
  9852. * @returns true if ok otherwise false
  9853. */
  9854. getFrameData(frameData: VRFrameData): boolean;
  9855. /**
  9856. * Get the layers currently being presented.
  9857. * @returns the list of VR layers
  9858. */
  9859. getLayers(): VRLayer[];
  9860. /**
  9861. * Return a VRPose containing the future predicted pose of the VRDisplay
  9862. * when the current frame will be presented. The value returned will not
  9863. * change until JavaScript has returned control to the browser.
  9864. *
  9865. * The VRPose will contain the position, orientation, velocity,
  9866. * and acceleration of each of these properties.
  9867. * @returns the pose object
  9868. */
  9869. getPose(): VRPose;
  9870. /**
  9871. * Return the current instantaneous pose of the VRDisplay, with no
  9872. * prediction applied.
  9873. * @returns the current instantaneous pose
  9874. */
  9875. getImmediatePose(): VRPose;
  9876. /**
  9877. * The callback passed to `requestAnimationFrame` will be called
  9878. * any time a new frame should be rendered. When the VRDisplay is
  9879. * presenting the callback will be called at the native refresh
  9880. * rate of the HMD. When not presenting this function acts
  9881. * identically to how window.requestAnimationFrame acts. Content should
  9882. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9883. * asynchronously from other displays and at differing refresh rates.
  9884. * @param callback Define the eaction to run next frame
  9885. * @returns the request handle it
  9886. */
  9887. requestAnimationFrame(callback: FrameRequestCallback): number;
  9888. /**
  9889. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9890. * Repeat calls while already presenting will update the VRLayers being displayed.
  9891. * @param layers Define the list of layer to present
  9892. * @returns a promise to know when the request has been fulfilled
  9893. */
  9894. requestPresent(layers: VRLayer[]): Promise<void>;
  9895. /**
  9896. * Reset the pose for this display, treating its current position and
  9897. * orientation as the "origin/zero" values. VRPose.position,
  9898. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9899. * updated when calling resetPose(). This should be called in only
  9900. * sitting-space experiences.
  9901. */
  9902. resetPose(): void;
  9903. /**
  9904. * The VRLayer provided to the VRDisplay will be captured and presented
  9905. * in the HMD. Calling this function has the same effect on the source
  9906. * canvas as any other operation that uses its source image, and canvases
  9907. * created without preserveDrawingBuffer set to true will be cleared.
  9908. * @param pose Define the pose to submit
  9909. */
  9910. submitFrame(pose?: VRPose): void;
  9911. }
  9912. declare var VRDisplay: {
  9913. prototype: VRDisplay;
  9914. new (): VRDisplay;
  9915. };
  9916. interface VRLayer {
  9917. leftBounds?: number[] | Float32Array | null;
  9918. rightBounds?: number[] | Float32Array | null;
  9919. source?: HTMLCanvasElement | null;
  9920. }
  9921. interface VRDisplayCapabilities {
  9922. readonly canPresent: boolean;
  9923. readonly hasExternalDisplay: boolean;
  9924. readonly hasOrientation: boolean;
  9925. readonly hasPosition: boolean;
  9926. readonly maxLayers: number;
  9927. }
  9928. interface VREyeParameters {
  9929. /** @deprecated */
  9930. readonly fieldOfView: VRFieldOfView;
  9931. readonly offset: Float32Array;
  9932. readonly renderHeight: number;
  9933. readonly renderWidth: number;
  9934. }
  9935. interface VRFieldOfView {
  9936. readonly downDegrees: number;
  9937. readonly leftDegrees: number;
  9938. readonly rightDegrees: number;
  9939. readonly upDegrees: number;
  9940. }
  9941. interface VRFrameData {
  9942. readonly leftProjectionMatrix: Float32Array;
  9943. readonly leftViewMatrix: Float32Array;
  9944. readonly pose: VRPose;
  9945. readonly rightProjectionMatrix: Float32Array;
  9946. readonly rightViewMatrix: Float32Array;
  9947. readonly timestamp: number;
  9948. }
  9949. interface VRPose {
  9950. readonly angularAcceleration: Float32Array | null;
  9951. readonly angularVelocity: Float32Array | null;
  9952. readonly linearAcceleration: Float32Array | null;
  9953. readonly linearVelocity: Float32Array | null;
  9954. readonly orientation: Float32Array | null;
  9955. readonly position: Float32Array | null;
  9956. readonly timestamp: number;
  9957. }
  9958. interface VRStageParameters {
  9959. sittingToStandingTransform?: Float32Array;
  9960. sizeX?: number;
  9961. sizeY?: number;
  9962. }
  9963. interface Navigator {
  9964. getVRDisplays(): Promise<VRDisplay[]>;
  9965. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9966. }
  9967. interface Window {
  9968. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9969. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9970. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9971. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9972. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9973. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9974. }
  9975. interface Gamepad {
  9976. readonly displayId: number;
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Interface for attribute information associated with buffer instanciation
  9981. */
  9982. class InstancingAttributeInfo {
  9983. /**
  9984. * Index/offset of the attribute in the vertex shader
  9985. */
  9986. index: number;
  9987. /**
  9988. * size of the attribute, 1, 2, 3 or 4
  9989. */
  9990. attributeSize: number;
  9991. /**
  9992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9993. * default is FLOAT
  9994. */
  9995. attribyteType: number;
  9996. /**
  9997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9998. */
  9999. normalized: boolean;
  10000. /**
  10001. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  10002. */
  10003. offset: number;
  10004. /**
  10005. * Name of the GLSL attribute, for debugging purpose only
  10006. */
  10007. attributeName: string;
  10008. }
  10009. /**
  10010. * Define options used to create a render target texture
  10011. */
  10012. class RenderTargetCreationOptions {
  10013. /**
  10014. * Specifies is mipmaps must be generated
  10015. */
  10016. generateMipMaps?: boolean;
  10017. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  10018. generateDepthBuffer?: boolean;
  10019. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  10020. generateStencilBuffer?: boolean;
  10021. /** Defines texture type (int by default) */
  10022. type?: number;
  10023. /** Defines sampling mode (trilinear by default) */
  10024. samplingMode?: number;
  10025. /** Defines format (RGBA by default) */
  10026. format?: number;
  10027. }
  10028. /**
  10029. * Define options used to create a depth texture
  10030. */
  10031. class DepthTextureCreationOptions {
  10032. /** Specifies whether or not a stencil should be allocated in the texture */
  10033. generateStencil?: boolean;
  10034. /** Specifies whether or not bilinear filtering is enable on the texture */
  10035. bilinearFiltering?: boolean;
  10036. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10037. comparisonFunction?: number;
  10038. /** Specifies if the created texture is a cube texture */
  10039. isCube?: boolean;
  10040. }
  10041. /**
  10042. * Class used to describe the capabilities of the engine relatively to the current browser
  10043. */
  10044. class EngineCapabilities {
  10045. /** Maximum textures units per fragment shader */
  10046. maxTexturesImageUnits: number;
  10047. /** Maximum texture units per vertex shader */
  10048. maxVertexTextureImageUnits: number;
  10049. /** Maximum textures units in the entire pipeline */
  10050. maxCombinedTexturesImageUnits: number;
  10051. /** Maximum texture size */
  10052. maxTextureSize: number;
  10053. /** Maximum cube texture size */
  10054. maxCubemapTextureSize: number;
  10055. /** Maximum render texture size */
  10056. maxRenderTextureSize: number;
  10057. /** Maximum number of vertex attributes */
  10058. maxVertexAttribs: number;
  10059. /** Maximum number of varyings */
  10060. maxVaryingVectors: number;
  10061. /** Maximum number of uniforms per vertex shader */
  10062. maxVertexUniformVectors: number;
  10063. /** Maximum number of uniforms per fragment shader */
  10064. maxFragmentUniformVectors: number;
  10065. /** Defines if standard derivates (dx/dy) are supported */
  10066. standardDerivatives: boolean;
  10067. /** Defines if s3tc texture compression is supported */
  10068. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10069. /** Defines if pvrtc texture compression is supported */
  10070. pvrtc: any;
  10071. /** Defines if etc1 texture compression is supported */
  10072. etc1: any;
  10073. /** Defines if etc2 texture compression is supported */
  10074. etc2: any;
  10075. /** Defines if astc texture compression is supported */
  10076. astc: any;
  10077. /** Defines if float textures are supported */
  10078. textureFloat: boolean;
  10079. /** Defines if vertex array objects are supported */
  10080. vertexArrayObject: boolean;
  10081. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10082. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10083. /** Gets the maximum level of anisotropy supported */
  10084. maxAnisotropy: number;
  10085. /** Defines if instancing is supported */
  10086. instancedArrays: boolean;
  10087. /** Defines if 32 bits indices are supported */
  10088. uintIndices: boolean;
  10089. /** Defines if high precision shaders are supported */
  10090. highPrecisionShaderSupported: boolean;
  10091. /** Defines if depth reading in the fragment shader is supported */
  10092. fragmentDepthSupported: boolean;
  10093. /** Defines if float texture linear filtering is supported*/
  10094. textureFloatLinearFiltering: boolean;
  10095. /** Defines if rendering to float textures is supported */
  10096. textureFloatRender: boolean;
  10097. /** Defines if half float textures are supported*/
  10098. textureHalfFloat: boolean;
  10099. /** Defines if half float texture linear filtering is supported*/
  10100. textureHalfFloatLinearFiltering: boolean;
  10101. /** Defines if rendering to half float textures is supported */
  10102. textureHalfFloatRender: boolean;
  10103. /** Defines if textureLOD shader command is supported */
  10104. textureLOD: boolean;
  10105. /** Defines if draw buffers extension is supported */
  10106. drawBuffersExtension: boolean;
  10107. /** Defines if depth textures are supported */
  10108. depthTextureExtension: boolean;
  10109. /** Defines if float color buffer are supported */
  10110. colorBufferFloat: boolean;
  10111. /** Gets disjoint timer query extension (null if not supported) */
  10112. timerQuery: EXT_disjoint_timer_query;
  10113. /** Defines if timestamp can be used with timer query */
  10114. canUseTimestampForTimerQuery: boolean;
  10115. /** Function used to let the system compiles shaders in background */
  10116. parallelShaderCompile: {
  10117. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10118. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10119. COMPLETION_STATUS_KHR: number;
  10120. };
  10121. }
  10122. /** Interface defining initialization parameters for Engine class */
  10123. interface EngineOptions extends WebGLContextAttributes {
  10124. /**
  10125. * Defines if the engine should no exceed a specified device ratio
  10126. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10127. */
  10128. limitDeviceRatio?: number;
  10129. /**
  10130. * Defines if webvr should be enabled automatically
  10131. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10132. */
  10133. autoEnableWebVR?: boolean;
  10134. /**
  10135. * Defines if webgl2 should be turned off even if supported
  10136. * @see http://doc.babylonjs.com/features/webgl2
  10137. */
  10138. disableWebGL2Support?: boolean;
  10139. /**
  10140. * Defines if webaudio should be initialized as well
  10141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10142. */
  10143. audioEngine?: boolean;
  10144. /**
  10145. * Defines if animations should run using a deterministic lock step
  10146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10147. */
  10148. deterministicLockstep?: boolean;
  10149. /** Defines the maximum steps to use with deterministic lock step mode */
  10150. lockstepMaxSteps?: number;
  10151. /**
  10152. * Defines that engine should ignore context lost events
  10153. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10154. */
  10155. doNotHandleContextLost?: boolean;
  10156. }
  10157. /**
  10158. * Defines the interface used by display changed events
  10159. */
  10160. interface IDisplayChangedEventArgs {
  10161. /** Gets the vrDisplay object (if any) */
  10162. vrDisplay: Nullable<any>;
  10163. /** Gets a boolean indicating if webVR is supported */
  10164. vrSupported: boolean;
  10165. }
  10166. /**
  10167. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10168. */
  10169. class Engine {
  10170. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10171. static ExceptionList: ({
  10172. key: string;
  10173. capture: string;
  10174. captureConstraint: number;
  10175. targets: string[];
  10176. } | {
  10177. key: string;
  10178. capture: null;
  10179. captureConstraint: null;
  10180. targets: string[];
  10181. })[];
  10182. /** Gets the list of created engines */
  10183. static Instances: Engine[];
  10184. /**
  10185. * Gets the latest created engine
  10186. */
  10187. static readonly LastCreatedEngine: Nullable<Engine>;
  10188. /**
  10189. * Gets the latest created scene
  10190. */
  10191. static readonly LastCreatedScene: Nullable<Scene>;
  10192. /**
  10193. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10194. * @param flag defines which part of the materials must be marked as dirty
  10195. * @param predicate defines a predicate used to filter which materials should be affected
  10196. */
  10197. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10198. /**
  10199. * Hidden
  10200. */
  10201. static _TextureLoaders: IInternalTextureLoader[];
  10202. /** Defines that alpha blending is disabled */
  10203. static readonly ALPHA_DISABLE: number;
  10204. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10205. static readonly ALPHA_ADD: number;
  10206. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10207. static readonly ALPHA_COMBINE: number;
  10208. /** Defines that alpha blending to DEST - SRC * DEST */
  10209. static readonly ALPHA_SUBTRACT: number;
  10210. /** Defines that alpha blending to SRC * DEST */
  10211. static readonly ALPHA_MULTIPLY: number;
  10212. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10213. static readonly ALPHA_MAXIMIZED: number;
  10214. /** Defines that alpha blending to SRC + DEST */
  10215. static readonly ALPHA_ONEONE: number;
  10216. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10217. static readonly ALPHA_PREMULTIPLIED: number;
  10218. /**
  10219. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10220. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10221. */
  10222. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10223. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10224. static readonly ALPHA_INTERPOLATE: number;
  10225. /**
  10226. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10227. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10228. */
  10229. static readonly ALPHA_SCREENMODE: number;
  10230. /** Defines that the ressource is not delayed*/
  10231. static readonly DELAYLOADSTATE_NONE: number;
  10232. /** Defines that the ressource was successfully delay loaded */
  10233. static readonly DELAYLOADSTATE_LOADED: number;
  10234. /** Defines that the ressource is currently delay loading */
  10235. static readonly DELAYLOADSTATE_LOADING: number;
  10236. /** Defines that the ressource is delayed and has not started loading */
  10237. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10238. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10239. static readonly NEVER: number;
  10240. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  10241. static readonly ALWAYS: number;
  10242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10243. static readonly LESS: number;
  10244. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10245. static readonly EQUAL: number;
  10246. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  10247. static readonly LEQUAL: number;
  10248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10249. static readonly GREATER: number;
  10250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  10251. static readonly GEQUAL: number;
  10252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  10253. static readonly NOTEQUAL: number;
  10254. /** Passed to stencilOperation to specify that stencil value must be kept */
  10255. static readonly KEEP: number;
  10256. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10257. static readonly REPLACE: number;
  10258. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10259. static readonly INCR: number;
  10260. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10261. static readonly DECR: number;
  10262. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10263. static readonly INVERT: number;
  10264. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10265. static readonly INCR_WRAP: number;
  10266. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10267. static readonly DECR_WRAP: number;
  10268. /** Texture is not repeating outside of 0..1 UVs */
  10269. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10270. /** Texture is repeating outside of 0..1 UVs */
  10271. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10272. /** Texture is repeating and mirrored */
  10273. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10274. /** ALPHA */
  10275. static readonly TEXTUREFORMAT_ALPHA: number;
  10276. /** LUMINANCE */
  10277. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10278. /** LUMINANCE_ALPHA */
  10279. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10280. /** RGB */
  10281. static readonly TEXTUREFORMAT_RGB: number;
  10282. /** RGBA */
  10283. static readonly TEXTUREFORMAT_RGBA: number;
  10284. /** RED */
  10285. static readonly TEXTUREFORMAT_RED: number;
  10286. /** RED (2nd reference) */
  10287. static readonly TEXTUREFORMAT_R: number;
  10288. /** RG */
  10289. static readonly TEXTUREFORMAT_RG: number;
  10290. /** RED_INTEGER */
  10291. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10292. /** RED_INTEGER (2nd reference) */
  10293. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10294. /** RG_INTEGER */
  10295. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10296. /** RGB_INTEGER */
  10297. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10298. /** RGBA_INTEGER */
  10299. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10300. /** UNSIGNED_BYTE */
  10301. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10302. /** UNSIGNED_BYTE (2nd reference) */
  10303. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10304. /** FLOAT */
  10305. static readonly TEXTURETYPE_FLOAT: number;
  10306. /** HALF_FLOAT */
  10307. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10308. /** BYTE */
  10309. static readonly TEXTURETYPE_BYTE: number;
  10310. /** SHORT */
  10311. static readonly TEXTURETYPE_SHORT: number;
  10312. /** UNSIGNED_SHORT */
  10313. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10314. /** INT */
  10315. static readonly TEXTURETYPE_INT: number;
  10316. /** UNSIGNED_INT */
  10317. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10318. /** UNSIGNED_SHORT_4_4_4_4 */
  10319. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10320. /** UNSIGNED_SHORT_5_5_5_1 */
  10321. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10322. /** UNSIGNED_SHORT_5_6_5 */
  10323. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10324. /** UNSIGNED_INT_2_10_10_10_REV */
  10325. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10326. /** UNSIGNED_INT_24_8 */
  10327. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10328. /** UNSIGNED_INT_10F_11F_11F_REV */
  10329. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10330. /** UNSIGNED_INT_5_9_9_9_REV */
  10331. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10332. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10333. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10334. /** nearest is mag = nearest and min = nearest and mip = linear */
  10335. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10336. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10337. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10338. /** Trilinear is mag = linear and min = linear and mip = linear */
  10339. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10340. /** nearest is mag = nearest and min = nearest and mip = linear */
  10341. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10343. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10344. /** Trilinear is mag = linear and min = linear and mip = linear */
  10345. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10346. /** mag = nearest and min = nearest and mip = nearest */
  10347. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10348. /** mag = nearest and min = linear and mip = nearest */
  10349. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10350. /** mag = nearest and min = linear and mip = linear */
  10351. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10352. /** mag = nearest and min = linear and mip = none */
  10353. static readonly TEXTURE_NEAREST_LINEAR: number;
  10354. /** mag = nearest and min = nearest and mip = none */
  10355. static readonly TEXTURE_NEAREST_NEAREST: number;
  10356. /** mag = linear and min = nearest and mip = nearest */
  10357. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10358. /** mag = linear and min = nearest and mip = linear */
  10359. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10360. /** mag = linear and min = linear and mip = none */
  10361. static readonly TEXTURE_LINEAR_LINEAR: number;
  10362. /** mag = linear and min = nearest and mip = none */
  10363. static readonly TEXTURE_LINEAR_NEAREST: number;
  10364. /** Explicit coordinates mode */
  10365. static readonly TEXTURE_EXPLICIT_MODE: number;
  10366. /** Spherical coordinates mode */
  10367. static readonly TEXTURE_SPHERICAL_MODE: number;
  10368. /** Planar coordinates mode */
  10369. static readonly TEXTURE_PLANAR_MODE: number;
  10370. /** Cubic coordinates mode */
  10371. static readonly TEXTURE_CUBIC_MODE: number;
  10372. /** Projection coordinates mode */
  10373. static readonly TEXTURE_PROJECTION_MODE: number;
  10374. /** Skybox coordinates mode */
  10375. static readonly TEXTURE_SKYBOX_MODE: number;
  10376. /** Inverse Cubic coordinates mode */
  10377. static readonly TEXTURE_INVCUBIC_MODE: number;
  10378. /** Equirectangular coordinates mode */
  10379. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10380. /** Equirectangular Fixed coordinates mode */
  10381. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10382. /** Equirectangular Fixed Mirrored coordinates mode */
  10383. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10384. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10385. static readonly SCALEMODE_FLOOR: number;
  10386. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10387. static readonly SCALEMODE_NEAREST: number;
  10388. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10389. static readonly SCALEMODE_CEILING: number;
  10390. /**
  10391. * Returns the current version of the framework
  10392. */
  10393. static readonly Version: string;
  10394. /**
  10395. * Returns a string describing the current engine
  10396. */
  10397. readonly description: string;
  10398. /**
  10399. * Gets or sets the epsilon value used by collision engine
  10400. */
  10401. static CollisionsEpsilon: number;
  10402. /**
  10403. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10404. */
  10405. static CodeRepository: string;
  10406. /**
  10407. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10408. */
  10409. static ShadersRepository: string;
  10410. /**
  10411. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10412. */
  10413. forcePOTTextures: boolean;
  10414. /**
  10415. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10416. */
  10417. isFullscreen: boolean;
  10418. /**
  10419. * Gets a boolean indicating if the pointer is currently locked
  10420. */
  10421. isPointerLock: boolean;
  10422. /**
  10423. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10424. */
  10425. cullBackFaces: boolean;
  10426. /**
  10427. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10428. */
  10429. renderEvenInBackground: boolean;
  10430. /**
  10431. * Gets or sets a boolean indicating that cache can be kept between frames
  10432. */
  10433. preventCacheWipeBetweenFrames: boolean;
  10434. /**
  10435. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10436. **/
  10437. enableOfflineSupport: boolean;
  10438. /**
  10439. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10440. **/
  10441. disableManifestCheck: boolean;
  10442. /**
  10443. * Gets the list of created scenes
  10444. */
  10445. scenes: Scene[];
  10446. /**
  10447. * Event raised when a new scene is created
  10448. */
  10449. onNewSceneAddedObservable: Observable<Scene>;
  10450. /**
  10451. * Gets the list of created postprocesses
  10452. */
  10453. postProcesses: PostProcess[];
  10454. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10455. validateShaderPrograms: boolean;
  10456. /**
  10457. * Observable event triggered each time the rendering canvas is resized
  10458. */
  10459. onResizeObservable: Observable<Engine>;
  10460. /**
  10461. * Observable event triggered each time the canvas loses focus
  10462. */
  10463. onCanvasBlurObservable: Observable<Engine>;
  10464. /**
  10465. * Observable event triggered each time the canvas gains focus
  10466. */
  10467. onCanvasFocusObservable: Observable<Engine>;
  10468. /**
  10469. * Observable event triggered each time the canvas receives pointerout event
  10470. */
  10471. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10472. /**
  10473. * Observable event triggered before each texture is initialized
  10474. */
  10475. onBeforeTextureInitObservable: Observable<Texture>;
  10476. private _vrDisplay;
  10477. private _vrSupported;
  10478. private _oldSize;
  10479. private _oldHardwareScaleFactor;
  10480. private _vrExclusivePointerMode;
  10481. private _webVRInitPromise;
  10482. /**
  10483. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10484. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10485. */
  10486. readonly isInVRExclusivePointerMode: boolean;
  10487. /**
  10488. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10489. */
  10490. disableUniformBuffers: boolean;
  10491. /** @hidden */
  10492. _uniformBuffers: UniformBuffer[];
  10493. /**
  10494. * Gets a boolean indicating that the engine supports uniform buffers
  10495. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10496. */
  10497. readonly supportsUniformBuffers: boolean;
  10498. /**
  10499. * Observable raised when the engine begins a new frame
  10500. */
  10501. onBeginFrameObservable: Observable<Engine>;
  10502. /**
  10503. * If set, will be used to request the next animation frame for the render loop
  10504. */
  10505. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10506. /**
  10507. * Observable raised when the engine ends the current frame
  10508. */
  10509. onEndFrameObservable: Observable<Engine>;
  10510. /**
  10511. * Observable raised when the engine is about to compile a shader
  10512. */
  10513. onBeforeShaderCompilationObservable: Observable<Engine>;
  10514. /**
  10515. * Observable raised when the engine has jsut compiled a shader
  10516. */
  10517. onAfterShaderCompilationObservable: Observable<Engine>;
  10518. /** @hidden */
  10519. _gl: WebGLRenderingContext;
  10520. private _renderingCanvas;
  10521. private _windowIsBackground;
  10522. private _webGLVersion;
  10523. /**
  10524. * Gets a boolean indicating that only power of 2 textures are supported
  10525. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10526. */
  10527. readonly needPOTTextures: boolean;
  10528. /** @hidden */
  10529. _badOS: boolean;
  10530. /** @hidden */
  10531. _badDesktopOS: boolean;
  10532. /**
  10533. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10534. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10535. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10536. */
  10537. disableTextureBindingOptimization: boolean;
  10538. /**
  10539. * Gets the audio engine
  10540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10541. * @ignorenaming
  10542. */
  10543. static audioEngine: IAudioEngine;
  10544. /**
  10545. * Default AudioEngine factory responsible of creating the Audio Engine.
  10546. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10547. */
  10548. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10549. /**
  10550. * Default offline support factory responsible of creating a tool used to store data locally.
  10551. * By default, this will create a Database object if the workload has been embedded.
  10552. */
  10553. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10554. private _onFocus;
  10555. private _onBlur;
  10556. private _onCanvasPointerOut;
  10557. private _onCanvasBlur;
  10558. private _onCanvasFocus;
  10559. private _onFullscreenChange;
  10560. private _onPointerLockChange;
  10561. private _onVRDisplayPointerRestricted;
  10562. private _onVRDisplayPointerUnrestricted;
  10563. private _onVrDisplayConnect;
  10564. private _onVrDisplayDisconnect;
  10565. private _onVrDisplayPresentChange;
  10566. /**
  10567. * Observable signaled when VR display mode changes
  10568. */
  10569. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10570. /**
  10571. * Observable signaled when VR request present is complete
  10572. */
  10573. onVRRequestPresentComplete: Observable<boolean>;
  10574. /**
  10575. * Observable signaled when VR request present starts
  10576. */
  10577. onVRRequestPresentStart: Observable<Engine>;
  10578. private _hardwareScalingLevel;
  10579. /** @hidden */
  10580. protected _caps: EngineCapabilities;
  10581. private _pointerLockRequested;
  10582. private _isStencilEnable;
  10583. private _colorWrite;
  10584. private _loadingScreen;
  10585. /** @hidden */
  10586. _drawCalls: PerfCounter;
  10587. /** @hidden */
  10588. _textureCollisions: PerfCounter;
  10589. private _glVersion;
  10590. private _glRenderer;
  10591. private _glVendor;
  10592. private _videoTextureSupported;
  10593. private _renderingQueueLaunched;
  10594. private _activeRenderLoops;
  10595. private _deterministicLockstep;
  10596. private _lockstepMaxSteps;
  10597. /**
  10598. * Observable signaled when a context lost event is raised
  10599. */
  10600. onContextLostObservable: Observable<Engine>;
  10601. /**
  10602. * Observable signaled when a context restored event is raised
  10603. */
  10604. onContextRestoredObservable: Observable<Engine>;
  10605. private _onContextLost;
  10606. private _onContextRestored;
  10607. private _contextWasLost;
  10608. private _doNotHandleContextLost;
  10609. /**
  10610. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10612. */
  10613. doNotHandleContextLost: boolean;
  10614. private _performanceMonitor;
  10615. private _fps;
  10616. private _deltaTime;
  10617. /**
  10618. * Turn this value on if you want to pause FPS computation when in background
  10619. */
  10620. disablePerformanceMonitorInBackground: boolean;
  10621. /**
  10622. * Gets the performance monitor attached to this engine
  10623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10624. */
  10625. readonly performanceMonitor: PerformanceMonitor;
  10626. /** @hidden */
  10627. protected _depthCullingState: _DepthCullingState;
  10628. /** @hidden */
  10629. protected _stencilState: _StencilState;
  10630. /** @hidden */
  10631. protected _alphaState: _AlphaState;
  10632. /** @hidden */
  10633. protected _alphaMode: number;
  10634. protected _internalTexturesCache: InternalTexture[];
  10635. /** @hidden */
  10636. protected _activeChannel: number;
  10637. private _currentTextureChannel;
  10638. /** @hidden */
  10639. protected _boundTexturesCache: {
  10640. [key: string]: Nullable<InternalTexture>;
  10641. };
  10642. /** @hidden */
  10643. protected _currentEffect: Nullable<Effect>;
  10644. /** @hidden */
  10645. protected _currentProgram: Nullable<WebGLProgram>;
  10646. private _compiledEffects;
  10647. private _vertexAttribArraysEnabled;
  10648. /** @hidden */
  10649. protected _cachedViewport: Nullable<Viewport>;
  10650. private _cachedVertexArrayObject;
  10651. /** @hidden */
  10652. protected _cachedVertexBuffers: any;
  10653. /** @hidden */
  10654. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10655. /** @hidden */
  10656. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10657. /** @hidden */
  10658. protected _currentRenderTarget: Nullable<InternalTexture>;
  10659. private _uintIndicesCurrentlySet;
  10660. private _currentBoundBuffer;
  10661. /** @hidden */
  10662. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10663. private _currentBufferPointers;
  10664. private _currentInstanceLocations;
  10665. private _currentInstanceBuffers;
  10666. private _textureUnits;
  10667. private _firstBoundInternalTextureTracker;
  10668. private _lastBoundInternalTextureTracker;
  10669. private _workingCanvas;
  10670. private _workingContext;
  10671. private _rescalePostProcess;
  10672. private _dummyFramebuffer;
  10673. private _externalData;
  10674. private _bindedRenderFunction;
  10675. private _vaoRecordInProgress;
  10676. private _mustWipeVertexAttributes;
  10677. private _emptyTexture;
  10678. private _emptyCubeTexture;
  10679. private _emptyTexture3D;
  10680. /** @hidden */
  10681. _frameHandler: number;
  10682. private _nextFreeTextureSlots;
  10683. private _maxSimultaneousTextures;
  10684. private _activeRequests;
  10685. private _texturesSupported;
  10686. private _textureFormatInUse;
  10687. /**
  10688. * Gets the list of texture formats supported
  10689. */
  10690. readonly texturesSupported: Array<string>;
  10691. /**
  10692. * Gets the list of texture formats in use
  10693. */
  10694. readonly textureFormatInUse: Nullable<string>;
  10695. /**
  10696. * Gets the current viewport
  10697. */
  10698. readonly currentViewport: Nullable<Viewport>;
  10699. /**
  10700. * Gets the default empty texture
  10701. */
  10702. readonly emptyTexture: InternalTexture;
  10703. /**
  10704. * Gets the default empty 3D texture
  10705. */
  10706. readonly emptyTexture3D: InternalTexture;
  10707. /**
  10708. * Gets the default empty cube texture
  10709. */
  10710. readonly emptyCubeTexture: InternalTexture;
  10711. /**
  10712. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10713. */
  10714. readonly premultipliedAlpha: boolean;
  10715. /**
  10716. * Creates a new engine
  10717. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  10718. * @param antialias defines enable antialiasing (default: false)
  10719. * @param options defines further options to be sent to the getContext() function
  10720. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10721. */
  10722. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10723. private _rebuildInternalTextures;
  10724. private _rebuildEffects;
  10725. /**
  10726. * Gets a boolean indicating if all created effects are ready
  10727. * @returns true if all effects are ready
  10728. */
  10729. areAllEffectsReady(): boolean;
  10730. private _rebuildBuffers;
  10731. private _initGLContext;
  10732. /**
  10733. * Gets version of the current webGL context
  10734. */
  10735. readonly webGLVersion: number;
  10736. /**
  10737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10738. */
  10739. readonly isStencilEnable: boolean;
  10740. private _prepareWorkingCanvas;
  10741. /**
  10742. * Reset the texture cache to empty state
  10743. */
  10744. resetTextureCache(): void;
  10745. /**
  10746. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10748. * @returns true if engine is in deterministic lock step mode
  10749. */
  10750. isDeterministicLockStep(): boolean;
  10751. /**
  10752. * Gets the max steps when engine is running in deterministic lock step
  10753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10754. * @returns the max steps
  10755. */
  10756. getLockstepMaxSteps(): number;
  10757. /**
  10758. * Gets an object containing information about the current webGL context
  10759. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10760. */
  10761. getGlInfo(): {
  10762. vendor: string;
  10763. renderer: string;
  10764. version: string;
  10765. };
  10766. /**
  10767. * Gets current aspect ratio
  10768. * @param camera defines the camera to use to get the aspect ratio
  10769. * @param useScreen defines if screen size must be used (or the current render target if any)
  10770. * @returns a number defining the aspect ratio
  10771. */
  10772. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10773. /**
  10774. * Gets current screen aspect ratio
  10775. * @returns a number defining the aspect ratio
  10776. */
  10777. getScreenAspectRatio(): number;
  10778. /**
  10779. * Gets the current render width
  10780. * @param useScreen defines if screen size must be used (or the current render target if any)
  10781. * @returns a number defining the current render width
  10782. */
  10783. getRenderWidth(useScreen?: boolean): number;
  10784. /**
  10785. * Gets the current render height
  10786. * @param useScreen defines if screen size must be used (or the current render target if any)
  10787. * @returns a number defining the current render height
  10788. */
  10789. getRenderHeight(useScreen?: boolean): number;
  10790. /**
  10791. * Gets the HTML canvas attached with the current webGL context
  10792. * @returns a HTML canvas
  10793. */
  10794. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10795. /**
  10796. * Gets the client rect of the HTML canvas attached with the current webGL context
  10797. * @returns a client rectanglee
  10798. */
  10799. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10800. /**
  10801. * Defines the hardware scaling level.
  10802. * By default the hardware scaling level is computed from the window device ratio.
  10803. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  10804. * @param level defines the level to use
  10805. */
  10806. setHardwareScalingLevel(level: number): void;
  10807. /**
  10808. * Gets the current hardware scaling level.
  10809. * By default the hardware scaling level is computed from the window device ratio.
  10810. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  10811. * @returns a number indicating the current hardware scaling level
  10812. */
  10813. getHardwareScalingLevel(): number;
  10814. /**
  10815. * Gets the list of loaded textures
  10816. * @returns an array containing all loaded textures
  10817. */
  10818. getLoadedTexturesCache(): InternalTexture[];
  10819. /**
  10820. * Gets the object containing all engine capabilities
  10821. * @returns the EngineCapabilities object
  10822. */
  10823. getCaps(): EngineCapabilities;
  10824. /**
  10825. * Gets the current depth function
  10826. * @returns a number defining the depth function
  10827. */
  10828. getDepthFunction(): Nullable<number>;
  10829. /**
  10830. * Sets the current depth function
  10831. * @param depthFunc defines the function to use
  10832. */
  10833. setDepthFunction(depthFunc: number): void;
  10834. /**
  10835. * Sets the current depth function to GREATER
  10836. */
  10837. setDepthFunctionToGreater(): void;
  10838. /**
  10839. * Sets the current depth function to GEQUAL
  10840. */
  10841. setDepthFunctionToGreaterOrEqual(): void;
  10842. /**
  10843. * Sets the current depth function to LESS
  10844. */
  10845. setDepthFunctionToLess(): void;
  10846. /**
  10847. * Sets the current depth function to LEQUAL
  10848. */
  10849. setDepthFunctionToLessOrEqual(): void;
  10850. /**
  10851. * Gets a boolean indicating if stencil buffer is enabled
  10852. * @returns the current stencil buffer state
  10853. */
  10854. getStencilBuffer(): boolean;
  10855. /**
  10856. * Enable or disable the stencil buffer
  10857. * @param enable defines if the stencil buffer must be enabled or disabled
  10858. */
  10859. setStencilBuffer(enable: boolean): void;
  10860. /**
  10861. * Gets the current stencil mask
  10862. * @returns a number defining the new stencil mask to use
  10863. */
  10864. getStencilMask(): number;
  10865. /**
  10866. * Sets the current stencil mask
  10867. * @param mask defines the new stencil mask to use
  10868. */
  10869. setStencilMask(mask: number): void;
  10870. /**
  10871. * Gets the current stencil function
  10872. * @returns a number defining the stencil function to use
  10873. */
  10874. getStencilFunction(): number;
  10875. /**
  10876. * Gets the current stencil reference value
  10877. * @returns a number defining the stencil reference value to use
  10878. */
  10879. getStencilFunctionReference(): number;
  10880. /**
  10881. * Gets the current stencil mask
  10882. * @returns a number defining the stencil mask to use
  10883. */
  10884. getStencilFunctionMask(): number;
  10885. /**
  10886. * Sets the current stencil function
  10887. * @param stencilFunc defines the new stencil function to use
  10888. */
  10889. setStencilFunction(stencilFunc: number): void;
  10890. /**
  10891. * Sets the current stencil reference
  10892. * @param reference defines the new stencil reference to use
  10893. */
  10894. setStencilFunctionReference(reference: number): void;
  10895. /**
  10896. * Sets the current stencil mask
  10897. * @param mask defines the new stencil mask to use
  10898. */
  10899. setStencilFunctionMask(mask: number): void;
  10900. /**
  10901. * Gets the current stencil operation when stencil fails
  10902. * @returns a number defining stencil operation to use when stencil fails
  10903. */
  10904. getStencilOperationFail(): number;
  10905. /**
  10906. * Gets the current stencil operation when depth fails
  10907. * @returns a number defining stencil operation to use when depth fails
  10908. */
  10909. getStencilOperationDepthFail(): number;
  10910. /**
  10911. * Gets the current stencil operation when stencil passes
  10912. * @returns a number defining stencil operation to use when stencil passes
  10913. */
  10914. getStencilOperationPass(): number;
  10915. /**
  10916. * Sets the stencil operation to use when stencil fails
  10917. * @param operation defines the stencil operation to use when stencil fails
  10918. */
  10919. setStencilOperationFail(operation: number): void;
  10920. /**
  10921. * Sets the stencil operation to use when depth fails
  10922. * @param operation defines the stencil operation to use when depth fails
  10923. */
  10924. setStencilOperationDepthFail(operation: number): void;
  10925. /**
  10926. * Sets the stencil operation to use when stencil passes
  10927. * @param operation defines the stencil operation to use when stencil passes
  10928. */
  10929. setStencilOperationPass(operation: number): void;
  10930. /**
  10931. * Sets a boolean indicating if the dithering state is enabled or disabled
  10932. * @param value defines the dithering state
  10933. */
  10934. setDitheringState(value: boolean): void;
  10935. /**
  10936. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10937. * @param value defines the rasterizer state
  10938. */
  10939. setRasterizerState(value: boolean): void;
  10940. /**
  10941. * stop executing a render loop function and remove it from the execution array
  10942. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10943. */
  10944. stopRenderLoop(renderFunction?: () => void): void;
  10945. /** @hidden */
  10946. _renderLoop(): void;
  10947. /**
  10948. * Register and execute a render loop. The engine can have more than one render function
  10949. * @param renderFunction defines the function to continuously execute
  10950. */
  10951. runRenderLoop(renderFunction: () => void): void;
  10952. /**
  10953. * Toggle full screen mode
  10954. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10955. */
  10956. switchFullscreen(requestPointerLock: boolean): void;
  10957. /**
  10958. * Clear the current render buffer or the current render target (if any is set up)
  10959. * @param color defines the color to use
  10960. * @param backBuffer defines if the back buffer must be cleared
  10961. * @param depth defines if the depth buffer must be cleared
  10962. * @param stencil defines if the stencil buffer must be cleared
  10963. */
  10964. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10965. /**
  10966. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10967. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10968. * @param y defines the y-coordinate of the corner of the clear rectangle
  10969. * @param width defines the width of the clear rectangle
  10970. * @param height defines the height of the clear rectangle
  10971. * @param clearColor defines the clear color
  10972. */
  10973. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10974. /**
  10975. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  10976. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10977. * @param y defines the y-coordinate of the corner of the clear rectangle
  10978. * @param width defines the width of the clear rectangle
  10979. * @param height defines the height of the clear rectangle
  10980. */
  10981. enableScissor(x: number, y: number, width: number, height: number): void;
  10982. /**
  10983. * Disable previously set scissor test rectangle
  10984. */
  10985. disableScissor(): void;
  10986. private _viewportCached;
  10987. /** @hidden */
  10988. _viewport(x: number, y: number, width: number, height: number): void;
  10989. /**
  10990. * Set the WebGL's viewport
  10991. * @param viewport defines the viewport element to be used
  10992. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10993. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10994. */
  10995. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10996. /**
  10997. * Directly set the WebGL Viewport
  10998. * @param x defines the x coordinate of the viewport (in screen space)
  10999. * @param y defines the y coordinate of the viewport (in screen space)
  11000. * @param width defines the width of the viewport (in screen space)
  11001. * @param height defines the height of the viewport (in screen space)
  11002. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  11003. */
  11004. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  11005. /**
  11006. * Begin a new frame
  11007. */
  11008. beginFrame(): void;
  11009. /**
  11010. * Enf the current frame
  11011. */
  11012. endFrame(): void;
  11013. /**
  11014. * Resize the view according to the canvas' size
  11015. */
  11016. resize(): void;
  11017. /**
  11018. * Force a specific size of the canvas
  11019. * @param width defines the new canvas' width
  11020. * @param height defines the new canvas' height
  11021. */
  11022. setSize(width: number, height: number): void;
  11023. /**
  11024. * Gets a boolean indicating if a webVR device was detected
  11025. * @returns true if a webVR device was detected
  11026. */
  11027. isVRDevicePresent(): boolean;
  11028. /**
  11029. * Gets the current webVR device
  11030. * @returns the current webVR device (or null)
  11031. */
  11032. getVRDevice(): any;
  11033. /**
  11034. * Initializes a webVR display and starts listening to display change events
  11035. * The onVRDisplayChangedObservable will be notified upon these changes
  11036. * @returns The onVRDisplayChangedObservable
  11037. */
  11038. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11039. /**
  11040. * Initializes a webVR display and starts listening to display change events
  11041. * The onVRDisplayChangedObservable will be notified upon these changes
  11042. * @returns A promise containing a VRDisplay and if vr is supported
  11043. */
  11044. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11045. /**
  11046. * Call this function to switch to webVR mode
  11047. * Will do nothing if webVR is not supported or if there is no webVR device
  11048. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11049. */
  11050. enableVR(): void;
  11051. /**
  11052. * Call this function to leave webVR mode
  11053. * Will do nothing if webVR is not supported or if there is no webVR device
  11054. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11055. */
  11056. disableVR(): void;
  11057. private _onVRFullScreenTriggered;
  11058. private _getVRDisplaysAsync;
  11059. /**
  11060. * Binds the frame buffer to the specified texture.
  11061. * @param texture The texture to render to or null for the default canvas
  11062. * @param faceIndex The face of the texture to render to in case of cube texture
  11063. * @param requiredWidth The width of the target to render to
  11064. * @param requiredHeight The height of the target to render to
  11065. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11066. * @param depthStencilTexture The depth stencil texture to use to render
  11067. * @param lodLevel defines le lod level to bind to the frame buffer
  11068. */
  11069. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11070. private bindUnboundFramebuffer;
  11071. /**
  11072. * Unbind the current render target texture from the webGL context
  11073. * @param texture defines the render target texture to unbind
  11074. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11075. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11076. */
  11077. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11078. /**
  11079. * Unbind a list of render target textures from the webGL context
  11080. * This is used only when drawBuffer extension or webGL2 are active
  11081. * @param textures defines the render target textures to unbind
  11082. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11083. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11084. */
  11085. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11086. /**
  11087. * Force the mipmap generation for the given render target texture
  11088. * @param texture defines the render target texture to use
  11089. */
  11090. generateMipMapsForCubemap(texture: InternalTexture): void;
  11091. /**
  11092. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11093. */
  11094. flushFramebuffer(): void;
  11095. /**
  11096. * Unbind the current render target and bind the default framebuffer
  11097. */
  11098. restoreDefaultFramebuffer(): void;
  11099. /**
  11100. * Create an uniform buffer
  11101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11102. * @param elements defines the content of the uniform buffer
  11103. * @returns the webGL uniform buffer
  11104. */
  11105. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11106. /**
  11107. * Create a dynamic uniform buffer
  11108. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11109. * @param elements defines the content of the uniform buffer
  11110. * @returns the webGL uniform buffer
  11111. */
  11112. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11113. /**
  11114. * Update an existing uniform buffer
  11115. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11116. * @param uniformBuffer defines the target uniform buffer
  11117. * @param elements defines the content to update
  11118. * @param offset defines the offset in the uniform buffer where update should start
  11119. * @param count defines the size of the data to update
  11120. */
  11121. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11122. private _resetVertexBufferBinding;
  11123. /**
  11124. * Creates a vertex buffer
  11125. * @param data the data for the vertex buffer
  11126. * @returns the new WebGL static buffer
  11127. */
  11128. createVertexBuffer(data: DataArray): WebGLBuffer;
  11129. /**
  11130. * Creates a dynamic vertex buffer
  11131. * @param data the data for the dynamic vertex buffer
  11132. * @returns the new WebGL dynamic buffer
  11133. */
  11134. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11135. /**
  11136. * Update a dynamic index buffer
  11137. * @param indexBuffer defines the target index buffer
  11138. * @param indices defines the data to update
  11139. * @param offset defines the offset in the target index buffer where update should start
  11140. */
  11141. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11142. /**
  11143. * Updates a dynamic vertex buffer.
  11144. * @param vertexBuffer the vertex buffer to update
  11145. * @param data the data used to update the vertex buffer
  11146. * @param byteOffset the byte offset of the data
  11147. * @param byteLength the byte length of the data
  11148. */
  11149. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11150. private _resetIndexBufferBinding;
  11151. /**
  11152. * Creates a new index buffer
  11153. * @param indices defines the content of the index buffer
  11154. * @param updatable defines if the index buffer must be updatable
  11155. * @returns a new webGL buffer
  11156. */
  11157. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11158. /**
  11159. * Bind a webGL buffer to the webGL context
  11160. * @param buffer defines the buffer to bind
  11161. */
  11162. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11163. /**
  11164. * Bind an uniform buffer to the current webGL context
  11165. * @param buffer defines the buffer to bind
  11166. */
  11167. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11168. /**
  11169. * Bind a buffer to the current webGL context at a given location
  11170. * @param buffer defines the buffer to bind
  11171. * @param location defines the index where to bind the buffer
  11172. */
  11173. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11174. /**
  11175. * Bind a specific block at a given index in a specific shader program
  11176. * @param shaderProgram defines the shader program
  11177. * @param blockName defines the block name
  11178. * @param index defines the index where to bind the block
  11179. */
  11180. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11181. private bindIndexBuffer;
  11182. private bindBuffer;
  11183. /**
  11184. * update the bound buffer with the given data
  11185. * @param data defines the data to update
  11186. */
  11187. updateArrayBuffer(data: Float32Array): void;
  11188. private _vertexAttribPointer;
  11189. private _bindIndexBufferWithCache;
  11190. private _bindVertexBuffersAttributes;
  11191. /**
  11192. * Records a vertex array object
  11193. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11194. * @param vertexBuffers defines the list of vertex buffers to store
  11195. * @param indexBuffer defines the index buffer to store
  11196. * @param effect defines the effect to store
  11197. * @returns the new vertex array object
  11198. */
  11199. recordVertexArrayObject(vertexBuffers: {
  11200. [key: string]: VertexBuffer;
  11201. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11202. /**
  11203. * Bind a specific vertex array object
  11204. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11205. * @param vertexArrayObject defines the vertex array object to bind
  11206. * @param indexBuffer defines the index buffer to bind
  11207. */
  11208. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11209. /**
  11210. * Bind webGl buffers directly to the webGL context
  11211. * @param vertexBuffer defines the vertex buffer to bind
  11212. * @param indexBuffer defines the index buffer to bind
  11213. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11214. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11215. * @param effect defines the effect associated with the vertex buffer
  11216. */
  11217. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11218. private _unbindVertexArrayObject;
  11219. /**
  11220. * Bind a list of vertex buffers to the webGL context
  11221. * @param vertexBuffers defines the list of vertex buffers to bind
  11222. * @param indexBuffer defines the index buffer to bind
  11223. * @param effect defines the effect associated with the vertex buffers
  11224. */
  11225. bindBuffers(vertexBuffers: {
  11226. [key: string]: Nullable<VertexBuffer>;
  11227. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11228. /**
  11229. * Unbind all instance attributes
  11230. */
  11231. unbindInstanceAttributes(): void;
  11232. /**
  11233. * Release and free the memory of a vertex array object
  11234. * @param vao defines the vertex array object to delete
  11235. */
  11236. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11237. /** @hidden */
  11238. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11239. /**
  11240. * Creates a webGL buffer to use with instanciation
  11241. * @param capacity defines the size of the buffer
  11242. * @returns the webGL buffer
  11243. */
  11244. createInstancesBuffer(capacity: number): WebGLBuffer;
  11245. /**
  11246. * Delete a webGL buffer used with instanciation
  11247. * @param buffer defines the webGL buffer to delete
  11248. */
  11249. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11250. /**
  11251. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11252. * @param instancesBuffer defines the webGL buffer to update and bind
  11253. * @param data defines the data to store in the buffer
  11254. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11255. */
  11256. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11257. /**
  11258. * Apply all cached states (depth, culling, stencil and alpha)
  11259. */
  11260. applyStates(): void;
  11261. /**
  11262. * Send a draw order
  11263. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11264. * @param indexStart defines the starting index
  11265. * @param indexCount defines the number of index to draw
  11266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11267. */
  11268. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11269. /**
  11270. * Draw a list of points
  11271. * @param verticesStart defines the index of first vertex to draw
  11272. * @param verticesCount defines the count of vertices to draw
  11273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11274. */
  11275. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11276. /**
  11277. * Draw a list of unindexed primitives
  11278. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11279. * @param verticesStart defines the index of first vertex to draw
  11280. * @param verticesCount defines the count of vertices to draw
  11281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11282. */
  11283. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11284. /**
  11285. * Draw a list of indexed primitives
  11286. * @param fillMode defines the primitive to use
  11287. * @param indexStart defines the starting index
  11288. * @param indexCount defines the number of index to draw
  11289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11290. */
  11291. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11292. /**
  11293. * Draw a list of unindexed primitives
  11294. * @param fillMode defines the primitive to use
  11295. * @param verticesStart defines the index of first vertex to draw
  11296. * @param verticesCount defines the count of vertices to draw
  11297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11298. */
  11299. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11300. private _drawMode;
  11301. /** @hidden */
  11302. _releaseEffect(effect: Effect): void;
  11303. /** @hidden */
  11304. _deleteProgram(program: WebGLProgram): void;
  11305. /**
  11306. * Create a new effect (used to store vertex/fragment shaders)
  11307. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11308. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11309. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11310. * @param samplers defines an array of string used to represent textures
  11311. * @param defines defines the string containing the defines to use to compile the shaders
  11312. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11313. * @param onCompiled defines a function to call when the effect creation is successful
  11314. * @param onError defines a function to call when the effect creation has failed
  11315. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11316. * @returns the new Effect
  11317. */
  11318. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  11319. private _compileShader;
  11320. private _compileRawShader;
  11321. /**
  11322. * Directly creates a webGL program
  11323. * @param vertexCode defines the vertex shader code to use
  11324. * @param fragmentCode defines the fragment shader code to use
  11325. * @param context defines the webGL context to use (if not set, the current one will be used)
  11326. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11327. * @returns the new webGL program
  11328. */
  11329. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11330. /**
  11331. * Creates a webGL program
  11332. * @param vertexCode defines the vertex shader code to use
  11333. * @param fragmentCode defines the fragment shader code to use
  11334. * @param defines defines the string containing the defines to use to compile the shaders
  11335. * @param context defines the webGL context to use (if not set, the current one will be used)
  11336. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11337. * @returns the new webGL program
  11338. */
  11339. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11340. private _createShaderProgram;
  11341. private _finalizeProgram;
  11342. /** @hidden */
  11343. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11344. /** @hidden */
  11345. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11346. /**
  11347. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11348. * @param shaderProgram defines the webGL program to use
  11349. * @param uniformsNames defines the list of uniform names
  11350. * @returns an array of webGL uniform locations
  11351. */
  11352. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11353. /**
  11354. * Gets the lsit of active attributes for a given webGL program
  11355. * @param shaderProgram defines the webGL program to use
  11356. * @param attributesNames defines the list of attribute names to get
  11357. * @returns an array of indices indicating the offset of each attribute
  11358. */
  11359. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11360. /**
  11361. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11362. * @param effect defines the effect to activate
  11363. */
  11364. enableEffect(effect: Nullable<Effect>): void;
  11365. /**
  11366. * Set the value of an uniform to an array of int32
  11367. * @param uniform defines the webGL uniform location where to store the value
  11368. * @param array defines the array of int32 to store
  11369. */
  11370. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11371. /**
  11372. * Set the value of an uniform to an array of int32 (stored as vec2)
  11373. * @param uniform defines the webGL uniform location where to store the value
  11374. * @param array defines the array of int32 to store
  11375. */
  11376. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11377. /**
  11378. * Set the value of an uniform to an array of int32 (stored as vec3)
  11379. * @param uniform defines the webGL uniform location where to store the value
  11380. * @param array defines the array of int32 to store
  11381. */
  11382. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11383. /**
  11384. * Set the value of an uniform to an array of int32 (stored as vec4)
  11385. * @param uniform defines the webGL uniform location where to store the value
  11386. * @param array defines the array of int32 to store
  11387. */
  11388. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11389. /**
  11390. * Set the value of an uniform to an array of float32
  11391. * @param uniform defines the webGL uniform location where to store the value
  11392. * @param array defines the array of float32 to store
  11393. */
  11394. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11395. /**
  11396. * Set the value of an uniform to an array of float32 (stored as vec2)
  11397. * @param uniform defines the webGL uniform location where to store the value
  11398. * @param array defines the array of float32 to store
  11399. */
  11400. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11401. /**
  11402. * Set the value of an uniform to an array of float32 (stored as vec3)
  11403. * @param uniform defines the webGL uniform location where to store the value
  11404. * @param array defines the array of float32 to store
  11405. */
  11406. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11407. /**
  11408. * Set the value of an uniform to an array of float32 (stored as vec4)
  11409. * @param uniform defines the webGL uniform location where to store the value
  11410. * @param array defines the array of float32 to store
  11411. */
  11412. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11413. /**
  11414. * Set the value of an uniform to an array of number
  11415. * @param uniform defines the webGL uniform location where to store the value
  11416. * @param array defines the array of number to store
  11417. */
  11418. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11419. /**
  11420. * Set the value of an uniform to an array of number (stored as vec2)
  11421. * @param uniform defines the webGL uniform location where to store the value
  11422. * @param array defines the array of number to store
  11423. */
  11424. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11425. /**
  11426. * Set the value of an uniform to an array of number (stored as vec3)
  11427. * @param uniform defines the webGL uniform location where to store the value
  11428. * @param array defines the array of number to store
  11429. */
  11430. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11431. /**
  11432. * Set the value of an uniform to an array of number (stored as vec4)
  11433. * @param uniform defines the webGL uniform location where to store the value
  11434. * @param array defines the array of number to store
  11435. */
  11436. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11437. /**
  11438. * Set the value of an uniform to an array of float32 (stored as matrices)
  11439. * @param uniform defines the webGL uniform location where to store the value
  11440. * @param matrices defines the array of float32 to store
  11441. */
  11442. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11443. /**
  11444. * Set the value of an uniform to a matrix
  11445. * @param uniform defines the webGL uniform location where to store the value
  11446. * @param matrix defines the matrix to store
  11447. */
  11448. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11449. /**
  11450. * Set the value of an uniform to a matrix (3x3)
  11451. * @param uniform defines the webGL uniform location where to store the value
  11452. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11453. */
  11454. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11455. /**
  11456. * Set the value of an uniform to a matrix (2x2)
  11457. * @param uniform defines the webGL uniform location where to store the value
  11458. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11459. */
  11460. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11461. /**
  11462. * Set the value of an uniform to a number (int)
  11463. * @param uniform defines the webGL uniform location where to store the value
  11464. * @param value defines the int number to store
  11465. */
  11466. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11467. /**
  11468. * Set the value of an uniform to a number (float)
  11469. * @param uniform defines the webGL uniform location where to store the value
  11470. * @param value defines the float number to store
  11471. */
  11472. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11473. /**
  11474. * Set the value of an uniform to a vec2
  11475. * @param uniform defines the webGL uniform location where to store the value
  11476. * @param x defines the 1st component of the value
  11477. * @param y defines the 2nd component of the value
  11478. */
  11479. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11480. /**
  11481. * Set the value of an uniform to a vec3
  11482. * @param uniform defines the webGL uniform location where to store the value
  11483. * @param x defines the 1st component of the value
  11484. * @param y defines the 2nd component of the value
  11485. * @param z defines the 3rd component of the value
  11486. */
  11487. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11488. /**
  11489. * Set the value of an uniform to a boolean
  11490. * @param uniform defines the webGL uniform location where to store the value
  11491. * @param bool defines the boolean to store
  11492. */
  11493. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11494. /**
  11495. * Set the value of an uniform to a vec4
  11496. * @param uniform defines the webGL uniform location where to store the value
  11497. * @param x defines the 1st component of the value
  11498. * @param y defines the 2nd component of the value
  11499. * @param z defines the 3rd component of the value
  11500. * @param w defines the 4th component of the value
  11501. */
  11502. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11503. /**
  11504. * Set the value of an uniform to a Color3
  11505. * @param uniform defines the webGL uniform location where to store the value
  11506. * @param color3 defines the color to store
  11507. */
  11508. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11509. /**
  11510. * Set the value of an uniform to a Color3 and an alpha value
  11511. * @param uniform defines the webGL uniform location where to store the value
  11512. * @param color3 defines the color to store
  11513. * @param alpha defines the alpha component to store
  11514. */
  11515. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11516. /**
  11517. * Sets a Color4 on a uniform variable
  11518. * @param uniform defines the uniform location
  11519. * @param color4 defines the value to be set
  11520. */
  11521. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11522. /**
  11523. * Set various states to the webGL context
  11524. * @param culling defines backface culling state
  11525. * @param zOffset defines the value to apply to zOffset (0 by default)
  11526. * @param force defines if states must be applied even if cache is up to date
  11527. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11528. */
  11529. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11530. /**
  11531. * Set the z offset to apply to current rendering
  11532. * @param value defines the offset to apply
  11533. */
  11534. setZOffset(value: number): void;
  11535. /**
  11536. * Gets the current value of the zOffset
  11537. * @returns the current zOffset state
  11538. */
  11539. getZOffset(): number;
  11540. /**
  11541. * Enable or disable depth buffering
  11542. * @param enable defines the state to set
  11543. */
  11544. setDepthBuffer(enable: boolean): void;
  11545. /**
  11546. * Gets a boolean indicating if depth writing is enabled
  11547. * @returns the current depth writing state
  11548. */
  11549. getDepthWrite(): boolean;
  11550. /**
  11551. * Enable or disable depth writing
  11552. * @param enable defines the state to set
  11553. */
  11554. setDepthWrite(enable: boolean): void;
  11555. /**
  11556. * Enable or disable color writing
  11557. * @param enable defines the state to set
  11558. */
  11559. setColorWrite(enable: boolean): void;
  11560. /**
  11561. * Gets a boolean indicating if color writing is enabled
  11562. * @returns the current color writing state
  11563. */
  11564. getColorWrite(): boolean;
  11565. /**
  11566. * Sets alpha constants used by some alpha blending modes
  11567. * @param r defines the red component
  11568. * @param g defines the green component
  11569. * @param b defines the blue component
  11570. * @param a defines the alpha component
  11571. */
  11572. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11573. /**
  11574. * Sets the current alpha mode
  11575. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11576. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11578. */
  11579. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11580. /**
  11581. * Gets the current alpha mode
  11582. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11583. * @returns the current alpha mode
  11584. */
  11585. getAlphaMode(): number;
  11586. /**
  11587. * Clears the list of texture accessible through engine.
  11588. * This can help preventing texture load conflict due to name collision.
  11589. */
  11590. clearInternalTexturesCache(): void;
  11591. /**
  11592. * Force the entire cache to be cleared
  11593. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11594. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11595. */
  11596. wipeCaches(bruteForce?: boolean): void;
  11597. /**
  11598. * Set the compressed texture format to use, based on the formats you have, and the formats
  11599. * supported by the hardware / browser.
  11600. *
  11601. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11602. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11603. * to API arguments needed to compressed textures. This puts the burden on the container
  11604. * generator to house the arcane code for determining these for current & future formats.
  11605. *
  11606. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11607. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11608. *
  11609. * Note: The result of this call is not taken into account when a texture is base64.
  11610. *
  11611. * @param formatsAvailable defines the list of those format families you have created
  11612. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11613. *
  11614. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11615. * @returns The extension selected.
  11616. */
  11617. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11618. private _getSamplingParameters;
  11619. private _partialLoadImg;
  11620. private _cascadeLoadImgs;
  11621. /** @hidden */
  11622. _createTexture(): WebGLTexture;
  11623. /**
  11624. * Usually called from BABYLON.Texture.ts.
  11625. * Passed information to create a WebGLTexture
  11626. * @param urlArg defines a value which contains one of the following:
  11627. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11628. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11629. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11631. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  11632. * @param scene needed for loading to the correct scene
  11633. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11634. * @param onLoad optional callback to be called upon successful completion
  11635. * @param onError optional callback to be called upon failure
  11636. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  11637. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11638. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11639. * @param forcedExtension defines the extension to use to pick the right loader
  11640. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11641. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11642. */
  11643. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  11644. private _rescaleTexture;
  11645. /**
  11646. * Update a raw texture
  11647. * @param texture defines the texture to update
  11648. * @param data defines the data to store in the texture
  11649. * @param format defines the format of the data
  11650. * @param invertY defines if data must be stored with Y axis inverted
  11651. * @param compression defines the compression used (null by default)
  11652. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11653. */
  11654. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11655. /**
  11656. * Creates a raw texture
  11657. * @param data defines the data to store in the texture
  11658. * @param width defines the width of the texture
  11659. * @param height defines the height of the texture
  11660. * @param format defines the format of the data
  11661. * @param generateMipMaps defines if the engine should generate the mip levels
  11662. * @param invertY defines if data must be stored with Y axis inverted
  11663. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11664. * @param compression defines the compression used (null by default)
  11665. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11666. * @returns the raw texture inside an InternalTexture
  11667. */
  11668. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11669. private _unpackFlipYCached;
  11670. /**
  11671. * In case you are sharing the context with other applications, it might
  11672. * be interested to not cache the unpack flip y state to ensure a consistent
  11673. * value would be set.
  11674. */
  11675. enableUnpackFlipYCached: boolean;
  11676. /** @hidden */
  11677. _unpackFlipY(value: boolean): void;
  11678. /** @hidden */
  11679. _getUnpackAlignement(): number;
  11680. /**
  11681. * Creates a dynamic texture
  11682. * @param width defines the width of the texture
  11683. * @param height defines the height of the texture
  11684. * @param generateMipMaps defines if the engine should generate the mip levels
  11685. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11686. * @returns the dynamic texture inside an InternalTexture
  11687. */
  11688. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11689. /**
  11690. * Update the sampling mode of a given texture
  11691. * @param samplingMode defines the required sampling mode
  11692. * @param texture defines the texture to update
  11693. */
  11694. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11695. /**
  11696. * Update the content of a dynamic texture
  11697. * @param texture defines the texture to update
  11698. * @param canvas defines the canvas containing the source
  11699. * @param invertY defines if data must be stored with Y axis inverted
  11700. * @param premulAlpha defines if alpha is stored as premultiplied
  11701. * @param format defines the format of the data
  11702. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11703. */
  11704. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11705. /**
  11706. * Update a video texture
  11707. * @param texture defines the texture to update
  11708. * @param video defines the video element to use
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11712. /**
  11713. * Updates a depth texture Comparison Mode and Function.
  11714. * If the comparison Function is equal to 0, the mode will be set to none.
  11715. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11716. * @param texture The texture to set the comparison function for
  11717. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11718. */
  11719. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11720. private _setupDepthStencilTexture;
  11721. /**
  11722. * Creates a depth stencil texture.
  11723. * This is only available in WebGL 2 or with the depth texture extension available.
  11724. * @param size The size of face edge in the texture.
  11725. * @param options The options defining the texture.
  11726. * @returns The texture
  11727. */
  11728. createDepthStencilTexture(size: number | {
  11729. width: number;
  11730. height: number;
  11731. }, options: DepthTextureCreationOptions): InternalTexture;
  11732. /**
  11733. * Creates a depth stencil texture.
  11734. * This is only available in WebGL 2 or with the depth texture extension available.
  11735. * @param size The size of face edge in the texture.
  11736. * @param options The options defining the texture.
  11737. * @returns The texture
  11738. */
  11739. private _createDepthStencilTexture;
  11740. /**
  11741. * Creates a depth stencil cube texture.
  11742. * This is only available in WebGL 2.
  11743. * @param size The size of face edge in the cube texture.
  11744. * @param options The options defining the cube texture.
  11745. * @returns The cube texture
  11746. */
  11747. private _createDepthStencilCubeTexture;
  11748. /**
  11749. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11750. * @param renderTarget The render target to set the frame buffer for
  11751. */
  11752. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11753. /**
  11754. * Creates a new render target texture
  11755. * @param size defines the size of the texture
  11756. * @param options defines the options used to create the texture
  11757. * @returns a new render target texture stored in an InternalTexture
  11758. */
  11759. createRenderTargetTexture(size: number | {
  11760. width: number;
  11761. height: number;
  11762. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11763. /**
  11764. * Create a multi render target texture
  11765. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11766. * @param size defines the size of the texture
  11767. * @param options defines the creation options
  11768. * @returns the cube texture as an InternalTexture
  11769. */
  11770. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11771. private _setupFramebufferDepthAttachments;
  11772. /**
  11773. * Updates the sample count of a render target texture
  11774. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11775. * @param texture defines the texture to update
  11776. * @param samples defines the sample count to set
  11777. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11778. */
  11779. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11780. /**
  11781. * Update the sample count for a given multiple render target texture
  11782. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11783. * @param textures defines the textures to update
  11784. * @param samples defines the sample count to set
  11785. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11786. */
  11787. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11788. /** @hidden */
  11789. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11790. /** @hidden */
  11791. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11792. /** @hidden */
  11793. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11794. /** @hidden */
  11795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11796. /**
  11797. * Creates a new render target cube texture
  11798. * @param size defines the size of the texture
  11799. * @param options defines the options used to create the texture
  11800. * @returns a new render target cube texture stored in an InternalTexture
  11801. */
  11802. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11803. /**
  11804. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11805. * @param rootUrl defines the url where the file to load is located
  11806. * @param scene defines the current scene
  11807. * @param lodScale defines scale to apply to the mip map selection
  11808. * @param lodOffset defines offset to apply to the mip map selection
  11809. * @param onLoad defines an optional callback raised when the texture is loaded
  11810. * @param onError defines an optional callback raised if there is an issue to load the texture
  11811. * @param format defines the format of the data
  11812. * @param forcedExtension defines the extension to use to pick the right loader
  11813. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11814. * @returns the cube texture as an InternalTexture
  11815. */
  11816. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  11817. /**
  11818. * Creates a cube texture
  11819. * @param rootUrl defines the url where the files to load is located
  11820. * @param scene defines the current scene
  11821. * @param files defines the list of files to load (1 per face)
  11822. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11823. * @param onLoad defines an optional callback raised when the texture is loaded
  11824. * @param onError defines an optional callback raised if there is an issue to load the texture
  11825. * @param format defines the format of the data
  11826. * @param forcedExtension defines the extension to use to pick the right loader
  11827. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11830. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11831. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11832. * @returns the cube texture as an InternalTexture
  11833. */
  11834. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  11835. /**
  11836. * @hidden
  11837. */
  11838. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11839. /**
  11840. * Update a raw cube texture
  11841. * @param texture defines the texture to udpdate
  11842. * @param data defines the data to store
  11843. * @param format defines the data format
  11844. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11845. * @param invertY defines if data must be stored with Y axis inverted
  11846. * @param compression defines the compression used (null by default)
  11847. * @param level defines which level of the texture to update
  11848. */
  11849. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11850. /**
  11851. * Creates a new raw cube texture
  11852. * @param data defines the array of data to use to create each face
  11853. * @param size defines the size of the textures
  11854. * @param format defines the format of the data
  11855. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11856. * @param generateMipMaps defines if the engine should generate the mip levels
  11857. * @param invertY defines if data must be stored with Y axis inverted
  11858. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11859. * @param compression defines the compression used (null by default)
  11860. * @returns the cube texture as an InternalTexture
  11861. */
  11862. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11863. /**
  11864. * Creates a new raw cube texture from a specified url
  11865. * @param url defines the url where the data is located
  11866. * @param scene defines the current scene
  11867. * @param size defines the size of the textures
  11868. * @param format defines the format of the data
  11869. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11870. * @param noMipmap defines if the engine should avoid generating the mip levels
  11871. * @param callback defines a callback used to extract texture data from loaded data
  11872. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11873. * @param onLoad defines a callback called when texture is loaded
  11874. * @param onError defines a callback called if there is an error
  11875. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11876. * @param invertY defines if data must be stored with Y axis inverted
  11877. * @returns the cube texture as an InternalTexture
  11878. */
  11879. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  11880. /**
  11881. * Update a raw 3D texture
  11882. * @param texture defines the texture to update
  11883. * @param data defines the data to store
  11884. * @param format defines the data format
  11885. * @param invertY defines if data must be stored with Y axis inverted
  11886. * @param compression defines the used compression (can be null)
  11887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11888. */
  11889. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11890. /**
  11891. * Creates a new raw 3D texture
  11892. * @param data defines the data used to create the texture
  11893. * @param width defines the width of the texture
  11894. * @param height defines the height of the texture
  11895. * @param depth defines the depth of the texture
  11896. * @param format defines the format of the texture
  11897. * @param generateMipMaps defines if the engine must generate mip levels
  11898. * @param invertY defines if data must be stored with Y axis inverted
  11899. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11900. * @param compression defines the compressed used (can be null)
  11901. * @param textureType defines the compressed used (can be null)
  11902. * @returns a new raw 3D texture (stored in an InternalTexture)
  11903. */
  11904. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11905. private _prepareWebGLTextureContinuation;
  11906. private _prepareWebGLTexture;
  11907. private _convertRGBtoRGBATextureData;
  11908. /** @hidden */
  11909. _releaseFramebufferObjects(texture: InternalTexture): void;
  11910. /** @hidden */
  11911. _releaseTexture(texture: InternalTexture): void;
  11912. private setProgram;
  11913. private _boundUniforms;
  11914. /**
  11915. * Binds an effect to the webGL context
  11916. * @param effect defines the effect to bind
  11917. */
  11918. bindSamplers(effect: Effect): void;
  11919. private _moveBoundTextureOnTop;
  11920. private _getCorrectTextureChannel;
  11921. private _linkTrackers;
  11922. private _removeDesignatedSlot;
  11923. private _activateCurrentTexture;
  11924. /** @hidden */
  11925. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11926. /** @hidden */
  11927. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11928. /**
  11929. * Sets a texture to the webGL context from a postprocess
  11930. * @param channel defines the channel to use
  11931. * @param postProcess defines the source postprocess
  11932. */
  11933. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11934. /**
  11935. * Binds the output of the passed in post process to the texture channel specified
  11936. * @param channel The channel the texture should be bound to
  11937. * @param postProcess The post process which's output should be bound
  11938. */
  11939. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11940. /**
  11941. * Unbind all textures from the webGL context
  11942. */
  11943. unbindAllTextures(): void;
  11944. /**
  11945. * Sets a texture to the according uniform.
  11946. * @param channel The texture channel
  11947. * @param uniform The uniform to set
  11948. * @param texture The texture to apply
  11949. */
  11950. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11951. /**
  11952. * Sets a depth stencil texture from a render target to the according uniform.
  11953. * @param channel The texture channel
  11954. * @param uniform The uniform to set
  11955. * @param texture The render target texture containing the depth stencil texture to apply
  11956. */
  11957. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11958. private _bindSamplerUniformToChannel;
  11959. private _getTextureWrapMode;
  11960. private _setTexture;
  11961. /**
  11962. * Sets an array of texture to the webGL context
  11963. * @param channel defines the channel where the texture array must be set
  11964. * @param uniform defines the associated uniform location
  11965. * @param textures defines the array of textures to bind
  11966. */
  11967. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11968. /** @hidden */
  11969. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11970. private _setTextureParameterFloat;
  11971. private _setTextureParameterInteger;
  11972. /**
  11973. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11974. * @param x defines the x coordinate of the rectangle where pixels must be read
  11975. * @param y defines the y coordinate of the rectangle where pixels must be read
  11976. * @param width defines the width of the rectangle where pixels must be read
  11977. * @param height defines the height of the rectangle where pixels must be read
  11978. * @returns a Uint8Array containing RGBA colors
  11979. */
  11980. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11981. /**
  11982. * Add an externaly attached data from its key.
  11983. * This method call will fail and return false, if such key already exists.
  11984. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11985. * @param key the unique key that identifies the data
  11986. * @param data the data object to associate to the key for this Engine instance
  11987. * @return true if no such key were already present and the data was added successfully, false otherwise
  11988. */
  11989. addExternalData<T>(key: string, data: T): boolean;
  11990. /**
  11991. * Get an externaly attached data from its key
  11992. * @param key the unique key that identifies the data
  11993. * @return the associated data, if present (can be null), or undefined if not present
  11994. */
  11995. getExternalData<T>(key: string): T;
  11996. /**
  11997. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11998. * @param key the unique key that identifies the data
  11999. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  12000. * @return the associated data, can be null if the factory returned null.
  12001. */
  12002. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  12003. /**
  12004. * Remove an externaly attached data from the Engine instance
  12005. * @param key the unique key that identifies the data
  12006. * @return true if the data was successfully removed, false if it doesn't exist
  12007. */
  12008. removeExternalData(key: string): boolean;
  12009. /**
  12010. * Unbind all vertex attributes from the webGL context
  12011. */
  12012. unbindAllAttributes(): void;
  12013. /**
  12014. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  12015. */
  12016. releaseEffects(): void;
  12017. /**
  12018. * Dispose and release all associated resources
  12019. */
  12020. dispose(): void;
  12021. /**
  12022. * Display the loading screen
  12023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12024. */
  12025. displayLoadingUI(): void;
  12026. /**
  12027. * Hide the loading screen
  12028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12029. */
  12030. hideLoadingUI(): void;
  12031. /**
  12032. * Gets the current loading screen object
  12033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12034. */
  12035. /**
  12036. * Sets the current loading screen object
  12037. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12038. */
  12039. loadingScreen: ILoadingScreen;
  12040. /**
  12041. * Sets the current loading screen text
  12042. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12043. */
  12044. loadingUIText: string;
  12045. /**
  12046. * Sets the current loading screen background color
  12047. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12048. */
  12049. loadingUIBackgroundColor: string;
  12050. /**
  12051. * Attach a new callback raised when context lost event is fired
  12052. * @param callback defines the callback to call
  12053. */
  12054. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12055. /**
  12056. * Attach a new callback raised when context restored event is fired
  12057. * @param callback defines the callback to call
  12058. */
  12059. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12060. /**
  12061. * Gets the source code of the vertex shader associated with a specific webGL program
  12062. * @param program defines the program to use
  12063. * @returns a string containing the source code of the vertex shader associated with the program
  12064. */
  12065. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12066. /**
  12067. * Gets the source code of the fragment shader associated with a specific webGL program
  12068. * @param program defines the program to use
  12069. * @returns a string containing the source code of the fragment shader associated with the program
  12070. */
  12071. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12072. /**
  12073. * Get the current error code of the webGL context
  12074. * @returns the error code
  12075. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12076. */
  12077. getError(): number;
  12078. /**
  12079. * Gets the current framerate
  12080. * @returns a number representing the framerate
  12081. */
  12082. getFps(): number;
  12083. /**
  12084. * Gets the time spent between current and previous frame
  12085. * @returns a number representing the delta time in ms
  12086. */
  12087. getDeltaTime(): number;
  12088. private _measureFps;
  12089. /** @hidden */
  12090. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12091. private _canRenderToFloatFramebuffer;
  12092. private _canRenderToHalfFloatFramebuffer;
  12093. private _canRenderToFramebuffer;
  12094. /** @hidden */
  12095. _getWebGLTextureType(type: number): number;
  12096. private _getInternalFormat;
  12097. /** @hidden */
  12098. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12099. /** @hidden */
  12100. _getRGBAMultiSampleBufferFormat(type: number): number;
  12101. /** @hidden */
  12102. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  12103. /** @hidden */
  12104. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12105. private _partialLoadFile;
  12106. private _cascadeLoadFiles;
  12107. /**
  12108. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12109. * @returns true if the engine can be created
  12110. * @ignorenaming
  12111. */
  12112. static isSupported(): boolean;
  12113. }
  12114. }
  12115. declare module BABYLON {
  12116. /**
  12117. * Options to create the null engine
  12118. */
  12119. class NullEngineOptions {
  12120. /**
  12121. * Render width (Default: 512)
  12122. */
  12123. renderWidth: number;
  12124. /**
  12125. * Render height (Default: 256)
  12126. */
  12127. renderHeight: number;
  12128. /**
  12129. * Texture size (Default: 512)
  12130. */
  12131. textureSize: number;
  12132. /**
  12133. * If delta time between frames should be constant
  12134. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12135. */
  12136. deterministicLockstep: boolean;
  12137. /**
  12138. * Maximum about of steps between frames (Default: 4)
  12139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12140. */
  12141. lockstepMaxSteps: number;
  12142. }
  12143. /**
  12144. * The null engine class provides support for headless version of babylon.js.
  12145. * This can be used in server side scenario or for testing purposes
  12146. */
  12147. class NullEngine extends Engine {
  12148. private _options;
  12149. /**
  12150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12151. */
  12152. isDeterministicLockStep(): boolean;
  12153. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12154. getLockstepMaxSteps(): number;
  12155. /**
  12156. * Sets hardware scaling, used to save performance if needed
  12157. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12158. */
  12159. getHardwareScalingLevel(): number;
  12160. constructor(options?: NullEngineOptions);
  12161. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12162. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12163. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12164. getRenderWidth(useScreen?: boolean): number;
  12165. getRenderHeight(useScreen?: boolean): number;
  12166. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12167. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12168. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12169. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12170. bindSamplers(effect: Effect): void;
  12171. enableEffect(effect: Effect): void;
  12172. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12173. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12174. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12175. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12176. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12177. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12178. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12179. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12180. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12181. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12182. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12183. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12184. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12185. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12186. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12187. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12188. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12189. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12190. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12191. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12192. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12193. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12194. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12195. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12196. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12197. bindBuffers(vertexBuffers: {
  12198. [key: string]: VertexBuffer;
  12199. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12200. wipeCaches(bruteForce?: boolean): void;
  12201. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12202. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12203. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12204. /** @hidden */
  12205. _createTexture(): WebGLTexture;
  12206. /** @hidden */
  12207. _releaseTexture(texture: InternalTexture): void;
  12208. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  12209. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12210. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12211. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12212. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12213. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12214. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12215. areAllEffectsReady(): boolean;
  12216. /**
  12217. * @hidden
  12218. * Get the current error code of the webGL context
  12219. * @returns the error code
  12220. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12221. */
  12222. getError(): number;
  12223. /** @hidden */
  12224. _getUnpackAlignement(): number;
  12225. /** @hidden */
  12226. _unpackFlipY(value: boolean): void;
  12227. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12228. /**
  12229. * Updates a dynamic vertex buffer.
  12230. * @param vertexBuffer the vertex buffer to update
  12231. * @param data the data used to update the vertex buffer
  12232. * @param byteOffset the byte offset of the data (optional)
  12233. * @param byteLength the byte length of the data (optional)
  12234. */
  12235. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12236. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12237. /** @hidden */
  12238. _bindTexture(channel: number, texture: InternalTexture): void;
  12239. /** @hidden */
  12240. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12241. releaseEffects(): void;
  12242. displayLoadingUI(): void;
  12243. hideLoadingUI(): void;
  12244. /** @hidden */
  12245. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12246. /** @hidden */
  12247. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12248. /** @hidden */
  12249. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12250. /** @hidden */
  12251. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12252. }
  12253. }
  12254. interface WebGLRenderingContext {
  12255. readonly RASTERIZER_DISCARD: number;
  12256. readonly DEPTH_COMPONENT24: number;
  12257. readonly TEXTURE_3D: number;
  12258. readonly TEXTURE_2D_ARRAY: number;
  12259. readonly TEXTURE_COMPARE_FUNC: number;
  12260. readonly TEXTURE_COMPARE_MODE: number;
  12261. readonly COMPARE_REF_TO_TEXTURE: number;
  12262. readonly TEXTURE_WRAP_R: number;
  12263. readonly HALF_FLOAT: number;
  12264. readonly RGB8: number;
  12265. readonly RED_INTEGER: number;
  12266. readonly RG_INTEGER: number;
  12267. readonly RGB_INTEGER: number;
  12268. readonly RGBA_INTEGER: number;
  12269. readonly R8_SNORM: number;
  12270. readonly RG8_SNORM: number;
  12271. readonly RGB8_SNORM: number;
  12272. readonly RGBA8_SNORM: number;
  12273. readonly R8I: number;
  12274. readonly RG8I: number;
  12275. readonly RGB8I: number;
  12276. readonly RGBA8I: number;
  12277. readonly R8UI: number;
  12278. readonly RG8UI: number;
  12279. readonly RGB8UI: number;
  12280. readonly RGBA8UI: number;
  12281. readonly R16I: number;
  12282. readonly RG16I: number;
  12283. readonly RGB16I: number;
  12284. readonly RGBA16I: number;
  12285. readonly R16UI: number;
  12286. readonly RG16UI: number;
  12287. readonly RGB16UI: number;
  12288. readonly RGBA16UI: number;
  12289. readonly R32I: number;
  12290. readonly RG32I: number;
  12291. readonly RGB32I: number;
  12292. readonly RGBA32I: number;
  12293. readonly R32UI: number;
  12294. readonly RG32UI: number;
  12295. readonly RGB32UI: number;
  12296. readonly RGBA32UI: number;
  12297. readonly RGB10_A2UI: number;
  12298. readonly R11F_G11F_B10F: number;
  12299. readonly RGB9_E5: number;
  12300. readonly RGB10_A2: number;
  12301. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12302. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12303. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12304. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12305. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12306. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12307. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
  12308. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12309. readonly TRANSFORM_FEEDBACK: number;
  12310. readonly INTERLEAVED_ATTRIBS: number;
  12311. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12312. createTransformFeedback(): WebGLTransformFeedback;
  12313. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12314. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12315. beginTransformFeedback(primitiveMode: number): void;
  12316. endTransformFeedback(): void;
  12317. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12318. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12319. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12320. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12321. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12322. }
  12323. interface ImageBitmap {
  12324. readonly width: number;
  12325. readonly height: number;
  12326. close(): void;
  12327. }
  12328. interface WebGLQuery extends WebGLObject {
  12329. }
  12330. declare var WebGLQuery: {
  12331. prototype: WebGLQuery;
  12332. new (): WebGLQuery;
  12333. };
  12334. interface WebGLSampler extends WebGLObject {
  12335. }
  12336. declare var WebGLSampler: {
  12337. prototype: WebGLSampler;
  12338. new (): WebGLSampler;
  12339. };
  12340. interface WebGLSync extends WebGLObject {
  12341. }
  12342. declare var WebGLSync: {
  12343. prototype: WebGLSync;
  12344. new (): WebGLSync;
  12345. };
  12346. interface WebGLTransformFeedback extends WebGLObject {
  12347. }
  12348. declare var WebGLTransformFeedback: {
  12349. prototype: WebGLTransformFeedback;
  12350. new (): WebGLTransformFeedback;
  12351. };
  12352. interface WebGLVertexArrayObject extends WebGLObject {
  12353. }
  12354. declare var WebGLVertexArrayObject: {
  12355. prototype: WebGLVertexArrayObject;
  12356. new (): WebGLVertexArrayObject;
  12357. };
  12358. declare module BABYLON {
  12359. /**
  12360. * Represents a gamepad control stick position
  12361. */
  12362. class StickValues {
  12363. /**
  12364. * The x component of the control stick
  12365. */
  12366. x: number;
  12367. /**
  12368. * The y component of the control stick
  12369. */
  12370. y: number;
  12371. /**
  12372. * Initializes the gamepad x and y control stick values
  12373. * @param x The x component of the gamepad control stick value
  12374. * @param y The y component of the gamepad control stick value
  12375. */
  12376. constructor(
  12377. /**
  12378. * The x component of the control stick
  12379. */
  12380. x: number,
  12381. /**
  12382. * The y component of the control stick
  12383. */
  12384. y: number);
  12385. }
  12386. /**
  12387. * An interface which manages callbacks for gamepad button changes
  12388. */
  12389. interface GamepadButtonChanges {
  12390. /**
  12391. * Called when a gamepad has been changed
  12392. */
  12393. changed: boolean;
  12394. /**
  12395. * Called when a gamepad press event has been triggered
  12396. */
  12397. pressChanged: boolean;
  12398. /**
  12399. * Called when a touch event has been triggered
  12400. */
  12401. touchChanged: boolean;
  12402. /**
  12403. * Called when a value has changed
  12404. */
  12405. valueChanged: boolean;
  12406. }
  12407. /**
  12408. * Represents a gamepad
  12409. */
  12410. class Gamepad {
  12411. /**
  12412. * The id of the gamepad
  12413. */
  12414. id: string;
  12415. /**
  12416. * The index of the gamepad
  12417. */
  12418. index: number;
  12419. /**
  12420. * The browser gamepad
  12421. */
  12422. browserGamepad: any;
  12423. /**
  12424. * Specifies what type of gamepad this represents
  12425. */
  12426. type: number;
  12427. private _leftStick;
  12428. private _rightStick;
  12429. /** @hidden */
  12430. _isConnected: boolean;
  12431. private _leftStickAxisX;
  12432. private _leftStickAxisY;
  12433. private _rightStickAxisX;
  12434. private _rightStickAxisY;
  12435. /**
  12436. * Triggered when the left control stick has been changed
  12437. */
  12438. private _onleftstickchanged;
  12439. /**
  12440. * Triggered when the right control stick has been changed
  12441. */
  12442. private _onrightstickchanged;
  12443. /**
  12444. * Represents a gamepad controller
  12445. */
  12446. static GAMEPAD: number;
  12447. /**
  12448. * Represents a generic controller
  12449. */
  12450. static GENERIC: number;
  12451. /**
  12452. * Represents an XBox controller
  12453. */
  12454. static XBOX: number;
  12455. /**
  12456. * Represents a pose-enabled controller
  12457. */
  12458. static POSE_ENABLED: number;
  12459. /**
  12460. * Specifies whether the left control stick should be Y-inverted
  12461. */
  12462. protected _invertLeftStickY: boolean;
  12463. /**
  12464. * Specifies if the gamepad has been connected
  12465. */
  12466. readonly isConnected: boolean;
  12467. /**
  12468. * Initializes the gamepad
  12469. * @param id The id of the gamepad
  12470. * @param index The index of the gamepad
  12471. * @param browserGamepad The browser gamepad
  12472. * @param leftStickX The x component of the left joystick
  12473. * @param leftStickY The y component of the left joystick
  12474. * @param rightStickX The x component of the right joystick
  12475. * @param rightStickY The y component of the right joystick
  12476. */
  12477. constructor(
  12478. /**
  12479. * The id of the gamepad
  12480. */
  12481. id: string,
  12482. /**
  12483. * The index of the gamepad
  12484. */
  12485. index: number,
  12486. /**
  12487. * The browser gamepad
  12488. */
  12489. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12490. /**
  12491. * Callback triggered when the left joystick has changed
  12492. * @param callback
  12493. */
  12494. onleftstickchanged(callback: (values: StickValues) => void): void;
  12495. /**
  12496. * Callback triggered when the right joystick has changed
  12497. * @param callback
  12498. */
  12499. onrightstickchanged(callback: (values: StickValues) => void): void;
  12500. /**
  12501. * Gets the left joystick
  12502. */
  12503. /**
  12504. * Sets the left joystick values
  12505. */
  12506. leftStick: StickValues;
  12507. /**
  12508. * Gets the right joystick
  12509. */
  12510. /**
  12511. * Sets the right joystick value
  12512. */
  12513. rightStick: StickValues;
  12514. /**
  12515. * Updates the gamepad joystick positions
  12516. */
  12517. update(): void;
  12518. /**
  12519. * Disposes the gamepad
  12520. */
  12521. dispose(): void;
  12522. }
  12523. /**
  12524. * Represents a generic gamepad
  12525. */
  12526. class GenericPad extends Gamepad {
  12527. private _buttons;
  12528. private _onbuttondown;
  12529. private _onbuttonup;
  12530. /**
  12531. * Observable triggered when a button has been pressed
  12532. */
  12533. onButtonDownObservable: Observable<number>;
  12534. /**
  12535. * Observable triggered when a button has been released
  12536. */
  12537. onButtonUpObservable: Observable<number>;
  12538. /**
  12539. * Callback triggered when a button has been pressed
  12540. * @param callback Called when a button has been pressed
  12541. */
  12542. onbuttondown(callback: (buttonPressed: number) => void): void;
  12543. /**
  12544. * Callback triggered when a button has been released
  12545. * @param callback Called when a button has been released
  12546. */
  12547. onbuttonup(callback: (buttonReleased: number) => void): void;
  12548. /**
  12549. * Initializes the generic gamepad
  12550. * @param id The id of the generic gamepad
  12551. * @param index The index of the generic gamepad
  12552. * @param browserGamepad The browser gamepad
  12553. */
  12554. constructor(id: string, index: number, browserGamepad: any);
  12555. private _setButtonValue;
  12556. /**
  12557. * Updates the generic gamepad
  12558. */
  12559. update(): void;
  12560. /**
  12561. * Disposes the generic gamepad
  12562. */
  12563. dispose(): void;
  12564. }
  12565. }
  12566. declare module BABYLON {
  12567. /**
  12568. * Manager for handling gamepads
  12569. */
  12570. class GamepadManager {
  12571. private _scene?;
  12572. private _babylonGamepads;
  12573. private _oneGamepadConnected;
  12574. /** @hidden */
  12575. _isMonitoring: boolean;
  12576. private _gamepadEventSupported;
  12577. private _gamepadSupport;
  12578. /**
  12579. * observable to be triggered when the gamepad controller has been connected
  12580. */
  12581. onGamepadConnectedObservable: Observable<Gamepad>;
  12582. /**
  12583. * observable to be triggered when the gamepad controller has been disconnected
  12584. */
  12585. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12586. private _onGamepadConnectedEvent;
  12587. private _onGamepadDisconnectedEvent;
  12588. /**
  12589. * Initializes the gamepad manager
  12590. * @param _scene BabylonJS scene
  12591. */
  12592. constructor(_scene?: Scene | undefined);
  12593. /**
  12594. * The gamepads in the game pad manager
  12595. */
  12596. readonly gamepads: Gamepad[];
  12597. /**
  12598. * Get the gamepad controllers based on type
  12599. * @param type The type of gamepad controller
  12600. * @returns Nullable gamepad
  12601. */
  12602. getGamepadByType(type?: number): Nullable<Gamepad>;
  12603. /**
  12604. * Disposes the gamepad manager
  12605. */
  12606. dispose(): void;
  12607. private _addNewGamepad;
  12608. private _startMonitoringGamepads;
  12609. private _stopMonitoringGamepads;
  12610. /** @hidden */
  12611. _checkGamepadsStatus(): void;
  12612. private _updateGamepadObjects;
  12613. }
  12614. }
  12615. declare module BABYLON {
  12616. interface Scene {
  12617. /** @hidden */
  12618. _gamepadManager: Nullable<GamepadManager>;
  12619. /**
  12620. * Gets the gamepad manager associated with the scene
  12621. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12622. */
  12623. gamepadManager: GamepadManager;
  12624. }
  12625. /**
  12626. * Interface representing a free camera inputs manager
  12627. */
  12628. interface FreeCameraInputsManager {
  12629. /**
  12630. * Adds gamepad input support to the FreeCameraInputsManager.
  12631. * @returns the FreeCameraInputsManager
  12632. */
  12633. addGamepad(): FreeCameraInputsManager;
  12634. }
  12635. /**
  12636. * Interface representing an arc rotate camera inputs manager
  12637. */
  12638. interface ArcRotateCameraInputsManager {
  12639. /**
  12640. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12641. * @returns the camera inputs manager
  12642. */
  12643. addGamepad(): ArcRotateCameraInputsManager;
  12644. }
  12645. /**
  12646. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12647. */
  12648. class GamepadSystemSceneComponent implements ISceneComponent {
  12649. /**
  12650. * The component name helpfull to identify the component in the list of scene components.
  12651. */
  12652. readonly name: string;
  12653. /**
  12654. * The scene the component belongs to.
  12655. */
  12656. scene: Scene;
  12657. /**
  12658. * Creates a new instance of the component for the given scene
  12659. * @param scene Defines the scene to register the component in
  12660. */
  12661. constructor(scene: Scene);
  12662. /**
  12663. * Registers the component in a given scene
  12664. */
  12665. register(): void;
  12666. /**
  12667. * Rebuilds the elements related to this component in case of
  12668. * context lost for instance.
  12669. */
  12670. rebuild(): void;
  12671. /**
  12672. * Disposes the component and the associated ressources
  12673. */
  12674. dispose(): void;
  12675. private _beforeCameraUpdate;
  12676. }
  12677. }
  12678. declare module BABYLON {
  12679. /**
  12680. * Defines supported buttons for XBox360 compatible gamepads
  12681. */
  12682. enum Xbox360Button {
  12683. /** A */
  12684. A = 0,
  12685. /** B */
  12686. B = 1,
  12687. /** X */
  12688. X = 2,
  12689. /** Y */
  12690. Y = 3,
  12691. /** Start */
  12692. Start = 4,
  12693. /** Back */
  12694. Back = 5,
  12695. /** Left button */
  12696. LB = 6,
  12697. /** Right button */
  12698. RB = 7,
  12699. /** Left stick */
  12700. LeftStick = 8,
  12701. /** Right stick */
  12702. RightStick = 9
  12703. }
  12704. /** Defines values for XBox360 DPad */
  12705. enum Xbox360Dpad {
  12706. /** Up */
  12707. Up = 0,
  12708. /** Down */
  12709. Down = 1,
  12710. /** Left */
  12711. Left = 2,
  12712. /** Right */
  12713. Right = 3
  12714. }
  12715. /**
  12716. * Defines a XBox360 gamepad
  12717. */
  12718. class Xbox360Pad extends Gamepad {
  12719. private _leftTrigger;
  12720. private _rightTrigger;
  12721. private _onlefttriggerchanged;
  12722. private _onrighttriggerchanged;
  12723. private _onbuttondown;
  12724. private _onbuttonup;
  12725. private _ondpaddown;
  12726. private _ondpadup;
  12727. /** Observable raised when a button is pressed */
  12728. onButtonDownObservable: Observable<Xbox360Button>;
  12729. /** Observable raised when a button is released */
  12730. onButtonUpObservable: Observable<Xbox360Button>;
  12731. /** Observable raised when a pad is pressed */
  12732. onPadDownObservable: Observable<Xbox360Dpad>;
  12733. /** Observable raised when a pad is released */
  12734. onPadUpObservable: Observable<Xbox360Dpad>;
  12735. private _buttonA;
  12736. private _buttonB;
  12737. private _buttonX;
  12738. private _buttonY;
  12739. private _buttonBack;
  12740. private _buttonStart;
  12741. private _buttonLB;
  12742. private _buttonRB;
  12743. private _buttonLeftStick;
  12744. private _buttonRightStick;
  12745. private _dPadUp;
  12746. private _dPadDown;
  12747. private _dPadLeft;
  12748. private _dPadRight;
  12749. private _isXboxOnePad;
  12750. /**
  12751. * Creates a new XBox360 gamepad object
  12752. * @param id defines the id of this gamepad
  12753. * @param index defines its index
  12754. * @param gamepad defines the internal HTML gamepad object
  12755. * @param xboxOne defines if it is a XBox One gamepad
  12756. */
  12757. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12758. /**
  12759. * Defines the callback to call when left trigger is pressed
  12760. * @param callback defines the callback to use
  12761. */
  12762. onlefttriggerchanged(callback: (value: number) => void): void;
  12763. /**
  12764. * Defines the callback to call when right trigger is pressed
  12765. * @param callback defines the callback to use
  12766. */
  12767. onrighttriggerchanged(callback: (value: number) => void): void;
  12768. /**
  12769. * Gets the left trigger value
  12770. */
  12771. /**
  12772. * Sets the left trigger value
  12773. */
  12774. leftTrigger: number;
  12775. /**
  12776. * Gets the right trigger value
  12777. */
  12778. /**
  12779. * Sets the right trigger value
  12780. */
  12781. rightTrigger: number;
  12782. /**
  12783. * Defines the callback to call when a button is pressed
  12784. * @param callback defines the callback to use
  12785. */
  12786. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12787. /**
  12788. * Defines the callback to call when a button is released
  12789. * @param callback defines the callback to use
  12790. */
  12791. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12792. /**
  12793. * Defines the callback to call when a pad is pressed
  12794. * @param callback defines the callback to use
  12795. */
  12796. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12797. /**
  12798. * Defines the callback to call when a pad is released
  12799. * @param callback defines the callback to use
  12800. */
  12801. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12802. private _setButtonValue;
  12803. private _setDPadValue;
  12804. /**
  12805. * Gets the value of the `A` button
  12806. */
  12807. /**
  12808. * Sets the value of the `A` button
  12809. */
  12810. buttonA: number;
  12811. /**
  12812. * Gets the value of the `B` button
  12813. */
  12814. /**
  12815. * Sets the value of the `B` button
  12816. */
  12817. buttonB: number;
  12818. /**
  12819. * Gets the value of the `X` button
  12820. */
  12821. /**
  12822. * Sets the value of the `X` button
  12823. */
  12824. buttonX: number;
  12825. /**
  12826. * Gets the value of the `Y` button
  12827. */
  12828. /**
  12829. * Sets the value of the `Y` button
  12830. */
  12831. buttonY: number;
  12832. /**
  12833. * Gets the value of the `Start` button
  12834. */
  12835. /**
  12836. * Sets the value of the `Start` button
  12837. */
  12838. buttonStart: number;
  12839. /**
  12840. * Gets the value of the `Back` button
  12841. */
  12842. /**
  12843. * Sets the value of the `Back` button
  12844. */
  12845. buttonBack: number;
  12846. /**
  12847. * Gets the value of the `Left` button
  12848. */
  12849. /**
  12850. * Sets the value of the `Left` button
  12851. */
  12852. buttonLB: number;
  12853. /**
  12854. * Gets the value of the `Right` button
  12855. */
  12856. /**
  12857. * Sets the value of the `Right` button
  12858. */
  12859. buttonRB: number;
  12860. /**
  12861. * Gets the value of the Left joystick
  12862. */
  12863. /**
  12864. * Sets the value of the Left joystick
  12865. */
  12866. buttonLeftStick: number;
  12867. /**
  12868. * Gets the value of the Right joystick
  12869. */
  12870. /**
  12871. * Sets the value of the Right joystick
  12872. */
  12873. buttonRightStick: number;
  12874. /**
  12875. * Gets the value of D-pad up
  12876. */
  12877. /**
  12878. * Sets the value of D-pad up
  12879. */
  12880. dPadUp: number;
  12881. /**
  12882. * Gets the value of D-pad down
  12883. */
  12884. /**
  12885. * Sets the value of D-pad down
  12886. */
  12887. dPadDown: number;
  12888. /**
  12889. * Gets the value of D-pad left
  12890. */
  12891. /**
  12892. * Sets the value of D-pad left
  12893. */
  12894. dPadLeft: number;
  12895. /**
  12896. * Gets the value of D-pad right
  12897. */
  12898. /**
  12899. * Sets the value of D-pad right
  12900. */
  12901. dPadRight: number;
  12902. /**
  12903. * Force the gamepad to synchronize with device values
  12904. */
  12905. update(): void;
  12906. /**
  12907. * Disposes the gamepad
  12908. */
  12909. dispose(): void;
  12910. }
  12911. }
  12912. declare module BABYLON {
  12913. /**
  12914. * Gather the list of clipboard event types as constants.
  12915. */
  12916. class ClipboardEventTypes {
  12917. /**
  12918. * The clipboard event is fired when a copy command is active (pressed).
  12919. */
  12920. static readonly COPY: number;
  12921. /**
  12922. * The clipboard event is fired when a cut command is active (pressed).
  12923. */
  12924. static readonly CUT: number;
  12925. /**
  12926. * The clipboard event is fired when a paste command is active (pressed).
  12927. */
  12928. static readonly PASTE: number;
  12929. }
  12930. /**
  12931. * This class is used to store clipboard related info for the onClipboardObservable event.
  12932. */
  12933. class ClipboardInfo {
  12934. /**
  12935. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12936. */
  12937. type: number;
  12938. /**
  12939. * Defines the related dom event
  12940. */
  12941. event: ClipboardEvent;
  12942. /**
  12943. *Creates an instance of ClipboardInfo.
  12944. * @param {number} type
  12945. * @param {ClipboardEvent} event
  12946. */
  12947. constructor(
  12948. /**
  12949. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12950. */
  12951. type: number,
  12952. /**
  12953. * Defines the related dom event
  12954. */
  12955. event: ClipboardEvent);
  12956. /**
  12957. * Get the clipboard event's type from the keycode.
  12958. * @param keyCode Defines the keyCode for the current keyboard event.
  12959. * @return {number}
  12960. */
  12961. static GetTypeFromCharacter(keyCode: number): number;
  12962. }
  12963. }
  12964. declare module BABYLON {
  12965. /**
  12966. * Gather the list of keyboard event types as constants.
  12967. */
  12968. class KeyboardEventTypes {
  12969. /**
  12970. * The keydown event is fired when a key becomes active (pressed).
  12971. */
  12972. static readonly KEYDOWN: number;
  12973. /**
  12974. * The keyup event is fired when a key has been released.
  12975. */
  12976. static readonly KEYUP: number;
  12977. }
  12978. /**
  12979. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12980. */
  12981. class KeyboardInfo {
  12982. /**
  12983. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12984. */
  12985. type: number;
  12986. /**
  12987. * Defines the related dom event
  12988. */
  12989. event: KeyboardEvent;
  12990. /**
  12991. * Instantiates a new keyboard info.
  12992. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12993. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12994. * @param event Defines the related dom event
  12995. */
  12996. constructor(
  12997. /**
  12998. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12999. */
  13000. type: number,
  13001. /**
  13002. * Defines the related dom event
  13003. */
  13004. event: KeyboardEvent);
  13005. }
  13006. /**
  13007. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  13008. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  13009. */
  13010. class KeyboardInfoPre extends KeyboardInfo {
  13011. /**
  13012. * Defines the type of event (BABYLON.KeyboardEventTypes)
  13013. */
  13014. type: number;
  13015. /**
  13016. * Defines the related dom event
  13017. */
  13018. event: KeyboardEvent;
  13019. /**
  13020. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  13021. */
  13022. skipOnPointerObservable: boolean;
  13023. /**
  13024. * Instantiates a new keyboard pre info.
  13025. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  13026. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  13027. * @param event Defines the related dom event
  13028. */
  13029. constructor(
  13030. /**
  13031. * Defines the type of event (BABYLON.KeyboardEventTypes)
  13032. */
  13033. type: number,
  13034. /**
  13035. * Defines the related dom event
  13036. */
  13037. event: KeyboardEvent);
  13038. }
  13039. }
  13040. declare module BABYLON {
  13041. /**
  13042. * Gather the list of pointer event types as constants.
  13043. */
  13044. class PointerEventTypes {
  13045. /**
  13046. * 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.
  13047. */
  13048. static readonly POINTERDOWN: number;
  13049. /**
  13050. * The pointerup event is fired when a pointer is no longer active.
  13051. */
  13052. static readonly POINTERUP: number;
  13053. /**
  13054. * The pointermove event is fired when a pointer changes coordinates.
  13055. */
  13056. static readonly POINTERMOVE: number;
  13057. /**
  13058. * The pointerwheel event is fired when a mouse wheel has been rotated.
  13059. */
  13060. static readonly POINTERWHEEL: number;
  13061. /**
  13062. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  13063. */
  13064. static readonly POINTERPICK: number;
  13065. /**
  13066. * The pointertap event is fired when a the object has been touched and released without drag.
  13067. */
  13068. static readonly POINTERTAP: number;
  13069. /**
  13070. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  13071. */
  13072. static readonly POINTERDOUBLETAP: number;
  13073. }
  13074. /**
  13075. * Base class of pointer info types.
  13076. */
  13077. class PointerInfoBase {
  13078. /**
  13079. * Defines the type of event (BABYLON.PointerEventTypes)
  13080. */
  13081. type: number;
  13082. /**
  13083. * Defines the related dom event
  13084. */
  13085. event: PointerEvent | MouseWheelEvent;
  13086. /**
  13087. * Instantiates the base class of pointers info.
  13088. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  13089. * @param event Defines the related dom event
  13090. */
  13091. constructor(
  13092. /**
  13093. * Defines the type of event (BABYLON.PointerEventTypes)
  13094. */
  13095. type: number,
  13096. /**
  13097. * Defines the related dom event
  13098. */
  13099. event: PointerEvent | MouseWheelEvent);
  13100. }
  13101. /**
  13102. * This class is used to store pointer related info for the onPrePointerObservable event.
  13103. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  13104. */
  13105. class PointerInfoPre extends PointerInfoBase {
  13106. /**
  13107. * Ray from a pointer if availible (eg. 6dof controller)
  13108. */
  13109. ray: Nullable<Ray>;
  13110. /**
  13111. * Defines the local position of the pointer on the canvas.
  13112. */
  13113. localPosition: Vector2;
  13114. /**
  13115. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  13116. */
  13117. skipOnPointerObservable: boolean;
  13118. /**
  13119. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  13120. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  13121. * @param event Defines the related dom event
  13122. * @param localX Defines the local x coordinates of the pointer when the event occured
  13123. * @param localY Defines the local y coordinates of the pointer when the event occured
  13124. */
  13125. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  13126. }
  13127. /**
  13128. * This type contains all the data related to a pointer event in Babylon.js.
  13129. * 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.
  13130. */
  13131. class PointerInfo extends PointerInfoBase {
  13132. /**
  13133. * Defines the picking info associated to the info (if any)\
  13134. */
  13135. pickInfo: Nullable<PickingInfo>;
  13136. /**
  13137. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  13138. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  13139. * @param event Defines the related dom event
  13140. * @param pickInfo Defines the picking info associated to the info (if any)\
  13141. */
  13142. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  13143. /**
  13144. * Defines the picking info associated to the info (if any)\
  13145. */
  13146. pickInfo: Nullable<PickingInfo>);
  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. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16554. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16555. * 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;
  16556. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16557. */
  16558. class ColorCurves {
  16559. private _dirty;
  16560. private _tempColor;
  16561. private _globalCurve;
  16562. private _highlightsCurve;
  16563. private _midtonesCurve;
  16564. private _shadowsCurve;
  16565. private _positiveCurve;
  16566. private _negativeCurve;
  16567. private _globalHue;
  16568. private _globalDensity;
  16569. private _globalSaturation;
  16570. private _globalExposure;
  16571. /**
  16572. * Gets the global Hue value.
  16573. * 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).
  16574. */
  16575. /**
  16576. * Sets the global Hue value.
  16577. * 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).
  16578. */
  16579. globalHue: number;
  16580. /**
  16581. * Gets the global Density value.
  16582. * 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.
  16583. * Values less than zero provide a filter of opposite hue.
  16584. */
  16585. /**
  16586. * Sets the global Density value.
  16587. * 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.
  16588. * Values less than zero provide a filter of opposite hue.
  16589. */
  16590. globalDensity: number;
  16591. /**
  16592. * Gets the global Saturation value.
  16593. * 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.
  16594. */
  16595. /**
  16596. * Sets the global Saturation value.
  16597. * 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.
  16598. */
  16599. globalSaturation: number;
  16600. /**
  16601. * Gets the global Exposure value.
  16602. * 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.
  16603. */
  16604. /**
  16605. * Sets the global Exposure value.
  16606. * 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.
  16607. */
  16608. globalExposure: number;
  16609. private _highlightsHue;
  16610. private _highlightsDensity;
  16611. private _highlightsSaturation;
  16612. private _highlightsExposure;
  16613. /**
  16614. * Gets the highlights Hue value.
  16615. * 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).
  16616. */
  16617. /**
  16618. * Sets the highlights Hue value.
  16619. * 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).
  16620. */
  16621. highlightsHue: number;
  16622. /**
  16623. * Gets the highlights Density value.
  16624. * 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.
  16625. * Values less than zero provide a filter of opposite hue.
  16626. */
  16627. /**
  16628. * Sets the highlights Density value.
  16629. * 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.
  16630. * Values less than zero provide a filter of opposite hue.
  16631. */
  16632. highlightsDensity: number;
  16633. /**
  16634. * Gets the highlights Saturation value.
  16635. * 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.
  16636. */
  16637. /**
  16638. * Sets the highlights Saturation value.
  16639. * 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.
  16640. */
  16641. highlightsSaturation: number;
  16642. /**
  16643. * Gets the highlights Exposure value.
  16644. * 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.
  16645. */
  16646. /**
  16647. * Sets the highlights Exposure value.
  16648. * 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.
  16649. */
  16650. highlightsExposure: number;
  16651. private _midtonesHue;
  16652. private _midtonesDensity;
  16653. private _midtonesSaturation;
  16654. private _midtonesExposure;
  16655. /**
  16656. * Gets the midtones Hue value.
  16657. * 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).
  16658. */
  16659. /**
  16660. * Sets the midtones Hue value.
  16661. * 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).
  16662. */
  16663. midtonesHue: number;
  16664. /**
  16665. * Gets the midtones Density value.
  16666. * 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.
  16667. * Values less than zero provide a filter of opposite hue.
  16668. */
  16669. /**
  16670. * Sets the midtones Density value.
  16671. * 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.
  16672. * Values less than zero provide a filter of opposite hue.
  16673. */
  16674. midtonesDensity: number;
  16675. /**
  16676. * Gets the midtones Saturation value.
  16677. * 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.
  16678. */
  16679. /**
  16680. * Sets the midtones Saturation value.
  16681. * 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.
  16682. */
  16683. midtonesSaturation: number;
  16684. /**
  16685. * Gets the midtones Exposure value.
  16686. * 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.
  16687. */
  16688. /**
  16689. * Sets the midtones Exposure value.
  16690. * 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.
  16691. */
  16692. midtonesExposure: number;
  16693. private _shadowsHue;
  16694. private _shadowsDensity;
  16695. private _shadowsSaturation;
  16696. private _shadowsExposure;
  16697. /**
  16698. * Gets the shadows Hue value.
  16699. * 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).
  16700. */
  16701. /**
  16702. * Sets the shadows Hue value.
  16703. * 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).
  16704. */
  16705. shadowsHue: number;
  16706. /**
  16707. * Gets the shadows Density value.
  16708. * 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.
  16709. * Values less than zero provide a filter of opposite hue.
  16710. */
  16711. /**
  16712. * Sets the shadows Density value.
  16713. * 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.
  16714. * Values less than zero provide a filter of opposite hue.
  16715. */
  16716. shadowsDensity: number;
  16717. /**
  16718. * Gets the shadows Saturation value.
  16719. * 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.
  16720. */
  16721. /**
  16722. * Sets the shadows Saturation value.
  16723. * 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.
  16724. */
  16725. shadowsSaturation: number;
  16726. /**
  16727. * Gets the shadows Exposure value.
  16728. * 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.
  16729. */
  16730. /**
  16731. * Sets the shadows Exposure value.
  16732. * 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.
  16733. */
  16734. shadowsExposure: number;
  16735. /**
  16736. * Returns the class name
  16737. * @returns The class name
  16738. */
  16739. getClassName(): string;
  16740. /**
  16741. * Binds the color curves to the shader.
  16742. * @param colorCurves The color curve to bind
  16743. * @param effect The effect to bind to
  16744. * @param positiveUniform The positive uniform shader parameter
  16745. * @param neutralUniform The neutral uniform shader parameter
  16746. * @param negativeUniform The negative uniform shader parameter
  16747. */
  16748. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16749. /**
  16750. * Prepare the list of uniforms associated with the ColorCurves effects.
  16751. * @param uniformsList The list of uniforms used in the effect
  16752. */
  16753. static PrepareUniforms(uniformsList: string[]): void;
  16754. /**
  16755. * Returns color grading data based on a hue, density, saturation and exposure value.
  16756. * @param filterHue The hue of the color filter.
  16757. * @param filterDensity The density of the color filter.
  16758. * @param saturation The saturation.
  16759. * @param exposure The exposure.
  16760. * @param result The result data container.
  16761. */
  16762. private getColorGradingDataToRef;
  16763. /**
  16764. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16765. * @param value The input slider value in range [-100,100].
  16766. * @returns Adjusted value.
  16767. */
  16768. private static applyColorGradingSliderNonlinear;
  16769. /**
  16770. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16771. * @param hue The hue (H) input.
  16772. * @param saturation The saturation (S) input.
  16773. * @param brightness The brightness (B) input.
  16774. * @result An RGBA color represented as Vector4.
  16775. */
  16776. private static fromHSBToRef;
  16777. /**
  16778. * Returns a value clamped between min and max
  16779. * @param value The value to clamp
  16780. * @param min The minimum of value
  16781. * @param max The maximum of value
  16782. * @returns The clamped value.
  16783. */
  16784. private static clamp;
  16785. /**
  16786. * Clones the current color curve instance.
  16787. * @return The cloned curves
  16788. */
  16789. clone(): ColorCurves;
  16790. /**
  16791. * Serializes the current color curve instance to a json representation.
  16792. * @return a JSON representation
  16793. */
  16794. serialize(): any;
  16795. /**
  16796. * Parses the color curve from a json representation.
  16797. * @param source the JSON source to parse
  16798. * @return The parsed curves
  16799. */
  16800. static Parse(source: any): ColorCurves;
  16801. }
  16802. }
  16803. declare module BABYLON {
  16804. /**
  16805. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16806. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16807. */
  16808. class EffectFallbacks {
  16809. private _defines;
  16810. private _currentRank;
  16811. private _maxRank;
  16812. private _mesh;
  16813. /**
  16814. * Removes the fallback from the bound mesh.
  16815. */
  16816. unBindMesh(): void;
  16817. /**
  16818. * Adds a fallback on the specified property.
  16819. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16820. * @param define The name of the define in the shader
  16821. */
  16822. addFallback(rank: number, define: string): void;
  16823. /**
  16824. * Sets the mesh to use CPU skinning when needing to fallback.
  16825. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16826. * @param mesh The mesh to use the fallbacks.
  16827. */
  16828. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16829. /**
  16830. * Checks to see if more fallbacks are still availible.
  16831. */
  16832. readonly isMoreFallbacks: boolean;
  16833. /**
  16834. * Removes the defines that shoould be removed when falling back.
  16835. * @param currentDefines defines the current define statements for the shader.
  16836. * @param effect defines the current effect we try to compile
  16837. * @returns The resulting defines with defines of the current rank removed.
  16838. */
  16839. reduce(currentDefines: string, effect: Effect): string;
  16840. }
  16841. /**
  16842. * Options to be used when creating an effect.
  16843. */
  16844. class EffectCreationOptions {
  16845. /**
  16846. * Atrributes that will be used in the shader.
  16847. */
  16848. attributes: string[];
  16849. /**
  16850. * Uniform varible names that will be set in the shader.
  16851. */
  16852. uniformsNames: string[];
  16853. /**
  16854. * Uniform buffer varible names that will be set in the shader.
  16855. */
  16856. uniformBuffersNames: string[];
  16857. /**
  16858. * Sampler texture variable names that will be set in the shader.
  16859. */
  16860. samplers: string[];
  16861. /**
  16862. * Define statements that will be set in the shader.
  16863. */
  16864. defines: any;
  16865. /**
  16866. * Possible fallbacks for this effect to improve performance when needed.
  16867. */
  16868. fallbacks: Nullable<EffectFallbacks>;
  16869. /**
  16870. * Callback that will be called when the shader is compiled.
  16871. */
  16872. onCompiled: Nullable<(effect: Effect) => void>;
  16873. /**
  16874. * Callback that will be called if an error occurs during shader compilation.
  16875. */
  16876. onError: Nullable<(effect: Effect, errors: string) => void>;
  16877. /**
  16878. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16879. */
  16880. indexParameters: any;
  16881. /**
  16882. * Max number of lights that can be used in the shader.
  16883. */
  16884. maxSimultaneousLights: number;
  16885. /**
  16886. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16887. */
  16888. transformFeedbackVaryings: Nullable<string[]>;
  16889. }
  16890. /**
  16891. * Effect containing vertex and fragment shader that can be executed on an object.
  16892. */
  16893. class Effect {
  16894. /**
  16895. * Name of the effect.
  16896. */
  16897. name: any;
  16898. /**
  16899. * String container all the define statements that should be set on the shader.
  16900. */
  16901. defines: string;
  16902. /**
  16903. * Callback that will be called when the shader is compiled.
  16904. */
  16905. onCompiled: Nullable<(effect: Effect) => void>;
  16906. /**
  16907. * Callback that will be called if an error occurs during shader compilation.
  16908. */
  16909. onError: Nullable<(effect: Effect, errors: string) => void>;
  16910. /**
  16911. * Callback that will be called when effect is bound.
  16912. */
  16913. onBind: Nullable<(effect: Effect) => void>;
  16914. /**
  16915. * Unique ID of the effect.
  16916. */
  16917. uniqueId: number;
  16918. /**
  16919. * Observable that will be called when the shader is compiled.
  16920. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  16921. */
  16922. onCompileObservable: Observable<Effect>;
  16923. /**
  16924. * Observable that will be called if an error occurs during shader compilation.
  16925. */
  16926. onErrorObservable: Observable<Effect>;
  16927. /** @hidden */
  16928. _onBindObservable: Nullable<Observable<Effect>>;
  16929. /**
  16930. * Observable that will be called when effect is bound.
  16931. */
  16932. readonly onBindObservable: Observable<Effect>;
  16933. /** @hidden */
  16934. _bonesComputationForcedToCPU: boolean;
  16935. private static _uniqueIdSeed;
  16936. private _engine;
  16937. private _uniformBuffersNames;
  16938. private _uniformsNames;
  16939. private _samplers;
  16940. private _isReady;
  16941. private _compilationError;
  16942. private _attributesNames;
  16943. private _attributes;
  16944. private _uniforms;
  16945. /**
  16946. * Key for the effect.
  16947. * @hidden
  16948. */
  16949. _key: string;
  16950. private _indexParameters;
  16951. private _fallbacks;
  16952. private _vertexSourceCode;
  16953. private _fragmentSourceCode;
  16954. private _vertexSourceCodeOverride;
  16955. private _fragmentSourceCodeOverride;
  16956. private _transformFeedbackVaryings;
  16957. /**
  16958. * Compiled shader to webGL program.
  16959. * @hidden
  16960. */
  16961. _program: WebGLProgram;
  16962. private _valueCache;
  16963. private static _baseCache;
  16964. /**
  16965. * Instantiates an effect.
  16966. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16967. * @param baseName Name of the effect.
  16968. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16969. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16970. * @param samplers List of sampler variables that will be passed to the shader.
  16971. * @param engine Engine to be used to render the effect
  16972. * @param defines Define statements to be added to the shader.
  16973. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16974. * @param onCompiled Callback that will be called when the shader is compiled.
  16975. * @param onError Callback that will be called if an error occurs during shader compilation.
  16976. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16977. */
  16978. 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);
  16979. /**
  16980. * Unique key for this effect
  16981. */
  16982. readonly key: string;
  16983. /**
  16984. * If the effect has been compiled and prepared.
  16985. * @returns if the effect is compiled and prepared.
  16986. */
  16987. isReady(): boolean;
  16988. /**
  16989. * The engine the effect was initialized with.
  16990. * @returns the engine.
  16991. */
  16992. getEngine(): Engine;
  16993. /**
  16994. * The compiled webGL program for the effect
  16995. * @returns the webGL program.
  16996. */
  16997. getProgram(): WebGLProgram;
  16998. /**
  16999. * The set of names of attribute variables for the shader.
  17000. * @returns An array of attribute names.
  17001. */
  17002. getAttributesNames(): string[];
  17003. /**
  17004. * Returns the attribute at the given index.
  17005. * @param index The index of the attribute.
  17006. * @returns The location of the attribute.
  17007. */
  17008. getAttributeLocation(index: number): number;
  17009. /**
  17010. * Returns the attribute based on the name of the variable.
  17011. * @param name of the attribute to look up.
  17012. * @returns the attribute location.
  17013. */
  17014. getAttributeLocationByName(name: string): number;
  17015. /**
  17016. * The number of attributes.
  17017. * @returns the numnber of attributes.
  17018. */
  17019. getAttributesCount(): number;
  17020. /**
  17021. * Gets the index of a uniform variable.
  17022. * @param uniformName of the uniform to look up.
  17023. * @returns the index.
  17024. */
  17025. getUniformIndex(uniformName: string): number;
  17026. /**
  17027. * Returns the attribute based on the name of the variable.
  17028. * @param uniformName of the uniform to look up.
  17029. * @returns the location of the uniform.
  17030. */
  17031. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17032. /**
  17033. * Returns an array of sampler variable names
  17034. * @returns The array of sampler variable neames.
  17035. */
  17036. getSamplers(): string[];
  17037. /**
  17038. * The error from the last compilation.
  17039. * @returns the error string.
  17040. */
  17041. getCompilationError(): string;
  17042. /**
  17043. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17044. * @param func The callback to be used.
  17045. */
  17046. executeWhenCompiled(func: (effect: Effect) => void): void;
  17047. private _checkIsReady;
  17048. /** @hidden */
  17049. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17050. /** @hidden */
  17051. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17052. /** @hidden */
  17053. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17054. private _processShaderConversion;
  17055. private _processIncludes;
  17056. private _processPrecision;
  17057. /**
  17058. * Recompiles the webGL program
  17059. * @param vertexSourceCode The source code for the vertex shader.
  17060. * @param fragmentSourceCode The source code for the fragment shader.
  17061. * @param onCompiled Callback called when completed.
  17062. * @param onError Callback called on error.
  17063. * @hidden
  17064. */
  17065. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17066. /**
  17067. * Gets the uniform locations of the the specified variable names
  17068. * @param names THe names of the variables to lookup.
  17069. * @returns Array of locations in the same order as variable names.
  17070. */
  17071. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17072. /**
  17073. * Prepares the effect
  17074. * @hidden
  17075. */
  17076. _prepareEffect(): void;
  17077. /**
  17078. * Checks if the effect is supported. (Must be called after compilation)
  17079. */
  17080. readonly isSupported: boolean;
  17081. /**
  17082. * Binds a texture to the engine to be used as output of the shader.
  17083. * @param channel Name of the output variable.
  17084. * @param texture Texture to bind.
  17085. * @hidden
  17086. */
  17087. _bindTexture(channel: string, texture: InternalTexture): void;
  17088. /**
  17089. * Sets a texture on the engine to be used in the shader.
  17090. * @param channel Name of the sampler variable.
  17091. * @param texture Texture to set.
  17092. */
  17093. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17094. /**
  17095. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17096. * @param channel Name of the sampler variable.
  17097. * @param texture Texture to set.
  17098. */
  17099. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17100. /**
  17101. * Sets an array of textures on the engine to be used in the shader.
  17102. * @param channel Name of the variable.
  17103. * @param textures Textures to set.
  17104. */
  17105. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17106. /**
  17107. * 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)
  17108. * @param channel Name of the sampler variable.
  17109. * @param postProcess Post process to get the input texture from.
  17110. */
  17111. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17112. /**
  17113. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17114. * 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)
  17115. * @param channel Name of the sampler variable.
  17116. * @param postProcess Post process to get the output texture from.
  17117. */
  17118. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17119. /** @hidden */
  17120. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17121. /** @hidden */
  17122. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17123. /** @hidden */
  17124. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17125. /** @hidden */
  17126. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17127. /**
  17128. * Binds a buffer to a uniform.
  17129. * @param buffer Buffer to bind.
  17130. * @param name Name of the uniform variable to bind to.
  17131. */
  17132. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17133. /**
  17134. * Binds block to a uniform.
  17135. * @param blockName Name of the block to bind.
  17136. * @param index Index to bind.
  17137. */
  17138. bindUniformBlock(blockName: string, index: number): void;
  17139. /**
  17140. * Sets an interger value on a uniform variable.
  17141. * @param uniformName Name of the variable.
  17142. * @param value Value to be set.
  17143. * @returns this effect.
  17144. */
  17145. setInt(uniformName: string, value: number): Effect;
  17146. /**
  17147. * Sets an int array on a uniform variable.
  17148. * @param uniformName Name of the variable.
  17149. * @param array array to be set.
  17150. * @returns this effect.
  17151. */
  17152. setIntArray(uniformName: string, array: Int32Array): Effect;
  17153. /**
  17154. * 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)
  17155. * @param uniformName Name of the variable.
  17156. * @param array array to be set.
  17157. * @returns this effect.
  17158. */
  17159. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17160. /**
  17161. * 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)
  17162. * @param uniformName Name of the variable.
  17163. * @param array array to be set.
  17164. * @returns this effect.
  17165. */
  17166. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17167. /**
  17168. * 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)
  17169. * @param uniformName Name of the variable.
  17170. * @param array array to be set.
  17171. * @returns this effect.
  17172. */
  17173. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17174. /**
  17175. * Sets an float array on a uniform variable.
  17176. * @param uniformName Name of the variable.
  17177. * @param array array to be set.
  17178. * @returns this effect.
  17179. */
  17180. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17181. /**
  17182. * 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)
  17183. * @param uniformName Name of the variable.
  17184. * @param array array to be set.
  17185. * @returns this effect.
  17186. */
  17187. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17188. /**
  17189. * 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)
  17190. * @param uniformName Name of the variable.
  17191. * @param array array to be set.
  17192. * @returns this effect.
  17193. */
  17194. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17195. /**
  17196. * 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)
  17197. * @param uniformName Name of the variable.
  17198. * @param array array to be set.
  17199. * @returns this effect.
  17200. */
  17201. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17202. /**
  17203. * Sets an array on a uniform variable.
  17204. * @param uniformName Name of the variable.
  17205. * @param array array to be set.
  17206. * @returns this effect.
  17207. */
  17208. setArray(uniformName: string, array: number[]): Effect;
  17209. /**
  17210. * 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)
  17211. * @param uniformName Name of the variable.
  17212. * @param array array to be set.
  17213. * @returns this effect.
  17214. */
  17215. setArray2(uniformName: string, array: number[]): Effect;
  17216. /**
  17217. * 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)
  17218. * @param uniformName Name of the variable.
  17219. * @param array array to be set.
  17220. * @returns this effect.
  17221. */
  17222. setArray3(uniformName: string, array: number[]): Effect;
  17223. /**
  17224. * 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)
  17225. * @param uniformName Name of the variable.
  17226. * @param array array to be set.
  17227. * @returns this effect.
  17228. */
  17229. setArray4(uniformName: string, array: number[]): Effect;
  17230. /**
  17231. * Sets matrices on a uniform variable.
  17232. * @param uniformName Name of the variable.
  17233. * @param matrices matrices to be set.
  17234. * @returns this effect.
  17235. */
  17236. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17237. /**
  17238. * Sets matrix on a uniform variable.
  17239. * @param uniformName Name of the variable.
  17240. * @param matrix matrix to be set.
  17241. * @returns this effect.
  17242. */
  17243. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17244. /**
  17245. * 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)
  17246. * @param uniformName Name of the variable.
  17247. * @param matrix matrix to be set.
  17248. * @returns this effect.
  17249. */
  17250. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17251. /**
  17252. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17253. * @param uniformName Name of the variable.
  17254. * @param matrix matrix to be set.
  17255. * @returns this effect.
  17256. */
  17257. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17258. /**
  17259. * Sets a float on a uniform variable.
  17260. * @param uniformName Name of the variable.
  17261. * @param value value to be set.
  17262. * @returns this effect.
  17263. */
  17264. setFloat(uniformName: string, value: number): Effect;
  17265. /**
  17266. * Sets a boolean on a uniform variable.
  17267. * @param uniformName Name of the variable.
  17268. * @param bool value to be set.
  17269. * @returns this effect.
  17270. */
  17271. setBool(uniformName: string, bool: boolean): Effect;
  17272. /**
  17273. * Sets a Vector2 on a uniform variable.
  17274. * @param uniformName Name of the variable.
  17275. * @param vector2 vector2 to be set.
  17276. * @returns this effect.
  17277. */
  17278. setVector2(uniformName: string, vector2: Vector2): Effect;
  17279. /**
  17280. * Sets a float2 on a uniform variable.
  17281. * @param uniformName Name of the variable.
  17282. * @param x First float in float2.
  17283. * @param y Second float in float2.
  17284. * @returns this effect.
  17285. */
  17286. setFloat2(uniformName: string, x: number, y: number): Effect;
  17287. /**
  17288. * Sets a Vector3 on a uniform variable.
  17289. * @param uniformName Name of the variable.
  17290. * @param vector3 Value to be set.
  17291. * @returns this effect.
  17292. */
  17293. setVector3(uniformName: string, vector3: Vector3): Effect;
  17294. /**
  17295. * Sets a float3 on a uniform variable.
  17296. * @param uniformName Name of the variable.
  17297. * @param x First float in float3.
  17298. * @param y Second float in float3.
  17299. * @param z Third float in float3.
  17300. * @returns this effect.
  17301. */
  17302. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17303. /**
  17304. * Sets a Vector4 on a uniform variable.
  17305. * @param uniformName Name of the variable.
  17306. * @param vector4 Value to be set.
  17307. * @returns this effect.
  17308. */
  17309. setVector4(uniformName: string, vector4: Vector4): Effect;
  17310. /**
  17311. * Sets a float4 on a uniform variable.
  17312. * @param uniformName Name of the variable.
  17313. * @param x First float in float4.
  17314. * @param y Second float in float4.
  17315. * @param z Third float in float4.
  17316. * @param w Fourth float in float4.
  17317. * @returns this effect.
  17318. */
  17319. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17320. /**
  17321. * Sets a Color3 on a uniform variable.
  17322. * @param uniformName Name of the variable.
  17323. * @param color3 Value to be set.
  17324. * @returns this effect.
  17325. */
  17326. setColor3(uniformName: string, color3: Color3): Effect;
  17327. /**
  17328. * Sets a Color4 on a uniform variable.
  17329. * @param uniformName Name of the variable.
  17330. * @param color3 Value to be set.
  17331. * @param alpha Alpha value to be set.
  17332. * @returns this effect.
  17333. */
  17334. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17335. /**
  17336. * Sets a Color4 on a uniform variable
  17337. * @param uniformName defines the name of the variable
  17338. * @param color4 defines the value to be set
  17339. * @returns this effect.
  17340. */
  17341. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17342. /**
  17343. * This function will add a new shader to the shader store
  17344. * @param name the name of the shader
  17345. * @param pixelShader optional pixel shader content
  17346. * @param vertexShader optional vertex shader content
  17347. */
  17348. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17349. /**
  17350. * Store of each shader (The can be looked up using effect.key)
  17351. */
  17352. static ShadersStore: {
  17353. [key: string]: string;
  17354. };
  17355. /**
  17356. * Store of each included file for a shader (The can be looked up using effect.key)
  17357. */
  17358. static IncludesShadersStore: {
  17359. [key: string]: string;
  17360. };
  17361. /**
  17362. * Resets the cache of effects.
  17363. */
  17364. static ResetCache(): void;
  17365. }
  17366. }
  17367. declare module BABYLON {
  17368. /**
  17369. * This represents all the required information to add a fresnel effect on a material:
  17370. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17371. */
  17372. class FresnelParameters {
  17373. private _isEnabled;
  17374. /**
  17375. * Define if the fresnel effect is enable or not.
  17376. */
  17377. isEnabled: boolean;
  17378. /**
  17379. * Define the color used on edges (grazing angle)
  17380. */
  17381. leftColor: Color3;
  17382. /**
  17383. * Define the color used on center
  17384. */
  17385. rightColor: Color3;
  17386. /**
  17387. * Define bias applied to computed fresnel term
  17388. */
  17389. bias: number;
  17390. /**
  17391. * Defined the power exponent applied to fresnel term
  17392. */
  17393. power: number;
  17394. /**
  17395. * Clones the current fresnel and its valuues
  17396. * @returns a clone fresnel configuration
  17397. */
  17398. clone(): FresnelParameters;
  17399. /**
  17400. * Serializes the current fresnel parameters to a JSON representation.
  17401. * @return the JSON serialization
  17402. */
  17403. serialize(): any;
  17404. /**
  17405. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17406. * @param parsedFresnelParameters Define the JSON representation
  17407. * @returns the parsed parameters
  17408. */
  17409. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17410. }
  17411. }
  17412. declare module BABYLON {
  17413. /**
  17414. * Interface to follow in your material defines to integrate easily the
  17415. * Image proccessing functions.
  17416. * @hidden
  17417. */
  17418. interface IImageProcessingConfigurationDefines {
  17419. IMAGEPROCESSING: boolean;
  17420. VIGNETTE: boolean;
  17421. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17422. VIGNETTEBLENDMODEOPAQUE: boolean;
  17423. TONEMAPPING: boolean;
  17424. TONEMAPPING_ACES: boolean;
  17425. CONTRAST: boolean;
  17426. EXPOSURE: boolean;
  17427. COLORCURVES: boolean;
  17428. COLORGRADING: boolean;
  17429. COLORGRADING3D: boolean;
  17430. SAMPLER3DGREENDEPTH: boolean;
  17431. SAMPLER3DBGRMAP: boolean;
  17432. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17433. }
  17434. /**
  17435. * @hidden
  17436. */
  17437. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17438. IMAGEPROCESSING: boolean;
  17439. VIGNETTE: boolean;
  17440. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17441. VIGNETTEBLENDMODEOPAQUE: boolean;
  17442. TONEMAPPING: boolean;
  17443. TONEMAPPING_ACES: boolean;
  17444. CONTRAST: boolean;
  17445. COLORCURVES: boolean;
  17446. COLORGRADING: boolean;
  17447. COLORGRADING3D: boolean;
  17448. SAMPLER3DGREENDEPTH: boolean;
  17449. SAMPLER3DBGRMAP: boolean;
  17450. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17451. EXPOSURE: boolean;
  17452. constructor();
  17453. }
  17454. /**
  17455. * This groups together the common properties used for image processing either in direct forward pass
  17456. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17457. * or not.
  17458. */
  17459. class ImageProcessingConfiguration {
  17460. /**
  17461. * Default tone mapping applied in BabylonJS.
  17462. */
  17463. static readonly TONEMAPPING_STANDARD: number;
  17464. /**
  17465. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17466. * to other engines rendering to increase portability.
  17467. */
  17468. static readonly TONEMAPPING_ACES: number;
  17469. /**
  17470. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17471. */
  17472. colorCurves: Nullable<ColorCurves>;
  17473. private _colorCurvesEnabled;
  17474. /**
  17475. * Gets wether the color curves effect is enabled.
  17476. */
  17477. /**
  17478. * Sets wether the color curves effect is enabled.
  17479. */
  17480. colorCurvesEnabled: boolean;
  17481. private _colorGradingTexture;
  17482. /**
  17483. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17484. */
  17485. /**
  17486. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17487. */
  17488. colorGradingTexture: Nullable<BaseTexture>;
  17489. private _colorGradingEnabled;
  17490. /**
  17491. * Gets wether the color grading effect is enabled.
  17492. */
  17493. /**
  17494. * Sets wether the color grading effect is enabled.
  17495. */
  17496. colorGradingEnabled: boolean;
  17497. private _colorGradingWithGreenDepth;
  17498. /**
  17499. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17500. */
  17501. /**
  17502. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17503. */
  17504. colorGradingWithGreenDepth: boolean;
  17505. private _colorGradingBGR;
  17506. /**
  17507. * Gets wether the color grading texture contains BGR values.
  17508. */
  17509. /**
  17510. * Sets wether the color grading texture contains BGR values.
  17511. */
  17512. colorGradingBGR: boolean;
  17513. /** @hidden */
  17514. _exposure: number;
  17515. /**
  17516. * Gets the Exposure used in the effect.
  17517. */
  17518. /**
  17519. * Sets the Exposure used in the effect.
  17520. */
  17521. exposure: number;
  17522. private _toneMappingEnabled;
  17523. /**
  17524. * Gets wether the tone mapping effect is enabled.
  17525. */
  17526. /**
  17527. * Sets wether the tone mapping effect is enabled.
  17528. */
  17529. toneMappingEnabled: boolean;
  17530. private _toneMappingType;
  17531. /**
  17532. * Gets the type of tone mapping effect.
  17533. */
  17534. /**
  17535. * Sets the type of tone mapping effect used in BabylonJS.
  17536. */
  17537. toneMappingType: number;
  17538. protected _contrast: number;
  17539. /**
  17540. * Gets the contrast used in the effect.
  17541. */
  17542. /**
  17543. * Sets the contrast used in the effect.
  17544. */
  17545. contrast: number;
  17546. /**
  17547. * Vignette stretch size.
  17548. */
  17549. vignetteStretch: number;
  17550. /**
  17551. * Vignette centre X Offset.
  17552. */
  17553. vignetteCentreX: number;
  17554. /**
  17555. * Vignette centre Y Offset.
  17556. */
  17557. vignetteCentreY: number;
  17558. /**
  17559. * Vignette weight or intensity of the vignette effect.
  17560. */
  17561. vignetteWeight: number;
  17562. /**
  17563. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17564. * if vignetteEnabled is set to true.
  17565. */
  17566. vignetteColor: Color4;
  17567. /**
  17568. * Camera field of view used by the Vignette effect.
  17569. */
  17570. vignetteCameraFov: number;
  17571. private _vignetteBlendMode;
  17572. /**
  17573. * Gets the vignette blend mode allowing different kind of effect.
  17574. */
  17575. /**
  17576. * Sets the vignette blend mode allowing different kind of effect.
  17577. */
  17578. vignetteBlendMode: number;
  17579. private _vignetteEnabled;
  17580. /**
  17581. * Gets wether the vignette effect is enabled.
  17582. */
  17583. /**
  17584. * Sets wether the vignette effect is enabled.
  17585. */
  17586. vignetteEnabled: boolean;
  17587. private _applyByPostProcess;
  17588. /**
  17589. * Gets wether the image processing is applied through a post process or not.
  17590. */
  17591. /**
  17592. * Sets wether the image processing is applied through a post process or not.
  17593. */
  17594. applyByPostProcess: boolean;
  17595. private _isEnabled;
  17596. /**
  17597. * Gets wether the image processing is enabled or not.
  17598. */
  17599. /**
  17600. * Sets wether the image processing is enabled or not.
  17601. */
  17602. isEnabled: boolean;
  17603. /**
  17604. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17605. */
  17606. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17607. /**
  17608. * Method called each time the image processing information changes requires to recompile the effect.
  17609. */
  17610. protected _updateParameters(): void;
  17611. /**
  17612. * Gets the current class name.
  17613. * @return "ImageProcessingConfiguration"
  17614. */
  17615. getClassName(): string;
  17616. /**
  17617. * Prepare the list of uniforms associated with the Image Processing effects.
  17618. * @param uniforms The list of uniforms used in the effect
  17619. * @param defines the list of defines currently in use
  17620. */
  17621. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17622. /**
  17623. * Prepare the list of samplers associated with the Image Processing effects.
  17624. * @param samplersList The list of uniforms used in the effect
  17625. * @param defines the list of defines currently in use
  17626. */
  17627. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17628. /**
  17629. * Prepare the list of defines associated to the shader.
  17630. * @param defines the list of defines to complete
  17631. * @param forPostProcess Define if we are currently in post process mode or not
  17632. */
  17633. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17634. /**
  17635. * Returns true if all the image processing information are ready.
  17636. * @returns True if ready, otherwise, false
  17637. */
  17638. isReady(): boolean;
  17639. /**
  17640. * Binds the image processing to the shader.
  17641. * @param effect The effect to bind to
  17642. * @param aspectRatio Define the current aspect ratio of the effect
  17643. */
  17644. bind(effect: Effect, aspectRatio?: number): void;
  17645. /**
  17646. * Clones the current image processing instance.
  17647. * @return The cloned image processing
  17648. */
  17649. clone(): ImageProcessingConfiguration;
  17650. /**
  17651. * Serializes the current image processing instance to a json representation.
  17652. * @return a JSON representation
  17653. */
  17654. serialize(): any;
  17655. /**
  17656. * Parses the image processing from a json representation.
  17657. * @param source the JSON source to parse
  17658. * @return The parsed image processing
  17659. */
  17660. static Parse(source: any): ImageProcessingConfiguration;
  17661. private static _VIGNETTEMODE_MULTIPLY;
  17662. private static _VIGNETTEMODE_OPAQUE;
  17663. /**
  17664. * Used to apply the vignette as a mix with the pixel color.
  17665. */
  17666. static readonly VIGNETTEMODE_MULTIPLY: number;
  17667. /**
  17668. * Used to apply the vignette as a replacement of the pixel color.
  17669. */
  17670. static readonly VIGNETTEMODE_OPAQUE: number;
  17671. }
  17672. }
  17673. declare module BABYLON {
  17674. /**
  17675. * Manages the defines for the Material
  17676. */
  17677. class MaterialDefines {
  17678. private _keys;
  17679. private _isDirty;
  17680. /** @hidden */
  17681. _renderId: number;
  17682. /** @hidden */
  17683. _areLightsDirty: boolean;
  17684. /** @hidden */
  17685. _areAttributesDirty: boolean;
  17686. /** @hidden */
  17687. _areTexturesDirty: boolean;
  17688. /** @hidden */
  17689. _areFresnelDirty: boolean;
  17690. /** @hidden */
  17691. _areMiscDirty: boolean;
  17692. /** @hidden */
  17693. _areImageProcessingDirty: boolean;
  17694. /** @hidden */
  17695. _normals: boolean;
  17696. /** @hidden */
  17697. _uvs: boolean;
  17698. /** @hidden */
  17699. _needNormals: boolean;
  17700. /** @hidden */
  17701. _needUVs: boolean;
  17702. /**
  17703. * Specifies if the material needs to be re-calculated
  17704. */
  17705. readonly isDirty: boolean;
  17706. /**
  17707. * Marks the material to indicate that it has been re-calculated
  17708. */
  17709. markAsProcessed(): void;
  17710. /**
  17711. * Marks the material to indicate that it needs to be re-calculated
  17712. */
  17713. markAsUnprocessed(): void;
  17714. /**
  17715. * Marks the material to indicate all of its defines need to be re-calculated
  17716. */
  17717. markAllAsDirty(): void;
  17718. /**
  17719. * Marks the material to indicate that image processing needs to be re-calculated
  17720. */
  17721. markAsImageProcessingDirty(): void;
  17722. /**
  17723. * Marks the material to indicate the lights need to be re-calculated
  17724. */
  17725. markAsLightDirty(): void;
  17726. /**
  17727. * Marks the attribute state as changed
  17728. */
  17729. markAsAttributesDirty(): void;
  17730. /**
  17731. * Marks the texture state as changed
  17732. */
  17733. markAsTexturesDirty(): void;
  17734. /**
  17735. * Marks the fresnel state as changed
  17736. */
  17737. markAsFresnelDirty(): void;
  17738. /**
  17739. * Marks the misc state as changed
  17740. */
  17741. markAsMiscDirty(): void;
  17742. /**
  17743. * Rebuilds the material defines
  17744. */
  17745. rebuild(): void;
  17746. /**
  17747. * Specifies if two material defines are equal
  17748. * @param other - A material define instance to compare to
  17749. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17750. */
  17751. isEqual(other: MaterialDefines): boolean;
  17752. /**
  17753. * Clones this instance's defines to another instance
  17754. * @param other - material defines to clone values to
  17755. */
  17756. cloneTo(other: MaterialDefines): void;
  17757. /**
  17758. * Resets the material define values
  17759. */
  17760. reset(): void;
  17761. /**
  17762. * Converts the material define values to a string
  17763. * @returns - String of material define information
  17764. */
  17765. toString(): string;
  17766. }
  17767. /**
  17768. * Base class for the main features of a material in Babylon.js
  17769. */
  17770. class Material implements IAnimatable {
  17771. private static _TriangleFillMode;
  17772. private static _WireFrameFillMode;
  17773. private static _PointFillMode;
  17774. private static _PointListDrawMode;
  17775. private static _LineListDrawMode;
  17776. private static _LineLoopDrawMode;
  17777. private static _LineStripDrawMode;
  17778. private static _TriangleStripDrawMode;
  17779. private static _TriangleFanDrawMode;
  17780. /**
  17781. * Returns the triangle fill mode
  17782. */
  17783. static readonly TriangleFillMode: number;
  17784. /**
  17785. * Returns the wireframe mode
  17786. */
  17787. static readonly WireFrameFillMode: number;
  17788. /**
  17789. * Returns the point fill mode
  17790. */
  17791. static readonly PointFillMode: number;
  17792. /**
  17793. * Returns the point list draw mode
  17794. */
  17795. static readonly PointListDrawMode: number;
  17796. /**
  17797. * Returns the line list draw mode
  17798. */
  17799. static readonly LineListDrawMode: number;
  17800. /**
  17801. * Returns the line loop draw mode
  17802. */
  17803. static readonly LineLoopDrawMode: number;
  17804. /**
  17805. * Returns the line strip draw mode
  17806. */
  17807. static readonly LineStripDrawMode: number;
  17808. /**
  17809. * Returns the triangle strip draw mode
  17810. */
  17811. static readonly TriangleStripDrawMode: number;
  17812. /**
  17813. * Returns the triangle fan draw mode
  17814. */
  17815. static readonly TriangleFanDrawMode: number;
  17816. /**
  17817. * Stores the clock-wise side orientation
  17818. */
  17819. private static _ClockWiseSideOrientation;
  17820. /**
  17821. * Stores the counter clock-wise side orientation
  17822. */
  17823. private static _CounterClockWiseSideOrientation;
  17824. /**
  17825. * Returns the clock-wise side orientation
  17826. */
  17827. static readonly ClockWiseSideOrientation: number;
  17828. /**
  17829. * Returns the counter clock-wise side orientation
  17830. */
  17831. static readonly CounterClockWiseSideOrientation: number;
  17832. /**
  17833. * The dirty texture flag value
  17834. */
  17835. static readonly TextureDirtyFlag: number;
  17836. /**
  17837. * The dirty light flag value
  17838. */
  17839. static readonly LightDirtyFlag: number;
  17840. /**
  17841. * The dirty fresnel flag value
  17842. */
  17843. static readonly FresnelDirtyFlag: number;
  17844. /**
  17845. * The dirty attribute flag value
  17846. */
  17847. static readonly AttributesDirtyFlag: number;
  17848. /**
  17849. * The dirty misc flag value
  17850. */
  17851. static readonly MiscDirtyFlag: number;
  17852. /**
  17853. * The all dirty flag value
  17854. */
  17855. static readonly AllDirtyFlag: number;
  17856. /**
  17857. * The ID of the material
  17858. */
  17859. id: string;
  17860. /**
  17861. * Gets or sets the unique id of the material
  17862. */
  17863. uniqueId: number;
  17864. /**
  17865. * The name of the material
  17866. */
  17867. name: string;
  17868. /**
  17869. * Gets or sets user defined metadata
  17870. */
  17871. metadata: any;
  17872. /**
  17873. * For internal use only. Please do not use.
  17874. */
  17875. reservedDataStore: any;
  17876. /**
  17877. * Specifies if the ready state should be checked on each call
  17878. */
  17879. checkReadyOnEveryCall: boolean;
  17880. /**
  17881. * Specifies if the ready state should be checked once
  17882. */
  17883. checkReadyOnlyOnce: boolean;
  17884. /**
  17885. * The state of the material
  17886. */
  17887. state: string;
  17888. /**
  17889. * The alpha value of the material
  17890. */
  17891. protected _alpha: number;
  17892. /**
  17893. * Sets the alpha value of the material
  17894. */
  17895. /**
  17896. * Gets the alpha value of the material
  17897. */
  17898. alpha: number;
  17899. /**
  17900. * Specifies if back face culling is enabled
  17901. */
  17902. protected _backFaceCulling: boolean;
  17903. /**
  17904. * Sets the back-face culling state
  17905. */
  17906. /**
  17907. * Gets the back-face culling state
  17908. */
  17909. backFaceCulling: boolean;
  17910. /**
  17911. * Stores the value for side orientation
  17912. */
  17913. sideOrientation: number;
  17914. /**
  17915. * Callback triggered when the material is compiled
  17916. */
  17917. onCompiled: (effect: Effect) => void;
  17918. /**
  17919. * Callback triggered when an error occurs
  17920. */
  17921. onError: (effect: Effect, errors: string) => void;
  17922. /**
  17923. * Callback triggered to get the render target textures
  17924. */
  17925. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17926. /**
  17927. * Gets a boolean indicating that current material needs to register RTT
  17928. */
  17929. readonly hasRenderTargetTextures: boolean;
  17930. /**
  17931. * Specifies if the material should be serialized
  17932. */
  17933. doNotSerialize: boolean;
  17934. /**
  17935. * @hidden
  17936. */
  17937. _storeEffectOnSubMeshes: boolean;
  17938. /**
  17939. * Stores the animations for the material
  17940. */
  17941. animations: Array<Animation>;
  17942. /**
  17943. * An event triggered when the material is disposed
  17944. */
  17945. onDisposeObservable: Observable<Material>;
  17946. /**
  17947. * An observer which watches for dispose events
  17948. */
  17949. private _onDisposeObserver;
  17950. private _onUnBindObservable;
  17951. /**
  17952. * Called during a dispose event
  17953. */
  17954. onDispose: () => void;
  17955. private _onBindObservable;
  17956. /**
  17957. * An event triggered when the material is bound
  17958. */
  17959. readonly onBindObservable: Observable<AbstractMesh>;
  17960. /**
  17961. * An observer which watches for bind events
  17962. */
  17963. private _onBindObserver;
  17964. /**
  17965. * Called during a bind event
  17966. */
  17967. onBind: (Mesh: AbstractMesh) => void;
  17968. /**
  17969. * An event triggered when the material is unbound
  17970. */
  17971. readonly onUnBindObservable: Observable<Material>;
  17972. /**
  17973. * Stores the value of the alpha mode
  17974. */
  17975. private _alphaMode;
  17976. /**
  17977. * Sets the value of the alpha mode.
  17978. *
  17979. * | Value | Type | Description |
  17980. * | --- | --- | --- |
  17981. * | 0 | ALPHA_DISABLE | |
  17982. * | 1 | ALPHA_ADD | |
  17983. * | 2 | ALPHA_COMBINE | |
  17984. * | 3 | ALPHA_SUBTRACT | |
  17985. * | 4 | ALPHA_MULTIPLY | |
  17986. * | 5 | ALPHA_MAXIMIZED | |
  17987. * | 6 | ALPHA_ONEONE | |
  17988. * | 7 | ALPHA_PREMULTIPLIED | |
  17989. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17990. * | 9 | ALPHA_INTERPOLATE | |
  17991. * | 10 | ALPHA_SCREENMODE | |
  17992. *
  17993. */
  17994. /**
  17995. * Gets the value of the alpha mode
  17996. */
  17997. alphaMode: number;
  17998. /**
  17999. * Stores the state of the need depth pre-pass value
  18000. */
  18001. private _needDepthPrePass;
  18002. /**
  18003. * Sets the need depth pre-pass value
  18004. */
  18005. /**
  18006. * Gets the depth pre-pass value
  18007. */
  18008. needDepthPrePass: boolean;
  18009. /**
  18010. * Specifies if depth writing should be disabled
  18011. */
  18012. disableDepthWrite: boolean;
  18013. /**
  18014. * Specifies if depth writing should be forced
  18015. */
  18016. forceDepthWrite: boolean;
  18017. /**
  18018. * Specifies if there should be a separate pass for culling
  18019. */
  18020. separateCullingPass: boolean;
  18021. /**
  18022. * Stores the state specifing if fog should be enabled
  18023. */
  18024. private _fogEnabled;
  18025. /**
  18026. * Sets the state for enabling fog
  18027. */
  18028. /**
  18029. * Gets the value of the fog enabled state
  18030. */
  18031. fogEnabled: boolean;
  18032. /**
  18033. * Stores the size of points
  18034. */
  18035. pointSize: number;
  18036. /**
  18037. * Stores the z offset value
  18038. */
  18039. zOffset: number;
  18040. /**
  18041. * Gets a value specifying if wireframe mode is enabled
  18042. */
  18043. /**
  18044. * Sets the state of wireframe mode
  18045. */
  18046. wireframe: boolean;
  18047. /**
  18048. * Gets the value specifying if point clouds are enabled
  18049. */
  18050. /**
  18051. * Sets the state of point cloud mode
  18052. */
  18053. pointsCloud: boolean;
  18054. /**
  18055. * Gets the material fill mode
  18056. */
  18057. /**
  18058. * Sets the material fill mode
  18059. */
  18060. fillMode: number;
  18061. /**
  18062. * @hidden
  18063. * Stores the effects for the material
  18064. */
  18065. _effect: Nullable<Effect>;
  18066. /**
  18067. * @hidden
  18068. * Specifies if the material was previously ready
  18069. */
  18070. _wasPreviouslyReady: boolean;
  18071. /**
  18072. * Specifies if uniform buffers should be used
  18073. */
  18074. private _useUBO;
  18075. /**
  18076. * Stores a reference to the scene
  18077. */
  18078. private _scene;
  18079. /**
  18080. * Stores the fill mode state
  18081. */
  18082. private _fillMode;
  18083. /**
  18084. * Specifies if the depth write state should be cached
  18085. */
  18086. private _cachedDepthWriteState;
  18087. /**
  18088. * Stores the uniform buffer
  18089. */
  18090. protected _uniformBuffer: UniformBuffer;
  18091. /** @hidden */
  18092. _indexInSceneMaterialArray: number;
  18093. /** @hidden */
  18094. meshMap: Nullable<{
  18095. [id: string]: AbstractMesh | undefined;
  18096. }>;
  18097. /**
  18098. * Creates a material instance
  18099. * @param name defines the name of the material
  18100. * @param scene defines the scene to reference
  18101. * @param doNotAdd specifies if the material should be added to the scene
  18102. */
  18103. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18104. /**
  18105. * Returns a string representation of the current material
  18106. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18107. * @returns a string with material information
  18108. */
  18109. toString(fullDetails?: boolean): string;
  18110. /**
  18111. * Gets the class name of the material
  18112. * @returns a string with the class name of the material
  18113. */
  18114. getClassName(): string;
  18115. /**
  18116. * Specifies if updates for the material been locked
  18117. */
  18118. readonly isFrozen: boolean;
  18119. /**
  18120. * Locks updates for the material
  18121. */
  18122. freeze(): void;
  18123. /**
  18124. * Unlocks updates for the material
  18125. */
  18126. unfreeze(): void;
  18127. /**
  18128. * Specifies if the material is ready to be used
  18129. * @param mesh defines the mesh to check
  18130. * @param useInstances specifies if instances should be used
  18131. * @returns a boolean indicating if the material is ready to be used
  18132. */
  18133. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18134. /**
  18135. * Specifies that the submesh is ready to be used
  18136. * @param mesh defines the mesh to check
  18137. * @param subMesh defines which submesh to check
  18138. * @param useInstances specifies that instances should be used
  18139. * @returns a boolean indicating that the submesh is ready or not
  18140. */
  18141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18142. /**
  18143. * Returns the material effect
  18144. * @returns the effect associated with the material
  18145. */
  18146. getEffect(): Nullable<Effect>;
  18147. /**
  18148. * Returns the current scene
  18149. * @returns a Scene
  18150. */
  18151. getScene(): Scene;
  18152. /**
  18153. * Specifies if the material will require alpha blending
  18154. * @returns a boolean specifying if alpha blending is needed
  18155. */
  18156. needAlphaBlending(): boolean;
  18157. /**
  18158. * Specifies if the mesh will require alpha blending
  18159. * @param mesh defines the mesh to check
  18160. * @returns a boolean specifying if alpha blending is needed for the mesh
  18161. */
  18162. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18163. /**
  18164. * Specifies if this material should be rendered in alpha test mode
  18165. * @returns a boolean specifying if an alpha test is needed.
  18166. */
  18167. needAlphaTesting(): boolean;
  18168. /**
  18169. * Gets the texture used for the alpha test
  18170. * @returns the texture to use for alpha testing
  18171. */
  18172. getAlphaTestTexture(): Nullable<BaseTexture>;
  18173. /**
  18174. * Marks the material to indicate that it needs to be re-calculated
  18175. */
  18176. markDirty(): void;
  18177. /** @hidden */
  18178. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18179. /**
  18180. * Binds the material to the mesh
  18181. * @param world defines the world transformation matrix
  18182. * @param mesh defines the mesh to bind the material to
  18183. */
  18184. bind(world: Matrix, mesh?: Mesh): void;
  18185. /**
  18186. * Binds the submesh to the material
  18187. * @param world defines the world transformation matrix
  18188. * @param mesh defines the mesh containing the submesh
  18189. * @param subMesh defines the submesh to bind the material to
  18190. */
  18191. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18192. /**
  18193. * Binds the world matrix to the material
  18194. * @param world defines the world transformation matrix
  18195. */
  18196. bindOnlyWorldMatrix(world: Matrix): void;
  18197. /**
  18198. * Binds the scene's uniform buffer to the effect.
  18199. * @param effect defines the effect to bind to the scene uniform buffer
  18200. * @param sceneUbo defines the uniform buffer storing scene data
  18201. */
  18202. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18203. /**
  18204. * Binds the view matrix to the effect
  18205. * @param effect defines the effect to bind the view matrix to
  18206. */
  18207. bindView(effect: Effect): void;
  18208. /**
  18209. * Binds the view projection matrix to the effect
  18210. * @param effect defines the effect to bind the view projection matrix to
  18211. */
  18212. bindViewProjection(effect: Effect): void;
  18213. /**
  18214. * Specifies if material alpha testing should be turned on for the mesh
  18215. * @param mesh defines the mesh to check
  18216. */
  18217. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18218. /**
  18219. * Processes to execute after binding the material to a mesh
  18220. * @param mesh defines the rendered mesh
  18221. */
  18222. protected _afterBind(mesh?: Mesh): void;
  18223. /**
  18224. * Unbinds the material from the mesh
  18225. */
  18226. unbind(): void;
  18227. /**
  18228. * Gets the active textures from the material
  18229. * @returns an array of textures
  18230. */
  18231. getActiveTextures(): BaseTexture[];
  18232. /**
  18233. * Specifies if the material uses a texture
  18234. * @param texture defines the texture to check against the material
  18235. * @returns a boolean specifying if the material uses the texture
  18236. */
  18237. hasTexture(texture: BaseTexture): boolean;
  18238. /**
  18239. * Makes a duplicate of the material, and gives it a new name
  18240. * @param name defines the new name for the duplicated material
  18241. * @returns the cloned material
  18242. */
  18243. clone(name: string): Nullable<Material>;
  18244. /**
  18245. * Gets the meshes bound to the material
  18246. * @returns an array of meshes bound to the material
  18247. */
  18248. getBindedMeshes(): AbstractMesh[];
  18249. /**
  18250. * Force shader compilation
  18251. * @param mesh defines the mesh associated with this material
  18252. * @param onCompiled defines a function to execute once the material is compiled
  18253. * @param options defines the options to configure the compilation
  18254. */
  18255. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18256. clipPlane: boolean;
  18257. }>): void;
  18258. /**
  18259. * Force shader compilation
  18260. * @param mesh defines the mesh that will use this material
  18261. * @param options defines additional options for compiling the shaders
  18262. * @returns a promise that resolves when the compilation completes
  18263. */
  18264. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18265. clipPlane: boolean;
  18266. }>): Promise<void>;
  18267. private static readonly _ImageProcessingDirtyCallBack;
  18268. private static readonly _TextureDirtyCallBack;
  18269. private static readonly _FresnelDirtyCallBack;
  18270. private static readonly _MiscDirtyCallBack;
  18271. private static readonly _LightsDirtyCallBack;
  18272. private static readonly _AttributeDirtyCallBack;
  18273. private static _FresnelAndMiscDirtyCallBack;
  18274. private static _TextureAndMiscDirtyCallBack;
  18275. private static readonly _DirtyCallbackArray;
  18276. private static readonly _RunDirtyCallBacks;
  18277. /**
  18278. * Marks a define in the material to indicate that it needs to be re-computed
  18279. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18280. */
  18281. markAsDirty(flag: number): void;
  18282. /**
  18283. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18284. * @param func defines a function which checks material defines against the submeshes
  18285. */
  18286. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18287. /**
  18288. * Indicates that image processing needs to be re-calculated for all submeshes
  18289. */
  18290. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18291. /**
  18292. * Indicates that textures need to be re-calculated for all submeshes
  18293. */
  18294. protected _markAllSubMeshesAsTexturesDirty(): void;
  18295. /**
  18296. * Indicates that fresnel needs to be re-calculated for all submeshes
  18297. */
  18298. protected _markAllSubMeshesAsFresnelDirty(): void;
  18299. /**
  18300. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18301. */
  18302. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18303. /**
  18304. * Indicates that lights need to be re-calculated for all submeshes
  18305. */
  18306. protected _markAllSubMeshesAsLightsDirty(): void;
  18307. /**
  18308. * Indicates that attributes need to be re-calculated for all submeshes
  18309. */
  18310. protected _markAllSubMeshesAsAttributesDirty(): void;
  18311. /**
  18312. * Indicates that misc needs to be re-calculated for all submeshes
  18313. */
  18314. protected _markAllSubMeshesAsMiscDirty(): void;
  18315. /**
  18316. * Indicates that textures and misc need to be re-calculated for all submeshes
  18317. */
  18318. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18319. /**
  18320. * Disposes the material
  18321. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18322. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18323. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18324. */
  18325. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18326. /** @hidden */
  18327. private releaseVertexArrayObject;
  18328. /**
  18329. * Serializes this material
  18330. * @returns the serialized material object
  18331. */
  18332. serialize(): any;
  18333. /**
  18334. * Creates a MultiMaterial from parsed MultiMaterial data.
  18335. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18336. * @param scene defines the hosting scene
  18337. * @returns a new MultiMaterial
  18338. */
  18339. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18340. /**
  18341. * Creates a material from parsed material data
  18342. * @param parsedMaterial defines parsed material data
  18343. * @param scene defines the hosting scene
  18344. * @param rootUrl defines the root URL to use to load textures
  18345. * @returns a new material
  18346. */
  18347. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18348. }
  18349. }
  18350. declare module BABYLON {
  18351. /**
  18352. * "Static Class" containing the most commonly used helper while dealing with material for
  18353. * rendering purpose.
  18354. *
  18355. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18356. *
  18357. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18358. */
  18359. class MaterialHelper {
  18360. /**
  18361. * Bind the current view position to an effect.
  18362. * @param effect The effect to be bound
  18363. * @param scene The scene the eyes position is used from
  18364. */
  18365. static BindEyePosition(effect: Effect, scene: Scene): void;
  18366. /**
  18367. * Helps preparing the defines values about the UVs in used in the effect.
  18368. * UVs are shared as much as we can accross channels in the shaders.
  18369. * @param texture The texture we are preparing the UVs for
  18370. * @param defines The defines to update
  18371. * @param key The channel key "diffuse", "specular"... used in the shader
  18372. */
  18373. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18374. /**
  18375. * Binds a texture matrix value to its corrsponding uniform
  18376. * @param texture The texture to bind the matrix for
  18377. * @param uniformBuffer The uniform buffer receivin the data
  18378. * @param key The channel key "diffuse", "specular"... used in the shader
  18379. */
  18380. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18381. /**
  18382. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18383. * @param mesh defines the current mesh
  18384. * @param scene defines the current scene
  18385. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18386. * @param pointsCloud defines if point cloud rendering has to be turned on
  18387. * @param fogEnabled defines if fog has to be turned on
  18388. * @param alphaTest defines if alpha testing has to be turned on
  18389. * @param defines defines the current list of defines
  18390. */
  18391. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18392. /**
  18393. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18394. * @param scene defines the current scene
  18395. * @param engine defines the current engine
  18396. * @param defines specifies the list of active defines
  18397. * @param useInstances defines if instances have to be turned on
  18398. * @param useClipPlane defines if clip plane have to be turned on
  18399. */
  18400. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18401. /**
  18402. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18403. * @param mesh The mesh containing the geometry data we will draw
  18404. * @param defines The defines to update
  18405. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18406. * @param useBones Precise whether bones should be used or not (override mesh info)
  18407. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18408. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18409. * @returns false if defines are considered not dirty and have not been checked
  18410. */
  18411. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18412. /**
  18413. * Prepares the defines related to the light information passed in parameter
  18414. * @param scene The scene we are intending to draw
  18415. * @param mesh The mesh the effect is compiling for
  18416. * @param defines The defines to update
  18417. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18418. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18419. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18420. * @returns true if normals will be required for the rest of the effect
  18421. */
  18422. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18423. /**
  18424. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18425. * that won t be acctive due to defines being turned off.
  18426. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18427. * @param samplersList The samplers list
  18428. * @param defines The defines helping in the list generation
  18429. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18430. */
  18431. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18432. /**
  18433. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18434. * @param defines The defines to update while falling back
  18435. * @param fallbacks The authorized effect fallbacks
  18436. * @param maxSimultaneousLights The maximum number of lights allowed
  18437. * @param rank the current rank of the Effect
  18438. * @returns The newly affected rank
  18439. */
  18440. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18441. /**
  18442. * Prepares the list of attributes required for morph targets according to the effect defines.
  18443. * @param attribs The current list of supported attribs
  18444. * @param mesh The mesh to prepare the morph targets attributes for
  18445. * @param defines The current Defines of the effect
  18446. */
  18447. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18448. /**
  18449. * Prepares the list of attributes required for bones according to the effect defines.
  18450. * @param attribs The current list of supported attribs
  18451. * @param mesh The mesh to prepare the bones attributes for
  18452. * @param defines The current Defines of the effect
  18453. * @param fallbacks The current efffect fallback strategy
  18454. */
  18455. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18456. /**
  18457. * Prepares the list of attributes required for instances according to the effect defines.
  18458. * @param attribs The current list of supported attribs
  18459. * @param defines The current Defines of the effect
  18460. */
  18461. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18462. /**
  18463. * Binds the light shadow information to the effect for the given mesh.
  18464. * @param light The light containing the generator
  18465. * @param scene The scene the lights belongs to
  18466. * @param mesh The mesh we are binding the information to render
  18467. * @param lightIndex The light index in the effect used to render the mesh
  18468. * @param effect The effect we are binding the data to
  18469. */
  18470. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18471. /**
  18472. * Binds the light information to the effect.
  18473. * @param light The light containing the generator
  18474. * @param effect The effect we are binding the data to
  18475. * @param lightIndex The light index in the effect used to render
  18476. */
  18477. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18478. /**
  18479. * Binds the lights information from the scene to the effect for the given mesh.
  18480. * @param scene The scene the lights belongs to
  18481. * @param mesh The mesh we are binding the information to render
  18482. * @param effect The effect we are binding the data to
  18483. * @param defines The generated defines for the effect
  18484. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18485. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18486. */
  18487. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18488. private static _tempFogColor;
  18489. /**
  18490. * Binds the fog information from the scene to the effect for the given mesh.
  18491. * @param scene The scene the lights belongs to
  18492. * @param mesh The mesh we are binding the information to render
  18493. * @param effect The effect we are binding the data to
  18494. * @param linearSpace Defines if the fog effect is applied in linear space
  18495. */
  18496. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18497. /**
  18498. * Binds the bones information from the mesh to the effect.
  18499. * @param mesh The mesh we are binding the information to render
  18500. * @param effect The effect we are binding the data to
  18501. */
  18502. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18503. /**
  18504. * Binds the morph targets information from the mesh to the effect.
  18505. * @param abstractMesh The mesh we are binding the information to render
  18506. * @param effect The effect we are binding the data to
  18507. */
  18508. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18509. /**
  18510. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18511. * @param defines The generated defines used in the effect
  18512. * @param effect The effect we are binding the data to
  18513. * @param scene The scene we are willing to render with logarithmic scale for
  18514. */
  18515. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18516. /**
  18517. * Binds the clip plane information from the scene to the effect.
  18518. * @param scene The scene the clip plane information are extracted from
  18519. * @param effect The effect we are binding the data to
  18520. */
  18521. static BindClipPlane(effect: Effect, scene: Scene): void;
  18522. }
  18523. }
  18524. declare module BABYLON {
  18525. /**
  18526. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18527. * separate meshes. This can be use to improve performances.
  18528. * @see http://doc.babylonjs.com/how_to/multi_materials
  18529. */
  18530. class MultiMaterial extends Material {
  18531. private _subMaterials;
  18532. /**
  18533. * Gets or Sets the list of Materials used within the multi material.
  18534. * They need to be ordered according to the submeshes order in the associated mesh
  18535. */
  18536. subMaterials: Nullable<Material>[];
  18537. /**
  18538. * Function used to align with Node.getChildren()
  18539. * @returns the list of Materials used within the multi material
  18540. */
  18541. getChildren(): Nullable<Material>[];
  18542. /**
  18543. * Instantiates a new Multi Material
  18544. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18545. * separate meshes. This can be use to improve performances.
  18546. * @see http://doc.babylonjs.com/how_to/multi_materials
  18547. * @param name Define the name in the scene
  18548. * @param scene Define the scene the material belongs to
  18549. */
  18550. constructor(name: string, scene: Scene);
  18551. private _hookArray;
  18552. /**
  18553. * Get one of the submaterial by its index in the submaterials array
  18554. * @param index The index to look the sub material at
  18555. * @returns The Material if the index has been defined
  18556. */
  18557. getSubMaterial(index: number): Nullable<Material>;
  18558. /**
  18559. * Get the list of active textures for the whole sub materials list.
  18560. * @returns All the textures that will be used during the rendering
  18561. */
  18562. getActiveTextures(): BaseTexture[];
  18563. /**
  18564. * Gets the current class name of the material e.g. "MultiMaterial"
  18565. * Mainly use in serialization.
  18566. * @returns the class name
  18567. */
  18568. getClassName(): string;
  18569. /**
  18570. * Checks if the material is ready to render the requested sub mesh
  18571. * @param mesh Define the mesh the submesh belongs to
  18572. * @param subMesh Define the sub mesh to look readyness for
  18573. * @param useInstances Define whether or not the material is used with instances
  18574. * @returns true if ready, otherwise false
  18575. */
  18576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18577. /**
  18578. * Clones the current material and its related sub materials
  18579. * @param name Define the name of the newly cloned material
  18580. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18581. * @returns the cloned material
  18582. */
  18583. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18584. /**
  18585. * Serializes the materials into a JSON representation.
  18586. * @returns the JSON representation
  18587. */
  18588. serialize(): any;
  18589. /**
  18590. * Dispose the material and release its associated resources
  18591. * @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)
  18592. * @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)
  18593. */
  18594. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18595. }
  18596. }
  18597. declare module BABYLON {
  18598. /**
  18599. * Base class of materials working in push mode in babylon JS
  18600. * @hidden
  18601. */
  18602. class PushMaterial extends Material {
  18603. protected _activeEffect: Effect;
  18604. protected _normalMatrix: Matrix;
  18605. /**
  18606. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18607. * This means that the material can keep using a previous shader while a new one is being compiled.
  18608. * This is mostly used when shader parallel compilation is supported (true by default)
  18609. */
  18610. allowShaderHotSwapping: boolean;
  18611. constructor(name: string, scene: Scene);
  18612. getEffect(): Effect;
  18613. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18614. /**
  18615. * Binds the given world matrix to the active effect
  18616. *
  18617. * @param world the matrix to bind
  18618. */
  18619. bindOnlyWorldMatrix(world: Matrix): void;
  18620. /**
  18621. * Binds the given normal matrix to the active effect
  18622. *
  18623. * @param normalMatrix the matrix to bind
  18624. */
  18625. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18626. bind(world: Matrix, mesh?: Mesh): void;
  18627. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18628. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18629. }
  18630. }
  18631. declare module BABYLON {
  18632. /**
  18633. * Defines the options associated with the creation of a shader material.
  18634. */
  18635. interface IShaderMaterialOptions {
  18636. /**
  18637. * Does the material work in alpha blend mode
  18638. */
  18639. needAlphaBlending: boolean;
  18640. /**
  18641. * Does the material work in alpha test mode
  18642. */
  18643. needAlphaTesting: boolean;
  18644. /**
  18645. * The list of attribute names used in the shader
  18646. */
  18647. attributes: string[];
  18648. /**
  18649. * The list of unifrom names used in the shader
  18650. */
  18651. uniforms: string[];
  18652. /**
  18653. * The list of UBO names used in the shader
  18654. */
  18655. uniformBuffers: string[];
  18656. /**
  18657. * The list of sampler names used in the shader
  18658. */
  18659. samplers: string[];
  18660. /**
  18661. * The list of defines used in the shader
  18662. */
  18663. defines: string[];
  18664. }
  18665. /**
  18666. * 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.
  18667. *
  18668. * This returned material effects how the mesh will look based on the code in the shaders.
  18669. *
  18670. * @see http://doc.babylonjs.com/how_to/shader_material
  18671. */
  18672. class ShaderMaterial extends Material {
  18673. private _shaderPath;
  18674. private _options;
  18675. private _textures;
  18676. private _textureArrays;
  18677. private _floats;
  18678. private _ints;
  18679. private _floatsArrays;
  18680. private _colors3;
  18681. private _colors3Arrays;
  18682. private _colors4;
  18683. private _vectors2;
  18684. private _vectors3;
  18685. private _vectors4;
  18686. private _matrices;
  18687. private _matrices3x3;
  18688. private _matrices2x2;
  18689. private _vectors2Arrays;
  18690. private _vectors3Arrays;
  18691. private _cachedWorldViewMatrix;
  18692. private _renderId;
  18693. /**
  18694. * Instantiate a new shader material.
  18695. * 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.
  18696. * This returned material effects how the mesh will look based on the code in the shaders.
  18697. * @see http://doc.babylonjs.com/how_to/shader_material
  18698. * @param name Define the name of the material in the scene
  18699. * @param scene Define the scene the material belongs to
  18700. * @param shaderPath Defines the route to the shader code in one of three ways:
  18701. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18702. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18703. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18704. * @param options Define the options used to create the shader
  18705. */
  18706. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18707. /**
  18708. * Gets the current class name of the material e.g. "ShaderMaterial"
  18709. * Mainly use in serialization.
  18710. * @returns the class name
  18711. */
  18712. getClassName(): string;
  18713. /**
  18714. * Specifies if the material will require alpha blending
  18715. * @returns a boolean specifying if alpha blending is needed
  18716. */
  18717. needAlphaBlending(): boolean;
  18718. /**
  18719. * Specifies if this material should be rendered in alpha test mode
  18720. * @returns a boolean specifying if an alpha test is needed.
  18721. */
  18722. needAlphaTesting(): boolean;
  18723. private _checkUniform;
  18724. /**
  18725. * Set a texture in the shader.
  18726. * @param name Define the name of the uniform samplers as defined in the shader
  18727. * @param texture Define the texture to bind to this sampler
  18728. * @return the material itself allowing "fluent" like uniform updates
  18729. */
  18730. setTexture(name: string, texture: Texture): ShaderMaterial;
  18731. /**
  18732. * Set a texture array in the shader.
  18733. * @param name Define the name of the uniform sampler array as defined in the shader
  18734. * @param textures Define the list of textures to bind to this sampler
  18735. * @return the material itself allowing "fluent" like uniform updates
  18736. */
  18737. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18738. /**
  18739. * Set a float in the shader.
  18740. * @param name Define the name of the uniform as defined in the shader
  18741. * @param value Define the value to give to the uniform
  18742. * @return the material itself allowing "fluent" like uniform updates
  18743. */
  18744. setFloat(name: string, value: number): ShaderMaterial;
  18745. /**
  18746. * Set a int in the shader.
  18747. * @param name Define the name of the uniform as defined in the shader
  18748. * @param value Define the value to give to the uniform
  18749. * @return the material itself allowing "fluent" like uniform updates
  18750. */
  18751. setInt(name: string, value: number): ShaderMaterial;
  18752. /**
  18753. * Set an array of floats in the shader.
  18754. * @param name Define the name of the uniform as defined in the shader
  18755. * @param value Define the value to give to the uniform
  18756. * @return the material itself allowing "fluent" like uniform updates
  18757. */
  18758. setFloats(name: string, value: number[]): ShaderMaterial;
  18759. /**
  18760. * Set a vec3 in the shader from a Color3.
  18761. * @param name Define the name of the uniform as defined in the shader
  18762. * @param value Define the value to give to the uniform
  18763. * @return the material itself allowing "fluent" like uniform updates
  18764. */
  18765. setColor3(name: string, value: Color3): ShaderMaterial;
  18766. /**
  18767. * Set a vec3 array in the shader from a Color3 array.
  18768. * @param name Define the name of the uniform as defined in the shader
  18769. * @param value Define the value to give to the uniform
  18770. * @return the material itself allowing "fluent" like uniform updates
  18771. */
  18772. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18773. /**
  18774. * Set a vec4 in the shader from a Color4.
  18775. * @param name Define the name of the uniform as defined in the shader
  18776. * @param value Define the value to give to the uniform
  18777. * @return the material itself allowing "fluent" like uniform updates
  18778. */
  18779. setColor4(name: string, value: Color4): ShaderMaterial;
  18780. /**
  18781. * Set a vec2 in the shader from a Vector2.
  18782. * @param name Define the name of the uniform as defined in the shader
  18783. * @param value Define the value to give to the uniform
  18784. * @return the material itself allowing "fluent" like uniform updates
  18785. */
  18786. setVector2(name: string, value: Vector2): ShaderMaterial;
  18787. /**
  18788. * Set a vec3 in the shader from a Vector3.
  18789. * @param name Define the name of the uniform as defined in the shader
  18790. * @param value Define the value to give to the uniform
  18791. * @return the material itself allowing "fluent" like uniform updates
  18792. */
  18793. setVector3(name: string, value: Vector3): ShaderMaterial;
  18794. /**
  18795. * Set a vec4 in the shader from a Vector4.
  18796. * @param name Define the name of the uniform as defined in the shader
  18797. * @param value Define the value to give to the uniform
  18798. * @return the material itself allowing "fluent" like uniform updates
  18799. */
  18800. setVector4(name: string, value: Vector4): ShaderMaterial;
  18801. /**
  18802. * Set a mat4 in the shader from a Matrix.
  18803. * @param name Define the name of the uniform as defined in the shader
  18804. * @param value Define the value to give to the uniform
  18805. * @return the material itself allowing "fluent" like uniform updates
  18806. */
  18807. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18808. /**
  18809. * Set a mat3 in the shader from a Float32Array.
  18810. * @param name Define the name of the uniform as defined in the shader
  18811. * @param value Define the value to give to the uniform
  18812. * @return the material itself allowing "fluent" like uniform updates
  18813. */
  18814. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18815. /**
  18816. * Set a mat2 in the shader from a Float32Array.
  18817. * @param name Define the name of the uniform as defined in the shader
  18818. * @param value Define the value to give to the uniform
  18819. * @return the material itself allowing "fluent" like uniform updates
  18820. */
  18821. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18822. /**
  18823. * Set a vec2 array in the shader from a number array.
  18824. * @param name Define the name of the uniform as defined in the shader
  18825. * @param value Define the value to give to the uniform
  18826. * @return the material itself allowing "fluent" like uniform updates
  18827. */
  18828. setArray2(name: string, value: number[]): ShaderMaterial;
  18829. /**
  18830. * Set a vec3 array in the shader from a number array.
  18831. * @param name Define the name of the uniform as defined in the shader
  18832. * @param value Define the value to give to the uniform
  18833. * @return the material itself allowing "fluent" like uniform updates
  18834. */
  18835. setArray3(name: string, value: number[]): ShaderMaterial;
  18836. private _checkCache;
  18837. /**
  18838. * Checks if the material is ready to render the requested mesh
  18839. * @param mesh Define the mesh to render
  18840. * @param useInstances Define whether or not the material is used with instances
  18841. * @returns true if ready, otherwise false
  18842. */
  18843. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18844. /**
  18845. * Binds the world matrix to the material
  18846. * @param world defines the world transformation matrix
  18847. */
  18848. bindOnlyWorldMatrix(world: Matrix): void;
  18849. /**
  18850. * Binds the material to the mesh
  18851. * @param world defines the world transformation matrix
  18852. * @param mesh defines the mesh to bind the material to
  18853. */
  18854. bind(world: Matrix, mesh?: Mesh): void;
  18855. /**
  18856. * Gets the active textures from the material
  18857. * @returns an array of textures
  18858. */
  18859. getActiveTextures(): BaseTexture[];
  18860. /**
  18861. * Specifies if the material uses a texture
  18862. * @param texture defines the texture to check against the material
  18863. * @returns a boolean specifying if the material uses the texture
  18864. */
  18865. hasTexture(texture: BaseTexture): boolean;
  18866. /**
  18867. * Makes a duplicate of the material, and gives it a new name
  18868. * @param name defines the new name for the duplicated material
  18869. * @returns the cloned material
  18870. */
  18871. clone(name: string): ShaderMaterial;
  18872. /**
  18873. * Disposes the material
  18874. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18875. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18876. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18877. */
  18878. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18879. /**
  18880. * Serializes this material in a JSON representation
  18881. * @returns the serialized material object
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Creates a shader material from parsed shader material data
  18886. * @param source defines the JSON represnetation of the material
  18887. * @param scene defines the hosting scene
  18888. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18889. * @returns a new material
  18890. */
  18891. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18892. }
  18893. }
  18894. declare module BABYLON {
  18895. /** @hidden */
  18896. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18897. MAINUV1: boolean;
  18898. MAINUV2: boolean;
  18899. DIFFUSE: boolean;
  18900. DIFFUSEDIRECTUV: number;
  18901. AMBIENT: boolean;
  18902. AMBIENTDIRECTUV: number;
  18903. OPACITY: boolean;
  18904. OPACITYDIRECTUV: number;
  18905. OPACITYRGB: boolean;
  18906. REFLECTION: boolean;
  18907. EMISSIVE: boolean;
  18908. EMISSIVEDIRECTUV: number;
  18909. SPECULAR: boolean;
  18910. SPECULARDIRECTUV: number;
  18911. BUMP: boolean;
  18912. BUMPDIRECTUV: number;
  18913. PARALLAX: boolean;
  18914. PARALLAXOCCLUSION: boolean;
  18915. SPECULAROVERALPHA: boolean;
  18916. CLIPPLANE: boolean;
  18917. CLIPPLANE2: boolean;
  18918. CLIPPLANE3: boolean;
  18919. CLIPPLANE4: boolean;
  18920. ALPHATEST: boolean;
  18921. DEPTHPREPASS: boolean;
  18922. ALPHAFROMDIFFUSE: boolean;
  18923. POINTSIZE: boolean;
  18924. FOG: boolean;
  18925. SPECULARTERM: boolean;
  18926. DIFFUSEFRESNEL: boolean;
  18927. OPACITYFRESNEL: boolean;
  18928. REFLECTIONFRESNEL: boolean;
  18929. REFRACTIONFRESNEL: boolean;
  18930. EMISSIVEFRESNEL: boolean;
  18931. FRESNEL: boolean;
  18932. NORMAL: boolean;
  18933. UV1: boolean;
  18934. UV2: boolean;
  18935. VERTEXCOLOR: boolean;
  18936. VERTEXALPHA: boolean;
  18937. NUM_BONE_INFLUENCERS: number;
  18938. BonesPerMesh: number;
  18939. BONETEXTURE: boolean;
  18940. INSTANCES: boolean;
  18941. GLOSSINESS: boolean;
  18942. ROUGHNESS: boolean;
  18943. EMISSIVEASILLUMINATION: boolean;
  18944. LINKEMISSIVEWITHDIFFUSE: boolean;
  18945. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18946. LIGHTMAP: boolean;
  18947. LIGHTMAPDIRECTUV: number;
  18948. OBJECTSPACE_NORMALMAP: boolean;
  18949. USELIGHTMAPASSHADOWMAP: boolean;
  18950. REFLECTIONMAP_3D: boolean;
  18951. REFLECTIONMAP_SPHERICAL: boolean;
  18952. REFLECTIONMAP_PLANAR: boolean;
  18953. REFLECTIONMAP_CUBIC: boolean;
  18954. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18955. REFLECTIONMAP_PROJECTION: boolean;
  18956. REFLECTIONMAP_SKYBOX: boolean;
  18957. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18958. REFLECTIONMAP_EXPLICIT: boolean;
  18959. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18960. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18961. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18962. INVERTCUBICMAP: boolean;
  18963. LOGARITHMICDEPTH: boolean;
  18964. REFRACTION: boolean;
  18965. REFRACTIONMAP_3D: boolean;
  18966. REFLECTIONOVERALPHA: boolean;
  18967. TWOSIDEDLIGHTING: boolean;
  18968. SHADOWFLOAT: boolean;
  18969. MORPHTARGETS: boolean;
  18970. MORPHTARGETS_NORMAL: boolean;
  18971. MORPHTARGETS_TANGENT: boolean;
  18972. NUM_MORPH_INFLUENCERS: number;
  18973. NONUNIFORMSCALING: boolean;
  18974. PREMULTIPLYALPHA: boolean;
  18975. IMAGEPROCESSING: boolean;
  18976. VIGNETTE: boolean;
  18977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18978. VIGNETTEBLENDMODEOPAQUE: boolean;
  18979. TONEMAPPING: boolean;
  18980. TONEMAPPING_ACES: boolean;
  18981. CONTRAST: boolean;
  18982. COLORCURVES: boolean;
  18983. COLORGRADING: boolean;
  18984. COLORGRADING3D: boolean;
  18985. SAMPLER3DGREENDEPTH: boolean;
  18986. SAMPLER3DBGRMAP: boolean;
  18987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18988. /**
  18989. * If the reflection texture on this material is in linear color space
  18990. * @hidden
  18991. */
  18992. IS_REFLECTION_LINEAR: boolean;
  18993. /**
  18994. * If the refraction texture on this material is in linear color space
  18995. * @hidden
  18996. */
  18997. IS_REFRACTION_LINEAR: boolean;
  18998. EXPOSURE: boolean;
  18999. constructor();
  19000. setReflectionMode(modeToEnable: string): void;
  19001. }
  19002. /**
  19003. * This is the default material used in Babylon. It is the best trade off between quality
  19004. * and performances.
  19005. * @see http://doc.babylonjs.com/babylon101/materials
  19006. */
  19007. class StandardMaterial extends PushMaterial {
  19008. private _diffuseTexture;
  19009. /**
  19010. * The basic texture of the material as viewed under a light.
  19011. */
  19012. diffuseTexture: Nullable<BaseTexture>;
  19013. private _ambientTexture;
  19014. /**
  19015. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19016. */
  19017. ambientTexture: Nullable<BaseTexture>;
  19018. private _opacityTexture;
  19019. /**
  19020. * Define the transparency of the material from a texture.
  19021. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19022. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19023. */
  19024. opacityTexture: Nullable<BaseTexture>;
  19025. private _reflectionTexture;
  19026. /**
  19027. * Define the texture used to display the reflection.
  19028. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19029. */
  19030. reflectionTexture: Nullable<BaseTexture>;
  19031. private _emissiveTexture;
  19032. /**
  19033. * Define texture of the material as if self lit.
  19034. * This will be mixed in the final result even in the absence of light.
  19035. */
  19036. emissiveTexture: Nullable<BaseTexture>;
  19037. private _specularTexture;
  19038. /**
  19039. * Define how the color and intensity of the highlight given by the light in the material.
  19040. */
  19041. specularTexture: Nullable<BaseTexture>;
  19042. private _bumpTexture;
  19043. /**
  19044. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19045. * 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.
  19046. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19047. */
  19048. bumpTexture: Nullable<BaseTexture>;
  19049. private _lightmapTexture;
  19050. /**
  19051. * Complex lighting can be computationally expensive to compute at runtime.
  19052. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19053. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19054. */
  19055. lightmapTexture: Nullable<BaseTexture>;
  19056. private _refractionTexture;
  19057. /**
  19058. * Define the texture used to display the refraction.
  19059. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19060. */
  19061. refractionTexture: Nullable<BaseTexture>;
  19062. /**
  19063. * The color of the material lit by the environmental background lighting.
  19064. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19065. */
  19066. ambientColor: Color3;
  19067. /**
  19068. * The basic color of the material as viewed under a light.
  19069. */
  19070. diffuseColor: Color3;
  19071. /**
  19072. * Define how the color and intensity of the highlight given by the light in the material.
  19073. */
  19074. specularColor: Color3;
  19075. /**
  19076. * Define the color of the material as if self lit.
  19077. * This will be mixed in the final result even in the absence of light.
  19078. */
  19079. emissiveColor: Color3;
  19080. /**
  19081. * Defines how sharp are the highlights in the material.
  19082. * The bigger the value the sharper giving a more glossy feeling to the result.
  19083. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19084. */
  19085. specularPower: number;
  19086. private _useAlphaFromDiffuseTexture;
  19087. /**
  19088. * Does the transparency come from the diffuse texture alpha channel.
  19089. */
  19090. useAlphaFromDiffuseTexture: boolean;
  19091. private _useEmissiveAsIllumination;
  19092. /**
  19093. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19094. */
  19095. useEmissiveAsIllumination: boolean;
  19096. private _linkEmissiveWithDiffuse;
  19097. /**
  19098. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19099. * the emissive level when the final color is close to one.
  19100. */
  19101. linkEmissiveWithDiffuse: boolean;
  19102. private _useSpecularOverAlpha;
  19103. /**
  19104. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19105. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19106. */
  19107. useSpecularOverAlpha: boolean;
  19108. private _useReflectionOverAlpha;
  19109. /**
  19110. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19111. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19112. */
  19113. useReflectionOverAlpha: boolean;
  19114. private _disableLighting;
  19115. /**
  19116. * Does lights from the scene impacts this material.
  19117. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19118. */
  19119. disableLighting: boolean;
  19120. private _useObjectSpaceNormalMap;
  19121. /**
  19122. * Allows using an object space normal map (instead of tangent space).
  19123. */
  19124. useObjectSpaceNormalMap: boolean;
  19125. private _useParallax;
  19126. /**
  19127. * Is parallax enabled or not.
  19128. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19129. */
  19130. useParallax: boolean;
  19131. private _useParallaxOcclusion;
  19132. /**
  19133. * Is parallax occlusion enabled or not.
  19134. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19135. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19136. */
  19137. useParallaxOcclusion: boolean;
  19138. /**
  19139. * 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.
  19140. */
  19141. parallaxScaleBias: number;
  19142. private _roughness;
  19143. /**
  19144. * Helps to define how blurry the reflections should appears in the material.
  19145. */
  19146. roughness: number;
  19147. /**
  19148. * In case of refraction, define the value of the indice of refraction.
  19149. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19150. */
  19151. indexOfRefraction: number;
  19152. /**
  19153. * Invert the refraction texture alongside the y axis.
  19154. * It can be useful with procedural textures or probe for instance.
  19155. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19156. */
  19157. invertRefractionY: boolean;
  19158. /**
  19159. * Defines the alpha limits in alpha test mode.
  19160. */
  19161. alphaCutOff: number;
  19162. private _useLightmapAsShadowmap;
  19163. /**
  19164. * In case of light mapping, define whether the map contains light or shadow informations.
  19165. */
  19166. useLightmapAsShadowmap: boolean;
  19167. private _diffuseFresnelParameters;
  19168. /**
  19169. * Define the diffuse fresnel parameters of the material.
  19170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19171. */
  19172. diffuseFresnelParameters: FresnelParameters;
  19173. private _opacityFresnelParameters;
  19174. /**
  19175. * Define the opacity fresnel parameters of the material.
  19176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19177. */
  19178. opacityFresnelParameters: FresnelParameters;
  19179. private _reflectionFresnelParameters;
  19180. /**
  19181. * Define the reflection fresnel parameters of the material.
  19182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19183. */
  19184. reflectionFresnelParameters: FresnelParameters;
  19185. private _refractionFresnelParameters;
  19186. /**
  19187. * Define the refraction fresnel parameters of the material.
  19188. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19189. */
  19190. refractionFresnelParameters: FresnelParameters;
  19191. private _emissiveFresnelParameters;
  19192. /**
  19193. * Define the emissive fresnel parameters of the material.
  19194. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19195. */
  19196. emissiveFresnelParameters: FresnelParameters;
  19197. private _useReflectionFresnelFromSpecular;
  19198. /**
  19199. * If true automatically deducts the fresnels values from the material specularity.
  19200. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19201. */
  19202. useReflectionFresnelFromSpecular: boolean;
  19203. private _useGlossinessFromSpecularMapAlpha;
  19204. /**
  19205. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19206. */
  19207. useGlossinessFromSpecularMapAlpha: boolean;
  19208. private _maxSimultaneousLights;
  19209. /**
  19210. * Defines the maximum number of lights that can be used in the material
  19211. */
  19212. maxSimultaneousLights: number;
  19213. private _invertNormalMapX;
  19214. /**
  19215. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19216. */
  19217. invertNormalMapX: boolean;
  19218. private _invertNormalMapY;
  19219. /**
  19220. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19221. */
  19222. invertNormalMapY: boolean;
  19223. private _twoSidedLighting;
  19224. /**
  19225. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19226. */
  19227. twoSidedLighting: boolean;
  19228. /**
  19229. * Default configuration related to image processing available in the standard Material.
  19230. */
  19231. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19232. /**
  19233. * Gets the image processing configuration used either in this material.
  19234. */
  19235. /**
  19236. * Sets the Default image processing configuration used either in the this material.
  19237. *
  19238. * If sets to null, the scene one is in use.
  19239. */
  19240. imageProcessingConfiguration: ImageProcessingConfiguration;
  19241. /**
  19242. * Keep track of the image processing observer to allow dispose and replace.
  19243. */
  19244. private _imageProcessingObserver;
  19245. /**
  19246. * Attaches a new image processing configuration to the Standard Material.
  19247. * @param configuration
  19248. */
  19249. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19250. /**
  19251. * Gets wether the color curves effect is enabled.
  19252. */
  19253. /**
  19254. * Sets wether the color curves effect is enabled.
  19255. */
  19256. cameraColorCurvesEnabled: boolean;
  19257. /**
  19258. * Gets wether the color grading effect is enabled.
  19259. */
  19260. /**
  19261. * Gets wether the color grading effect is enabled.
  19262. */
  19263. cameraColorGradingEnabled: boolean;
  19264. /**
  19265. * Gets wether tonemapping is enabled or not.
  19266. */
  19267. /**
  19268. * Sets wether tonemapping is enabled or not
  19269. */
  19270. cameraToneMappingEnabled: boolean;
  19271. /**
  19272. * The camera exposure used on this material.
  19273. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19274. * This corresponds to a photographic exposure.
  19275. */
  19276. /**
  19277. * The camera exposure used on this material.
  19278. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19279. * This corresponds to a photographic exposure.
  19280. */
  19281. cameraExposure: number;
  19282. /**
  19283. * Gets The camera contrast used on this material.
  19284. */
  19285. /**
  19286. * Sets The camera contrast used on this material.
  19287. */
  19288. cameraContrast: number;
  19289. /**
  19290. * Gets the Color Grading 2D Lookup Texture.
  19291. */
  19292. /**
  19293. * Sets the Color Grading 2D Lookup Texture.
  19294. */
  19295. cameraColorGradingTexture: Nullable<BaseTexture>;
  19296. /**
  19297. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19298. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19299. * 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;
  19300. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19301. */
  19302. /**
  19303. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19304. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19305. * 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;
  19306. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19307. */
  19308. cameraColorCurves: Nullable<ColorCurves>;
  19309. /**
  19310. * Custom callback helping to override the default shader used in the material.
  19311. */
  19312. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19313. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19314. protected _worldViewProjectionMatrix: Matrix;
  19315. protected _globalAmbientColor: Color3;
  19316. protected _useLogarithmicDepth: boolean;
  19317. /**
  19318. * Instantiates a new standard material.
  19319. * This is the default material used in Babylon. It is the best trade off between quality
  19320. * and performances.
  19321. * @see http://doc.babylonjs.com/babylon101/materials
  19322. * @param name Define the name of the material in the scene
  19323. * @param scene Define the scene the material belong to
  19324. */
  19325. constructor(name: string, scene: Scene);
  19326. /**
  19327. * Gets a boolean indicating that current material needs to register RTT
  19328. */
  19329. readonly hasRenderTargetTextures: boolean;
  19330. /**
  19331. * Gets the current class name of the material e.g. "StandardMaterial"
  19332. * Mainly use in serialization.
  19333. * @returns the class name
  19334. */
  19335. getClassName(): string;
  19336. /**
  19337. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19338. * You can try switching to logarithmic depth.
  19339. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19340. */
  19341. useLogarithmicDepth: boolean;
  19342. /**
  19343. * Specifies if the material will require alpha blending
  19344. * @returns a boolean specifying if alpha blending is needed
  19345. */
  19346. needAlphaBlending(): boolean;
  19347. /**
  19348. * Specifies if this material should be rendered in alpha test mode
  19349. * @returns a boolean specifying if an alpha test is needed.
  19350. */
  19351. needAlphaTesting(): boolean;
  19352. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19353. /**
  19354. * Get the texture used for alpha test purpose.
  19355. * @returns the diffuse texture in case of the standard material.
  19356. */
  19357. getAlphaTestTexture(): Nullable<BaseTexture>;
  19358. /**
  19359. * Get if the submesh is ready to be used and all its information available.
  19360. * Child classes can use it to update shaders
  19361. * @param mesh defines the mesh to check
  19362. * @param subMesh defines which submesh to check
  19363. * @param useInstances specifies that instances should be used
  19364. * @returns a boolean indicating that the submesh is ready or not
  19365. */
  19366. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19367. /**
  19368. * Builds the material UBO layouts.
  19369. * Used internally during the effect preparation.
  19370. */
  19371. buildUniformLayout(): void;
  19372. /**
  19373. * Unbinds the material from the mesh
  19374. */
  19375. unbind(): void;
  19376. /**
  19377. * Binds the submesh to this material by preparing the effect and shader to draw
  19378. * @param world defines the world transformation matrix
  19379. * @param mesh defines the mesh containing the submesh
  19380. * @param subMesh defines the submesh to bind the material to
  19381. */
  19382. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19383. /**
  19384. * Get the list of animatables in the material.
  19385. * @returns the list of animatables object used in the material
  19386. */
  19387. getAnimatables(): IAnimatable[];
  19388. /**
  19389. * Gets the active textures from the material
  19390. * @returns an array of textures
  19391. */
  19392. getActiveTextures(): BaseTexture[];
  19393. /**
  19394. * Specifies if the material uses a texture
  19395. * @param texture defines the texture to check against the material
  19396. * @returns a boolean specifying if the material uses the texture
  19397. */
  19398. hasTexture(texture: BaseTexture): boolean;
  19399. /**
  19400. * Disposes the material
  19401. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19402. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19403. */
  19404. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19405. /**
  19406. * Makes a duplicate of the material, and gives it a new name
  19407. * @param name defines the new name for the duplicated material
  19408. * @returns the cloned material
  19409. */
  19410. clone(name: string): StandardMaterial;
  19411. /**
  19412. * Serializes this material in a JSON representation
  19413. * @returns the serialized material object
  19414. */
  19415. serialize(): any;
  19416. /**
  19417. * Creates a standard material from parsed material data
  19418. * @param source defines the JSON representation of the material
  19419. * @param scene defines the hosting scene
  19420. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19421. * @returns a new standard material
  19422. */
  19423. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19424. private static _DiffuseTextureEnabled;
  19425. /**
  19426. * Are diffuse textures enabled in the application.
  19427. */
  19428. static DiffuseTextureEnabled: boolean;
  19429. private static _AmbientTextureEnabled;
  19430. /**
  19431. * Are ambient textures enabled in the application.
  19432. */
  19433. static AmbientTextureEnabled: boolean;
  19434. private static _OpacityTextureEnabled;
  19435. /**
  19436. * Are opacity textures enabled in the application.
  19437. */
  19438. static OpacityTextureEnabled: boolean;
  19439. private static _ReflectionTextureEnabled;
  19440. /**
  19441. * Are reflection textures enabled in the application.
  19442. */
  19443. static ReflectionTextureEnabled: boolean;
  19444. private static _EmissiveTextureEnabled;
  19445. /**
  19446. * Are emissive textures enabled in the application.
  19447. */
  19448. static EmissiveTextureEnabled: boolean;
  19449. private static _SpecularTextureEnabled;
  19450. /**
  19451. * Are specular textures enabled in the application.
  19452. */
  19453. static SpecularTextureEnabled: boolean;
  19454. private static _BumpTextureEnabled;
  19455. /**
  19456. * Are bump textures enabled in the application.
  19457. */
  19458. static BumpTextureEnabled: boolean;
  19459. private static _LightmapTextureEnabled;
  19460. /**
  19461. * Are lightmap textures enabled in the application.
  19462. */
  19463. static LightmapTextureEnabled: boolean;
  19464. private static _RefractionTextureEnabled;
  19465. /**
  19466. * Are refraction textures enabled in the application.
  19467. */
  19468. static RefractionTextureEnabled: boolean;
  19469. private static _ColorGradingTextureEnabled;
  19470. /**
  19471. * Are color grading textures enabled in the application.
  19472. */
  19473. static ColorGradingTextureEnabled: boolean;
  19474. private static _FresnelEnabled;
  19475. /**
  19476. * Are fresnels enabled in the application.
  19477. */
  19478. static FresnelEnabled: boolean;
  19479. }
  19480. }
  19481. declare module BABYLON {
  19482. /**
  19483. * Uniform buffer objects.
  19484. *
  19485. * Handles blocks of uniform on the GPU.
  19486. *
  19487. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19488. *
  19489. * For more information, please refer to :
  19490. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19491. */
  19492. class UniformBuffer {
  19493. private _engine;
  19494. private _buffer;
  19495. private _data;
  19496. private _bufferData;
  19497. private _dynamic?;
  19498. private _uniformLocations;
  19499. private _uniformSizes;
  19500. private _uniformLocationPointer;
  19501. private _needSync;
  19502. private _noUBO;
  19503. private _currentEffect;
  19504. private static _MAX_UNIFORM_SIZE;
  19505. private static _tempBuffer;
  19506. /**
  19507. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19508. * This is dynamic to allow compat with webgl 1 and 2.
  19509. * You will need to pass the name of the uniform as well as the value.
  19510. */
  19511. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19512. /**
  19513. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19514. * This is dynamic to allow compat with webgl 1 and 2.
  19515. * You will need to pass the name of the uniform as well as the value.
  19516. */
  19517. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19518. /**
  19519. * Lambda to Update a single float in a uniform buffer.
  19520. * This is dynamic to allow compat with webgl 1 and 2.
  19521. * You will need to pass the name of the uniform as well as the value.
  19522. */
  19523. updateFloat: (name: string, x: number) => void;
  19524. /**
  19525. * Lambda to Update a vec2 of float in a uniform buffer.
  19526. * This is dynamic to allow compat with webgl 1 and 2.
  19527. * You will need to pass the name of the uniform as well as the value.
  19528. */
  19529. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19530. /**
  19531. * Lambda to Update a vec3 of float in a uniform buffer.
  19532. * This is dynamic to allow compat with webgl 1 and 2.
  19533. * You will need to pass the name of the uniform as well as the value.
  19534. */
  19535. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19536. /**
  19537. * Lambda to Update a vec4 of float in a uniform buffer.
  19538. * This is dynamic to allow compat with webgl 1 and 2.
  19539. * You will need to pass the name of the uniform as well as the value.
  19540. */
  19541. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19542. /**
  19543. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19544. * This is dynamic to allow compat with webgl 1 and 2.
  19545. * You will need to pass the name of the uniform as well as the value.
  19546. */
  19547. updateMatrix: (name: string, mat: Matrix) => void;
  19548. /**
  19549. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19550. * This is dynamic to allow compat with webgl 1 and 2.
  19551. * You will need to pass the name of the uniform as well as the value.
  19552. */
  19553. updateVector3: (name: string, vector: Vector3) => void;
  19554. /**
  19555. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19556. * This is dynamic to allow compat with webgl 1 and 2.
  19557. * You will need to pass the name of the uniform as well as the value.
  19558. */
  19559. updateVector4: (name: string, vector: Vector4) => void;
  19560. /**
  19561. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19562. * This is dynamic to allow compat with webgl 1 and 2.
  19563. * You will need to pass the name of the uniform as well as the value.
  19564. */
  19565. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19566. /**
  19567. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19568. * This is dynamic to allow compat with webgl 1 and 2.
  19569. * You will need to pass the name of the uniform as well as the value.
  19570. */
  19571. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19572. /**
  19573. * Instantiates a new Uniform buffer objects.
  19574. *
  19575. * Handles blocks of uniform on the GPU.
  19576. *
  19577. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19578. *
  19579. * For more information, please refer to :
  19580. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19581. * @param engine Define the engine the buffer is associated with
  19582. * @param data Define the data contained in the buffer
  19583. * @param dynamic Define if the buffer is updatable
  19584. */
  19585. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19586. /**
  19587. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19588. * or just falling back on setUniformXXX calls.
  19589. */
  19590. readonly useUbo: boolean;
  19591. /**
  19592. * Indicates if the WebGL underlying uniform buffer is in sync
  19593. * with the javascript cache data.
  19594. */
  19595. readonly isSync: boolean;
  19596. /**
  19597. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19598. * Also, a dynamic UniformBuffer will disable cache verification and always
  19599. * update the underlying WebGL uniform buffer to the GPU.
  19600. * @returns if Dynamic, otherwise false
  19601. */
  19602. isDynamic(): boolean;
  19603. /**
  19604. * The data cache on JS side.
  19605. * @returns the underlying data as a float array
  19606. */
  19607. getData(): Float32Array;
  19608. /**
  19609. * The underlying WebGL Uniform buffer.
  19610. * @returns the webgl buffer
  19611. */
  19612. getBuffer(): Nullable<WebGLBuffer>;
  19613. /**
  19614. * std140 layout specifies how to align data within an UBO structure.
  19615. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19616. * for specs.
  19617. */
  19618. private _fillAlignment;
  19619. /**
  19620. * Adds an uniform in the buffer.
  19621. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19622. * for the layout to be correct !
  19623. * @param name Name of the uniform, as used in the uniform block in the shader.
  19624. * @param size Data size, or data directly.
  19625. */
  19626. addUniform(name: string, size: number | number[]): void;
  19627. /**
  19628. * Adds a Matrix 4x4 to the uniform buffer.
  19629. * @param name Name of the uniform, as used in the uniform block in the shader.
  19630. * @param mat A 4x4 matrix.
  19631. */
  19632. addMatrix(name: string, mat: Matrix): void;
  19633. /**
  19634. * Adds a vec2 to the uniform buffer.
  19635. * @param name Name of the uniform, as used in the uniform block in the shader.
  19636. * @param x Define the x component value of the vec2
  19637. * @param y Define the y component value of the vec2
  19638. */
  19639. addFloat2(name: string, x: number, y: number): void;
  19640. /**
  19641. * Adds a vec3 to the uniform buffer.
  19642. * @param name Name of the uniform, as used in the uniform block in the shader.
  19643. * @param x Define the x component value of the vec3
  19644. * @param y Define the y component value of the vec3
  19645. * @param z Define the z component value of the vec3
  19646. */
  19647. addFloat3(name: string, x: number, y: number, z: number): void;
  19648. /**
  19649. * Adds a vec3 to the uniform buffer.
  19650. * @param name Name of the uniform, as used in the uniform block in the shader.
  19651. * @param color Define the vec3 from a Color
  19652. */
  19653. addColor3(name: string, color: Color3): void;
  19654. /**
  19655. * Adds a vec4 to the uniform buffer.
  19656. * @param name Name of the uniform, as used in the uniform block in the shader.
  19657. * @param color Define the rgb components from a Color
  19658. * @param alpha Define the a component of the vec4
  19659. */
  19660. addColor4(name: string, color: Color3, alpha: number): void;
  19661. /**
  19662. * Adds a vec3 to the uniform buffer.
  19663. * @param name Name of the uniform, as used in the uniform block in the shader.
  19664. * @param vector Define the vec3 components from a Vector
  19665. */
  19666. addVector3(name: string, vector: Vector3): void;
  19667. /**
  19668. * Adds a Matrix 3x3 to the uniform buffer.
  19669. * @param name Name of the uniform, as used in the uniform block in the shader.
  19670. */
  19671. addMatrix3x3(name: string): void;
  19672. /**
  19673. * Adds a Matrix 2x2 to the uniform buffer.
  19674. * @param name Name of the uniform, as used in the uniform block in the shader.
  19675. */
  19676. addMatrix2x2(name: string): void;
  19677. /**
  19678. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19679. */
  19680. create(): void;
  19681. /** @hidden */
  19682. _rebuild(): void;
  19683. /**
  19684. * Updates the WebGL Uniform Buffer on the GPU.
  19685. * If the `dynamic` flag is set to true, no cache comparison is done.
  19686. * Otherwise, the buffer will be updated only if the cache differs.
  19687. */
  19688. update(): void;
  19689. /**
  19690. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19691. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19692. * @param data Define the flattened data
  19693. * @param size Define the size of the data.
  19694. */
  19695. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19696. private _updateMatrix3x3ForUniform;
  19697. private _updateMatrix3x3ForEffect;
  19698. private _updateMatrix2x2ForEffect;
  19699. private _updateMatrix2x2ForUniform;
  19700. private _updateFloatForEffect;
  19701. private _updateFloatForUniform;
  19702. private _updateFloat2ForEffect;
  19703. private _updateFloat2ForUniform;
  19704. private _updateFloat3ForEffect;
  19705. private _updateFloat3ForUniform;
  19706. private _updateFloat4ForEffect;
  19707. private _updateFloat4ForUniform;
  19708. private _updateMatrixForEffect;
  19709. private _updateMatrixForUniform;
  19710. private _updateVector3ForEffect;
  19711. private _updateVector3ForUniform;
  19712. private _updateVector4ForEffect;
  19713. private _updateVector4ForUniform;
  19714. private _updateColor3ForEffect;
  19715. private _updateColor3ForUniform;
  19716. private _updateColor4ForEffect;
  19717. private _updateColor4ForUniform;
  19718. /**
  19719. * Sets a sampler uniform on the effect.
  19720. * @param name Define the name of the sampler.
  19721. * @param texture Define the texture to set in the sampler
  19722. */
  19723. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19724. /**
  19725. * Directly updates the value of the uniform in the cache AND on the GPU.
  19726. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19727. * @param data Define the flattened data
  19728. */
  19729. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19730. /**
  19731. * Binds this uniform buffer to an effect.
  19732. * @param effect Define the effect to bind the buffer to
  19733. * @param name Name of the uniform block in the shader.
  19734. */
  19735. bindToEffect(effect: Effect, name: string): void;
  19736. /**
  19737. * Disposes the uniform buffer.
  19738. */
  19739. dispose(): void;
  19740. }
  19741. }
  19742. declare module BABYLON {
  19743. /**
  19744. * Scalar computation library
  19745. */
  19746. class Scalar {
  19747. /**
  19748. * Two pi constants convenient for computation.
  19749. */
  19750. static TwoPi: number;
  19751. /**
  19752. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19753. * @param a number
  19754. * @param b number
  19755. * @param epsilon (default = 1.401298E-45)
  19756. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19757. */
  19758. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19759. /**
  19760. * Returns a string : the upper case translation of the number i to hexadecimal.
  19761. * @param i number
  19762. * @returns the upper case translation of the number i to hexadecimal.
  19763. */
  19764. static ToHex(i: number): string;
  19765. /**
  19766. * Returns -1 if value is negative and +1 is value is positive.
  19767. * @param value the value
  19768. * @returns the value itself if it's equal to zero.
  19769. */
  19770. static Sign(value: number): number;
  19771. /**
  19772. * Returns the value itself if it's between min and max.
  19773. * Returns min if the value is lower than min.
  19774. * Returns max if the value is greater than max.
  19775. * @param value the value to clmap
  19776. * @param min the min value to clamp to (default: 0)
  19777. * @param max the max value to clamp to (default: 1)
  19778. * @returns the clamped value
  19779. */
  19780. static Clamp(value: number, min?: number, max?: number): number;
  19781. /**
  19782. * the log2 of value.
  19783. * @param value the value to compute log2 of
  19784. * @returns the log2 of value.
  19785. */
  19786. static Log2(value: number): number;
  19787. /**
  19788. * Loops the value, so that it is never larger than length and never smaller than 0.
  19789. *
  19790. * This is similar to the modulo operator but it works with floating point numbers.
  19791. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19792. * With t = 5 and length = 2.5, the result would be 0.0.
  19793. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19794. * @param value the value
  19795. * @param length the length
  19796. * @returns the looped value
  19797. */
  19798. static Repeat(value: number, length: number): number;
  19799. /**
  19800. * Normalize the value between 0.0 and 1.0 using min and max values
  19801. * @param value value to normalize
  19802. * @param min max to normalize between
  19803. * @param max min to normalize between
  19804. * @returns the normalized value
  19805. */
  19806. static Normalize(value: number, min: number, max: number): number;
  19807. /**
  19808. * Denormalize the value from 0.0 and 1.0 using min and max values
  19809. * @param normalized value to denormalize
  19810. * @param min max to denormalize between
  19811. * @param max min to denormalize between
  19812. * @returns the denormalized value
  19813. */
  19814. static Denormalize(normalized: number, min: number, max: number): number;
  19815. /**
  19816. * Calculates the shortest difference between two given angles given in degrees.
  19817. * @param current current angle in degrees
  19818. * @param target target angle in degrees
  19819. * @returns the delta
  19820. */
  19821. static DeltaAngle(current: number, target: number): number;
  19822. /**
  19823. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19824. * @param tx value
  19825. * @param length length
  19826. * @returns The returned value will move back and forth between 0 and length
  19827. */
  19828. static PingPong(tx: number, length: number): number;
  19829. /**
  19830. * Interpolates between min and max with smoothing at the limits.
  19831. *
  19832. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19833. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19834. * @param from from
  19835. * @param to to
  19836. * @param tx value
  19837. * @returns the smooth stepped value
  19838. */
  19839. static SmoothStep(from: number, to: number, tx: number): number;
  19840. /**
  19841. * Moves a value current towards target.
  19842. *
  19843. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19844. * Negative values of maxDelta pushes the value away from target.
  19845. * @param current current value
  19846. * @param target target value
  19847. * @param maxDelta max distance to move
  19848. * @returns resulting value
  19849. */
  19850. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19851. /**
  19852. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19853. *
  19854. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19855. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19856. * @param current current value
  19857. * @param target target value
  19858. * @param maxDelta max distance to move
  19859. * @returns resulting angle
  19860. */
  19861. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19862. /**
  19863. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19864. * @param start start value
  19865. * @param end target value
  19866. * @param amount amount to lerp between
  19867. * @returns the lerped value
  19868. */
  19869. static Lerp(start: number, end: number, amount: number): number;
  19870. /**
  19871. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19872. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19873. * @param start start value
  19874. * @param end target value
  19875. * @param amount amount to lerp between
  19876. * @returns the lerped value
  19877. */
  19878. static LerpAngle(start: number, end: number, amount: number): number;
  19879. /**
  19880. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19881. * @param a start value
  19882. * @param b target value
  19883. * @param value value between a and b
  19884. * @returns the inverseLerp value
  19885. */
  19886. static InverseLerp(a: number, b: number, value: number): number;
  19887. /**
  19888. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19889. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19890. * @param value1 spline value
  19891. * @param tangent1 spline value
  19892. * @param value2 spline value
  19893. * @param tangent2 spline value
  19894. * @param amount input value
  19895. * @returns hermite result
  19896. */
  19897. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19898. /**
  19899. * Returns a random float number between and min and max values
  19900. * @param min min value of random
  19901. * @param max max value of random
  19902. * @returns random value
  19903. */
  19904. static RandomRange(min: number, max: number): number;
  19905. /**
  19906. * This function returns percentage of a number in a given range.
  19907. *
  19908. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19909. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19910. * @param number to convert to percentage
  19911. * @param min min range
  19912. * @param max max range
  19913. * @returns the percentage
  19914. */
  19915. static RangeToPercent(number: number, min: number, max: number): number;
  19916. /**
  19917. * This function returns number that corresponds to the percentage in a given range.
  19918. *
  19919. * PercentToRange(0.34,0,100) will return 34.
  19920. * @param percent to convert to number
  19921. * @param min min range
  19922. * @param max max range
  19923. * @returns the number
  19924. */
  19925. static PercentToRange(percent: number, min: number, max: number): number;
  19926. /**
  19927. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19928. * @param angle The angle to normalize in radian.
  19929. * @return The converted angle.
  19930. */
  19931. static NormalizeRadians(angle: number): number;
  19932. }
  19933. }
  19934. declare module BABYLON {
  19935. /**
  19936. * Constant used to convert a value to gamma space
  19937. * @ignorenaming
  19938. */
  19939. const ToGammaSpace: number;
  19940. /**
  19941. * Constant used to convert a value to linear space
  19942. * @ignorenaming
  19943. */
  19944. const ToLinearSpace = 2.2;
  19945. /**
  19946. * Constant used to define the minimal number value in Babylon.js
  19947. * @ignorenaming
  19948. */
  19949. const Epsilon = 0.001;
  19950. /**
  19951. * Class used to hold a RBG color
  19952. */
  19953. class Color3 {
  19954. /**
  19955. * Defines the red component (between 0 and 1, default is 0)
  19956. */
  19957. r: number;
  19958. /**
  19959. * Defines the green component (between 0 and 1, default is 0)
  19960. */
  19961. g: number;
  19962. /**
  19963. * Defines the blue component (between 0 and 1, default is 0)
  19964. */
  19965. b: number;
  19966. /**
  19967. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  19968. * @param r defines the red component (between 0 and 1, default is 0)
  19969. * @param g defines the green component (between 0 and 1, default is 0)
  19970. * @param b defines the blue component (between 0 and 1, default is 0)
  19971. */
  19972. constructor(
  19973. /**
  19974. * Defines the red component (between 0 and 1, default is 0)
  19975. */
  19976. r?: number,
  19977. /**
  19978. * Defines the green component (between 0 and 1, default is 0)
  19979. */
  19980. g?: number,
  19981. /**
  19982. * Defines the blue component (between 0 and 1, default is 0)
  19983. */
  19984. b?: number);
  19985. /**
  19986. * Creates a string with the Color3 current values
  19987. * @returns the string representation of the Color3 object
  19988. */
  19989. toString(): string;
  19990. /**
  19991. * Returns the string "Color3"
  19992. * @returns "Color3"
  19993. */
  19994. getClassName(): string;
  19995. /**
  19996. * Compute the Color3 hash code
  19997. * @returns an unique number that can be used to hash Color3 objects
  19998. */
  19999. getHashCode(): number;
  20000. /**
  20001. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20002. * @param array defines the array where to store the r,g,b components
  20003. * @param index defines an optional index in the target array to define where to start storing values
  20004. * @returns the current Color3 object
  20005. */
  20006. toArray(array: FloatArray, index?: number): Color3;
  20007. /**
  20008. * Returns a new Color4 object from the current Color3 and the given alpha
  20009. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20010. * @returns a new Color4 object
  20011. */
  20012. toColor4(alpha?: number): Color4;
  20013. /**
  20014. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20015. * @returns the new array
  20016. */
  20017. asArray(): number[];
  20018. /**
  20019. * Returns the luminance value
  20020. * @returns a float value
  20021. */
  20022. toLuminance(): number;
  20023. /**
  20024. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20025. * @param otherColor defines the second operand
  20026. * @returns the new Color3 object
  20027. */
  20028. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20029. /**
  20030. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20031. * @param otherColor defines the second operand
  20032. * @param result defines the Color3 object where to store the result
  20033. * @returns the current Color3
  20034. */
  20035. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20036. /**
  20037. * Determines equality between Color3 objects
  20038. * @param otherColor defines the second operand
  20039. * @returns true if the rgb values are equal to the given ones
  20040. */
  20041. equals(otherColor: DeepImmutable<Color3>): boolean;
  20042. /**
  20043. * Determines equality between the current Color3 object and a set of r,b,g values
  20044. * @param r defines the red component to check
  20045. * @param g defines the green component to check
  20046. * @param b defines the blue component to check
  20047. * @returns true if the rgb values are equal to the given ones
  20048. */
  20049. equalsFloats(r: number, g: number, b: number): boolean;
  20050. /**
  20051. * Multiplies in place each rgb value by scale
  20052. * @param scale defines the scaling factor
  20053. * @returns the updated Color3
  20054. */
  20055. scale(scale: number): Color3;
  20056. /**
  20057. * Multiplies the rgb values by scale and stores the result into "result"
  20058. * @param scale defines the scaling factor
  20059. * @param result defines the Color3 object where to store the result
  20060. * @returns the unmodified current Color3
  20061. */
  20062. scaleToRef(scale: number, result: Color3): Color3;
  20063. /**
  20064. * Scale the current Color3 values by a factor and add the result to a given Color3
  20065. * @param scale defines the scale factor
  20066. * @param result defines color to store the result into
  20067. * @returns the unmodified current Color3
  20068. */
  20069. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20070. /**
  20071. * Clamps the rgb values by the min and max values and stores the result into "result"
  20072. * @param min defines minimum clamping value (default is 0)
  20073. * @param max defines maximum clamping value (default is 1)
  20074. * @param result defines color to store the result into
  20075. * @returns the original Color3
  20076. */
  20077. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20078. /**
  20079. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20080. * @param otherColor defines the second operand
  20081. * @returns the new Color3
  20082. */
  20083. add(otherColor: DeepImmutable<Color3>): Color3;
  20084. /**
  20085. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20086. * @param otherColor defines the second operand
  20087. * @param result defines Color3 object to store the result into
  20088. * @returns the unmodified current Color3
  20089. */
  20090. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20091. /**
  20092. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20093. * @param otherColor defines the second operand
  20094. * @returns the new Color3
  20095. */
  20096. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20097. /**
  20098. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20099. * @param otherColor defines the second operand
  20100. * @param result defines Color3 object to store the result into
  20101. * @returns the unmodified current Color3
  20102. */
  20103. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20104. /**
  20105. * Copy the current object
  20106. * @returns a new Color3 copied the current one
  20107. */
  20108. clone(): Color3;
  20109. /**
  20110. * Copies the rgb values from the source in the current Color3
  20111. * @param source defines the source Color3 object
  20112. * @returns the updated Color3 object
  20113. */
  20114. copyFrom(source: DeepImmutable<Color3>): Color3;
  20115. /**
  20116. * Updates the Color3 rgb values from the given floats
  20117. * @param r defines the red component to read from
  20118. * @param g defines the green component to read from
  20119. * @param b defines the blue component to read from
  20120. * @returns the current Color3 object
  20121. */
  20122. copyFromFloats(r: number, g: number, b: number): Color3;
  20123. /**
  20124. * Updates the Color3 rgb values from the given floats
  20125. * @param r defines the red component to read from
  20126. * @param g defines the green component to read from
  20127. * @param b defines the blue component to read from
  20128. * @returns the current Color3 object
  20129. */
  20130. set(r: number, g: number, b: number): Color3;
  20131. /**
  20132. * Compute the Color3 hexadecimal code as a string
  20133. * @returns a string containing the hexadecimal representation of the Color3 object
  20134. */
  20135. toHexString(): string;
  20136. /**
  20137. * Computes a new Color3 converted from the current one to linear space
  20138. * @returns a new Color3 object
  20139. */
  20140. toLinearSpace(): Color3;
  20141. /**
  20142. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20143. * @param convertedColor defines the Color3 object where to store the linear space version
  20144. * @returns the unmodified Color3
  20145. */
  20146. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20147. /**
  20148. * Computes a new Color3 converted from the current one to gamma space
  20149. * @returns a new Color3 object
  20150. */
  20151. toGammaSpace(): Color3;
  20152. /**
  20153. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20154. * @param convertedColor defines the Color3 object where to store the gamma space version
  20155. * @returns the unmodified Color3
  20156. */
  20157. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20158. private static _BlackReadOnly;
  20159. /**
  20160. * Creates a new Color3 from the string containing valid hexadecimal values
  20161. * @param hex defines a string containing valid hexadecimal values
  20162. * @returns a new Color3 object
  20163. */
  20164. static FromHexString(hex: string): Color3;
  20165. /**
  20166. * Creates a new Vector3 from the starting index of the given array
  20167. * @param array defines the source array
  20168. * @param offset defines an offset in the source array
  20169. * @returns a new Color3 object
  20170. */
  20171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20172. /**
  20173. * Creates a new Color3 from integer values (< 256)
  20174. * @param r defines the red component to read from (value between 0 and 255)
  20175. * @param g defines the green component to read from (value between 0 and 255)
  20176. * @param b defines the blue component to read from (value between 0 and 255)
  20177. * @returns a new Color3 object
  20178. */
  20179. static FromInts(r: number, g: number, b: number): Color3;
  20180. /**
  20181. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20182. * @param start defines the start Color3 value
  20183. * @param end defines the end Color3 value
  20184. * @param amount defines the gradient value between start and end
  20185. * @returns a new Color3 object
  20186. */
  20187. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20188. /**
  20189. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20190. * @param left defines the start value
  20191. * @param right defines the end value
  20192. * @param amount defines the gradient factor
  20193. * @param result defines the Color3 object where to store the result
  20194. */
  20195. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20196. /**
  20197. * Returns a Color3 value containing a red color
  20198. * @returns a new Color3 object
  20199. */
  20200. static Red(): Color3;
  20201. /**
  20202. * Returns a Color3 value containing a green color
  20203. * @returns a new Color3 object
  20204. */
  20205. static Green(): Color3;
  20206. /**
  20207. * Returns a Color3 value containing a blue color
  20208. * @returns a new Color3 object
  20209. */
  20210. static Blue(): Color3;
  20211. /**
  20212. * Returns a Color3 value containing a black color
  20213. * @returns a new Color3 object
  20214. */
  20215. static Black(): Color3;
  20216. /**
  20217. * Gets a Color3 value containing a black color that must not be updated
  20218. */
  20219. static readonly BlackReadOnly: DeepImmutable<Color3>;
  20220. /**
  20221. * Returns a Color3 value containing a white color
  20222. * @returns a new Color3 object
  20223. */
  20224. static White(): Color3;
  20225. /**
  20226. * Returns a Color3 value containing a purple color
  20227. * @returns a new Color3 object
  20228. */
  20229. static Purple(): Color3;
  20230. /**
  20231. * Returns a Color3 value containing a magenta color
  20232. * @returns a new Color3 object
  20233. */
  20234. static Magenta(): Color3;
  20235. /**
  20236. * Returns a Color3 value containing a yellow color
  20237. * @returns a new Color3 object
  20238. */
  20239. static Yellow(): Color3;
  20240. /**
  20241. * Returns a Color3 value containing a gray color
  20242. * @returns a new Color3 object
  20243. */
  20244. static Gray(): Color3;
  20245. /**
  20246. * Returns a Color3 value containing a teal color
  20247. * @returns a new Color3 object
  20248. */
  20249. static Teal(): Color3;
  20250. /**
  20251. * Returns a Color3 value containing a random color
  20252. * @returns a new Color3 object
  20253. */
  20254. static Random(): Color3;
  20255. }
  20256. /**
  20257. * Class used to hold a RBGA color
  20258. */
  20259. class Color4 {
  20260. /**
  20261. * Defines the red component (between 0 and 1, default is 0)
  20262. */
  20263. r: number;
  20264. /**
  20265. * Defines the green component (between 0 and 1, default is 0)
  20266. */
  20267. g: number;
  20268. /**
  20269. * Defines the blue component (between 0 and 1, default is 0)
  20270. */
  20271. b: number;
  20272. /**
  20273. * Defines the alpha component (between 0 and 1, default is 1)
  20274. */
  20275. a: number;
  20276. /**
  20277. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20278. * @param r defines the red component (between 0 and 1, default is 0)
  20279. * @param g defines the green component (between 0 and 1, default is 0)
  20280. * @param b defines the blue component (between 0 and 1, default is 0)
  20281. * @param a defines the alpha component (between 0 and 1, default is 1)
  20282. */
  20283. constructor(
  20284. /**
  20285. * Defines the red component (between 0 and 1, default is 0)
  20286. */
  20287. r?: number,
  20288. /**
  20289. * Defines the green component (between 0 and 1, default is 0)
  20290. */
  20291. g?: number,
  20292. /**
  20293. * Defines the blue component (between 0 and 1, default is 0)
  20294. */
  20295. b?: number,
  20296. /**
  20297. * Defines the alpha component (between 0 and 1, default is 1)
  20298. */
  20299. a?: number);
  20300. /**
  20301. * Adds in place the given Color4 values to the current Color4 object
  20302. * @param right defines the second operand
  20303. * @returns the current updated Color4 object
  20304. */
  20305. addInPlace(right: DeepImmutable<Color4>): Color4;
  20306. /**
  20307. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20308. * @returns the new array
  20309. */
  20310. asArray(): number[];
  20311. /**
  20312. * Stores from the starting index in the given array the Color4 successive values
  20313. * @param array defines the array where to store the r,g,b components
  20314. * @param index defines an optional index in the target array to define where to start storing values
  20315. * @returns the current Color4 object
  20316. */
  20317. toArray(array: number[], index?: number): Color4;
  20318. /**
  20319. * Determines equality between Color4 objects
  20320. * @param otherColor defines the second operand
  20321. * @returns true if the rgba values are equal to the given ones
  20322. */
  20323. equals(otherColor: DeepImmutable<Color4>): boolean;
  20324. /**
  20325. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20326. * @param right defines the second operand
  20327. * @returns a new Color4 object
  20328. */
  20329. add(right: DeepImmutable<Color4>): Color4;
  20330. /**
  20331. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20332. * @param right defines the second operand
  20333. * @returns a new Color4 object
  20334. */
  20335. subtract(right: DeepImmutable<Color4>): Color4;
  20336. /**
  20337. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20338. * @param right defines the second operand
  20339. * @param result defines the Color4 object where to store the result
  20340. * @returns the current Color4 object
  20341. */
  20342. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20343. /**
  20344. * Creates a new Color4 with the current Color4 values multiplied by scale
  20345. * @param scale defines the scaling factor to apply
  20346. * @returns a new Color4 object
  20347. */
  20348. scale(scale: number): Color4;
  20349. /**
  20350. * Multiplies the current Color4 values by scale and stores the result in "result"
  20351. * @param scale defines the scaling factor to apply
  20352. * @param result defines the Color4 object where to store the result
  20353. * @returns the current unmodified Color4
  20354. */
  20355. scaleToRef(scale: number, result: Color4): Color4;
  20356. /**
  20357. * Scale the current Color4 values by a factor and add the result to a given Color4
  20358. * @param scale defines the scale factor
  20359. * @param result defines the Color4 object where to store the result
  20360. * @returns the unmodified current Color4
  20361. */
  20362. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20363. /**
  20364. * Clamps the rgb values by the min and max values and stores the result into "result"
  20365. * @param min defines minimum clamping value (default is 0)
  20366. * @param max defines maximum clamping value (default is 1)
  20367. * @param result defines color to store the result into.
  20368. * @returns the cuurent Color4
  20369. */
  20370. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20371. /**
  20372. * Multipy an Color4 value by another and return a new Color4 object
  20373. * @param color defines the Color4 value to multiply by
  20374. * @returns a new Color4 object
  20375. */
  20376. multiply(color: Color4): Color4;
  20377. /**
  20378. * Multipy a Color4 value by another and push the result in a reference value
  20379. * @param color defines the Color4 value to multiply by
  20380. * @param result defines the Color4 to fill the result in
  20381. * @returns the result Color4
  20382. */
  20383. multiplyToRef(color: Color4, result: Color4): Color4;
  20384. /**
  20385. * Creates a string with the Color4 current values
  20386. * @returns the string representation of the Color4 object
  20387. */
  20388. toString(): string;
  20389. /**
  20390. * Returns the string "Color4"
  20391. * @returns "Color4"
  20392. */
  20393. getClassName(): string;
  20394. /**
  20395. * Compute the Color4 hash code
  20396. * @returns an unique number that can be used to hash Color4 objects
  20397. */
  20398. getHashCode(): number;
  20399. /**
  20400. * Creates a new Color4 copied from the current one
  20401. * @returns a new Color4 object
  20402. */
  20403. clone(): Color4;
  20404. /**
  20405. * Copies the given Color4 values into the current one
  20406. * @param source defines the source Color4 object
  20407. * @returns the current updated Color4 object
  20408. */
  20409. copyFrom(source: Color4): Color4;
  20410. /**
  20411. * Copies the given float values into the current one
  20412. * @param r defines the red component to read from
  20413. * @param g defines the green component to read from
  20414. * @param b defines the blue component to read from
  20415. * @param a defines the alpha component to read from
  20416. * @returns the current updated Color4 object
  20417. */
  20418. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20419. /**
  20420. * Copies the given float values into the current one
  20421. * @param r defines the red component to read from
  20422. * @param g defines the green component to read from
  20423. * @param b defines the blue component to read from
  20424. * @param a defines the alpha component to read from
  20425. * @returns the current updated Color4 object
  20426. */
  20427. set(r: number, g: number, b: number, a: number): Color4;
  20428. /**
  20429. * Compute the Color4 hexadecimal code as a string
  20430. * @returns a string containing the hexadecimal representation of the Color4 object
  20431. */
  20432. toHexString(): string;
  20433. /**
  20434. * Computes a new Color4 converted from the current one to linear space
  20435. * @returns a new Color4 object
  20436. */
  20437. toLinearSpace(): Color4;
  20438. /**
  20439. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20440. * @param convertedColor defines the Color4 object where to store the linear space version
  20441. * @returns the unmodified Color4
  20442. */
  20443. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20444. /**
  20445. * Computes a new Color4 converted from the current one to gamma space
  20446. * @returns a new Color4 object
  20447. */
  20448. toGammaSpace(): Color4;
  20449. /**
  20450. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20451. * @param convertedColor defines the Color4 object where to store the gamma space version
  20452. * @returns the unmodified Color4
  20453. */
  20454. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20455. /**
  20456. * Creates a new Color4 from the string containing valid hexadecimal values
  20457. * @param hex defines a string containing valid hexadecimal values
  20458. * @returns a new Color4 object
  20459. */
  20460. static FromHexString(hex: string): Color4;
  20461. /**
  20462. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20463. * @param left defines the start value
  20464. * @param right defines the end value
  20465. * @param amount defines the gradient factor
  20466. * @returns a new Color4 object
  20467. */
  20468. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20469. /**
  20470. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20471. * @param left defines the start value
  20472. * @param right defines the end value
  20473. * @param amount defines the gradient factor
  20474. * @param result defines the Color4 object where to store data
  20475. */
  20476. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20477. /**
  20478. * Creates a new Color4 from a Color3 and an alpha value
  20479. * @param color3 defines the source Color3 to read from
  20480. * @param alpha defines the alpha component (1.0 by default)
  20481. * @returns a new Color4 object
  20482. */
  20483. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20484. /**
  20485. * Creates a new Color4 from the starting index element of the given array
  20486. * @param array defines the source array to read from
  20487. * @param offset defines the offset in the source array
  20488. * @returns a new Color4 object
  20489. */
  20490. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20491. /**
  20492. * Creates a new Color3 from integer values (< 256)
  20493. * @param r defines the red component to read from (value between 0 and 255)
  20494. * @param g defines the green component to read from (value between 0 and 255)
  20495. * @param b defines the blue component to read from (value between 0 and 255)
  20496. * @param a defines the alpha component to read from (value between 0 and 255)
  20497. * @returns a new Color3 object
  20498. */
  20499. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20500. /**
  20501. * Check the content of a given array and convert it to an array containing RGBA data
  20502. * If the original array was already containing count * 4 values then it is returned directly
  20503. * @param colors defines the array to check
  20504. * @param count defines the number of RGBA data to expect
  20505. * @returns an array containing count * 4 values (RGBA)
  20506. */
  20507. static CheckColors4(colors: number[], count: number): number[];
  20508. }
  20509. /**
  20510. * Class representing a vector containing 2 coordinates
  20511. */
  20512. class Vector2 {
  20513. /** defines the first coordinate */
  20514. x: number;
  20515. /** defines the second coordinate */
  20516. y: number;
  20517. /**
  20518. * Creates a new Vector2 from the given x and y coordinates
  20519. * @param x defines the first coordinate
  20520. * @param y defines the second coordinate
  20521. */
  20522. constructor(
  20523. /** defines the first coordinate */
  20524. x?: number,
  20525. /** defines the second coordinate */
  20526. y?: number);
  20527. /**
  20528. * Gets a string with the Vector2 coordinates
  20529. * @returns a string with the Vector2 coordinates
  20530. */
  20531. toString(): string;
  20532. /**
  20533. * Gets class name
  20534. * @returns the string "Vector2"
  20535. */
  20536. getClassName(): string;
  20537. /**
  20538. * Gets current vector hash code
  20539. * @returns the Vector2 hash code as a number
  20540. */
  20541. getHashCode(): number;
  20542. /**
  20543. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20544. * @param array defines the source array
  20545. * @param index defines the offset in source array
  20546. * @returns the current Vector2
  20547. */
  20548. toArray(array: FloatArray, index?: number): Vector2;
  20549. /**
  20550. * Copy the current vector to an array
  20551. * @returns a new array with 2 elements: the Vector2 coordinates.
  20552. */
  20553. asArray(): number[];
  20554. /**
  20555. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20556. * @param source defines the source Vector2
  20557. * @returns the current updated Vector2
  20558. */
  20559. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20560. /**
  20561. * Sets the Vector2 coordinates with the given floats
  20562. * @param x defines the first coordinate
  20563. * @param y defines the second coordinate
  20564. * @returns the current updated Vector2
  20565. */
  20566. copyFromFloats(x: number, y: number): Vector2;
  20567. /**
  20568. * Sets the Vector2 coordinates with the given floats
  20569. * @param x defines the first coordinate
  20570. * @param y defines the second coordinate
  20571. * @returns the current updated Vector2
  20572. */
  20573. set(x: number, y: number): Vector2;
  20574. /**
  20575. * Add another vector with the current one
  20576. * @param otherVector defines the other vector
  20577. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20578. */
  20579. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20580. /**
  20581. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20582. * @param otherVector defines the other vector
  20583. * @param result defines the target vector
  20584. * @returns the unmodified current Vector2
  20585. */
  20586. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20587. /**
  20588. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20589. * @param otherVector defines the other vector
  20590. * @returns the current updated Vector2
  20591. */
  20592. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20593. /**
  20594. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20595. * @param otherVector defines the other vector
  20596. * @returns a new Vector2
  20597. */
  20598. addVector3(otherVector: Vector3): Vector2;
  20599. /**
  20600. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20601. * @param otherVector defines the other vector
  20602. * @returns a new Vector2
  20603. */
  20604. subtract(otherVector: Vector2): Vector2;
  20605. /**
  20606. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20607. * @param otherVector defines the other vector
  20608. * @param result defines the target vector
  20609. * @returns the unmodified current Vector2
  20610. */
  20611. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20612. /**
  20613. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20614. * @param otherVector defines the other vector
  20615. * @returns the current updated Vector2
  20616. */
  20617. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20618. /**
  20619. * Multiplies in place the current Vector2 coordinates by the given ones
  20620. * @param otherVector defines the other vector
  20621. * @returns the current updated Vector2
  20622. */
  20623. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20624. /**
  20625. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20626. * @param otherVector defines the other vector
  20627. * @returns a new Vector2
  20628. */
  20629. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20630. /**
  20631. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20632. * @param otherVector defines the other vector
  20633. * @param result defines the target vector
  20634. * @returns the unmodified current Vector2
  20635. */
  20636. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20637. /**
  20638. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20639. * @param x defines the first coordinate
  20640. * @param y defines the second coordinate
  20641. * @returns a new Vector2
  20642. */
  20643. multiplyByFloats(x: number, y: number): Vector2;
  20644. /**
  20645. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20646. * @param otherVector defines the other vector
  20647. * @returns a new Vector2
  20648. */
  20649. divide(otherVector: Vector2): Vector2;
  20650. /**
  20651. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20652. * @param otherVector defines the other vector
  20653. * @param result defines the target vector
  20654. * @returns the unmodified current Vector2
  20655. */
  20656. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20657. /**
  20658. * Divides the current Vector2 coordinates by the given ones
  20659. * @param otherVector defines the other vector
  20660. * @returns the current updated Vector2
  20661. */
  20662. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20663. /**
  20664. * Gets a new Vector2 with current Vector2 negated coordinates
  20665. * @returns a new Vector2
  20666. */
  20667. negate(): Vector2;
  20668. /**
  20669. * Multiply the Vector2 coordinates by scale
  20670. * @param scale defines the scaling factor
  20671. * @returns the current updated Vector2
  20672. */
  20673. scaleInPlace(scale: number): Vector2;
  20674. /**
  20675. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20676. * @param scale defines the scaling factor
  20677. * @returns a new Vector2
  20678. */
  20679. scale(scale: number): Vector2;
  20680. /**
  20681. * Scale the current Vector2 values by a factor to a given Vector2
  20682. * @param scale defines the scale factor
  20683. * @param result defines the Vector2 object where to store the result
  20684. * @returns the unmodified current Vector2
  20685. */
  20686. scaleToRef(scale: number, result: Vector2): Vector2;
  20687. /**
  20688. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20689. * @param scale defines the scale factor
  20690. * @param result defines the Vector2 object where to store the result
  20691. * @returns the unmodified current Vector2
  20692. */
  20693. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20694. /**
  20695. * Gets a boolean if two vectors are equals
  20696. * @param otherVector defines the other vector
  20697. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20698. */
  20699. equals(otherVector: DeepImmutable<Vector2>): boolean;
  20700. /**
  20701. * Gets a boolean if two vectors are equals (using an epsilon value)
  20702. * @param otherVector defines the other vector
  20703. * @param epsilon defines the minimal distance to consider equality
  20704. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20705. */
  20706. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  20707. /**
  20708. * Gets a new Vector2 from current Vector2 floored values
  20709. * @returns a new Vector2
  20710. */
  20711. floor(): Vector2;
  20712. /**
  20713. * Gets a new Vector2 from current Vector2 floored values
  20714. * @returns a new Vector2
  20715. */
  20716. fract(): Vector2;
  20717. /**
  20718. * Gets the length of the vector
  20719. * @returns the vector length (float)
  20720. */
  20721. length(): number;
  20722. /**
  20723. * Gets the vector squared length
  20724. * @returns the vector squared length (float)
  20725. */
  20726. lengthSquared(): number;
  20727. /**
  20728. * Normalize the vector
  20729. * @returns the current updated Vector2
  20730. */
  20731. normalize(): Vector2;
  20732. /**
  20733. * Gets a new Vector2 copied from the Vector2
  20734. * @returns a new Vector2
  20735. */
  20736. clone(): Vector2;
  20737. /**
  20738. * Gets a new Vector2(0, 0)
  20739. * @returns a new Vector2
  20740. */
  20741. static Zero(): Vector2;
  20742. /**
  20743. * Gets a new Vector2(1, 1)
  20744. * @returns a new Vector2
  20745. */
  20746. static One(): Vector2;
  20747. /**
  20748. * Gets a new Vector2 set from the given index element of the given array
  20749. * @param array defines the data source
  20750. * @param offset defines the offset in the data source
  20751. * @returns a new Vector2
  20752. */
  20753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  20754. /**
  20755. * Sets "result" from the given index element of the given array
  20756. * @param array defines the data source
  20757. * @param offset defines the offset in the data source
  20758. * @param result defines the target vector
  20759. */
  20760. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  20761. /**
  20762. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20763. * @param value1 defines 1st point of control
  20764. * @param value2 defines 2nd point of control
  20765. * @param value3 defines 3rd point of control
  20766. * @param value4 defines 4th point of control
  20767. * @param amount defines the interpolation factor
  20768. * @returns a new Vector2
  20769. */
  20770. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  20771. /**
  20772. * 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".
  20773. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20774. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20775. * @param value defines the value to clamp
  20776. * @param min defines the lower limit
  20777. * @param max defines the upper limit
  20778. * @returns a new Vector2
  20779. */
  20780. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  20781. /**
  20782. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20783. * @param value1 defines the 1st control point
  20784. * @param tangent1 defines the outgoing tangent
  20785. * @param value2 defines the 2nd control point
  20786. * @param tangent2 defines the incoming tangent
  20787. * @param amount defines the interpolation factor
  20788. * @returns a new Vector2
  20789. */
  20790. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  20791. /**
  20792. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20793. * @param start defines the start vector
  20794. * @param end defines the end vector
  20795. * @param amount defines the interpolation factor
  20796. * @returns a new Vector2
  20797. */
  20798. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  20799. /**
  20800. * Gets the dot product of the vector "left" and the vector "right"
  20801. * @param left defines first vector
  20802. * @param right defines second vector
  20803. * @returns the dot product (float)
  20804. */
  20805. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  20806. /**
  20807. * Returns a new Vector2 equal to the normalized given vector
  20808. * @param vector defines the vector to normalize
  20809. * @returns a new Vector2
  20810. */
  20811. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  20812. /**
  20813. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20814. * @param left defines 1st vector
  20815. * @param right defines 2nd vector
  20816. * @returns a new Vector2
  20817. */
  20818. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  20819. /**
  20820. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20821. * @param left defines 1st vector
  20822. * @param right defines 2nd vector
  20823. * @returns a new Vector2
  20824. */
  20825. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  20826. /**
  20827. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20828. * @param vector defines the vector to transform
  20829. * @param transformation defines the matrix to apply
  20830. * @returns a new Vector2
  20831. */
  20832. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  20833. /**
  20834. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20835. * @param vector defines the vector to transform
  20836. * @param transformation defines the matrix to apply
  20837. * @param result defines the target vector
  20838. */
  20839. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  20840. /**
  20841. * Determines if a given vector is included in a triangle
  20842. * @param p defines the vector to test
  20843. * @param p0 defines 1st triangle point
  20844. * @param p1 defines 2nd triangle point
  20845. * @param p2 defines 3rd triangle point
  20846. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20847. */
  20848. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  20849. /**
  20850. * Gets the distance between the vectors "value1" and "value2"
  20851. * @param value1 defines first vector
  20852. * @param value2 defines second vector
  20853. * @returns the distance between vectors
  20854. */
  20855. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  20856. /**
  20857. * Returns the squared distance between the vectors "value1" and "value2"
  20858. * @param value1 defines first vector
  20859. * @param value2 defines second vector
  20860. * @returns the squared distance between vectors
  20861. */
  20862. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  20863. /**
  20864. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20865. * @param value1 defines first vector
  20866. * @param value2 defines second vector
  20867. * @returns a new Vector2
  20868. */
  20869. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  20870. /**
  20871. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20872. * @param p defines the middle point
  20873. * @param segA defines one point of the segment
  20874. * @param segB defines the other point of the segment
  20875. * @returns the shortest distance
  20876. */
  20877. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  20878. }
  20879. /**
  20880. * Classed used to store (x,y,z) vector representation
  20881. * A Vector3 is the main object used in 3D geometry
  20882. * It can represent etiher the coordinates of a point the space, either a direction
  20883. * Reminder: Babylon.js uses a left handed forward facing system
  20884. */
  20885. class Vector3 {
  20886. /**
  20887. * Defines the first coordinates (on X axis)
  20888. */
  20889. x: number;
  20890. /**
  20891. * Defines the second coordinates (on Y axis)
  20892. */
  20893. y: number;
  20894. /**
  20895. * Defines the third coordinates (on Z axis)
  20896. */
  20897. z: number;
  20898. private static _UpReadOnly;
  20899. /**
  20900. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20901. * @param x defines the first coordinates (on X axis)
  20902. * @param y defines the second coordinates (on Y axis)
  20903. * @param z defines the third coordinates (on Z axis)
  20904. */
  20905. constructor(
  20906. /**
  20907. * Defines the first coordinates (on X axis)
  20908. */
  20909. x?: number,
  20910. /**
  20911. * Defines the second coordinates (on Y axis)
  20912. */
  20913. y?: number,
  20914. /**
  20915. * Defines the third coordinates (on Z axis)
  20916. */
  20917. z?: number);
  20918. /**
  20919. * Creates a string representation of the Vector3
  20920. * @returns a string with the Vector3 coordinates.
  20921. */
  20922. toString(): string;
  20923. /**
  20924. * Gets the class name
  20925. * @returns the string "Vector3"
  20926. */
  20927. getClassName(): string;
  20928. /**
  20929. * Creates the Vector3 hash code
  20930. * @returns a number which tends to be unique between Vector3 instances
  20931. */
  20932. getHashCode(): number;
  20933. /**
  20934. * Creates an array containing three elements : the coordinates of the Vector3
  20935. * @returns a new array of numbers
  20936. */
  20937. asArray(): number[];
  20938. /**
  20939. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20940. * @param array defines the destination array
  20941. * @param index defines the offset in the destination array
  20942. * @returns the current Vector3
  20943. */
  20944. toArray(array: FloatArray, index?: number): Vector3;
  20945. /**
  20946. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20947. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20948. */
  20949. toQuaternion(): Quaternion;
  20950. /**
  20951. * Adds the given vector to the current Vector3
  20952. * @param otherVector defines the second operand
  20953. * @returns the current updated Vector3
  20954. */
  20955. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  20956. /**
  20957. * Adds the given coordinates to the current Vector3
  20958. * @param x defines the x coordinate of the operand
  20959. * @param y defines the y coordinate of the operand
  20960. * @param z defines the z coordinate of the operand
  20961. * @returns the current updated Vector3
  20962. */
  20963. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20964. /**
  20965. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20966. * @param otherVector defines the second operand
  20967. * @returns the resulting Vector3
  20968. */
  20969. add(otherVector: DeepImmutable<Vector3>): Vector3;
  20970. /**
  20971. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20972. * @param otherVector defines the second operand
  20973. * @param result defines the Vector3 object where to store the result
  20974. * @returns the current Vector3
  20975. */
  20976. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  20977. /**
  20978. * Subtract the given vector from the current Vector3
  20979. * @param otherVector defines the second operand
  20980. * @returns the current updated Vector3
  20981. */
  20982. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  20983. /**
  20984. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20985. * @param otherVector defines the second operand
  20986. * @returns the resulting Vector3
  20987. */
  20988. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  20989. /**
  20990. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20991. * @param otherVector defines the second operand
  20992. * @param result defines the Vector3 object where to store the result
  20993. * @returns the current Vector3
  20994. */
  20995. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  20996. /**
  20997. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20998. * @param x defines the x coordinate of the operand
  20999. * @param y defines the y coordinate of the operand
  21000. * @param z defines the z coordinate of the operand
  21001. * @returns the resulting Vector3
  21002. */
  21003. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21004. /**
  21005. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21006. * @param x defines the x coordinate of the operand
  21007. * @param y defines the y coordinate of the operand
  21008. * @param z defines the z coordinate of the operand
  21009. * @param result defines the Vector3 object where to store the result
  21010. * @returns the current Vector3
  21011. */
  21012. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21013. /**
  21014. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21015. * @returns a new Vector3
  21016. */
  21017. negate(): Vector3;
  21018. /**
  21019. * Multiplies the Vector3 coordinates by the float "scale"
  21020. * @param scale defines the multiplier factor
  21021. * @returns the current updated Vector3
  21022. */
  21023. scaleInPlace(scale: number): Vector3;
  21024. /**
  21025. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21026. * @param scale defines the multiplier factor
  21027. * @returns a new Vector3
  21028. */
  21029. scale(scale: number): Vector3;
  21030. /**
  21031. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21032. * @param scale defines the multiplier factor
  21033. * @param result defines the Vector3 object where to store the result
  21034. * @returns the current Vector3
  21035. */
  21036. scaleToRef(scale: number, result: Vector3): Vector3;
  21037. /**
  21038. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21039. * @param scale defines the scale factor
  21040. * @param result defines the Vector3 object where to store the result
  21041. * @returns the unmodified current Vector3
  21042. */
  21043. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21044. /**
  21045. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21046. * @param otherVector defines the second operand
  21047. * @returns true if both vectors are equals
  21048. */
  21049. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21050. /**
  21051. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21052. * @param otherVector defines the second operand
  21053. * @param epsilon defines the minimal distance to define values as equals
  21054. * @returns true if both vectors are distant less than epsilon
  21055. */
  21056. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21057. /**
  21058. * Returns true if the current Vector3 coordinates equals the given floats
  21059. * @param x defines the x coordinate of the operand
  21060. * @param y defines the y coordinate of the operand
  21061. * @param z defines the z coordinate of the operand
  21062. * @returns true if both vectors are equals
  21063. */
  21064. equalsToFloats(x: number, y: number, z: number): boolean;
  21065. /**
  21066. * Multiplies the current Vector3 coordinates by the given ones
  21067. * @param otherVector defines the second operand
  21068. * @returns the current updated Vector3
  21069. */
  21070. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21071. /**
  21072. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21073. * @param otherVector defines the second operand
  21074. * @returns the new Vector3
  21075. */
  21076. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21077. /**
  21078. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21079. * @param otherVector defines the second operand
  21080. * @param result defines the Vector3 object where to store the result
  21081. * @returns the current Vector3
  21082. */
  21083. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21084. /**
  21085. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21086. * @param x defines the x coordinate of the operand
  21087. * @param y defines the y coordinate of the operand
  21088. * @param z defines the z coordinate of the operand
  21089. * @returns the new Vector3
  21090. */
  21091. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21092. /**
  21093. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21094. * @param otherVector defines the second operand
  21095. * @returns the new Vector3
  21096. */
  21097. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21098. /**
  21099. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21100. * @param otherVector defines the second operand
  21101. * @param result defines the Vector3 object where to store the result
  21102. * @returns the current Vector3
  21103. */
  21104. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21105. /**
  21106. * Divides the current Vector3 coordinates by the given ones.
  21107. * @param otherVector defines the second operand
  21108. * @returns the current updated Vector3
  21109. */
  21110. divideInPlace(otherVector: Vector3): Vector3;
  21111. /**
  21112. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21113. * @param other defines the second operand
  21114. * @returns the current updated Vector3
  21115. */
  21116. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21117. /**
  21118. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21119. * @param other defines the second operand
  21120. * @returns the current updated Vector3
  21121. */
  21122. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21123. /**
  21124. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21125. * @param x defines the x coordinate of the operand
  21126. * @param y defines the y coordinate of the operand
  21127. * @param z defines the z coordinate of the operand
  21128. * @returns the current updated Vector3
  21129. */
  21130. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21131. /**
  21132. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21133. * @param x defines the x coordinate of the operand
  21134. * @param y defines the y coordinate of the operand
  21135. * @param z defines the z coordinate of the operand
  21136. * @returns the current updated Vector3
  21137. */
  21138. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21139. /**
  21140. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21141. */
  21142. readonly isNonUniform: boolean;
  21143. /**
  21144. * Gets a new Vector3 from current Vector3 floored values
  21145. * @returns a new Vector3
  21146. */
  21147. floor(): Vector3;
  21148. /**
  21149. * Gets a new Vector3 from current Vector3 floored values
  21150. * @returns a new Vector3
  21151. */
  21152. fract(): Vector3;
  21153. /**
  21154. * Gets the length of the Vector3
  21155. * @returns the length of the Vecto3
  21156. */
  21157. length(): number;
  21158. /**
  21159. * Gets the squared length of the Vector3
  21160. * @returns squared length of the Vector3
  21161. */
  21162. lengthSquared(): number;
  21163. /**
  21164. * Normalize the current Vector3.
  21165. * Please note that this is an in place operation.
  21166. * @returns the current updated Vector3
  21167. */
  21168. normalize(): Vector3;
  21169. /**
  21170. * Reorders the x y z properties of the vector in place
  21171. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21172. * @returns the current updated vector
  21173. */
  21174. reorderInPlace(order: string): this;
  21175. /**
  21176. * Rotates the vector around 0,0,0 by a quaternion
  21177. * @param quaternion the rotation quaternion
  21178. * @param result vector to store the result
  21179. * @returns the resulting vector
  21180. */
  21181. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21182. /**
  21183. * Rotates a vector around a given point
  21184. * @param quaternion the rotation quaternion
  21185. * @param point the point to rotate around
  21186. * @param result vector to store the result
  21187. * @returns the resulting vector
  21188. */
  21189. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21190. /**
  21191. * Normalize the current Vector3 with the given input length.
  21192. * Please note that this is an in place operation.
  21193. * @param len the length of the vector
  21194. * @returns the current updated Vector3
  21195. */
  21196. normalizeFromLength(len: number): Vector3;
  21197. /**
  21198. * Normalize the current Vector3 to a new vector
  21199. * @returns the new Vector3
  21200. */
  21201. normalizeToNew(): Vector3;
  21202. /**
  21203. * Normalize the current Vector3 to the reference
  21204. * @param reference define the Vector3 to update
  21205. * @returns the updated Vector3
  21206. */
  21207. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21208. /**
  21209. * Creates a new Vector3 copied from the current Vector3
  21210. * @returns the new Vector3
  21211. */
  21212. clone(): Vector3;
  21213. /**
  21214. * Copies the given vector coordinates to the current Vector3 ones
  21215. * @param source defines the source Vector3
  21216. * @returns the current updated Vector3
  21217. */
  21218. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21219. /**
  21220. * Copies the given floats to the current Vector3 coordinates
  21221. * @param x defines the x coordinate of the operand
  21222. * @param y defines the y coordinate of the operand
  21223. * @param z defines the z coordinate of the operand
  21224. * @returns the current updated Vector3
  21225. */
  21226. copyFromFloats(x: number, y: number, z: number): Vector3;
  21227. /**
  21228. * Copies the given floats to the current Vector3 coordinates
  21229. * @param x defines the x coordinate of the operand
  21230. * @param y defines the y coordinate of the operand
  21231. * @param z defines the z coordinate of the operand
  21232. * @returns the current updated Vector3
  21233. */
  21234. set(x: number, y: number, z: number): Vector3;
  21235. /**
  21236. * Copies the given float to the current Vector3 coordinates
  21237. * @param v defines the x, y and z coordinates of the operand
  21238. * @returns the current updated Vector3
  21239. */
  21240. setAll(v: number): Vector3;
  21241. /**
  21242. * Get the clip factor between two vectors
  21243. * @param vector0 defines the first operand
  21244. * @param vector1 defines the second operand
  21245. * @param axis defines the axis to use
  21246. * @param size defines the size along the axis
  21247. * @returns the clip factor
  21248. */
  21249. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21250. /**
  21251. * Get angle between two vectors
  21252. * @param vector0 angle between vector0 and vector1
  21253. * @param vector1 angle between vector0 and vector1
  21254. * @param normal direction of the normal
  21255. * @return the angle between vector0 and vector1
  21256. */
  21257. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21258. /**
  21259. * Returns a new Vector3 set from the index "offset" of the given array
  21260. * @param array defines the source array
  21261. * @param offset defines the offset in the source array
  21262. * @returns the new Vector3
  21263. */
  21264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21265. /**
  21266. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21267. * This function is deprecated. Use FromArray instead
  21268. * @param array defines the source array
  21269. * @param offset defines the offset in the source array
  21270. * @returns the new Vector3
  21271. */
  21272. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21273. /**
  21274. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21275. * @param array defines the source array
  21276. * @param offset defines the offset in the source array
  21277. * @param result defines the Vector3 where to store the result
  21278. */
  21279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21280. /**
  21281. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21282. * This function is deprecated. Use FromArrayToRef instead.
  21283. * @param array defines the source array
  21284. * @param offset defines the offset in the source array
  21285. * @param result defines the Vector3 where to store the result
  21286. */
  21287. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21288. /**
  21289. * Sets the given vector "result" with the given floats.
  21290. * @param x defines the x coordinate of the source
  21291. * @param y defines the y coordinate of the source
  21292. * @param z defines the z coordinate of the source
  21293. * @param result defines the Vector3 where to store the result
  21294. */
  21295. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21296. /**
  21297. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21298. * @returns a new empty Vector3
  21299. */
  21300. static Zero(): Vector3;
  21301. /**
  21302. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21303. * @returns a new unit Vector3
  21304. */
  21305. static One(): Vector3;
  21306. /**
  21307. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21308. * @returns a new up Vector3
  21309. */
  21310. static Up(): Vector3;
  21311. /**
  21312. * Gets a up Vector3 that must not be updated
  21313. */
  21314. static readonly UpReadOnly: DeepImmutable<Vector3>;
  21315. /**
  21316. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21317. * @returns a new down Vector3
  21318. */
  21319. static Down(): Vector3;
  21320. /**
  21321. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21322. * @returns a new forward Vector3
  21323. */
  21324. static Forward(): Vector3;
  21325. /**
  21326. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21327. * @returns a new forward Vector3
  21328. */
  21329. static Backward(): Vector3;
  21330. /**
  21331. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21332. * @returns a new right Vector3
  21333. */
  21334. static Right(): Vector3;
  21335. /**
  21336. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21337. * @returns a new left Vector3
  21338. */
  21339. static Left(): Vector3;
  21340. /**
  21341. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21342. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21343. * @param vector defines the Vector3 to transform
  21344. * @param transformation defines the transformation matrix
  21345. * @returns the transformed Vector3
  21346. */
  21347. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21348. /**
  21349. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21350. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21351. * @param vector defines the Vector3 to transform
  21352. * @param transformation defines the transformation matrix
  21353. * @param result defines the Vector3 where to store the result
  21354. */
  21355. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21356. /**
  21357. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21358. * This method computes tranformed coordinates only, not transformed direction vectors
  21359. * @param x define the x coordinate of the source vector
  21360. * @param y define the y coordinate of the source vector
  21361. * @param z define the z coordinate of the source vector
  21362. * @param transformation defines the transformation matrix
  21363. * @param result defines the Vector3 where to store the result
  21364. */
  21365. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21366. /**
  21367. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21368. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21369. * @param vector defines the Vector3 to transform
  21370. * @param transformation defines the transformation matrix
  21371. * @returns the new Vector3
  21372. */
  21373. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21374. /**
  21375. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21376. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21377. * @param vector defines the Vector3 to transform
  21378. * @param transformation defines the transformation matrix
  21379. * @param result defines the Vector3 where to store the result
  21380. */
  21381. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21382. /**
  21383. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21384. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21385. * @param x define the x coordinate of the source vector
  21386. * @param y define the y coordinate of the source vector
  21387. * @param z define the z coordinate of the source vector
  21388. * @param transformation defines the transformation matrix
  21389. * @param result defines the Vector3 where to store the result
  21390. */
  21391. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21392. /**
  21393. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21394. * @param value1 defines the first control point
  21395. * @param value2 defines the second control point
  21396. * @param value3 defines the third control point
  21397. * @param value4 defines the fourth control point
  21398. * @param amount defines the amount on the spline to use
  21399. * @returns the new Vector3
  21400. */
  21401. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21402. /**
  21403. * 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"
  21404. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21405. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21406. * @param value defines the current value
  21407. * @param min defines the lower range value
  21408. * @param max defines the upper range value
  21409. * @returns the new Vector3
  21410. */
  21411. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21412. /**
  21413. * 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"
  21414. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21415. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21416. * @param value defines the current value
  21417. * @param min defines the lower range value
  21418. * @param max defines the upper range value
  21419. * @param result defines the Vector3 where to store the result
  21420. */
  21421. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21422. /**
  21423. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21424. * @param value1 defines the first control point
  21425. * @param tangent1 defines the first tangent vector
  21426. * @param value2 defines the second control point
  21427. * @param tangent2 defines the second tangent vector
  21428. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21429. * @returns the new Vector3
  21430. */
  21431. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21432. /**
  21433. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21434. * @param start defines the start value
  21435. * @param end defines the end value
  21436. * @param amount max defines amount between both (between 0 and 1)
  21437. * @returns the new Vector3
  21438. */
  21439. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21440. /**
  21441. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21442. * @param start defines the start value
  21443. * @param end defines the end value
  21444. * @param amount max defines amount between both (between 0 and 1)
  21445. * @param result defines the Vector3 where to store the result
  21446. */
  21447. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21448. /**
  21449. * Returns the dot product (float) between the vectors "left" and "right"
  21450. * @param left defines the left operand
  21451. * @param right defines the right operand
  21452. * @returns the dot product
  21453. */
  21454. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21455. /**
  21456. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21457. * The cross product is then orthogonal to both "left" and "right"
  21458. * @param left defines the left operand
  21459. * @param right defines the right operand
  21460. * @returns the cross product
  21461. */
  21462. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21463. /**
  21464. * Sets the given vector "result" with the cross product of "left" and "right"
  21465. * The cross product is then orthogonal to both "left" and "right"
  21466. * @param left defines the left operand
  21467. * @param right defines the right operand
  21468. * @param result defines the Vector3 where to store the result
  21469. */
  21470. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21471. /**
  21472. * Returns a new Vector3 as the normalization of the given vector
  21473. * @param vector defines the Vector3 to normalize
  21474. * @returns the new Vector3
  21475. */
  21476. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21477. /**
  21478. * Sets the given vector "result" with the normalization of the given first vector
  21479. * @param vector defines the Vector3 to normalize
  21480. * @param result defines the Vector3 where to store the result
  21481. */
  21482. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21483. /**
  21484. * Project a Vector3 onto screen space
  21485. * @param vector defines the Vector3 to project
  21486. * @param world defines the world matrix to use
  21487. * @param transform defines the transform (view x projection) matrix to use
  21488. * @param viewport defines the screen viewport to use
  21489. * @returns the new Vector3
  21490. */
  21491. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21492. /** @hidden */
  21493. private static UnprojectFromInvertedMatrixToRef;
  21494. /**
  21495. * Unproject from screen space to object space
  21496. * @param source defines the screen space Vector3 to use
  21497. * @param viewportWidth defines the current width of the viewport
  21498. * @param viewportHeight defines the current height of the viewport
  21499. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21500. * @param transform defines the transform (view x projection) matrix to use
  21501. * @returns the new Vector3
  21502. */
  21503. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21504. /**
  21505. * Unproject from screen space to object space
  21506. * @param source defines the screen space Vector3 to use
  21507. * @param viewportWidth defines the current width of the viewport
  21508. * @param viewportHeight defines the current height of the viewport
  21509. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21510. * @param view defines the view matrix to use
  21511. * @param projection defines the projection matrix to use
  21512. * @returns the new Vector3
  21513. */
  21514. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21515. /**
  21516. * Unproject from screen space to object space
  21517. * @param source defines the screen space Vector3 to use
  21518. * @param viewportWidth defines the current width of the viewport
  21519. * @param viewportHeight defines the current height of the viewport
  21520. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21521. * @param view defines the view matrix to use
  21522. * @param projection defines the projection matrix to use
  21523. * @param result defines the Vector3 where to store the result
  21524. */
  21525. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21526. /**
  21527. * Unproject from screen space to object space
  21528. * @param sourceX defines the screen space x coordinate to use
  21529. * @param sourceY defines the screen space y coordinate to use
  21530. * @param sourceZ defines the screen space z coordinate to use
  21531. * @param viewportWidth defines the current width of the viewport
  21532. * @param viewportHeight defines the current height of the viewport
  21533. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21534. * @param view defines the view matrix to use
  21535. * @param projection defines the projection matrix to use
  21536. * @param result defines the Vector3 where to store the result
  21537. */
  21538. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21539. /**
  21540. * Unproject a ray from screen space to object space
  21541. * @param sourceX defines the screen space x coordinate to use
  21542. * @param sourceY defines the screen space y coordinate to use
  21543. * @param viewportWidth defines the current width of the viewport
  21544. * @param viewportHeight defines the current height of the viewport
  21545. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21546. * @param view defines the view matrix to use
  21547. * @param projection defines the projection matrix to use
  21548. * @param ray defines the Ray where to store the result
  21549. */
  21550. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21551. /**
  21552. * Gets the minimal coordinate values between two Vector3
  21553. * @param left defines the first operand
  21554. * @param right defines the second operand
  21555. * @returns the new Vector3
  21556. */
  21557. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21558. /**
  21559. * Gets the maximal coordinate values between two Vector3
  21560. * @param left defines the first operand
  21561. * @param right defines the second operand
  21562. * @returns the new Vector3
  21563. */
  21564. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21565. /**
  21566. * Returns the distance between the vectors "value1" and "value2"
  21567. * @param value1 defines the first operand
  21568. * @param value2 defines the second operand
  21569. * @returns the distance
  21570. */
  21571. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21572. /**
  21573. * Returns the squared distance between the vectors "value1" and "value2"
  21574. * @param value1 defines the first operand
  21575. * @param value2 defines the second operand
  21576. * @returns the squared distance
  21577. */
  21578. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21579. /**
  21580. * Returns a new Vector3 located at the center between "value1" and "value2"
  21581. * @param value1 defines the first operand
  21582. * @param value2 defines the second operand
  21583. * @returns the new Vector3
  21584. */
  21585. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21586. /**
  21587. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21588. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21589. * to something in order to rotate it from its local system to the given target system
  21590. * Note: axis1, axis2 and axis3 are normalized during this operation
  21591. * @param axis1 defines the first axis
  21592. * @param axis2 defines the second axis
  21593. * @param axis3 defines the third axis
  21594. * @returns a new Vector3
  21595. */
  21596. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21597. /**
  21598. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21599. * @param axis1 defines the first axis
  21600. * @param axis2 defines the second axis
  21601. * @param axis3 defines the third axis
  21602. * @param ref defines the Vector3 where to store the result
  21603. */
  21604. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21605. }
  21606. /**
  21607. * Vector4 class created for EulerAngle class conversion to Quaternion
  21608. */
  21609. class Vector4 {
  21610. /** x value of the vector */
  21611. x: number;
  21612. /** y value of the vector */
  21613. y: number;
  21614. /** z value of the vector */
  21615. z: number;
  21616. /** w value of the vector */
  21617. w: number;
  21618. /**
  21619. * Creates a Vector4 object from the given floats.
  21620. * @param x x value of the vector
  21621. * @param y y value of the vector
  21622. * @param z z value of the vector
  21623. * @param w w value of the vector
  21624. */
  21625. constructor(
  21626. /** x value of the vector */
  21627. x: number,
  21628. /** y value of the vector */
  21629. y: number,
  21630. /** z value of the vector */
  21631. z: number,
  21632. /** w value of the vector */
  21633. w: number);
  21634. /**
  21635. * Returns the string with the Vector4 coordinates.
  21636. * @returns a string containing all the vector values
  21637. */
  21638. toString(): string;
  21639. /**
  21640. * Returns the string "Vector4".
  21641. * @returns "Vector4"
  21642. */
  21643. getClassName(): string;
  21644. /**
  21645. * Returns the Vector4 hash code.
  21646. * @returns a unique hash code
  21647. */
  21648. getHashCode(): number;
  21649. /**
  21650. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21651. * @returns the resulting array
  21652. */
  21653. asArray(): number[];
  21654. /**
  21655. * Populates the given array from the given index with the Vector4 coordinates.
  21656. * @param array array to populate
  21657. * @param index index of the array to start at (default: 0)
  21658. * @returns the Vector4.
  21659. */
  21660. toArray(array: FloatArray, index?: number): Vector4;
  21661. /**
  21662. * Adds the given vector to the current Vector4.
  21663. * @param otherVector the vector to add
  21664. * @returns the updated Vector4.
  21665. */
  21666. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21667. /**
  21668. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21669. * @param otherVector the vector to add
  21670. * @returns the resulting vector
  21671. */
  21672. add(otherVector: DeepImmutable<Vector4>): Vector4;
  21673. /**
  21674. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21675. * @param otherVector the vector to add
  21676. * @param result the vector to store the result
  21677. * @returns the current Vector4.
  21678. */
  21679. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21680. /**
  21681. * Subtract in place the given vector from the current Vector4.
  21682. * @param otherVector the vector to subtract
  21683. * @returns the updated Vector4.
  21684. */
  21685. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21686. /**
  21687. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21688. * @param otherVector the vector to add
  21689. * @returns the new vector with the result
  21690. */
  21691. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  21692. /**
  21693. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21694. * @param otherVector the vector to subtract
  21695. * @param result the vector to store the result
  21696. * @returns the current Vector4.
  21697. */
  21698. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21699. /**
  21700. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21701. */
  21702. /**
  21703. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21704. * @param x value to subtract
  21705. * @param y value to subtract
  21706. * @param z value to subtract
  21707. * @param w value to subtract
  21708. * @returns new vector containing the result
  21709. */
  21710. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21711. /**
  21712. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21713. * @param x value to subtract
  21714. * @param y value to subtract
  21715. * @param z value to subtract
  21716. * @param w value to subtract
  21717. * @param result the vector to store the result in
  21718. * @returns the current Vector4.
  21719. */
  21720. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21721. /**
  21722. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21723. * @returns a new vector with the negated values
  21724. */
  21725. negate(): Vector4;
  21726. /**
  21727. * Multiplies the current Vector4 coordinates by scale (float).
  21728. * @param scale the number to scale with
  21729. * @returns the updated Vector4.
  21730. */
  21731. scaleInPlace(scale: number): Vector4;
  21732. /**
  21733. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21734. * @param scale the number to scale with
  21735. * @returns a new vector with the result
  21736. */
  21737. scale(scale: number): Vector4;
  21738. /**
  21739. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21740. * @param scale the number to scale with
  21741. * @param result a vector to store the result in
  21742. * @returns the current Vector4.
  21743. */
  21744. scaleToRef(scale: number, result: Vector4): Vector4;
  21745. /**
  21746. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21747. * @param scale defines the scale factor
  21748. * @param result defines the Vector4 object where to store the result
  21749. * @returns the unmodified current Vector4
  21750. */
  21751. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21752. /**
  21753. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21754. * @param otherVector the vector to compare against
  21755. * @returns true if they are equal
  21756. */
  21757. equals(otherVector: DeepImmutable<Vector4>): boolean;
  21758. /**
  21759. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21760. * @param otherVector vector to compare against
  21761. * @param epsilon (Default: very small number)
  21762. * @returns true if they are equal
  21763. */
  21764. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  21765. /**
  21766. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21767. * @param x x value to compare against
  21768. * @param y y value to compare against
  21769. * @param z z value to compare against
  21770. * @param w w value to compare against
  21771. * @returns true if equal
  21772. */
  21773. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21774. /**
  21775. * Multiplies in place the current Vector4 by the given one.
  21776. * @param otherVector vector to multiple with
  21777. * @returns the updated Vector4.
  21778. */
  21779. multiplyInPlace(otherVector: Vector4): Vector4;
  21780. /**
  21781. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21782. * @param otherVector vector to multiple with
  21783. * @returns resulting new vector
  21784. */
  21785. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  21786. /**
  21787. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21788. * @param otherVector vector to multiple with
  21789. * @param result vector to store the result
  21790. * @returns the current Vector4.
  21791. */
  21792. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21793. /**
  21794. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21795. * @param x x value multiply with
  21796. * @param y y value multiply with
  21797. * @param z z value multiply with
  21798. * @param w w value multiply with
  21799. * @returns resulting new vector
  21800. */
  21801. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21802. /**
  21803. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21804. * @param otherVector vector to devide with
  21805. * @returns resulting new vector
  21806. */
  21807. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  21808. /**
  21809. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21810. * @param otherVector vector to devide with
  21811. * @param result vector to store the result
  21812. * @returns the current Vector4.
  21813. */
  21814. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21815. /**
  21816. * Divides the current Vector3 coordinates by the given ones.
  21817. * @param otherVector vector to devide with
  21818. * @returns the updated Vector3.
  21819. */
  21820. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21821. /**
  21822. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21823. * @param other defines the second operand
  21824. * @returns the current updated Vector4
  21825. */
  21826. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  21827. /**
  21828. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21829. * @param other defines the second operand
  21830. * @returns the current updated Vector4
  21831. */
  21832. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  21833. /**
  21834. * Gets a new Vector4 from current Vector4 floored values
  21835. * @returns a new Vector4
  21836. */
  21837. floor(): Vector4;
  21838. /**
  21839. * Gets a new Vector4 from current Vector3 floored values
  21840. * @returns a new Vector4
  21841. */
  21842. fract(): Vector4;
  21843. /**
  21844. * Returns the Vector4 length (float).
  21845. * @returns the length
  21846. */
  21847. length(): number;
  21848. /**
  21849. * Returns the Vector4 squared length (float).
  21850. * @returns the length squared
  21851. */
  21852. lengthSquared(): number;
  21853. /**
  21854. * Normalizes in place the Vector4.
  21855. * @returns the updated Vector4.
  21856. */
  21857. normalize(): Vector4;
  21858. /**
  21859. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21860. * @returns this converted to a new vector3
  21861. */
  21862. toVector3(): Vector3;
  21863. /**
  21864. * Returns a new Vector4 copied from the current one.
  21865. * @returns the new cloned vector
  21866. */
  21867. clone(): Vector4;
  21868. /**
  21869. * Updates the current Vector4 with the given one coordinates.
  21870. * @param source the source vector to copy from
  21871. * @returns the updated Vector4.
  21872. */
  21873. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  21874. /**
  21875. * Updates the current Vector4 coordinates with the given floats.
  21876. * @param x float to copy from
  21877. * @param y float to copy from
  21878. * @param z float to copy from
  21879. * @param w float to copy from
  21880. * @returns the updated Vector4.
  21881. */
  21882. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21883. /**
  21884. * Updates the current Vector4 coordinates with the given floats.
  21885. * @param x float to set from
  21886. * @param y float to set from
  21887. * @param z float to set from
  21888. * @param w float to set from
  21889. * @returns the updated Vector4.
  21890. */
  21891. set(x: number, y: number, z: number, w: number): Vector4;
  21892. /**
  21893. * Copies the given float to the current Vector3 coordinates
  21894. * @param v defines the x, y, z and w coordinates of the operand
  21895. * @returns the current updated Vector3
  21896. */
  21897. setAll(v: number): Vector4;
  21898. /**
  21899. * Returns a new Vector4 set from the starting index of the given array.
  21900. * @param array the array to pull values from
  21901. * @param offset the offset into the array to start at
  21902. * @returns the new vector
  21903. */
  21904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  21905. /**
  21906. * Updates the given vector "result" from the starting index of the given array.
  21907. * @param array the array to pull values from
  21908. * @param offset the offset into the array to start at
  21909. * @param result the vector to store the result in
  21910. */
  21911. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  21912. /**
  21913. * Updates the given vector "result" from the starting index of the given Float32Array.
  21914. * @param array the array to pull values from
  21915. * @param offset the offset into the array to start at
  21916. * @param result the vector to store the result in
  21917. */
  21918. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  21919. /**
  21920. * Updates the given vector "result" coordinates from the given floats.
  21921. * @param x float to set from
  21922. * @param y float to set from
  21923. * @param z float to set from
  21924. * @param w float to set from
  21925. * @param result the vector to the floats in
  21926. */
  21927. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21928. /**
  21929. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21930. * @returns the new vector
  21931. */
  21932. static Zero(): Vector4;
  21933. /**
  21934. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21935. * @returns the new vector
  21936. */
  21937. static One(): Vector4;
  21938. /**
  21939. * Returns a new normalized Vector4 from the given one.
  21940. * @param vector the vector to normalize
  21941. * @returns the vector
  21942. */
  21943. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  21944. /**
  21945. * Updates the given vector "result" from the normalization of the given one.
  21946. * @param vector the vector to normalize
  21947. * @param result the vector to store the result in
  21948. */
  21949. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  21950. /**
  21951. * Returns a vector with the minimum values from the left and right vectors
  21952. * @param left left vector to minimize
  21953. * @param right right vector to minimize
  21954. * @returns a new vector with the minimum of the left and right vector values
  21955. */
  21956. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  21957. /**
  21958. * Returns a vector with the maximum values from the left and right vectors
  21959. * @param left left vector to maximize
  21960. * @param right right vector to maximize
  21961. * @returns a new vector with the maximum of the left and right vector values
  21962. */
  21963. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  21964. /**
  21965. * Returns the distance (float) between the vectors "value1" and "value2".
  21966. * @param value1 value to calulate the distance between
  21967. * @param value2 value to calulate the distance between
  21968. * @return the distance between the two vectors
  21969. */
  21970. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  21971. /**
  21972. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21973. * @param value1 value to calulate the distance between
  21974. * @param value2 value to calulate the distance between
  21975. * @return the distance between the two vectors squared
  21976. */
  21977. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  21978. /**
  21979. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21980. * @param value1 value to calulate the center between
  21981. * @param value2 value to calulate the center between
  21982. * @return the center between the two vectors
  21983. */
  21984. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  21985. /**
  21986. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21987. * This methods computes transformed normalized direction vectors only.
  21988. * @param vector the vector to transform
  21989. * @param transformation the transformation matrix to apply
  21990. * @returns the new vector
  21991. */
  21992. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  21993. /**
  21994. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21995. * This methods computes transformed normalized direction vectors only.
  21996. * @param vector the vector to transform
  21997. * @param transformation the transformation matrix to apply
  21998. * @param result the vector to store the result in
  21999. */
  22000. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22001. /**
  22002. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22003. * This methods computes transformed normalized direction vectors only.
  22004. * @param x value to transform
  22005. * @param y value to transform
  22006. * @param z value to transform
  22007. * @param w value to transform
  22008. * @param transformation the transformation matrix to apply
  22009. * @param result the vector to store the results in
  22010. */
  22011. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22012. /**
  22013. * Creates a new Vector4 from a Vector3
  22014. * @param source defines the source data
  22015. * @param w defines the 4th component (default is 0)
  22016. * @returns a new Vector4
  22017. */
  22018. static FromVector3(source: Vector3, w?: number): Vector4;
  22019. }
  22020. /**
  22021. * Interface for the size containing width and height
  22022. */
  22023. interface ISize {
  22024. /**
  22025. * Width
  22026. */
  22027. width: number;
  22028. /**
  22029. * Heighht
  22030. */
  22031. height: number;
  22032. }
  22033. /**
  22034. * Size containing widht and height
  22035. */
  22036. class Size implements ISize {
  22037. /**
  22038. * Width
  22039. */
  22040. width: number;
  22041. /**
  22042. * Height
  22043. */
  22044. height: number;
  22045. /**
  22046. * Creates a Size object from the given width and height (floats).
  22047. * @param width width of the new size
  22048. * @param height height of the new size
  22049. */
  22050. constructor(width: number, height: number);
  22051. /**
  22052. * Returns a string with the Size width and height
  22053. * @returns a string with the Size width and height
  22054. */
  22055. toString(): string;
  22056. /**
  22057. * "Size"
  22058. * @returns the string "Size"
  22059. */
  22060. getClassName(): string;
  22061. /**
  22062. * Returns the Size hash code.
  22063. * @returns a hash code for a unique width and height
  22064. */
  22065. getHashCode(): number;
  22066. /**
  22067. * Updates the current size from the given one.
  22068. * @param src the given size
  22069. */
  22070. copyFrom(src: Size): void;
  22071. /**
  22072. * Updates in place the current Size from the given floats.
  22073. * @param width width of the new size
  22074. * @param height height of the new size
  22075. * @returns the updated Size.
  22076. */
  22077. copyFromFloats(width: number, height: number): Size;
  22078. /**
  22079. * Updates in place the current Size from the given floats.
  22080. * @param width width to set
  22081. * @param height height to set
  22082. * @returns the updated Size.
  22083. */
  22084. set(width: number, height: number): Size;
  22085. /**
  22086. * Multiplies the width and height by numbers
  22087. * @param w factor to multiple the width by
  22088. * @param h factor to multiple the height by
  22089. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22090. */
  22091. multiplyByFloats(w: number, h: number): Size;
  22092. /**
  22093. * Clones the size
  22094. * @returns a new Size copied from the given one.
  22095. */
  22096. clone(): Size;
  22097. /**
  22098. * True if the current Size and the given one width and height are strictly equal.
  22099. * @param other the other size to compare against
  22100. * @returns True if the current Size and the given one width and height are strictly equal.
  22101. */
  22102. equals(other: Size): boolean;
  22103. /**
  22104. * The surface of the Size : width * height (float).
  22105. */
  22106. readonly surface: number;
  22107. /**
  22108. * Create a new size of zero
  22109. * @returns a new Size set to (0.0, 0.0)
  22110. */
  22111. static Zero(): Size;
  22112. /**
  22113. * Sums the width and height of two sizes
  22114. * @param otherSize size to add to this size
  22115. * @returns a new Size set as the addition result of the current Size and the given one.
  22116. */
  22117. add(otherSize: Size): Size;
  22118. /**
  22119. * Subtracts the width and height of two
  22120. * @param otherSize size to subtract to this size
  22121. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22122. */
  22123. subtract(otherSize: Size): Size;
  22124. /**
  22125. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22126. * @param start starting size to lerp between
  22127. * @param end end size to lerp between
  22128. * @param amount amount to lerp between the start and end values
  22129. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22130. */
  22131. static Lerp(start: Size, end: Size, amount: number): Size;
  22132. }
  22133. /**
  22134. * Class used to store quaternion data
  22135. * @see https://en.wikipedia.org/wiki/Quaternion
  22136. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22137. */
  22138. class Quaternion {
  22139. /** defines the first component (0 by default) */
  22140. x: number;
  22141. /** defines the second component (0 by default) */
  22142. y: number;
  22143. /** defines the third component (0 by default) */
  22144. z: number;
  22145. /** defines the fourth component (1.0 by default) */
  22146. w: number;
  22147. /**
  22148. * Creates a new Quaternion from the given floats
  22149. * @param x defines the first component (0 by default)
  22150. * @param y defines the second component (0 by default)
  22151. * @param z defines the third component (0 by default)
  22152. * @param w defines the fourth component (1.0 by default)
  22153. */
  22154. constructor(
  22155. /** defines the first component (0 by default) */
  22156. x?: number,
  22157. /** defines the second component (0 by default) */
  22158. y?: number,
  22159. /** defines the third component (0 by default) */
  22160. z?: number,
  22161. /** defines the fourth component (1.0 by default) */
  22162. w?: number);
  22163. /**
  22164. * Gets a string representation for the current quaternion
  22165. * @returns a string with the Quaternion coordinates
  22166. */
  22167. toString(): string;
  22168. /**
  22169. * Gets the class name of the quaternion
  22170. * @returns the string "Quaternion"
  22171. */
  22172. getClassName(): string;
  22173. /**
  22174. * Gets a hash code for this quaternion
  22175. * @returns the quaternion hash code
  22176. */
  22177. getHashCode(): number;
  22178. /**
  22179. * Copy the quaternion to an array
  22180. * @returns a new array populated with 4 elements from the quaternion coordinates
  22181. */
  22182. asArray(): number[];
  22183. /**
  22184. * Check if two quaternions are equals
  22185. * @param otherQuaternion defines the second operand
  22186. * @return true if the current quaternion and the given one coordinates are strictly equals
  22187. */
  22188. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22189. /**
  22190. * Clone the current quaternion
  22191. * @returns a new quaternion copied from the current one
  22192. */
  22193. clone(): Quaternion;
  22194. /**
  22195. * Copy a quaternion to the current one
  22196. * @param other defines the other quaternion
  22197. * @returns the updated current quaternion
  22198. */
  22199. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22200. /**
  22201. * Updates the current quaternion with the given float coordinates
  22202. * @param x defines the x coordinate
  22203. * @param y defines the y coordinate
  22204. * @param z defines the z coordinate
  22205. * @param w defines the w coordinate
  22206. * @returns the updated current quaternion
  22207. */
  22208. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22209. /**
  22210. * Updates the current quaternion from the given float coordinates
  22211. * @param x defines the x coordinate
  22212. * @param y defines the y coordinate
  22213. * @param z defines the z coordinate
  22214. * @param w defines the w coordinate
  22215. * @returns the updated current quaternion
  22216. */
  22217. set(x: number, y: number, z: number, w: number): Quaternion;
  22218. /**
  22219. * Adds two quaternions
  22220. * @param other defines the second operand
  22221. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22222. */
  22223. add(other: DeepImmutable<Quaternion>): Quaternion;
  22224. /**
  22225. * Add a quaternion to the current one
  22226. * @param other defines the quaternion to add
  22227. * @returns the current quaternion
  22228. */
  22229. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22230. /**
  22231. * Subtract two quaternions
  22232. * @param other defines the second operand
  22233. * @returns a new quaternion as the subtraction result of the given one from the current one
  22234. */
  22235. subtract(other: Quaternion): Quaternion;
  22236. /**
  22237. * Multiplies the current quaternion by a scale factor
  22238. * @param value defines the scale factor
  22239. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22240. */
  22241. scale(value: number): Quaternion;
  22242. /**
  22243. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22244. * @param scale defines the scale factor
  22245. * @param result defines the Quaternion object where to store the result
  22246. * @returns the unmodified current quaternion
  22247. */
  22248. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22249. /**
  22250. * Multiplies in place the current quaternion by a scale factor
  22251. * @param value defines the scale factor
  22252. * @returns the current modified quaternion
  22253. */
  22254. scaleInPlace(value: number): Quaternion;
  22255. /**
  22256. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22257. * @param scale defines the scale factor
  22258. * @param result defines the Quaternion object where to store the result
  22259. * @returns the unmodified current quaternion
  22260. */
  22261. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22262. /**
  22263. * Multiplies two quaternions
  22264. * @param q1 defines the second operand
  22265. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22266. */
  22267. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22268. /**
  22269. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22270. * @param q1 defines the second operand
  22271. * @param result defines the target quaternion
  22272. * @returns the current quaternion
  22273. */
  22274. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22275. /**
  22276. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22277. * @param q1 defines the second operand
  22278. * @returns the currentupdated quaternion
  22279. */
  22280. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22281. /**
  22282. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22283. * @param ref defines the target quaternion
  22284. * @returns the current quaternion
  22285. */
  22286. conjugateToRef(ref: Quaternion): Quaternion;
  22287. /**
  22288. * Conjugates in place (1-q) the current quaternion
  22289. * @returns the current updated quaternion
  22290. */
  22291. conjugateInPlace(): Quaternion;
  22292. /**
  22293. * Conjugates in place (1-q) the current quaternion
  22294. * @returns a new quaternion
  22295. */
  22296. conjugate(): Quaternion;
  22297. /**
  22298. * Gets length of current quaternion
  22299. * @returns the quaternion length (float)
  22300. */
  22301. length(): number;
  22302. /**
  22303. * Normalize in place the current quaternion
  22304. * @returns the current updated quaternion
  22305. */
  22306. normalize(): Quaternion;
  22307. /**
  22308. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22309. * @param order is a reserved parameter and is ignore for now
  22310. * @returns a new Vector3 containing the Euler angles
  22311. */
  22312. toEulerAngles(order?: string): Vector3;
  22313. /**
  22314. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22315. * @param result defines the vector which will be filled with the Euler angles
  22316. * @param order is a reserved parameter and is ignore for now
  22317. * @returns the current unchanged quaternion
  22318. */
  22319. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22320. /**
  22321. * Updates the given rotation matrix with the current quaternion values
  22322. * @param result defines the target matrix
  22323. * @returns the current unchanged quaternion
  22324. */
  22325. toRotationMatrix(result: Matrix): Quaternion;
  22326. /**
  22327. * Updates the current quaternion from the given rotation matrix values
  22328. * @param matrix defines the source matrix
  22329. * @returns the current updated quaternion
  22330. */
  22331. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22332. /**
  22333. * Creates a new quaternion from a rotation matrix
  22334. * @param matrix defines the source matrix
  22335. * @returns a new quaternion created from the given rotation matrix values
  22336. */
  22337. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22338. /**
  22339. * Updates the given quaternion with the given rotation matrix values
  22340. * @param matrix defines the source matrix
  22341. * @param result defines the target quaternion
  22342. */
  22343. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22344. /**
  22345. * Returns the dot product (float) between the quaternions "left" and "right"
  22346. * @param left defines the left operand
  22347. * @param right defines the right operand
  22348. * @returns the dot product
  22349. */
  22350. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22351. /**
  22352. * Checks if the two quaternions are close to each other
  22353. * @param quat0 defines the first quaternion to check
  22354. * @param quat1 defines the second quaternion to check
  22355. * @returns true if the two quaternions are close to each other
  22356. */
  22357. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22358. /**
  22359. * Creates an empty quaternion
  22360. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22361. */
  22362. static Zero(): Quaternion;
  22363. /**
  22364. * Inverse a given quaternion
  22365. * @param q defines the source quaternion
  22366. * @returns a new quaternion as the inverted current quaternion
  22367. */
  22368. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22369. /**
  22370. * Inverse a given quaternion
  22371. * @param q defines the source quaternion
  22372. * @param result the quaternion the result will be stored in
  22373. * @returns the result quaternion
  22374. */
  22375. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22376. /**
  22377. * Creates an identity quaternion
  22378. * @returns the identity quaternion
  22379. */
  22380. static Identity(): Quaternion;
  22381. /**
  22382. * Gets a boolean indicating if the given quaternion is identity
  22383. * @param quaternion defines the quaternion to check
  22384. * @returns true if the quaternion is identity
  22385. */
  22386. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22387. /**
  22388. * Creates a quaternion from a rotation around an axis
  22389. * @param axis defines the axis to use
  22390. * @param angle defines the angle to use
  22391. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22392. */
  22393. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22394. /**
  22395. * Creates a rotation around an axis and stores it into the given quaternion
  22396. * @param axis defines the axis to use
  22397. * @param angle defines the angle to use
  22398. * @param result defines the target quaternion
  22399. * @returns the target quaternion
  22400. */
  22401. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22402. /**
  22403. * Creates a new quaternion from data stored into an array
  22404. * @param array defines the data source
  22405. * @param offset defines the offset in the source array where the data starts
  22406. * @returns a new quaternion
  22407. */
  22408. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22409. /**
  22410. * Create a quaternion from Euler rotation angles
  22411. * @param x Pitch
  22412. * @param y Yaw
  22413. * @param z Roll
  22414. * @returns the new Quaternion
  22415. */
  22416. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22417. /**
  22418. * Updates a quaternion from Euler rotation angles
  22419. * @param x Pitch
  22420. * @param y Yaw
  22421. * @param z Roll
  22422. * @param result the quaternion to store the result
  22423. * @returns the updated quaternion
  22424. */
  22425. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22426. /**
  22427. * Create a quaternion from Euler rotation vector
  22428. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22429. * @returns the new Quaternion
  22430. */
  22431. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22432. /**
  22433. * Updates a quaternion from Euler rotation vector
  22434. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22435. * @param result the quaternion to store the result
  22436. * @returns the updated quaternion
  22437. */
  22438. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22439. /**
  22440. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22441. * @param yaw defines the rotation around Y axis
  22442. * @param pitch defines the rotation around X axis
  22443. * @param roll defines the rotation around Z axis
  22444. * @returns the new quaternion
  22445. */
  22446. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22447. /**
  22448. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22449. * @param yaw defines the rotation around Y axis
  22450. * @param pitch defines the rotation around X axis
  22451. * @param roll defines the rotation around Z axis
  22452. * @param result defines the target quaternion
  22453. */
  22454. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22455. /**
  22456. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22457. * @param alpha defines the rotation around first axis
  22458. * @param beta defines the rotation around second axis
  22459. * @param gamma defines the rotation around third axis
  22460. * @returns the new quaternion
  22461. */
  22462. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22463. /**
  22464. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22465. * @param alpha defines the rotation around first axis
  22466. * @param beta defines the rotation around second axis
  22467. * @param gamma defines the rotation around third axis
  22468. * @param result defines the target quaternion
  22469. */
  22470. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22471. /**
  22472. * 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)
  22473. * @param axis1 defines the first axis
  22474. * @param axis2 defines the second axis
  22475. * @param axis3 defines the third axis
  22476. * @returns the new quaternion
  22477. */
  22478. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22479. /**
  22480. * 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
  22481. * @param axis1 defines the first axis
  22482. * @param axis2 defines the second axis
  22483. * @param axis3 defines the third axis
  22484. * @param ref defines the target quaternion
  22485. */
  22486. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22487. /**
  22488. * Interpolates between two quaternions
  22489. * @param left defines first quaternion
  22490. * @param right defines second quaternion
  22491. * @param amount defines the gradient to use
  22492. * @returns the new interpolated quaternion
  22493. */
  22494. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22495. /**
  22496. * Interpolates between two quaternions and stores it into a target quaternion
  22497. * @param left defines first quaternion
  22498. * @param right defines second quaternion
  22499. * @param amount defines the gradient to use
  22500. * @param result defines the target quaternion
  22501. */
  22502. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22503. /**
  22504. * Interpolate between two quaternions using Hermite interpolation
  22505. * @param value1 defines first quaternion
  22506. * @param tangent1 defines the incoming tangent
  22507. * @param value2 defines second quaternion
  22508. * @param tangent2 defines the outgoing tangent
  22509. * @param amount defines the target quaternion
  22510. * @returns the new interpolated quaternion
  22511. */
  22512. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22513. }
  22514. /**
  22515. * Class used to store matrix data (4x4)
  22516. */
  22517. class Matrix {
  22518. private static _updateFlagSeed;
  22519. private static _identityReadOnly;
  22520. private _isIdentity;
  22521. private _isIdentityDirty;
  22522. private _isIdentity3x2;
  22523. private _isIdentity3x2Dirty;
  22524. /**
  22525. * Gets the update flag of the matrix which is an unique number for the matrix.
  22526. * It will be incremented every time the matrix data change.
  22527. * You can use it to speed the comparison between two versions of the same matrix.
  22528. */
  22529. updateFlag: number;
  22530. private readonly _m;
  22531. /**
  22532. * Gets the internal data of the matrix
  22533. */
  22534. readonly m: DeepImmutable<Float32Array>;
  22535. /** @hidden */
  22536. _markAsUpdated(): void;
  22537. /** @hidden */
  22538. private _updateIdentityStatus;
  22539. /**
  22540. * Creates an empty matrix (filled with zeros)
  22541. */
  22542. constructor();
  22543. /**
  22544. * Check if the current matrix is identity
  22545. * @returns true is the matrix is the identity matrix
  22546. */
  22547. isIdentity(): boolean;
  22548. /**
  22549. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22550. * @returns true is the matrix is the identity matrix
  22551. */
  22552. isIdentityAs3x2(): boolean;
  22553. /**
  22554. * Gets the determinant of the matrix
  22555. * @returns the matrix determinant
  22556. */
  22557. determinant(): number;
  22558. /**
  22559. * Returns the matrix as a Float32Array
  22560. * @returns the matrix underlying array
  22561. */
  22562. toArray(): DeepImmutable<Float32Array>;
  22563. /**
  22564. * Returns the matrix as a Float32Array
  22565. * @returns the matrix underlying array.
  22566. */
  22567. asArray(): DeepImmutable<Float32Array>;
  22568. /**
  22569. * Inverts the current matrix in place
  22570. * @returns the current inverted matrix
  22571. */
  22572. invert(): Matrix;
  22573. /**
  22574. * Sets all the matrix elements to zero
  22575. * @returns the current matrix
  22576. */
  22577. reset(): Matrix;
  22578. /**
  22579. * Adds the current matrix with a second one
  22580. * @param other defines the matrix to add
  22581. * @returns a new matrix as the addition of the current matrix and the given one
  22582. */
  22583. add(other: DeepImmutable<Matrix>): Matrix;
  22584. /**
  22585. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22586. * @param other defines the matrix to add
  22587. * @param result defines the target matrix
  22588. * @returns the current matrix
  22589. */
  22590. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22591. /**
  22592. * Adds in place the given matrix to the current matrix
  22593. * @param other defines the second operand
  22594. * @returns the current updated matrix
  22595. */
  22596. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22597. /**
  22598. * Sets the given matrix to the current inverted Matrix
  22599. * @param other defines the target matrix
  22600. * @returns the unmodified current matrix
  22601. */
  22602. invertToRef(other: Matrix): Matrix;
  22603. /**
  22604. * add a value at the specified position in the current Matrix
  22605. * @param index the index of the value within the matrix. between 0 and 15.
  22606. * @param value the value to be added
  22607. * @returns the current updated matrix
  22608. */
  22609. addAtIndex(index: number, value: number): Matrix;
  22610. /**
  22611. * mutiply the specified position in the current Matrix by a value
  22612. * @param index the index of the value within the matrix. between 0 and 15.
  22613. * @param value the value to be added
  22614. * @returns the current updated matrix
  22615. */
  22616. multiplyAtIndex(index: number, value: number): Matrix;
  22617. /**
  22618. * Inserts the translation vector (using 3 floats) in the current matrix
  22619. * @param x defines the 1st component of the translation
  22620. * @param y defines the 2nd component of the translation
  22621. * @param z defines the 3rd component of the translation
  22622. * @returns the current updated matrix
  22623. */
  22624. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22625. /**
  22626. * Inserts the translation vector in the current matrix
  22627. * @param vector3 defines the translation to insert
  22628. * @returns the current updated matrix
  22629. */
  22630. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22631. /**
  22632. * Gets the translation value of the current matrix
  22633. * @returns a new Vector3 as the extracted translation from the matrix
  22634. */
  22635. getTranslation(): Vector3;
  22636. /**
  22637. * Fill a Vector3 with the extracted translation from the matrix
  22638. * @param result defines the Vector3 where to store the translation
  22639. * @returns the current matrix
  22640. */
  22641. getTranslationToRef(result: Vector3): Matrix;
  22642. /**
  22643. * Remove rotation and scaling part from the matrix
  22644. * @returns the updated matrix
  22645. */
  22646. removeRotationAndScaling(): Matrix;
  22647. /**
  22648. * Multiply two matrices
  22649. * @param other defines the second operand
  22650. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22651. */
  22652. multiply(other: DeepImmutable<Matrix>): Matrix;
  22653. /**
  22654. * Copy the current matrix from the given one
  22655. * @param other defines the source matrix
  22656. * @returns the current updated matrix
  22657. */
  22658. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  22659. /**
  22660. * Populates the given array from the starting index with the current matrix values
  22661. * @param array defines the target array
  22662. * @param offset defines the offset in the target array where to start storing values
  22663. * @returns the current matrix
  22664. */
  22665. copyToArray(array: Float32Array, offset?: number): Matrix;
  22666. /**
  22667. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22668. * @param other defines the second operand
  22669. * @param result defines the matrix where to store the multiplication
  22670. * @returns the current matrix
  22671. */
  22672. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22673. /**
  22674. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22675. * @param other defines the second operand
  22676. * @param result defines the array where to store the multiplication
  22677. * @param offset defines the offset in the target array where to start storing values
  22678. * @returns the current matrix
  22679. */
  22680. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  22681. /**
  22682. * Check equality between this matrix and a second one
  22683. * @param value defines the second matrix to compare
  22684. * @returns true is the current matrix and the given one values are strictly equal
  22685. */
  22686. equals(value: DeepImmutable<Matrix>): boolean;
  22687. /**
  22688. * Clone the current matrix
  22689. * @returns a new matrix from the current matrix
  22690. */
  22691. clone(): Matrix;
  22692. /**
  22693. * Returns the name of the current matrix class
  22694. * @returns the string "Matrix"
  22695. */
  22696. getClassName(): string;
  22697. /**
  22698. * Gets the hash code of the current matrix
  22699. * @returns the hash code
  22700. */
  22701. getHashCode(): number;
  22702. /**
  22703. * Decomposes the current Matrix into a translation, rotation and scaling components
  22704. * @param scale defines the scale vector3 given as a reference to update
  22705. * @param rotation defines the rotation quaternion given as a reference to update
  22706. * @param translation defines the translation vector3 given as a reference to update
  22707. * @returns true if operation was successful
  22708. */
  22709. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22710. /**
  22711. * Gets specific row of the matrix
  22712. * @param index defines the number of the row to get
  22713. * @returns the index-th row of the current matrix as a new Vector4
  22714. */
  22715. getRow(index: number): Nullable<Vector4>;
  22716. /**
  22717. * Sets the index-th row of the current matrix to the vector4 values
  22718. * @param index defines the number of the row to set
  22719. * @param row defines the target vector4
  22720. * @returns the updated current matrix
  22721. */
  22722. setRow(index: number, row: Vector4): Matrix;
  22723. /**
  22724. * Compute the transpose of the matrix
  22725. * @returns the new transposed matrix
  22726. */
  22727. transpose(): Matrix;
  22728. /**
  22729. * Compute the transpose of the matrix and store it in a given matrix
  22730. * @param result defines the target matrix
  22731. * @returns the current matrix
  22732. */
  22733. transposeToRef(result: Matrix): Matrix;
  22734. /**
  22735. * Sets the index-th row of the current matrix with the given 4 x float values
  22736. * @param index defines the row index
  22737. * @param x defines the x component to set
  22738. * @param y defines the y component to set
  22739. * @param z defines the z component to set
  22740. * @param w defines the w component to set
  22741. * @returns the updated current matrix
  22742. */
  22743. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22744. /**
  22745. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22746. * @param scale defines the scale factor
  22747. * @returns a new matrix
  22748. */
  22749. scale(scale: number): Matrix;
  22750. /**
  22751. * Scale the current matrix values by a factor to a given result matrix
  22752. * @param scale defines the scale factor
  22753. * @param result defines the matrix to store the result
  22754. * @returns the current matrix
  22755. */
  22756. scaleToRef(scale: number, result: Matrix): Matrix;
  22757. /**
  22758. * Scale the current matrix values by a factor and add the result to a given matrix
  22759. * @param scale defines the scale factor
  22760. * @param result defines the Matrix to store the result
  22761. * @returns the current matrix
  22762. */
  22763. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22764. /**
  22765. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22766. * @param ref matrix to store the result
  22767. */
  22768. toNormalMatrix(ref: Matrix): void;
  22769. /**
  22770. * Gets only rotation part of the current matrix
  22771. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22772. */
  22773. getRotationMatrix(): Matrix;
  22774. /**
  22775. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22776. * @param result defines the target matrix to store data to
  22777. * @returns the current matrix
  22778. */
  22779. getRotationMatrixToRef(result: Matrix): Matrix;
  22780. /**
  22781. * Toggles model matrix from being right handed to left handed in place and vice versa
  22782. */
  22783. toggleModelMatrixHandInPlace(): void;
  22784. /**
  22785. * Toggles projection matrix from being right handed to left handed in place and vice versa
  22786. */
  22787. toggleProjectionMatrixHandInPlace(): void;
  22788. /**
  22789. * Creates a matrix from an array
  22790. * @param array defines the source array
  22791. * @param offset defines an offset in the source array
  22792. * @returns a new Matrix set from the starting index of the given array
  22793. */
  22794. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  22795. /**
  22796. * Copy the content of an array into a given matrix
  22797. * @param array defines the source array
  22798. * @param offset defines an offset in the source array
  22799. * @param result defines the target matrix
  22800. */
  22801. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  22802. /**
  22803. * Stores an array into a matrix after having multiplied each component by a given factor
  22804. * @param array defines the source array
  22805. * @param offset defines the offset in the source array
  22806. * @param scale defines the scaling factor
  22807. * @param result defines the target matrix
  22808. */
  22809. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  22810. /**
  22811. * Gets an identity matrix that must not be updated
  22812. */
  22813. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  22814. /**
  22815. * Stores a list of values (16) inside a given matrix
  22816. * @param initialM11 defines 1st value of 1st row
  22817. * @param initialM12 defines 2nd value of 1st row
  22818. * @param initialM13 defines 3rd value of 1st row
  22819. * @param initialM14 defines 4th value of 1st row
  22820. * @param initialM21 defines 1st value of 2nd row
  22821. * @param initialM22 defines 2nd value of 2nd row
  22822. * @param initialM23 defines 3rd value of 2nd row
  22823. * @param initialM24 defines 4th value of 2nd row
  22824. * @param initialM31 defines 1st value of 3rd row
  22825. * @param initialM32 defines 2nd value of 3rd row
  22826. * @param initialM33 defines 3rd value of 3rd row
  22827. * @param initialM34 defines 4th value of 3rd row
  22828. * @param initialM41 defines 1st value of 4th row
  22829. * @param initialM42 defines 2nd value of 4th row
  22830. * @param initialM43 defines 3rd value of 4th row
  22831. * @param initialM44 defines 4th value of 4th row
  22832. * @param result defines the target matrix
  22833. */
  22834. 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;
  22835. /**
  22836. * Creates new matrix from a list of values (16)
  22837. * @param initialM11 defines 1st value of 1st row
  22838. * @param initialM12 defines 2nd value of 1st row
  22839. * @param initialM13 defines 3rd value of 1st row
  22840. * @param initialM14 defines 4th value of 1st row
  22841. * @param initialM21 defines 1st value of 2nd row
  22842. * @param initialM22 defines 2nd value of 2nd row
  22843. * @param initialM23 defines 3rd value of 2nd row
  22844. * @param initialM24 defines 4th value of 2nd row
  22845. * @param initialM31 defines 1st value of 3rd row
  22846. * @param initialM32 defines 2nd value of 3rd row
  22847. * @param initialM33 defines 3rd value of 3rd row
  22848. * @param initialM34 defines 4th value of 3rd row
  22849. * @param initialM41 defines 1st value of 4th row
  22850. * @param initialM42 defines 2nd value of 4th row
  22851. * @param initialM43 defines 3rd value of 4th row
  22852. * @param initialM44 defines 4th value of 4th row
  22853. * @returns the new matrix
  22854. */
  22855. 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;
  22856. /**
  22857. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22858. * @param scale defines the scale vector3
  22859. * @param rotation defines the rotation quaternion
  22860. * @param translation defines the translation vector3
  22861. * @returns a new matrix
  22862. */
  22863. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  22864. /**
  22865. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22866. * @param scale defines the scale vector3
  22867. * @param rotation defines the rotation quaternion
  22868. * @param translation defines the translation vector3
  22869. * @param result defines the target matrix
  22870. */
  22871. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  22872. /**
  22873. * Creates a new identity matrix
  22874. * @returns a new identity matrix
  22875. */
  22876. static Identity(): Matrix;
  22877. /**
  22878. * Creates a new identity matrix and stores the result in a given matrix
  22879. * @param result defines the target matrix
  22880. */
  22881. static IdentityToRef(result: Matrix): void;
  22882. /**
  22883. * Creates a new zero matrix
  22884. * @returns a new zero matrix
  22885. */
  22886. static Zero(): Matrix;
  22887. /**
  22888. * Creates a new rotation matrix for "angle" radians around the X axis
  22889. * @param angle defines the angle (in radians) to use
  22890. * @return the new matrix
  22891. */
  22892. static RotationX(angle: number): Matrix;
  22893. /**
  22894. * Creates a new matrix as the invert of a given matrix
  22895. * @param source defines the source matrix
  22896. * @returns the new matrix
  22897. */
  22898. static Invert(source: DeepImmutable<Matrix>): Matrix;
  22899. /**
  22900. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22901. * @param angle defines the angle (in radians) to use
  22902. * @param result defines the target matrix
  22903. */
  22904. static RotationXToRef(angle: number, result: Matrix): void;
  22905. /**
  22906. * Creates a new rotation matrix for "angle" radians around the Y axis
  22907. * @param angle defines the angle (in radians) to use
  22908. * @return the new matrix
  22909. */
  22910. static RotationY(angle: number): Matrix;
  22911. /**
  22912. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22913. * @param angle defines the angle (in radians) to use
  22914. * @param result defines the target matrix
  22915. */
  22916. static RotationYToRef(angle: number, result: Matrix): void;
  22917. /**
  22918. * Creates a new rotation matrix for "angle" radians around the Z axis
  22919. * @param angle defines the angle (in radians) to use
  22920. * @return the new matrix
  22921. */
  22922. static RotationZ(angle: number): Matrix;
  22923. /**
  22924. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22925. * @param angle defines the angle (in radians) to use
  22926. * @param result defines the target matrix
  22927. */
  22928. static RotationZToRef(angle: number, result: Matrix): void;
  22929. /**
  22930. * Creates a new rotation matrix for "angle" radians around the given axis
  22931. * @param axis defines the axis to use
  22932. * @param angle defines the angle (in radians) to use
  22933. * @return the new matrix
  22934. */
  22935. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  22936. /**
  22937. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22938. * @param axis defines the axis to use
  22939. * @param angle defines the angle (in radians) to use
  22940. * @param result defines the target matrix
  22941. */
  22942. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  22943. /**
  22944. * Creates a rotation matrix
  22945. * @param yaw defines the yaw angle in radians (Y axis)
  22946. * @param pitch defines the pitch angle in radians (X axis)
  22947. * @param roll defines the roll angle in radians (X axis)
  22948. * @returns the new rotation matrix
  22949. */
  22950. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22951. /**
  22952. * Creates a rotation matrix and stores it in a given matrix
  22953. * @param yaw defines the yaw angle in radians (Y axis)
  22954. * @param pitch defines the pitch angle in radians (X axis)
  22955. * @param roll defines the roll angle in radians (X axis)
  22956. * @param result defines the target matrix
  22957. */
  22958. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22959. /**
  22960. * Creates a scaling matrix
  22961. * @param x defines the scale factor on X axis
  22962. * @param y defines the scale factor on Y axis
  22963. * @param z defines the scale factor on Z axis
  22964. * @returns the new matrix
  22965. */
  22966. static Scaling(x: number, y: number, z: number): Matrix;
  22967. /**
  22968. * Creates a scaling matrix and stores it in a given matrix
  22969. * @param x defines the scale factor on X axis
  22970. * @param y defines the scale factor on Y axis
  22971. * @param z defines the scale factor on Z axis
  22972. * @param result defines the target matrix
  22973. */
  22974. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22975. /**
  22976. * Creates a translation matrix
  22977. * @param x defines the translation on X axis
  22978. * @param y defines the translation on Y axis
  22979. * @param z defines the translationon Z axis
  22980. * @returns the new matrix
  22981. */
  22982. static Translation(x: number, y: number, z: number): Matrix;
  22983. /**
  22984. * Creates a translation matrix and stores it in a given matrix
  22985. * @param x defines the translation on X axis
  22986. * @param y defines the translation on Y axis
  22987. * @param z defines the translationon Z axis
  22988. * @param result defines the target matrix
  22989. */
  22990. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22991. /**
  22992. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22993. * @param startValue defines the start value
  22994. * @param endValue defines the end value
  22995. * @param gradient defines the gradient factor
  22996. * @returns the new matrix
  22997. */
  22998. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  22999. /**
  23000. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23001. * @param startValue defines the start value
  23002. * @param endValue defines the end value
  23003. * @param gradient defines the gradient factor
  23004. * @param result defines the Matrix object where to store data
  23005. */
  23006. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23007. /**
  23008. * Builds a new matrix whose values are computed by:
  23009. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23010. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23011. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23012. * @param startValue defines the first matrix
  23013. * @param endValue defines the second matrix
  23014. * @param gradient defines the gradient between the two matrices
  23015. * @returns the new matrix
  23016. */
  23017. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23018. /**
  23019. * Update a matrix to values which are computed by:
  23020. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23021. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23022. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23023. * @param startValue defines the first matrix
  23024. * @param endValue defines the second matrix
  23025. * @param gradient defines the gradient between the two matrices
  23026. * @param result defines the target matrix
  23027. */
  23028. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23029. /**
  23030. * 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"
  23031. * This function works in left handed mode
  23032. * @param eye defines the final position of the entity
  23033. * @param target defines where the entity should look at
  23034. * @param up defines the up vector for the entity
  23035. * @returns the new matrix
  23036. */
  23037. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23038. /**
  23039. * 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".
  23040. * This function works in left handed mode
  23041. * @param eye defines the final position of the entity
  23042. * @param target defines where the entity should look at
  23043. * @param up defines the up vector for the entity
  23044. * @param result defines the target matrix
  23045. */
  23046. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23047. /**
  23048. * 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"
  23049. * This function works in right handed mode
  23050. * @param eye defines the final position of the entity
  23051. * @param target defines where the entity should look at
  23052. * @param up defines the up vector for the entity
  23053. * @returns the new matrix
  23054. */
  23055. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23056. /**
  23057. * 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".
  23058. * This function works in right handed mode
  23059. * @param eye defines the final position of the entity
  23060. * @param target defines where the entity should look at
  23061. * @param up defines the up vector for the entity
  23062. * @param result defines the target matrix
  23063. */
  23064. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23065. /**
  23066. * Create a left-handed orthographic projection matrix
  23067. * @param width defines the viewport width
  23068. * @param height defines the viewport height
  23069. * @param znear defines the near clip plane
  23070. * @param zfar defines the far clip plane
  23071. * @returns a new matrix as a left-handed orthographic projection matrix
  23072. */
  23073. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23074. /**
  23075. * Store a left-handed orthographic projection to a given matrix
  23076. * @param width defines the viewport width
  23077. * @param height defines the viewport height
  23078. * @param znear defines the near clip plane
  23079. * @param zfar defines the far clip plane
  23080. * @param result defines the target matrix
  23081. */
  23082. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23083. /**
  23084. * Create a left-handed orthographic projection matrix
  23085. * @param left defines the viewport left coordinate
  23086. * @param right defines the viewport right coordinate
  23087. * @param bottom defines the viewport bottom coordinate
  23088. * @param top defines the viewport top coordinate
  23089. * @param znear defines the near clip plane
  23090. * @param zfar defines the far clip plane
  23091. * @returns a new matrix as a left-handed orthographic projection matrix
  23092. */
  23093. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23094. /**
  23095. * Stores a left-handed orthographic projection into a given matrix
  23096. * @param left defines the viewport left coordinate
  23097. * @param right defines the viewport right coordinate
  23098. * @param bottom defines the viewport bottom coordinate
  23099. * @param top defines the viewport top coordinate
  23100. * @param znear defines the near clip plane
  23101. * @param zfar defines the far clip plane
  23102. * @param result defines the target matrix
  23103. */
  23104. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23105. /**
  23106. * Creates a right-handed orthographic projection matrix
  23107. * @param left defines the viewport left coordinate
  23108. * @param right defines the viewport right coordinate
  23109. * @param bottom defines the viewport bottom coordinate
  23110. * @param top defines the viewport top coordinate
  23111. * @param znear defines the near clip plane
  23112. * @param zfar defines the far clip plane
  23113. * @returns a new matrix as a right-handed orthographic projection matrix
  23114. */
  23115. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23116. /**
  23117. * Stores a right-handed orthographic projection into a given matrix
  23118. * @param left defines the viewport left coordinate
  23119. * @param right defines the viewport right coordinate
  23120. * @param bottom defines the viewport bottom coordinate
  23121. * @param top defines the viewport top coordinate
  23122. * @param znear defines the near clip plane
  23123. * @param zfar defines the far clip plane
  23124. * @param result defines the target matrix
  23125. */
  23126. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23127. /**
  23128. * Creates a left-handed perspective projection matrix
  23129. * @param width defines the viewport width
  23130. * @param height defines the viewport height
  23131. * @param znear defines the near clip plane
  23132. * @param zfar defines the far clip plane
  23133. * @returns a new matrix as a left-handed perspective projection matrix
  23134. */
  23135. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23136. /**
  23137. * Creates a left-handed perspective projection matrix
  23138. * @param fov defines the horizontal field of view
  23139. * @param aspect defines the aspect ratio
  23140. * @param znear defines the near clip plane
  23141. * @param zfar defines the far clip plane
  23142. * @returns a new matrix as a left-handed perspective projection matrix
  23143. */
  23144. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23145. /**
  23146. * Stores a left-handed perspective projection into a given matrix
  23147. * @param fov defines the horizontal field of view
  23148. * @param aspect defines the aspect ratio
  23149. * @param znear defines the near clip plane
  23150. * @param zfar defines the far clip plane
  23151. * @param result defines the target matrix
  23152. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23153. */
  23154. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23155. /**
  23156. * Creates a right-handed perspective projection matrix
  23157. * @param fov defines the horizontal field of view
  23158. * @param aspect defines the aspect ratio
  23159. * @param znear defines the near clip plane
  23160. * @param zfar defines the far clip plane
  23161. * @returns a new matrix as a right-handed perspective projection matrix
  23162. */
  23163. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23164. /**
  23165. * Stores a right-handed perspective projection into a given matrix
  23166. * @param fov defines the horizontal field of view
  23167. * @param aspect defines the aspect ratio
  23168. * @param znear defines the near clip plane
  23169. * @param zfar defines the far clip plane
  23170. * @param result defines the target matrix
  23171. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23172. */
  23173. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23174. /**
  23175. * Stores a perspective projection for WebVR info a given matrix
  23176. * @param fov defines the field of view
  23177. * @param znear defines the near clip plane
  23178. * @param zfar defines the far clip plane
  23179. * @param result defines the target matrix
  23180. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23181. */
  23182. static PerspectiveFovWebVRToRef(fov: {
  23183. upDegrees: number;
  23184. downDegrees: number;
  23185. leftDegrees: number;
  23186. rightDegrees: number;
  23187. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23188. /**
  23189. * Computes a complete transformation matrix
  23190. * @param viewport defines the viewport to use
  23191. * @param world defines the world matrix
  23192. * @param view defines the view matrix
  23193. * @param projection defines the projection matrix
  23194. * @param zmin defines the near clip plane
  23195. * @param zmax defines the far clip plane
  23196. * @returns the transformation matrix
  23197. */
  23198. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23199. /**
  23200. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23201. * @param matrix defines the matrix to use
  23202. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23203. */
  23204. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23205. /**
  23206. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23207. * @param matrix defines the matrix to use
  23208. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23209. */
  23210. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23211. /**
  23212. * Compute the transpose of a given matrix
  23213. * @param matrix defines the matrix to transpose
  23214. * @returns the new matrix
  23215. */
  23216. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23217. /**
  23218. * Compute the transpose of a matrix and store it in a target matrix
  23219. * @param matrix defines the matrix to transpose
  23220. * @param result defines the target matrix
  23221. */
  23222. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23223. /**
  23224. * Computes a reflection matrix from a plane
  23225. * @param plane defines the reflection plane
  23226. * @returns a new matrix
  23227. */
  23228. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23229. /**
  23230. * Computes a reflection matrix from a plane
  23231. * @param plane defines the reflection plane
  23232. * @param result defines the target matrix
  23233. */
  23234. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23235. /**
  23236. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23237. * @param xaxis defines the value of the 1st axis
  23238. * @param yaxis defines the value of the 2nd axis
  23239. * @param zaxis defines the value of the 3rd axis
  23240. * @param result defines the target matrix
  23241. */
  23242. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23243. /**
  23244. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23245. * @param quat defines the quaternion to use
  23246. * @param result defines the target matrix
  23247. */
  23248. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23249. }
  23250. /**
  23251. * Represens a plane by the equation ax + by + cz + d = 0
  23252. */
  23253. class Plane {
  23254. /**
  23255. * Normal of the plane (a,b,c)
  23256. */
  23257. normal: Vector3;
  23258. /**
  23259. * d component of the plane
  23260. */
  23261. d: number;
  23262. /**
  23263. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23264. * @param a a component of the plane
  23265. * @param b b component of the plane
  23266. * @param c c component of the plane
  23267. * @param d d component of the plane
  23268. */
  23269. constructor(a: number, b: number, c: number, d: number);
  23270. /**
  23271. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23272. */
  23273. asArray(): number[];
  23274. /**
  23275. * @returns a new plane copied from the current Plane.
  23276. */
  23277. clone(): Plane;
  23278. /**
  23279. * @returns the string "Plane".
  23280. */
  23281. getClassName(): string;
  23282. /**
  23283. * @returns the Plane hash code.
  23284. */
  23285. getHashCode(): number;
  23286. /**
  23287. * Normalize the current Plane in place.
  23288. * @returns the updated Plane.
  23289. */
  23290. normalize(): Plane;
  23291. /**
  23292. * Applies a transformation the plane and returns the result
  23293. * @param transformation the transformation matrix to be applied to the plane
  23294. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23295. */
  23296. transform(transformation: DeepImmutable<Matrix>): Plane;
  23297. /**
  23298. * Calcualtte the dot product between the point and the plane normal
  23299. * @param point point to calculate the dot product with
  23300. * @returns the dot product (float) of the point coordinates and the plane normal.
  23301. */
  23302. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23303. /**
  23304. * Updates the current Plane from the plane defined by the three given points.
  23305. * @param point1 one of the points used to contruct the plane
  23306. * @param point2 one of the points used to contruct the plane
  23307. * @param point3 one of the points used to contruct the plane
  23308. * @returns the updated Plane.
  23309. */
  23310. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23311. /**
  23312. * Checks if the plane is facing a given direction
  23313. * @param direction the direction to check if the plane is facing
  23314. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23315. * @returns True is the vector "direction" is the same side than the plane normal.
  23316. */
  23317. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23318. /**
  23319. * Calculates the distance to a point
  23320. * @param point point to calculate distance to
  23321. * @returns the signed distance (float) from the given point to the Plane.
  23322. */
  23323. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23324. /**
  23325. * Creates a plane from an array
  23326. * @param array the array to create a plane from
  23327. * @returns a new Plane from the given array.
  23328. */
  23329. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23330. /**
  23331. * Creates a plane from three points
  23332. * @param point1 point used to create the plane
  23333. * @param point2 point used to create the plane
  23334. * @param point3 point used to create the plane
  23335. * @returns a new Plane defined by the three given points.
  23336. */
  23337. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23338. /**
  23339. * Creates a plane from an origin point and a normal
  23340. * @param origin origin of the plane to be constructed
  23341. * @param normal normal of the plane to be constructed
  23342. * @returns a new Plane the normal vector to this plane at the given origin point.
  23343. * Note : the vector "normal" is updated because normalized.
  23344. */
  23345. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23346. /**
  23347. * Calculates the distance from a plane and a point
  23348. * @param origin origin of the plane to be constructed
  23349. * @param normal normal of the plane to be constructed
  23350. * @param point point to calculate distance to
  23351. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23352. */
  23353. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23354. }
  23355. /**
  23356. * Class used to represent a viewport on screen
  23357. */
  23358. class Viewport {
  23359. /** viewport left coordinate */
  23360. x: number;
  23361. /** viewport top coordinate */
  23362. y: number;
  23363. /**viewport width */
  23364. width: number;
  23365. /** viewport height */
  23366. height: number;
  23367. /**
  23368. * Creates a Viewport object located at (x, y) and sized (width, height)
  23369. * @param x defines viewport left coordinate
  23370. * @param y defines viewport top coordinate
  23371. * @param width defines the viewport width
  23372. * @param height defines the viewport height
  23373. */
  23374. constructor(
  23375. /** viewport left coordinate */
  23376. x: number,
  23377. /** viewport top coordinate */
  23378. y: number,
  23379. /**viewport width */
  23380. width: number,
  23381. /** viewport height */
  23382. height: number);
  23383. /**
  23384. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23385. * @param renderWidthOrEngine defines either an engine or the rendering width
  23386. * @param renderHeight defines the rendering height
  23387. * @returns a new Viewport
  23388. */
  23389. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23390. /**
  23391. * Returns a new Viewport copied from the current one
  23392. * @returns a new Viewport
  23393. */
  23394. clone(): Viewport;
  23395. }
  23396. /**
  23397. * Reprasents a camera frustum
  23398. */
  23399. class Frustum {
  23400. /**
  23401. * Gets the planes representing the frustum
  23402. * @param transform matrix to be applied to the returned planes
  23403. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23404. */
  23405. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23406. /**
  23407. * Gets the near frustum plane transformed by the transform matrix
  23408. * @param transform transformation matrix to be applied to the resulting frustum plane
  23409. * @param frustumPlane the resuling frustum plane
  23410. */
  23411. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23412. /**
  23413. * Gets the far frustum plane transformed by the transform matrix
  23414. * @param transform transformation matrix to be applied to the resulting frustum plane
  23415. * @param frustumPlane the resuling frustum plane
  23416. */
  23417. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23418. /**
  23419. * Gets the left frustum plane transformed by the transform matrix
  23420. * @param transform transformation matrix to be applied to the resulting frustum plane
  23421. * @param frustumPlane the resuling frustum plane
  23422. */
  23423. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23424. /**
  23425. * Gets the right frustum plane transformed by the transform matrix
  23426. * @param transform transformation matrix to be applied to the resulting frustum plane
  23427. * @param frustumPlane the resuling frustum plane
  23428. */
  23429. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23430. /**
  23431. * Gets the top frustum plane transformed by the transform matrix
  23432. * @param transform transformation matrix to be applied to the resulting frustum plane
  23433. * @param frustumPlane the resuling frustum plane
  23434. */
  23435. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23436. /**
  23437. * Gets the bottom frustum plane transformed by the transform matrix
  23438. * @param transform transformation matrix to be applied to the resulting frustum plane
  23439. * @param frustumPlane the resuling frustum plane
  23440. */
  23441. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23442. /**
  23443. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23444. * @param transform transformation matrix to be applied to the resulting frustum planes
  23445. * @param frustumPlanes the resuling frustum planes
  23446. */
  23447. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23448. }
  23449. /** Defines supported spaces */
  23450. enum Space {
  23451. /** Local (object) space */
  23452. LOCAL = 0,
  23453. /** World space */
  23454. WORLD = 1,
  23455. /** Bone space */
  23456. BONE = 2
  23457. }
  23458. /** Defines the 3 main axes */
  23459. class Axis {
  23460. /** X axis */
  23461. static X: Vector3;
  23462. /** Y axis */
  23463. static Y: Vector3;
  23464. /** Z axis */
  23465. static Z: Vector3;
  23466. }
  23467. /** Class used to represent a Bezier curve */
  23468. class BezierCurve {
  23469. /**
  23470. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23471. * @param t defines the time
  23472. * @param x1 defines the left coordinate on X axis
  23473. * @param y1 defines the left coordinate on Y axis
  23474. * @param x2 defines the right coordinate on X axis
  23475. * @param y2 defines the right coordinate on Y axis
  23476. * @returns the interpolated value
  23477. */
  23478. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23479. }
  23480. /**
  23481. * Defines potential orientation for back face culling
  23482. */
  23483. enum Orientation {
  23484. /**
  23485. * Clockwise
  23486. */
  23487. CW = 0,
  23488. /** Counter clockwise */
  23489. CCW = 1
  23490. }
  23491. /**
  23492. * Defines angle representation
  23493. */
  23494. class Angle {
  23495. private _radians;
  23496. /**
  23497. * Creates an Angle object of "radians" radians (float).
  23498. */
  23499. constructor(radians: number);
  23500. /**
  23501. * Get value in degrees
  23502. * @returns the Angle value in degrees (float)
  23503. */
  23504. degrees(): number;
  23505. /**
  23506. * Get value in radians
  23507. * @returns the Angle value in radians (float)
  23508. */
  23509. radians(): number;
  23510. /**
  23511. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23512. * @param a defines first vector
  23513. * @param b defines second vector
  23514. * @returns a new Angle
  23515. */
  23516. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23517. /**
  23518. * Gets a new Angle object from the given float in radians
  23519. * @param radians defines the angle value in radians
  23520. * @returns a new Angle
  23521. */
  23522. static FromRadians(radians: number): Angle;
  23523. /**
  23524. * Gets a new Angle object from the given float in degrees
  23525. * @param degrees defines the angle value in degrees
  23526. * @returns a new Angle
  23527. */
  23528. static FromDegrees(degrees: number): Angle;
  23529. }
  23530. /**
  23531. * This represents an arc in a 2d space.
  23532. */
  23533. class Arc2 {
  23534. /** Defines the start point of the arc */
  23535. startPoint: Vector2;
  23536. /** Defines the mid point of the arc */
  23537. midPoint: Vector2;
  23538. /** Defines the end point of the arc */
  23539. endPoint: Vector2;
  23540. /**
  23541. * Defines the center point of the arc.
  23542. */
  23543. centerPoint: Vector2;
  23544. /**
  23545. * Defines the radius of the arc.
  23546. */
  23547. radius: number;
  23548. /**
  23549. * Defines the angle of the arc (from mid point to end point).
  23550. */
  23551. angle: Angle;
  23552. /**
  23553. * Defines the start angle of the arc (from start point to middle point).
  23554. */
  23555. startAngle: Angle;
  23556. /**
  23557. * Defines the orientation of the arc (clock wise/counter clock wise).
  23558. */
  23559. orientation: Orientation;
  23560. /**
  23561. * Creates an Arc object from the three given points : start, middle and end.
  23562. * @param startPoint Defines the start point of the arc
  23563. * @param midPoint Defines the midlle point of the arc
  23564. * @param endPoint Defines the end point of the arc
  23565. */
  23566. constructor(
  23567. /** Defines the start point of the arc */
  23568. startPoint: Vector2,
  23569. /** Defines the mid point of the arc */
  23570. midPoint: Vector2,
  23571. /** Defines the end point of the arc */
  23572. endPoint: Vector2);
  23573. }
  23574. /**
  23575. * Represents a 2D path made up of multiple 2D points
  23576. */
  23577. class Path2 {
  23578. private _points;
  23579. private _length;
  23580. /**
  23581. * If the path start and end point are the same
  23582. */
  23583. closed: boolean;
  23584. /**
  23585. * Creates a Path2 object from the starting 2D coordinates x and y.
  23586. * @param x the starting points x value
  23587. * @param y the starting points y value
  23588. */
  23589. constructor(x: number, y: number);
  23590. /**
  23591. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23592. * @param x the added points x value
  23593. * @param y the added points y value
  23594. * @returns the updated Path2.
  23595. */
  23596. addLineTo(x: number, y: number): Path2;
  23597. /**
  23598. * 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.
  23599. * @param midX middle point x value
  23600. * @param midY middle point y value
  23601. * @param endX end point x value
  23602. * @param endY end point y value
  23603. * @param numberOfSegments (default: 36)
  23604. * @returns the updated Path2.
  23605. */
  23606. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23607. /**
  23608. * Closes the Path2.
  23609. * @returns the Path2.
  23610. */
  23611. close(): Path2;
  23612. /**
  23613. * Gets the sum of the distance between each sequential point in the path
  23614. * @returns the Path2 total length (float).
  23615. */
  23616. length(): number;
  23617. /**
  23618. * Gets the points which construct the path
  23619. * @returns the Path2 internal array of points.
  23620. */
  23621. getPoints(): Vector2[];
  23622. /**
  23623. * Retreives the point at the distance aways from the starting point
  23624. * @param normalizedLengthPosition the length along the path to retreive the point from
  23625. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23626. */
  23627. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23628. /**
  23629. * Creates a new path starting from an x and y position
  23630. * @param x starting x value
  23631. * @param y starting y value
  23632. * @returns a new Path2 starting at the coordinates (x, y).
  23633. */
  23634. static StartingAt(x: number, y: number): Path2;
  23635. }
  23636. /**
  23637. * Represents a 3D path made up of multiple 3D points
  23638. */
  23639. class Path3D {
  23640. /**
  23641. * an array of Vector3, the curve axis of the Path3D
  23642. */
  23643. path: Vector3[];
  23644. private _curve;
  23645. private _distances;
  23646. private _tangents;
  23647. private _normals;
  23648. private _binormals;
  23649. private _raw;
  23650. /**
  23651. * new Path3D(path, normal, raw)
  23652. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23653. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  23654. * @param path an array of Vector3, the curve axis of the Path3D
  23655. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23656. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23657. */
  23658. constructor(
  23659. /**
  23660. * an array of Vector3, the curve axis of the Path3D
  23661. */
  23662. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23663. /**
  23664. * Returns the Path3D array of successive Vector3 designing its curve.
  23665. * @returns the Path3D array of successive Vector3 designing its curve.
  23666. */
  23667. getCurve(): Vector3[];
  23668. /**
  23669. * Returns an array populated with tangent vectors on each Path3D curve point.
  23670. * @returns an array populated with tangent vectors on each Path3D curve point.
  23671. */
  23672. getTangents(): Vector3[];
  23673. /**
  23674. * Returns an array populated with normal vectors on each Path3D curve point.
  23675. * @returns an array populated with normal vectors on each Path3D curve point.
  23676. */
  23677. getNormals(): Vector3[];
  23678. /**
  23679. * Returns an array populated with binormal vectors on each Path3D curve point.
  23680. * @returns an array populated with binormal vectors on each Path3D curve point.
  23681. */
  23682. getBinormals(): Vector3[];
  23683. /**
  23684. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23685. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23686. */
  23687. getDistances(): number[];
  23688. /**
  23689. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23690. * @param path path which all values are copied into the curves points
  23691. * @param firstNormal which should be projected onto the curve
  23692. * @returns the same object updated.
  23693. */
  23694. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23695. private _compute;
  23696. private _getFirstNonNullVector;
  23697. private _getLastNonNullVector;
  23698. private _normalVector;
  23699. }
  23700. /**
  23701. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23702. * A Curve3 is designed from a series of successive Vector3.
  23703. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23704. */
  23705. class Curve3 {
  23706. private _points;
  23707. private _length;
  23708. /**
  23709. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  23710. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23711. * @param v1 (Vector3) the control point
  23712. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23713. * @param nbPoints (integer) the wanted number of points in the curve
  23714. * @returns the created Curve3
  23715. */
  23716. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23717. /**
  23718. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  23719. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23720. * @param v1 (Vector3) the first control point
  23721. * @param v2 (Vector3) the second control point
  23722. * @param v3 (Vector3) the end point of the Cubic Bezier
  23723. * @param nbPoints (integer) the wanted number of points in the curve
  23724. * @returns the created Curve3
  23725. */
  23726. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23727. /**
  23728. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  23729. * @param p1 (Vector3) the origin point of the Hermite Spline
  23730. * @param t1 (Vector3) the tangent vector at the origin point
  23731. * @param p2 (Vector3) the end point of the Hermite Spline
  23732. * @param t2 (Vector3) the tangent vector at the end point
  23733. * @param nbPoints (integer) the wanted number of points in the curve
  23734. * @returns the created Curve3
  23735. */
  23736. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23737. /**
  23738. * Returns a Curve3 object along a CatmullRom Spline curve :
  23739. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23740. * @param nbPoints (integer) the wanted number of points between each curve control points
  23741. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23742. * @returns the created Curve3
  23743. */
  23744. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  23745. /**
  23746. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23747. * A Curve3 is designed from a series of successive Vector3.
  23748. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  23749. * @param points points which make up the curve
  23750. */
  23751. constructor(points: Vector3[]);
  23752. /**
  23753. * @returns the Curve3 stored array of successive Vector3
  23754. */
  23755. getPoints(): Vector3[];
  23756. /**
  23757. * @returns the computed length (float) of the curve.
  23758. */
  23759. length(): number;
  23760. /**
  23761. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23762. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23763. * curveA and curveB keep unchanged.
  23764. * @param curve the curve to continue from this curve
  23765. * @returns the newly constructed curve
  23766. */
  23767. continue(curve: DeepImmutable<Curve3>): Curve3;
  23768. private _computeLength;
  23769. }
  23770. /**
  23771. * Contains position and normal vectors for a vertex
  23772. */
  23773. class PositionNormalVertex {
  23774. /** the position of the vertex (defaut: 0,0,0) */
  23775. position: Vector3;
  23776. /** the normal of the vertex (defaut: 0,1,0) */
  23777. normal: Vector3;
  23778. /**
  23779. * Creates a PositionNormalVertex
  23780. * @param position the position of the vertex (defaut: 0,0,0)
  23781. * @param normal the normal of the vertex (defaut: 0,1,0)
  23782. */
  23783. constructor(
  23784. /** the position of the vertex (defaut: 0,0,0) */
  23785. position?: Vector3,
  23786. /** the normal of the vertex (defaut: 0,1,0) */
  23787. normal?: Vector3);
  23788. /**
  23789. * Clones the PositionNormalVertex
  23790. * @returns the cloned PositionNormalVertex
  23791. */
  23792. clone(): PositionNormalVertex;
  23793. }
  23794. /**
  23795. * Contains position, normal and uv vectors for a vertex
  23796. */
  23797. class PositionNormalTextureVertex {
  23798. /** the position of the vertex (defaut: 0,0,0) */
  23799. position: Vector3;
  23800. /** the normal of the vertex (defaut: 0,1,0) */
  23801. normal: Vector3;
  23802. /** the uv of the vertex (default: 0,0) */
  23803. uv: Vector2;
  23804. /**
  23805. * Creates a PositionNormalTextureVertex
  23806. * @param position the position of the vertex (defaut: 0,0,0)
  23807. * @param normal the normal of the vertex (defaut: 0,1,0)
  23808. * @param uv the uv of the vertex (default: 0,0)
  23809. */
  23810. constructor(
  23811. /** the position of the vertex (defaut: 0,0,0) */
  23812. position?: Vector3,
  23813. /** the normal of the vertex (defaut: 0,1,0) */
  23814. normal?: Vector3,
  23815. /** the uv of the vertex (default: 0,0) */
  23816. uv?: Vector2);
  23817. /**
  23818. * Clones the PositionNormalTextureVertex
  23819. * @returns the cloned PositionNormalTextureVertex
  23820. */
  23821. clone(): PositionNormalTextureVertex;
  23822. }
  23823. /**
  23824. * @hidden
  23825. */
  23826. class Tmp {
  23827. static Color3: Color3[];
  23828. static Color4: Color4[];
  23829. static Vector2: Vector2[];
  23830. static Vector3: Vector3[];
  23831. static Vector4: Vector4[];
  23832. static Quaternion: Quaternion[];
  23833. static Matrix: Matrix[];
  23834. }
  23835. }
  23836. declare module BABYLON {
  23837. /**
  23838. * Class representing spherical polynomial coefficients to the 3rd degree
  23839. */
  23840. class SphericalPolynomial {
  23841. /**
  23842. * The x coefficients of the spherical polynomial
  23843. */
  23844. x: Vector3;
  23845. /**
  23846. * The y coefficients of the spherical polynomial
  23847. */
  23848. y: Vector3;
  23849. /**
  23850. * The z coefficients of the spherical polynomial
  23851. */
  23852. z: Vector3;
  23853. /**
  23854. * The xx coefficients of the spherical polynomial
  23855. */
  23856. xx: Vector3;
  23857. /**
  23858. * The yy coefficients of the spherical polynomial
  23859. */
  23860. yy: Vector3;
  23861. /**
  23862. * The zz coefficients of the spherical polynomial
  23863. */
  23864. zz: Vector3;
  23865. /**
  23866. * The xy coefficients of the spherical polynomial
  23867. */
  23868. xy: Vector3;
  23869. /**
  23870. * The yz coefficients of the spherical polynomial
  23871. */
  23872. yz: Vector3;
  23873. /**
  23874. * The zx coefficients of the spherical polynomial
  23875. */
  23876. zx: Vector3;
  23877. /**
  23878. * Adds an ambient color to the spherical polynomial
  23879. * @param color the color to add
  23880. */
  23881. addAmbient(color: Color3): void;
  23882. /**
  23883. * Scales the spherical polynomial by the given amount
  23884. * @param scale the amount to scale
  23885. */
  23886. scale(scale: number): void;
  23887. /**
  23888. * Gets the spherical polynomial from harmonics
  23889. * @param harmonics the spherical harmonics
  23890. * @returns the spherical polynomial
  23891. */
  23892. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23893. /**
  23894. * Constructs a spherical polynomial from an array.
  23895. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23896. * @returns the spherical polynomial
  23897. */
  23898. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23899. }
  23900. /**
  23901. * Class representing spherical harmonics coefficients to the 3rd degree
  23902. */
  23903. class SphericalHarmonics {
  23904. /**
  23905. * The l0,0 coefficients of the spherical harmonics
  23906. */
  23907. l00: Vector3;
  23908. /**
  23909. * The l1,-1 coefficients of the spherical harmonics
  23910. */
  23911. l1_1: Vector3;
  23912. /**
  23913. * The l1,0 coefficients of the spherical harmonics
  23914. */
  23915. l10: Vector3;
  23916. /**
  23917. * The l1,1 coefficients of the spherical harmonics
  23918. */
  23919. l11: Vector3;
  23920. /**
  23921. * The l2,-2 coefficients of the spherical harmonics
  23922. */
  23923. l2_2: Vector3;
  23924. /**
  23925. * The l2,-1 coefficients of the spherical harmonics
  23926. */
  23927. l2_1: Vector3;
  23928. /**
  23929. * The l2,0 coefficients of the spherical harmonics
  23930. */
  23931. l20: Vector3;
  23932. /**
  23933. * The l2,1 coefficients of the spherical harmonics
  23934. */
  23935. l21: Vector3;
  23936. /**
  23937. * The l2,2 coefficients of the spherical harmonics
  23938. */
  23939. lL22: Vector3;
  23940. /**
  23941. * Adds a light to the spherical harmonics
  23942. * @param direction the direction of the light
  23943. * @param color the color of the light
  23944. * @param deltaSolidAngle the delta solid angle of the light
  23945. */
  23946. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23947. /**
  23948. * Scales the spherical harmonics by the given amount
  23949. * @param scale the amount to scale
  23950. */
  23951. scale(scale: number): void;
  23952. /**
  23953. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23954. *
  23955. * ```
  23956. * E_lm = A_l * L_lm
  23957. * ```
  23958. *
  23959. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23960. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23961. * the scaling factors are given in equation 9.
  23962. */
  23963. convertIncidentRadianceToIrradiance(): void;
  23964. /**
  23965. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23966. *
  23967. * ```
  23968. * L = (1/pi) * E * rho
  23969. * ```
  23970. *
  23971. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23972. */
  23973. convertIrradianceToLambertianRadiance(): void;
  23974. /**
  23975. * Gets the spherical harmonics from polynomial
  23976. * @param polynomial the spherical polynomial
  23977. * @returns the spherical harmonics
  23978. */
  23979. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23980. /**
  23981. * Constructs a spherical harmonics from an array.
  23982. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23983. * @returns the spherical harmonics
  23984. */
  23985. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23986. }
  23987. }
  23988. declare module BABYLON {
  23989. /**
  23990. * Class used to store all common mesh properties
  23991. */
  23992. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23993. /** No occlusion */
  23994. static OCCLUSION_TYPE_NONE: number;
  23995. /** Occlusion set to optimisitic */
  23996. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23997. /** Occlusion set to strict */
  23998. static OCCLUSION_TYPE_STRICT: number;
  23999. /** Use an accurante occlusion algorithm */
  24000. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24001. /** Use a conservative occlusion algorithm */
  24002. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24003. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24004. * Test order :
  24005. * Is the bounding sphere outside the frustum ?
  24006. * If not, are the bounding box vertices outside the frustum ?
  24007. * It not, then the cullable object is in the frustum.
  24008. */
  24009. static readonly CULLINGSTRATEGY_STANDARD: number;
  24010. /** Culling strategy : Bounding Sphere Only.
  24011. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24012. * It's also less accurate than the standard because some not visible objects can still be selected.
  24013. * Test : is the bounding sphere outside the frustum ?
  24014. * If not, then the cullable object is in the frustum.
  24015. */
  24016. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24017. /** Culling strategy : Optimistic Inclusion.
  24018. * This in an inclusion test first, then the standard exclusion test.
  24019. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24020. * 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.
  24021. * Anyway, it's as accurate as the standard strategy.
  24022. * Test :
  24023. * Is the cullable object bounding sphere center in the frustum ?
  24024. * If not, apply the default culling strategy.
  24025. */
  24026. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24027. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24028. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24029. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24030. * 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.
  24031. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24032. * Test :
  24033. * Is the cullable object bounding sphere center in the frustum ?
  24034. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24035. */
  24036. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24037. /**
  24038. * No billboard
  24039. */
  24040. static readonly BILLBOARDMODE_NONE: number;
  24041. /** Billboard on X axis */
  24042. static readonly BILLBOARDMODE_X: number;
  24043. /** Billboard on Y axis */
  24044. static readonly BILLBOARDMODE_Y: number;
  24045. /** Billboard on Z axis */
  24046. static readonly BILLBOARDMODE_Z: number;
  24047. /** Billboard on all axes */
  24048. static readonly BILLBOARDMODE_ALL: number;
  24049. private _facetData;
  24050. /**
  24051. * The culling strategy to use to check whether the mesh must be rendered or not.
  24052. * This value can be changed at any time and will be used on the next render mesh selection.
  24053. * The possible values are :
  24054. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24055. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24056. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24057. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24058. * Please read each static variable documentation to get details about the culling process.
  24059. * */
  24060. cullingStrategy: number;
  24061. /**
  24062. * Gets the number of facets in the mesh
  24063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24064. */
  24065. readonly facetNb: number;
  24066. /**
  24067. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24069. */
  24070. partitioningSubdivisions: number;
  24071. /**
  24072. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24073. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24075. */
  24076. partitioningBBoxRatio: number;
  24077. /**
  24078. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24079. * Works only for updatable meshes.
  24080. * Doesn't work with multi-materials
  24081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24082. */
  24083. mustDepthSortFacets: boolean;
  24084. /**
  24085. * The location (Vector3) where the facet depth sort must be computed from.
  24086. * By default, the active camera position.
  24087. * Used only when facet depth sort is enabled
  24088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24089. */
  24090. facetDepthSortFrom: Vector3;
  24091. /**
  24092. * gets a boolean indicating if facetData is enabled
  24093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24094. */
  24095. readonly isFacetDataEnabled: boolean;
  24096. /** @hidden */
  24097. _updateNonUniformScalingState(value: boolean): boolean;
  24098. /**
  24099. * An event triggered when this mesh collides with another one
  24100. */
  24101. onCollideObservable: Observable<AbstractMesh>;
  24102. private _onCollideObserver;
  24103. /** Set a function to call when this mesh collides with another one */
  24104. onCollide: () => void;
  24105. /**
  24106. * An event triggered when the collision's position changes
  24107. */
  24108. onCollisionPositionChangeObservable: Observable<Vector3>;
  24109. private _onCollisionPositionChangeObserver;
  24110. /** Set a function to call when the collision's position changes */
  24111. onCollisionPositionChange: () => void;
  24112. /**
  24113. * An event triggered when material is changed
  24114. */
  24115. onMaterialChangedObservable: Observable<AbstractMesh>;
  24116. /**
  24117. * Gets or sets the orientation for POV movement & rotation
  24118. */
  24119. definedFacingForward: boolean;
  24120. /** @hidden */
  24121. _occlusionQuery: Nullable<WebGLQuery>;
  24122. private _visibility;
  24123. /**
  24124. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24125. */
  24126. /**
  24127. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24128. */
  24129. visibility: number;
  24130. /** Gets or sets the alpha index used to sort transparent meshes
  24131. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24132. */
  24133. alphaIndex: number;
  24134. /**
  24135. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24136. */
  24137. isVisible: boolean;
  24138. /**
  24139. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24140. */
  24141. isPickable: boolean;
  24142. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24143. showSubMeshesBoundingBox: boolean;
  24144. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24145. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24146. */
  24147. isBlocker: boolean;
  24148. /**
  24149. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24150. */
  24151. enablePointerMoveEvents: boolean;
  24152. /**
  24153. * Specifies the rendering group id for this mesh (0 by default)
  24154. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24155. */
  24156. renderingGroupId: number;
  24157. private _material;
  24158. /** Gets or sets current material */
  24159. material: Nullable<Material>;
  24160. private _receiveShadows;
  24161. /**
  24162. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24163. * @see http://doc.babylonjs.com/babylon101/shadows
  24164. */
  24165. receiveShadows: boolean;
  24166. /** Defines color to use when rendering outline */
  24167. outlineColor: Color3;
  24168. /** Define width to use when rendering outline */
  24169. outlineWidth: number;
  24170. /** Defines color to use when rendering overlay */
  24171. overlayColor: Color3;
  24172. /** Defines alpha to use when rendering overlay */
  24173. overlayAlpha: number;
  24174. private _hasVertexAlpha;
  24175. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24176. hasVertexAlpha: boolean;
  24177. private _useVertexColors;
  24178. /** 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) */
  24179. useVertexColors: boolean;
  24180. private _computeBonesUsingShaders;
  24181. /**
  24182. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24183. */
  24184. computeBonesUsingShaders: boolean;
  24185. private _numBoneInfluencers;
  24186. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24187. numBoneInfluencers: number;
  24188. private _applyFog;
  24189. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24190. applyFog: boolean;
  24191. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24192. useOctreeForRenderingSelection: boolean;
  24193. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24194. useOctreeForPicking: boolean;
  24195. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24196. useOctreeForCollisions: boolean;
  24197. private _layerMask;
  24198. /**
  24199. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24200. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24201. */
  24202. layerMask: number;
  24203. /**
  24204. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24205. */
  24206. alwaysSelectAsActiveMesh: boolean;
  24207. /**
  24208. * Gets or sets the current action manager
  24209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24210. */
  24211. actionManager: Nullable<ActionManager>;
  24212. private _checkCollisions;
  24213. private _collisionMask;
  24214. private _collisionGroup;
  24215. /**
  24216. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24218. */
  24219. ellipsoid: Vector3;
  24220. /**
  24221. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24222. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24223. */
  24224. ellipsoidOffset: Vector3;
  24225. private _collider;
  24226. private _oldPositionForCollisions;
  24227. private _diffPositionForCollisions;
  24228. /**
  24229. * Gets or sets a collision mask used to mask collisions (default is -1).
  24230. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24231. */
  24232. collisionMask: number;
  24233. /**
  24234. * Gets or sets the current collision group mask (-1 by default).
  24235. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24236. */
  24237. collisionGroup: number;
  24238. /**
  24239. * Defines edge width used when edgesRenderer is enabled
  24240. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24241. */
  24242. edgesWidth: number;
  24243. /**
  24244. * Defines edge color used when edgesRenderer is enabled
  24245. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24246. */
  24247. edgesColor: Color4;
  24248. /** @hidden */
  24249. _edgesRenderer: Nullable<IEdgesRenderer>;
  24250. /** @hidden */
  24251. _masterMesh: Nullable<AbstractMesh>;
  24252. /** @hidden */
  24253. _boundingInfo: Nullable<BoundingInfo>;
  24254. /** @hidden */
  24255. _renderId: number;
  24256. /**
  24257. * Gets or sets the list of subMeshes
  24258. * @see http://doc.babylonjs.com/how_to/multi_materials
  24259. */
  24260. subMeshes: SubMesh[];
  24261. /** @hidden */
  24262. _intersectionsInProgress: AbstractMesh[];
  24263. /** @hidden */
  24264. _unIndexed: boolean;
  24265. /** @hidden */
  24266. _lightSources: Light[];
  24267. /** @hidden */
  24268. readonly _positions: Nullable<Vector3[]>;
  24269. /** @hidden */
  24270. _waitingActions: any;
  24271. /** @hidden */
  24272. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24273. private _skeleton;
  24274. /** @hidden */
  24275. _bonesTransformMatrices: Nullable<Float32Array>;
  24276. /**
  24277. * Gets or sets a skeleton to apply skining transformations
  24278. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24279. */
  24280. skeleton: Nullable<Skeleton>;
  24281. /**
  24282. * An event triggered when the mesh is rebuilt.
  24283. */
  24284. onRebuildObservable: Observable<AbstractMesh>;
  24285. /**
  24286. * Creates a new AbstractMesh
  24287. * @param name defines the name of the mesh
  24288. * @param scene defines the hosting scene
  24289. */
  24290. constructor(name: string, scene?: Nullable<Scene>);
  24291. /**
  24292. * Returns the string "AbstractMesh"
  24293. * @returns "AbstractMesh"
  24294. */
  24295. getClassName(): string;
  24296. /**
  24297. * Gets a string representation of the current mesh
  24298. * @param fullDetails defines a boolean indicating if full details must be included
  24299. * @returns a string representation of the current mesh
  24300. */
  24301. toString(fullDetails?: boolean): string;
  24302. /** @hidden */
  24303. _rebuild(): void;
  24304. /** @hidden */
  24305. _resyncLightSources(): void;
  24306. /** @hidden */
  24307. _resyncLighSource(light: Light): void;
  24308. /** @hidden */
  24309. _unBindEffect(): void;
  24310. /** @hidden */
  24311. _removeLightSource(light: Light): void;
  24312. private _markSubMeshesAsDirty;
  24313. /** @hidden */
  24314. _markSubMeshesAsLightDirty(): void;
  24315. /** @hidden */
  24316. _markSubMeshesAsAttributesDirty(): void;
  24317. /** @hidden */
  24318. _markSubMeshesAsMiscDirty(): void;
  24319. /**
  24320. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24321. */
  24322. scaling: Vector3;
  24323. /**
  24324. * Returns true if the mesh is blocked. Implemented by child classes
  24325. */
  24326. readonly isBlocked: boolean;
  24327. /**
  24328. * Returns the mesh itself by default. Implemented by child classes
  24329. * @param camera defines the camera to use to pick the right LOD level
  24330. * @returns the currentAbstractMesh
  24331. */
  24332. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24333. /**
  24334. * Returns 0 by default. Implemented by child classes
  24335. * @returns an integer
  24336. */
  24337. getTotalVertices(): number;
  24338. /**
  24339. * Returns a positive integer : the total number of indices in this mesh geometry.
  24340. * @returns the numner of indices or zero if the mesh has no geometry.
  24341. */
  24342. getTotalIndices(): number;
  24343. /**
  24344. * Returns null by default. Implemented by child classes
  24345. * @returns null
  24346. */
  24347. getIndices(): Nullable<IndicesArray>;
  24348. /**
  24349. * Returns the array of the requested vertex data kind. Implemented by child classes
  24350. * @param kind defines the vertex data kind to use
  24351. * @returns null
  24352. */
  24353. getVerticesData(kind: string): Nullable<FloatArray>;
  24354. /**
  24355. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24356. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24357. * Note that a new underlying VertexBuffer object is created each call.
  24358. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24359. * @param kind defines vertex data kind:
  24360. * * BABYLON.VertexBuffer.PositionKind
  24361. * * BABYLON.VertexBuffer.UVKind
  24362. * * BABYLON.VertexBuffer.UV2Kind
  24363. * * BABYLON.VertexBuffer.UV3Kind
  24364. * * BABYLON.VertexBuffer.UV4Kind
  24365. * * BABYLON.VertexBuffer.UV5Kind
  24366. * * BABYLON.VertexBuffer.UV6Kind
  24367. * * BABYLON.VertexBuffer.ColorKind
  24368. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24369. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24370. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24371. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24372. * @param data defines the data source
  24373. * @param updatable defines if the data must be flagged as updatable (or static)
  24374. * @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
  24375. * @returns the current mesh
  24376. */
  24377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24378. /**
  24379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24380. * If the mesh has no geometry, it is simply returned as it is.
  24381. * @param kind defines vertex data kind:
  24382. * * BABYLON.VertexBuffer.PositionKind
  24383. * * BABYLON.VertexBuffer.UVKind
  24384. * * BABYLON.VertexBuffer.UV2Kind
  24385. * * BABYLON.VertexBuffer.UV3Kind
  24386. * * BABYLON.VertexBuffer.UV4Kind
  24387. * * BABYLON.VertexBuffer.UV5Kind
  24388. * * BABYLON.VertexBuffer.UV6Kind
  24389. * * BABYLON.VertexBuffer.ColorKind
  24390. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24391. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24392. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24393. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24394. * @param data defines the data source
  24395. * @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
  24396. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24397. * @returns the current mesh
  24398. */
  24399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24400. /**
  24401. * Sets the mesh indices,
  24402. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24403. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24404. * @param totalVertices Defines the total number of vertices
  24405. * @returns the current mesh
  24406. */
  24407. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24408. /**
  24409. * Gets a boolean indicating if specific vertex data is present
  24410. * @param kind defines the vertex data kind to use
  24411. * @returns true is data kind is present
  24412. */
  24413. isVerticesDataPresent(kind: string): boolean;
  24414. /**
  24415. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24416. * @returns a BoundingInfo
  24417. */
  24418. getBoundingInfo(): BoundingInfo;
  24419. /**
  24420. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24421. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24422. * @returns the current mesh
  24423. */
  24424. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24425. /**
  24426. * Overwrite the current bounding info
  24427. * @param boundingInfo defines the new bounding info
  24428. * @returns the current mesh
  24429. */
  24430. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24431. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24432. readonly useBones: boolean;
  24433. /** @hidden */
  24434. _preActivate(): void;
  24435. /** @hidden */
  24436. _preActivateForIntermediateRendering(renderId: number): void;
  24437. /** @hidden */
  24438. _activate(renderId: number): void;
  24439. /**
  24440. * Gets the current world matrix
  24441. * @returns a Matrix
  24442. */
  24443. getWorldMatrix(): Matrix;
  24444. /** @hidden */
  24445. _getWorldMatrixDeterminant(): number;
  24446. /**
  24447. * Perform relative position change from the point of view of behind the front of the mesh.
  24448. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24449. * Supports definition of mesh facing forward or backward
  24450. * @param amountRight defines the distance on the right axis
  24451. * @param amountUp defines the distance on the up axis
  24452. * @param amountForward defines the distance on the forward axis
  24453. * @returns the current mesh
  24454. */
  24455. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24456. /**
  24457. * Calculate relative position change from the point of view of behind the front of the mesh.
  24458. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24459. * Supports definition of mesh facing forward or backward
  24460. * @param amountRight defines the distance on the right axis
  24461. * @param amountUp defines the distance on the up axis
  24462. * @param amountForward defines the distance on the forward axis
  24463. * @returns the new displacement vector
  24464. */
  24465. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24466. /**
  24467. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24468. * Supports definition of mesh facing forward or backward
  24469. * @param flipBack defines the flip
  24470. * @param twirlClockwise defines the twirl
  24471. * @param tiltRight defines the tilt
  24472. * @returns the current mesh
  24473. */
  24474. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24475. /**
  24476. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24477. * Supports definition of mesh facing forward or backward.
  24478. * @param flipBack defines the flip
  24479. * @param twirlClockwise defines the twirl
  24480. * @param tiltRight defines the tilt
  24481. * @returns the new rotation vector
  24482. */
  24483. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24484. /**
  24485. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24486. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24487. * @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
  24488. * @returns the new bounding vectors
  24489. */
  24490. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24491. min: Vector3;
  24492. max: Vector3;
  24493. };
  24494. /**
  24495. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24496. * This means the mesh underlying bounding box and sphere are recomputed.
  24497. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24498. * @returns the current mesh
  24499. */
  24500. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24501. /** @hidden */
  24502. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24503. /** @hidden */
  24504. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24505. /** @hidden */
  24506. _updateBoundingInfo(): AbstractMesh;
  24507. /** @hidden */
  24508. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24509. /** @hidden */
  24510. protected _afterComputeWorldMatrix(): void;
  24511. /**
  24512. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24513. * A mesh is in the frustum if its bounding box intersects the frustum
  24514. * @param frustumPlanes defines the frustum to test
  24515. * @returns true if the mesh is in the frustum planes
  24516. */
  24517. isInFrustum(frustumPlanes: Plane[]): boolean;
  24518. /**
  24519. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24520. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24521. * @param frustumPlanes defines the frustum to test
  24522. * @returns true if the mesh is completely in the frustum planes
  24523. */
  24524. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24525. /**
  24526. * True if the mesh intersects another mesh or a SolidParticle object
  24527. * @param mesh defines a target mesh or SolidParticle to test
  24528. * @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)
  24529. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24530. * @returns true if there is an intersection
  24531. */
  24532. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24533. /**
  24534. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24535. * @param point defines the point to test
  24536. * @returns true if there is an intersection
  24537. */
  24538. intersectsPoint(point: Vector3): boolean;
  24539. /**
  24540. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24542. */
  24543. checkCollisions: boolean;
  24544. /**
  24545. * Gets Collider object used to compute collisions (not physics)
  24546. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24547. */
  24548. readonly collider: Collider;
  24549. /**
  24550. * Move the mesh using collision engine
  24551. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24552. * @param displacement defines the requested displacement vector
  24553. * @returns the current mesh
  24554. */
  24555. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24556. private _onCollisionPositionChange;
  24557. /** @hidden */
  24558. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24559. /** @hidden */
  24560. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24561. /** @hidden */
  24562. _checkCollision(collider: Collider): AbstractMesh;
  24563. /** @hidden */
  24564. _generatePointsArray(): boolean;
  24565. /**
  24566. * Checks if the passed Ray intersects with the mesh
  24567. * @param ray defines the ray to use
  24568. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24569. * @returns the picking info
  24570. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24571. */
  24572. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24573. /**
  24574. * Clones the current mesh
  24575. * @param name defines the mesh name
  24576. * @param newParent defines the new mesh parent
  24577. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24578. * @returns the new mesh
  24579. */
  24580. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24581. /**
  24582. * Disposes all the submeshes of the current meshnp
  24583. * @returns the current mesh
  24584. */
  24585. releaseSubMeshes(): AbstractMesh;
  24586. /**
  24587. * Releases resources associated with this abstract mesh.
  24588. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24589. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24590. */
  24591. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24592. /**
  24593. * Adds the passed mesh as a child to the current mesh
  24594. * @param mesh defines the child mesh
  24595. * @returns the current mesh
  24596. */
  24597. addChild(mesh: AbstractMesh): AbstractMesh;
  24598. /**
  24599. * Removes the passed mesh from the current mesh children list
  24600. * @param mesh defines the child mesh
  24601. * @returns the current mesh
  24602. */
  24603. removeChild(mesh: AbstractMesh): AbstractMesh;
  24604. /** @hidden */
  24605. private _initFacetData;
  24606. /**
  24607. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24608. * This method can be called within the render loop.
  24609. * 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
  24610. * @returns the current mesh
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24612. */
  24613. updateFacetData(): AbstractMesh;
  24614. /**
  24615. * Returns the facetLocalNormals array.
  24616. * The normals are expressed in the mesh local spac
  24617. * @returns an array of Vector3
  24618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24619. */
  24620. getFacetLocalNormals(): Vector3[];
  24621. /**
  24622. * Returns the facetLocalPositions array.
  24623. * The facet positions are expressed in the mesh local space
  24624. * @returns an array of Vector3
  24625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24626. */
  24627. getFacetLocalPositions(): Vector3[];
  24628. /**
  24629. * Returns the facetLocalPartioning array
  24630. * @returns an array of array of numbers
  24631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24632. */
  24633. getFacetLocalPartitioning(): number[][];
  24634. /**
  24635. * Returns the i-th facet position in the world system.
  24636. * This method allocates a new Vector3 per call
  24637. * @param i defines the facet index
  24638. * @returns a new Vector3
  24639. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24640. */
  24641. getFacetPosition(i: number): Vector3;
  24642. /**
  24643. * Sets the reference Vector3 with the i-th facet position in the world system
  24644. * @param i defines the facet index
  24645. * @param ref defines the target vector
  24646. * @returns the current mesh
  24647. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24648. */
  24649. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24650. /**
  24651. * Returns the i-th facet normal in the world system.
  24652. * This method allocates a new Vector3 per call
  24653. * @param i defines the facet index
  24654. * @returns a new Vector3
  24655. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24656. */
  24657. getFacetNormal(i: number): Vector3;
  24658. /**
  24659. * Sets the reference Vector3 with the i-th facet normal in the world system
  24660. * @param i defines the facet index
  24661. * @param ref defines the target vector
  24662. * @returns the current mesh
  24663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24664. */
  24665. getFacetNormalToRef(i: number, ref: Vector3): this;
  24666. /**
  24667. * 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)
  24668. * @param x defines x coordinate
  24669. * @param y defines y coordinate
  24670. * @param z defines z coordinate
  24671. * @returns the array of facet indexes
  24672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24673. */
  24674. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24675. /**
  24676. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24677. * @param projected sets as the (x,y,z) world projection on the facet
  24678. * @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
  24679. * @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
  24680. * @param x defines x coordinate
  24681. * @param y defines y coordinate
  24682. * @param z defines z coordinate
  24683. * @returns the face index if found (or null instead)
  24684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24685. */
  24686. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24687. /**
  24688. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24689. * @param projected sets as the (x,y,z) local projection on the facet
  24690. * @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
  24691. * @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
  24692. * @param x defines x coordinate
  24693. * @param y defines y coordinate
  24694. * @param z defines z coordinate
  24695. * @returns the face index if found (or null instead)
  24696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24697. */
  24698. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24699. /**
  24700. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24701. * @returns the parameters
  24702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24703. */
  24704. getFacetDataParameters(): any;
  24705. /**
  24706. * Disables the feature FacetData and frees the related memory
  24707. * @returns the current mesh
  24708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24709. */
  24710. disableFacetData(): AbstractMesh;
  24711. /**
  24712. * Updates the AbstractMesh indices array
  24713. * @param indices defines the data source
  24714. * @returns the current mesh
  24715. */
  24716. updateIndices(indices: IndicesArray): AbstractMesh;
  24717. /**
  24718. * Creates new normals data for the mesh
  24719. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24720. * @returns the current mesh
  24721. */
  24722. createNormals(updatable: boolean): AbstractMesh;
  24723. /**
  24724. * Align the mesh with a normal
  24725. * @param normal defines the normal to use
  24726. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24727. * @returns the current mesh
  24728. */
  24729. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24730. /** @hidden */
  24731. _checkOcclusionQuery(): boolean;
  24732. }
  24733. }
  24734. declare module BABYLON {
  24735. /**
  24736. * Class used to store data that will be store in GPU memory
  24737. */
  24738. class Buffer {
  24739. private _engine;
  24740. private _buffer;
  24741. /** @hidden */
  24742. _data: Nullable<DataArray>;
  24743. private _updatable;
  24744. private _instanced;
  24745. /**
  24746. * Gets the byte stride.
  24747. */
  24748. readonly byteStride: number;
  24749. /**
  24750. * Constructor
  24751. * @param engine the engine
  24752. * @param data the data to use for this buffer
  24753. * @param updatable whether the data is updatable
  24754. * @param stride the stride (optional)
  24755. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24756. * @param instanced whether the buffer is instanced (optional)
  24757. * @param useBytes set to true if the stride in in bytes (optional)
  24758. */
  24759. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24760. /**
  24761. * Create a new VertexBuffer based on the current buffer
  24762. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24763. * @param offset defines offset in the buffer (0 by default)
  24764. * @param size defines the size in floats of attributes (position is 3 for instance)
  24765. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24766. * @param instanced defines if the vertex buffer contains indexed data
  24767. * @param useBytes defines if the offset and stride are in bytes
  24768. * @returns the new vertex buffer
  24769. */
  24770. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24771. /**
  24772. * Gets a boolean indicating if the Buffer is updatable?
  24773. * @returns true if the buffer is updatable
  24774. */
  24775. isUpdatable(): boolean;
  24776. /**
  24777. * Gets current buffer's data
  24778. * @returns a DataArray or null
  24779. */
  24780. getData(): Nullable<DataArray>;
  24781. /**
  24782. * Gets underlying native buffer
  24783. * @returns underlying native buffer
  24784. */
  24785. getBuffer(): Nullable<WebGLBuffer>;
  24786. /**
  24787. * Gets the stride in float32 units (i.e. byte stride / 4).
  24788. * May not be an integer if the byte stride is not divisible by 4.
  24789. * DEPRECATED. Use byteStride instead.
  24790. * @returns the stride in float32 units
  24791. */
  24792. getStrideSize(): number;
  24793. /**
  24794. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24795. * @param data defines the data to store
  24796. */
  24797. create(data?: Nullable<DataArray>): void;
  24798. /** @hidden */
  24799. _rebuild(): void;
  24800. /**
  24801. * Update current buffer data
  24802. * @param data defines the data to store
  24803. */
  24804. update(data: DataArray): void;
  24805. /**
  24806. * Updates the data directly.
  24807. * @param data the new data
  24808. * @param offset the new offset
  24809. * @param vertexCount the vertex count (optional)
  24810. * @param useBytes set to true if the offset is in bytes
  24811. */
  24812. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24813. /**
  24814. * Release all resources
  24815. */
  24816. dispose(): void;
  24817. }
  24818. }
  24819. declare module BABYLON {
  24820. /**
  24821. * Class for building Constructive Solid Geometry
  24822. */
  24823. class CSG {
  24824. private polygons;
  24825. /**
  24826. * The world matrix
  24827. */
  24828. matrix: Matrix;
  24829. /**
  24830. * Stores the position
  24831. */
  24832. position: Vector3;
  24833. /**
  24834. * Stores the rotation
  24835. */
  24836. rotation: Vector3;
  24837. /**
  24838. * Stores the rotation quaternion
  24839. */
  24840. rotationQuaternion: Nullable<Quaternion>;
  24841. /**
  24842. * Stores the scaling vector
  24843. */
  24844. scaling: Vector3;
  24845. /**
  24846. * Convert the BABYLON.Mesh to BABYLON.CSG
  24847. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24848. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24849. */
  24850. static FromMesh(mesh: Mesh): CSG;
  24851. /**
  24852. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24853. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24854. */
  24855. private static FromPolygons;
  24856. /**
  24857. * Clones, or makes a deep copy, of the BABYLON.CSG
  24858. * @returns A new BABYLON.CSG
  24859. */
  24860. clone(): CSG;
  24861. /**
  24862. * Unions this CSG with another CSG
  24863. * @param csg The CSG to union against this CSG
  24864. * @returns The unioned CSG
  24865. */
  24866. union(csg: CSG): CSG;
  24867. /**
  24868. * Unions this CSG with another CSG in place
  24869. * @param csg The CSG to union against this CSG
  24870. */
  24871. unionInPlace(csg: CSG): void;
  24872. /**
  24873. * Subtracts this CSG with another CSG
  24874. * @param csg The CSG to subtract against this CSG
  24875. * @returns A new BABYLON.CSG
  24876. */
  24877. subtract(csg: CSG): CSG;
  24878. /**
  24879. * Subtracts this CSG with another CSG in place
  24880. * @param csg The CSG to subtact against this CSG
  24881. */
  24882. subtractInPlace(csg: CSG): void;
  24883. /**
  24884. * Intersect this CSG with another CSG
  24885. * @param csg The CSG to intersect against this CSG
  24886. * @returns A new BABYLON.CSG
  24887. */
  24888. intersect(csg: CSG): CSG;
  24889. /**
  24890. * Intersects this CSG with another CSG in place
  24891. * @param csg The CSG to intersect against this CSG
  24892. */
  24893. intersectInPlace(csg: CSG): void;
  24894. /**
  24895. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24896. * not modified.
  24897. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24898. */
  24899. inverse(): CSG;
  24900. /**
  24901. * Inverses the BABYLON.CSG in place
  24902. */
  24903. inverseInPlace(): void;
  24904. /**
  24905. * This is used to keep meshes transformations so they can be restored
  24906. * when we build back a Babylon Mesh
  24907. * NB : All CSG operations are performed in world coordinates
  24908. * @param csg The BABYLON.CSG to copy the transform attributes from
  24909. * @returns This BABYLON.CSG
  24910. */
  24911. copyTransformAttributes(csg: CSG): CSG;
  24912. /**
  24913. * Build Raw mesh from CSG
  24914. * Coordinates here are in world space
  24915. * @param name The name of the mesh geometry
  24916. * @param scene The BABYLON.Scene
  24917. * @param keepSubMeshes Specifies if the submeshes should be kept
  24918. * @returns A new BABYLON.Mesh
  24919. */
  24920. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24921. /**
  24922. * Build Mesh from CSG taking material and transforms into account
  24923. * @param name The name of the BABYLON.Mesh
  24924. * @param material The material of the BABYLON.Mesh
  24925. * @param scene The BABYLON.Scene
  24926. * @param keepSubMeshes Specifies if submeshes should be kept
  24927. * @returns The new BABYLON.Mesh
  24928. */
  24929. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24930. }
  24931. }
  24932. declare module BABYLON {
  24933. /**
  24934. * Class used to store geometry data (vertex buffers + index buffer)
  24935. */
  24936. class Geometry implements IGetSetVerticesData {
  24937. /**
  24938. * Gets or sets the ID of the geometry
  24939. */
  24940. id: string;
  24941. /**
  24942. * Gets or sets the unique ID of the geometry
  24943. */
  24944. uniqueId: number;
  24945. /**
  24946. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24947. */
  24948. delayLoadState: number;
  24949. /**
  24950. * Gets the file containing the data to load when running in delay load state
  24951. */
  24952. delayLoadingFile: Nullable<string>;
  24953. /**
  24954. * Callback called when the geometry is updated
  24955. */
  24956. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24957. private _scene;
  24958. private _engine;
  24959. private _meshes;
  24960. private _totalVertices;
  24961. /** @hidden */
  24962. _indices: IndicesArray;
  24963. /** @hidden */
  24964. _vertexBuffers: {
  24965. [key: string]: VertexBuffer;
  24966. };
  24967. private _isDisposed;
  24968. private _extend;
  24969. private _boundingBias;
  24970. /** @hidden */
  24971. _delayInfo: Array<string>;
  24972. private _indexBuffer;
  24973. private _indexBufferIsUpdatable;
  24974. /** @hidden */
  24975. _boundingInfo: Nullable<BoundingInfo>;
  24976. /** @hidden */
  24977. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24978. /** @hidden */
  24979. _softwareSkinningFrameId: number;
  24980. private _vertexArrayObjects;
  24981. private _updatable;
  24982. /** @hidden */
  24983. _positions: Nullable<Vector3[]>;
  24984. /**
  24985. * 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
  24986. */
  24987. /**
  24988. * 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
  24989. */
  24990. boundingBias: Vector2;
  24991. /**
  24992. * Static function used to attach a new empty geometry to a mesh
  24993. * @param mesh defines the mesh to attach the geometry to
  24994. * @returns the new Geometry
  24995. */
  24996. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24997. /**
  24998. * Creates a new geometry
  24999. * @param id defines the unique ID
  25000. * @param scene defines the hosting scene
  25001. * @param vertexData defines the VertexData used to get geometry data
  25002. * @param updatable defines if geometry must be updatable (false by default)
  25003. * @param mesh defines the mesh that will be associated with the geometry
  25004. */
  25005. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25006. /**
  25007. * Gets the current extend of the geometry
  25008. */
  25009. readonly extend: {
  25010. minimum: Vector3;
  25011. maximum: Vector3;
  25012. };
  25013. /**
  25014. * Gets the hosting scene
  25015. * @returns the hosting Scene
  25016. */
  25017. getScene(): Scene;
  25018. /**
  25019. * Gets the hosting engine
  25020. * @returns the hosting Engine
  25021. */
  25022. getEngine(): Engine;
  25023. /**
  25024. * Defines if the geometry is ready to use
  25025. * @returns true if the geometry is ready to be used
  25026. */
  25027. isReady(): boolean;
  25028. /**
  25029. * Gets a value indicating that the geometry should not be serialized
  25030. */
  25031. readonly doNotSerialize: boolean;
  25032. /** @hidden */
  25033. _rebuild(): void;
  25034. /**
  25035. * Affects all geometry data in one call
  25036. * @param vertexData defines the geometry data
  25037. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25038. */
  25039. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25040. /**
  25041. * Set specific vertex data
  25042. * @param kind defines the data kind (Position, normal, etc...)
  25043. * @param data defines the vertex data to use
  25044. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25045. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25046. */
  25047. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25048. /**
  25049. * Removes a specific vertex data
  25050. * @param kind defines the data kind (Position, normal, etc...)
  25051. */
  25052. removeVerticesData(kind: string): void;
  25053. /**
  25054. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25055. * @param buffer defines the vertex buffer to use
  25056. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25057. */
  25058. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25059. /**
  25060. * Update a specific vertex buffer
  25061. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25062. * It will do nothing if the buffer is not updatable
  25063. * @param kind defines the data kind (Position, normal, etc...)
  25064. * @param data defines the data to use
  25065. * @param offset defines the offset in the target buffer where to store the data
  25066. * @param useBytes set to true if the offset is in bytes
  25067. */
  25068. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25069. /**
  25070. * Update a specific vertex buffer
  25071. * This function will create a new buffer if the current one is not updatable
  25072. * @param kind defines the data kind (Position, normal, etc...)
  25073. * @param data defines the data to use
  25074. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25075. */
  25076. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25077. private _updateBoundingInfo;
  25078. /** @hidden */
  25079. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25080. /**
  25081. * Gets total number of vertices
  25082. * @returns the total number of vertices
  25083. */
  25084. getTotalVertices(): number;
  25085. /**
  25086. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25087. * @param kind defines the data kind (Position, normal, etc...)
  25088. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25089. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25090. * @returns a float array containing vertex data
  25091. */
  25092. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25093. /**
  25094. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25095. * @param kind defines the data kind (Position, normal, etc...)
  25096. * @returns true if the vertex buffer with the specified kind is updatable
  25097. */
  25098. isVertexBufferUpdatable(kind: string): boolean;
  25099. /**
  25100. * Gets a specific vertex buffer
  25101. * @param kind defines the data kind (Position, normal, etc...)
  25102. * @returns a VertexBuffer
  25103. */
  25104. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25105. /**
  25106. * Returns all vertex buffers
  25107. * @return an object holding all vertex buffers indexed by kind
  25108. */
  25109. getVertexBuffers(): Nullable<{
  25110. [key: string]: VertexBuffer;
  25111. }>;
  25112. /**
  25113. * Gets a boolean indicating if specific vertex buffer is present
  25114. * @param kind defines the data kind (Position, normal, etc...)
  25115. * @returns true if data is present
  25116. */
  25117. isVerticesDataPresent(kind: string): boolean;
  25118. /**
  25119. * Gets a list of all attached data kinds (Position, normal, etc...)
  25120. * @returns a list of string containing all kinds
  25121. */
  25122. getVerticesDataKinds(): string[];
  25123. /**
  25124. * Update index buffer
  25125. * @param indices defines the indices to store in the index buffer
  25126. * @param offset defines the offset in the target buffer where to store the data
  25127. */
  25128. updateIndices(indices: IndicesArray, offset?: number): void;
  25129. /**
  25130. * Creates a new index buffer
  25131. * @param indices defines the indices to store in the index buffer
  25132. * @param totalVertices defines the total number of vertices (could be null)
  25133. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25134. */
  25135. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25136. /**
  25137. * Return the total number of indices
  25138. * @returns the total number of indices
  25139. */
  25140. getTotalIndices(): number;
  25141. /**
  25142. * Gets the index buffer array
  25143. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25144. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25145. * @returns the index buffer array
  25146. */
  25147. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25148. /**
  25149. * Gets the index buffer
  25150. * @return the index buffer
  25151. */
  25152. getIndexBuffer(): Nullable<WebGLBuffer>;
  25153. /** @hidden */
  25154. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25155. /**
  25156. * Release the associated resources for a specific mesh
  25157. * @param mesh defines the source mesh
  25158. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25159. */
  25160. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25161. /**
  25162. * Apply current geometry to a given mesh
  25163. * @param mesh defines the mesh to apply geometry to
  25164. */
  25165. applyToMesh(mesh: Mesh): void;
  25166. private _updateExtend;
  25167. private _applyToMesh;
  25168. private notifyUpdate;
  25169. /**
  25170. * Load the geometry if it was flagged as delay loaded
  25171. * @param scene defines the hosting scene
  25172. * @param onLoaded defines a callback called when the geometry is loaded
  25173. */
  25174. load(scene: Scene, onLoaded?: () => void): void;
  25175. private _queueLoad;
  25176. /**
  25177. * Invert the geometry to move from a right handed system to a left handed one.
  25178. */
  25179. toLeftHanded(): void;
  25180. /** @hidden */
  25181. _resetPointsArrayCache(): void;
  25182. /** @hidden */
  25183. _generatePointsArray(): boolean;
  25184. /**
  25185. * Gets a value indicating if the geometry is disposed
  25186. * @returns true if the geometry was disposed
  25187. */
  25188. isDisposed(): boolean;
  25189. private _disposeVertexArrayObjects;
  25190. /**
  25191. * Free all associated resources
  25192. */
  25193. dispose(): void;
  25194. /**
  25195. * Clone the current geometry into a new geometry
  25196. * @param id defines the unique ID of the new geometry
  25197. * @returns a new geometry object
  25198. */
  25199. copy(id: string): Geometry;
  25200. /**
  25201. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25202. * @return a JSON representation of the current geometry data (without the vertices data)
  25203. */
  25204. serialize(): any;
  25205. private toNumberArray;
  25206. /**
  25207. * Serialize all vertices data into a JSON oject
  25208. * @returns a JSON representation of the current geometry data
  25209. */
  25210. serializeVerticeData(): any;
  25211. /**
  25212. * Extracts a clone of a mesh geometry
  25213. * @param mesh defines the source mesh
  25214. * @param id defines the unique ID of the new geometry object
  25215. * @returns the new geometry object
  25216. */
  25217. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25218. /**
  25219. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25220. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25221. * Be aware Math.random() could cause collisions, but:
  25222. * "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"
  25223. * @returns a string containing a new GUID
  25224. */
  25225. static RandomId(): string;
  25226. /** @hidden */
  25227. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25228. private static _CleanMatricesWeights;
  25229. /**
  25230. * Create a new geometry from persisted data (Using .babylon file format)
  25231. * @param parsedVertexData defines the persisted data
  25232. * @param scene defines the hosting scene
  25233. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25234. * @returns the new geometry object
  25235. */
  25236. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25237. }
  25238. /**
  25239. * Abstract class used to provide common services for all typed geometries
  25240. * @hidden
  25241. */
  25242. class _PrimitiveGeometry extends Geometry {
  25243. private _canBeRegenerated;
  25244. private _beingRegenerated;
  25245. /**
  25246. * Creates a new typed geometry
  25247. * @param id defines the unique ID of the geometry
  25248. * @param scene defines the hosting scene
  25249. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25250. * @param mesh defines the hosting mesh (can be null)
  25251. */
  25252. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25253. /**
  25254. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25255. * @returns true if the geometry can be regenerated
  25256. */
  25257. canBeRegenerated(): boolean;
  25258. /**
  25259. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25260. */
  25261. regenerate(): void;
  25262. /**
  25263. * Clone the geometry
  25264. * @param id defines the unique ID of the new geometry
  25265. * @returns the new geometry
  25266. */
  25267. asNewGeometry(id: string): Geometry;
  25268. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25269. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25270. /** @hidden */
  25271. _regenerateVertexData(): VertexData;
  25272. copy(id: string): Geometry;
  25273. serialize(): any;
  25274. }
  25275. /**
  25276. * Creates a ribbon geometry
  25277. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25278. */
  25279. class RibbonGeometry extends _PrimitiveGeometry {
  25280. /**
  25281. * Defines the array of paths to use
  25282. */
  25283. pathArray: Vector3[][];
  25284. /**
  25285. * Defines if the last and first points of each path in your pathArray must be joined
  25286. */
  25287. closeArray: boolean;
  25288. /**
  25289. * Defines if the last and first points of each path in your pathArray must be joined
  25290. */
  25291. closePath: boolean;
  25292. /**
  25293. * Defines the offset between points
  25294. */
  25295. offset: number;
  25296. /**
  25297. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25298. */
  25299. side: number;
  25300. /**
  25301. * Creates a ribbon geometry
  25302. * @param id defines the unique ID of the geometry
  25303. * @param scene defines the hosting scene
  25304. * @param pathArray defines the array of paths to use
  25305. * @param closeArray defines if the last path and the first path must be joined
  25306. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25307. * @param offset defines the offset between points
  25308. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25309. * @param mesh defines the hosting mesh (can be null)
  25310. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25311. */
  25312. constructor(id: string, scene: Scene,
  25313. /**
  25314. * Defines the array of paths to use
  25315. */
  25316. pathArray: Vector3[][],
  25317. /**
  25318. * Defines if the last and first points of each path in your pathArray must be joined
  25319. */
  25320. closeArray: boolean,
  25321. /**
  25322. * Defines if the last and first points of each path in your pathArray must be joined
  25323. */
  25324. closePath: boolean,
  25325. /**
  25326. * Defines the offset between points
  25327. */
  25328. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25329. /**
  25330. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25331. */
  25332. side?: number);
  25333. /** @hidden */
  25334. _regenerateVertexData(): VertexData;
  25335. copy(id: string): Geometry;
  25336. }
  25337. /**
  25338. * Creates a box geometry
  25339. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25340. */
  25341. class BoxGeometry extends _PrimitiveGeometry {
  25342. /**
  25343. * Defines the zise of the box (width, height and depth are the same)
  25344. */
  25345. size: number;
  25346. /**
  25347. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25348. */
  25349. side: number;
  25350. /**
  25351. * Creates a box geometry
  25352. * @param id defines the unique ID of the geometry
  25353. * @param scene defines the hosting scene
  25354. * @param size defines the zise of the box (width, height and depth are the same)
  25355. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25356. * @param mesh defines the hosting mesh (can be null)
  25357. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25358. */
  25359. constructor(id: string, scene: Scene,
  25360. /**
  25361. * Defines the zise of the box (width, height and depth are the same)
  25362. */
  25363. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25364. /**
  25365. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25366. */
  25367. side?: number);
  25368. /** @hidden */
  25369. _regenerateVertexData(): VertexData;
  25370. copy(id: string): Geometry;
  25371. serialize(): any;
  25372. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25373. }
  25374. /**
  25375. * Creates a sphere geometry
  25376. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25377. */
  25378. class SphereGeometry extends _PrimitiveGeometry {
  25379. /**
  25380. * Defines the number of segments to use to create the sphere
  25381. */
  25382. segments: number;
  25383. /**
  25384. * Defines the diameter of the sphere
  25385. */
  25386. diameter: number;
  25387. /**
  25388. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25389. */
  25390. side: number;
  25391. /**
  25392. * Create a new sphere geometry
  25393. * @param id defines the unique ID of the geometry
  25394. * @param scene defines the hosting scene
  25395. * @param segments defines the number of segments to use to create the sphere
  25396. * @param diameter defines the diameter of the sphere
  25397. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25398. * @param mesh defines the hosting mesh (can be null)
  25399. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25400. */
  25401. constructor(id: string, scene: Scene,
  25402. /**
  25403. * Defines the number of segments to use to create the sphere
  25404. */
  25405. segments: number,
  25406. /**
  25407. * Defines the diameter of the sphere
  25408. */
  25409. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25410. /**
  25411. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25412. */
  25413. side?: number);
  25414. /** @hidden */
  25415. _regenerateVertexData(): VertexData;
  25416. copy(id: string): Geometry;
  25417. serialize(): any;
  25418. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25419. }
  25420. /**
  25421. * Creates a disc geometry
  25422. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25423. */
  25424. class DiscGeometry extends _PrimitiveGeometry {
  25425. /**
  25426. * Defines the radius of the disc
  25427. */
  25428. radius: number;
  25429. /**
  25430. * Defines the tesselation factor to apply to the disc
  25431. */
  25432. tessellation: number;
  25433. /**
  25434. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25435. */
  25436. side: number;
  25437. /**
  25438. * Creates a new disc geometry
  25439. * @param id defines the unique ID of the geometry
  25440. * @param scene defines the hosting scene
  25441. * @param radius defines the radius of the disc
  25442. * @param tessellation defines the tesselation factor to apply to the disc
  25443. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25444. * @param mesh defines the hosting mesh (can be null)
  25445. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25446. */
  25447. constructor(id: string, scene: Scene,
  25448. /**
  25449. * Defines the radius of the disc
  25450. */
  25451. radius: number,
  25452. /**
  25453. * Defines the tesselation factor to apply to the disc
  25454. */
  25455. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25456. /**
  25457. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25458. */
  25459. side?: number);
  25460. /** @hidden */
  25461. _regenerateVertexData(): VertexData;
  25462. copy(id: string): Geometry;
  25463. }
  25464. /**
  25465. * Creates a new cylinder geometry
  25466. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25467. */
  25468. class CylinderGeometry extends _PrimitiveGeometry {
  25469. /**
  25470. * Defines the height of the cylinder
  25471. */
  25472. height: number;
  25473. /**
  25474. * Defines the diameter of the cylinder's top cap
  25475. */
  25476. diameterTop: number;
  25477. /**
  25478. * Defines the diameter of the cylinder's bottom cap
  25479. */
  25480. diameterBottom: number;
  25481. /**
  25482. * Defines the tessellation factor to apply to the cylinder
  25483. */
  25484. tessellation: number;
  25485. /**
  25486. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25487. */
  25488. subdivisions: number;
  25489. /**
  25490. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25491. */
  25492. side: number;
  25493. /**
  25494. * Creates a new cylinder geometry
  25495. * @param id defines the unique ID of the geometry
  25496. * @param scene defines the hosting scene
  25497. * @param height defines the height of the cylinder
  25498. * @param diameterTop defines the diameter of the cylinder's top cap
  25499. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25500. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25501. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25502. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25503. * @param mesh defines the hosting mesh (can be null)
  25504. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25505. */
  25506. constructor(id: string, scene: Scene,
  25507. /**
  25508. * Defines the height of the cylinder
  25509. */
  25510. height: number,
  25511. /**
  25512. * Defines the diameter of the cylinder's top cap
  25513. */
  25514. diameterTop: number,
  25515. /**
  25516. * Defines the diameter of the cylinder's bottom cap
  25517. */
  25518. diameterBottom: number,
  25519. /**
  25520. * Defines the tessellation factor to apply to the cylinder
  25521. */
  25522. tessellation: number,
  25523. /**
  25524. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25525. */
  25526. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25527. /**
  25528. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25529. */
  25530. side?: number);
  25531. /** @hidden */
  25532. _regenerateVertexData(): VertexData;
  25533. copy(id: string): Geometry;
  25534. serialize(): any;
  25535. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25536. }
  25537. /**
  25538. * Creates a new torus geometry
  25539. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25540. */
  25541. class TorusGeometry extends _PrimitiveGeometry {
  25542. /**
  25543. * Defines the diameter of the torus
  25544. */
  25545. diameter: number;
  25546. /**
  25547. * Defines the thickness of the torus (ie. internal diameter)
  25548. */
  25549. thickness: number;
  25550. /**
  25551. * Defines the tesselation factor to apply to the torus
  25552. */
  25553. tessellation: number;
  25554. /**
  25555. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25556. */
  25557. side: number;
  25558. /**
  25559. * Creates a new torus geometry
  25560. * @param id defines the unique ID of the geometry
  25561. * @param scene defines the hosting scene
  25562. * @param diameter defines the diameter of the torus
  25563. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25564. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25565. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25566. * @param mesh defines the hosting mesh (can be null)
  25567. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25568. */
  25569. constructor(id: string, scene: Scene,
  25570. /**
  25571. * Defines the diameter of the torus
  25572. */
  25573. diameter: number,
  25574. /**
  25575. * Defines the thickness of the torus (ie. internal diameter)
  25576. */
  25577. thickness: number,
  25578. /**
  25579. * Defines the tesselation factor to apply to the torus
  25580. */
  25581. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25582. /**
  25583. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25584. */
  25585. side?: number);
  25586. /** @hidden */
  25587. _regenerateVertexData(): VertexData;
  25588. copy(id: string): Geometry;
  25589. serialize(): any;
  25590. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25591. }
  25592. /**
  25593. * Creates a new ground geometry
  25594. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25595. */
  25596. class GroundGeometry extends _PrimitiveGeometry {
  25597. /**
  25598. * Defines the width of the ground
  25599. */
  25600. width: number;
  25601. /**
  25602. * Defines the height of the ground
  25603. */
  25604. height: number;
  25605. /**
  25606. * Defines the subdivisions to apply to the ground
  25607. */
  25608. subdivisions: number;
  25609. /**
  25610. * Creates a new ground geometry
  25611. * @param id defines the unique ID of the geometry
  25612. * @param scene defines the hosting scene
  25613. * @param width defines the width of the ground
  25614. * @param height defines the height of the ground
  25615. * @param subdivisions defines the subdivisions to apply to the ground
  25616. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25617. * @param mesh defines the hosting mesh (can be null)
  25618. */
  25619. constructor(id: string, scene: Scene,
  25620. /**
  25621. * Defines the width of the ground
  25622. */
  25623. width: number,
  25624. /**
  25625. * Defines the height of the ground
  25626. */
  25627. height: number,
  25628. /**
  25629. * Defines the subdivisions to apply to the ground
  25630. */
  25631. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25632. /** @hidden */
  25633. _regenerateVertexData(): VertexData;
  25634. copy(id: string): Geometry;
  25635. serialize(): any;
  25636. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25637. }
  25638. /**
  25639. * Creates a tiled ground geometry
  25640. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25641. */
  25642. class TiledGroundGeometry extends _PrimitiveGeometry {
  25643. /**
  25644. * Defines the minimum value on X axis
  25645. */
  25646. xmin: number;
  25647. /**
  25648. * Defines the minimum value on Z axis
  25649. */
  25650. zmin: number;
  25651. /**
  25652. * Defines the maximum value on X axis
  25653. */
  25654. xmax: number;
  25655. /**
  25656. * Defines the maximum value on Z axis
  25657. */
  25658. zmax: number;
  25659. /**
  25660. * Defines the subdivisions to apply to the ground
  25661. */
  25662. subdivisions: {
  25663. w: number;
  25664. h: number;
  25665. };
  25666. /**
  25667. * Defines the precision to use when computing the tiles
  25668. */
  25669. precision: {
  25670. w: number;
  25671. h: number;
  25672. };
  25673. /**
  25674. * Creates a tiled ground geometry
  25675. * @param id defines the unique ID of the geometry
  25676. * @param scene defines the hosting scene
  25677. * @param xmin defines the minimum value on X axis
  25678. * @param zmin defines the minimum value on Z axis
  25679. * @param xmax defines the maximum value on X axis
  25680. * @param zmax defines the maximum value on Z axis
  25681. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25682. * @param precision defines the precision to use when computing the tiles
  25683. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25684. * @param mesh defines the hosting mesh (can be null)
  25685. */
  25686. constructor(id: string, scene: Scene,
  25687. /**
  25688. * Defines the minimum value on X axis
  25689. */
  25690. xmin: number,
  25691. /**
  25692. * Defines the minimum value on Z axis
  25693. */
  25694. zmin: number,
  25695. /**
  25696. * Defines the maximum value on X axis
  25697. */
  25698. xmax: number,
  25699. /**
  25700. * Defines the maximum value on Z axis
  25701. */
  25702. zmax: number,
  25703. /**
  25704. * Defines the subdivisions to apply to the ground
  25705. */
  25706. subdivisions: {
  25707. w: number;
  25708. h: number;
  25709. },
  25710. /**
  25711. * Defines the precision to use when computing the tiles
  25712. */
  25713. precision: {
  25714. w: number;
  25715. h: number;
  25716. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25717. /** @hidden */
  25718. _regenerateVertexData(): VertexData;
  25719. copy(id: string): Geometry;
  25720. }
  25721. /**
  25722. * Creates a plane geometry
  25723. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25724. */
  25725. class PlaneGeometry extends _PrimitiveGeometry {
  25726. /**
  25727. * Defines the size of the plane (width === height)
  25728. */
  25729. size: number;
  25730. /**
  25731. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25732. */
  25733. side: number;
  25734. /**
  25735. * Creates a plane geometry
  25736. * @param id defines the unique ID of the geometry
  25737. * @param scene defines the hosting scene
  25738. * @param size defines the size of the plane (width === height)
  25739. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25740. * @param mesh defines the hosting mesh (can be null)
  25741. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25742. */
  25743. constructor(id: string, scene: Scene,
  25744. /**
  25745. * Defines the size of the plane (width === height)
  25746. */
  25747. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25748. /**
  25749. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25750. */
  25751. side?: number);
  25752. /** @hidden */
  25753. _regenerateVertexData(): VertexData;
  25754. copy(id: string): Geometry;
  25755. serialize(): any;
  25756. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25757. }
  25758. /**
  25759. * Creates a torus knot geometry
  25760. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25761. */
  25762. class TorusKnotGeometry extends _PrimitiveGeometry {
  25763. /**
  25764. * Defines the radius of the torus knot
  25765. */
  25766. radius: number;
  25767. /**
  25768. * Defines the thickness of the torus knot tube
  25769. */
  25770. tube: number;
  25771. /**
  25772. * Defines the number of radial segments
  25773. */
  25774. radialSegments: number;
  25775. /**
  25776. * Defines the number of tubular segments
  25777. */
  25778. tubularSegments: number;
  25779. /**
  25780. * Defines the first number of windings
  25781. */
  25782. p: number;
  25783. /**
  25784. * Defines the second number of windings
  25785. */
  25786. q: number;
  25787. /**
  25788. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25789. */
  25790. side: number;
  25791. /**
  25792. * Creates a torus knot geometry
  25793. * @param id defines the unique ID of the geometry
  25794. * @param scene defines the hosting scene
  25795. * @param radius defines the radius of the torus knot
  25796. * @param tube defines the thickness of the torus knot tube
  25797. * @param radialSegments defines the number of radial segments
  25798. * @param tubularSegments defines the number of tubular segments
  25799. * @param p defines the first number of windings
  25800. * @param q defines the second number of windings
  25801. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25802. * @param mesh defines the hosting mesh (can be null)
  25803. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25804. */
  25805. constructor(id: string, scene: Scene,
  25806. /**
  25807. * Defines the radius of the torus knot
  25808. */
  25809. radius: number,
  25810. /**
  25811. * Defines the thickness of the torus knot tube
  25812. */
  25813. tube: number,
  25814. /**
  25815. * Defines the number of radial segments
  25816. */
  25817. radialSegments: number,
  25818. /**
  25819. * Defines the number of tubular segments
  25820. */
  25821. tubularSegments: number,
  25822. /**
  25823. * Defines the first number of windings
  25824. */
  25825. p: number,
  25826. /**
  25827. * Defines the second number of windings
  25828. */
  25829. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25830. /**
  25831. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25832. */
  25833. side?: number);
  25834. /** @hidden */
  25835. _regenerateVertexData(): VertexData;
  25836. copy(id: string): Geometry;
  25837. serialize(): any;
  25838. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25839. }
  25840. }
  25841. declare module BABYLON {
  25842. /**
  25843. * Mesh representing the gorund
  25844. */
  25845. class GroundMesh extends Mesh {
  25846. /** If octree should be generated */
  25847. generateOctree: boolean;
  25848. private _heightQuads;
  25849. /** @hidden */
  25850. _subdivisionsX: number;
  25851. /** @hidden */
  25852. _subdivisionsY: number;
  25853. /** @hidden */
  25854. _width: number;
  25855. /** @hidden */
  25856. _height: number;
  25857. /** @hidden */
  25858. _minX: number;
  25859. /** @hidden */
  25860. _maxX: number;
  25861. /** @hidden */
  25862. _minZ: number;
  25863. /** @hidden */
  25864. _maxZ: number;
  25865. constructor(name: string, scene: Scene);
  25866. /**
  25867. * "GroundMesh"
  25868. * @returns "GroundMesh"
  25869. */
  25870. getClassName(): string;
  25871. /**
  25872. * The minimum of x and y subdivisions
  25873. */
  25874. readonly subdivisions: number;
  25875. /**
  25876. * X subdivisions
  25877. */
  25878. readonly subdivisionsX: number;
  25879. /**
  25880. * Y subdivisions
  25881. */
  25882. readonly subdivisionsY: number;
  25883. /**
  25884. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25885. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25886. * @param chunksCount the number of subdivisions for x and y
  25887. * @param octreeBlocksSize (Default: 32)
  25888. */
  25889. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25890. /**
  25891. * Returns a height (y) value in the Worl system :
  25892. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25893. * @param x x coordinate
  25894. * @param z z coordinate
  25895. * @returns the ground y position if (x, z) are outside the ground surface.
  25896. */
  25897. getHeightAtCoordinates(x: number, z: number): number;
  25898. /**
  25899. * Returns a normalized vector (Vector3) orthogonal to the ground
  25900. * at the ground coordinates (x, z) expressed in the World system.
  25901. * @param x x coordinate
  25902. * @param z z coordinate
  25903. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25904. */
  25905. getNormalAtCoordinates(x: number, z: number): Vector3;
  25906. /**
  25907. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25908. * at the ground coordinates (x, z) expressed in the World system.
  25909. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25910. * @param x x coordinate
  25911. * @param z z coordinate
  25912. * @param ref vector to store the result
  25913. * @returns the GroundMesh.
  25914. */
  25915. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25916. /**
  25917. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25918. * if the ground has been updated.
  25919. * This can be used in the render loop.
  25920. * @returns the GroundMesh.
  25921. */
  25922. updateCoordinateHeights(): GroundMesh;
  25923. private _getFacetAt;
  25924. private _initHeightQuads;
  25925. private _computeHeightQuads;
  25926. /**
  25927. * Serializes this ground mesh
  25928. * @param serializationObject object to write serialization to
  25929. */
  25930. serialize(serializationObject: any): void;
  25931. /**
  25932. * Parses a serialized ground mesh
  25933. * @param parsedMesh the serialized mesh
  25934. * @param scene the scene to create the ground mesh in
  25935. * @returns the created ground mesh
  25936. */
  25937. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25938. }
  25939. }
  25940. declare module BABYLON {
  25941. /**
  25942. * Creates an instance based on a source mesh.
  25943. */
  25944. class InstancedMesh extends AbstractMesh {
  25945. private _sourceMesh;
  25946. private _currentLOD;
  25947. /** @hidden */
  25948. _indexInSourceMeshInstanceArray: number;
  25949. constructor(name: string, source: Mesh);
  25950. /**
  25951. * Returns the string "InstancedMesh".
  25952. */
  25953. getClassName(): string;
  25954. /**
  25955. * If the source mesh receives shadows
  25956. */
  25957. readonly receiveShadows: boolean;
  25958. /**
  25959. * The material of the source mesh
  25960. */
  25961. readonly material: Nullable<Material>;
  25962. /**
  25963. * Visibility of the source mesh
  25964. */
  25965. readonly visibility: number;
  25966. /**
  25967. * Skeleton of the source mesh
  25968. */
  25969. readonly skeleton: Nullable<Skeleton>;
  25970. /**
  25971. * Rendering ground id of the source mesh
  25972. */
  25973. renderingGroupId: number;
  25974. /**
  25975. * Returns the total number of vertices (integer).
  25976. */
  25977. getTotalVertices(): number;
  25978. /**
  25979. * Returns a positive integer : the total number of indices in this mesh geometry.
  25980. * @returns the numner of indices or zero if the mesh has no geometry.
  25981. */
  25982. getTotalIndices(): number;
  25983. /**
  25984. * The source mesh of the instance
  25985. */
  25986. readonly sourceMesh: Mesh;
  25987. /**
  25988. * Is this node ready to be used/rendered
  25989. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25990. * @return {boolean} is it ready
  25991. */
  25992. isReady(completeCheck?: boolean): boolean;
  25993. /**
  25994. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25995. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25996. * @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.
  25997. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25998. */
  25999. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26000. /**
  26001. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26002. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26003. * The `data` are either a numeric array either a Float32Array.
  26004. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26005. * 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).
  26006. * Note that a new underlying VertexBuffer object is created each call.
  26007. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26008. *
  26009. * Possible `kind` values :
  26010. * - BABYLON.VertexBuffer.PositionKind
  26011. * - BABYLON.VertexBuffer.UVKind
  26012. * - BABYLON.VertexBuffer.UV2Kind
  26013. * - BABYLON.VertexBuffer.UV3Kind
  26014. * - BABYLON.VertexBuffer.UV4Kind
  26015. * - BABYLON.VertexBuffer.UV5Kind
  26016. * - BABYLON.VertexBuffer.UV6Kind
  26017. * - BABYLON.VertexBuffer.ColorKind
  26018. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26019. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26020. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26021. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26022. *
  26023. * Returns the Mesh.
  26024. */
  26025. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26026. /**
  26027. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26028. * If the mesh has no geometry, it is simply returned as it is.
  26029. * The `data` are either a numeric array either a Float32Array.
  26030. * No new underlying VertexBuffer object is created.
  26031. * 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.
  26032. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26033. *
  26034. * Possible `kind` values :
  26035. * - BABYLON.VertexBuffer.PositionKind
  26036. * - BABYLON.VertexBuffer.UVKind
  26037. * - BABYLON.VertexBuffer.UV2Kind
  26038. * - BABYLON.VertexBuffer.UV3Kind
  26039. * - BABYLON.VertexBuffer.UV4Kind
  26040. * - BABYLON.VertexBuffer.UV5Kind
  26041. * - BABYLON.VertexBuffer.UV6Kind
  26042. * - BABYLON.VertexBuffer.ColorKind
  26043. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26044. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26045. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26046. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26047. *
  26048. * Returns the Mesh.
  26049. */
  26050. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26051. /**
  26052. * Sets the mesh indices.
  26053. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26054. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26055. * This method creates a new index buffer each call.
  26056. * Returns the Mesh.
  26057. */
  26058. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26059. /**
  26060. * Boolean : True if the mesh owns the requested kind of data.
  26061. */
  26062. isVerticesDataPresent(kind: string): boolean;
  26063. /**
  26064. * Returns an array of indices (IndicesArray).
  26065. */
  26066. getIndices(): Nullable<IndicesArray>;
  26067. readonly _positions: Nullable<Vector3[]>;
  26068. /**
  26069. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26070. * This means the mesh underlying bounding box and sphere are recomputed.
  26071. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26072. * @returns the current mesh
  26073. */
  26074. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26075. /** @hidden */
  26076. _preActivate(): InstancedMesh;
  26077. /** @hidden */
  26078. _activate(renderId: number): InstancedMesh;
  26079. /**
  26080. * Returns the current associated LOD AbstractMesh.
  26081. */
  26082. getLOD(camera: Camera): AbstractMesh;
  26083. /** @hidden */
  26084. _syncSubMeshes(): InstancedMesh;
  26085. /** @hidden */
  26086. _generatePointsArray(): boolean;
  26087. /**
  26088. * Creates a new InstancedMesh from the current mesh.
  26089. * - name (string) : the cloned mesh name
  26090. * - newParent (optional Node) : the optional Node to parent the clone to.
  26091. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26092. *
  26093. * Returns the clone.
  26094. */
  26095. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26096. /**
  26097. * Disposes the InstancedMesh.
  26098. * Returns nothing.
  26099. */
  26100. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26101. }
  26102. }
  26103. declare module BABYLON {
  26104. /**
  26105. * Line mesh
  26106. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26107. */
  26108. class LinesMesh extends Mesh {
  26109. /**
  26110. * If vertex color should be applied to the mesh
  26111. */
  26112. useVertexColor?: boolean | undefined;
  26113. /**
  26114. * If vertex alpha should be applied to the mesh
  26115. */
  26116. useVertexAlpha?: boolean | undefined;
  26117. /**
  26118. * Color of the line (Default: White)
  26119. */
  26120. color: Color3;
  26121. /**
  26122. * Alpha of the line (Default: 1)
  26123. */
  26124. alpha: number;
  26125. /**
  26126. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26127. * This margin is expressed in world space coordinates, so its value may vary.
  26128. * Default value is 0.1
  26129. */
  26130. intersectionThreshold: number;
  26131. private _colorShader;
  26132. /**
  26133. * Creates a new LinesMesh
  26134. * @param name defines the name
  26135. * @param scene defines the hosting scene
  26136. * @param parent defines the parent mesh if any
  26137. * @param source defines the optional source LinesMesh used to clone data from
  26138. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26139. * When false, achieved by calling a clone(), also passing False.
  26140. * This will make creation of children, recursive.
  26141. * @param useVertexColor defines if this LinesMesh supports vertex color
  26142. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26143. */
  26144. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26145. /**
  26146. * If vertex color should be applied to the mesh
  26147. */
  26148. useVertexColor?: boolean | undefined,
  26149. /**
  26150. * If vertex alpha should be applied to the mesh
  26151. */
  26152. useVertexAlpha?: boolean | undefined);
  26153. /**
  26154. * Returns the string "LineMesh"
  26155. */
  26156. getClassName(): string;
  26157. /**
  26158. * @hidden
  26159. */
  26160. /**
  26161. * @hidden
  26162. */
  26163. material: Material;
  26164. /**
  26165. * @hidden
  26166. */
  26167. readonly checkCollisions: boolean;
  26168. /** @hidden */
  26169. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26170. /** @hidden */
  26171. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26172. /**
  26173. * Disposes of the line mesh
  26174. * @param doNotRecurse If children should be disposed
  26175. */
  26176. dispose(doNotRecurse?: boolean): void;
  26177. /**
  26178. * Returns a new LineMesh object cloned from the current one.
  26179. */
  26180. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26181. /**
  26182. * Creates a new InstancedLinesMesh object from the mesh model.
  26183. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26184. * @param name defines the name of the new instance
  26185. * @returns a new InstancedLinesMesh
  26186. */
  26187. createInstance(name: string): InstancedLinesMesh;
  26188. }
  26189. /**
  26190. * Creates an instance based on a source LinesMesh
  26191. */
  26192. class InstancedLinesMesh extends InstancedMesh {
  26193. /**
  26194. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26195. * This margin is expressed in world space coordinates, so its value may vary.
  26196. * Initilized with the intersectionThreshold value of the source LinesMesh
  26197. */
  26198. intersectionThreshold: number;
  26199. constructor(name: string, source: LinesMesh);
  26200. /**
  26201. * Returns the string "InstancedLinesMesh".
  26202. */
  26203. getClassName(): string;
  26204. }
  26205. }
  26206. declare module BABYLON {
  26207. /**
  26208. * @hidden
  26209. **/
  26210. class _CreationDataStorage {
  26211. closePath?: boolean;
  26212. closeArray?: boolean;
  26213. idx: number[];
  26214. dashSize: number;
  26215. gapSize: number;
  26216. path3D: Path3D;
  26217. pathArray: Vector3[][];
  26218. arc: number;
  26219. radius: number;
  26220. cap: number;
  26221. tessellation: number;
  26222. }
  26223. /**
  26224. * @hidden
  26225. **/
  26226. class _InstanceDataStorage {
  26227. visibleInstances: any;
  26228. renderIdForInstances: number[];
  26229. batchCache: _InstancesBatch;
  26230. instancesBufferSize: number;
  26231. instancesBuffer: Nullable<Buffer>;
  26232. instancesData: Float32Array;
  26233. overridenInstanceCount: number;
  26234. }
  26235. /**
  26236. * @hidden
  26237. **/
  26238. class _InstancesBatch {
  26239. mustReturn: boolean;
  26240. visibleInstances: Nullable<InstancedMesh[]>[];
  26241. renderSelf: boolean[];
  26242. }
  26243. /**
  26244. * Class used to represent renderable models
  26245. */
  26246. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26247. /**
  26248. * Mesh side orientation : usually the external or front surface
  26249. */
  26250. static readonly FRONTSIDE: number;
  26251. /**
  26252. * Mesh side orientation : usually the internal or back surface
  26253. */
  26254. static readonly BACKSIDE: number;
  26255. /**
  26256. * Mesh side orientation : both internal and external or front and back surfaces
  26257. */
  26258. static readonly DOUBLESIDE: number;
  26259. /**
  26260. * Mesh side orientation : by default, `FRONTSIDE`
  26261. */
  26262. static readonly DEFAULTSIDE: number;
  26263. /**
  26264. * Mesh cap setting : no cap
  26265. */
  26266. static readonly NO_CAP: number;
  26267. /**
  26268. * Mesh cap setting : one cap at the beginning of the mesh
  26269. */
  26270. static readonly CAP_START: number;
  26271. /**
  26272. * Mesh cap setting : one cap at the end of the mesh
  26273. */
  26274. static readonly CAP_END: number;
  26275. /**
  26276. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26277. */
  26278. static readonly CAP_ALL: number;
  26279. private _onBeforeRenderObservable;
  26280. private _onAfterRenderObservable;
  26281. private _onBeforeDrawObservable;
  26282. /**
  26283. * An event triggered before rendering the mesh
  26284. */
  26285. readonly onBeforeRenderObservable: Observable<Mesh>;
  26286. /**
  26287. * An event triggered after rendering the mesh
  26288. */
  26289. readonly onAfterRenderObservable: Observable<Mesh>;
  26290. /**
  26291. * An event triggered before drawing the mesh
  26292. */
  26293. readonly onBeforeDrawObservable: Observable<Mesh>;
  26294. private _onBeforeDrawObserver;
  26295. /**
  26296. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26297. */
  26298. onBeforeDraw: () => void;
  26299. /**
  26300. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26301. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26302. */
  26303. delayLoadState: number;
  26304. /**
  26305. * Gets the list of instances created from this mesh
  26306. * it is not supposed to be modified manually.
  26307. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26308. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26309. */
  26310. instances: InstancedMesh[];
  26311. /**
  26312. * Gets the file containing delay loading data for this mesh
  26313. */
  26314. delayLoadingFile: string;
  26315. /** @hidden */
  26316. _binaryInfo: any;
  26317. private _LODLevels;
  26318. /**
  26319. * User defined function used to change how LOD level selection is done
  26320. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26321. */
  26322. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26323. private _morphTargetManager;
  26324. /**
  26325. * Gets or sets the morph target manager
  26326. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26327. */
  26328. morphTargetManager: Nullable<MorphTargetManager>;
  26329. /** @hidden */
  26330. _creationDataStorage: Nullable<_CreationDataStorage>;
  26331. /** @hidden */
  26332. _geometry: Nullable<Geometry>;
  26333. /** @hidden */
  26334. _delayInfo: Array<string>;
  26335. /** @hidden */
  26336. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26337. /** @hidden */
  26338. _instanceDataStorage: _InstanceDataStorage;
  26339. private _effectiveMaterial;
  26340. /** @hidden */
  26341. _shouldGenerateFlatShading: boolean;
  26342. private _preActivateId;
  26343. /** @hidden */
  26344. _originalBuilderSideOrientation: number;
  26345. /**
  26346. * Use this property to change the original side orientation defined at construction time
  26347. */
  26348. overrideMaterialSideOrientation: Nullable<number>;
  26349. private _areNormalsFrozen;
  26350. private _sourcePositions;
  26351. private _sourceNormals;
  26352. private _source;
  26353. private meshMap;
  26354. /**
  26355. * Gets the source mesh (the one used to clone this one from)
  26356. */
  26357. readonly source: Nullable<Mesh>;
  26358. /**
  26359. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26360. */
  26361. isUnIndexed: boolean;
  26362. /**
  26363. * @constructor
  26364. * @param name The value used by scene.getMeshByName() to do a lookup.
  26365. * @param scene The scene to add this mesh to.
  26366. * @param parent The parent of this mesh, if it has one
  26367. * @param source An optional Mesh from which geometry is shared, cloned.
  26368. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26369. * When false, achieved by calling a clone(), also passing False.
  26370. * This will make creation of children, recursive.
  26371. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26372. */
  26373. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26374. /**
  26375. * Gets the class name
  26376. * @returns the string "Mesh".
  26377. */
  26378. getClassName(): string;
  26379. /**
  26380. * Returns a description of this mesh
  26381. * @param fullDetails define if full details about this mesh must be used
  26382. * @returns a descriptive string representing this mesh
  26383. */
  26384. toString(fullDetails?: boolean): string;
  26385. /** @hidden */
  26386. _unBindEffect(): void;
  26387. /**
  26388. * Gets a boolean indicating if this mesh has LOD
  26389. */
  26390. readonly hasLODLevels: boolean;
  26391. /**
  26392. * Gets the list of MeshLODLevel associated with the current mesh
  26393. * @returns an array of MeshLODLevel
  26394. */
  26395. getLODLevels(): MeshLODLevel[];
  26396. private _sortLODLevels;
  26397. /**
  26398. * Add a mesh as LOD level triggered at the given distance.
  26399. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26400. * @param distance The distance from the center of the object to show this level
  26401. * @param mesh The mesh to be added as LOD level (can be null)
  26402. * @return This mesh (for chaining)
  26403. */
  26404. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26405. /**
  26406. * Returns the LOD level mesh at the passed distance or null if not found.
  26407. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26408. * @param distance The distance from the center of the object to show this level
  26409. * @returns a Mesh or `null`
  26410. */
  26411. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26412. /**
  26413. * Remove a mesh from the LOD array
  26414. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26415. * @param mesh defines the mesh to be removed
  26416. * @return This mesh (for chaining)
  26417. */
  26418. removeLODLevel(mesh: Mesh): Mesh;
  26419. /**
  26420. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26422. * @param camera defines the camera to use to compute distance
  26423. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26424. * @return This mesh (for chaining)
  26425. */
  26426. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26427. /**
  26428. * Gets the mesh internal Geometry object
  26429. */
  26430. readonly geometry: Nullable<Geometry>;
  26431. /**
  26432. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26433. * @returns the total number of vertices
  26434. */
  26435. getTotalVertices(): number;
  26436. /**
  26437. * Returns the content of an associated vertex buffer
  26438. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26439. * - BABYLON.VertexBuffer.PositionKind
  26440. * - BABYLON.VertexBuffer.UVKind
  26441. * - BABYLON.VertexBuffer.UV2Kind
  26442. * - BABYLON.VertexBuffer.UV3Kind
  26443. * - BABYLON.VertexBuffer.UV4Kind
  26444. * - BABYLON.VertexBuffer.UV5Kind
  26445. * - BABYLON.VertexBuffer.UV6Kind
  26446. * - BABYLON.VertexBuffer.ColorKind
  26447. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26448. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26449. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26450. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26451. * @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
  26452. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26453. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26454. */
  26455. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26456. /**
  26457. * Returns the mesh VertexBuffer object from the requested `kind`
  26458. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26459. * - BABYLON.VertexBuffer.PositionKind
  26460. * - BABYLON.VertexBuffer.UVKind
  26461. * - BABYLON.VertexBuffer.UV2Kind
  26462. * - BABYLON.VertexBuffer.UV3Kind
  26463. * - BABYLON.VertexBuffer.UV4Kind
  26464. * - BABYLON.VertexBuffer.UV5Kind
  26465. * - BABYLON.VertexBuffer.UV6Kind
  26466. * - BABYLON.VertexBuffer.ColorKind
  26467. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26468. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26469. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26470. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26471. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26472. */
  26473. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26474. /**
  26475. * Tests if a specific vertex buffer is associated with this mesh
  26476. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26477. * - BABYLON.VertexBuffer.PositionKind
  26478. * - BABYLON.VertexBuffer.UVKind
  26479. * - BABYLON.VertexBuffer.UV2Kind
  26480. * - BABYLON.VertexBuffer.UV3Kind
  26481. * - BABYLON.VertexBuffer.UV4Kind
  26482. * - BABYLON.VertexBuffer.UV5Kind
  26483. * - BABYLON.VertexBuffer.UV6Kind
  26484. * - BABYLON.VertexBuffer.ColorKind
  26485. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26486. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26487. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26488. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26489. * @returns a boolean
  26490. */
  26491. isVerticesDataPresent(kind: string): boolean;
  26492. /**
  26493. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26494. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26495. * - BABYLON.VertexBuffer.PositionKind
  26496. * - BABYLON.VertexBuffer.UVKind
  26497. * - BABYLON.VertexBuffer.UV2Kind
  26498. * - BABYLON.VertexBuffer.UV3Kind
  26499. * - BABYLON.VertexBuffer.UV4Kind
  26500. * - BABYLON.VertexBuffer.UV5Kind
  26501. * - BABYLON.VertexBuffer.UV6Kind
  26502. * - BABYLON.VertexBuffer.ColorKind
  26503. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26504. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26505. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26506. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26507. * @returns a boolean
  26508. */
  26509. isVertexBufferUpdatable(kind: string): boolean;
  26510. /**
  26511. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26512. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26513. * - BABYLON.VertexBuffer.PositionKind
  26514. * - BABYLON.VertexBuffer.UVKind
  26515. * - BABYLON.VertexBuffer.UV2Kind
  26516. * - BABYLON.VertexBuffer.UV3Kind
  26517. * - BABYLON.VertexBuffer.UV4Kind
  26518. * - BABYLON.VertexBuffer.UV5Kind
  26519. * - BABYLON.VertexBuffer.UV6Kind
  26520. * - BABYLON.VertexBuffer.ColorKind
  26521. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26522. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26523. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26524. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26525. * @returns an array of strings
  26526. */
  26527. getVerticesDataKinds(): string[];
  26528. /**
  26529. * Returns a positive integer : the total number of indices in this mesh geometry.
  26530. * @returns the numner of indices or zero if the mesh has no geometry.
  26531. */
  26532. getTotalIndices(): number;
  26533. /**
  26534. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26535. * @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.
  26536. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26537. * @returns the indices array or an empty array if the mesh has no geometry
  26538. */
  26539. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26540. readonly isBlocked: boolean;
  26541. /**
  26542. * Determine if the current mesh is ready to be rendered
  26543. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26544. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26545. * @returns true if all associated assets are ready (material, textures, shaders)
  26546. */
  26547. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26548. /**
  26549. * 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.
  26550. */
  26551. readonly areNormalsFrozen: boolean;
  26552. /**
  26553. * 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.
  26554. * @returns the current mesh
  26555. */
  26556. freezeNormals(): Mesh;
  26557. /**
  26558. * 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
  26559. * @returns the current mesh
  26560. */
  26561. unfreezeNormals(): Mesh;
  26562. /**
  26563. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26564. */
  26565. overridenInstanceCount: number;
  26566. /** @hidden */
  26567. _preActivate(): Mesh;
  26568. /** @hidden */
  26569. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26570. /** @hidden */
  26571. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26572. /**
  26573. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26574. * This means the mesh underlying bounding box and sphere are recomputed.
  26575. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26576. * @returns the current mesh
  26577. */
  26578. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26579. /** @hidden */
  26580. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26581. /**
  26582. * This function will subdivide the mesh into multiple submeshes
  26583. * @param count defines the expected number of submeshes
  26584. */
  26585. subdivide(count: number): void;
  26586. /**
  26587. * Copy a FloatArray into a specific associated vertex buffer
  26588. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26589. * - BABYLON.VertexBuffer.PositionKind
  26590. * - BABYLON.VertexBuffer.UVKind
  26591. * - BABYLON.VertexBuffer.UV2Kind
  26592. * - BABYLON.VertexBuffer.UV3Kind
  26593. * - BABYLON.VertexBuffer.UV4Kind
  26594. * - BABYLON.VertexBuffer.UV5Kind
  26595. * - BABYLON.VertexBuffer.UV6Kind
  26596. * - BABYLON.VertexBuffer.ColorKind
  26597. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26598. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26599. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26600. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26601. * @param data defines the data source
  26602. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26603. * @param stride defines the data stride size (can be null)
  26604. * @returns the current mesh
  26605. */
  26606. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26607. /**
  26608. * Flags an associated vertex buffer as updatable
  26609. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26610. * - BABYLON.VertexBuffer.PositionKind
  26611. * - BABYLON.VertexBuffer.UVKind
  26612. * - BABYLON.VertexBuffer.UV2Kind
  26613. * - BABYLON.VertexBuffer.UV3Kind
  26614. * - BABYLON.VertexBuffer.UV4Kind
  26615. * - BABYLON.VertexBuffer.UV5Kind
  26616. * - BABYLON.VertexBuffer.UV6Kind
  26617. * - BABYLON.VertexBuffer.ColorKind
  26618. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26619. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26620. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26621. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26622. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26623. */
  26624. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26625. /**
  26626. * Sets the mesh global Vertex Buffer
  26627. * @param buffer defines the buffer to use
  26628. * @returns the current mesh
  26629. */
  26630. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26631. /**
  26632. * Update a specific associated vertex buffer
  26633. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26634. * - BABYLON.VertexBuffer.PositionKind
  26635. * - BABYLON.VertexBuffer.UVKind
  26636. * - BABYLON.VertexBuffer.UV2Kind
  26637. * - BABYLON.VertexBuffer.UV3Kind
  26638. * - BABYLON.VertexBuffer.UV4Kind
  26639. * - BABYLON.VertexBuffer.UV5Kind
  26640. * - BABYLON.VertexBuffer.UV6Kind
  26641. * - BABYLON.VertexBuffer.ColorKind
  26642. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26643. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26644. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26645. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26646. * @param data defines the data source
  26647. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26648. * @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)
  26649. * @returns the current mesh
  26650. */
  26651. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26652. /**
  26653. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26654. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26655. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26656. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26657. * @returns the current mesh
  26658. */
  26659. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26660. /**
  26661. * Creates a un-shared specific occurence of the geometry for the mesh.
  26662. * @returns the current mesh
  26663. */
  26664. makeGeometryUnique(): Mesh;
  26665. /**
  26666. * Set the index buffer of this mesh
  26667. * @param indices defines the source data
  26668. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26669. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26670. * @returns the current mesh
  26671. */
  26672. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26673. /**
  26674. * Update the current index buffer
  26675. * @param indices defines the source data
  26676. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26677. * @returns the current mesh
  26678. */
  26679. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26680. /**
  26681. * Invert the geometry to move from a right handed system to a left handed one.
  26682. * @returns the current mesh
  26683. */
  26684. toLeftHanded(): Mesh;
  26685. /** @hidden */
  26686. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26687. /** @hidden */
  26688. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26689. /**
  26690. * Registers for this mesh a javascript function called just before the rendering process
  26691. * @param func defines the function to call before rendering this mesh
  26692. * @returns the current mesh
  26693. */
  26694. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26695. /**
  26696. * Disposes a previously registered javascript function called before the rendering
  26697. * @param func defines the function to remove
  26698. * @returns the current mesh
  26699. */
  26700. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26701. /**
  26702. * Registers for this mesh a javascript function called just after the rendering is complete
  26703. * @param func defines the function to call after rendering this mesh
  26704. * @returns the current mesh
  26705. */
  26706. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26707. /**
  26708. * Disposes a previously registered javascript function called after the rendering.
  26709. * @param func defines the function to remove
  26710. * @returns the current mesh
  26711. */
  26712. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26713. /** @hidden */
  26714. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26715. /** @hidden */
  26716. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26717. /** @hidden */
  26718. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26719. /**
  26720. * 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
  26721. * @param subMesh defines the subMesh to render
  26722. * @param enableAlphaMode defines if alpha mode can be changed
  26723. * @returns the current mesh
  26724. */
  26725. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26726. private _onBeforeDraw;
  26727. /**
  26728. * Renormalize the mesh and patch it up if there are no weights
  26729. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26730. * However in the case of zero weights then we set just a single influence to 1.
  26731. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26732. */
  26733. cleanMatrixWeights(): void;
  26734. private normalizeSkinFourWeights;
  26735. private normalizeSkinWeightsAndExtra;
  26736. /**
  26737. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26738. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26739. * the user know there was an issue with importing the mesh
  26740. * @returns a validation object with skinned, valid and report string
  26741. */
  26742. validateSkinning(): {
  26743. skinned: boolean;
  26744. valid: boolean;
  26745. report: string;
  26746. };
  26747. /** @hidden */
  26748. _checkDelayState(): Mesh;
  26749. private _queueLoad;
  26750. /**
  26751. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26752. * A mesh is in the frustum if its bounding box intersects the frustum
  26753. * @param frustumPlanes defines the frustum to test
  26754. * @returns true if the mesh is in the frustum planes
  26755. */
  26756. isInFrustum(frustumPlanes: Plane[]): boolean;
  26757. /**
  26758. * Sets the mesh material by the material or multiMaterial `id` property
  26759. * @param id is a string identifying the material or the multiMaterial
  26760. * @returns the current mesh
  26761. */
  26762. setMaterialByID(id: string): Mesh;
  26763. /**
  26764. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26765. * @returns an array of IAnimatable
  26766. */
  26767. getAnimatables(): IAnimatable[];
  26768. /**
  26769. * Modifies the mesh geometry according to the passed transformation matrix.
  26770. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26771. * The mesh normals are modified using the same transformation.
  26772. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26773. * @param transform defines the transform matrix to use
  26774. * @see http://doc.babylonjs.com/resources/baking_transformations
  26775. * @returns the current mesh
  26776. */
  26777. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26778. /**
  26779. * Modifies the mesh geometry according to its own current World Matrix.
  26780. * The mesh World Matrix is then reset.
  26781. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26782. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26783. * @see http://doc.babylonjs.com/resources/baking_transformations
  26784. * @returns the current mesh
  26785. */
  26786. bakeCurrentTransformIntoVertices(): Mesh;
  26787. /** @hidden */
  26788. readonly _positions: Nullable<Vector3[]>;
  26789. /** @hidden */
  26790. _resetPointsArrayCache(): Mesh;
  26791. /** @hidden */
  26792. _generatePointsArray(): boolean;
  26793. /**
  26794. * Returns a new Mesh object generated from the current mesh properties.
  26795. * This method must not get confused with createInstance()
  26796. * @param name is a string, the name given to the new mesh
  26797. * @param newParent can be any Node object (default `null`)
  26798. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26799. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26800. * @returns a new mesh
  26801. */
  26802. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26803. /**
  26804. * Releases resources associated with this mesh.
  26805. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26806. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26807. */
  26808. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26809. /**
  26810. * Modifies the mesh geometry according to a displacement map.
  26811. * 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.
  26812. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26813. * @param url is a string, the URL from the image file is to be downloaded.
  26814. * @param minHeight is the lower limit of the displacement.
  26815. * @param maxHeight is the upper limit of the displacement.
  26816. * @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.
  26817. * @param uvOffset is an optional vector2 used to offset UV.
  26818. * @param uvScale is an optional vector2 used to scale UV.
  26819. * @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.
  26820. * @returns the Mesh.
  26821. */
  26822. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26823. /**
  26824. * Modifies the mesh geometry according to a displacementMap buffer.
  26825. * 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.
  26826. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26827. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26828. * @param heightMapWidth is the width of the buffer image.
  26829. * @param heightMapHeight is the height of the buffer image.
  26830. * @param minHeight is the lower limit of the displacement.
  26831. * @param maxHeight is the upper limit of the displacement.
  26832. * @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.
  26833. * @param uvOffset is an optional vector2 used to offset UV.
  26834. * @param uvScale is an optional vector2 used to scale UV.
  26835. * @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.
  26836. * @returns the Mesh.
  26837. */
  26838. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26839. /**
  26840. * Modify the mesh to get a flat shading rendering.
  26841. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26842. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26843. * @returns current mesh
  26844. */
  26845. convertToFlatShadedMesh(): Mesh;
  26846. /**
  26847. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26848. * In other words, more vertices, no more indices and a single bigger VBO.
  26849. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26850. * @returns current mesh
  26851. */
  26852. convertToUnIndexedMesh(): Mesh;
  26853. /**
  26854. * Inverses facet orientations.
  26855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26856. * @param flipNormals will also inverts the normals
  26857. * @returns current mesh
  26858. */
  26859. flipFaces(flipNormals?: boolean): Mesh;
  26860. /**
  26861. * Creates a new InstancedMesh object from the mesh model.
  26862. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26863. * @param name defines the name of the new instance
  26864. * @returns a new InstancedMesh
  26865. */
  26866. createInstance(name: string): InstancedMesh;
  26867. /**
  26868. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26869. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26870. * @returns the current mesh
  26871. */
  26872. synchronizeInstances(): Mesh;
  26873. /**
  26874. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26875. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26876. * This should be used together with the simplification to avoid disappearing triangles.
  26877. * @param successCallback an optional success callback to be called after the optimization finished.
  26878. * @returns the current mesh
  26879. */
  26880. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26881. /**
  26882. * Serialize current mesh
  26883. * @param serializationObject defines the object which will receive the serialization data
  26884. */
  26885. serialize(serializationObject: any): void;
  26886. /** @hidden */
  26887. _syncGeometryWithMorphTargetManager(): void;
  26888. /**
  26889. * Returns a new Mesh object parsed from the source provided.
  26890. * @param parsedMesh is the source
  26891. * @param scene defines the hosting scene
  26892. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26893. * @returns a new Mesh
  26894. */
  26895. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26896. /**
  26897. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26898. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26899. * @param name defines the name of the mesh to create
  26900. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26901. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26902. * @param closePath creates a seam between the first and the last points of each path of the path array
  26903. * @param offset is taken in account only if the `pathArray` is containing a single path
  26904. * @param scene defines the hosting scene
  26905. * @param updatable defines if the mesh must be flagged as updatable
  26906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26907. * @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)
  26908. * @returns a new Mesh
  26909. */
  26910. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26911. /**
  26912. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26913. * @param name defines the name of the mesh to create
  26914. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26915. * @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
  26916. * @param scene defines the hosting scene
  26917. * @param updatable defines if the mesh must be flagged as updatable
  26918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26919. * @returns a new Mesh
  26920. */
  26921. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26922. /**
  26923. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26924. * @param name defines the name of the mesh to create
  26925. * @param size sets the size (float) of each box side (default 1)
  26926. * @param scene defines the hosting scene
  26927. * @param updatable defines if the mesh must be flagged as updatable
  26928. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26929. * @returns a new Mesh
  26930. */
  26931. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26932. /**
  26933. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26934. * @param name defines the name of the mesh to create
  26935. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26936. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26937. * @param scene defines the hosting scene
  26938. * @param updatable defines if the mesh must be flagged as updatable
  26939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26940. * @returns a new Mesh
  26941. */
  26942. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26943. /**
  26944. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26945. * @param name defines the name of the mesh to create
  26946. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26947. * @param diameterTop set the top cap diameter (floats, default 1)
  26948. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26949. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26950. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26951. * @param scene defines the hosting scene
  26952. * @param updatable defines if the mesh must be flagged as updatable
  26953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26954. * @returns a new Mesh
  26955. */
  26956. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26957. /**
  26958. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26959. * @param name defines the name of the mesh to create
  26960. * @param diameter sets the diameter size (float) of the torus (default 1)
  26961. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26962. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26963. * @param scene defines the hosting scene
  26964. * @param updatable defines if the mesh must be flagged as updatable
  26965. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26966. * @returns a new Mesh
  26967. */
  26968. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26969. /**
  26970. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26971. * @param name defines the name of the mesh to create
  26972. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26973. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26974. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26975. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26976. * @param p the number of windings on X axis (positive integers, default 2)
  26977. * @param q the number of windings on Y axis (positive integers, default 3)
  26978. * @param scene defines the hosting scene
  26979. * @param updatable defines if the mesh must be flagged as updatable
  26980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26981. * @returns a new Mesh
  26982. */
  26983. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26984. /**
  26985. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26986. * @param name defines the name of the mesh to create
  26987. * @param points is an array successive Vector3
  26988. * @param scene defines the hosting scene
  26989. * @param updatable defines if the mesh must be flagged as updatable
  26990. * @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).
  26991. * @returns a new Mesh
  26992. */
  26993. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26994. /**
  26995. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26996. * @param name defines the name of the mesh to create
  26997. * @param points is an array successive Vector3
  26998. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26999. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27000. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27001. * @param scene defines the hosting scene
  27002. * @param updatable defines if the mesh must be flagged as updatable
  27003. * @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)
  27004. * @returns a new Mesh
  27005. */
  27006. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27007. /**
  27008. * Creates a polygon mesh.
  27009. * Please consider using the same method from the MeshBuilder class instead.
  27010. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27011. * 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.
  27012. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27013. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27014. * Remember you can only change the shape positions, not their number when updating a polygon.
  27015. */
  27016. /**
  27017. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27018. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27019. * @param name defines the name of the mesh to create
  27020. * @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
  27021. * @param scene defines the hosting scene
  27022. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27023. * @param updatable defines if the mesh must be flagged as updatable
  27024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27025. * @returns a new Mesh
  27026. */
  27027. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27028. /**
  27029. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27030. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27031. * @param name defines the name of the mesh to create
  27032. * @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
  27033. * @param depth defines the height of extrusion
  27034. * @param scene defines the hosting scene
  27035. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27036. * @param updatable defines if the mesh must be flagged as updatable
  27037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27038. * @returns a new Mesh
  27039. */
  27040. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27041. /**
  27042. * Creates an extruded shape mesh.
  27043. * 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
  27044. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27045. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27046. * @param name defines the name of the mesh to create
  27047. * @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
  27048. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27049. * @param scale is the value to scale the shape
  27050. * @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
  27051. * @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
  27052. * @param scene defines the hosting scene
  27053. * @param updatable defines if the mesh must be flagged as updatable
  27054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27055. * @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)
  27056. * @returns a new Mesh
  27057. */
  27058. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27059. /**
  27060. * Creates an custom extruded shape mesh.
  27061. * The custom extrusion is a parametric shape.
  27062. * It has no predefined shape. Its final shape will depend on the input parameters.
  27063. * Please consider using the same method from the MeshBuilder class instead
  27064. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27065. * @param name defines the name of the mesh to create
  27066. * @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
  27067. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27068. * @param scaleFunction is a custom Javascript function called on each path point
  27069. * @param rotationFunction is a custom Javascript function called on each path point
  27070. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27071. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27072. * @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
  27073. * @param scene defines the hosting scene
  27074. * @param updatable defines if the mesh must be flagged as updatable
  27075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27076. * @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)
  27077. * @returns a new Mesh
  27078. */
  27079. 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;
  27080. /**
  27081. * Creates lathe mesh.
  27082. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27083. * Please consider using the same method from the MeshBuilder class instead
  27084. * @param name defines the name of the mesh to create
  27085. * @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
  27086. * @param radius is the radius value of the lathe
  27087. * @param tessellation is the side number of the lathe.
  27088. * @param scene defines the hosting scene
  27089. * @param updatable defines if the mesh must be flagged as updatable
  27090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27091. * @returns a new Mesh
  27092. */
  27093. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27094. /**
  27095. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27096. * @param name defines the name of the mesh to create
  27097. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27098. * @param scene defines the hosting scene
  27099. * @param updatable defines if the mesh must be flagged as updatable
  27100. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27101. * @returns a new Mesh
  27102. */
  27103. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27104. /**
  27105. * Creates a ground mesh.
  27106. * Please consider using the same method from the MeshBuilder class instead
  27107. * @param name defines the name of the mesh to create
  27108. * @param width set the width of the ground
  27109. * @param height set the height of the ground
  27110. * @param subdivisions sets the number of subdivisions per side
  27111. * @param scene defines the hosting scene
  27112. * @param updatable defines if the mesh must be flagged as updatable
  27113. * @returns a new Mesh
  27114. */
  27115. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27116. /**
  27117. * Creates a tiled ground mesh.
  27118. * Please consider using the same method from the MeshBuilder class instead
  27119. * @param name defines the name of the mesh to create
  27120. * @param xmin set the ground minimum X coordinate
  27121. * @param zmin set the ground minimum Y coordinate
  27122. * @param xmax set the ground maximum X coordinate
  27123. * @param zmax set the ground maximum Z coordinate
  27124. * @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
  27125. * @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
  27126. * @param scene defines the hosting scene
  27127. * @param updatable defines if the mesh must be flagged as updatable
  27128. * @returns a new Mesh
  27129. */
  27130. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27131. w: number;
  27132. h: number;
  27133. }, precision: {
  27134. w: number;
  27135. h: number;
  27136. }, scene: Scene, updatable?: boolean): Mesh;
  27137. /**
  27138. * Creates a ground mesh from a height map.
  27139. * Please consider using the same method from the MeshBuilder class instead
  27140. * @see http://doc.babylonjs.com/babylon101/height_map
  27141. * @param name defines the name of the mesh to create
  27142. * @param url sets the URL of the height map image resource
  27143. * @param width set the ground width size
  27144. * @param height set the ground height size
  27145. * @param subdivisions sets the number of subdivision per side
  27146. * @param minHeight is the minimum altitude on the ground
  27147. * @param maxHeight is the maximum altitude on the ground
  27148. * @param scene defines the hosting scene
  27149. * @param updatable defines if the mesh must be flagged as updatable
  27150. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27151. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27152. * @returns a new Mesh
  27153. */
  27154. 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;
  27155. /**
  27156. * Creates a tube mesh.
  27157. * The tube is a parametric shape.
  27158. * It has no predefined shape. Its final shape will depend on the input parameters.
  27159. * Please consider using the same method from the MeshBuilder class instead
  27160. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27161. * @param name defines the name of the mesh to create
  27162. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27163. * @param radius sets the tube radius size
  27164. * @param tessellation is the number of sides on the tubular surface
  27165. * @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
  27166. * @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
  27167. * @param scene defines the hosting scene
  27168. * @param updatable defines if the mesh must be flagged as updatable
  27169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27170. * @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)
  27171. * @returns a new Mesh
  27172. */
  27173. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27174. (i: number, distance: number): number;
  27175. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27176. /**
  27177. * Creates a polyhedron mesh.
  27178. * Please consider using the same method from the MeshBuilder class instead.
  27179. * * 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
  27180. * * The parameter `size` (positive float, default 1) sets the polygon size
  27181. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27182. * * 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`
  27183. * * 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
  27184. * * 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)`)
  27185. * * 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
  27186. * * 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
  27187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27188. * * 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
  27189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27190. * @param name defines the name of the mesh to create
  27191. * @param options defines the options used to create the mesh
  27192. * @param scene defines the hosting scene
  27193. * @returns a new Mesh
  27194. */
  27195. static CreatePolyhedron(name: string, options: {
  27196. type?: number;
  27197. size?: number;
  27198. sizeX?: number;
  27199. sizeY?: number;
  27200. sizeZ?: number;
  27201. custom?: any;
  27202. faceUV?: Vector4[];
  27203. faceColors?: Color4[];
  27204. updatable?: boolean;
  27205. sideOrientation?: number;
  27206. }, scene: Scene): Mesh;
  27207. /**
  27208. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27209. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27210. * * 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`)
  27211. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27212. * * 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
  27213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27214. * * 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
  27215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27216. * @param name defines the name of the mesh
  27217. * @param options defines the options used to create the mesh
  27218. * @param scene defines the hosting scene
  27219. * @returns a new Mesh
  27220. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27221. */
  27222. static CreateIcoSphere(name: string, options: {
  27223. radius?: number;
  27224. flat?: boolean;
  27225. subdivisions?: number;
  27226. sideOrientation?: number;
  27227. updatable?: boolean;
  27228. }, scene: Scene): Mesh;
  27229. /**
  27230. * Creates a decal mesh.
  27231. * Please consider using the same method from the MeshBuilder class instead.
  27232. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27233. * @param name defines the name of the mesh
  27234. * @param sourceMesh defines the mesh receiving the decal
  27235. * @param position sets the position of the decal in world coordinates
  27236. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27237. * @param size sets the decal scaling
  27238. * @param angle sets the angle to rotate the decal
  27239. * @returns a new Mesh
  27240. */
  27241. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27242. /**
  27243. * Prepare internal position array for software CPU skinning
  27244. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27245. */
  27246. setPositionsForCPUSkinning(): Float32Array;
  27247. /**
  27248. * Prepare internal normal array for software CPU skinning
  27249. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27250. */
  27251. setNormalsForCPUSkinning(): Float32Array;
  27252. /**
  27253. * Updates the vertex buffer by applying transformation from the bones
  27254. * @param skeleton defines the skeleton to apply to current mesh
  27255. * @returns the current mesh
  27256. */
  27257. applySkeleton(skeleton: Skeleton): Mesh;
  27258. /**
  27259. * 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
  27260. * @param meshes defines the list of meshes to scan
  27261. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27262. */
  27263. static MinMax(meshes: AbstractMesh[]): {
  27264. min: Vector3;
  27265. max: Vector3;
  27266. };
  27267. /**
  27268. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27269. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27270. * @returns a vector3
  27271. */
  27272. static Center(meshesOrMinMaxVector: {
  27273. min: Vector3;
  27274. max: Vector3;
  27275. } | AbstractMesh[]): Vector3;
  27276. /**
  27277. * Merge the array of meshes into a single mesh for performance reasons.
  27278. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27279. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27280. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27281. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27282. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27283. * @returns a new mesh
  27284. */
  27285. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27286. /** @hidden */
  27287. addInstance(instance: InstancedMesh): void;
  27288. /** @hidden */
  27289. removeInstance(instance: InstancedMesh): void;
  27290. }
  27291. }
  27292. declare module BABYLON {
  27293. /**
  27294. * Define an interface for all classes that will get and set the data on vertices
  27295. */
  27296. interface IGetSetVerticesData {
  27297. /**
  27298. * Gets a boolean indicating if specific vertex data is present
  27299. * @param kind defines the vertex data kind to use
  27300. * @returns true is data kind is present
  27301. */
  27302. isVerticesDataPresent(kind: string): boolean;
  27303. /**
  27304. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27305. * @param kind defines the data kind (Position, normal, etc...)
  27306. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27307. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27308. * @returns a float array containing vertex data
  27309. */
  27310. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27311. /**
  27312. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27313. * @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.
  27314. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27315. * @returns the indices array or an empty array if the mesh has no geometry
  27316. */
  27317. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27318. /**
  27319. * Set specific vertex data
  27320. * @param kind defines the data kind (Position, normal, etc...)
  27321. * @param data defines the vertex data to use
  27322. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27323. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27324. */
  27325. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27326. /**
  27327. * Update a specific associated vertex buffer
  27328. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27329. * - BABYLON.VertexBuffer.PositionKind
  27330. * - BABYLON.VertexBuffer.UVKind
  27331. * - BABYLON.VertexBuffer.UV2Kind
  27332. * - BABYLON.VertexBuffer.UV3Kind
  27333. * - BABYLON.VertexBuffer.UV4Kind
  27334. * - BABYLON.VertexBuffer.UV5Kind
  27335. * - BABYLON.VertexBuffer.UV6Kind
  27336. * - BABYLON.VertexBuffer.ColorKind
  27337. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27338. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27339. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27340. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27341. * @param data defines the data source
  27342. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27343. * @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)
  27344. */
  27345. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27346. /**
  27347. * Creates a new index buffer
  27348. * @param indices defines the indices to store in the index buffer
  27349. * @param totalVertices defines the total number of vertices (could be null)
  27350. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27351. */
  27352. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27353. }
  27354. /**
  27355. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27356. */
  27357. class VertexData {
  27358. /**
  27359. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27360. */
  27361. positions: Nullable<FloatArray>;
  27362. /**
  27363. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27364. */
  27365. normals: Nullable<FloatArray>;
  27366. /**
  27367. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27368. */
  27369. tangents: Nullable<FloatArray>;
  27370. /**
  27371. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27372. */
  27373. uvs: Nullable<FloatArray>;
  27374. /**
  27375. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27376. */
  27377. uvs2: Nullable<FloatArray>;
  27378. /**
  27379. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27380. */
  27381. uvs3: Nullable<FloatArray>;
  27382. /**
  27383. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27384. */
  27385. uvs4: Nullable<FloatArray>;
  27386. /**
  27387. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27388. */
  27389. uvs5: Nullable<FloatArray>;
  27390. /**
  27391. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27392. */
  27393. uvs6: Nullable<FloatArray>;
  27394. /**
  27395. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27396. */
  27397. colors: Nullable<FloatArray>;
  27398. /**
  27399. * 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).
  27400. */
  27401. matricesIndices: Nullable<FloatArray>;
  27402. /**
  27403. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27404. */
  27405. matricesWeights: Nullable<FloatArray>;
  27406. /**
  27407. * An array extending the number of possible indices
  27408. */
  27409. matricesIndicesExtra: Nullable<FloatArray>;
  27410. /**
  27411. * An array extending the number of possible weights when the number of indices is extended
  27412. */
  27413. matricesWeightsExtra: Nullable<FloatArray>;
  27414. /**
  27415. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27416. */
  27417. indices: Nullable<IndicesArray>;
  27418. /**
  27419. * Uses the passed data array to set the set the values for the specified kind of data
  27420. * @param data a linear array of floating numbers
  27421. * @param kind the type of data that is being set, eg positions, colors etc
  27422. */
  27423. set(data: FloatArray, kind: string): void;
  27424. /**
  27425. * Associates the vertexData to the passed Mesh.
  27426. * Sets it as updatable or not (default `false`)
  27427. * @param mesh the mesh the vertexData is applied to
  27428. * @param updatable when used and having the value true allows new data to update the vertexData
  27429. * @returns the VertexData
  27430. */
  27431. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27432. /**
  27433. * Associates the vertexData to the passed Geometry.
  27434. * Sets it as updatable or not (default `false`)
  27435. * @param geometry the geometry the vertexData is applied to
  27436. * @param updatable when used and having the value true allows new data to update the vertexData
  27437. * @returns VertexData
  27438. */
  27439. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27440. /**
  27441. * Updates the associated mesh
  27442. * @param mesh the mesh to be updated
  27443. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27444. * @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
  27445. * @returns VertexData
  27446. */
  27447. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27448. /**
  27449. * Updates the associated geometry
  27450. * @param geometry the geometry to be updated
  27451. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27452. * @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
  27453. * @returns VertexData.
  27454. */
  27455. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27456. private _applyTo;
  27457. private _update;
  27458. /**
  27459. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27460. * @param matrix the transforming matrix
  27461. * @returns the VertexData
  27462. */
  27463. transform(matrix: Matrix): VertexData;
  27464. /**
  27465. * Merges the passed VertexData into the current one
  27466. * @param other the VertexData to be merged into the current one
  27467. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27468. * @returns the modified VertexData
  27469. */
  27470. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27471. private _mergeElement;
  27472. private _validate;
  27473. /**
  27474. * Serializes the VertexData
  27475. * @returns a serialized object
  27476. */
  27477. serialize(): any;
  27478. /**
  27479. * Extracts the vertexData from a mesh
  27480. * @param mesh the mesh from which to extract the VertexData
  27481. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27482. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27483. * @returns the object VertexData associated to the passed mesh
  27484. */
  27485. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27486. /**
  27487. * Extracts the vertexData from the geometry
  27488. * @param geometry the geometry from which to extract the VertexData
  27489. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27490. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27491. * @returns the object VertexData associated to the passed mesh
  27492. */
  27493. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27494. private static _ExtractFrom;
  27495. /**
  27496. * Creates the VertexData for a Ribbon
  27497. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27498. * * pathArray array of paths, each of which an array of successive Vector3
  27499. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27500. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27501. * * 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
  27502. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27503. * * 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)
  27504. * * 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)
  27505. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27506. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27507. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27508. * @returns the VertexData of the ribbon
  27509. */
  27510. static CreateRibbon(options: {
  27511. pathArray: Vector3[][];
  27512. closeArray?: boolean;
  27513. closePath?: boolean;
  27514. offset?: number;
  27515. sideOrientation?: number;
  27516. frontUVs?: Vector4;
  27517. backUVs?: Vector4;
  27518. invertUV?: boolean;
  27519. uvs?: Vector2[];
  27520. colors?: Color4[];
  27521. }): VertexData;
  27522. /**
  27523. * Creates the VertexData for a box
  27524. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27525. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27526. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27527. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27528. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27529. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27530. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27531. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27532. * * 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)
  27533. * * 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)
  27534. * @returns the VertexData of the box
  27535. */
  27536. static CreateBox(options: {
  27537. size?: number;
  27538. width?: number;
  27539. height?: number;
  27540. depth?: number;
  27541. faceUV?: Vector4[];
  27542. faceColors?: Color4[];
  27543. sideOrientation?: number;
  27544. frontUVs?: Vector4;
  27545. backUVs?: Vector4;
  27546. }): VertexData;
  27547. /**
  27548. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27549. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27550. * * segments sets the number of horizontal strips optional, default 32
  27551. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27552. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27553. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27554. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27555. * * 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
  27556. * * 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
  27557. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27558. * * 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)
  27559. * * 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)
  27560. * @returns the VertexData of the ellipsoid
  27561. */
  27562. static CreateSphere(options: {
  27563. segments?: number;
  27564. diameter?: number;
  27565. diameterX?: number;
  27566. diameterY?: number;
  27567. diameterZ?: number;
  27568. arc?: number;
  27569. slice?: number;
  27570. sideOrientation?: number;
  27571. frontUVs?: Vector4;
  27572. backUVs?: Vector4;
  27573. }): VertexData;
  27574. /**
  27575. * Creates the VertexData for a cylinder, cone or prism
  27576. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27577. * * height sets the height (y direction) of the cylinder, optional, default 2
  27578. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27579. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27580. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27581. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27582. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27583. * * 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
  27584. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27585. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27586. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27587. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27588. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27589. * * 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)
  27590. * * 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)
  27591. * @returns the VertexData of the cylinder, cone or prism
  27592. */
  27593. static CreateCylinder(options: {
  27594. height?: number;
  27595. diameterTop?: number;
  27596. diameterBottom?: number;
  27597. diameter?: number;
  27598. tessellation?: number;
  27599. subdivisions?: number;
  27600. arc?: number;
  27601. faceColors?: Color4[];
  27602. faceUV?: Vector4[];
  27603. hasRings?: boolean;
  27604. enclose?: boolean;
  27605. sideOrientation?: number;
  27606. frontUVs?: Vector4;
  27607. backUVs?: Vector4;
  27608. }): VertexData;
  27609. /**
  27610. * Creates the VertexData for a torus
  27611. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27612. * * diameter the diameter of the torus, optional default 1
  27613. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27614. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27615. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27616. * * 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)
  27617. * * 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)
  27618. * @returns the VertexData of the torus
  27619. */
  27620. static CreateTorus(options: {
  27621. diameter?: number;
  27622. thickness?: number;
  27623. tessellation?: number;
  27624. sideOrientation?: number;
  27625. frontUVs?: Vector4;
  27626. backUVs?: Vector4;
  27627. }): VertexData;
  27628. /**
  27629. * Creates the VertexData of the LineSystem
  27630. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27631. * - lines an array of lines, each line being an array of successive Vector3
  27632. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27633. * @returns the VertexData of the LineSystem
  27634. */
  27635. static CreateLineSystem(options: {
  27636. lines: Vector3[][];
  27637. colors?: Nullable<Color4[][]>;
  27638. }): VertexData;
  27639. /**
  27640. * Create the VertexData for a DashedLines
  27641. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27642. * - points an array successive Vector3
  27643. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27644. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27645. * - dashNb the intended total number of dashes, optional, default 200
  27646. * @returns the VertexData for the DashedLines
  27647. */
  27648. static CreateDashedLines(options: {
  27649. points: Vector3[];
  27650. dashSize?: number;
  27651. gapSize?: number;
  27652. dashNb?: number;
  27653. }): VertexData;
  27654. /**
  27655. * Creates the VertexData for a Ground
  27656. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27657. * - width the width (x direction) of the ground, optional, default 1
  27658. * - height the height (z direction) of the ground, optional, default 1
  27659. * - subdivisions the number of subdivisions per side, optional, default 1
  27660. * @returns the VertexData of the Ground
  27661. */
  27662. static CreateGround(options: {
  27663. width?: number;
  27664. height?: number;
  27665. subdivisions?: number;
  27666. subdivisionsX?: number;
  27667. subdivisionsY?: number;
  27668. }): VertexData;
  27669. /**
  27670. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27671. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27672. * * xmin the ground minimum X coordinate, optional, default -1
  27673. * * zmin the ground minimum Z coordinate, optional, default -1
  27674. * * xmax the ground maximum X coordinate, optional, default 1
  27675. * * zmax the ground maximum Z coordinate, optional, default 1
  27676. * * 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}
  27677. * * 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}
  27678. * @returns the VertexData of the TiledGround
  27679. */
  27680. static CreateTiledGround(options: {
  27681. xmin: number;
  27682. zmin: number;
  27683. xmax: number;
  27684. zmax: number;
  27685. subdivisions?: {
  27686. w: number;
  27687. h: number;
  27688. };
  27689. precision?: {
  27690. w: number;
  27691. h: number;
  27692. };
  27693. }): VertexData;
  27694. /**
  27695. * Creates the VertexData of the Ground designed from a heightmap
  27696. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27697. * * width the width (x direction) of the ground
  27698. * * height the height (z direction) of the ground
  27699. * * subdivisions the number of subdivisions per side
  27700. * * minHeight the minimum altitude on the ground, optional, default 0
  27701. * * maxHeight the maximum altitude on the ground, optional default 1
  27702. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27703. * * buffer the array holding the image color data
  27704. * * bufferWidth the width of image
  27705. * * bufferHeight the height of image
  27706. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27707. * @returns the VertexData of the Ground designed from a heightmap
  27708. */
  27709. static CreateGroundFromHeightMap(options: {
  27710. width: number;
  27711. height: number;
  27712. subdivisions: number;
  27713. minHeight: number;
  27714. maxHeight: number;
  27715. colorFilter: Color3;
  27716. buffer: Uint8Array;
  27717. bufferWidth: number;
  27718. bufferHeight: number;
  27719. alphaFilter: number;
  27720. }): VertexData;
  27721. /**
  27722. * Creates the VertexData for a Plane
  27723. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27724. * * size sets the width and height of the plane to the value of size, optional default 1
  27725. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27726. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27727. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27728. * * 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)
  27729. * * 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)
  27730. * @returns the VertexData of the box
  27731. */
  27732. static CreatePlane(options: {
  27733. size?: number;
  27734. width?: number;
  27735. height?: number;
  27736. sideOrientation?: number;
  27737. frontUVs?: Vector4;
  27738. backUVs?: Vector4;
  27739. }): VertexData;
  27740. /**
  27741. * Creates the VertexData of the Disc or regular Polygon
  27742. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27743. * * radius the radius of the disc, optional default 0.5
  27744. * * tessellation the number of polygon sides, optional, default 64
  27745. * * 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
  27746. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27747. * * 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)
  27748. * * 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)
  27749. * @returns the VertexData of the box
  27750. */
  27751. static CreateDisc(options: {
  27752. radius?: number;
  27753. tessellation?: number;
  27754. arc?: number;
  27755. sideOrientation?: number;
  27756. frontUVs?: Vector4;
  27757. backUVs?: Vector4;
  27758. }): VertexData;
  27759. /**
  27760. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27761. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27762. * @param polygon a mesh built from polygonTriangulation.build()
  27763. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27764. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27765. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27766. * @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)
  27767. * @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)
  27768. * @returns the VertexData of the Polygon
  27769. */
  27770. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27771. /**
  27772. * Creates the VertexData of the IcoSphere
  27773. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27774. * * radius the radius of the IcoSphere, optional default 1
  27775. * * radiusX allows stretching in the x direction, optional, default radius
  27776. * * radiusY allows stretching in the y direction, optional, default radius
  27777. * * radiusZ allows stretching in the z direction, optional, default radius
  27778. * * flat when true creates a flat shaded mesh, optional, default true
  27779. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27780. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27781. * * 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)
  27782. * * 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)
  27783. * @returns the VertexData of the IcoSphere
  27784. */
  27785. static CreateIcoSphere(options: {
  27786. radius?: number;
  27787. radiusX?: number;
  27788. radiusY?: number;
  27789. radiusZ?: number;
  27790. flat?: boolean;
  27791. subdivisions?: number;
  27792. sideOrientation?: number;
  27793. frontUVs?: Vector4;
  27794. backUVs?: Vector4;
  27795. }): VertexData;
  27796. /**
  27797. * Creates the VertexData for a Polyhedron
  27798. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27799. * * type provided types are:
  27800. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27801. * * 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)
  27802. * * size the size of the IcoSphere, optional default 1
  27803. * * sizeX allows stretching in the x direction, optional, default size
  27804. * * sizeY allows stretching in the y direction, optional, default size
  27805. * * sizeZ allows stretching in the z direction, optional, default size
  27806. * * 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
  27807. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27808. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27809. * * flat when true creates a flat shaded mesh, optional, default true
  27810. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27811. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27812. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27813. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27814. * @returns the VertexData of the Polyhedron
  27815. */
  27816. static CreatePolyhedron(options: {
  27817. type?: number;
  27818. size?: number;
  27819. sizeX?: number;
  27820. sizeY?: number;
  27821. sizeZ?: number;
  27822. custom?: any;
  27823. faceUV?: Vector4[];
  27824. faceColors?: Color4[];
  27825. flat?: boolean;
  27826. sideOrientation?: number;
  27827. frontUVs?: Vector4;
  27828. backUVs?: Vector4;
  27829. }): VertexData;
  27830. /**
  27831. * Creates the VertexData for a TorusKnot
  27832. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27833. * * radius the radius of the torus knot, optional, default 2
  27834. * * tube the thickness of the tube, optional, default 0.5
  27835. * * radialSegments the number of sides on each tube segments, optional, default 32
  27836. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27837. * * p the number of windings around the z axis, optional, default 2
  27838. * * q the number of windings around the x axis, optional, default 3
  27839. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27840. * * 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)
  27841. * * 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)
  27842. * @returns the VertexData of the Torus Knot
  27843. */
  27844. static CreateTorusKnot(options: {
  27845. radius?: number;
  27846. tube?: number;
  27847. radialSegments?: number;
  27848. tubularSegments?: number;
  27849. p?: number;
  27850. q?: number;
  27851. sideOrientation?: number;
  27852. frontUVs?: Vector4;
  27853. backUVs?: Vector4;
  27854. }): VertexData;
  27855. /**
  27856. * Compute normals for given positions and indices
  27857. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27858. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27859. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27860. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27861. * * facetNormals : optional array of facet normals (vector3)
  27862. * * facetPositions : optional array of facet positions (vector3)
  27863. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27864. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27865. * * bInfo : optional bounding info, required for facetPartitioning computation
  27866. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27867. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27868. * * useRightHandedSystem: optional boolean to for right handed system computation
  27869. * * depthSort : optional boolean to enable the facet depth sort computation
  27870. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27871. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27872. */
  27873. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27874. facetNormals?: any;
  27875. facetPositions?: any;
  27876. facetPartitioning?: any;
  27877. ratio?: number;
  27878. bInfo?: any;
  27879. bbSize?: Vector3;
  27880. subDiv?: any;
  27881. useRightHandedSystem?: boolean;
  27882. depthSort?: boolean;
  27883. distanceTo?: Vector3;
  27884. depthSortedFacets?: any;
  27885. }): void;
  27886. private static _ComputeSides;
  27887. /**
  27888. * Applies VertexData created from the imported parameters to the geometry
  27889. * @param parsedVertexData the parsed data from an imported file
  27890. * @param geometry the geometry to apply the VertexData to
  27891. */
  27892. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27893. }
  27894. }
  27895. declare module BABYLON {
  27896. /**
  27897. * Class containing static functions to help procedurally build meshes
  27898. */
  27899. class MeshBuilder {
  27900. private static _UpdateSideOrientation;
  27901. /**
  27902. * Creates a box mesh
  27903. * * The parameter `size` sets the size (float) of each box side (default 1)
  27904. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27905. * * 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)
  27906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  27907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27908. * * 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
  27909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27910. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  27911. * @param name defines the name of the mesh
  27912. * @param options defines the options used to create the mesh
  27913. * @param scene defines the hosting scene
  27914. * @returns the box mesh
  27915. */
  27916. static CreateBox(name: string, options: {
  27917. size?: number;
  27918. width?: number;
  27919. height?: number;
  27920. depth?: number;
  27921. faceUV?: Vector4[];
  27922. faceColors?: Color4[];
  27923. sideOrientation?: number;
  27924. frontUVs?: Vector4;
  27925. backUVs?: Vector4;
  27926. updatable?: boolean;
  27927. }, scene?: Nullable<Scene>): Mesh;
  27928. /**
  27929. * Creates a sphere mesh
  27930. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27931. * * 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`)
  27932. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27933. * * 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
  27934. * * 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)
  27935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27936. * * 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
  27937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27938. * @param name defines the name of the mesh
  27939. * @param options defines the options used to create the mesh
  27940. * @param scene defines the hosting scene
  27941. * @returns the sphere mesh
  27942. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  27943. */
  27944. static CreateSphere(name: string, options: {
  27945. segments?: number;
  27946. diameter?: number;
  27947. diameterX?: number;
  27948. diameterY?: number;
  27949. diameterZ?: number;
  27950. arc?: number;
  27951. slice?: number;
  27952. sideOrientation?: number;
  27953. frontUVs?: Vector4;
  27954. backUVs?: Vector4;
  27955. updatable?: boolean;
  27956. }, scene: any): Mesh;
  27957. /**
  27958. * Creates a plane polygonal mesh. By default, this is a disc
  27959. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27960. * * 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
  27961. * * 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
  27962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27963. * * 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
  27964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27965. * @param name defines the name of the mesh
  27966. * @param options defines the options used to create the mesh
  27967. * @param scene defines the hosting scene
  27968. * @returns the plane polygonal mesh
  27969. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27970. */
  27971. static CreateDisc(name: string, options: {
  27972. radius?: number;
  27973. tessellation?: number;
  27974. arc?: number;
  27975. updatable?: boolean;
  27976. sideOrientation?: number;
  27977. frontUVs?: Vector4;
  27978. backUVs?: Vector4;
  27979. }, scene?: Nullable<Scene>): Mesh;
  27980. /**
  27981. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27982. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27983. * * 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`)
  27984. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27985. * * 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
  27986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27987. * * 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
  27988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27989. * @param name defines the name of the mesh
  27990. * @param options defines the options used to create the mesh
  27991. * @param scene defines the hosting scene
  27992. * @returns the icosahedron mesh
  27993. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27994. */
  27995. static CreateIcoSphere(name: string, options: {
  27996. radius?: number;
  27997. radiusX?: number;
  27998. radiusY?: number;
  27999. radiusZ?: number;
  28000. flat?: boolean;
  28001. subdivisions?: number;
  28002. sideOrientation?: number;
  28003. frontUVs?: Vector4;
  28004. backUVs?: Vector4;
  28005. updatable?: boolean;
  28006. }, scene: Scene): Mesh;
  28007. /**
  28008. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28009. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28010. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28011. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28012. * * 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
  28013. * * 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
  28014. * * 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
  28015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28016. * * 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
  28017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28018. * * 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
  28019. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28020. * * 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
  28021. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28023. * @param name defines the name of the mesh
  28024. * @param options defines the options used to create the mesh
  28025. * @param scene defines the hosting scene
  28026. * @returns the ribbon mesh
  28027. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28029. */
  28030. static CreateRibbon(name: string, options: {
  28031. pathArray: Vector3[][];
  28032. closeArray?: boolean;
  28033. closePath?: boolean;
  28034. offset?: number;
  28035. updatable?: boolean;
  28036. sideOrientation?: number;
  28037. frontUVs?: Vector4;
  28038. backUVs?: Vector4;
  28039. instance?: Mesh;
  28040. invertUV?: boolean;
  28041. uvs?: Vector2[];
  28042. colors?: Color4[];
  28043. }, scene?: Nullable<Scene>): Mesh;
  28044. /**
  28045. * Creates a cylinder or a cone mesh
  28046. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28047. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28048. * * 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.
  28049. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28050. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28051. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28052. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28053. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28054. * * 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).
  28055. * * 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
  28056. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28057. * * 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
  28058. * * 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.
  28059. * * If `enclose` is false, a ring surface is one element.
  28060. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28061. * * 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
  28062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28063. * * 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
  28064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28065. * @param name defines the name of the mesh
  28066. * @param options defines the options used to create the mesh
  28067. * @param scene defines the hosting scene
  28068. * @returns the cylinder mesh
  28069. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28070. */
  28071. static CreateCylinder(name: string, options: {
  28072. height?: number;
  28073. diameterTop?: number;
  28074. diameterBottom?: number;
  28075. diameter?: number;
  28076. tessellation?: number;
  28077. subdivisions?: number;
  28078. arc?: number;
  28079. faceColors?: Color4[];
  28080. faceUV?: Vector4[];
  28081. updatable?: boolean;
  28082. hasRings?: boolean;
  28083. enclose?: boolean;
  28084. sideOrientation?: number;
  28085. frontUVs?: Vector4;
  28086. backUVs?: Vector4;
  28087. }, scene: any): Mesh;
  28088. /**
  28089. * Creates a torus mesh
  28090. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28091. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28092. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28094. * * 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
  28095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28096. * @param name defines the name of the mesh
  28097. * @param options defines the options used to create the mesh
  28098. * @param scene defines the hosting scene
  28099. * @returns the torus mesh
  28100. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28101. */
  28102. static CreateTorus(name: string, options: {
  28103. diameter?: number;
  28104. thickness?: number;
  28105. tessellation?: number;
  28106. updatable?: boolean;
  28107. sideOrientation?: number;
  28108. frontUVs?: Vector4;
  28109. backUVs?: Vector4;
  28110. }, scene: any): Mesh;
  28111. /**
  28112. * Creates a torus knot mesh
  28113. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28114. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28115. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28116. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28118. * * 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
  28119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28120. * @param name defines the name of the mesh
  28121. * @param options defines the options used to create the mesh
  28122. * @param scene defines the hosting scene
  28123. * @returns the torus knot mesh
  28124. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28125. */
  28126. static CreateTorusKnot(name: string, options: {
  28127. radius?: number;
  28128. tube?: number;
  28129. radialSegments?: number;
  28130. tubularSegments?: number;
  28131. p?: number;
  28132. q?: number;
  28133. updatable?: boolean;
  28134. sideOrientation?: number;
  28135. frontUVs?: Vector4;
  28136. backUVs?: Vector4;
  28137. }, scene: any): Mesh;
  28138. /**
  28139. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28140. * * 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
  28141. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28142. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28143. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28144. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28145. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28146. * * 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
  28147. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28150. * @param name defines the name of the new line system
  28151. * @param options defines the options used to create the line system
  28152. * @param scene defines the hosting scene
  28153. * @returns a new line system mesh
  28154. */
  28155. static CreateLineSystem(name: string, options: {
  28156. lines: Vector3[][];
  28157. updatable?: boolean;
  28158. instance?: Nullable<LinesMesh>;
  28159. colors?: Nullable<Color4[][]>;
  28160. useVertexAlpha?: boolean;
  28161. }, scene: Nullable<Scene>): LinesMesh;
  28162. /**
  28163. * Creates a line mesh
  28164. * 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
  28165. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28166. * * The parameter `points` is an array successive Vector3
  28167. * * 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
  28168. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28169. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28170. * * When updating an instance, remember that only point positions can change, not the number of points
  28171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28173. * @param name defines the name of the new line system
  28174. * @param options defines the options used to create the line system
  28175. * @param scene defines the hosting scene
  28176. * @returns a new line mesh
  28177. */
  28178. static CreateLines(name: string, options: {
  28179. points: Vector3[];
  28180. updatable?: boolean;
  28181. instance?: Nullable<LinesMesh>;
  28182. colors?: Color4[];
  28183. useVertexAlpha?: boolean;
  28184. }, scene?: Nullable<Scene>): LinesMesh;
  28185. /**
  28186. * Creates a dashed line mesh
  28187. * * 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
  28188. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28189. * * The parameter `points` is an array successive Vector3
  28190. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28191. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28192. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28193. * * 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
  28194. * * When updating an instance, remember that only point positions can change, not the number of points
  28195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28196. * @param name defines the name of the mesh
  28197. * @param options defines the options used to create the mesh
  28198. * @param scene defines the hosting scene
  28199. * @returns the dashed line mesh
  28200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28201. */
  28202. static CreateDashedLines(name: string, options: {
  28203. points: Vector3[];
  28204. dashSize?: number;
  28205. gapSize?: number;
  28206. dashNb?: number;
  28207. updatable?: boolean;
  28208. instance?: LinesMesh;
  28209. }, scene?: Nullable<Scene>): LinesMesh;
  28210. /**
  28211. * 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.
  28212. * * 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.
  28213. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28214. * * 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.
  28215. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28216. * * 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
  28217. * * 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
  28218. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28220. * * 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
  28221. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28223. * @param name defines the name of the mesh
  28224. * @param options defines the options used to create the mesh
  28225. * @param scene defines the hosting scene
  28226. * @returns the extruded shape mesh
  28227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28229. */
  28230. static ExtrudeShape(name: string, options: {
  28231. shape: Vector3[];
  28232. path: Vector3[];
  28233. scale?: number;
  28234. rotation?: number;
  28235. cap?: number;
  28236. updatable?: boolean;
  28237. sideOrientation?: number;
  28238. frontUVs?: Vector4;
  28239. backUVs?: Vector4;
  28240. instance?: Mesh;
  28241. invertUV?: boolean;
  28242. }, scene?: Nullable<Scene>): Mesh;
  28243. /**
  28244. * Creates an custom extruded shape mesh.
  28245. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28246. * * 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.
  28247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28248. * * 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
  28249. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28250. * * 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
  28251. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28252. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28253. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28254. * * 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
  28255. * * 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
  28256. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28258. * * 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
  28259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28261. * @param name defines the name of the mesh
  28262. * @param options defines the options used to create the mesh
  28263. * @param scene defines the hosting scene
  28264. * @returns the custom extruded shape mesh
  28265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28268. */
  28269. static ExtrudeShapeCustom(name: string, options: {
  28270. shape: Vector3[];
  28271. path: Vector3[];
  28272. scaleFunction?: any;
  28273. rotationFunction?: any;
  28274. ribbonCloseArray?: boolean;
  28275. ribbonClosePath?: boolean;
  28276. cap?: number;
  28277. updatable?: boolean;
  28278. sideOrientation?: number;
  28279. frontUVs?: Vector4;
  28280. backUVs?: Vector4;
  28281. instance?: Mesh;
  28282. invertUV?: boolean;
  28283. }, scene: Scene): Mesh;
  28284. /**
  28285. * Creates lathe mesh.
  28286. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28287. * * 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
  28288. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28289. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28290. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28291. * * 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
  28292. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28293. * * 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
  28294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28295. * * 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
  28296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28298. * @param name defines the name of the mesh
  28299. * @param options defines the options used to create the mesh
  28300. * @param scene defines the hosting scene
  28301. * @returns the lathe mesh
  28302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28303. */
  28304. static CreateLathe(name: string, options: {
  28305. shape: Vector3[];
  28306. radius?: number;
  28307. tessellation?: number;
  28308. clip?: number;
  28309. arc?: number;
  28310. closed?: boolean;
  28311. updatable?: boolean;
  28312. sideOrientation?: number;
  28313. frontUVs?: Vector4;
  28314. backUVs?: Vector4;
  28315. cap?: number;
  28316. invertUV?: boolean;
  28317. }, scene: Scene): Mesh;
  28318. /**
  28319. * Creates a plane mesh
  28320. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28321. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28322. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28324. * * 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
  28325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28326. * @param name defines the name of the mesh
  28327. * @param options defines the options used to create the mesh
  28328. * @param scene defines the hosting scene
  28329. * @returns the plane mesh
  28330. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28331. */
  28332. static CreatePlane(name: string, options: {
  28333. size?: number;
  28334. width?: number;
  28335. height?: number;
  28336. sideOrientation?: number;
  28337. frontUVs?: Vector4;
  28338. backUVs?: Vector4;
  28339. updatable?: boolean;
  28340. sourcePlane?: Plane;
  28341. }, scene: Scene): Mesh;
  28342. /**
  28343. * Creates a ground mesh
  28344. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28345. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28347. * @param name defines the name of the mesh
  28348. * @param options defines the options used to create the mesh
  28349. * @param scene defines the hosting scene
  28350. * @returns the ground mesh
  28351. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28352. */
  28353. static CreateGround(name: string, options: {
  28354. width?: number;
  28355. height?: number;
  28356. subdivisions?: number;
  28357. subdivisionsX?: number;
  28358. subdivisionsY?: number;
  28359. updatable?: boolean;
  28360. }, scene: any): Mesh;
  28361. /**
  28362. * Creates a tiled ground mesh
  28363. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28364. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28365. * * 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
  28366. * * 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
  28367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28368. * @param name defines the name of the mesh
  28369. * @param options defines the options used to create the mesh
  28370. * @param scene defines the hosting scene
  28371. * @returns the tiled ground mesh
  28372. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28373. */
  28374. static CreateTiledGround(name: string, options: {
  28375. xmin: number;
  28376. zmin: number;
  28377. xmax: number;
  28378. zmax: number;
  28379. subdivisions?: {
  28380. w: number;
  28381. h: number;
  28382. };
  28383. precision?: {
  28384. w: number;
  28385. h: number;
  28386. };
  28387. updatable?: boolean;
  28388. }, scene: Scene): Mesh;
  28389. /**
  28390. * Creates a ground mesh from a height map
  28391. * * The parameter `url` sets the URL of the height map image resource.
  28392. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28393. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28394. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28395. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28396. * * 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.
  28397. * * 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).
  28398. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28400. * @param name defines the name of the mesh
  28401. * @param url defines the url to the height map
  28402. * @param options defines the options used to create the mesh
  28403. * @param scene defines the hosting scene
  28404. * @returns the ground mesh
  28405. * @see https://doc.babylonjs.com/babylon101/height_map
  28406. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28407. */
  28408. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28409. width?: number;
  28410. height?: number;
  28411. subdivisions?: number;
  28412. minHeight?: number;
  28413. maxHeight?: number;
  28414. colorFilter?: Color3;
  28415. alphaFilter?: number;
  28416. updatable?: boolean;
  28417. onReady?: (mesh: GroundMesh) => void;
  28418. }, scene: Scene): GroundMesh;
  28419. /**
  28420. * Creates a polygon mesh
  28421. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28422. * * 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
  28423. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28425. * * 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)
  28426. * * Remember you can only change the shape positions, not their number when updating a polygon
  28427. * @param name defines the name of the mesh
  28428. * @param options defines the options used to create the mesh
  28429. * @param scene defines the hosting scene
  28430. * @returns the polygon mesh
  28431. */
  28432. static CreatePolygon(name: string, options: {
  28433. shape: Vector3[];
  28434. holes?: Vector3[][];
  28435. depth?: number;
  28436. faceUV?: Vector4[];
  28437. faceColors?: Color4[];
  28438. updatable?: boolean;
  28439. sideOrientation?: number;
  28440. frontUVs?: Vector4;
  28441. backUVs?: Vector4;
  28442. }, scene: Scene): Mesh;
  28443. /**
  28444. * Creates an extruded polygon mesh, with depth in the Y direction.
  28445. * * 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)
  28446. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28447. * @param name defines the name of the mesh
  28448. * @param options defines the options used to create the mesh
  28449. * @param scene defines the hosting scene
  28450. * @returns the polygon mesh
  28451. */
  28452. static ExtrudePolygon(name: string, options: {
  28453. shape: Vector3[];
  28454. holes?: Vector3[][];
  28455. depth?: number;
  28456. faceUV?: Vector4[];
  28457. faceColors?: Color4[];
  28458. updatable?: boolean;
  28459. sideOrientation?: number;
  28460. frontUVs?: Vector4;
  28461. backUVs?: Vector4;
  28462. }, scene: Scene): Mesh;
  28463. /**
  28464. * Creates a tube mesh.
  28465. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28466. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28467. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28468. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28469. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28470. * * 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)
  28471. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28472. * * 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
  28473. * * 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
  28474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28475. * * 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
  28476. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28478. * @param name defines the name of the mesh
  28479. * @param options defines the options used to create the mesh
  28480. * @param scene defines the hosting scene
  28481. * @returns the tube mesh
  28482. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28483. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28484. */
  28485. static CreateTube(name: string, options: {
  28486. path: Vector3[];
  28487. radius?: number;
  28488. tessellation?: number;
  28489. radiusFunction?: {
  28490. (i: number, distance: number): number;
  28491. };
  28492. cap?: number;
  28493. arc?: number;
  28494. updatable?: boolean;
  28495. sideOrientation?: number;
  28496. frontUVs?: Vector4;
  28497. backUVs?: Vector4;
  28498. instance?: Mesh;
  28499. invertUV?: boolean;
  28500. }, scene: Scene): Mesh;
  28501. /**
  28502. * Creates a polyhedron mesh
  28503. * * 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
  28504. * * The parameter `size` (positive float, default 1) sets the polygon size
  28505. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28506. * * 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`
  28507. * * 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
  28508. * * 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)`)
  28509. * * 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
  28510. * * 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
  28511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28512. * * 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
  28513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28514. * @param name defines the name of the mesh
  28515. * @param options defines the options used to create the mesh
  28516. * @param scene defines the hosting scene
  28517. * @returns the polyhedron mesh
  28518. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28519. */
  28520. static CreatePolyhedron(name: string, options: {
  28521. type?: number;
  28522. size?: number;
  28523. sizeX?: number;
  28524. sizeY?: number;
  28525. sizeZ?: number;
  28526. custom?: any;
  28527. faceUV?: Vector4[];
  28528. faceColors?: Color4[];
  28529. flat?: boolean;
  28530. updatable?: boolean;
  28531. sideOrientation?: number;
  28532. frontUVs?: Vector4;
  28533. backUVs?: Vector4;
  28534. }, scene: Scene): Mesh;
  28535. /**
  28536. * Creates a decal mesh.
  28537. * 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
  28538. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28539. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28540. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28541. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28542. * @param name defines the name of the mesh
  28543. * @param sourceMesh defines the mesh where the decal must be applied
  28544. * @param options defines the options used to create the mesh
  28545. * @param scene defines the hosting scene
  28546. * @returns the decal mesh
  28547. * @see https://doc.babylonjs.com/how_to/decals
  28548. */
  28549. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28550. position?: Vector3;
  28551. normal?: Vector3;
  28552. size?: Vector3;
  28553. angle?: number;
  28554. }): Mesh;
  28555. private static _ExtrudeShapeGeneric;
  28556. }
  28557. }
  28558. declare module BABYLON {
  28559. /**
  28560. * Class used to represent a specific level of detail of a mesh
  28561. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28562. */
  28563. class MeshLODLevel {
  28564. /** Defines the distance where this level should star being displayed */
  28565. distance: number;
  28566. /** Defines the mesh to use to render this level */
  28567. mesh: Nullable<Mesh>;
  28568. /**
  28569. * Creates a new LOD level
  28570. * @param distance defines the distance where this level should star being displayed
  28571. * @param mesh defines the mesh to use to render this level
  28572. */
  28573. constructor(
  28574. /** Defines the distance where this level should star being displayed */
  28575. distance: number,
  28576. /** Defines the mesh to use to render this level */
  28577. mesh: Nullable<Mesh>);
  28578. }
  28579. }
  28580. declare module BABYLON {
  28581. /**
  28582. * A simplifier interface for future simplification implementations
  28583. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28584. */
  28585. interface ISimplifier {
  28586. /**
  28587. * Simplification of a given mesh according to the given settings.
  28588. * Since this requires computation, it is assumed that the function runs async.
  28589. * @param settings The settings of the simplification, including quality and distance
  28590. * @param successCallback A callback that will be called after the mesh was simplified.
  28591. * @param errorCallback in case of an error, this callback will be called. optional.
  28592. */
  28593. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28594. }
  28595. /**
  28596. * Expected simplification settings.
  28597. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28598. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28599. */
  28600. interface ISimplificationSettings {
  28601. /**
  28602. * Gets or sets the expected quality
  28603. */
  28604. quality: number;
  28605. /**
  28606. * Gets or sets the distance when this optimized version should be used
  28607. */
  28608. distance: number;
  28609. /**
  28610. * Gets an already optimized mesh
  28611. */
  28612. optimizeMesh?: boolean;
  28613. }
  28614. /**
  28615. * Class used to specify simplification options
  28616. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28617. */
  28618. class SimplificationSettings implements ISimplificationSettings {
  28619. /** expected quality */
  28620. quality: number;
  28621. /** distance when this optimized version should be used */
  28622. distance: number;
  28623. /** already optimized mesh */
  28624. optimizeMesh?: boolean | undefined;
  28625. /**
  28626. * Creates a SimplificationSettings
  28627. * @param quality expected quality
  28628. * @param distance distance when this optimized version should be used
  28629. * @param optimizeMesh already optimized mesh
  28630. */
  28631. constructor(
  28632. /** expected quality */
  28633. quality: number,
  28634. /** distance when this optimized version should be used */
  28635. distance: number,
  28636. /** already optimized mesh */
  28637. optimizeMesh?: boolean | undefined);
  28638. }
  28639. /**
  28640. * Interface used to define a simplification task
  28641. */
  28642. interface ISimplificationTask {
  28643. /**
  28644. * Array of settings
  28645. */
  28646. settings: Array<ISimplificationSettings>;
  28647. /**
  28648. * Simplification type
  28649. */
  28650. simplificationType: SimplificationType;
  28651. /**
  28652. * Mesh to simplify
  28653. */
  28654. mesh: Mesh;
  28655. /**
  28656. * Callback called on success
  28657. */
  28658. successCallback?: () => void;
  28659. /**
  28660. * Defines if parallel processing can be used
  28661. */
  28662. parallelProcessing: boolean;
  28663. }
  28664. /**
  28665. * Queue used to order the simplification tasks
  28666. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28667. */
  28668. class SimplificationQueue {
  28669. private _simplificationArray;
  28670. /**
  28671. * Gets a boolean indicating that the process is still running
  28672. */
  28673. running: boolean;
  28674. /**
  28675. * Creates a new queue
  28676. */
  28677. constructor();
  28678. /**
  28679. * Adds a new simplification task
  28680. * @param task defines a task to add
  28681. */
  28682. addTask(task: ISimplificationTask): void;
  28683. /**
  28684. * Execute next task
  28685. */
  28686. executeNext(): void;
  28687. /**
  28688. * Execute a simplification task
  28689. * @param task defines the task to run
  28690. */
  28691. runSimplification(task: ISimplificationTask): void;
  28692. private getSimplifier;
  28693. }
  28694. /**
  28695. * The implemented types of simplification
  28696. * At the moment only Quadratic Error Decimation is implemented
  28697. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28698. */
  28699. enum SimplificationType {
  28700. /** Quadratic error decimation */
  28701. QUADRATIC = 0
  28702. }
  28703. }
  28704. declare module BABYLON {
  28705. interface Scene {
  28706. /** @hidden (Backing field) */
  28707. _simplificationQueue: SimplificationQueue;
  28708. /**
  28709. * Gets or sets the simplification queue attached to the scene
  28710. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28711. */
  28712. simplificationQueue: SimplificationQueue;
  28713. }
  28714. interface Mesh {
  28715. /**
  28716. * Simplify the mesh according to the given array of settings.
  28717. * Function will return immediately and will simplify async
  28718. * @param settings a collection of simplification settings
  28719. * @param parallelProcessing should all levels calculate parallel or one after the other
  28720. * @param simplificationType the type of simplification to run
  28721. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28722. * @returns the current mesh
  28723. */
  28724. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28725. }
  28726. /**
  28727. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28728. * created in a scene
  28729. */
  28730. class SimplicationQueueSceneComponent implements ISceneComponent {
  28731. /**
  28732. * The component name helpfull to identify the component in the list of scene components.
  28733. */
  28734. readonly name: string;
  28735. /**
  28736. * The scene the component belongs to.
  28737. */
  28738. scene: Scene;
  28739. /**
  28740. * Creates a new instance of the component for the given scene
  28741. * @param scene Defines the scene to register the component in
  28742. */
  28743. constructor(scene: Scene);
  28744. /**
  28745. * Registers the component in a given scene
  28746. */
  28747. register(): void;
  28748. /**
  28749. * Rebuilds the elements related to this component in case of
  28750. * context lost for instance.
  28751. */
  28752. rebuild(): void;
  28753. /**
  28754. * Disposes the component and the associated ressources
  28755. */
  28756. dispose(): void;
  28757. private _beforeCameraUpdate;
  28758. }
  28759. }
  28760. declare module BABYLON {
  28761. /**
  28762. * Polygon
  28763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28764. */
  28765. class Polygon {
  28766. /**
  28767. * Creates a rectangle
  28768. * @param xmin bottom X coord
  28769. * @param ymin bottom Y coord
  28770. * @param xmax top X coord
  28771. * @param ymax top Y coord
  28772. * @returns points that make the resulting rectation
  28773. */
  28774. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28775. /**
  28776. * Creates a circle
  28777. * @param radius radius of circle
  28778. * @param cx scale in x
  28779. * @param cy scale in y
  28780. * @param numberOfSides number of sides that make up the circle
  28781. * @returns points that make the resulting circle
  28782. */
  28783. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28784. /**
  28785. * Creates a polygon from input string
  28786. * @param input Input polygon data
  28787. * @returns the parsed points
  28788. */
  28789. static Parse(input: string): Vector2[];
  28790. /**
  28791. * Starts building a polygon from x and y coordinates
  28792. * @param x x coordinate
  28793. * @param y y coordinate
  28794. * @returns the started path2
  28795. */
  28796. static StartingAt(x: number, y: number): Path2;
  28797. }
  28798. /**
  28799. * Builds a polygon
  28800. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28801. */
  28802. class PolygonMeshBuilder {
  28803. private _points;
  28804. private _outlinepoints;
  28805. private _holes;
  28806. private _name;
  28807. private _scene;
  28808. private _epoints;
  28809. private _eholes;
  28810. private _addToepoint;
  28811. /**
  28812. * Creates a PolygonMeshBuilder
  28813. * @param name name of the builder
  28814. * @param contours Path of the polygon
  28815. * @param scene scene to add to
  28816. */
  28817. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28818. /**
  28819. * Adds a whole within the polygon
  28820. * @param hole Array of points defining the hole
  28821. * @returns this
  28822. */
  28823. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28824. /**
  28825. * Creates the polygon
  28826. * @param updatable If the mesh should be updatable
  28827. * @param depth The depth of the mesh created
  28828. * @returns the created mesh
  28829. */
  28830. build(updatable?: boolean, depth?: number): Mesh;
  28831. /**
  28832. * Adds a side to the polygon
  28833. * @param positions points that make the polygon
  28834. * @param normals normals of the polygon
  28835. * @param uvs uvs of the polygon
  28836. * @param indices indices of the polygon
  28837. * @param bounds bounds of the polygon
  28838. * @param points points of the polygon
  28839. * @param depth depth of the polygon
  28840. * @param flip flip of the polygon
  28841. */
  28842. private addSide;
  28843. }
  28844. }
  28845. declare module BABYLON {
  28846. /**
  28847. * Base class for submeshes
  28848. */
  28849. class BaseSubMesh {
  28850. /** @hidden */
  28851. _materialDefines: Nullable<MaterialDefines>;
  28852. /** @hidden */
  28853. _materialEffect: Nullable<Effect>;
  28854. /**
  28855. * Gets associated effect
  28856. */
  28857. readonly effect: Nullable<Effect>;
  28858. /**
  28859. * Sets associated effect (effect used to render this submesh)
  28860. * @param effect defines the effect to associate with
  28861. * @param defines defines the set of defines used to compile this effect
  28862. */
  28863. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28864. }
  28865. /**
  28866. * Defines a subdivision inside a mesh
  28867. */
  28868. class SubMesh extends BaseSubMesh implements ICullable {
  28869. /** the material index to use */
  28870. materialIndex: number;
  28871. /** vertex index start */
  28872. verticesStart: number;
  28873. /** vertices count */
  28874. verticesCount: number;
  28875. /** index start */
  28876. indexStart: number;
  28877. /** indices count */
  28878. indexCount: number;
  28879. /** @hidden */
  28880. _linesIndexCount: number;
  28881. private _mesh;
  28882. private _renderingMesh;
  28883. private _boundingInfo;
  28884. private _linesIndexBuffer;
  28885. /** @hidden */
  28886. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28887. /** @hidden */
  28888. _trianglePlanes: Plane[];
  28889. /** @hidden */
  28890. _lastColliderTransformMatrix: Matrix;
  28891. /** @hidden */
  28892. _renderId: number;
  28893. /** @hidden */
  28894. _alphaIndex: number;
  28895. /** @hidden */
  28896. _distanceToCamera: number;
  28897. /** @hidden */
  28898. _id: number;
  28899. private _currentMaterial;
  28900. /**
  28901. * Add a new submesh to a mesh
  28902. * @param materialIndex defines the material index to use
  28903. * @param verticesStart defines vertex index start
  28904. * @param verticesCount defines vertices count
  28905. * @param indexStart defines index start
  28906. * @param indexCount defines indices count
  28907. * @param mesh defines the parent mesh
  28908. * @param renderingMesh defines an optional rendering mesh
  28909. * @param createBoundingBox defines if bounding box should be created for this submesh
  28910. * @returns the new submesh
  28911. */
  28912. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28913. /**
  28914. * Creates a new submesh
  28915. * @param materialIndex defines the material index to use
  28916. * @param verticesStart defines vertex index start
  28917. * @param verticesCount defines vertices count
  28918. * @param indexStart defines index start
  28919. * @param indexCount defines indices count
  28920. * @param mesh defines the parent mesh
  28921. * @param renderingMesh defines an optional rendering mesh
  28922. * @param createBoundingBox defines if bounding box should be created for this submesh
  28923. */
  28924. constructor(
  28925. /** the material index to use */
  28926. materialIndex: number,
  28927. /** vertex index start */
  28928. verticesStart: number,
  28929. /** vertices count */
  28930. verticesCount: number,
  28931. /** index start */
  28932. indexStart: number,
  28933. /** indices count */
  28934. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28935. /**
  28936. * Returns true if this submesh covers the entire parent mesh
  28937. * @ignorenaming
  28938. */
  28939. readonly IsGlobal: boolean;
  28940. /**
  28941. * Returns the submesh BoudingInfo object
  28942. * @returns current bounding info (or mesh's one if the submesh is global)
  28943. */
  28944. getBoundingInfo(): BoundingInfo;
  28945. /**
  28946. * Sets the submesh BoundingInfo
  28947. * @param boundingInfo defines the new bounding info to use
  28948. * @returns the SubMesh
  28949. */
  28950. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28951. /**
  28952. * Returns the mesh of the current submesh
  28953. * @return the parent mesh
  28954. */
  28955. getMesh(): AbstractMesh;
  28956. /**
  28957. * Returns the rendering mesh of the submesh
  28958. * @returns the rendering mesh (could be different from parent mesh)
  28959. */
  28960. getRenderingMesh(): Mesh;
  28961. /**
  28962. * Returns the submesh material
  28963. * @returns null or the current material
  28964. */
  28965. getMaterial(): Nullable<Material>;
  28966. /**
  28967. * Sets a new updated BoundingInfo object to the submesh
  28968. * @returns the SubMesh
  28969. */
  28970. refreshBoundingInfo(): SubMesh;
  28971. /** @hidden */
  28972. _checkCollision(collider: Collider): boolean;
  28973. /**
  28974. * Updates the submesh BoundingInfo
  28975. * @param world defines the world matrix to use to update the bounding info
  28976. * @returns the submesh
  28977. */
  28978. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  28979. /**
  28980. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28981. * @param frustumPlanes defines the frustum planes
  28982. * @returns true if the submesh is intersecting with the frustum
  28983. */
  28984. isInFrustum(frustumPlanes: Plane[]): boolean;
  28985. /**
  28986. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28987. * @param frustumPlanes defines the frustum planes
  28988. * @returns true if the submesh is inside the frustum
  28989. */
  28990. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28991. /**
  28992. * Renders the submesh
  28993. * @param enableAlphaMode defines if alpha needs to be used
  28994. * @returns the submesh
  28995. */
  28996. render(enableAlphaMode: boolean): SubMesh;
  28997. /**
  28998. * @hidden
  28999. */
  29000. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29001. /**
  29002. * Checks if the submesh intersects with a ray
  29003. * @param ray defines the ray to test
  29004. * @returns true is the passed ray intersects the submesh bounding box
  29005. */
  29006. canIntersects(ray: Ray): boolean;
  29007. /**
  29008. * Intersects current submesh with a ray
  29009. * @param ray defines the ray to test
  29010. * @param positions defines mesh's positions array
  29011. * @param indices defines mesh's indices array
  29012. * @param fastCheck defines if only bounding info should be used
  29013. * @returns intersection info or null if no intersection
  29014. */
  29015. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29016. /** @hidden */
  29017. private _intersectLines;
  29018. /** @hidden */
  29019. private _intersectTriangles;
  29020. /** @hidden */
  29021. _rebuild(): void;
  29022. /**
  29023. * Creates a new submesh from the passed mesh
  29024. * @param newMesh defines the new hosting mesh
  29025. * @param newRenderingMesh defines an optional rendering mesh
  29026. * @returns the new submesh
  29027. */
  29028. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29029. /**
  29030. * Release associated resources
  29031. */
  29032. dispose(): void;
  29033. /**
  29034. * Creates a new submesh from indices data
  29035. * @param materialIndex the index of the main mesh material
  29036. * @param startIndex the index where to start the copy in the mesh indices array
  29037. * @param indexCount the number of indices to copy then from the startIndex
  29038. * @param mesh the main mesh to create the submesh from
  29039. * @param renderingMesh the optional rendering mesh
  29040. * @returns a new submesh
  29041. */
  29042. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29043. }
  29044. }
  29045. declare module BABYLON {
  29046. /**
  29047. * 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.
  29048. * @see https://doc.babylonjs.com/how_to/transformnode
  29049. */
  29050. class TransformNode extends Node {
  29051. /**
  29052. * Object will not rotate to face the camera
  29053. */
  29054. static BILLBOARDMODE_NONE: number;
  29055. /**
  29056. * Object will rotate to face the camera but only on the x axis
  29057. */
  29058. static BILLBOARDMODE_X: number;
  29059. /**
  29060. * Object will rotate to face the camera but only on the y axis
  29061. */
  29062. static BILLBOARDMODE_Y: number;
  29063. /**
  29064. * Object will rotate to face the camera but only on the z axis
  29065. */
  29066. static BILLBOARDMODE_Z: number;
  29067. /**
  29068. * Object will rotate to face the camera
  29069. */
  29070. static BILLBOARDMODE_ALL: number;
  29071. private _forward;
  29072. private _forwardInverted;
  29073. private _up;
  29074. private _right;
  29075. private _rightInverted;
  29076. private _position;
  29077. private _rotation;
  29078. private _rotationQuaternion;
  29079. protected _scaling: Vector3;
  29080. protected _isDirty: boolean;
  29081. private _transformToBoneReferal;
  29082. /**
  29083. * Set the billboard mode. Default is 0.
  29084. *
  29085. * | Value | Type | Description |
  29086. * | --- | --- | --- |
  29087. * | 0 | BILLBOARDMODE_NONE | |
  29088. * | 1 | BILLBOARDMODE_X | |
  29089. * | 2 | BILLBOARDMODE_Y | |
  29090. * | 4 | BILLBOARDMODE_Z | |
  29091. * | 7 | BILLBOARDMODE_ALL | |
  29092. *
  29093. */
  29094. billboardMode: number;
  29095. /**
  29096. * 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
  29097. */
  29098. scalingDeterminant: number;
  29099. /**
  29100. * Sets the distance of the object to max, often used by skybox
  29101. */
  29102. infiniteDistance: boolean;
  29103. /**
  29104. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29105. * By default the system will update normals to compensate
  29106. */
  29107. ignoreNonUniformScaling: boolean;
  29108. /** @hidden */
  29109. _poseMatrix: Matrix;
  29110. /** @hidden */
  29111. _localMatrix: Matrix;
  29112. private _absolutePosition;
  29113. private _pivotMatrix;
  29114. private _pivotMatrixInverse;
  29115. protected _postMultiplyPivotMatrix: boolean;
  29116. protected _isWorldMatrixFrozen: boolean;
  29117. /** @hidden */
  29118. _indexInSceneTransformNodesArray: number;
  29119. /**
  29120. * An event triggered after the world matrix is updated
  29121. */
  29122. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29123. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29124. /**
  29125. * Gets a string identifying the name of the class
  29126. * @returns "TransformNode" string
  29127. */
  29128. getClassName(): string;
  29129. /**
  29130. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29131. */
  29132. position: Vector3;
  29133. /**
  29134. * 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)).
  29135. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29136. */
  29137. rotation: Vector3;
  29138. /**
  29139. * 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)).
  29140. */
  29141. scaling: Vector3;
  29142. /**
  29143. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29144. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29145. */
  29146. rotationQuaternion: Nullable<Quaternion>;
  29147. /**
  29148. * The forward direction of that transform in world space.
  29149. */
  29150. readonly forward: Vector3;
  29151. /**
  29152. * The up direction of that transform in world space.
  29153. */
  29154. readonly up: Vector3;
  29155. /**
  29156. * The right direction of that transform in world space.
  29157. */
  29158. readonly right: Vector3;
  29159. /**
  29160. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29161. * @param matrix the matrix to copy the pose from
  29162. * @returns this TransformNode.
  29163. */
  29164. updatePoseMatrix(matrix: Matrix): TransformNode;
  29165. /**
  29166. * Returns the mesh Pose matrix.
  29167. * @returns the pose matrix
  29168. */
  29169. getPoseMatrix(): Matrix;
  29170. /** @hidden */
  29171. _isSynchronized(): boolean;
  29172. /** @hidden */
  29173. _initCache(): void;
  29174. /**
  29175. * Flag the transform node as dirty (Forcing it to update everything)
  29176. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29177. * @returns this transform node
  29178. */
  29179. markAsDirty(property: string): TransformNode;
  29180. /**
  29181. * Returns the current mesh absolute position.
  29182. * Returns a Vector3.
  29183. */
  29184. readonly absolutePosition: Vector3;
  29185. /**
  29186. * Sets a new matrix to apply before all other transformation
  29187. * @param matrix defines the transform matrix
  29188. * @returns the current TransformNode
  29189. */
  29190. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29191. /**
  29192. * Sets a new pivot matrix to the current node
  29193. * @param matrix defines the new pivot matrix to use
  29194. * @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
  29195. * @returns the current TransformNode
  29196. */
  29197. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29198. /**
  29199. * Returns the mesh pivot matrix.
  29200. * Default : Identity.
  29201. * @returns the matrix
  29202. */
  29203. getPivotMatrix(): Matrix;
  29204. /**
  29205. * Prevents the World matrix to be computed any longer.
  29206. * @returns the TransformNode.
  29207. */
  29208. freezeWorldMatrix(): TransformNode;
  29209. /**
  29210. * Allows back the World matrix computation.
  29211. * @returns the TransformNode.
  29212. */
  29213. unfreezeWorldMatrix(): this;
  29214. /**
  29215. * True if the World matrix has been frozen.
  29216. */
  29217. readonly isWorldMatrixFrozen: boolean;
  29218. /**
  29219. * Retuns the mesh absolute position in the World.
  29220. * @returns a Vector3.
  29221. */
  29222. getAbsolutePosition(): Vector3;
  29223. /**
  29224. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29225. * @param absolutePosition the absolute position to set
  29226. * @returns the TransformNode.
  29227. */
  29228. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29229. /**
  29230. * Sets the mesh position in its local space.
  29231. * @param vector3 the position to set in localspace
  29232. * @returns the TransformNode.
  29233. */
  29234. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29235. /**
  29236. * Returns the mesh position in the local space from the current World matrix values.
  29237. * @returns a new Vector3.
  29238. */
  29239. getPositionExpressedInLocalSpace(): Vector3;
  29240. /**
  29241. * Translates the mesh along the passed Vector3 in its local space.
  29242. * @param vector3 the distance to translate in localspace
  29243. * @returns the TransformNode.
  29244. */
  29245. locallyTranslate(vector3: Vector3): TransformNode;
  29246. private static _lookAtVectorCache;
  29247. /**
  29248. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29249. * @param targetPoint the position (must be in same space as current mesh) to look at
  29250. * @param yawCor optional yaw (y-axis) correction in radians
  29251. * @param pitchCor optional pitch (x-axis) correction in radians
  29252. * @param rollCor optional roll (z-axis) correction in radians
  29253. * @param space the choosen space of the target
  29254. * @returns the TransformNode.
  29255. */
  29256. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29257. /**
  29258. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29259. * This Vector3 is expressed in the World space.
  29260. * @param localAxis axis to rotate
  29261. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29262. */
  29263. getDirection(localAxis: Vector3): Vector3;
  29264. /**
  29265. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29266. * localAxis is expressed in the mesh local space.
  29267. * result is computed in the Wordl space from the mesh World matrix.
  29268. * @param localAxis axis to rotate
  29269. * @param result the resulting transformnode
  29270. * @returns this TransformNode.
  29271. */
  29272. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29273. /**
  29274. * Sets this transform node rotation to the given local axis.
  29275. * @param localAxis the axis in local space
  29276. * @param yawCor optional yaw (y-axis) correction in radians
  29277. * @param pitchCor optional pitch (x-axis) correction in radians
  29278. * @param rollCor optional roll (z-axis) correction in radians
  29279. * @returns this TransformNode
  29280. */
  29281. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29282. /**
  29283. * Sets a new pivot point to the current node
  29284. * @param point defines the new pivot point to use
  29285. * @param space defines if the point is in world or local space (local by default)
  29286. * @returns the current TransformNode
  29287. */
  29288. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29289. /**
  29290. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29291. * @returns the pivot point
  29292. */
  29293. getPivotPoint(): Vector3;
  29294. /**
  29295. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29296. * @param result the vector3 to store the result
  29297. * @returns this TransformNode.
  29298. */
  29299. getPivotPointToRef(result: Vector3): TransformNode;
  29300. /**
  29301. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29302. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29303. */
  29304. getAbsolutePivotPoint(): Vector3;
  29305. /**
  29306. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29307. * @param result vector3 to store the result
  29308. * @returns this TransformNode.
  29309. */
  29310. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29311. /**
  29312. * Defines the passed node as the parent of the current node.
  29313. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29314. * @param node the node ot set as the parent
  29315. * @returns this TransformNode.
  29316. */
  29317. setParent(node: Nullable<Node>): TransformNode;
  29318. private _nonUniformScaling;
  29319. /**
  29320. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29321. */
  29322. readonly nonUniformScaling: boolean;
  29323. /** @hidden */
  29324. _updateNonUniformScalingState(value: boolean): boolean;
  29325. /**
  29326. * Attach the current TransformNode to another TransformNode associated with a bone
  29327. * @param bone Bone affecting the TransformNode
  29328. * @param affectedTransformNode TransformNode associated with the bone
  29329. * @returns this object
  29330. */
  29331. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29332. /**
  29333. * Detach the transform node if its associated with a bone
  29334. * @returns this object
  29335. */
  29336. detachFromBone(): TransformNode;
  29337. private static _rotationAxisCache;
  29338. /**
  29339. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29340. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29341. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29342. * The passed axis is also normalized.
  29343. * @param axis the axis to rotate around
  29344. * @param amount the amount to rotate in radians
  29345. * @param space Space to rotate in (Default: local)
  29346. * @returns the TransformNode.
  29347. */
  29348. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29349. /**
  29350. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29351. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29352. * The passed axis is also normalized. .
  29353. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29354. * @param point the point to rotate around
  29355. * @param axis the axis to rotate around
  29356. * @param amount the amount to rotate in radians
  29357. * @returns the TransformNode
  29358. */
  29359. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29360. /**
  29361. * Translates the mesh along the axis vector for the passed distance in the given space.
  29362. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29363. * @param axis the axis to translate in
  29364. * @param distance the distance to translate
  29365. * @param space Space to rotate in (Default: local)
  29366. * @returns the TransformNode.
  29367. */
  29368. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29369. /**
  29370. * Adds a rotation step to the mesh current rotation.
  29371. * x, y, z are Euler angles expressed in radians.
  29372. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29373. * This means this rotation is made in the mesh local space only.
  29374. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29375. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29376. * ```javascript
  29377. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29378. * ```
  29379. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29380. * 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.
  29381. * @param x Rotation to add
  29382. * @param y Rotation to add
  29383. * @param z Rotation to add
  29384. * @returns the TransformNode.
  29385. */
  29386. addRotation(x: number, y: number, z: number): TransformNode;
  29387. /**
  29388. * Computes the world matrix of the node
  29389. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29390. * @returns the world matrix
  29391. */
  29392. computeWorldMatrix(force?: boolean): Matrix;
  29393. protected _afterComputeWorldMatrix(): void;
  29394. /**
  29395. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29396. * @param func callback function to add
  29397. *
  29398. * @returns the TransformNode.
  29399. */
  29400. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29401. /**
  29402. * Removes a registered callback function.
  29403. * @param func callback function to remove
  29404. * @returns the TransformNode.
  29405. */
  29406. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29407. /**
  29408. * Gets the position of the current mesh in camera space
  29409. * @param camera defines the camera to use
  29410. * @returns a position
  29411. */
  29412. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29413. /**
  29414. * Returns the distance from the mesh to the active camera
  29415. * @param camera defines the camera to use
  29416. * @returns the distance
  29417. */
  29418. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29419. /**
  29420. * Clone the current transform node
  29421. * @param name Name of the new clone
  29422. * @param newParent New parent for the clone
  29423. * @param doNotCloneChildren Do not clone children hierarchy
  29424. * @returns the new transform node
  29425. */
  29426. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29427. /**
  29428. * Serializes the objects information.
  29429. * @param currentSerializationObject defines the object to serialize in
  29430. * @returns the serialized object
  29431. */
  29432. serialize(currentSerializationObject?: any): any;
  29433. /**
  29434. * Returns a new TransformNode object parsed from the source provided.
  29435. * @param parsedTransformNode is the source.
  29436. * @param scene the scne the object belongs to
  29437. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29438. * @returns a new TransformNode object parsed from the source provided.
  29439. */
  29440. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29441. /**
  29442. * Releases resources associated with this transform node.
  29443. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29444. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29445. */
  29446. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29447. }
  29448. }
  29449. declare module BABYLON {
  29450. /**
  29451. * Specialized buffer used to store vertex data
  29452. */
  29453. class VertexBuffer {
  29454. /** @hidden */
  29455. _buffer: Buffer;
  29456. private _kind;
  29457. private _size;
  29458. private _ownsBuffer;
  29459. private _instanced;
  29460. private _instanceDivisor;
  29461. /**
  29462. * The byte type.
  29463. */
  29464. static readonly BYTE: number;
  29465. /**
  29466. * The unsigned byte type.
  29467. */
  29468. static readonly UNSIGNED_BYTE: number;
  29469. /**
  29470. * The short type.
  29471. */
  29472. static readonly SHORT: number;
  29473. /**
  29474. * The unsigned short type.
  29475. */
  29476. static readonly UNSIGNED_SHORT: number;
  29477. /**
  29478. * The integer type.
  29479. */
  29480. static readonly INT: number;
  29481. /**
  29482. * The unsigned integer type.
  29483. */
  29484. static readonly UNSIGNED_INT: number;
  29485. /**
  29486. * The float type.
  29487. */
  29488. static readonly FLOAT: number;
  29489. /**
  29490. * Gets or sets the instance divisor when in instanced mode
  29491. */
  29492. instanceDivisor: number;
  29493. /**
  29494. * Gets the byte stride.
  29495. */
  29496. readonly byteStride: number;
  29497. /**
  29498. * Gets the byte offset.
  29499. */
  29500. readonly byteOffset: number;
  29501. /**
  29502. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29503. */
  29504. readonly normalized: boolean;
  29505. /**
  29506. * Gets the data type of each component in the array.
  29507. */
  29508. readonly type: number;
  29509. /**
  29510. * Constructor
  29511. * @param engine the engine
  29512. * @param data the data to use for this vertex buffer
  29513. * @param kind the vertex buffer kind
  29514. * @param updatable whether the data is updatable
  29515. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29516. * @param stride the stride (optional)
  29517. * @param instanced whether the buffer is instanced (optional)
  29518. * @param offset the offset of the data (optional)
  29519. * @param size the number of components (optional)
  29520. * @param type the type of the component (optional)
  29521. * @param normalized whether the data contains normalized data (optional)
  29522. * @param useBytes set to true if stride and offset are in bytes (optional)
  29523. */
  29524. 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);
  29525. /** @hidden */
  29526. _rebuild(): void;
  29527. /**
  29528. * Returns the kind of the VertexBuffer (string)
  29529. * @returns a string
  29530. */
  29531. getKind(): string;
  29532. /**
  29533. * Gets a boolean indicating if the VertexBuffer is updatable?
  29534. * @returns true if the buffer is updatable
  29535. */
  29536. isUpdatable(): boolean;
  29537. /**
  29538. * Gets current buffer's data
  29539. * @returns a DataArray or null
  29540. */
  29541. getData(): Nullable<DataArray>;
  29542. /**
  29543. * Gets underlying native buffer
  29544. * @returns underlying native buffer
  29545. */
  29546. getBuffer(): Nullable<WebGLBuffer>;
  29547. /**
  29548. * Gets the stride in float32 units (i.e. byte stride / 4).
  29549. * May not be an integer if the byte stride is not divisible by 4.
  29550. * DEPRECATED. Use byteStride instead.
  29551. * @returns the stride in float32 units
  29552. */
  29553. getStrideSize(): number;
  29554. /**
  29555. * Returns the offset as a multiple of the type byte length.
  29556. * DEPRECATED. Use byteOffset instead.
  29557. * @returns the offset in bytes
  29558. */
  29559. getOffset(): number;
  29560. /**
  29561. * Returns the number of components per vertex attribute (integer)
  29562. * @returns the size in float
  29563. */
  29564. getSize(): number;
  29565. /**
  29566. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29567. * @returns true if this buffer is instanced
  29568. */
  29569. getIsInstanced(): boolean;
  29570. /**
  29571. * Returns the instancing divisor, zero for non-instanced (integer).
  29572. * @returns a number
  29573. */
  29574. getInstanceDivisor(): number;
  29575. /**
  29576. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29577. * @param data defines the data to store
  29578. */
  29579. create(data?: DataArray): void;
  29580. /**
  29581. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29582. * This function will create a new buffer if the current one is not updatable
  29583. * @param data defines the data to store
  29584. */
  29585. update(data: DataArray): void;
  29586. /**
  29587. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29588. * Returns the directly updated WebGLBuffer.
  29589. * @param data the new data
  29590. * @param offset the new offset
  29591. * @param useBytes set to true if the offset is in bytes
  29592. */
  29593. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29594. /**
  29595. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29596. */
  29597. dispose(): void;
  29598. /**
  29599. * Enumerates each value of this vertex buffer as numbers.
  29600. * @param count the number of values to enumerate
  29601. * @param callback the callback function called for each value
  29602. */
  29603. forEach(count: number, callback: (value: number, index: number) => void): void;
  29604. /**
  29605. * Positions
  29606. */
  29607. static readonly PositionKind: string;
  29608. /**
  29609. * Normals
  29610. */
  29611. static readonly NormalKind: string;
  29612. /**
  29613. * Tangents
  29614. */
  29615. static readonly TangentKind: string;
  29616. /**
  29617. * Texture coordinates
  29618. */
  29619. static readonly UVKind: string;
  29620. /**
  29621. * Texture coordinates 2
  29622. */
  29623. static readonly UV2Kind: string;
  29624. /**
  29625. * Texture coordinates 3
  29626. */
  29627. static readonly UV3Kind: string;
  29628. /**
  29629. * Texture coordinates 4
  29630. */
  29631. static readonly UV4Kind: string;
  29632. /**
  29633. * Texture coordinates 5
  29634. */
  29635. static readonly UV5Kind: string;
  29636. /**
  29637. * Texture coordinates 6
  29638. */
  29639. static readonly UV6Kind: string;
  29640. /**
  29641. * Colors
  29642. */
  29643. static readonly ColorKind: string;
  29644. /**
  29645. * Matrix indices (for bones)
  29646. */
  29647. static readonly MatricesIndicesKind: string;
  29648. /**
  29649. * Matrix weights (for bones)
  29650. */
  29651. static readonly MatricesWeightsKind: string;
  29652. /**
  29653. * Additional matrix indices (for bones)
  29654. */
  29655. static readonly MatricesIndicesExtraKind: string;
  29656. /**
  29657. * Additional matrix weights (for bones)
  29658. */
  29659. static readonly MatricesWeightsExtraKind: string;
  29660. /**
  29661. * Deduces the stride given a kind.
  29662. * @param kind The kind string to deduce
  29663. * @returns The deduced stride
  29664. */
  29665. static DeduceStride(kind: string): number;
  29666. /**
  29667. * Gets the byte length of the given type.
  29668. * @param type the type
  29669. * @returns the number of bytes
  29670. */
  29671. static GetTypeByteLength(type: number): number;
  29672. /**
  29673. * Enumerates each value of the given parameters as numbers.
  29674. * @param data the data to enumerate
  29675. * @param byteOffset the byte offset of the data
  29676. * @param byteStride the byte stride of the data
  29677. * @param componentCount the number of components per element
  29678. * @param componentType the type of the component
  29679. * @param count the total number of components
  29680. * @param normalized whether the data is normalized
  29681. * @param callback the callback function called for each value
  29682. */
  29683. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29684. private static _GetFloatValue;
  29685. }
  29686. }
  29687. declare module BABYLON {
  29688. /**
  29689. * Defines a target to use with MorphTargetManager
  29690. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29691. */
  29692. class MorphTarget implements IAnimatable {
  29693. /** defines the name of the target */
  29694. name: string;
  29695. /**
  29696. * Gets or sets the list of animations
  29697. */
  29698. animations: Animation[];
  29699. private _scene;
  29700. private _positions;
  29701. private _normals;
  29702. private _tangents;
  29703. private _influence;
  29704. /**
  29705. * Observable raised when the influence changes
  29706. */
  29707. onInfluenceChanged: Observable<boolean>;
  29708. /** @hidden */
  29709. _onDataLayoutChanged: Observable<void>;
  29710. /**
  29711. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29712. */
  29713. influence: number;
  29714. /**
  29715. * Gets or sets the id of the morph Target
  29716. */
  29717. id: string;
  29718. private _animationPropertiesOverride;
  29719. /**
  29720. * Gets or sets the animation properties override
  29721. */
  29722. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29723. /**
  29724. * Creates a new MorphTarget
  29725. * @param name defines the name of the target
  29726. * @param influence defines the influence to use
  29727. */
  29728. constructor(
  29729. /** defines the name of the target */
  29730. name: string, influence?: number, scene?: Nullable<Scene>);
  29731. /**
  29732. * Gets a boolean defining if the target contains position data
  29733. */
  29734. readonly hasPositions: boolean;
  29735. /**
  29736. * Gets a boolean defining if the target contains normal data
  29737. */
  29738. readonly hasNormals: boolean;
  29739. /**
  29740. * Gets a boolean defining if the target contains tangent data
  29741. */
  29742. readonly hasTangents: boolean;
  29743. /**
  29744. * Affects position data to this target
  29745. * @param data defines the position data to use
  29746. */
  29747. setPositions(data: Nullable<FloatArray>): void;
  29748. /**
  29749. * Gets the position data stored in this target
  29750. * @returns a FloatArray containing the position data (or null if not present)
  29751. */
  29752. getPositions(): Nullable<FloatArray>;
  29753. /**
  29754. * Affects normal data to this target
  29755. * @param data defines the normal data to use
  29756. */
  29757. setNormals(data: Nullable<FloatArray>): void;
  29758. /**
  29759. * Gets the normal data stored in this target
  29760. * @returns a FloatArray containing the normal data (or null if not present)
  29761. */
  29762. getNormals(): Nullable<FloatArray>;
  29763. /**
  29764. * Affects tangent data to this target
  29765. * @param data defines the tangent data to use
  29766. */
  29767. setTangents(data: Nullable<FloatArray>): void;
  29768. /**
  29769. * Gets the tangent data stored in this target
  29770. * @returns a FloatArray containing the tangent data (or null if not present)
  29771. */
  29772. getTangents(): Nullable<FloatArray>;
  29773. /**
  29774. * Serializes the current target into a Serialization object
  29775. * @returns the serialized object
  29776. */
  29777. serialize(): any;
  29778. /**
  29779. * Returns the string "MorphTarget"
  29780. * @returns "MorphTarget"
  29781. */
  29782. getClassName(): string;
  29783. /**
  29784. * Creates a new target from serialized data
  29785. * @param serializationObject defines the serialized data to use
  29786. * @returns a new MorphTarget
  29787. */
  29788. static Parse(serializationObject: any): MorphTarget;
  29789. /**
  29790. * Creates a MorphTarget from mesh data
  29791. * @param mesh defines the source mesh
  29792. * @param name defines the name to use for the new target
  29793. * @param influence defines the influence to attach to the target
  29794. * @returns a new MorphTarget
  29795. */
  29796. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29797. }
  29798. }
  29799. declare module BABYLON {
  29800. /**
  29801. * This class is used to deform meshes using morphing between different targets
  29802. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29803. */
  29804. class MorphTargetManager {
  29805. private _targets;
  29806. private _targetInfluenceChangedObservers;
  29807. private _targetDataLayoutChangedObservers;
  29808. private _activeTargets;
  29809. private _scene;
  29810. private _influences;
  29811. private _supportsNormals;
  29812. private _supportsTangents;
  29813. private _vertexCount;
  29814. private _uniqueId;
  29815. private _tempInfluences;
  29816. /**
  29817. * Creates a new MorphTargetManager
  29818. * @param scene defines the current scene
  29819. */
  29820. constructor(scene?: Nullable<Scene>);
  29821. /**
  29822. * Gets the unique ID of this manager
  29823. */
  29824. readonly uniqueId: number;
  29825. /**
  29826. * Gets the number of vertices handled by this manager
  29827. */
  29828. readonly vertexCount: number;
  29829. /**
  29830. * Gets a boolean indicating if this manager supports morphing of normals
  29831. */
  29832. readonly supportsNormals: boolean;
  29833. /**
  29834. * Gets a boolean indicating if this manager supports morphing of tangents
  29835. */
  29836. readonly supportsTangents: boolean;
  29837. /**
  29838. * Gets the number of targets stored in this manager
  29839. */
  29840. readonly numTargets: number;
  29841. /**
  29842. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29843. */
  29844. readonly numInfluencers: number;
  29845. /**
  29846. * Gets the list of influences (one per target)
  29847. */
  29848. readonly influences: Float32Array;
  29849. /**
  29850. * Gets the active target at specified index. An active target is a target with an influence > 0
  29851. * @param index defines the index to check
  29852. * @returns the requested target
  29853. */
  29854. getActiveTarget(index: number): MorphTarget;
  29855. /**
  29856. * Gets the target at specified index
  29857. * @param index defines the index to check
  29858. * @returns the requested target
  29859. */
  29860. getTarget(index: number): MorphTarget;
  29861. /**
  29862. * Add a new target to this manager
  29863. * @param target defines the target to add
  29864. */
  29865. addTarget(target: MorphTarget): void;
  29866. /**
  29867. * Removes a target from the manager
  29868. * @param target defines the target to remove
  29869. */
  29870. removeTarget(target: MorphTarget): void;
  29871. /**
  29872. * Serializes the current manager into a Serialization object
  29873. * @returns the serialized object
  29874. */
  29875. serialize(): any;
  29876. private _syncActiveTargets;
  29877. /**
  29878. * Syncrhonize the targets with all the meshes using this morph target manager
  29879. */
  29880. synchronize(): void;
  29881. /**
  29882. * Creates a new MorphTargetManager from serialized data
  29883. * @param serializationObject defines the serialized data
  29884. * @param scene defines the hosting scene
  29885. * @returns the new MorphTargetManager
  29886. */
  29887. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29888. }
  29889. }
  29890. declare module BABYLON {
  29891. /**
  29892. * Interface used to present a loading screen while loading a scene
  29893. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29894. */
  29895. interface ILoadingScreen {
  29896. /**
  29897. * Function called to display the loading screen
  29898. */
  29899. displayLoadingUI: () => void;
  29900. /**
  29901. * Function called to hide the loading screen
  29902. */
  29903. hideLoadingUI: () => void;
  29904. /**
  29905. * Gets or sets the color to use for the background
  29906. */
  29907. loadingUIBackgroundColor: string;
  29908. /**
  29909. * Gets or sets the text to display while loading
  29910. */
  29911. loadingUIText: string;
  29912. }
  29913. /**
  29914. * Class used for the default loading screen
  29915. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29916. */
  29917. class DefaultLoadingScreen implements ILoadingScreen {
  29918. private _renderingCanvas;
  29919. private _loadingText;
  29920. private _loadingDivBackgroundColor;
  29921. private _loadingDiv;
  29922. private _loadingTextDiv;
  29923. /**
  29924. * Creates a new default loading screen
  29925. * @param _renderingCanvas defines the canvas used to render the scene
  29926. * @param _loadingText defines the default text to display
  29927. * @param _loadingDivBackgroundColor defines the default background color
  29928. */
  29929. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29930. /**
  29931. * Function called to display the loading screen
  29932. */
  29933. displayLoadingUI(): void;
  29934. /**
  29935. * Function called to hide the loading screen
  29936. */
  29937. hideLoadingUI(): void;
  29938. /**
  29939. * Gets or sets the text to display while loading
  29940. */
  29941. loadingUIText: string;
  29942. /**
  29943. * Gets or sets the color to use for the background
  29944. */
  29945. loadingUIBackgroundColor: string;
  29946. private _resizeLoadingUI;
  29947. }
  29948. }
  29949. declare module BABYLON {
  29950. /**
  29951. * Class used to represent data loading progression
  29952. */
  29953. class SceneLoaderProgressEvent {
  29954. /** defines if data length to load can be evaluated */
  29955. readonly lengthComputable: boolean;
  29956. /** defines the loaded data length */
  29957. readonly loaded: number;
  29958. /** defines the data length to load */
  29959. readonly total: number;
  29960. /**
  29961. * Create a new progress event
  29962. * @param lengthComputable defines if data length to load can be evaluated
  29963. * @param loaded defines the loaded data length
  29964. * @param total defines the data length to load
  29965. */
  29966. constructor(
  29967. /** defines if data length to load can be evaluated */
  29968. lengthComputable: boolean,
  29969. /** defines the loaded data length */
  29970. loaded: number,
  29971. /** defines the data length to load */
  29972. total: number);
  29973. /**
  29974. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  29975. * @param event defines the source event
  29976. * @returns a new SceneLoaderProgressEvent
  29977. */
  29978. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  29979. }
  29980. /**
  29981. * Interface used by SceneLoader plugins to define supported file extensions
  29982. */
  29983. interface ISceneLoaderPluginExtensions {
  29984. /**
  29985. * Defines the list of supported extensions
  29986. */
  29987. [extension: string]: {
  29988. isBinary: boolean;
  29989. };
  29990. }
  29991. /**
  29992. * Interface used by SceneLoader plugin factory
  29993. */
  29994. interface ISceneLoaderPluginFactory {
  29995. /**
  29996. * Defines the name of the factory
  29997. */
  29998. name: string;
  29999. /**
  30000. * Function called to create a new plugin
  30001. * @return the new plugin
  30002. */
  30003. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  30004. /**
  30005. * Boolean indicating if the plugin can direct load specific data
  30006. */
  30007. canDirectLoad?: (data: string) => boolean;
  30008. }
  30009. /**
  30010. * Interface used to define a SceneLoader plugin
  30011. */
  30012. interface ISceneLoaderPlugin {
  30013. /**
  30014. * The friendly name of this plugin.
  30015. */
  30016. name: string;
  30017. /**
  30018. * The file extensions supported by this plugin.
  30019. */
  30020. extensions: string | ISceneLoaderPluginExtensions;
  30021. /**
  30022. * Import meshes into a scene.
  30023. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  30024. * @param scene The scene to import into
  30025. * @param data The data to import
  30026. * @param rootUrl The root url for scene and resources
  30027. * @param meshes The meshes array to import into
  30028. * @param particleSystems The particle systems array to import into
  30029. * @param skeletons The skeletons array to import into
  30030. * @param onError The callback when import fails
  30031. * @returns True if successful or false otherwise
  30032. */
  30033. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  30034. /**
  30035. * Load into a scene.
  30036. * @param scene The scene to load into
  30037. * @param data The data to import
  30038. * @param rootUrl The root url for scene and resources
  30039. * @param onError The callback when import fails
  30040. * @returns true if successful or false otherwise
  30041. */
  30042. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  30043. /**
  30044. * The callback that returns true if the data can be directly loaded.
  30045. */
  30046. canDirectLoad?: (data: string) => boolean;
  30047. /**
  30048. * The callback that allows custom handling of the root url based on the response url.
  30049. */
  30050. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  30051. /**
  30052. * Load into an asset container.
  30053. * @param scene The scene to load into
  30054. * @param data The data to import
  30055. * @param rootUrl The root url for scene and resources
  30056. * @param onError The callback when import fails
  30057. * @returns The loaded asset container
  30058. */
  30059. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  30060. }
  30061. /**
  30062. * Interface used to define an async SceneLoader plugin
  30063. */
  30064. interface ISceneLoaderPluginAsync {
  30065. /**
  30066. * The friendly name of this plugin.
  30067. */
  30068. name: string;
  30069. /**
  30070. * The file extensions supported by this plugin.
  30071. */
  30072. extensions: string | ISceneLoaderPluginExtensions;
  30073. /**
  30074. * Import meshes into a scene.
  30075. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  30076. * @param scene The scene to import into
  30077. * @param data The data to import
  30078. * @param rootUrl The root url for scene and resources
  30079. * @param onProgress The callback when the load progresses
  30080. * @param fileName Defines the name of the file to load
  30081. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  30082. */
  30083. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  30084. meshes: AbstractMesh[];
  30085. particleSystems: IParticleSystem[];
  30086. skeletons: Skeleton[];
  30087. animationGroups: AnimationGroup[];
  30088. }>;
  30089. /**
  30090. * Load into a scene.
  30091. * @param scene The scene to load into
  30092. * @param data The data to import
  30093. * @param rootUrl The root url for scene and resources
  30094. * @param onProgress The callback when the load progresses
  30095. * @param fileName Defines the name of the file to load
  30096. * @returns Nothing
  30097. */
  30098. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  30099. /**
  30100. * The callback that returns true if the data can be directly loaded.
  30101. */
  30102. canDirectLoad?: (data: string) => boolean;
  30103. /**
  30104. * The callback that allows custom handling of the root url based on the response url.
  30105. */
  30106. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  30107. /**
  30108. * Load into an asset container.
  30109. * @param scene The scene to load into
  30110. * @param data The data to import
  30111. * @param rootUrl The root url for scene and resources
  30112. * @param onProgress The callback when the load progresses
  30113. * @param fileName Defines the name of the file to load
  30114. * @returns The loaded asset container
  30115. */
  30116. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  30117. }
  30118. /**
  30119. * Class used to load scene from various file formats using registered plugins
  30120. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  30121. */
  30122. class SceneLoader {
  30123. private static _ForceFullSceneLoadingForIncremental;
  30124. private static _ShowLoadingScreen;
  30125. private static _CleanBoneMatrixWeights;
  30126. /**
  30127. * No logging while loading
  30128. */
  30129. static readonly NO_LOGGING: number;
  30130. /**
  30131. * Minimal logging while loading
  30132. */
  30133. static readonly MINIMAL_LOGGING: number;
  30134. /**
  30135. * Summary logging while loading
  30136. */
  30137. static readonly SUMMARY_LOGGING: number;
  30138. /**
  30139. * Detailled logging while loading
  30140. */
  30141. static readonly DETAILED_LOGGING: number;
  30142. private static _loggingLevel;
  30143. /**
  30144. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30145. */
  30146. static ForceFullSceneLoadingForIncremental: boolean;
  30147. /**
  30148. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30149. */
  30150. static ShowLoadingScreen: boolean;
  30151. /**
  30152. * Defines the current logging level (while loading the scene)
  30153. * @ignorenaming
  30154. */
  30155. static loggingLevel: number;
  30156. /**
  30157. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30158. */
  30159. static CleanBoneMatrixWeights: boolean;
  30160. /**
  30161. * Event raised when a plugin is used to load a scene
  30162. */
  30163. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  30164. private static _registeredPlugins;
  30165. private static _getDefaultPlugin;
  30166. private static _getPluginForExtension;
  30167. private static _getPluginForDirectLoad;
  30168. private static _getPluginForFilename;
  30169. private static _getDirectLoad;
  30170. private static _loadData;
  30171. private static _getFileInfo;
  30172. /**
  30173. * Gets a plugin that can load the given extension
  30174. * @param extension defines the extension to load
  30175. * @returns a plugin or null if none works
  30176. */
  30177. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  30178. /**
  30179. * Gets a boolean indicating that the given extension can be loaded
  30180. * @param extension defines the extension to load
  30181. * @returns true if the extension is supported
  30182. */
  30183. static IsPluginForExtensionAvailable(extension: string): boolean;
  30184. /**
  30185. * Adds a new plugin to the list of registered plugins
  30186. * @param plugin defines the plugin to add
  30187. */
  30188. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  30189. /**
  30190. * Import meshes into a scene
  30191. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  30192. * @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)
  30193. * @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)
  30194. * @param scene the instance of BABYLON.Scene to append to
  30195. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  30196. * @param onProgress a callback with a progress event for each file being loaded
  30197. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  30198. * @param pluginExtension the extension used to determine the plugin
  30199. * @returns The loaded plugin
  30200. */
  30201. 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>;
  30202. /**
  30203. * Import meshes into a scene
  30204. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  30205. * @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)
  30206. * @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)
  30207. * @param scene the instance of BABYLON.Scene to append to
  30208. * @param onProgress a callback with a progress event for each file being loaded
  30209. * @param pluginExtension the extension used to determine the plugin
  30210. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  30211. */
  30212. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  30213. meshes: AbstractMesh[];
  30214. particleSystems: IParticleSystem[];
  30215. skeletons: Skeleton[];
  30216. animationGroups: AnimationGroup[];
  30217. }>;
  30218. /**
  30219. * Load a scene
  30220. * @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)
  30221. * @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)
  30222. * @param engine is the instance of BABYLON.Engine to use to create the scene
  30223. * @param onSuccess a callback with the scene when import succeeds
  30224. * @param onProgress a callback with a progress event for each file being loaded
  30225. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  30226. * @param pluginExtension the extension used to determine the plugin
  30227. * @returns The loaded plugin
  30228. */
  30229. 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>;
  30230. /**
  30231. * Load a scene
  30232. * @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)
  30233. * @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)
  30234. * @param engine is the instance of BABYLON.Engine to use to create the scene
  30235. * @param onProgress a callback with a progress event for each file being loaded
  30236. * @param pluginExtension the extension used to determine the plugin
  30237. * @returns The loaded scene
  30238. */
  30239. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  30240. /**
  30241. * Append a scene
  30242. * @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)
  30243. * @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)
  30244. * @param scene is the instance of BABYLON.Scene to append to
  30245. * @param onSuccess a callback with the scene when import succeeds
  30246. * @param onProgress a callback with a progress event for each file being loaded
  30247. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  30248. * @param pluginExtension the extension used to determine the plugin
  30249. * @returns The loaded plugin
  30250. */
  30251. 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>;
  30252. /**
  30253. * Append a scene
  30254. * @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)
  30255. * @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)
  30256. * @param scene is the instance of BABYLON.Scene to append to
  30257. * @param onProgress a callback with a progress event for each file being loaded
  30258. * @param pluginExtension the extension used to determine the plugin
  30259. * @returns The given scene
  30260. */
  30261. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  30262. /**
  30263. * Load a scene into an asset container
  30264. * @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)
  30265. * @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)
  30266. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  30267. * @param onSuccess a callback with the scene when import succeeds
  30268. * @param onProgress a callback with a progress event for each file being loaded
  30269. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  30270. * @param pluginExtension the extension used to determine the plugin
  30271. * @returns The loaded plugin
  30272. */
  30273. 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>;
  30274. /**
  30275. * Load a scene into an asset container
  30276. * @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)
  30277. * @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)
  30278. * @param scene is the instance of BABYLON.Scene to append to
  30279. * @param onProgress a callback with a progress event for each file being loaded
  30280. * @param pluginExtension the extension used to determine the plugin
  30281. * @returns The loaded asset container
  30282. */
  30283. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  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. * Interface used to describe a physics joint
  30396. */
  30397. interface PhysicsImpostorJoint {
  30398. /** Defines the main impostor to which the joint is linked */
  30399. mainImpostor: PhysicsImpostor;
  30400. /** Defines the impostor that is connected to the main impostor using this joint */
  30401. connectedImpostor: PhysicsImpostor;
  30402. /** Defines the joint itself */
  30403. joint: PhysicsJoint;
  30404. }
  30405. /** @hidden */
  30406. interface IPhysicsEnginePlugin {
  30407. world: any;
  30408. name: string;
  30409. setGravity(gravity: Vector3): void;
  30410. setTimeStep(timeStep: number): void;
  30411. getTimeStep(): number;
  30412. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  30413. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30414. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  30416. removePhysicsBody(impostor: PhysicsImpostor): void;
  30417. generateJoint(joint: PhysicsImpostorJoint): void;
  30418. removeJoint(joint: PhysicsImpostorJoint): void;
  30419. isSupported(): boolean;
  30420. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  30421. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  30422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30423. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30424. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30425. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30426. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  30427. getBodyMass(impostor: PhysicsImpostor): number;
  30428. getBodyFriction(impostor: PhysicsImpostor): number;
  30429. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  30430. getBodyRestitution(impostor: PhysicsImpostor): number;
  30431. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  30432. sleepBody(impostor: PhysicsImpostor): void;
  30433. wakeUpBody(impostor: PhysicsImpostor): void;
  30434. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  30435. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  30436. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30437. getRadius(impostor: PhysicsImpostor): number;
  30438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  30439. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  30440. dispose(): void;
  30441. }
  30442. /**
  30443. * Interface used to define a physics engine
  30444. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30445. */
  30446. interface IPhysicsEngine {
  30447. /**
  30448. * Gets the gravity vector used by the simulation
  30449. */
  30450. gravity: Vector3;
  30451. /**
  30452. * Sets the gravity vector used by the simulation
  30453. * @param gravity defines the gravity vector to use
  30454. */
  30455. setGravity(gravity: Vector3): void;
  30456. /**
  30457. * Set the time step of the physics engine.
  30458. * Default is 1/60.
  30459. * To slow it down, enter 1/600 for example.
  30460. * To speed it up, 1/30
  30461. * @param newTimeStep the new timestep to apply to this world.
  30462. */
  30463. setTimeStep(newTimeStep: number): void;
  30464. /**
  30465. * Get the time step of the physics engine.
  30466. * @returns the current time step
  30467. */
  30468. getTimeStep(): number;
  30469. /**
  30470. * Release all resources
  30471. */
  30472. dispose(): void;
  30473. /**
  30474. * Gets the name of the current physics plugin
  30475. * @returns the name of the plugin
  30476. */
  30477. getPhysicsPluginName(): string;
  30478. /**
  30479. * Adding a new impostor for the impostor tracking.
  30480. * This will be done by the impostor itself.
  30481. * @param impostor the impostor to add
  30482. */
  30483. addImpostor(impostor: PhysicsImpostor): void;
  30484. /**
  30485. * Remove an impostor from the engine.
  30486. * This impostor and its mesh will not longer be updated by the physics engine.
  30487. * @param impostor the impostor to remove
  30488. */
  30489. removeImpostor(impostor: PhysicsImpostor): void;
  30490. /**
  30491. * Add a joint to the physics engine
  30492. * @param mainImpostor defines the main impostor to which the joint is added.
  30493. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30494. * @param joint defines the joint that will connect both impostors.
  30495. */
  30496. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30497. /**
  30498. * Removes a joint from the simulation
  30499. * @param mainImpostor defines the impostor used with the joint
  30500. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30501. * @param joint defines the joint to remove
  30502. */
  30503. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30504. /**
  30505. * Gets the current plugin used to run the simulation
  30506. * @returns current plugin
  30507. */
  30508. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30509. /**
  30510. * Gets the list of physic impostors
  30511. * @returns an array of PhysicsImpostor
  30512. */
  30513. getImpostors(): Array<PhysicsImpostor>;
  30514. /**
  30515. * Gets the impostor for a physics enabled object
  30516. * @param object defines the object impersonated by the impostor
  30517. * @returns the PhysicsImpostor or null if not found
  30518. */
  30519. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30520. /**
  30521. * Gets the impostor for a physics body object
  30522. * @param body defines physics body used by the impostor
  30523. * @returns the PhysicsImpostor or null if not found
  30524. */
  30525. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30526. /**
  30527. * Called by the scene. No need to call it.
  30528. * @param delta defines the timespam between frames
  30529. */
  30530. _step(delta: number): void;
  30531. }
  30532. }
  30533. declare module BABYLON {
  30534. /**
  30535. * Class used to control physics engine
  30536. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30537. */
  30538. class PhysicsEngine implements IPhysicsEngine {
  30539. private _physicsPlugin;
  30540. /**
  30541. * Global value used to control the smallest number supported by the simulation
  30542. */
  30543. static Epsilon: number;
  30544. private _impostors;
  30545. private _joints;
  30546. /**
  30547. * Gets the gravity vector used by the simulation
  30548. */
  30549. gravity: Vector3;
  30550. /**
  30551. * Creates a new Physics Engine
  30552. * @param gravity defines the gravity vector used by the simulation
  30553. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  30554. */
  30555. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  30556. /**
  30557. * Sets the gravity vector used by the simulation
  30558. * @param gravity defines the gravity vector to use
  30559. */
  30560. setGravity(gravity: Vector3): void;
  30561. /**
  30562. * Set the time step of the physics engine.
  30563. * Default is 1/60.
  30564. * To slow it down, enter 1/600 for example.
  30565. * To speed it up, 1/30
  30566. * @param newTimeStep defines the new timestep to apply to this world.
  30567. */
  30568. setTimeStep(newTimeStep?: number): void;
  30569. /**
  30570. * Get the time step of the physics engine.
  30571. * @returns the current time step
  30572. */
  30573. getTimeStep(): number;
  30574. /**
  30575. * Release all resources
  30576. */
  30577. dispose(): void;
  30578. /**
  30579. * Gets the name of the current physics plugin
  30580. * @returns the name of the plugin
  30581. */
  30582. getPhysicsPluginName(): string;
  30583. /**
  30584. * Adding a new impostor for the impostor tracking.
  30585. * This will be done by the impostor itself.
  30586. * @param impostor the impostor to add
  30587. */
  30588. addImpostor(impostor: PhysicsImpostor): void;
  30589. /**
  30590. * Remove an impostor from the engine.
  30591. * This impostor and its mesh will not longer be updated by the physics engine.
  30592. * @param impostor the impostor to remove
  30593. */
  30594. removeImpostor(impostor: PhysicsImpostor): void;
  30595. /**
  30596. * Add a joint to the physics engine
  30597. * @param mainImpostor defines the main impostor to which the joint is added.
  30598. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30599. * @param joint defines the joint that will connect both impostors.
  30600. */
  30601. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30602. /**
  30603. * Removes a joint from the simulation
  30604. * @param mainImpostor defines the impostor used with the joint
  30605. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30606. * @param joint defines the joint to remove
  30607. */
  30608. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30609. /**
  30610. * Called by the scene. No need to call it.
  30611. * @param delta defines the timespam between frames
  30612. */
  30613. _step(delta: number): void;
  30614. /**
  30615. * Gets the current plugin used to run the simulation
  30616. * @returns current plugin
  30617. */
  30618. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30619. /**
  30620. * Gets the list of physic impostors
  30621. * @returns an array of PhysicsImpostor
  30622. */
  30623. getImpostors(): Array<PhysicsImpostor>;
  30624. /**
  30625. * Gets the impostor for a physics enabled object
  30626. * @param object defines the object impersonated by the impostor
  30627. * @returns the PhysicsImpostor or null if not found
  30628. */
  30629. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30630. /**
  30631. * Gets the impostor for a physics body object
  30632. * @param body defines physics body used by the impostor
  30633. * @returns the PhysicsImpostor or null if not found
  30634. */
  30635. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30636. }
  30637. }
  30638. declare module BABYLON {
  30639. interface Scene {
  30640. /** @hidden (Backing field) */
  30641. _physicsEngine: Nullable<IPhysicsEngine>;
  30642. /**
  30643. * Gets the current physics engine
  30644. * @returns a IPhysicsEngine or null if none attached
  30645. */
  30646. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  30647. /**
  30648. * Enables physics to the current scene
  30649. * @param gravity defines the scene's gravity for the physics engine
  30650. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  30651. * @return a boolean indicating if the physics engine was initialized
  30652. */
  30653. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  30654. /**
  30655. * Disables and disposes the physics engine associated with the scene
  30656. */
  30657. disablePhysicsEngine(): void;
  30658. /**
  30659. * Gets a boolean indicating if there is an active physics engine
  30660. * @returns a boolean indicating if there is an active physics engine
  30661. */
  30662. isPhysicsEnabled(): boolean;
  30663. /**
  30664. * Deletes a physics compound impostor
  30665. * @param compound defines the compound to delete
  30666. */
  30667. deleteCompoundImpostor(compound: any): void;
  30668. /**
  30669. * An event triggered when physic simulation is about to be run
  30670. */
  30671. onBeforePhysicsObservable: Observable<Scene>;
  30672. /**
  30673. * An event triggered when physic simulation has been done
  30674. */
  30675. onAfterPhysicsObservable: Observable<Scene>;
  30676. }
  30677. interface AbstractMesh {
  30678. /** @hidden */
  30679. _physicsImpostor: Nullable<PhysicsImpostor>;
  30680. /**
  30681. * Gets or sets impostor used for physic simulation
  30682. * @see http://doc.babylonjs.com/features/physics_engine
  30683. */
  30684. physicsImpostor: Nullable<PhysicsImpostor>;
  30685. /**
  30686. * Gets the current physics impostor
  30687. * @see http://doc.babylonjs.com/features/physics_engine
  30688. * @returns a physics impostor or null
  30689. */
  30690. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  30691. /** Apply a physic impulse to the mesh
  30692. * @param force defines the force to apply
  30693. * @param contactPoint defines where to apply the force
  30694. * @returns the current mesh
  30695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30696. */
  30697. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  30698. /**
  30699. * Creates a physic joint between two meshes
  30700. * @param otherMesh defines the other mesh to use
  30701. * @param pivot1 defines the pivot to use on this mesh
  30702. * @param pivot2 defines the pivot to use on the other mesh
  30703. * @param options defines additional options (can be plugin dependent)
  30704. * @returns the current mesh
  30705. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  30706. */
  30707. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  30708. /** @hidden */
  30709. _disposePhysicsObserver: Nullable<Observer<Node>>;
  30710. }
  30711. /**
  30712. * Defines the physics engine scene component responsible to manage a physics engine
  30713. */
  30714. class PhysicsEngineSceneComponent implements ISceneComponent {
  30715. /**
  30716. * The component name helpful to identify the component in the list of scene components.
  30717. */
  30718. readonly name: string;
  30719. /**
  30720. * The scene the component belongs to.
  30721. */
  30722. scene: Scene;
  30723. /**
  30724. * Creates a new instance of the component for the given scene
  30725. * @param scene Defines the scene to register the component in
  30726. */
  30727. constructor(scene: Scene);
  30728. /**
  30729. * Registers the component in a given scene
  30730. */
  30731. register(): void;
  30732. /**
  30733. * Rebuilds the elements related to this component in case of
  30734. * context lost for instance.
  30735. */
  30736. rebuild(): void;
  30737. /**
  30738. * Disposes the component and the associated ressources
  30739. */
  30740. dispose(): void;
  30741. }
  30742. }
  30743. declare module BABYLON {
  30744. /**
  30745. * A helper for physics simulations
  30746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30747. */
  30748. class PhysicsHelper {
  30749. private _scene;
  30750. private _physicsEngine;
  30751. /**
  30752. * Initializes the Physics helper
  30753. * @param scene Babylon.js scene
  30754. */
  30755. constructor(scene: Scene);
  30756. /**
  30757. * Applies a radial explosion impulse
  30758. * @param origin the origin of the explosion
  30759. * @param radius the explosion radius
  30760. * @param strength the explosion strength
  30761. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30762. * @returns A physics radial explosion event, or null
  30763. */
  30764. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30765. /**
  30766. * Applies a radial explosion force
  30767. * @param origin the origin of the explosion
  30768. * @param radius the explosion radius
  30769. * @param strength the explosion strength
  30770. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30771. * @returns A physics radial explosion event, or null
  30772. */
  30773. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30774. /**
  30775. * Creates a gravitational field
  30776. * @param origin the origin of the explosion
  30777. * @param radius the explosion radius
  30778. * @param strength the explosion strength
  30779. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30780. * @returns A physics gravitational field event, or null
  30781. */
  30782. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30783. /**
  30784. * Creates a physics updraft event
  30785. * @param origin the origin of the updraft
  30786. * @param radius the radius of the updraft
  30787. * @param strength the strength of the updraft
  30788. * @param height the height of the updraft
  30789. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  30790. * @returns A physics updraft event, or null
  30791. */
  30792. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30793. /**
  30794. * Creates a physics vortex event
  30795. * @param origin the of the vortex
  30796. * @param radius the radius of the vortex
  30797. * @param strength the strength of the vortex
  30798. * @param height the height of the vortex
  30799. * @returns a Physics vortex event, or null
  30800. * A physics vortex event or null
  30801. */
  30802. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30803. }
  30804. /**
  30805. * Represents a physics radial explosion event
  30806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30807. */
  30808. class PhysicsRadialExplosionEvent {
  30809. private _scene;
  30810. private _sphere;
  30811. private _sphereOptions;
  30812. private _rays;
  30813. private _dataFetched;
  30814. /**
  30815. * Initializes a radial explosioin event
  30816. * @param scene BabylonJS scene
  30817. */
  30818. constructor(scene: Scene);
  30819. /**
  30820. * Returns the data related to the radial explosion event (sphere & rays).
  30821. * @returns The radial explosion event data
  30822. */
  30823. getData(): PhysicsRadialExplosionEventData;
  30824. /**
  30825. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30826. * @param impostor A physics imposter
  30827. * @param origin the origin of the explosion
  30828. * @param radius the explosion radius
  30829. * @param strength the explosion strength
  30830. * @param falloff possible options: Constant & Linear
  30831. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  30832. */
  30833. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30834. /**
  30835. * Disposes the sphere.
  30836. * @param force Specifies if the sphere should be disposed by force
  30837. */
  30838. dispose(force?: boolean): void;
  30839. /*** Helpers ***/
  30840. private _prepareSphere;
  30841. private _intersectsWithSphere;
  30842. }
  30843. /**
  30844. * Represents a gravitational field event
  30845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30846. */
  30847. class PhysicsGravitationalFieldEvent {
  30848. private _physicsHelper;
  30849. private _scene;
  30850. private _origin;
  30851. private _radius;
  30852. private _strength;
  30853. private _falloff;
  30854. private _tickCallback;
  30855. private _sphere;
  30856. private _dataFetched;
  30857. /**
  30858. * Initializes the physics gravitational field event
  30859. * @param physicsHelper A physics helper
  30860. * @param scene BabylonJS scene
  30861. * @param origin The origin position of the gravitational field event
  30862. * @param radius The radius of the gravitational field event
  30863. * @param strength The strength of the gravitational field event
  30864. * @param falloff The falloff for the gravitational field event
  30865. */
  30866. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30867. /**
  30868. * Returns the data related to the gravitational field event (sphere).
  30869. * @returns A gravitational field event
  30870. */
  30871. getData(): PhysicsGravitationalFieldEventData;
  30872. /**
  30873. * Enables the gravitational field.
  30874. */
  30875. enable(): void;
  30876. /**
  30877. * Disables the gravitational field.
  30878. */
  30879. disable(): void;
  30880. /**
  30881. * Disposes the sphere.
  30882. * @param force The force to dispose from the gravitational field event
  30883. */
  30884. dispose(force?: boolean): void;
  30885. private _tick;
  30886. }
  30887. /**
  30888. * Represents a physics updraft event
  30889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30890. */
  30891. class PhysicsUpdraftEvent {
  30892. private _scene;
  30893. private _origin;
  30894. private _radius;
  30895. private _strength;
  30896. private _height;
  30897. private _updraftMode;
  30898. private _physicsEngine;
  30899. private _originTop;
  30900. private _originDirection;
  30901. private _tickCallback;
  30902. private _cylinder;
  30903. private _cylinderPosition;
  30904. private _dataFetched;
  30905. /**
  30906. * Initializes the physics updraft event
  30907. * @param _scene BabylonJS scene
  30908. * @param _origin The origin position of the updraft
  30909. * @param _radius The radius of the updraft
  30910. * @param _strength The strength of the updraft
  30911. * @param _height The height of the updraft
  30912. * @param _updraftMode The mode of the updraft
  30913. */
  30914. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30915. /**
  30916. * Returns the data related to the updraft event (cylinder).
  30917. * @returns A physics updraft event
  30918. */
  30919. getData(): PhysicsUpdraftEventData;
  30920. /**
  30921. * Enables the updraft.
  30922. */
  30923. enable(): void;
  30924. /**
  30925. * Disables the cortex.
  30926. */
  30927. disable(): void;
  30928. /**
  30929. * Disposes the sphere.
  30930. * @param force Specifies if the updraft should be disposed by force
  30931. */
  30932. dispose(force?: boolean): void;
  30933. private getImpostorForceAndContactPoint;
  30934. private _tick;
  30935. /*** Helpers ***/
  30936. private _prepareCylinder;
  30937. private _intersectsWithCylinder;
  30938. }
  30939. /**
  30940. * Represents a physics vortex event
  30941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30942. */
  30943. class PhysicsVortexEvent {
  30944. private _scene;
  30945. private _origin;
  30946. private _radius;
  30947. private _strength;
  30948. private _height;
  30949. private _physicsEngine;
  30950. private _originTop;
  30951. private _centripetalForceThreshold;
  30952. private _updraftMultiplier;
  30953. private _tickCallback;
  30954. private _cylinder;
  30955. private _cylinderPosition;
  30956. private _dataFetched;
  30957. /**
  30958. * Initializes the physics vortex event
  30959. * @param _scene The BabylonJS scene
  30960. * @param _origin The origin position of the vortex
  30961. * @param _radius The radius of the vortex
  30962. * @param _strength The strength of the vortex
  30963. * @param _height The height of the vortex
  30964. */
  30965. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30966. /**
  30967. * Returns the data related to the vortex event (cylinder).
  30968. * @returns The physics vortex event data
  30969. */
  30970. getData(): PhysicsVortexEventData;
  30971. /**
  30972. * Enables the vortex.
  30973. */
  30974. enable(): void;
  30975. /**
  30976. * Disables the cortex.
  30977. */
  30978. disable(): void;
  30979. /**
  30980. * Disposes the sphere.
  30981. * @param force
  30982. */
  30983. dispose(force?: boolean): void;
  30984. private getImpostorForceAndContactPoint;
  30985. private _tick;
  30986. /*** Helpers ***/
  30987. private _prepareCylinder;
  30988. private _intersectsWithCylinder;
  30989. }
  30990. /**
  30991. * The strenght of the force in correspondence to the distance of the affected object
  30992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30993. */
  30994. enum PhysicsRadialImpulseFalloff {
  30995. /** Defines that impulse is constant in strength across it's whole radius */
  30996. Constant = 0,
  30997. /** DEfines that impulse gets weaker if it's further from the origin */
  30998. Linear = 1
  30999. }
  31000. /**
  31001. * The strength of the force in correspondence to the distance of the affected object
  31002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31003. */
  31004. enum PhysicsUpdraftMode {
  31005. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  31006. Center = 0,
  31007. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  31008. Perpendicular = 1
  31009. }
  31010. /**
  31011. * Interface for a physics force and contact point
  31012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31013. */
  31014. interface PhysicsForceAndContactPoint {
  31015. /**
  31016. * The force applied at the contact point
  31017. */
  31018. force: Vector3;
  31019. /**
  31020. * The contact point
  31021. */
  31022. contactPoint: Vector3;
  31023. }
  31024. /**
  31025. * Interface for radial explosion event data
  31026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31027. */
  31028. interface PhysicsRadialExplosionEventData {
  31029. /**
  31030. * A sphere used for the radial explosion event
  31031. */
  31032. sphere: Mesh;
  31033. /**
  31034. * An array of rays for the radial explosion event
  31035. */
  31036. rays: Array<Ray>;
  31037. }
  31038. /**
  31039. * Interface for gravitational field event data
  31040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31041. */
  31042. interface PhysicsGravitationalFieldEventData {
  31043. /**
  31044. * A sphere mesh used for the gravitational field event
  31045. */
  31046. sphere: Mesh;
  31047. }
  31048. /**
  31049. * Interface for updraft event data
  31050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31051. */
  31052. interface PhysicsUpdraftEventData {
  31053. /**
  31054. * A cylinder used for the updraft event
  31055. */
  31056. cylinder: Mesh;
  31057. }
  31058. /**
  31059. * Interface for vortex event data
  31060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31061. */
  31062. interface PhysicsVortexEventData {
  31063. /**
  31064. * A cylinder used for the vortex event
  31065. */
  31066. cylinder: Mesh;
  31067. }
  31068. }
  31069. declare module BABYLON {
  31070. /**
  31071. * The interface for the physics imposter parameters
  31072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31073. */
  31074. interface PhysicsImpostorParameters {
  31075. /**
  31076. * The mass of the physics imposter
  31077. */
  31078. mass: number;
  31079. /**
  31080. * The friction of the physics imposter
  31081. */
  31082. friction?: number;
  31083. /**
  31084. * The coefficient of restitution of the physics imposter
  31085. */
  31086. restitution?: number;
  31087. /**
  31088. * The native options of the physics imposter
  31089. */
  31090. nativeOptions?: any;
  31091. /**
  31092. * Specifies if the parent should be ignored
  31093. */
  31094. ignoreParent?: boolean;
  31095. /**
  31096. * Specifies if bi-directional transformations should be disabled
  31097. */
  31098. disableBidirectionalTransformation?: boolean;
  31099. }
  31100. /**
  31101. * Interface for a physics-enabled object
  31102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31103. */
  31104. interface IPhysicsEnabledObject {
  31105. /**
  31106. * The position of the physics-enabled object
  31107. */
  31108. position: Vector3;
  31109. /**
  31110. * The rotation of the physics-enabled object
  31111. */
  31112. rotationQuaternion: Nullable<Quaternion>;
  31113. /**
  31114. * The scale of the physics-enabled object
  31115. */
  31116. scaling: Vector3;
  31117. /**
  31118. * The rotation of the physics-enabled object
  31119. */
  31120. rotation?: Vector3;
  31121. /**
  31122. * The parent of the physics-enabled object
  31123. */
  31124. parent?: any;
  31125. /**
  31126. * The bounding info of the physics-enabled object
  31127. * @returns The bounding info of the physics-enabled object
  31128. */
  31129. getBoundingInfo(): BoundingInfo;
  31130. /**
  31131. * Computes the world matrix
  31132. * @param force Specifies if the world matrix should be computed by force
  31133. * @returns A world matrix
  31134. */
  31135. computeWorldMatrix(force: boolean): Matrix;
  31136. /**
  31137. * Gets the world matrix
  31138. * @returns A world matrix
  31139. */
  31140. getWorldMatrix?(): Matrix;
  31141. /**
  31142. * Gets the child meshes
  31143. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31144. * @returns An array of abstract meshes
  31145. */
  31146. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31147. /**
  31148. * Gets the vertex data
  31149. * @param kind The type of vertex data
  31150. * @returns A nullable array of numbers, or a float32 array
  31151. */
  31152. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31153. /**
  31154. * Gets the indices from the mesh
  31155. * @returns A nullable array of index arrays
  31156. */
  31157. getIndices?(): Nullable<IndicesArray>;
  31158. /**
  31159. * Gets the scene from the mesh
  31160. * @returns the indices array or null
  31161. */
  31162. getScene?(): Scene;
  31163. /**
  31164. * Gets the absolute position from the mesh
  31165. * @returns the absolute position
  31166. */
  31167. getAbsolutePosition(): Vector3;
  31168. /**
  31169. * Gets the absolute pivot point from the mesh
  31170. * @returns the absolute pivot point
  31171. */
  31172. getAbsolutePivotPoint(): Vector3;
  31173. /**
  31174. * Rotates the mesh
  31175. * @param axis The axis of rotation
  31176. * @param amount The amount of rotation
  31177. * @param space The space of the rotation
  31178. * @returns The rotation transform node
  31179. */
  31180. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31181. /**
  31182. * Translates the mesh
  31183. * @param axis The axis of translation
  31184. * @param distance The distance of translation
  31185. * @param space The space of the translation
  31186. * @returns The transform node
  31187. */
  31188. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31189. /**
  31190. * Sets the absolute position of the mesh
  31191. * @param absolutePosition The absolute position of the mesh
  31192. * @returns The transform node
  31193. */
  31194. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31195. /**
  31196. * Gets the class name of the mesh
  31197. * @returns The class name
  31198. */
  31199. getClassName(): string;
  31200. }
  31201. /**
  31202. * Represents a physics imposter
  31203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31204. */
  31205. class PhysicsImpostor {
  31206. /**
  31207. * The physics-enabled object used as the physics imposter
  31208. */
  31209. object: IPhysicsEnabledObject;
  31210. /**
  31211. * The type of the physics imposter
  31212. */
  31213. type: number;
  31214. private _options;
  31215. private _scene?;
  31216. /**
  31217. * The default object size of the imposter
  31218. */
  31219. static DEFAULT_OBJECT_SIZE: Vector3;
  31220. /**
  31221. * The identity quaternion of the imposter
  31222. */
  31223. static IDENTITY_QUATERNION: Quaternion;
  31224. /** @hidden */
  31225. _pluginData: any;
  31226. private _physicsEngine;
  31227. private _physicsBody;
  31228. private _bodyUpdateRequired;
  31229. private _onBeforePhysicsStepCallbacks;
  31230. private _onAfterPhysicsStepCallbacks;
  31231. /** @hidden */
  31232. _onPhysicsCollideCallbacks: Array<{
  31233. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  31234. otherImpostors: Array<PhysicsImpostor>;
  31235. }>;
  31236. private _deltaPosition;
  31237. private _deltaRotation;
  31238. private _deltaRotationConjugated;
  31239. private _parent;
  31240. private _isDisposed;
  31241. private static _tmpVecs;
  31242. private static _tmpQuat;
  31243. /**
  31244. * Specifies if the physics imposter is disposed
  31245. */
  31246. readonly isDisposed: boolean;
  31247. /**
  31248. * Gets the mass of the physics imposter
  31249. */
  31250. mass: number;
  31251. /**
  31252. * Gets the coefficient of friction
  31253. */
  31254. /**
  31255. * Sets the coefficient of friction
  31256. */
  31257. friction: number;
  31258. /**
  31259. * Gets the coefficient of restitution
  31260. */
  31261. /**
  31262. * Sets the coefficient of restitution
  31263. */
  31264. restitution: number;
  31265. /**
  31266. * The unique id of the physics imposter
  31267. * set by the physics engine when adding this impostor to the array
  31268. */
  31269. uniqueId: number;
  31270. private _joints;
  31271. /**
  31272. * Initializes the physics imposter
  31273. * @param object The physics-enabled object used as the physics imposter
  31274. * @param type The type of the physics imposter
  31275. * @param _options The options for the physics imposter
  31276. * @param _scene The Babylon scene
  31277. */
  31278. constructor(
  31279. /**
  31280. * The physics-enabled object used as the physics imposter
  31281. */
  31282. object: IPhysicsEnabledObject,
  31283. /**
  31284. * The type of the physics imposter
  31285. */
  31286. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31287. /**
  31288. * This function will completly initialize this impostor.
  31289. * It will create a new body - but only if this mesh has no parent.
  31290. * If it has, this impostor will not be used other than to define the impostor
  31291. * of the child mesh.
  31292. * @hidden
  31293. */
  31294. _init(): void;
  31295. private _getPhysicsParent;
  31296. /**
  31297. * Should a new body be generated.
  31298. * @returns boolean specifying if body initialization is required
  31299. */
  31300. isBodyInitRequired(): boolean;
  31301. /**
  31302. * Sets the updated scaling
  31303. * @param updated Specifies if the scaling is updated
  31304. */
  31305. setScalingUpdated(updated: boolean): void;
  31306. /**
  31307. * Force a regeneration of this or the parent's impostor's body.
  31308. * Use under cautious - This will remove all joints already implemented.
  31309. */
  31310. forceUpdate(): void;
  31311. /**
  31312. * Gets the body that holds this impostor. Either its own, or its parent.
  31313. */
  31314. /**
  31315. * Set the physics body. Used mainly by the physics engine/plugin
  31316. */
  31317. physicsBody: any;
  31318. /**
  31319. * Get the parent of the physics imposter
  31320. * @returns Physics imposter or null
  31321. */
  31322. /**
  31323. * Sets the parent of the physics imposter
  31324. */
  31325. parent: Nullable<PhysicsImpostor>;
  31326. /**
  31327. * Resets the update flags
  31328. */
  31329. resetUpdateFlags(): void;
  31330. /**
  31331. * Gets the object extend size
  31332. * @returns the object extend size
  31333. */
  31334. getObjectExtendSize(): Vector3;
  31335. /**
  31336. * Gets the object center
  31337. * @returns The object center
  31338. */
  31339. getObjectCenter(): Vector3;
  31340. /**
  31341. * Get a specific parametes from the options parameter
  31342. * @param paramName The object parameter name
  31343. * @returns The object parameter
  31344. */
  31345. getParam(paramName: string): any;
  31346. /**
  31347. * Sets a specific parameter in the options given to the physics plugin
  31348. * @param paramName The parameter name
  31349. * @param value The value of the parameter
  31350. */
  31351. setParam(paramName: string, value: number): void;
  31352. /**
  31353. * Specifically change the body's mass option. Won't recreate the physics body object
  31354. * @param mass The mass of the physics imposter
  31355. */
  31356. setMass(mass: number): void;
  31357. /**
  31358. * Gets the linear velocity
  31359. * @returns linear velocity or null
  31360. */
  31361. getLinearVelocity(): Nullable<Vector3>;
  31362. /**
  31363. * Sets the linear velocity
  31364. * @param velocity linear velocity or null
  31365. */
  31366. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31367. /**
  31368. * Gets the angular velocity
  31369. * @returns angular velocity or null
  31370. */
  31371. getAngularVelocity(): Nullable<Vector3>;
  31372. /**
  31373. * Sets the angular velocity
  31374. * @param velocity The velocity or null
  31375. */
  31376. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31377. /**
  31378. * Execute a function with the physics plugin native code
  31379. * Provide a function the will have two variables - the world object and the physics body object
  31380. * @param func The function to execute with the physics plugin native code
  31381. */
  31382. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31383. /**
  31384. * Register a function that will be executed before the physics world is stepping forward
  31385. * @param func The function to execute before the physics world is stepped forward
  31386. */
  31387. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31388. /**
  31389. * Unregister a function that will be executed before the physics world is stepping forward
  31390. * @param func The function to execute before the physics world is stepped forward
  31391. */
  31392. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31393. /**
  31394. * Register a function that will be executed after the physics step
  31395. * @param func The function to execute after physics step
  31396. */
  31397. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31398. /**
  31399. * Unregisters a function that will be executed after the physics step
  31400. * @param func The function to execute after physics step
  31401. */
  31402. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31403. /**
  31404. * register a function that will be executed when this impostor collides against a different body
  31405. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31406. * @param func Callback that is executed on collision
  31407. */
  31408. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31409. /**
  31410. * Unregisters the physics imposter on contact
  31411. * @param collideAgainst The physics object to collide against
  31412. * @param func Callback to execute on collision
  31413. */
  31414. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31415. private _tmpQuat;
  31416. private _tmpQuat2;
  31417. /**
  31418. * Get the parent rotation
  31419. * @returns The parent rotation
  31420. */
  31421. getParentsRotation(): Quaternion;
  31422. /**
  31423. * this function is executed by the physics engine.
  31424. */
  31425. beforeStep: () => void;
  31426. /**
  31427. * this function is executed by the physics engine
  31428. */
  31429. afterStep: () => void;
  31430. /**
  31431. * Legacy collision detection event support
  31432. */
  31433. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31434. /**
  31435. * event and body object due to cannon's event-based architecture.
  31436. */
  31437. onCollide: (e: {
  31438. body: any;
  31439. }) => void;
  31440. /**
  31441. * Apply a force
  31442. * @param force The force to apply
  31443. * @param contactPoint The contact point for the force
  31444. * @returns The physics imposter
  31445. */
  31446. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31447. /**
  31448. * Apply an impulse
  31449. * @param force The impulse force
  31450. * @param contactPoint The contact point for the impulse force
  31451. * @returns The physics imposter
  31452. */
  31453. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31454. /**
  31455. * A help function to create a joint
  31456. * @param otherImpostor A physics imposter used to create a joint
  31457. * @param jointType The type of joint
  31458. * @param jointData The data for the joint
  31459. * @returns The physics imposter
  31460. */
  31461. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  31462. /**
  31463. * Add a joint to this impostor with a different impostor
  31464. * @param otherImpostor A physics imposter used to add a joint
  31465. * @param joint The joint to add
  31466. * @returns The physics imposter
  31467. */
  31468. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  31469. /**
  31470. * Will keep this body still, in a sleep mode.
  31471. * @returns the physics imposter
  31472. */
  31473. sleep(): PhysicsImpostor;
  31474. /**
  31475. * Wake the body up.
  31476. * @returns The physics imposter
  31477. */
  31478. wakeUp(): PhysicsImpostor;
  31479. /**
  31480. * Clones the physics imposter
  31481. * @param newObject The physics imposter clones to this physics-enabled object
  31482. * @returns A nullable physics imposter
  31483. */
  31484. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31485. /**
  31486. * Disposes the physics imposter
  31487. */
  31488. dispose(): void;
  31489. /**
  31490. * Sets the delta position
  31491. * @param position The delta position amount
  31492. */
  31493. setDeltaPosition(position: Vector3): void;
  31494. /**
  31495. * Sets the delta rotation
  31496. * @param rotation The delta rotation amount
  31497. */
  31498. setDeltaRotation(rotation: Quaternion): void;
  31499. /**
  31500. * Gets the box size of the physics imposter and stores the result in the input parameter
  31501. * @param result Stores the box size
  31502. * @returns The physics imposter
  31503. */
  31504. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  31505. /**
  31506. * Gets the radius of the physics imposter
  31507. * @returns Radius of the physics imposter
  31508. */
  31509. getRadius(): number;
  31510. /**
  31511. * Sync a bone with this impostor
  31512. * @param bone The bone to sync to the impostor.
  31513. * @param boneMesh The mesh that the bone is influencing.
  31514. * @param jointPivot The pivot of the joint / bone in local space.
  31515. * @param distToJoint Optional distance from the impostor to the joint.
  31516. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31517. */
  31518. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  31519. /**
  31520. * Sync impostor to a bone
  31521. * @param bone The bone that the impostor will be synced to.
  31522. * @param boneMesh The mesh that the bone is influencing.
  31523. * @param jointPivot The pivot of the joint / bone in local space.
  31524. * @param distToJoint Optional distance from the impostor to the joint.
  31525. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31526. * @param boneAxis Optional vector3 axis the bone is aligned with
  31527. */
  31528. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  31529. /**
  31530. * No-Imposter type
  31531. */
  31532. static NoImpostor: number;
  31533. /**
  31534. * Sphere-Imposter type
  31535. */
  31536. static SphereImpostor: number;
  31537. /**
  31538. * Box-Imposter type
  31539. */
  31540. static BoxImpostor: number;
  31541. /**
  31542. * Plane-Imposter type
  31543. */
  31544. static PlaneImpostor: number;
  31545. /**
  31546. * Mesh-imposter type
  31547. */
  31548. static MeshImpostor: number;
  31549. /**
  31550. * Cylinder-Imposter type
  31551. */
  31552. static CylinderImpostor: number;
  31553. /**
  31554. * Particle-Imposter type
  31555. */
  31556. static ParticleImpostor: number;
  31557. /**
  31558. * Heightmap-Imposter type
  31559. */
  31560. static HeightmapImpostor: number;
  31561. }
  31562. }
  31563. declare module BABYLON {
  31564. /**
  31565. * Interface for Physics-Joint data
  31566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31567. */
  31568. interface PhysicsJointData {
  31569. /**
  31570. * The main pivot of the joint
  31571. */
  31572. mainPivot?: Vector3;
  31573. /**
  31574. * The connected pivot of the joint
  31575. */
  31576. connectedPivot?: Vector3;
  31577. /**
  31578. * The main axis of the joint
  31579. */
  31580. mainAxis?: Vector3;
  31581. /**
  31582. * The connected axis of the joint
  31583. */
  31584. connectedAxis?: Vector3;
  31585. /**
  31586. * The collision of the joint
  31587. */
  31588. collision?: boolean;
  31589. /**
  31590. * Native Oimo/Cannon/Energy data
  31591. */
  31592. nativeParams?: any;
  31593. }
  31594. /**
  31595. * This is a holder class for the physics joint created by the physics plugin
  31596. * It holds a set of functions to control the underlying joint
  31597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31598. */
  31599. class PhysicsJoint {
  31600. /**
  31601. * The type of the physics joint
  31602. */
  31603. type: number;
  31604. /**
  31605. * The data for the physics joint
  31606. */
  31607. jointData: PhysicsJointData;
  31608. private _physicsJoint;
  31609. protected _physicsPlugin: IPhysicsEnginePlugin;
  31610. /**
  31611. * Initializes the physics joint
  31612. * @param type The type of the physics joint
  31613. * @param jointData The data for the physics joint
  31614. */
  31615. constructor(
  31616. /**
  31617. * The type of the physics joint
  31618. */
  31619. type: number,
  31620. /**
  31621. * The data for the physics joint
  31622. */
  31623. jointData: PhysicsJointData);
  31624. /**
  31625. * Gets the physics joint
  31626. */
  31627. /**
  31628. * Sets the physics joint
  31629. */
  31630. physicsJoint: any;
  31631. /**
  31632. * Sets the physics plugin
  31633. */
  31634. physicsPlugin: IPhysicsEnginePlugin;
  31635. /**
  31636. * Execute a function that is physics-plugin specific.
  31637. * @param {Function} func the function that will be executed.
  31638. * It accepts two parameters: the physics world and the physics joint
  31639. */
  31640. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31641. /**
  31642. * Distance-Joint type
  31643. */
  31644. static DistanceJoint: number;
  31645. /**
  31646. * Hinge-Joint type
  31647. */
  31648. static HingeJoint: number;
  31649. /**
  31650. * Ball-and-Socket joint type
  31651. */
  31652. static BallAndSocketJoint: number;
  31653. /**
  31654. * Wheel-Joint type
  31655. */
  31656. static WheelJoint: number;
  31657. /**
  31658. * Slider-Joint type
  31659. */
  31660. static SliderJoint: number;
  31661. /**
  31662. * Prismatic-Joint type
  31663. */
  31664. static PrismaticJoint: number;
  31665. /**
  31666. * Universal-Joint type
  31667. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31668. */
  31669. static UniversalJoint: number;
  31670. /**
  31671. * Hinge-Joint 2 type
  31672. */
  31673. static Hinge2Joint: number;
  31674. /**
  31675. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31676. */
  31677. static PointToPointJoint: number;
  31678. /**
  31679. * Spring-Joint type
  31680. */
  31681. static SpringJoint: number;
  31682. /**
  31683. * Lock-Joint type
  31684. */
  31685. static LockJoint: number;
  31686. }
  31687. /**
  31688. * A class representing a physics distance joint
  31689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31690. */
  31691. class DistanceJoint extends PhysicsJoint {
  31692. /**
  31693. *
  31694. * @param jointData The data for the Distance-Joint
  31695. */
  31696. constructor(jointData: DistanceJointData);
  31697. /**
  31698. * Update the predefined distance.
  31699. * @param maxDistance The maximum preferred distance
  31700. * @param minDistance The minimum preferred distance
  31701. */
  31702. updateDistance(maxDistance: number, minDistance?: number): void;
  31703. }
  31704. /**
  31705. * Represents a Motor-Enabled Joint
  31706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31707. */
  31708. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31709. /**
  31710. * Initializes the Motor-Enabled Joint
  31711. * @param type The type of the joint
  31712. * @param jointData The physica joint data for the joint
  31713. */
  31714. constructor(type: number, jointData: PhysicsJointData);
  31715. /**
  31716. * Set the motor values.
  31717. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31718. * @param force the force to apply
  31719. * @param maxForce max force for this motor.
  31720. */
  31721. setMotor(force?: number, maxForce?: number): void;
  31722. /**
  31723. * Set the motor's limits.
  31724. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31725. * @param upperLimit The upper limit of the motor
  31726. * @param lowerLimit The lower limit of the motor
  31727. */
  31728. setLimit(upperLimit: number, lowerLimit?: number): void;
  31729. }
  31730. /**
  31731. * This class represents a single physics Hinge-Joint
  31732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31733. */
  31734. class HingeJoint extends MotorEnabledJoint {
  31735. /**
  31736. * Initializes the Hinge-Joint
  31737. * @param jointData The joint data for the Hinge-Joint
  31738. */
  31739. constructor(jointData: PhysicsJointData);
  31740. /**
  31741. * Set the motor values.
  31742. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31743. * @param {number} force the force to apply
  31744. * @param {number} maxForce max force for this motor.
  31745. */
  31746. setMotor(force?: number, maxForce?: number): void;
  31747. /**
  31748. * Set the motor's limits.
  31749. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31750. * @param upperLimit The upper limit of the motor
  31751. * @param lowerLimit The lower limit of the motor
  31752. */
  31753. setLimit(upperLimit: number, lowerLimit?: number): void;
  31754. }
  31755. /**
  31756. * This class represents a dual hinge physics joint (same as wheel joint)
  31757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31758. */
  31759. class Hinge2Joint extends MotorEnabledJoint {
  31760. /**
  31761. * Initializes the Hinge2-Joint
  31762. * @param jointData The joint data for the Hinge2-Joint
  31763. */
  31764. constructor(jointData: PhysicsJointData);
  31765. /**
  31766. * Set the motor values.
  31767. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31768. * @param {number} force the force to apply
  31769. * @param {number} maxForce max force for this motor.
  31770. * @param {motorIndex} the motor's index, 0 or 1.
  31771. */
  31772. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31773. /**
  31774. * Set the motor limits.
  31775. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31776. * @param {number} upperLimit the upper limit
  31777. * @param {number} lowerLimit lower limit
  31778. * @param {motorIndex} the motor's index, 0 or 1.
  31779. */
  31780. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31781. }
  31782. /**
  31783. * Interface for a motor enabled joint
  31784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31785. */
  31786. interface IMotorEnabledJoint {
  31787. /**
  31788. * Physics joint
  31789. */
  31790. physicsJoint: any;
  31791. /**
  31792. * Sets the motor of the motor-enabled joint
  31793. * @param force The force of the motor
  31794. * @param maxForce The maximum force of the motor
  31795. * @param motorIndex The index of the motor
  31796. */
  31797. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31798. /**
  31799. * Sets the limit of the motor
  31800. * @param upperLimit The upper limit of the motor
  31801. * @param lowerLimit The lower limit of the motor
  31802. * @param motorIndex The index of the motor
  31803. */
  31804. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31805. }
  31806. /**
  31807. * Joint data for a Distance-Joint
  31808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31809. */
  31810. interface DistanceJointData extends PhysicsJointData {
  31811. /**
  31812. * Max distance the 2 joint objects can be apart
  31813. */
  31814. maxDistance: number;
  31815. }
  31816. /**
  31817. * Joint data from a spring joint
  31818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31819. */
  31820. interface SpringJointData extends PhysicsJointData {
  31821. /**
  31822. * Length of the spring
  31823. */
  31824. length: number;
  31825. /**
  31826. * Stiffness of the spring
  31827. */
  31828. stiffness: number;
  31829. /**
  31830. * Damping of the spring
  31831. */
  31832. damping: number;
  31833. /** this callback will be called when applying the force to the impostors. */
  31834. forceApplicationCallback: () => void;
  31835. }
  31836. }
  31837. declare module BABYLON {
  31838. /**
  31839. * This represents the base class for particle system in Babylon.
  31840. * 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.
  31841. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31842. * @example https://doc.babylonjs.com/babylon101/particles
  31843. */
  31844. class BaseParticleSystem {
  31845. /**
  31846. * Source color is added to the destination color without alpha affecting the result
  31847. */
  31848. static BLENDMODE_ONEONE: number;
  31849. /**
  31850. * Blend current color and particle color using particle’s alpha
  31851. */
  31852. static BLENDMODE_STANDARD: number;
  31853. /**
  31854. * Add current color and particle color multiplied by particle’s alpha
  31855. */
  31856. static BLENDMODE_ADD: number;
  31857. /**
  31858. * Multiply current color with particle color
  31859. */
  31860. static BLENDMODE_MULTIPLY: number;
  31861. /**
  31862. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  31863. */
  31864. static BLENDMODE_MULTIPLYADD: number;
  31865. /**
  31866. * List of animations used by the particle system.
  31867. */
  31868. animations: Animation[];
  31869. /**
  31870. * The id of the Particle system.
  31871. */
  31872. id: string;
  31873. /**
  31874. * The friendly name of the Particle system.
  31875. */
  31876. name: string;
  31877. /**
  31878. * The rendering group used by the Particle system to chose when to render.
  31879. */
  31880. renderingGroupId: number;
  31881. /**
  31882. * The emitter represents the Mesh or position we are attaching the particle system to.
  31883. */
  31884. emitter: Nullable<AbstractMesh | Vector3>;
  31885. /**
  31886. * The maximum number of particles to emit per frame
  31887. */
  31888. emitRate: number;
  31889. /**
  31890. * If you want to launch only a few particles at once, that can be done, as well.
  31891. */
  31892. manualEmitCount: number;
  31893. /**
  31894. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31895. */
  31896. updateSpeed: number;
  31897. /**
  31898. * The amount of time the particle system is running (depends of the overall update speed).
  31899. */
  31900. targetStopDuration: number;
  31901. /**
  31902. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31903. */
  31904. disposeOnStop: boolean;
  31905. /**
  31906. * Minimum power of emitting particles.
  31907. */
  31908. minEmitPower: number;
  31909. /**
  31910. * Maximum power of emitting particles.
  31911. */
  31912. maxEmitPower: number;
  31913. /**
  31914. * Minimum life time of emitting particles.
  31915. */
  31916. minLifeTime: number;
  31917. /**
  31918. * Maximum life time of emitting particles.
  31919. */
  31920. maxLifeTime: number;
  31921. /**
  31922. * Minimum Size of emitting particles.
  31923. */
  31924. minSize: number;
  31925. /**
  31926. * Maximum Size of emitting particles.
  31927. */
  31928. maxSize: number;
  31929. /**
  31930. * Minimum scale of emitting particles on X axis.
  31931. */
  31932. minScaleX: number;
  31933. /**
  31934. * Maximum scale of emitting particles on X axis.
  31935. */
  31936. maxScaleX: number;
  31937. /**
  31938. * Minimum scale of emitting particles on Y axis.
  31939. */
  31940. minScaleY: number;
  31941. /**
  31942. * Maximum scale of emitting particles on Y axis.
  31943. */
  31944. maxScaleY: number;
  31945. /**
  31946. * Gets or sets the minimal initial rotation in radians.
  31947. */
  31948. minInitialRotation: number;
  31949. /**
  31950. * Gets or sets the maximal initial rotation in radians.
  31951. */
  31952. maxInitialRotation: number;
  31953. /**
  31954. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31955. */
  31956. minAngularSpeed: number;
  31957. /**
  31958. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31959. */
  31960. maxAngularSpeed: number;
  31961. /**
  31962. * The texture used to render each particle. (this can be a spritesheet)
  31963. */
  31964. particleTexture: Nullable<Texture>;
  31965. /**
  31966. * The layer mask we are rendering the particles through.
  31967. */
  31968. layerMask: number;
  31969. /**
  31970. * This can help using your own shader to render the particle system.
  31971. * The according effect will be created
  31972. */
  31973. customShader: any;
  31974. /**
  31975. * By default particle system starts as soon as they are created. This prevents the
  31976. * automatic start to happen and let you decide when to start emitting particles.
  31977. */
  31978. preventAutoStart: boolean;
  31979. private _noiseTexture;
  31980. /**
  31981. * Gets or sets a texture used to add random noise to particle positions
  31982. */
  31983. noiseTexture: Nullable<ProceduralTexture>;
  31984. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31985. noiseStrength: Vector3;
  31986. /**
  31987. * Callback triggered when the particle animation is ending.
  31988. */
  31989. onAnimationEnd: Nullable<() => void>;
  31990. /**
  31991. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  31992. */
  31993. blendMode: number;
  31994. /**
  31995. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31996. * to override the particles.
  31997. */
  31998. forceDepthWrite: boolean;
  31999. /** 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 */
  32000. preWarmCycles: number;
  32001. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  32002. preWarmStepOffset: number;
  32003. /**
  32004. * 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)
  32005. */
  32006. spriteCellChangeSpeed: number;
  32007. /**
  32008. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32009. */
  32010. startSpriteCellID: number;
  32011. /**
  32012. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32013. */
  32014. endSpriteCellID: number;
  32015. /**
  32016. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32017. */
  32018. spriteCellWidth: number;
  32019. /**
  32020. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32021. */
  32022. spriteCellHeight: number;
  32023. /**
  32024. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32025. */
  32026. spriteRandomStartCell: boolean;
  32027. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32028. translationPivot: Vector2;
  32029. /** @hidden */
  32030. protected _isAnimationSheetEnabled: boolean;
  32031. /**
  32032. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32033. */
  32034. beginAnimationOnStart: boolean;
  32035. /**
  32036. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32037. */
  32038. beginAnimationFrom: number;
  32039. /**
  32040. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32041. */
  32042. beginAnimationTo: number;
  32043. /**
  32044. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32045. */
  32046. beginAnimationLoop: boolean;
  32047. /**
  32048. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  32049. */
  32050. isAnimationSheetEnabled: boolean;
  32051. /**
  32052. * Get hosting scene
  32053. * @returns the scene
  32054. */
  32055. getScene(): Scene;
  32056. /**
  32057. * You can use gravity if you want to give an orientation to your particles.
  32058. */
  32059. gravity: Vector3;
  32060. protected _colorGradients: Nullable<Array<ColorGradient>>;
  32061. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  32062. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  32063. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  32064. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  32065. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  32066. protected _dragGradients: Nullable<Array<FactorGradient>>;
  32067. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  32068. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  32069. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  32070. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  32071. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  32072. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  32073. /**
  32074. * Defines the delay in milliseconds before starting the system (0 by default)
  32075. */
  32076. startDelay: number;
  32077. /**
  32078. * Gets the current list of drag gradients.
  32079. * You must use addDragGradient and removeDragGradient to udpate this list
  32080. * @returns the list of drag gradients
  32081. */
  32082. getDragGradients(): Nullable<Array<FactorGradient>>;
  32083. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32084. limitVelocityDamping: number;
  32085. /**
  32086. * Gets the current list of limit velocity gradients.
  32087. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32088. * @returns the list of limit velocity gradients
  32089. */
  32090. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32091. /**
  32092. * Gets the current list of color gradients.
  32093. * You must use addColorGradient and removeColorGradient to udpate this list
  32094. * @returns the list of color gradients
  32095. */
  32096. getColorGradients(): Nullable<Array<ColorGradient>>;
  32097. /**
  32098. * Gets the current list of size gradients.
  32099. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32100. * @returns the list of size gradients
  32101. */
  32102. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32103. /**
  32104. * Gets the current list of color remap gradients.
  32105. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  32106. * @returns the list of color remap gradients
  32107. */
  32108. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  32109. /**
  32110. * Gets the current list of alpha remap gradients.
  32111. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  32112. * @returns the list of alpha remap gradients
  32113. */
  32114. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  32115. /**
  32116. * Gets the current list of life time gradients.
  32117. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  32118. * @returns the list of life time gradients
  32119. */
  32120. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  32121. /**
  32122. * Gets the current list of angular speed gradients.
  32123. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32124. * @returns the list of angular speed gradients
  32125. */
  32126. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32127. /**
  32128. * Gets the current list of velocity gradients.
  32129. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32130. * @returns the list of velocity gradients
  32131. */
  32132. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32133. /**
  32134. * Gets the current list of start size gradients.
  32135. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32136. * @returns the list of start size gradients
  32137. */
  32138. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32139. /**
  32140. * Gets the current list of emit rate gradients.
  32141. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32142. * @returns the list of emit rate gradients
  32143. */
  32144. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32145. /**
  32146. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32147. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32148. */
  32149. direction1: Vector3;
  32150. /**
  32151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32152. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32153. */
  32154. direction2: Vector3;
  32155. /**
  32156. * 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.
  32157. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32158. */
  32159. minEmitBox: Vector3;
  32160. /**
  32161. * 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.
  32162. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32163. */
  32164. maxEmitBox: Vector3;
  32165. /**
  32166. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  32167. */
  32168. color1: Color4;
  32169. /**
  32170. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  32171. */
  32172. color2: Color4;
  32173. /**
  32174. * Color the particle will have at the end of its lifetime
  32175. */
  32176. colorDead: Color4;
  32177. /**
  32178. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  32179. */
  32180. textureMask: Color4;
  32181. /**
  32182. * The particle emitter type defines the emitter used by the particle system.
  32183. * It can be for example box, sphere, or cone...
  32184. */
  32185. particleEmitterType: IParticleEmitterType;
  32186. /** @hidden */
  32187. _isSubEmitter: boolean;
  32188. /**
  32189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32191. */
  32192. billboardMode: number;
  32193. protected _isBillboardBased: boolean;
  32194. /**
  32195. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32196. */
  32197. isBillboardBased: boolean;
  32198. /**
  32199. * The scene the particle system belongs to.
  32200. */
  32201. protected _scene: Scene;
  32202. /**
  32203. * Local cache of defines for image processing.
  32204. */
  32205. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  32206. /**
  32207. * Default configuration related to image processing available in the standard Material.
  32208. */
  32209. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32210. /**
  32211. * Gets the image processing configuration used either in this material.
  32212. */
  32213. /**
  32214. * Sets the Default image processing configuration used either in the this material.
  32215. *
  32216. * If sets to null, the scene one is in use.
  32217. */
  32218. imageProcessingConfiguration: ImageProcessingConfiguration;
  32219. /**
  32220. * Attaches a new image processing configuration to the Standard Material.
  32221. * @param configuration
  32222. */
  32223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32224. /** @hidden */
  32225. protected _reset(): void;
  32226. /** @hidden */
  32227. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  32228. /**
  32229. * Instantiates a particle system.
  32230. * 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.
  32231. * @param name The name of the particle system
  32232. */
  32233. constructor(name: string);
  32234. /**
  32235. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  32236. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32237. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32238. * @returns the emitter
  32239. */
  32240. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  32241. /**
  32242. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  32243. * @param radius The radius of the hemisphere to emit from
  32244. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32245. * @returns the emitter
  32246. */
  32247. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  32248. /**
  32249. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  32250. * @param radius The radius of the sphere to emit from
  32251. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32252. * @returns the emitter
  32253. */
  32254. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  32255. /**
  32256. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  32257. * @param radius The radius of the sphere to emit from
  32258. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  32259. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  32260. * @returns the emitter
  32261. */
  32262. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  32263. /**
  32264. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  32265. * @param radius The radius of the emission cylinder
  32266. * @param height The height of the emission cylinder
  32267. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  32268. * @param directionRandomizer How much to randomize the particle direction [0-1]
  32269. * @returns the emitter
  32270. */
  32271. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  32272. /**
  32273. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  32274. * @param radius The radius of the cylinder to emit from
  32275. * @param height The height of the emission cylinder
  32276. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  32277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  32278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  32279. * @returns the emitter
  32280. */
  32281. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  32282. /**
  32283. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  32284. * @param radius The radius of the cone to emit from
  32285. * @param angle The base angle of the cone
  32286. * @returns the emitter
  32287. */
  32288. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  32289. /**
  32290. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  32291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32293. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32294. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32295. * @returns the emitter
  32296. */
  32297. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  32298. }
  32299. }
  32300. declare module BABYLON {
  32301. /**
  32302. * This represents a GPU particle system in Babylon
  32303. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  32304. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  32305. */
  32306. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  32307. /**
  32308. * The layer mask we are rendering the particles through.
  32309. */
  32310. layerMask: number;
  32311. private _capacity;
  32312. private _activeCount;
  32313. private _currentActiveCount;
  32314. private _accumulatedCount;
  32315. private _renderEffect;
  32316. private _updateEffect;
  32317. private _buffer0;
  32318. private _buffer1;
  32319. private _spriteBuffer;
  32320. private _updateVAO;
  32321. private _renderVAO;
  32322. private _targetIndex;
  32323. private _sourceBuffer;
  32324. private _targetBuffer;
  32325. private _engine;
  32326. private _currentRenderId;
  32327. private _started;
  32328. private _stopped;
  32329. private _timeDelta;
  32330. private _randomTexture;
  32331. private _randomTexture2;
  32332. private _attributesStrideSize;
  32333. private _updateEffectOptions;
  32334. private _randomTextureSize;
  32335. private _actualFrame;
  32336. private readonly _rawTextureWidth;
  32337. /**
  32338. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  32339. */
  32340. static readonly IsSupported: boolean;
  32341. /**
  32342. * An event triggered when the system is disposed.
  32343. */
  32344. onDisposeObservable: Observable<GPUParticleSystem>;
  32345. /**
  32346. * Gets the maximum number of particles active at the same time.
  32347. * @returns The max number of active particles.
  32348. */
  32349. getCapacity(): number;
  32350. /**
  32351. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  32352. * to override the particles.
  32353. */
  32354. forceDepthWrite: boolean;
  32355. /**
  32356. * Gets or set the number of active particles
  32357. */
  32358. activeParticleCount: number;
  32359. private _preWarmDone;
  32360. /**
  32361. * Is this system ready to be used/rendered
  32362. * @return true if the system is ready
  32363. */
  32364. isReady(): boolean;
  32365. /**
  32366. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32367. * @returns True if it has been started, otherwise false.
  32368. */
  32369. isStarted(): boolean;
  32370. /**
  32371. * Starts the particle system and begins to emit
  32372. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32373. */
  32374. start(delay?: number): void;
  32375. /**
  32376. * Stops the particle system.
  32377. */
  32378. stop(): void;
  32379. /**
  32380. * Remove all active particles
  32381. */
  32382. reset(): void;
  32383. /**
  32384. * Returns the string "GPUParticleSystem"
  32385. * @returns a string containing the class name
  32386. */
  32387. getClassName(): string;
  32388. private _colorGradientsTexture;
  32389. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  32390. /**
  32391. * Adds a new color gradient
  32392. * @param gradient defines the gradient to use (between 0 and 1)
  32393. * @param color1 defines the color to affect to the specified gradient
  32394. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32395. * @returns the current particle system
  32396. */
  32397. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  32398. /**
  32399. * Remove a specific color gradient
  32400. * @param gradient defines the gradient to remove
  32401. * @returns the current particle system
  32402. */
  32403. removeColorGradient(gradient: number): GPUParticleSystem;
  32404. private _angularSpeedGradientsTexture;
  32405. private _sizeGradientsTexture;
  32406. private _velocityGradientsTexture;
  32407. private _limitVelocityGradientsTexture;
  32408. private _dragGradientsTexture;
  32409. private _addFactorGradient;
  32410. /**
  32411. * Adds a new size gradient
  32412. * @param gradient defines the gradient to use (between 0 and 1)
  32413. * @param factor defines the size factor to affect to the specified gradient
  32414. * @returns the current particle system
  32415. */
  32416. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  32417. /**
  32418. * Remove a specific size gradient
  32419. * @param gradient defines the gradient to remove
  32420. * @returns the current particle system
  32421. */
  32422. removeSizeGradient(gradient: number): GPUParticleSystem;
  32423. /**
  32424. * Adds a new angular speed gradient
  32425. * @param gradient defines the gradient to use (between 0 and 1)
  32426. * @param factor defines the angular speed to affect to the specified gradient
  32427. * @returns the current particle system
  32428. */
  32429. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  32430. /**
  32431. * Remove a specific angular speed gradient
  32432. * @param gradient defines the gradient to remove
  32433. * @returns the current particle system
  32434. */
  32435. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  32436. /**
  32437. * Adds a new velocity gradient
  32438. * @param gradient defines the gradient to use (between 0 and 1)
  32439. * @param factor defines the velocity to affect to the specified gradient
  32440. * @returns the current particle system
  32441. */
  32442. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  32443. /**
  32444. * Remove a specific velocity gradient
  32445. * @param gradient defines the gradient to remove
  32446. * @returns the current particle system
  32447. */
  32448. removeVelocityGradient(gradient: number): GPUParticleSystem;
  32449. /**
  32450. * Adds a new limit velocity gradient
  32451. * @param gradient defines the gradient to use (between 0 and 1)
  32452. * @param factor defines the limit velocity value to affect to the specified gradient
  32453. * @returns the current particle system
  32454. */
  32455. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  32456. /**
  32457. * Remove a specific limit velocity gradient
  32458. * @param gradient defines the gradient to remove
  32459. * @returns the current particle system
  32460. */
  32461. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  32462. /**
  32463. * Adds a new drag gradient
  32464. * @param gradient defines the gradient to use (between 0 and 1)
  32465. * @param factor defines the drag value to affect to the specified gradient
  32466. * @returns the current particle system
  32467. */
  32468. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  32469. /**
  32470. * Remove a specific drag gradient
  32471. * @param gradient defines the gradient to remove
  32472. * @returns the current particle system
  32473. */
  32474. removeDragGradient(gradient: number): GPUParticleSystem;
  32475. /**
  32476. * Not supported by GPUParticleSystem
  32477. * @param gradient defines the gradient to use (between 0 and 1)
  32478. * @param factor defines the emit rate value to affect to the specified gradient
  32479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32480. * @returns the current particle system
  32481. */
  32482. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32483. /**
  32484. * Not supported by GPUParticleSystem
  32485. * @param gradient defines the gradient to remove
  32486. * @returns the current particle system
  32487. */
  32488. removeEmitRateGradient(gradient: number): IParticleSystem;
  32489. /**
  32490. * Not supported by GPUParticleSystem
  32491. * @param gradient defines the gradient to use (between 0 and 1)
  32492. * @param factor defines the start size value to affect to the specified gradient
  32493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32494. * @returns the current particle system
  32495. */
  32496. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32497. /**
  32498. * Not supported by GPUParticleSystem
  32499. * @param gradient defines the gradient to remove
  32500. * @returns the current particle system
  32501. */
  32502. removeStartSizeGradient(gradient: number): IParticleSystem;
  32503. /**
  32504. * Not supported by GPUParticleSystem
  32505. * @param gradient defines the gradient to use (between 0 and 1)
  32506. * @param min defines the color remap minimal range
  32507. * @param max defines the color remap maximal range
  32508. * @returns the current particle system
  32509. */
  32510. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32511. /**
  32512. * Not supported by GPUParticleSystem
  32513. * @param gradient defines the gradient to remove
  32514. * @returns the current particle system
  32515. */
  32516. removeColorRemapGradient(gradient: number): IParticleSystem;
  32517. /**
  32518. * Not supported by GPUParticleSystem
  32519. * @param gradient defines the gradient to use (between 0 and 1)
  32520. * @param min defines the alpha remap minimal range
  32521. * @param max defines the alpha remap maximal range
  32522. * @returns the current particle system
  32523. */
  32524. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32525. /**
  32526. * Not supported by GPUParticleSystem
  32527. * @param gradient defines the gradient to remove
  32528. * @returns the current particle system
  32529. */
  32530. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32531. /**
  32532. * Not supported by GPUParticleSystem
  32533. * @param gradient defines the gradient to use (between 0 and 1)
  32534. * @param color defines the color to affect to the specified gradient
  32535. * @returns the current particle system
  32536. */
  32537. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32538. /**
  32539. * Not supported by GPUParticleSystem
  32540. * @param gradient defines the gradient to remove
  32541. * @returns the current particle system
  32542. */
  32543. removeRampGradient(gradient: number): IParticleSystem;
  32544. /**
  32545. * Not supported by GPUParticleSystem
  32546. * @returns the list of ramp gradients
  32547. */
  32548. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32549. /**
  32550. * Not supported by GPUParticleSystem
  32551. * Gets or sets a boolean indicating that ramp gradients must be used
  32552. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32553. */
  32554. useRampGradients: boolean;
  32555. /**
  32556. * Not supported by GPUParticleSystem
  32557. * @param gradient defines the gradient to use (between 0 and 1)
  32558. * @param factor defines the life time factor to affect to the specified gradient
  32559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32560. * @returns the current particle system
  32561. */
  32562. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32563. /**
  32564. * Not supported by GPUParticleSystem
  32565. * @param gradient defines the gradient to remove
  32566. * @returns the current particle system
  32567. */
  32568. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32569. /**
  32570. * Instantiates a GPU particle system.
  32571. * 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.
  32572. * @param name The name of the particle system
  32573. * @param options The options used to create the system
  32574. * @param scene The scene the particle system belongs to
  32575. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32576. */
  32577. constructor(name: string, options: Partial<{
  32578. capacity: number;
  32579. randomTextureSize: number;
  32580. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  32581. protected _reset(): void;
  32582. private _createUpdateVAO;
  32583. private _createRenderVAO;
  32584. private _initialize;
  32585. /** @hidden */
  32586. _recreateUpdateEffect(): void;
  32587. /** @hidden */
  32588. _recreateRenderEffect(): void;
  32589. /**
  32590. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32591. * @param preWarm defines if we are in the pre-warmimg phase
  32592. */
  32593. animate(preWarm?: boolean): void;
  32594. private _createFactorGradientTexture;
  32595. private _createSizeGradientTexture;
  32596. private _createAngularSpeedGradientTexture;
  32597. private _createVelocityGradientTexture;
  32598. private _createLimitVelocityGradientTexture;
  32599. private _createDragGradientTexture;
  32600. private _createColorGradientTexture;
  32601. /**
  32602. * Renders the particle system in its current state
  32603. * @param preWarm defines if the system should only update the particles but not render them
  32604. * @returns the current number of particles
  32605. */
  32606. render(preWarm?: boolean): number;
  32607. /**
  32608. * Rebuilds the particle system
  32609. */
  32610. rebuild(): void;
  32611. private _releaseBuffers;
  32612. private _releaseVAOs;
  32613. /**
  32614. * Disposes the particle system and free the associated resources
  32615. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32616. */
  32617. dispose(disposeTexture?: boolean): void;
  32618. /**
  32619. * Clones the particle system.
  32620. * @param name The name of the cloned object
  32621. * @param newEmitter The new emitter to use
  32622. * @returns the cloned particle system
  32623. */
  32624. clone(name: string, newEmitter: any): GPUParticleSystem;
  32625. /**
  32626. * Serializes the particle system to a JSON object.
  32627. * @returns the JSON object
  32628. */
  32629. serialize(): any;
  32630. /**
  32631. * Parses a JSON object to create a GPU particle system.
  32632. * @param parsedParticleSystem The JSON object to parse
  32633. * @param scene The scene to create the particle system in
  32634. * @param rootUrl The root url to use to load external dependencies like texture
  32635. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32636. * @returns the parsed GPU particle system
  32637. */
  32638. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  32639. }
  32640. }
  32641. declare module BABYLON {
  32642. /**
  32643. * Interface representing a particle system in Babylon.js.
  32644. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  32645. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  32646. */
  32647. interface IParticleSystem {
  32648. /**
  32649. * List of animations used by the particle system.
  32650. */
  32651. animations: Animation[];
  32652. /**
  32653. * The id of the Particle system.
  32654. */
  32655. id: string;
  32656. /**
  32657. * The name of the Particle system.
  32658. */
  32659. name: string;
  32660. /**
  32661. * The emitter represents the Mesh or position we are attaching the particle system to.
  32662. */
  32663. emitter: Nullable<AbstractMesh | Vector3>;
  32664. /**
  32665. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32666. */
  32667. isBillboardBased: boolean;
  32668. /**
  32669. * The rendering group used by the Particle system to chose when to render.
  32670. */
  32671. renderingGroupId: number;
  32672. /**
  32673. * The layer mask we are rendering the particles through.
  32674. */
  32675. layerMask: number;
  32676. /**
  32677. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  32678. */
  32679. updateSpeed: number;
  32680. /**
  32681. * The amount of time the particle system is running (depends of the overall update speed).
  32682. */
  32683. targetStopDuration: number;
  32684. /**
  32685. * The texture used to render each particle. (this can be a spritesheet)
  32686. */
  32687. particleTexture: Nullable<Texture>;
  32688. /**
  32689. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  32690. */
  32691. blendMode: number;
  32692. /**
  32693. * Minimum life time of emitting particles.
  32694. */
  32695. minLifeTime: number;
  32696. /**
  32697. * Maximum life time of emitting particles.
  32698. */
  32699. maxLifeTime: number;
  32700. /**
  32701. * Minimum Size of emitting particles.
  32702. */
  32703. minSize: number;
  32704. /**
  32705. * Maximum Size of emitting particles.
  32706. */
  32707. maxSize: number;
  32708. /**
  32709. * Minimum scale of emitting particles on X axis.
  32710. */
  32711. minScaleX: number;
  32712. /**
  32713. * Maximum scale of emitting particles on X axis.
  32714. */
  32715. maxScaleX: number;
  32716. /**
  32717. * Minimum scale of emitting particles on Y axis.
  32718. */
  32719. minScaleY: number;
  32720. /**
  32721. * Maximum scale of emitting particles on Y axis.
  32722. */
  32723. maxScaleY: number;
  32724. /**
  32725. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32726. */
  32727. color1: Color4;
  32728. /**
  32729. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32730. */
  32731. color2: Color4;
  32732. /**
  32733. * Color the particle will have at the end of its lifetime.
  32734. */
  32735. colorDead: Color4;
  32736. /**
  32737. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  32738. */
  32739. emitRate: number;
  32740. /**
  32741. * You can use gravity if you want to give an orientation to your particles.
  32742. */
  32743. gravity: Vector3;
  32744. /**
  32745. * Minimum power of emitting particles.
  32746. */
  32747. minEmitPower: number;
  32748. /**
  32749. * Maximum power of emitting particles.
  32750. */
  32751. maxEmitPower: number;
  32752. /**
  32753. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  32754. */
  32755. minAngularSpeed: number;
  32756. /**
  32757. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  32758. */
  32759. maxAngularSpeed: number;
  32760. /**
  32761. * Gets or sets the minimal initial rotation in radians.
  32762. */
  32763. minInitialRotation: number;
  32764. /**
  32765. * Gets or sets the maximal initial rotation in radians.
  32766. */
  32767. maxInitialRotation: number;
  32768. /**
  32769. * The particle emitter type defines the emitter used by the particle system.
  32770. * It can be for example box, sphere, or cone...
  32771. */
  32772. particleEmitterType: Nullable<IParticleEmitterType>;
  32773. /**
  32774. * Defines the delay in milliseconds before starting the system (0 by default)
  32775. */
  32776. startDelay: number;
  32777. /**
  32778. * 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
  32779. */
  32780. preWarmCycles: number;
  32781. /**
  32782. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  32783. */
  32784. preWarmStepOffset: number;
  32785. /**
  32786. * 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)
  32787. */
  32788. spriteCellChangeSpeed: number;
  32789. /**
  32790. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32791. */
  32792. startSpriteCellID: number;
  32793. /**
  32794. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32795. */
  32796. endSpriteCellID: number;
  32797. /**
  32798. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32799. */
  32800. spriteCellWidth: number;
  32801. /**
  32802. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32803. */
  32804. spriteCellHeight: number;
  32805. /**
  32806. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32807. */
  32808. spriteRandomStartCell: boolean;
  32809. /**
  32810. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  32811. */
  32812. isAnimationSheetEnabled: boolean;
  32813. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32814. translationPivot: Vector2;
  32815. /**
  32816. * Gets or sets a texture used to add random noise to particle positions
  32817. */
  32818. noiseTexture: Nullable<BaseTexture>;
  32819. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32820. noiseStrength: Vector3;
  32821. /**
  32822. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32823. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32824. */
  32825. billboardMode: number;
  32826. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32827. limitVelocityDamping: number;
  32828. /**
  32829. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32830. */
  32831. beginAnimationOnStart: boolean;
  32832. /**
  32833. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32834. */
  32835. beginAnimationFrom: number;
  32836. /**
  32837. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32838. */
  32839. beginAnimationTo: number;
  32840. /**
  32841. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32842. */
  32843. beginAnimationLoop: boolean;
  32844. /**
  32845. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  32846. */
  32847. disposeOnStop: boolean;
  32848. /**
  32849. * Gets the maximum number of particles active at the same time.
  32850. * @returns The max number of active particles.
  32851. */
  32852. getCapacity(): number;
  32853. /**
  32854. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32855. * @returns True if it has been started, otherwise false.
  32856. */
  32857. isStarted(): boolean;
  32858. /**
  32859. * Animates the particle system for this frame.
  32860. */
  32861. animate(): void;
  32862. /**
  32863. * Renders the particle system in its current state.
  32864. * @returns the current number of particles
  32865. */
  32866. render(): number;
  32867. /**
  32868. * Dispose the particle system and frees its associated resources.
  32869. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32870. */
  32871. dispose(disposeTexture?: boolean): void;
  32872. /**
  32873. * Clones the particle system.
  32874. * @param name The name of the cloned object
  32875. * @param newEmitter The new emitter to use
  32876. * @returns the cloned particle system
  32877. */
  32878. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  32879. /**
  32880. * Serializes the particle system to a JSON object.
  32881. * @returns the JSON object
  32882. */
  32883. serialize(): any;
  32884. /**
  32885. * Rebuild the particle system
  32886. */
  32887. rebuild(): void;
  32888. /**
  32889. * Starts the particle system and begins to emit
  32890. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  32891. */
  32892. start(delay?: number): void;
  32893. /**
  32894. * Stops the particle system.
  32895. */
  32896. stop(): void;
  32897. /**
  32898. * Remove all active particles
  32899. */
  32900. reset(): void;
  32901. /**
  32902. * Is this system ready to be used/rendered
  32903. * @return true if the system is ready
  32904. */
  32905. isReady(): boolean;
  32906. /**
  32907. * Adds a new color gradient
  32908. * @param gradient defines the gradient to use (between 0 and 1)
  32909. * @param color1 defines the color to affect to the specified gradient
  32910. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32911. * @returns the current particle system
  32912. */
  32913. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32914. /**
  32915. * Remove a specific color gradient
  32916. * @param gradient defines the gradient to remove
  32917. * @returns the current particle system
  32918. */
  32919. removeColorGradient(gradient: number): IParticleSystem;
  32920. /**
  32921. * Adds a new size gradient
  32922. * @param gradient defines the gradient to use (between 0 and 1)
  32923. * @param factor defines the size factor to affect to the specified gradient
  32924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32925. * @returns the current particle system
  32926. */
  32927. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32928. /**
  32929. * Remove a specific size gradient
  32930. * @param gradient defines the gradient to remove
  32931. * @returns the current particle system
  32932. */
  32933. removeSizeGradient(gradient: number): IParticleSystem;
  32934. /**
  32935. * Gets the current list of color gradients.
  32936. * You must use addColorGradient and removeColorGradient to udpate this list
  32937. * @returns the list of color gradients
  32938. */
  32939. getColorGradients(): Nullable<Array<ColorGradient>>;
  32940. /**
  32941. * Gets the current list of size gradients.
  32942. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32943. * @returns the list of size gradients
  32944. */
  32945. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32946. /**
  32947. * Gets the current list of angular speed gradients.
  32948. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32949. * @returns the list of angular speed gradients
  32950. */
  32951. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32952. /**
  32953. * Adds a new angular speed gradient
  32954. * @param gradient defines the gradient to use (between 0 and 1)
  32955. * @param factor defines the angular speed to affect to the specified gradient
  32956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32957. * @returns the current particle system
  32958. */
  32959. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32960. /**
  32961. * Remove a specific angular speed gradient
  32962. * @param gradient defines the gradient to remove
  32963. * @returns the current particle system
  32964. */
  32965. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32966. /**
  32967. * Gets the current list of velocity gradients.
  32968. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32969. * @returns the list of velocity gradients
  32970. */
  32971. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32972. /**
  32973. * Adds a new velocity gradient
  32974. * @param gradient defines the gradient to use (between 0 and 1)
  32975. * @param factor defines the velocity to affect to the specified gradient
  32976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32977. * @returns the current particle system
  32978. */
  32979. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32980. /**
  32981. * Remove a specific velocity gradient
  32982. * @param gradient defines the gradient to remove
  32983. * @returns the current particle system
  32984. */
  32985. removeVelocityGradient(gradient: number): IParticleSystem;
  32986. /**
  32987. * Gets the current list of limit velocity gradients.
  32988. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32989. * @returns the list of limit velocity gradients
  32990. */
  32991. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32992. /**
  32993. * Adds a new limit velocity gradient
  32994. * @param gradient defines the gradient to use (between 0 and 1)
  32995. * @param factor defines the limit velocity to affect to the specified gradient
  32996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32997. * @returns the current particle system
  32998. */
  32999. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33000. /**
  33001. * Remove a specific limit velocity gradient
  33002. * @param gradient defines the gradient to remove
  33003. * @returns the current particle system
  33004. */
  33005. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33006. /**
  33007. * Adds a new drag gradient
  33008. * @param gradient defines the gradient to use (between 0 and 1)
  33009. * @param factor defines the drag to affect to the specified gradient
  33010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33011. * @returns the current particle system
  33012. */
  33013. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33014. /**
  33015. * Remove a specific drag gradient
  33016. * @param gradient defines the gradient to remove
  33017. * @returns the current particle system
  33018. */
  33019. removeDragGradient(gradient: number): IParticleSystem;
  33020. /**
  33021. * Gets the current list of drag gradients.
  33022. * You must use addDragGradient and removeDragGradient to udpate this list
  33023. * @returns the list of drag gradients
  33024. */
  33025. getDragGradients(): Nullable<Array<FactorGradient>>;
  33026. /**
  33027. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33028. * @param gradient defines the gradient to use (between 0 and 1)
  33029. * @param factor defines the emit rate to affect to the specified gradient
  33030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33031. * @returns the current particle system
  33032. */
  33033. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33034. /**
  33035. * Remove a specific emit rate gradient
  33036. * @param gradient defines the gradient to remove
  33037. * @returns the current particle system
  33038. */
  33039. removeEmitRateGradient(gradient: number): IParticleSystem;
  33040. /**
  33041. * Gets the current list of emit rate gradients.
  33042. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  33043. * @returns the list of emit rate gradients
  33044. */
  33045. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  33046. /**
  33047. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33048. * @param gradient defines the gradient to use (between 0 and 1)
  33049. * @param factor defines the start size to affect to the specified gradient
  33050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33051. * @returns the current particle system
  33052. */
  33053. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33054. /**
  33055. * Remove a specific start size gradient
  33056. * @param gradient defines the gradient to remove
  33057. * @returns the current particle system
  33058. */
  33059. removeStartSizeGradient(gradient: number): IParticleSystem;
  33060. /**
  33061. * Gets the current list of start size gradients.
  33062. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  33063. * @returns the list of start size gradients
  33064. */
  33065. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  33066. /**
  33067. * Adds a new life time gradient
  33068. * @param gradient defines the gradient to use (between 0 and 1)
  33069. * @param factor defines the life time factor to affect to the specified gradient
  33070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33071. * @returns the current particle system
  33072. */
  33073. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33074. /**
  33075. * Remove a specific life time gradient
  33076. * @param gradient defines the gradient to remove
  33077. * @returns the current particle system
  33078. */
  33079. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33080. /**
  33081. * Gets the current list of life time gradients.
  33082. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  33083. * @returns the list of life time gradients
  33084. */
  33085. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  33086. /**
  33087. * Gets the current list of color gradients.
  33088. * You must use addColorGradient and removeColorGradient to udpate this list
  33089. * @returns the list of color gradients
  33090. */
  33091. getColorGradients(): Nullable<Array<ColorGradient>>;
  33092. /**
  33093. * Adds a new ramp gradient used to remap particle colors
  33094. * @param gradient defines the gradient to use (between 0 and 1)
  33095. * @param color defines the color to affect to the specified gradient
  33096. * @returns the current particle system
  33097. */
  33098. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  33099. /**
  33100. * Gets the current list of ramp gradients.
  33101. * You must use addRampGradient and removeRampGradient to udpate this list
  33102. * @returns the list of ramp gradients
  33103. */
  33104. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33105. /** Gets or sets a boolean indicating that ramp gradients must be used
  33106. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  33107. */
  33108. useRampGradients: boolean;
  33109. /**
  33110. * Adds a new color remap gradient
  33111. * @param gradient defines the gradient to use (between 0 and 1)
  33112. * @param min defines the color remap minimal range
  33113. * @param max defines the color remap maximal range
  33114. * @returns the current particle system
  33115. */
  33116. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33117. /**
  33118. * Gets the current list of color remap gradients.
  33119. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  33120. * @returns the list of color remap gradients
  33121. */
  33122. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  33123. /**
  33124. * Adds a new alpha remap gradient
  33125. * @param gradient defines the gradient to use (between 0 and 1)
  33126. * @param min defines the alpha remap minimal range
  33127. * @param max defines the alpha remap maximal range
  33128. * @returns the current particle system
  33129. */
  33130. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33131. /**
  33132. * Gets the current list of alpha remap gradients.
  33133. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  33134. * @returns the list of alpha remap gradients
  33135. */
  33136. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  33137. /**
  33138. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  33139. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  33140. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  33141. * @returns the emitter
  33142. */
  33143. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  33144. /**
  33145. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  33146. * @param radius The radius of the hemisphere to emit from
  33147. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  33148. * @returns the emitter
  33149. */
  33150. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  33151. /**
  33152. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  33153. * @param radius The radius of the sphere to emit from
  33154. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  33155. * @returns the emitter
  33156. */
  33157. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  33158. /**
  33159. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  33160. * @param radius The radius of the sphere to emit from
  33161. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  33162. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  33163. * @returns the emitter
  33164. */
  33165. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  33166. /**
  33167. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  33168. * @param radius The radius of the emission cylinder
  33169. * @param height The height of the emission cylinder
  33170. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  33171. * @param directionRandomizer How much to randomize the particle direction [0-1]
  33172. * @returns the emitter
  33173. */
  33174. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  33175. /**
  33176. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  33177. * @param radius The radius of the cylinder to emit from
  33178. * @param height The height of the emission cylinder
  33179. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  33180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  33181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  33182. * @returns the emitter
  33183. */
  33184. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  33185. /**
  33186. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  33187. * @param radius The radius of the cone to emit from
  33188. * @param angle The base angle of the cone
  33189. * @returns the emitter
  33190. */
  33191. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  33192. /**
  33193. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  33194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  33195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  33196. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  33197. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  33198. * @returns the emitter
  33199. */
  33200. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  33201. /**
  33202. * Get hosting scene
  33203. * @returns the scene
  33204. */
  33205. getScene(): Scene;
  33206. }
  33207. }
  33208. declare module BABYLON {
  33209. /**
  33210. * A particle represents one of the element emitted by a particle system.
  33211. * This is mainly define by its coordinates, direction, velocity and age.
  33212. */
  33213. class Particle {
  33214. /**
  33215. * The particle system the particle belongs to.
  33216. */
  33217. particleSystem: ParticleSystem;
  33218. private static _Count;
  33219. /**
  33220. * Unique ID of the particle
  33221. */
  33222. id: number;
  33223. /**
  33224. * The world position of the particle in the scene.
  33225. */
  33226. position: Vector3;
  33227. /**
  33228. * The world direction of the particle in the scene.
  33229. */
  33230. direction: Vector3;
  33231. /**
  33232. * The color of the particle.
  33233. */
  33234. color: Color4;
  33235. /**
  33236. * The color change of the particle per step.
  33237. */
  33238. colorStep: Color4;
  33239. /**
  33240. * Defines how long will the life of the particle be.
  33241. */
  33242. lifeTime: number;
  33243. /**
  33244. * The current age of the particle.
  33245. */
  33246. age: number;
  33247. /**
  33248. * The current size of the particle.
  33249. */
  33250. size: number;
  33251. /**
  33252. * The current scale of the particle.
  33253. */
  33254. scale: Vector2;
  33255. /**
  33256. * The current angle of the particle.
  33257. */
  33258. angle: number;
  33259. /**
  33260. * Defines how fast is the angle changing.
  33261. */
  33262. angularSpeed: number;
  33263. /**
  33264. * Defines the cell index used by the particle to be rendered from a sprite.
  33265. */
  33266. cellIndex: number;
  33267. /**
  33268. * The information required to support color remapping
  33269. */
  33270. remapData: Vector4;
  33271. /** @hidden */
  33272. _randomCellOffset?: number;
  33273. /** @hidden */
  33274. _initialDirection: Nullable<Vector3>;
  33275. /** @hidden */
  33276. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  33277. /** @hidden */
  33278. _initialStartSpriteCellID: number;
  33279. /** @hidden */
  33280. _initialEndSpriteCellID: number;
  33281. /** @hidden */
  33282. _currentColorGradient: Nullable<ColorGradient>;
  33283. /** @hidden */
  33284. _currentColor1: Color4;
  33285. /** @hidden */
  33286. _currentColor2: Color4;
  33287. /** @hidden */
  33288. _currentSizeGradient: Nullable<FactorGradient>;
  33289. /** @hidden */
  33290. _currentSize1: number;
  33291. /** @hidden */
  33292. _currentSize2: number;
  33293. /** @hidden */
  33294. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  33295. /** @hidden */
  33296. _currentAngularSpeed1: number;
  33297. /** @hidden */
  33298. _currentAngularSpeed2: number;
  33299. /** @hidden */
  33300. _currentVelocityGradient: Nullable<FactorGradient>;
  33301. /** @hidden */
  33302. _currentVelocity1: number;
  33303. /** @hidden */
  33304. _currentVelocity2: number;
  33305. /** @hidden */
  33306. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  33307. /** @hidden */
  33308. _currentLimitVelocity1: number;
  33309. /** @hidden */
  33310. _currentLimitVelocity2: number;
  33311. /** @hidden */
  33312. _currentDragGradient: Nullable<FactorGradient>;
  33313. /** @hidden */
  33314. _currentDrag1: number;
  33315. /** @hidden */
  33316. _currentDrag2: number;
  33317. /** @hidden */
  33318. _randomNoiseCoordinates1: Vector3;
  33319. /** @hidden */
  33320. _randomNoiseCoordinates2: Vector3;
  33321. /**
  33322. * Creates a new instance Particle
  33323. * @param particleSystem the particle system the particle belongs to
  33324. */
  33325. constructor(
  33326. /**
  33327. * The particle system the particle belongs to.
  33328. */
  33329. particleSystem: ParticleSystem);
  33330. private updateCellInfoFromSystem;
  33331. /**
  33332. * Defines how the sprite cell index is updated for the particle
  33333. */
  33334. updateCellIndex(): void;
  33335. /** @hidden */
  33336. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  33337. /** @hidden */
  33338. _inheritParticleInfoToSubEmitters(): void;
  33339. /** @hidden */
  33340. _reset(): void;
  33341. /**
  33342. * Copy the properties of particle to another one.
  33343. * @param other the particle to copy the information to.
  33344. */
  33345. copyTo(other: Particle): void;
  33346. }
  33347. }
  33348. declare module BABYLON {
  33349. /**
  33350. * This class is made for on one-liner static method to help creating particle system set.
  33351. */
  33352. class ParticleHelper {
  33353. /**
  33354. * Gets or sets base Assets URL
  33355. */
  33356. static BaseAssetsUrl: string;
  33357. /**
  33358. * Create a default particle system that you can tweak
  33359. * @param emitter defines the emitter to use
  33360. * @param capacity defines the system capacity (default is 500 particles)
  33361. * @param scene defines the hosting scene
  33362. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  33363. * @returns the new Particle system
  33364. */
  33365. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  33366. /**
  33367. * This is the main static method (one-liner) of this helper to create different particle systems
  33368. * @param type This string represents the type to the particle system to create
  33369. * @param scene The scene where the particle system should live
  33370. * @param gpu If the system will use gpu
  33371. * @returns the ParticleSystemSet created
  33372. */
  33373. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  33374. /**
  33375. * Static function used to export a particle system to a ParticleSystemSet variable.
  33376. * Please note that the emitter shape is not exported
  33377. * @param systems defines the particle systems to export
  33378. * @returns the created particle system set
  33379. */
  33380. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  33381. }
  33382. }
  33383. declare module BABYLON {
  33384. /**
  33385. * This represents a particle system in Babylon.
  33386. * 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.
  33387. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  33388. * @example https://doc.babylonjs.com/babylon101/particles
  33389. */
  33390. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  33391. /**
  33392. * Billboard mode will only apply to Y axis
  33393. */
  33394. static readonly BILLBOARDMODE_Y: number;
  33395. /**
  33396. * Billboard mode will apply to all axes
  33397. */
  33398. static readonly BILLBOARDMODE_ALL: number;
  33399. /**
  33400. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  33401. */
  33402. static readonly BILLBOARDMODE_STRETCHED: number;
  33403. /**
  33404. * This function can be defined to provide custom update for active particles.
  33405. * This function will be called instead of regular update (age, position, color, etc.).
  33406. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  33407. */
  33408. updateFunction: (particles: Particle[]) => void;
  33409. private _emitterWorldMatrix;
  33410. /**
  33411. * This function can be defined to specify initial direction for every new particle.
  33412. * It by default use the emitterType defined function
  33413. */
  33414. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  33415. /**
  33416. * This function can be defined to specify initial position for every new particle.
  33417. * It by default use the emitterType defined function
  33418. */
  33419. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  33420. /**
  33421. * @hidden
  33422. */
  33423. _inheritedVelocityOffset: Vector3;
  33424. /**
  33425. * An event triggered when the system is disposed
  33426. */
  33427. onDisposeObservable: Observable<ParticleSystem>;
  33428. private _onDisposeObserver;
  33429. /**
  33430. * Sets a callback that will be triggered when the system is disposed
  33431. */
  33432. onDispose: () => void;
  33433. private _particles;
  33434. private _epsilon;
  33435. private _capacity;
  33436. private _stockParticles;
  33437. private _newPartsExcess;
  33438. private _vertexData;
  33439. private _vertexBuffer;
  33440. private _vertexBuffers;
  33441. private _spriteBuffer;
  33442. private _indexBuffer;
  33443. private _effect;
  33444. private _customEffect;
  33445. private _cachedDefines;
  33446. private _scaledColorStep;
  33447. private _colorDiff;
  33448. private _scaledDirection;
  33449. private _scaledGravity;
  33450. private _currentRenderId;
  33451. private _alive;
  33452. private _useInstancing;
  33453. private _started;
  33454. private _stopped;
  33455. private _actualFrame;
  33456. private _scaledUpdateSpeed;
  33457. private _vertexBufferSize;
  33458. /** @hidden */
  33459. _currentEmitRateGradient: Nullable<FactorGradient>;
  33460. /** @hidden */
  33461. _currentEmitRate1: number;
  33462. /** @hidden */
  33463. _currentEmitRate2: number;
  33464. /** @hidden */
  33465. _currentStartSizeGradient: Nullable<FactorGradient>;
  33466. /** @hidden */
  33467. _currentStartSize1: number;
  33468. /** @hidden */
  33469. _currentStartSize2: number;
  33470. private readonly _rawTextureWidth;
  33471. private _rampGradientsTexture;
  33472. private _useRampGradients;
  33473. /** Gets or sets a boolean indicating that ramp gradients must be used
  33474. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  33475. */
  33476. useRampGradients: boolean;
  33477. /**
  33478. * 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.
  33479. * 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: [])
  33480. */
  33481. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  33482. private _subEmitters;
  33483. /**
  33484. * @hidden
  33485. * If the particle systems emitter should be disposed when the particle system is disposed
  33486. */
  33487. _disposeEmitterOnDispose: boolean;
  33488. /**
  33489. * The current active Sub-systems, this property is used by the root particle system only.
  33490. */
  33491. activeSubSystems: Array<ParticleSystem>;
  33492. private _rootParticleSystem;
  33493. /**
  33494. * Gets the current list of active particles
  33495. */
  33496. readonly particles: Particle[];
  33497. /**
  33498. * Returns the string "ParticleSystem"
  33499. * @returns a string containing the class name
  33500. */
  33501. getClassName(): string;
  33502. /**
  33503. * Instantiates a particle system.
  33504. * 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.
  33505. * @param name The name of the particle system
  33506. * @param capacity The max number of particles alive at the same time
  33507. * @param scene The scene the particle system belongs to
  33508. * @param customEffect a custom effect used to change the way particles are rendered by default
  33509. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  33510. * @param epsilon Offset used to render the particles
  33511. */
  33512. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  33513. private _addFactorGradient;
  33514. private _removeFactorGradient;
  33515. /**
  33516. * Adds a new life time gradient
  33517. * @param gradient defines the gradient to use (between 0 and 1)
  33518. * @param factor defines the life time factor to affect to the specified gradient
  33519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33520. * @returns the current particle system
  33521. */
  33522. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33523. /**
  33524. * Remove a specific life time gradient
  33525. * @param gradient defines the gradient to remove
  33526. * @returns the current particle system
  33527. */
  33528. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33529. /**
  33530. * Adds a new size gradient
  33531. * @param gradient defines the gradient to use (between 0 and 1)
  33532. * @param factor defines the size factor to affect to the specified gradient
  33533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33534. * @returns the current particle system
  33535. */
  33536. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33537. /**
  33538. * Remove a specific size gradient
  33539. * @param gradient defines the gradient to remove
  33540. * @returns the current particle system
  33541. */
  33542. removeSizeGradient(gradient: number): IParticleSystem;
  33543. /**
  33544. * Adds a new color remap gradient
  33545. * @param gradient defines the gradient to use (between 0 and 1)
  33546. * @param min defines the color remap minimal range
  33547. * @param max defines the color remap maximal range
  33548. * @returns the current particle system
  33549. */
  33550. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33551. /**
  33552. * Remove a specific color remap gradient
  33553. * @param gradient defines the gradient to remove
  33554. * @returns the current particle system
  33555. */
  33556. removeColorRemapGradient(gradient: number): IParticleSystem;
  33557. /**
  33558. * Adds a new alpha remap gradient
  33559. * @param gradient defines the gradient to use (between 0 and 1)
  33560. * @param min defines the alpha remap minimal range
  33561. * @param max defines the alpha remap maximal range
  33562. * @returns the current particle system
  33563. */
  33564. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33565. /**
  33566. * Remove a specific alpha remap gradient
  33567. * @param gradient defines the gradient to remove
  33568. * @returns the current particle system
  33569. */
  33570. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  33571. /**
  33572. * Adds a new angular speed gradient
  33573. * @param gradient defines the gradient to use (between 0 and 1)
  33574. * @param factor defines the angular speed to affect to the specified gradient
  33575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33576. * @returns the current particle system
  33577. */
  33578. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33579. /**
  33580. * Remove a specific angular speed gradient
  33581. * @param gradient defines the gradient to remove
  33582. * @returns the current particle system
  33583. */
  33584. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  33585. /**
  33586. * Adds a new velocity gradient
  33587. * @param gradient defines the gradient to use (between 0 and 1)
  33588. * @param factor defines the velocity to affect to the specified gradient
  33589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33590. * @returns the current particle system
  33591. */
  33592. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33593. /**
  33594. * Remove a specific velocity gradient
  33595. * @param gradient defines the gradient to remove
  33596. * @returns the current particle system
  33597. */
  33598. removeVelocityGradient(gradient: number): IParticleSystem;
  33599. /**
  33600. * Adds a new limit velocity gradient
  33601. * @param gradient defines the gradient to use (between 0 and 1)
  33602. * @param factor defines the limit velocity value to affect to the specified gradient
  33603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33604. * @returns the current particle system
  33605. */
  33606. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33607. /**
  33608. * Remove a specific limit velocity gradient
  33609. * @param gradient defines the gradient to remove
  33610. * @returns the current particle system
  33611. */
  33612. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33613. /**
  33614. * Adds a new drag gradient
  33615. * @param gradient defines the gradient to use (between 0 and 1)
  33616. * @param factor defines the drag value to affect to the specified gradient
  33617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33618. * @returns the current particle system
  33619. */
  33620. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33621. /**
  33622. * Remove a specific drag gradient
  33623. * @param gradient defines the gradient to remove
  33624. * @returns the current particle system
  33625. */
  33626. removeDragGradient(gradient: number): IParticleSystem;
  33627. /**
  33628. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33629. * @param gradient defines the gradient to use (between 0 and 1)
  33630. * @param factor defines the emit rate value to affect to the specified gradient
  33631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33632. * @returns the current particle system
  33633. */
  33634. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33635. /**
  33636. * Remove a specific emit rate gradient
  33637. * @param gradient defines the gradient to remove
  33638. * @returns the current particle system
  33639. */
  33640. removeEmitRateGradient(gradient: number): IParticleSystem;
  33641. /**
  33642. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33643. * @param gradient defines the gradient to use (between 0 and 1)
  33644. * @param factor defines the start size value to affect to the specified gradient
  33645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33646. * @returns the current particle system
  33647. */
  33648. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33649. /**
  33650. * Remove a specific start size gradient
  33651. * @param gradient defines the gradient to remove
  33652. * @returns the current particle system
  33653. */
  33654. removeStartSizeGradient(gradient: number): IParticleSystem;
  33655. private _createRampGradientTexture;
  33656. /**
  33657. * Gets the current list of ramp gradients.
  33658. * You must use addRampGradient and removeRampGradient to udpate this list
  33659. * @returns the list of ramp gradients
  33660. */
  33661. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33662. /**
  33663. * Adds a new ramp gradient used to remap particle colors
  33664. * @param gradient defines the gradient to use (between 0 and 1)
  33665. * @param color defines the color to affect to the specified gradient
  33666. * @returns the current particle system
  33667. */
  33668. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  33669. /**
  33670. * Remove a specific ramp gradient
  33671. * @param gradient defines the gradient to remove
  33672. * @returns the current particle system
  33673. */
  33674. removeRampGradient(gradient: number): ParticleSystem;
  33675. /**
  33676. * Adds a new color gradient
  33677. * @param gradient defines the gradient to use (between 0 and 1)
  33678. * @param color1 defines the color to affect to the specified gradient
  33679. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  33680. * @returns this particle system
  33681. */
  33682. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  33683. /**
  33684. * Remove a specific color gradient
  33685. * @param gradient defines the gradient to remove
  33686. * @returns this particle system
  33687. */
  33688. removeColorGradient(gradient: number): IParticleSystem;
  33689. private _fetchR;
  33690. protected _reset(): void;
  33691. private _resetEffect;
  33692. private _createVertexBuffers;
  33693. private _createIndexBuffer;
  33694. /**
  33695. * Gets the maximum number of particles active at the same time.
  33696. * @returns The max number of active particles.
  33697. */
  33698. getCapacity(): number;
  33699. /**
  33700. * Gets whether there are still active particles in the system.
  33701. * @returns True if it is alive, otherwise false.
  33702. */
  33703. isAlive(): boolean;
  33704. /**
  33705. * Gets if the system has been started. (Note: this will still be true after stop is called)
  33706. * @returns True if it has been started, otherwise false.
  33707. */
  33708. isStarted(): boolean;
  33709. private _prepareSubEmitterInternalArray;
  33710. /**
  33711. * Starts the particle system and begins to emit
  33712. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  33713. */
  33714. start(delay?: number): void;
  33715. /**
  33716. * Stops the particle system.
  33717. * @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.
  33718. */
  33719. stop(stopSubEmitters?: boolean): void;
  33720. /**
  33721. * Remove all active particles
  33722. */
  33723. reset(): void;
  33724. /**
  33725. * @hidden (for internal use only)
  33726. */
  33727. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  33728. /**
  33729. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  33730. * Its lifetime will start back at 0.
  33731. */
  33732. recycleParticle: (particle: Particle) => void;
  33733. private _stopSubEmitters;
  33734. private _createParticle;
  33735. private _removeFromRoot;
  33736. private _emitFromParticle;
  33737. private _update;
  33738. /** @hidden */
  33739. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  33740. /** @hidden */
  33741. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  33742. /** @hidden */
  33743. private _getEffect;
  33744. /**
  33745. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  33746. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  33747. */
  33748. animate(preWarmOnly?: boolean): void;
  33749. private _appendParticleVertices;
  33750. /**
  33751. * Rebuilds the particle system.
  33752. */
  33753. rebuild(): void;
  33754. /**
  33755. * Is this system ready to be used/rendered
  33756. * @return true if the system is ready
  33757. */
  33758. isReady(): boolean;
  33759. private _render;
  33760. /**
  33761. * Renders the particle system in its current state.
  33762. * @returns the current number of particles
  33763. */
  33764. render(): number;
  33765. /**
  33766. * Disposes the particle system and free the associated resources
  33767. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  33768. */
  33769. dispose(disposeTexture?: boolean): void;
  33770. /**
  33771. * Clones the particle system.
  33772. * @param name The name of the cloned object
  33773. * @param newEmitter The new emitter to use
  33774. * @returns the cloned particle system
  33775. */
  33776. clone(name: string, newEmitter: any): ParticleSystem;
  33777. /**
  33778. * Serializes the particle system to a JSON object.
  33779. * @returns the JSON object
  33780. */
  33781. serialize(): any;
  33782. /** @hidden */
  33783. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  33784. /** @hidden */
  33785. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  33786. /**
  33787. * Parses a JSON object to create a particle system.
  33788. * @param parsedParticleSystem The JSON object to parse
  33789. * @param scene The scene to create the particle system in
  33790. * @param rootUrl The root url to use to load external dependencies like texture
  33791. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  33792. * @returns the Parsed particle system
  33793. */
  33794. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  33795. }
  33796. }
  33797. declare module BABYLON {
  33798. interface Engine {
  33799. /**
  33800. * Create an effect to use with particle systems.
  33801. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  33802. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  33803. * @param uniformsNames defines a list of attribute names
  33804. * @param samplers defines an array of string used to represent textures
  33805. * @param defines defines the string containing the defines to use to compile the shaders
  33806. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33807. * @param onCompiled defines a function to call when the effect creation is successful
  33808. * @param onError defines a function to call when the effect creation has failed
  33809. * @returns the new Effect
  33810. */
  33811. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  33812. }
  33813. interface Mesh {
  33814. /**
  33815. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  33816. * @returns an array of IParticleSystem
  33817. */
  33818. getEmittedParticleSystems(): IParticleSystem[];
  33819. /**
  33820. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  33821. * @returns an array of IParticleSystem
  33822. */
  33823. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  33824. }
  33825. }
  33826. declare module BABYLON {
  33827. /**
  33828. * Represents a set of particle systems working together to create a specific effect
  33829. */
  33830. class ParticleSystemSet implements IDisposable {
  33831. private _emitterCreationOptions;
  33832. private _emitterNode;
  33833. /**
  33834. * Gets the particle system list
  33835. */
  33836. systems: IParticleSystem[];
  33837. /**
  33838. * Gets the emitter node used with this set
  33839. */
  33840. readonly emitterNode: Nullable<TransformNode>;
  33841. /**
  33842. * Creates a new emitter mesh as a sphere
  33843. * @param options defines the options used to create the sphere
  33844. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  33845. * @param scene defines the hosting scene
  33846. */
  33847. setEmitterAsSphere(options: {
  33848. diameter: number;
  33849. segments: number;
  33850. color: Color3;
  33851. }, renderingGroupId: number, scene: Scene): void;
  33852. /**
  33853. * Starts all particle systems of the set
  33854. * @param emitter defines an optional mesh to use as emitter for the particle systems
  33855. */
  33856. start(emitter?: AbstractMesh): void;
  33857. /**
  33858. * Release all associated resources
  33859. */
  33860. dispose(): void;
  33861. /**
  33862. * Serialize the set into a JSON compatible object
  33863. * @returns a JSON compatible representation of the set
  33864. */
  33865. serialize(): any;
  33866. /**
  33867. * Parse a new ParticleSystemSet from a serialized source
  33868. * @param data defines a JSON compatible representation of the set
  33869. * @param scene defines the hosting scene
  33870. * @param gpu defines if we want GPU particles or CPU particles
  33871. * @returns a new ParticleSystemSet
  33872. */
  33873. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  33874. }
  33875. }
  33876. declare module BABYLON {
  33877. /**
  33878. * Represents one particle of a solid particle system.
  33879. */
  33880. class SolidParticle {
  33881. /**
  33882. * particle global index
  33883. */
  33884. idx: number;
  33885. /**
  33886. * The color of the particle
  33887. */
  33888. color: Nullable<Color4>;
  33889. /**
  33890. * The world space position of the particle.
  33891. */
  33892. position: Vector3;
  33893. /**
  33894. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  33895. */
  33896. rotation: Vector3;
  33897. /**
  33898. * The world space rotation quaternion of the particle.
  33899. */
  33900. rotationQuaternion: Nullable<Quaternion>;
  33901. /**
  33902. * The scaling of the particle.
  33903. */
  33904. scaling: Vector3;
  33905. /**
  33906. * The uvs of the particle.
  33907. */
  33908. uvs: Vector4;
  33909. /**
  33910. * The current speed of the particle.
  33911. */
  33912. velocity: Vector3;
  33913. /**
  33914. * The pivot point in the particle local space.
  33915. */
  33916. pivot: Vector3;
  33917. /**
  33918. * Must the particle be translated from its pivot point in its local space ?
  33919. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  33920. * Default : false
  33921. */
  33922. translateFromPivot: boolean;
  33923. /**
  33924. * Is the particle active or not ?
  33925. */
  33926. alive: boolean;
  33927. /**
  33928. * Is the particle visible or not ?
  33929. */
  33930. isVisible: boolean;
  33931. /**
  33932. * Index of this particle in the global "positions" array (Internal use)
  33933. * @hidden
  33934. */
  33935. _pos: number;
  33936. /**
  33937. * @hidden Index of this particle in the global "indices" array (Internal use)
  33938. */
  33939. _ind: number;
  33940. /**
  33941. * @hidden ModelShape of this particle (Internal use)
  33942. */
  33943. _model: ModelShape;
  33944. /**
  33945. * ModelShape id of this particle
  33946. */
  33947. shapeId: number;
  33948. /**
  33949. * Index of the particle in its shape id (Internal use)
  33950. */
  33951. idxInShape: number;
  33952. /**
  33953. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  33954. */
  33955. _modelBoundingInfo: BoundingInfo;
  33956. /**
  33957. * @hidden Particle BoundingInfo object (Internal use)
  33958. */
  33959. _boundingInfo: BoundingInfo;
  33960. /**
  33961. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  33962. */
  33963. _sps: SolidParticleSystem;
  33964. /**
  33965. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33966. */
  33967. _stillInvisible: boolean;
  33968. /**
  33969. * @hidden Last computed particle rotation matrix
  33970. */
  33971. _rotationMatrix: number[];
  33972. /**
  33973. * Parent particle Id, if any.
  33974. * Default null.
  33975. */
  33976. parentId: Nullable<number>;
  33977. /**
  33978. * @hidden Internal global position in the SPS.
  33979. */
  33980. _globalPosition: Vector3;
  33981. /**
  33982. * Creates a Solid Particle object.
  33983. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33984. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  33985. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33986. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33987. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33988. * @param shapeId (integer) is the model shape identifier in the SPS.
  33989. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33990. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33991. */
  33992. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  33993. /**
  33994. * Legacy support, changed scale to scaling
  33995. */
  33996. /**
  33997. * Legacy support, changed scale to scaling
  33998. */
  33999. scale: Vector3;
  34000. /**
  34001. * Legacy support, changed quaternion to rotationQuaternion
  34002. */
  34003. /**
  34004. * Legacy support, changed quaternion to rotationQuaternion
  34005. */
  34006. quaternion: Nullable<Quaternion>;
  34007. /**
  34008. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34009. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34010. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34011. * @returns true if it intersects
  34012. */
  34013. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34014. /**
  34015. * get the rotation matrix of the particle
  34016. * @hidden
  34017. */
  34018. getRotationMatrix(m: Matrix): void;
  34019. }
  34020. /**
  34021. * Represents the shape of the model used by one particle of a solid particle system.
  34022. * SPS internal tool, don't use it manually.
  34023. */
  34024. class ModelShape {
  34025. /**
  34026. * The shape id
  34027. * @hidden
  34028. */
  34029. shapeID: number;
  34030. /**
  34031. * flat array of model positions (internal use)
  34032. * @hidden
  34033. */
  34034. _shape: Vector3[];
  34035. /**
  34036. * flat array of model UVs (internal use)
  34037. * @hidden
  34038. */
  34039. _shapeUV: number[];
  34040. /**
  34041. * length of the shape in the model indices array (internal use)
  34042. * @hidden
  34043. */
  34044. _indicesLength: number;
  34045. /**
  34046. * Custom position function (internal use)
  34047. * @hidden
  34048. */
  34049. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34050. /**
  34051. * Custom vertex function (internal use)
  34052. * @hidden
  34053. */
  34054. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34055. /**
  34056. * 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.
  34057. * SPS internal tool, don't use it manually.
  34058. * @hidden
  34059. */
  34060. 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>);
  34061. }
  34062. /**
  34063. * Represents a Depth Sorted Particle in the solid particle system.
  34064. */
  34065. class DepthSortedParticle {
  34066. /**
  34067. * Index of the particle in the "indices" array
  34068. */
  34069. ind: number;
  34070. /**
  34071. * Length of the particle shape in the "indices" array
  34072. */
  34073. indicesLength: number;
  34074. /**
  34075. * Squared distance from the particle to the camera
  34076. */
  34077. sqDistance: number;
  34078. }
  34079. }
  34080. declare module BABYLON {
  34081. /**
  34082. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34083. *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.
  34084. * The SPS is also a particle system. It provides some methods to manage the particles.
  34085. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34086. *
  34087. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  34088. */
  34089. class SolidParticleSystem implements IDisposable {
  34090. /**
  34091. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34092. * Example : var p = SPS.particles[i];
  34093. */
  34094. particles: SolidParticle[];
  34095. /**
  34096. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34097. */
  34098. nbParticles: number;
  34099. /**
  34100. * If the particles must ever face the camera (default false). Useful for planar particles.
  34101. */
  34102. billboard: boolean;
  34103. /**
  34104. * Recompute normals when adding a shape
  34105. */
  34106. recomputeNormals: boolean;
  34107. /**
  34108. * This a counter ofr your own usage. It's not set by any SPS functions.
  34109. */
  34110. counter: number;
  34111. /**
  34112. * The SPS name. This name is also given to the underlying mesh.
  34113. */
  34114. name: string;
  34115. /**
  34116. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34117. */
  34118. mesh: Mesh;
  34119. /**
  34120. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34121. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  34122. */
  34123. vars: any;
  34124. /**
  34125. * This array is populated when the SPS is set as 'pickable'.
  34126. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34127. * Each element of this array is an object `{idx: int, faceId: int}`.
  34128. * `idx` is the picked particle index in the `SPS.particles` array
  34129. * `faceId` is the picked face index counted within this particle.
  34130. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  34131. */
  34132. pickedParticles: {
  34133. idx: number;
  34134. faceId: number;
  34135. }[];
  34136. /**
  34137. * This array is populated when `enableDepthSort` is set to true.
  34138. * Each element of this array is an instance of the class DepthSortedParticle.
  34139. */
  34140. depthSortedParticles: DepthSortedParticle[];
  34141. /**
  34142. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34143. * @hidden
  34144. */
  34145. _bSphereOnly: boolean;
  34146. /**
  34147. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34148. * @hidden
  34149. */
  34150. _bSphereRadiusFactor: number;
  34151. private _scene;
  34152. private _positions;
  34153. private _indices;
  34154. private _normals;
  34155. private _colors;
  34156. private _uvs;
  34157. private _indices32;
  34158. private _positions32;
  34159. private _normals32;
  34160. private _fixedNormal32;
  34161. private _colors32;
  34162. private _uvs32;
  34163. private _index;
  34164. private _updatable;
  34165. private _pickable;
  34166. private _isVisibilityBoxLocked;
  34167. private _alwaysVisible;
  34168. private _depthSort;
  34169. private _shapeCounter;
  34170. private _copy;
  34171. private _color;
  34172. private _computeParticleColor;
  34173. private _computeParticleTexture;
  34174. private _computeParticleRotation;
  34175. private _computeParticleVertex;
  34176. private _computeBoundingBox;
  34177. private _depthSortParticles;
  34178. private _camera;
  34179. private _mustUnrotateFixedNormals;
  34180. private _particlesIntersect;
  34181. private _needs32Bits;
  34182. /**
  34183. * Creates a SPS (Solid Particle System) object.
  34184. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34185. * @param scene (Scene) is the scene in which the SPS is added.
  34186. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34187. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34188. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34189. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34190. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34191. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34192. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34193. */
  34194. constructor(name: string, scene: Scene, options?: {
  34195. updatable?: boolean;
  34196. isPickable?: boolean;
  34197. enableDepthSort?: boolean;
  34198. particleIntersection?: boolean;
  34199. boundingSphereOnly?: boolean;
  34200. bSphereRadiusFactor?: number;
  34201. });
  34202. /**
  34203. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34204. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34205. * @returns the created mesh
  34206. */
  34207. buildMesh(): Mesh;
  34208. /**
  34209. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34210. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34211. * Thus the particles generated from `digest()` have their property `position` set yet.
  34212. * @param mesh ( Mesh ) is the mesh to be digested
  34213. * @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
  34214. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34215. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34216. * @returns the current SPS
  34217. */
  34218. digest(mesh: Mesh, options?: {
  34219. facetNb?: number;
  34220. number?: number;
  34221. delta?: number;
  34222. }): SolidParticleSystem;
  34223. private _unrotateFixedNormals;
  34224. private _resetCopy;
  34225. private _meshBuilder;
  34226. private _posToShape;
  34227. private _uvsToShapeUV;
  34228. private _addParticle;
  34229. /**
  34230. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34231. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  34232. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34233. * @param nb (positive integer) the number of particles to be created from this model
  34234. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34235. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34236. * @returns the number of shapes in the system
  34237. */
  34238. addShape(mesh: Mesh, nb: number, options?: {
  34239. positionFunction?: any;
  34240. vertexFunction?: any;
  34241. }): number;
  34242. private _rebuildParticle;
  34243. /**
  34244. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34245. * @returns the SPS.
  34246. */
  34247. rebuildMesh(): SolidParticleSystem;
  34248. /**
  34249. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34250. * This method calls `updateParticle()` for each particle of the SPS.
  34251. * For an animated SPS, it is usually called within the render loop.
  34252. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34253. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34254. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34255. * @returns the SPS.
  34256. */
  34257. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34258. /**
  34259. * Disposes the SPS.
  34260. */
  34261. dispose(): void;
  34262. /**
  34263. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34264. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34265. * @returns the SPS.
  34266. */
  34267. refreshVisibleSize(): SolidParticleSystem;
  34268. /**
  34269. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34270. * @param size the size (float) of the visibility box
  34271. * note : this doesn't lock the SPS mesh bounding box.
  34272. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34273. */
  34274. setVisibilityBox(size: number): void;
  34275. /**
  34276. * Gets whether the SPS as always visible or not
  34277. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34278. */
  34279. /**
  34280. * Sets the SPS as always visible or not
  34281. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34282. */
  34283. isAlwaysVisible: boolean;
  34284. /**
  34285. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34286. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34287. */
  34288. /**
  34289. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34290. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34291. */
  34292. isVisibilityBoxLocked: boolean;
  34293. /**
  34294. * Tells to `setParticles()` to compute the particle rotations or not.
  34295. * Default value : true. The SPS is faster when it's set to false.
  34296. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34297. */
  34298. /**
  34299. * Gets if `setParticles()` computes the particle rotations or not.
  34300. * Default value : true. The SPS is faster when it's set to false.
  34301. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34302. */
  34303. computeParticleRotation: boolean;
  34304. /**
  34305. * Tells to `setParticles()` to compute the particle colors or not.
  34306. * Default value : true. The SPS is faster when it's set to false.
  34307. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34308. */
  34309. /**
  34310. * Gets if `setParticles()` computes the particle colors or not.
  34311. * Default value : true. The SPS is faster when it's set to false.
  34312. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34313. */
  34314. computeParticleColor: boolean;
  34315. /**
  34316. * Gets if `setParticles()` computes the particle textures or not.
  34317. * Default value : true. The SPS is faster when it's set to false.
  34318. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34319. */
  34320. computeParticleTexture: boolean;
  34321. /**
  34322. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34323. * Default value : false. The SPS is faster when it's set to false.
  34324. * Note : the particle custom vertex positions aren't stored values.
  34325. */
  34326. /**
  34327. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34328. * Default value : false. The SPS is faster when it's set to false.
  34329. * Note : the particle custom vertex positions aren't stored values.
  34330. */
  34331. computeParticleVertex: boolean;
  34332. /**
  34333. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34334. */
  34335. /**
  34336. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34337. */
  34338. computeBoundingBox: boolean;
  34339. /**
  34340. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34341. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34342. * Default : `true`
  34343. */
  34344. /**
  34345. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34346. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34347. * Default : `true`
  34348. */
  34349. depthSortParticles: boolean;
  34350. /**
  34351. * This function does nothing. It may be overwritten to set all the particle first values.
  34352. * The SPS doesn't call this function, you may have to call it by your own.
  34353. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34354. */
  34355. initParticles(): void;
  34356. /**
  34357. * This function does nothing. It may be overwritten to recycle a particle.
  34358. * The SPS doesn't call this function, you may have to call it by your own.
  34359. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34360. * @param particle The particle to recycle
  34361. * @returns the recycled particle
  34362. */
  34363. recycleParticle(particle: SolidParticle): SolidParticle;
  34364. /**
  34365. * Updates a particle : this function should be overwritten by the user.
  34366. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34367. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34368. * @example : just set a particle position or velocity and recycle conditions
  34369. * @param particle The particle to update
  34370. * @returns the updated particle
  34371. */
  34372. updateParticle(particle: SolidParticle): SolidParticle;
  34373. /**
  34374. * Updates a vertex of a particle : it can be overwritten by the user.
  34375. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34376. * @param particle the current particle
  34377. * @param vertex the current index of the current particle
  34378. * @param pt the index of the current vertex in the particle shape
  34379. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  34380. * @example : just set a vertex particle position
  34381. * @returns the updated vertex
  34382. */
  34383. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  34384. /**
  34385. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34386. * This does nothing and may be overwritten by the user.
  34387. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34388. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34389. * @param update the boolean update value actually passed to setParticles()
  34390. */
  34391. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34392. /**
  34393. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34394. * This will be passed three parameters.
  34395. * This does nothing and may be overwritten by the user.
  34396. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34397. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34398. * @param update the boolean update value actually passed to setParticles()
  34399. */
  34400. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34401. }
  34402. }
  34403. declare module BABYLON {
  34404. /**
  34405. * Type of sub emitter
  34406. */
  34407. enum SubEmitterType {
  34408. /**
  34409. * Attached to the particle over it's lifetime
  34410. */
  34411. ATTACHED = 0,
  34412. /**
  34413. * Created when the particle dies
  34414. */
  34415. END = 1
  34416. }
  34417. /**
  34418. * Sub emitter class used to emit particles from an existing particle
  34419. */
  34420. class SubEmitter {
  34421. /**
  34422. * the particle system to be used by the sub emitter
  34423. */
  34424. particleSystem: ParticleSystem;
  34425. /**
  34426. * Type of the submitter (Default: END)
  34427. */
  34428. type: SubEmitterType;
  34429. /**
  34430. * 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)
  34431. * Note: This only is supported when using an emitter of type Mesh
  34432. */
  34433. inheritDirection: boolean;
  34434. /**
  34435. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  34436. */
  34437. inheritedVelocityAmount: number;
  34438. /**
  34439. * Creates a sub emitter
  34440. * @param particleSystem the particle system to be used by the sub emitter
  34441. */
  34442. constructor(
  34443. /**
  34444. * the particle system to be used by the sub emitter
  34445. */
  34446. particleSystem: ParticleSystem);
  34447. /**
  34448. * Clones the sub emitter
  34449. * @returns the cloned sub emitter
  34450. */
  34451. clone(): SubEmitter;
  34452. /**
  34453. * Serialize current object to a JSON object
  34454. * @returns the serialized object
  34455. */
  34456. serialize(): any;
  34457. /**
  34458. * Creates a new SubEmitter from a serialized JSON version
  34459. * @param serializationObject defines the JSON object to read from
  34460. * @param scene defines the hosting scene
  34461. * @param rootUrl defines the rootUrl for data loading
  34462. * @returns a new SubEmitter
  34463. */
  34464. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  34465. /** Release associated resources */
  34466. dispose(): 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. interface Scene {
  34572. /** @hidden (Backing field) */
  34573. _boundingBoxRenderer: BoundingBoxRenderer;
  34574. /** @hidden (Backing field) */
  34575. _forceShowBoundingBoxes: boolean;
  34576. /**
  34577. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34578. */
  34579. forceShowBoundingBoxes: boolean;
  34580. /**
  34581. * Gets the bounding box renderer associated with the scene
  34582. * @returns a BoundingBoxRenderer
  34583. */
  34584. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34585. }
  34586. interface AbstractMesh {
  34587. /** @hidden (Backing field) */
  34588. _showBoundingBox: boolean;
  34589. /**
  34590. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34591. */
  34592. showBoundingBox: boolean;
  34593. }
  34594. /**
  34595. * Component responsible of rendering the bounding box of the meshes in a scene.
  34596. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34597. */
  34598. class BoundingBoxRenderer implements ISceneComponent {
  34599. /**
  34600. * The component name helpfull to identify the component in the list of scene components.
  34601. */
  34602. readonly name: string;
  34603. /**
  34604. * The scene the component belongs to.
  34605. */
  34606. scene: Scene;
  34607. /**
  34608. * Color of the bounding box lines placed in front of an object
  34609. */
  34610. frontColor: Color3;
  34611. /**
  34612. * Color of the bounding box lines placed behind an object
  34613. */
  34614. backColor: Color3;
  34615. /**
  34616. * Defines if the renderer should show the back lines or not
  34617. */
  34618. showBackLines: boolean;
  34619. /**
  34620. * @hidden
  34621. */
  34622. renderList: SmartArray<BoundingBox>;
  34623. private _colorShader;
  34624. private _vertexBuffers;
  34625. private _indexBuffer;
  34626. /**
  34627. * Instantiates a new bounding box renderer in a scene.
  34628. * @param scene the scene the renderer renders in
  34629. */
  34630. constructor(scene: Scene);
  34631. /**
  34632. * Registers the component in a given scene
  34633. */
  34634. register(): void;
  34635. private _evaluateSubMesh;
  34636. private _activeMesh;
  34637. private _prepareRessources;
  34638. private _createIndexBuffer;
  34639. /**
  34640. * Rebuilds the elements related to this component in case of
  34641. * context lost for instance.
  34642. */
  34643. rebuild(): void;
  34644. /**
  34645. * @hidden
  34646. */
  34647. reset(): void;
  34648. /**
  34649. * Render the bounding boxes of a specific rendering group
  34650. * @param renderingGroupId defines the rendering group to render
  34651. */
  34652. render(renderingGroupId: number): void;
  34653. /**
  34654. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34655. * @param mesh Define the mesh to render the occlusion bounding box for
  34656. */
  34657. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34658. /**
  34659. * Dispose and release the resources attached to this renderer.
  34660. */
  34661. dispose(): void;
  34662. }
  34663. }
  34664. declare module BABYLON {
  34665. /**
  34666. * This represents a depth renderer in Babylon.
  34667. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34668. */
  34669. class DepthRenderer {
  34670. private _scene;
  34671. private _depthMap;
  34672. private _effect;
  34673. private _cachedDefines;
  34674. private _camera;
  34675. /**
  34676. * Specifiess that the depth renderer will only be used within
  34677. * the camera it is created for.
  34678. * This can help forcing its rendering during the camera processing.
  34679. */
  34680. useOnlyInActiveCamera: boolean;
  34681. /**
  34682. * Instantiates a depth renderer
  34683. * @param scene The scene the renderer belongs to
  34684. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34685. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34686. */
  34687. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34688. /**
  34689. * Creates the depth rendering effect and checks if the effect is ready.
  34690. * @param subMesh The submesh to be used to render the depth map of
  34691. * @param useInstances If multiple world instances should be used
  34692. * @returns if the depth renderer is ready to render the depth map
  34693. */
  34694. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34695. /**
  34696. * Gets the texture which the depth map will be written to.
  34697. * @returns The depth map texture
  34698. */
  34699. getDepthMap(): RenderTargetTexture;
  34700. /**
  34701. * Disposes of the depth renderer.
  34702. */
  34703. dispose(): void;
  34704. }
  34705. }
  34706. declare module BABYLON {
  34707. interface Scene {
  34708. /** @hidden (Backing field) */
  34709. _depthRenderer: {
  34710. [id: string]: DepthRenderer;
  34711. };
  34712. /**
  34713. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34714. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34715. * @returns the created depth renderer
  34716. */
  34717. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34718. /**
  34719. * Disables a depth renderer for a given camera
  34720. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34721. */
  34722. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34723. }
  34724. /**
  34725. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  34726. * in several rendering techniques.
  34727. */
  34728. class DepthRendererSceneComponent implements ISceneComponent {
  34729. /**
  34730. * The component name helpfull to identify the component in the list of scene components.
  34731. */
  34732. readonly name: string;
  34733. /**
  34734. * The scene the component belongs to.
  34735. */
  34736. scene: Scene;
  34737. /**
  34738. * Creates a new instance of the component for the given scene
  34739. * @param scene Defines the scene to register the component in
  34740. */
  34741. constructor(scene: Scene);
  34742. /**
  34743. * Registers the component in a given scene
  34744. */
  34745. register(): void;
  34746. /**
  34747. * Rebuilds the elements related to this component in case of
  34748. * context lost for instance.
  34749. */
  34750. rebuild(): void;
  34751. /**
  34752. * Disposes the component and the associated ressources
  34753. */
  34754. dispose(): void;
  34755. private _gatherRenderTargets;
  34756. private _gatherActiveCameraRenderTargets;
  34757. }
  34758. }
  34759. declare module BABYLON {
  34760. interface AbstractMesh {
  34761. /**
  34762. * Disables the mesh edge rendering mode
  34763. * @returns the currentAbstractMesh
  34764. */
  34765. disableEdgesRendering(): AbstractMesh;
  34766. /**
  34767. * Enables the edge rendering mode on the mesh.
  34768. * This mode makes the mesh edges visible
  34769. * @param epsilon defines the maximal distance between two angles to detect a face
  34770. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34771. * @returns the currentAbstractMesh
  34772. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34773. */
  34774. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34775. /**
  34776. * Gets the edgesRenderer associated with the mesh
  34777. */
  34778. edgesRenderer: Nullable<EdgesRenderer>;
  34779. }
  34780. interface LinesMesh {
  34781. /**
  34782. * Enables the edge rendering mode on the mesh.
  34783. * This mode makes the mesh edges visible
  34784. * @param epsilon defines the maximal distance between two angles to detect a face
  34785. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34786. * @returns the currentAbstractMesh
  34787. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34788. */
  34789. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34790. }
  34791. interface InstancedLinesMesh {
  34792. /**
  34793. * Enables the edge rendering mode on the mesh.
  34794. * This mode makes the mesh edges visible
  34795. * @param epsilon defines the maximal distance between two angles to detect a face
  34796. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34797. * @returns the current InstancedLinesMesh
  34798. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34799. */
  34800. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34801. }
  34802. /**
  34803. * Defines the minimum contract an Edges renderer should follow.
  34804. */
  34805. interface IEdgesRenderer extends IDisposable {
  34806. /**
  34807. * Gets or sets a boolean indicating if the edgesRenderer is active
  34808. */
  34809. isEnabled: boolean;
  34810. /**
  34811. * Renders the edges of the attached mesh,
  34812. */
  34813. render(): void;
  34814. /**
  34815. * Checks wether or not the edges renderer is ready to render.
  34816. * @return true if ready, otherwise false.
  34817. */
  34818. isReady(): boolean;
  34819. }
  34820. /**
  34821. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34822. */
  34823. class EdgesRenderer implements IEdgesRenderer {
  34824. /**
  34825. * Define the size of the edges with an orthographic camera
  34826. */
  34827. edgesWidthScalerForOrthographic: number;
  34828. /**
  34829. * Define the size of the edges with a perspective camera
  34830. */
  34831. edgesWidthScalerForPerspective: number;
  34832. protected _source: AbstractMesh;
  34833. protected _linesPositions: number[];
  34834. protected _linesNormals: number[];
  34835. protected _linesIndices: number[];
  34836. protected _epsilon: number;
  34837. protected _indicesCount: number;
  34838. protected _lineShader: ShaderMaterial;
  34839. protected _ib: WebGLBuffer;
  34840. protected _buffers: {
  34841. [key: string]: Nullable<VertexBuffer>;
  34842. };
  34843. protected _checkVerticesInsteadOfIndices: boolean;
  34844. private _meshRebuildObserver;
  34845. private _meshDisposeObserver;
  34846. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34847. isEnabled: boolean;
  34848. /**
  34849. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34850. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34851. * @param source Mesh used to create edges
  34852. * @param epsilon sum of angles in adjacency to check for edge
  34853. * @param checkVerticesInsteadOfIndices
  34854. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34855. */
  34856. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34857. protected _prepareRessources(): void;
  34858. /** @hidden */
  34859. _rebuild(): void;
  34860. /**
  34861. * Releases the required resources for the edges renderer
  34862. */
  34863. dispose(): void;
  34864. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34865. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34866. /**
  34867. * Checks if the pair of p0 and p1 is en edge
  34868. * @param faceIndex
  34869. * @param edge
  34870. * @param faceNormals
  34871. * @param p0
  34872. * @param p1
  34873. * @private
  34874. */
  34875. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34876. /**
  34877. * push line into the position, normal and index buffer
  34878. * @protected
  34879. */
  34880. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34881. /**
  34882. * Generates lines edges from adjacencjes
  34883. * @private
  34884. */
  34885. _generateEdgesLines(): void;
  34886. /**
  34887. * Checks wether or not the edges renderer is ready to render.
  34888. * @return true if ready, otherwise false.
  34889. */
  34890. isReady(): boolean;
  34891. /**
  34892. * Renders the edges of the attached mesh,
  34893. */
  34894. render(): void;
  34895. }
  34896. }
  34897. declare module BABYLON {
  34898. /**
  34899. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34900. */
  34901. class GeometryBufferRenderer {
  34902. /**
  34903. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34904. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34905. */
  34906. static readonly POSITION_TEXTURE_TYPE: number;
  34907. /**
  34908. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34909. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34910. */
  34911. static readonly VELOCITY_TEXTURE_TYPE: number;
  34912. /**
  34913. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34914. * in order to compute objects velocities when enableVelocity is set to "true"
  34915. * @hidden
  34916. */
  34917. _previousTransformationMatrices: {
  34918. [index: number]: Matrix;
  34919. };
  34920. private _scene;
  34921. private _multiRenderTarget;
  34922. private _ratio;
  34923. private _enablePosition;
  34924. private _enableVelocity;
  34925. private _positionIndex;
  34926. private _velocityIndex;
  34927. protected _effect: Effect;
  34928. protected _cachedDefines: string;
  34929. /**
  34930. * Set the render list (meshes to be rendered) used in the G buffer.
  34931. */
  34932. renderList: Mesh[];
  34933. /**
  34934. * Gets wether or not G buffer are supported by the running hardware.
  34935. * This requires draw buffer supports
  34936. */
  34937. readonly isSupported: boolean;
  34938. /**
  34939. * Returns the index of the given texture type in the G-Buffer textures array
  34940. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34941. * @returns the index of the given texture type in the G-Buffer textures array
  34942. */
  34943. getTextureIndex(textureType: number): number;
  34944. /**
  34945. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34946. */
  34947. /**
  34948. * Sets whether or not objects positions are enabled for the G buffer.
  34949. */
  34950. enablePosition: boolean;
  34951. /**
  34952. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34953. */
  34954. /**
  34955. * Sets wether or not objects velocities are enabled for the G buffer.
  34956. */
  34957. enableVelocity: boolean;
  34958. /**
  34959. * Gets the scene associated with the buffer.
  34960. */
  34961. readonly scene: Scene;
  34962. /**
  34963. * Gets the ratio used by the buffer during its creation.
  34964. * How big is the buffer related to the main canvas.
  34965. */
  34966. readonly ratio: number;
  34967. /**
  34968. * Creates a new G Buffer for the scene
  34969. * @param scene The scene the buffer belongs to
  34970. * @param ratio How big is the buffer related to the main canvas.
  34971. */
  34972. constructor(scene: Scene, ratio?: number);
  34973. /**
  34974. * Checks wether everything is ready to render a submesh to the G buffer.
  34975. * @param subMesh the submesh to check readiness for
  34976. * @param useInstances is the mesh drawn using instance or not
  34977. * @returns true if ready otherwise false
  34978. */
  34979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34980. /**
  34981. * Gets the current underlying G Buffer.
  34982. * @returns the buffer
  34983. */
  34984. getGBuffer(): MultiRenderTarget;
  34985. /**
  34986. * Gets the number of samples used to render the buffer (anti aliasing).
  34987. */
  34988. /**
  34989. * Sets the number of samples used to render the buffer (anti aliasing).
  34990. */
  34991. samples: number;
  34992. /**
  34993. * Disposes the renderer and frees up associated resources.
  34994. */
  34995. dispose(): void;
  34996. protected _createRenderTargets(): void;
  34997. }
  34998. }
  34999. declare module BABYLON {
  35000. interface Scene {
  35001. /** @hidden (Backing field) */
  35002. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35003. /**
  35004. * Gets or Sets the current geometry buffer associated to the scene.
  35005. */
  35006. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35007. /**
  35008. * Enables a GeometryBufferRender and associates it with the scene
  35009. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35010. * @returns the GeometryBufferRenderer
  35011. */
  35012. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35013. /**
  35014. * Disables the GeometryBufferRender associated with the scene
  35015. */
  35016. disableGeometryBufferRenderer(): void;
  35017. }
  35018. /**
  35019. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35020. * in several rendering techniques.
  35021. */
  35022. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35023. /**
  35024. * The component name helpful to identify the component in the list of scene components.
  35025. */
  35026. readonly name: string;
  35027. /**
  35028. * The scene the component belongs to.
  35029. */
  35030. scene: Scene;
  35031. /**
  35032. * Creates a new instance of the component for the given scene
  35033. * @param scene Defines the scene to register the component in
  35034. */
  35035. constructor(scene: Scene);
  35036. /**
  35037. * Registers the component in a given scene
  35038. */
  35039. register(): void;
  35040. /**
  35041. * Rebuilds the elements related to this component in case of
  35042. * context lost for instance.
  35043. */
  35044. rebuild(): void;
  35045. /**
  35046. * Disposes the component and the associated ressources
  35047. */
  35048. dispose(): void;
  35049. private _gatherRenderTargets;
  35050. }
  35051. }
  35052. declare module BABYLON {
  35053. /**
  35054. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35055. */
  35056. class LineEdgesRenderer extends EdgesRenderer {
  35057. /**
  35058. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35059. * @param source LineMesh used to generate edges
  35060. * @param epsilon not important (specified angle for edge detection)
  35061. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35062. */
  35063. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35064. /**
  35065. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35066. */
  35067. _generateEdgesLines(): void;
  35068. }
  35069. }
  35070. declare module BABYLON {
  35071. interface Scene {
  35072. /** @hidden */
  35073. _outlineRenderer: OutlineRenderer;
  35074. /**
  35075. * Gets the outline renderer associated with the scene
  35076. * @returns a OutlineRenderer
  35077. */
  35078. getOutlineRenderer(): OutlineRenderer;
  35079. }
  35080. interface AbstractMesh {
  35081. /** @hidden (Backing field) */
  35082. _renderOutline: boolean;
  35083. /**
  35084. * Gets or sets a boolean indicating if the outline must be rendered as well
  35085. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35086. */
  35087. renderOutline: boolean;
  35088. /** @hidden (Backing field) */
  35089. _renderOverlay: boolean;
  35090. /**
  35091. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35092. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35093. */
  35094. renderOverlay: boolean;
  35095. }
  35096. /**
  35097. * This class is responsible to draw bothe outline/overlay of meshes.
  35098. * It should not be used directly but through the available method on mesh.
  35099. */
  35100. class OutlineRenderer implements ISceneComponent {
  35101. /**
  35102. * The name of the component. Each component must have a unique name.
  35103. */
  35104. name: string;
  35105. /**
  35106. * The scene the component belongs to.
  35107. */
  35108. scene: Scene;
  35109. /**
  35110. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35111. */
  35112. zOffset: number;
  35113. private _engine;
  35114. private _effect;
  35115. private _cachedDefines;
  35116. private _savedDepthWrite;
  35117. /**
  35118. * Instantiates a new outline renderer. (There could be only one per scene).
  35119. * @param scene Defines the scene it belongs to
  35120. */
  35121. constructor(scene: Scene);
  35122. /**
  35123. * Register the component to one instance of a scene.
  35124. */
  35125. register(): void;
  35126. /**
  35127. * Rebuilds the elements related to this component in case of
  35128. * context lost for instance.
  35129. */
  35130. rebuild(): void;
  35131. /**
  35132. * Disposes the component and the associated ressources.
  35133. */
  35134. dispose(): void;
  35135. /**
  35136. * Renders the outline in the canvas.
  35137. * @param subMesh Defines the sumesh to render
  35138. * @param batch Defines the batch of meshes in case of instances
  35139. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35140. */
  35141. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35142. /**
  35143. * Returns whether or not the outline renderer is ready for a given submesh.
  35144. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35145. * @param subMesh Defines the submesh to check readyness for
  35146. * @param useInstances Defines wheter wee are trying to render instances or not
  35147. * @returns true if ready otherwise false
  35148. */
  35149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35150. private _beforeRenderingMesh;
  35151. private _afterRenderingMesh;
  35152. }
  35153. }
  35154. declare module BABYLON {
  35155. /**
  35156. * This represents the object necessary to create a rendering group.
  35157. * This is exclusively used and created by the rendering manager.
  35158. * To modify the behavior, you use the available helpers in your scene or meshes.
  35159. * @hidden
  35160. */
  35161. class RenderingGroup {
  35162. index: number;
  35163. private _scene;
  35164. private _opaqueSubMeshes;
  35165. private _transparentSubMeshes;
  35166. private _alphaTestSubMeshes;
  35167. private _depthOnlySubMeshes;
  35168. private _particleSystems;
  35169. private _spriteManagers;
  35170. private _opaqueSortCompareFn;
  35171. private _alphaTestSortCompareFn;
  35172. private _transparentSortCompareFn;
  35173. private _renderOpaque;
  35174. private _renderAlphaTest;
  35175. private _renderTransparent;
  35176. private _edgesRenderers;
  35177. onBeforeTransparentRendering: () => void;
  35178. /**
  35179. * Set the opaque sort comparison function.
  35180. * If null the sub meshes will be render in the order they were created
  35181. */
  35182. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35183. /**
  35184. * Set the alpha test sort comparison function.
  35185. * If null the sub meshes will be render in the order they were created
  35186. */
  35187. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35188. /**
  35189. * Set the transparent sort comparison function.
  35190. * If null the sub meshes will be render in the order they were created
  35191. */
  35192. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35193. /**
  35194. * Creates a new rendering group.
  35195. * @param index The rendering group index
  35196. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35197. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35198. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35199. */
  35200. 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>);
  35201. /**
  35202. * Render all the sub meshes contained in the group.
  35203. * @param customRenderFunction Used to override the default render behaviour of the group.
  35204. * @returns true if rendered some submeshes.
  35205. */
  35206. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35207. /**
  35208. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35209. * @param subMeshes The submeshes to render
  35210. */
  35211. private renderOpaqueSorted;
  35212. /**
  35213. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35214. * @param subMeshes The submeshes to render
  35215. */
  35216. private renderAlphaTestSorted;
  35217. /**
  35218. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35219. * @param subMeshes The submeshes to render
  35220. */
  35221. private renderTransparentSorted;
  35222. /**
  35223. * Renders the submeshes in a specified order.
  35224. * @param subMeshes The submeshes to sort before render
  35225. * @param sortCompareFn The comparison function use to sort
  35226. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35227. * @param transparent Specifies to activate blending if true
  35228. */
  35229. private static renderSorted;
  35230. /**
  35231. * Renders the submeshes in the order they were dispatched (no sort applied).
  35232. * @param subMeshes The submeshes to render
  35233. */
  35234. private static renderUnsorted;
  35235. /**
  35236. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35237. * are rendered back to front if in the same alpha index.
  35238. *
  35239. * @param a The first submesh
  35240. * @param b The second submesh
  35241. * @returns The result of the comparison
  35242. */
  35243. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35244. /**
  35245. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35246. * are rendered back to front.
  35247. *
  35248. * @param a The first submesh
  35249. * @param b The second submesh
  35250. * @returns The result of the comparison
  35251. */
  35252. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35253. /**
  35254. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35255. * are rendered front to back (prevent overdraw).
  35256. *
  35257. * @param a The first submesh
  35258. * @param b The second submesh
  35259. * @returns The result of the comparison
  35260. */
  35261. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35262. /**
  35263. * Resets the different lists of submeshes to prepare a new frame.
  35264. */
  35265. prepare(): void;
  35266. dispose(): void;
  35267. /**
  35268. * Inserts the submesh in its correct queue depending on its material.
  35269. * @param subMesh The submesh to dispatch
  35270. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35271. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35272. */
  35273. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35274. dispatchSprites(spriteManager: ISpriteManager): void;
  35275. dispatchParticles(particleSystem: IParticleSystem): void;
  35276. private _renderParticles;
  35277. private _renderSprites;
  35278. }
  35279. }
  35280. declare module BABYLON {
  35281. /**
  35282. * Interface describing the different options available in the rendering manager
  35283. * regarding Auto Clear between groups.
  35284. */
  35285. interface IRenderingManagerAutoClearSetup {
  35286. /**
  35287. * Defines whether or not autoclear is enable.
  35288. */
  35289. autoClear: boolean;
  35290. /**
  35291. * Defines whether or not to autoclear the depth buffer.
  35292. */
  35293. depth: boolean;
  35294. /**
  35295. * Defines whether or not to autoclear the stencil buffer.
  35296. */
  35297. stencil: boolean;
  35298. }
  35299. /**
  35300. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35301. * It is enable to manage the different groups as well as the different necessary sort functions.
  35302. * This should not be used directly aside of the few static configurations
  35303. */
  35304. class RenderingManager {
  35305. /**
  35306. * The max id used for rendering groups (not included)
  35307. */
  35308. static MAX_RENDERINGGROUPS: number;
  35309. /**
  35310. * The min id used for rendering groups (included)
  35311. */
  35312. static MIN_RENDERINGGROUPS: number;
  35313. /**
  35314. * Used to globally prevent autoclearing scenes.
  35315. */
  35316. static AUTOCLEAR: boolean;
  35317. /**
  35318. * @hidden
  35319. */
  35320. _useSceneAutoClearSetup: boolean;
  35321. private _scene;
  35322. private _renderingGroups;
  35323. private _depthStencilBufferAlreadyCleaned;
  35324. private _autoClearDepthStencil;
  35325. private _customOpaqueSortCompareFn;
  35326. private _customAlphaTestSortCompareFn;
  35327. private _customTransparentSortCompareFn;
  35328. private _renderingGroupInfo;
  35329. /**
  35330. * Instantiates a new rendering group for a particular scene
  35331. * @param scene Defines the scene the groups belongs to
  35332. */
  35333. constructor(scene: Scene);
  35334. private _clearDepthStencilBuffer;
  35335. /**
  35336. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35337. * @hidden
  35338. */
  35339. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35340. /**
  35341. * Resets the different information of the group to prepare a new frame
  35342. * @hidden
  35343. */
  35344. reset(): void;
  35345. /**
  35346. * Dispose and release the group and its associated resources.
  35347. * @hidden
  35348. */
  35349. dispose(): void;
  35350. /**
  35351. * Clear the info related to rendering groups preventing retention points during dispose.
  35352. */
  35353. freeRenderingGroups(): void;
  35354. private _prepareRenderingGroup;
  35355. /**
  35356. * Add a sprite manager to the rendering manager in order to render it this frame.
  35357. * @param spriteManager Define the sprite manager to render
  35358. */
  35359. dispatchSprites(spriteManager: ISpriteManager): void;
  35360. /**
  35361. * Add a particle system to the rendering manager in order to render it this frame.
  35362. * @param particleSystem Define the particle system to render
  35363. */
  35364. dispatchParticles(particleSystem: IParticleSystem): void;
  35365. /**
  35366. * Add a submesh to the manager in order to render it this frame
  35367. * @param subMesh The submesh to dispatch
  35368. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35369. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35370. */
  35371. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35372. /**
  35373. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35374. * This allowed control for front to back rendering or reversly depending of the special needs.
  35375. *
  35376. * @param renderingGroupId The rendering group id corresponding to its index
  35377. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35378. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35379. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35380. */
  35381. 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;
  35382. /**
  35383. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35384. *
  35385. * @param renderingGroupId The rendering group id corresponding to its index
  35386. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35387. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35388. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35389. */
  35390. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35391. /**
  35392. * Gets the current auto clear configuration for one rendering group of the rendering
  35393. * manager.
  35394. * @param index the rendering group index to get the information for
  35395. * @returns The auto clear setup for the requested rendering group
  35396. */
  35397. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35398. }
  35399. }
  35400. declare module BABYLON {
  35401. /**
  35402. * Renders a layer on top of an existing scene
  35403. */
  35404. class UtilityLayerRenderer implements IDisposable {
  35405. /** the original scene that will be rendered on top of */
  35406. originalScene: Scene;
  35407. private _pointerCaptures;
  35408. private _lastPointerEvents;
  35409. private static _DefaultUtilityLayer;
  35410. private static _DefaultKeepDepthUtilityLayer;
  35411. /**
  35412. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35413. */
  35414. pickUtilitySceneFirst: boolean;
  35415. /**
  35416. * 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)
  35417. */
  35418. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35419. /**
  35420. * 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)
  35421. */
  35422. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35423. /**
  35424. * The scene that is rendered on top of the original scene
  35425. */
  35426. utilityLayerScene: Scene;
  35427. /**
  35428. * If the utility layer should automatically be rendered on top of existing scene
  35429. */
  35430. shouldRender: boolean;
  35431. /**
  35432. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35433. */
  35434. onlyCheckPointerDownEvents: boolean;
  35435. /**
  35436. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35437. */
  35438. processAllEvents: boolean;
  35439. /**
  35440. * Observable raised when the pointer move from the utility layer scene to the main scene
  35441. */
  35442. onPointerOutObservable: Observable<number>;
  35443. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35444. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35445. private _afterRenderObserver;
  35446. private _sceneDisposeObserver;
  35447. private _originalPointerObserver;
  35448. /**
  35449. * Instantiates a UtilityLayerRenderer
  35450. * @param originalScene the original scene that will be rendered on top of
  35451. * @param handleEvents boolean indicating if the utility layer should handle events
  35452. */
  35453. constructor(
  35454. /** the original scene that will be rendered on top of */
  35455. originalScene: Scene, handleEvents?: boolean);
  35456. private _notifyObservers;
  35457. /**
  35458. * Renders the utility layers scene on top of the original scene
  35459. */
  35460. render(): void;
  35461. /**
  35462. * Disposes of the renderer
  35463. */
  35464. dispose(): void;
  35465. private _updateCamera;
  35466. }
  35467. }
  35468. declare module BABYLON {
  35469. /**
  35470. * Postprocess used to generate anaglyphic rendering
  35471. */
  35472. class AnaglyphPostProcess extends PostProcess {
  35473. private _passedProcess;
  35474. /**
  35475. * Creates a new AnaglyphPostProcess
  35476. * @param name defines postprocess name
  35477. * @param options defines creation options or target ratio scale
  35478. * @param rigCameras defines cameras using this postprocess
  35479. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35480. * @param engine defines hosting engine
  35481. * @param reusable defines if the postprocess will be reused multiple times per frame
  35482. */
  35483. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35484. }
  35485. }
  35486. declare module BABYLON {
  35487. /**
  35488. * Post process used to render in black and white
  35489. */
  35490. class BlackAndWhitePostProcess extends PostProcess {
  35491. /**
  35492. * Linear about to convert he result to black and white (default: 1)
  35493. */
  35494. degree: number;
  35495. /**
  35496. * Creates a black and white post process
  35497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35498. * @param name The name of the effect.
  35499. * @param options The required width/height ratio to downsize to before computing the render pass.
  35500. * @param camera The camera to apply the render pass to.
  35501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35502. * @param engine The engine which the post process will be applied. (default: current engine)
  35503. * @param reusable If the post process can be reused on the same frame. (default: false)
  35504. */
  35505. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35506. }
  35507. }
  35508. declare module BABYLON {
  35509. /**
  35510. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35511. */
  35512. class BloomEffect extends PostProcessRenderEffect {
  35513. private bloomScale;
  35514. /**
  35515. * @hidden Internal
  35516. */
  35517. _effects: Array<PostProcess>;
  35518. /**
  35519. * @hidden Internal
  35520. */
  35521. _downscale: ExtractHighlightsPostProcess;
  35522. private _blurX;
  35523. private _blurY;
  35524. private _merge;
  35525. /**
  35526. * The luminance threshold to find bright areas of the image to bloom.
  35527. */
  35528. threshold: number;
  35529. /**
  35530. * The strength of the bloom.
  35531. */
  35532. weight: number;
  35533. /**
  35534. * Specifies the size of the bloom blur kernel, relative to the final output size
  35535. */
  35536. kernel: number;
  35537. /**
  35538. * Creates a new instance of @see BloomEffect
  35539. * @param scene The scene the effect belongs to.
  35540. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35541. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35542. * @param bloomWeight The the strength of bloom.
  35543. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35544. * @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)
  35545. */
  35546. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35547. /**
  35548. * Disposes each of the internal effects for a given camera.
  35549. * @param camera The camera to dispose the effect on.
  35550. */
  35551. disposeEffects(camera: Camera): void;
  35552. /**
  35553. * @hidden Internal
  35554. */
  35555. _updateEffects(): void;
  35556. /**
  35557. * Internal
  35558. * @returns if all the contained post processes are ready.
  35559. * @hidden
  35560. */
  35561. _isReady(): boolean;
  35562. }
  35563. }
  35564. declare module BABYLON {
  35565. /**
  35566. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35567. */
  35568. class BloomMergePostProcess extends PostProcess {
  35569. /** Weight of the bloom to be added to the original input. */
  35570. weight: number;
  35571. /**
  35572. * Creates a new instance of @see BloomMergePostProcess
  35573. * @param name The name of the effect.
  35574. * @param originalFromInput Post process which's input will be used for the merge.
  35575. * @param blurred Blurred highlights post process which's output will be used.
  35576. * @param weight Weight of the bloom to be added to the original input.
  35577. * @param options The required width/height ratio to downsize to before computing the render pass.
  35578. * @param camera The camera to apply the render pass to.
  35579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35580. * @param engine The engine which the post process will be applied. (default: current engine)
  35581. * @param reusable If the post process can be reused on the same frame. (default: false)
  35582. * @param textureType Type of textures used when performing the post process. (default: 0)
  35583. * @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)
  35584. */
  35585. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35586. /** Weight of the bloom to be added to the original input. */
  35587. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35588. }
  35589. }
  35590. declare module BABYLON {
  35591. /**
  35592. * The Blur Post Process which blurs an image based on a kernel and direction.
  35593. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35594. */
  35595. class BlurPostProcess extends PostProcess {
  35596. /** The direction in which to blur the image. */
  35597. direction: Vector2;
  35598. private blockCompilation;
  35599. protected _kernel: number;
  35600. protected _idealKernel: number;
  35601. protected _packedFloat: boolean;
  35602. private _staticDefines;
  35603. /**
  35604. * Sets the length in pixels of the blur sample region
  35605. */
  35606. /**
  35607. * Gets the length in pixels of the blur sample region
  35608. */
  35609. kernel: number;
  35610. /**
  35611. * Sets wether or not the blur needs to unpack/repack floats
  35612. */
  35613. /**
  35614. * Gets wether or not the blur is unpacking/repacking floats
  35615. */
  35616. packedFloat: boolean;
  35617. /**
  35618. * Creates a new instance BlurPostProcess
  35619. * @param name The name of the effect.
  35620. * @param direction The direction in which to blur the image.
  35621. * @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.
  35622. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35623. * @param camera The camera to apply the render pass to.
  35624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35625. * @param engine The engine which the post process will be applied. (default: current engine)
  35626. * @param reusable If the post process can be reused on the same frame. (default: false)
  35627. * @param textureType Type of textures used when performing the post process. (default: 0)
  35628. * @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)
  35629. */
  35630. constructor(name: string,
  35631. /** The direction in which to blur the image. */
  35632. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35633. /**
  35634. * Updates the effect with the current post process compile time values and recompiles the shader.
  35635. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35636. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35637. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  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 onCompiled Called when the shader has been compiled.
  35640. * @param onError Called if there is an error when compiling a shader.
  35641. */
  35642. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35643. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35644. /**
  35645. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35646. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35647. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35648. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35649. * The gaps between physical kernels are compensated for in the weighting of the samples
  35650. * @param idealKernel Ideal blur kernel.
  35651. * @return Nearest best kernel.
  35652. */
  35653. protected _nearestBestKernel(idealKernel: number): number;
  35654. /**
  35655. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35656. * @param x The point on the Gaussian distribution to sample.
  35657. * @return the value of the Gaussian function at x.
  35658. */
  35659. protected _gaussianWeight(x: number): number;
  35660. /**
  35661. * Generates a string that can be used as a floating point number in GLSL.
  35662. * @param x Value to print.
  35663. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35664. * @return GLSL float string.
  35665. */
  35666. protected _glslFloat(x: number, decimalFigures?: number): string;
  35667. }
  35668. }
  35669. declare module BABYLON {
  35670. /**
  35671. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35672. */
  35673. class ChromaticAberrationPostProcess extends PostProcess {
  35674. /**
  35675. * The amount of seperation of rgb channels (default: 30)
  35676. */
  35677. aberrationAmount: number;
  35678. /**
  35679. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35680. */
  35681. radialIntensity: number;
  35682. /**
  35683. * 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))
  35684. */
  35685. direction: Vector2;
  35686. /**
  35687. * 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))
  35688. */
  35689. centerPosition: Vector2;
  35690. /**
  35691. * Creates a new instance ChromaticAberrationPostProcess
  35692. * @param name The name of the effect.
  35693. * @param screenWidth The width of the screen to apply the effect on.
  35694. * @param screenHeight The height of the screen to apply the effect on.
  35695. * @param options The required width/height ratio to downsize to before computing the render pass.
  35696. * @param camera The camera to apply the render pass to.
  35697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35698. * @param engine The engine which the post process will be applied. (default: current engine)
  35699. * @param reusable If the post process can be reused on the same frame. (default: false)
  35700. * @param textureType Type of textures used when performing the post process. (default: 0)
  35701. * @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)
  35702. */
  35703. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35704. }
  35705. }
  35706. declare module BABYLON {
  35707. /**
  35708. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35709. */
  35710. class CircleOfConfusionPostProcess extends PostProcess {
  35711. /**
  35712. * 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.
  35713. */
  35714. lensSize: number;
  35715. /**
  35716. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35717. */
  35718. fStop: number;
  35719. /**
  35720. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35721. */
  35722. focusDistance: number;
  35723. /**
  35724. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35725. */
  35726. focalLength: number;
  35727. private _depthTexture;
  35728. /**
  35729. * Creates a new instance CircleOfConfusionPostProcess
  35730. * @param name The name of the effect.
  35731. * @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.
  35732. * @param options The required width/height ratio to downsize to before computing the render pass.
  35733. * @param camera The camera to apply the render pass to.
  35734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35735. * @param engine The engine which the post process will be applied. (default: current engine)
  35736. * @param reusable If the post process can be reused on the same frame. (default: false)
  35737. * @param textureType Type of textures used when performing the post process. (default: 0)
  35738. * @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)
  35739. */
  35740. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35741. /**
  35742. * 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.
  35743. */
  35744. depthTexture: RenderTargetTexture;
  35745. }
  35746. }
  35747. declare module BABYLON {
  35748. /**
  35749. *
  35750. * This post-process allows the modification of rendered colors by using
  35751. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35752. *
  35753. * The object needs to be provided an url to a texture containing the color
  35754. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35755. * Use an image editing software to tweak the LUT to match your needs.
  35756. *
  35757. * For an example of a color LUT, see here:
  35758. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35759. * For explanations on color grading, see here:
  35760. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35761. *
  35762. */
  35763. class ColorCorrectionPostProcess extends PostProcess {
  35764. private _colorTableTexture;
  35765. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35766. }
  35767. }
  35768. declare module BABYLON {
  35769. /**
  35770. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35771. * input texture to perform effects such as edge detection or sharpening
  35772. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35773. */
  35774. class ConvolutionPostProcess extends PostProcess {
  35775. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35776. kernel: number[];
  35777. /**
  35778. * Creates a new instance ConvolutionPostProcess
  35779. * @param name The name of the effect.
  35780. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35781. * @param options The required width/height ratio to downsize to before computing the render pass.
  35782. * @param camera The camera to apply the render pass to.
  35783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35784. * @param engine The engine which the post process will be applied. (default: current engine)
  35785. * @param reusable If the post process can be reused on the same frame. (default: false)
  35786. * @param textureType Type of textures used when performing the post process. (default: 0)
  35787. */
  35788. constructor(name: string,
  35789. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35790. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35791. /**
  35792. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35793. */
  35794. static EdgeDetect0Kernel: number[];
  35795. /**
  35796. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35797. */
  35798. static EdgeDetect1Kernel: number[];
  35799. /**
  35800. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35801. */
  35802. static EdgeDetect2Kernel: number[];
  35803. /**
  35804. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35805. */
  35806. static SharpenKernel: number[];
  35807. /**
  35808. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35809. */
  35810. static EmbossKernel: number[];
  35811. /**
  35812. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35813. */
  35814. static GaussianKernel: number[];
  35815. }
  35816. }
  35817. declare module BABYLON {
  35818. /**
  35819. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  35820. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  35821. * based on samples that have a large difference in distance than the center pixel.
  35822. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  35823. */
  35824. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  35825. direction: Vector2;
  35826. /**
  35827. * Creates a new instance CircleOfConfusionPostProcess
  35828. * @param name The name of the effect.
  35829. * @param scene The scene the effect belongs to.
  35830. * @param direction The direction the blur should be applied.
  35831. * @param kernel The size of the kernel used to blur.
  35832. * @param options The required width/height ratio to downsize to before computing the render pass.
  35833. * @param camera The camera to apply the render pass to.
  35834. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  35835. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  35836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35837. * @param engine The engine which the post process will be applied. (default: current engine)
  35838. * @param reusable If the post process can be reused on the same frame. (default: false)
  35839. * @param textureType Type of textures used when performing the post process. (default: 0)
  35840. * @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)
  35841. */
  35842. 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);
  35843. }
  35844. }
  35845. declare module BABYLON {
  35846. /**
  35847. * Specifies the level of max blur that should be applied when using the depth of field effect
  35848. */
  35849. enum DepthOfFieldEffectBlurLevel {
  35850. /**
  35851. * Subtle blur
  35852. */
  35853. Low = 0,
  35854. /**
  35855. * Medium blur
  35856. */
  35857. Medium = 1,
  35858. /**
  35859. * Large blur
  35860. */
  35861. High = 2
  35862. }
  35863. /**
  35864. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  35865. */
  35866. class DepthOfFieldEffect extends PostProcessRenderEffect {
  35867. private _circleOfConfusion;
  35868. /**
  35869. * @hidden Internal, blurs from high to low
  35870. */
  35871. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  35872. private _depthOfFieldBlurY;
  35873. private _dofMerge;
  35874. /**
  35875. * @hidden Internal post processes in depth of field effect
  35876. */
  35877. _effects: Array<PostProcess>;
  35878. /**
  35879. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  35880. */
  35881. focalLength: number;
  35882. /**
  35883. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35884. */
  35885. fStop: number;
  35886. /**
  35887. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35888. */
  35889. focusDistance: number;
  35890. /**
  35891. * 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.
  35892. */
  35893. lensSize: number;
  35894. /**
  35895. * Creates a new instance DepthOfFieldEffect
  35896. * @param scene The scene the effect belongs to.
  35897. * @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.
  35898. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35899. * @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)
  35900. */
  35901. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35902. /**
  35903. * 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.
  35904. */
  35905. depthTexture: RenderTargetTexture;
  35906. /**
  35907. * Disposes each of the internal effects for a given camera.
  35908. * @param camera The camera to dispose the effect on.
  35909. */
  35910. disposeEffects(camera: Camera): void;
  35911. /**
  35912. * @hidden Internal
  35913. */
  35914. _updateEffects(): void;
  35915. /**
  35916. * Internal
  35917. * @returns if all the contained post processes are ready.
  35918. * @hidden
  35919. */
  35920. _isReady(): boolean;
  35921. }
  35922. }
  35923. declare module BABYLON {
  35924. /**
  35925. * Options to be set when merging outputs from the default pipeline.
  35926. */
  35927. class DepthOfFieldMergePostProcessOptions {
  35928. /**
  35929. * The original image to merge on top of
  35930. */
  35931. originalFromInput: PostProcess;
  35932. /**
  35933. * Parameters to perform the merge of the depth of field effect
  35934. */
  35935. depthOfField?: {
  35936. circleOfConfusion: PostProcess;
  35937. blurSteps: Array<PostProcess>;
  35938. };
  35939. /**
  35940. * Parameters to perform the merge of bloom effect
  35941. */
  35942. bloom?: {
  35943. blurred: PostProcess;
  35944. weight: number;
  35945. };
  35946. }
  35947. /**
  35948. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35949. */
  35950. class DepthOfFieldMergePostProcess extends PostProcess {
  35951. private blurSteps;
  35952. /**
  35953. * Creates a new instance of DepthOfFieldMergePostProcess
  35954. * @param name The name of the effect.
  35955. * @param originalFromInput Post process which's input will be used for the merge.
  35956. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35957. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35958. * @param options The required width/height ratio to downsize to before computing the render pass.
  35959. * @param camera The camera to apply the render pass to.
  35960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35961. * @param engine The engine which the post process will be applied. (default: current engine)
  35962. * @param reusable If the post process can be reused on the same frame. (default: false)
  35963. * @param textureType Type of textures used when performing the post process. (default: 0)
  35964. * @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)
  35965. */
  35966. 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);
  35967. /**
  35968. * Updates the effect with the current post process compile time values and recompiles the shader.
  35969. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35970. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35971. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35972. * @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
  35973. * @param onCompiled Called when the shader has been compiled.
  35974. * @param onError Called if there is an error when compiling a shader.
  35975. */
  35976. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35977. }
  35978. }
  35979. declare module BABYLON {
  35980. /**
  35981. * DisplayPassPostProcess which produces an output the same as it's input
  35982. */
  35983. class DisplayPassPostProcess extends PostProcess {
  35984. /**
  35985. * Creates the DisplayPassPostProcess
  35986. * @param name The name of the effect.
  35987. * @param options The required width/height ratio to downsize to before computing the render pass.
  35988. * @param camera The camera to apply the render pass to.
  35989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35990. * @param engine The engine which the post process will be applied. (default: current engine)
  35991. * @param reusable If the post process can be reused on the same frame. (default: false)
  35992. */
  35993. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35994. }
  35995. }
  35996. declare module BABYLON {
  35997. /**
  35998. * 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.
  35999. */
  36000. class ExtractHighlightsPostProcess extends PostProcess {
  36001. /**
  36002. * The luminance threshold, pixels below this value will be set to black.
  36003. */
  36004. threshold: number;
  36005. /** @hidden */
  36006. _exposure: number;
  36007. /**
  36008. * Post process which has the input texture to be used when performing highlight extraction
  36009. * @hidden
  36010. */
  36011. _inputPostProcess: Nullable<PostProcess>;
  36012. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36013. }
  36014. }
  36015. declare module BABYLON {
  36016. /**
  36017. * Applies a kernel filter to the image
  36018. */
  36019. class FilterPostProcess extends PostProcess {
  36020. /** The matrix to be applied to the image */
  36021. kernelMatrix: Matrix;
  36022. /**
  36023. *
  36024. * @param name The name of the effect.
  36025. * @param kernelMatrix The matrix to be applied to the image
  36026. * @param options The required width/height ratio to downsize to before computing the render pass.
  36027. * @param camera The camera to apply the render pass to.
  36028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36029. * @param engine The engine which the post process will be applied. (default: current engine)
  36030. * @param reusable If the post process can be reused on the same frame. (default: false)
  36031. */
  36032. constructor(name: string,
  36033. /** The matrix to be applied to the image */
  36034. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36035. }
  36036. }
  36037. declare module BABYLON {
  36038. /**
  36039. * Fxaa post process
  36040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  36041. */
  36042. class FxaaPostProcess extends PostProcess {
  36043. /** @hidden */
  36044. texelWidth: number;
  36045. /** @hidden */
  36046. texelHeight: number;
  36047. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36048. private _getDefines;
  36049. }
  36050. }
  36051. declare module BABYLON {
  36052. /**
  36053. * The GrainPostProcess adds noise to the image at mid luminance levels
  36054. */
  36055. class GrainPostProcess extends PostProcess {
  36056. /**
  36057. * The intensity of the grain added (default: 30)
  36058. */
  36059. intensity: number;
  36060. /**
  36061. * If the grain should be randomized on every frame
  36062. */
  36063. animated: boolean;
  36064. /**
  36065. * Creates a new instance of @see GrainPostProcess
  36066. * @param name The name of the effect.
  36067. * @param options The required width/height ratio to downsize to before computing the render pass.
  36068. * @param camera The camera to apply the render pass to.
  36069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36070. * @param engine The engine which the post process will be applied. (default: current engine)
  36071. * @param reusable If the post process can be reused on the same frame. (default: false)
  36072. * @param textureType Type of textures used when performing the post process. (default: 0)
  36073. * @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)
  36074. */
  36075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36076. }
  36077. }
  36078. declare module BABYLON {
  36079. /**
  36080. * Extracts highlights from the image
  36081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36082. */
  36083. class HighlightsPostProcess extends PostProcess {
  36084. /**
  36085. * Extracts highlights from the image
  36086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36087. * @param name The name of the effect.
  36088. * @param options The required width/height ratio to downsize to before computing the render pass.
  36089. * @param camera The camera to apply the render pass to.
  36090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36091. * @param engine The engine which the post process will be applied. (default: current engine)
  36092. * @param reusable If the post process can be reused on the same frame. (default: false)
  36093. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  36094. */
  36095. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36096. }
  36097. }
  36098. declare module BABYLON {
  36099. /**
  36100. * ImageProcessingPostProcess
  36101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  36102. */
  36103. class ImageProcessingPostProcess extends PostProcess {
  36104. /**
  36105. * Default configuration related to image processing available in the PBR Material.
  36106. */
  36107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36108. /**
  36109. * Gets the image processing configuration used either in this material.
  36110. */
  36111. /**
  36112. * Sets the Default image processing configuration used either in the this material.
  36113. *
  36114. * If sets to null, the scene one is in use.
  36115. */
  36116. imageProcessingConfiguration: ImageProcessingConfiguration;
  36117. /**
  36118. * Keep track of the image processing observer to allow dispose and replace.
  36119. */
  36120. private _imageProcessingObserver;
  36121. /**
  36122. * Attaches a new image processing configuration to the PBR Material.
  36123. * @param configuration
  36124. */
  36125. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  36126. /**
  36127. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36128. */
  36129. /**
  36130. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36131. */
  36132. colorCurves: Nullable<ColorCurves>;
  36133. /**
  36134. * Gets wether the color curves effect is enabled.
  36135. */
  36136. /**
  36137. * Sets wether the color curves effect is enabled.
  36138. */
  36139. colorCurvesEnabled: boolean;
  36140. /**
  36141. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36142. */
  36143. /**
  36144. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36145. */
  36146. colorGradingTexture: Nullable<BaseTexture>;
  36147. /**
  36148. * Gets wether the color grading effect is enabled.
  36149. */
  36150. /**
  36151. * Gets wether the color grading effect is enabled.
  36152. */
  36153. colorGradingEnabled: boolean;
  36154. /**
  36155. * Gets exposure used in the effect.
  36156. */
  36157. /**
  36158. * Sets exposure used in the effect.
  36159. */
  36160. exposure: number;
  36161. /**
  36162. * Gets wether tonemapping is enabled or not.
  36163. */
  36164. /**
  36165. * Sets wether tonemapping is enabled or not
  36166. */
  36167. toneMappingEnabled: boolean;
  36168. /**
  36169. * Gets contrast used in the effect.
  36170. */
  36171. /**
  36172. * Sets contrast used in the effect.
  36173. */
  36174. contrast: number;
  36175. /**
  36176. * Gets Vignette stretch size.
  36177. */
  36178. /**
  36179. * Sets Vignette stretch size.
  36180. */
  36181. vignetteStretch: number;
  36182. /**
  36183. * Gets Vignette centre X Offset.
  36184. */
  36185. /**
  36186. * Sets Vignette centre X Offset.
  36187. */
  36188. vignetteCentreX: number;
  36189. /**
  36190. * Gets Vignette centre Y Offset.
  36191. */
  36192. /**
  36193. * Sets Vignette centre Y Offset.
  36194. */
  36195. vignetteCentreY: number;
  36196. /**
  36197. * Gets Vignette weight or intensity of the vignette effect.
  36198. */
  36199. /**
  36200. * Sets Vignette weight or intensity of the vignette effect.
  36201. */
  36202. vignetteWeight: number;
  36203. /**
  36204. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36205. * if vignetteEnabled is set to true.
  36206. */
  36207. /**
  36208. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36209. * if vignetteEnabled is set to true.
  36210. */
  36211. vignetteColor: Color4;
  36212. /**
  36213. * Gets Camera field of view used by the Vignette effect.
  36214. */
  36215. /**
  36216. * Sets Camera field of view used by the Vignette effect.
  36217. */
  36218. vignetteCameraFov: number;
  36219. /**
  36220. * Gets the vignette blend mode allowing different kind of effect.
  36221. */
  36222. /**
  36223. * Sets the vignette blend mode allowing different kind of effect.
  36224. */
  36225. vignetteBlendMode: number;
  36226. /**
  36227. * Gets wether the vignette effect is enabled.
  36228. */
  36229. /**
  36230. * Sets wether the vignette effect is enabled.
  36231. */
  36232. vignetteEnabled: boolean;
  36233. private _fromLinearSpace;
  36234. /**
  36235. * Gets wether the input of the processing is in Gamma or Linear Space.
  36236. */
  36237. /**
  36238. * Sets wether the input of the processing is in Gamma or Linear Space.
  36239. */
  36240. fromLinearSpace: boolean;
  36241. /**
  36242. * Defines cache preventing GC.
  36243. */
  36244. private _defines;
  36245. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  36246. /**
  36247. * "ImageProcessingPostProcess"
  36248. * @returns "ImageProcessingPostProcess"
  36249. */
  36250. getClassName(): string;
  36251. protected _updateParameters(): void;
  36252. dispose(camera?: Camera): void;
  36253. }
  36254. }
  36255. declare module BABYLON {
  36256. /**
  36257. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  36258. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  36259. * As an example, all you have to do is to create the post-process:
  36260. * var mb = new BABYLON.MotionBlurPostProcess(
  36261. * 'mb', // The name of the effect.
  36262. * scene, // The scene containing the objects to blur according to their velocity.
  36263. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36264. * camera // The camera to apply the render pass to.
  36265. * );
  36266. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36267. */
  36268. class MotionBlurPostProcess extends PostProcess {
  36269. /**
  36270. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36271. */
  36272. motionStrength: number;
  36273. /**
  36274. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36275. */
  36276. /**
  36277. * Sets the number of iterations to be used for motion blur quality
  36278. */
  36279. motionBlurSamples: number;
  36280. private _motionBlurSamples;
  36281. private _geometryBufferRenderer;
  36282. /**
  36283. * Creates a new instance MotionBlurPostProcess
  36284. * @param name The name of the effect.
  36285. * @param scene The scene containing the objects to blur according to their velocity.
  36286. * @param options The required width/height ratio to downsize to before computing the render pass.
  36287. * @param camera The camera to apply the render pass to.
  36288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36289. * @param engine The engine which the post process will be applied. (default: current engine)
  36290. * @param reusable If the post process can be reused on the same frame. (default: false)
  36291. * @param textureType Type of textures used when performing the post process. (default: 0)
  36292. * @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)
  36293. */
  36294. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36295. /**
  36296. * Disposes the post process.
  36297. * @param camera The camera to dispose the post process on.
  36298. */
  36299. dispose(camera?: Camera): void;
  36300. }
  36301. }
  36302. declare module BABYLON {
  36303. /**
  36304. * PassPostProcess which produces an output the same as it's input
  36305. */
  36306. class PassPostProcess extends PostProcess {
  36307. /**
  36308. * Creates the PassPostProcess
  36309. * @param name The name of the effect.
  36310. * @param options The required width/height ratio to downsize to before computing the render pass.
  36311. * @param camera The camera to apply the render pass to.
  36312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36313. * @param engine The engine which the post process will be applied. (default: current engine)
  36314. * @param reusable If the post process can be reused on the same frame. (default: false)
  36315. * @param textureType The type of texture to be used when performing the post processing.
  36316. * @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)
  36317. */
  36318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36319. }
  36320. /**
  36321. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36322. */
  36323. class PassCubePostProcess extends PostProcess {
  36324. private _face;
  36325. /**
  36326. * Gets or sets the cube face to display.
  36327. * * 0 is +X
  36328. * * 1 is -X
  36329. * * 2 is +Y
  36330. * * 3 is -Y
  36331. * * 4 is +Z
  36332. * * 5 is -Z
  36333. */
  36334. face: number;
  36335. /**
  36336. * Creates the PassCubePostProcess
  36337. * @param name The name of the effect.
  36338. * @param options The required width/height ratio to downsize to before computing the render pass.
  36339. * @param camera The camera to apply the render pass to.
  36340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36341. * @param engine The engine which the post process will be applied. (default: current engine)
  36342. * @param reusable If the post process can be reused on the same frame. (default: false)
  36343. * @param textureType The type of texture to be used when performing the post processing.
  36344. * @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)
  36345. */
  36346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36347. }
  36348. }
  36349. declare module BABYLON {
  36350. /**
  36351. * Size options for a post process
  36352. */
  36353. type PostProcessOptions = {
  36354. width: number;
  36355. height: number;
  36356. };
  36357. /**
  36358. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36359. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36360. */
  36361. class PostProcess {
  36362. /** Name of the PostProcess. */
  36363. name: string;
  36364. /**
  36365. * Width of the texture to apply the post process on
  36366. */
  36367. width: number;
  36368. /**
  36369. * Height of the texture to apply the post process on
  36370. */
  36371. height: number;
  36372. /**
  36373. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36374. * @hidden
  36375. */
  36376. _outputTexture: Nullable<InternalTexture>;
  36377. /**
  36378. * Sampling mode used by the shader
  36379. * See https://doc.babylonjs.com/classes/3.1/texture
  36380. */
  36381. renderTargetSamplingMode: number;
  36382. /**
  36383. * Clear color to use when screen clearing
  36384. */
  36385. clearColor: Color4;
  36386. /**
  36387. * If the buffer needs to be cleared before applying the post process. (default: true)
  36388. * Should be set to false if shader will overwrite all previous pixels.
  36389. */
  36390. autoClear: boolean;
  36391. /**
  36392. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36393. */
  36394. alphaMode: number;
  36395. /**
  36396. * Sets the setAlphaBlendConstants of the babylon engine
  36397. */
  36398. alphaConstants: Color4;
  36399. /**
  36400. * Animations to be used for the post processing
  36401. */
  36402. animations: Animation[];
  36403. /**
  36404. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36405. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36406. */
  36407. enablePixelPerfectMode: boolean;
  36408. /**
  36409. * Force the postprocess to be applied without taking in account viewport
  36410. */
  36411. forceFullscreenViewport: boolean;
  36412. /**
  36413. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36414. *
  36415. * | Value | Type | Description |
  36416. * | ----- | ----------------------------------- | ----------- |
  36417. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36418. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36419. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36420. *
  36421. */
  36422. scaleMode: number;
  36423. /**
  36424. * Force textures to be a power of two (default: false)
  36425. */
  36426. alwaysForcePOT: boolean;
  36427. private _samples;
  36428. /**
  36429. * Number of sample textures (default: 1)
  36430. */
  36431. samples: number;
  36432. /**
  36433. * Modify the scale of the post process to be the same as the viewport (default: false)
  36434. */
  36435. adaptScaleToCurrentViewport: boolean;
  36436. private _camera;
  36437. private _scene;
  36438. private _engine;
  36439. private _options;
  36440. private _reusable;
  36441. private _textureType;
  36442. /**
  36443. * Smart array of input and output textures for the post process.
  36444. * @hidden
  36445. */
  36446. _textures: SmartArray<InternalTexture>;
  36447. /**
  36448. * The index in _textures that corresponds to the output texture.
  36449. * @hidden
  36450. */
  36451. _currentRenderTextureInd: number;
  36452. private _effect;
  36453. private _samplers;
  36454. private _fragmentUrl;
  36455. private _vertexUrl;
  36456. private _parameters;
  36457. private _scaleRatio;
  36458. protected _indexParameters: any;
  36459. private _shareOutputWithPostProcess;
  36460. private _texelSize;
  36461. private _forcedOutputTexture;
  36462. /**
  36463. * An event triggered when the postprocess is activated.
  36464. */
  36465. onActivateObservable: Observable<Camera>;
  36466. private _onActivateObserver;
  36467. /**
  36468. * A function that is added to the onActivateObservable
  36469. */
  36470. onActivate: Nullable<(camera: Camera) => void>;
  36471. /**
  36472. * An event triggered when the postprocess changes its size.
  36473. */
  36474. onSizeChangedObservable: Observable<PostProcess>;
  36475. private _onSizeChangedObserver;
  36476. /**
  36477. * A function that is added to the onSizeChangedObservable
  36478. */
  36479. onSizeChanged: (postProcess: PostProcess) => void;
  36480. /**
  36481. * An event triggered when the postprocess applies its effect.
  36482. */
  36483. onApplyObservable: Observable<Effect>;
  36484. private _onApplyObserver;
  36485. /**
  36486. * A function that is added to the onApplyObservable
  36487. */
  36488. onApply: (effect: Effect) => void;
  36489. /**
  36490. * An event triggered before rendering the postprocess
  36491. */
  36492. onBeforeRenderObservable: Observable<Effect>;
  36493. private _onBeforeRenderObserver;
  36494. /**
  36495. * A function that is added to the onBeforeRenderObservable
  36496. */
  36497. onBeforeRender: (effect: Effect) => void;
  36498. /**
  36499. * An event triggered after rendering the postprocess
  36500. */
  36501. onAfterRenderObservable: Observable<Effect>;
  36502. private _onAfterRenderObserver;
  36503. /**
  36504. * A function that is added to the onAfterRenderObservable
  36505. */
  36506. onAfterRender: (efect: Effect) => void;
  36507. /**
  36508. * 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
  36509. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36510. */
  36511. inputTexture: InternalTexture;
  36512. /**
  36513. * Gets the camera which post process is applied to.
  36514. * @returns The camera the post process is applied to.
  36515. */
  36516. getCamera(): Camera;
  36517. /**
  36518. * Gets the texel size of the postprocess.
  36519. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36520. */
  36521. readonly texelSize: Vector2;
  36522. /**
  36523. * Creates a new instance PostProcess
  36524. * @param name The name of the PostProcess.
  36525. * @param fragmentUrl The url of the fragment shader to be used.
  36526. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36527. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36528. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36529. * @param camera The camera to apply the render pass to.
  36530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36531. * @param engine The engine which the post process will be applied. (default: current engine)
  36532. * @param reusable If the post process can be reused on the same frame. (default: false)
  36533. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36534. * @param textureType Type of textures used when performing the post process. (default: 0)
  36535. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36536. * @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
  36537. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36538. */
  36539. constructor(
  36540. /** Name of the PostProcess. */
  36541. 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);
  36542. /**
  36543. * Gets the engine which this post process belongs to.
  36544. * @returns The engine the post process was enabled with.
  36545. */
  36546. getEngine(): Engine;
  36547. /**
  36548. * The effect that is created when initializing the post process.
  36549. * @returns The created effect corrisponding the the postprocess.
  36550. */
  36551. getEffect(): Effect;
  36552. /**
  36553. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36554. * @param postProcess The post process to share the output with.
  36555. * @returns This post process.
  36556. */
  36557. shareOutputWith(postProcess: PostProcess): PostProcess;
  36558. /**
  36559. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36560. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36561. */
  36562. useOwnOutput(): void;
  36563. /**
  36564. * Updates the effect with the current post process compile time values and recompiles the shader.
  36565. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36566. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36567. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36568. * @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
  36569. * @param onCompiled Called when the shader has been compiled.
  36570. * @param onError Called if there is an error when compiling a shader.
  36571. */
  36572. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36573. /**
  36574. * The post process is reusable if it can be used multiple times within one frame.
  36575. * @returns If the post process is reusable
  36576. */
  36577. isReusable(): boolean;
  36578. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36579. markTextureDirty(): void;
  36580. /**
  36581. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36582. * 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.
  36583. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36584. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36585. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36586. * @returns The target texture that was bound to be written to.
  36587. */
  36588. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36589. /**
  36590. * If the post process is supported.
  36591. */
  36592. readonly isSupported: boolean;
  36593. /**
  36594. * The aspect ratio of the output texture.
  36595. */
  36596. readonly aspectRatio: number;
  36597. /**
  36598. * Get a value indicating if the post-process is ready to be used
  36599. * @returns true if the post-process is ready (shader is compiled)
  36600. */
  36601. isReady(): boolean;
  36602. /**
  36603. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36604. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36605. */
  36606. apply(): Nullable<Effect>;
  36607. private _disposeTextures;
  36608. /**
  36609. * Disposes the post process.
  36610. * @param camera The camera to dispose the post process on.
  36611. */
  36612. dispose(camera?: Camera): void;
  36613. }
  36614. }
  36615. declare module BABYLON {
  36616. /**
  36617. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36618. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36619. */
  36620. class PostProcessManager {
  36621. private _scene;
  36622. private _indexBuffer;
  36623. private _vertexBuffers;
  36624. /**
  36625. * Creates a new instance PostProcess
  36626. * @param scene The scene that the post process is associated with.
  36627. */
  36628. constructor(scene: Scene);
  36629. private _prepareBuffers;
  36630. private _buildIndexBuffer;
  36631. /**
  36632. * Rebuilds the vertex buffers of the manager.
  36633. * @hidden
  36634. */
  36635. _rebuild(): void;
  36636. /**
  36637. * Prepares a frame to be run through a post process.
  36638. * @param sourceTexture The input texture to the post procesess. (default: null)
  36639. * @param postProcesses An array of post processes to be run. (default: null)
  36640. * @returns True if the post processes were able to be run.
  36641. * @hidden
  36642. */
  36643. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36644. /**
  36645. * Manually render a set of post processes to a texture.
  36646. * @param postProcesses An array of post processes to be run.
  36647. * @param targetTexture The target texture to render to.
  36648. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36649. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36650. * @param lodLevel defines which lod of the texture to render to
  36651. */
  36652. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36653. /**
  36654. * Finalize the result of the output of the postprocesses.
  36655. * @param doNotPresent If true the result will not be displayed to the screen.
  36656. * @param targetTexture The target texture to render to.
  36657. * @param faceIndex The index of the face to bind the target texture to.
  36658. * @param postProcesses The array of post processes to render.
  36659. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36660. * @hidden
  36661. */
  36662. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36663. /**
  36664. * Disposes of the post process manager.
  36665. */
  36666. dispose(): void;
  36667. }
  36668. }
  36669. declare module BABYLON {
  36670. /**
  36671. * Post process which applies a refractin texture
  36672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36673. */
  36674. class RefractionPostProcess extends PostProcess {
  36675. /** the base color of the refraction (used to taint the rendering) */
  36676. color: Color3;
  36677. /** simulated refraction depth */
  36678. depth: number;
  36679. /** the coefficient of the base color (0 to remove base color tainting) */
  36680. colorLevel: number;
  36681. private _refTexture;
  36682. private _ownRefractionTexture;
  36683. /**
  36684. * Gets or sets the refraction texture
  36685. * Please note that you are responsible for disposing the texture if you set it manually
  36686. */
  36687. refractionTexture: Texture;
  36688. /**
  36689. * Initializes the RefractionPostProcess
  36690. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36691. * @param name The name of the effect.
  36692. * @param refractionTextureUrl Url of the refraction texture to use
  36693. * @param color the base color of the refraction (used to taint the rendering)
  36694. * @param depth simulated refraction depth
  36695. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36696. * @param camera The camera to apply the render pass to.
  36697. * @param options The required width/height ratio to downsize to before computing the render pass.
  36698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36699. * @param engine The engine which the post process will be applied. (default: current engine)
  36700. * @param reusable If the post process can be reused on the same frame. (default: false)
  36701. */
  36702. constructor(name: string, refractionTextureUrl: string,
  36703. /** the base color of the refraction (used to taint the rendering) */
  36704. color: Color3,
  36705. /** simulated refraction depth */
  36706. depth: number,
  36707. /** the coefficient of the base color (0 to remove base color tainting) */
  36708. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36709. /**
  36710. * Disposes of the post process
  36711. * @param camera Camera to dispose post process on
  36712. */
  36713. dispose(camera: Camera): void;
  36714. }
  36715. }
  36716. declare module BABYLON {
  36717. /**
  36718. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36719. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36720. */
  36721. class SharpenPostProcess extends PostProcess {
  36722. /**
  36723. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36724. */
  36725. colorAmount: number;
  36726. /**
  36727. * How much sharpness should be applied (default: 0.3)
  36728. */
  36729. edgeAmount: number;
  36730. /**
  36731. * Creates a new instance ConvolutionPostProcess
  36732. * @param name The name of the effect.
  36733. * @param options The required width/height ratio to downsize to before computing the render pass.
  36734. * @param camera The camera to apply the render pass to.
  36735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36736. * @param engine The engine which the post process will be applied. (default: current engine)
  36737. * @param reusable If the post process can be reused on the same frame. (default: false)
  36738. * @param textureType Type of textures used when performing the post process. (default: 0)
  36739. * @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)
  36740. */
  36741. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36742. }
  36743. }
  36744. declare module BABYLON {
  36745. /**
  36746. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36747. */
  36748. class StereoscopicInterlacePostProcess extends PostProcess {
  36749. private _stepSize;
  36750. private _passedProcess;
  36751. /**
  36752. * Initializes a StereoscopicInterlacePostProcess
  36753. * @param name The name of the effect.
  36754. * @param rigCameras The rig cameras to be appled to the post process
  36755. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36757. * @param engine The engine which the post process will be applied. (default: current engine)
  36758. * @param reusable If the post process can be reused on the same frame. (default: false)
  36759. */
  36760. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36761. }
  36762. }
  36763. declare module BABYLON {
  36764. /** Defines operator used for tonemapping */
  36765. enum TonemappingOperator {
  36766. /** Hable */
  36767. Hable = 0,
  36768. /** Reinhard */
  36769. Reinhard = 1,
  36770. /** HejiDawson */
  36771. HejiDawson = 2,
  36772. /** Photographic */
  36773. Photographic = 3
  36774. }
  36775. /**
  36776. * Defines a post process to apply tone mapping
  36777. */
  36778. class TonemapPostProcess extends PostProcess {
  36779. private _operator;
  36780. /** Defines the required exposure adjustement */
  36781. exposureAdjustment: number;
  36782. /**
  36783. * Creates a new TonemapPostProcess
  36784. * @param name defines the name of the postprocess
  36785. * @param _operator defines the operator to use
  36786. * @param exposureAdjustment defines the required exposure adjustement
  36787. * @param camera defines the camera to use (can be null)
  36788. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36789. * @param engine defines the hosting engine (can be ignore if camera is set)
  36790. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36791. */
  36792. constructor(name: string, _operator: TonemappingOperator,
  36793. /** Defines the required exposure adjustement */
  36794. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36795. }
  36796. }
  36797. declare module BABYLON {
  36798. /**
  36799. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36800. */
  36801. class VolumetricLightScatteringPostProcess extends PostProcess {
  36802. private _volumetricLightScatteringPass;
  36803. private _volumetricLightScatteringRTT;
  36804. private _viewPort;
  36805. private _screenCoordinates;
  36806. private _cachedDefines;
  36807. /**
  36808. * If not undefined, the mesh position is computed from the attached node position
  36809. */
  36810. attachedNode: {
  36811. position: Vector3;
  36812. };
  36813. /**
  36814. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  36815. */
  36816. customMeshPosition: Vector3;
  36817. /**
  36818. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  36819. */
  36820. useCustomMeshPosition: boolean;
  36821. /**
  36822. * If the post-process should inverse the light scattering direction
  36823. */
  36824. invert: boolean;
  36825. /**
  36826. * The internal mesh used by the post-process
  36827. */
  36828. mesh: Mesh;
  36829. /**
  36830. * @hidden
  36831. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  36832. */
  36833. useDiffuseColor: boolean;
  36834. /**
  36835. * Array containing the excluded meshes not rendered in the internal pass
  36836. */
  36837. excludedMeshes: AbstractMesh[];
  36838. /**
  36839. * Controls the overall intensity of the post-process
  36840. */
  36841. exposure: number;
  36842. /**
  36843. * Dissipates each sample's contribution in range [0, 1]
  36844. */
  36845. decay: number;
  36846. /**
  36847. * Controls the overall intensity of each sample
  36848. */
  36849. weight: number;
  36850. /**
  36851. * Controls the density of each sample
  36852. */
  36853. density: number;
  36854. /**
  36855. * @constructor
  36856. * @param name The post-process name
  36857. * @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)
  36858. * @param camera The camera that the post-process will be attached to
  36859. * @param mesh The mesh used to create the light scattering
  36860. * @param samples The post-process quality, default 100
  36861. * @param samplingModeThe post-process filtering mode
  36862. * @param engine The babylon engine
  36863. * @param reusable If the post-process is reusable
  36864. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  36865. */
  36866. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  36867. /**
  36868. * Returns the string "VolumetricLightScatteringPostProcess"
  36869. * @returns "VolumetricLightScatteringPostProcess"
  36870. */
  36871. getClassName(): string;
  36872. private _isReady;
  36873. /**
  36874. * Sets the new light position for light scattering effect
  36875. * @param position The new custom light position
  36876. */
  36877. setCustomMeshPosition(position: Vector3): void;
  36878. /**
  36879. * Returns the light position for light scattering effect
  36880. * @return Vector3 The custom light position
  36881. */
  36882. getCustomMeshPosition(): Vector3;
  36883. /**
  36884. * Disposes the internal assets and detaches the post-process from the camera
  36885. */
  36886. dispose(camera: Camera): void;
  36887. /**
  36888. * Returns the render target texture used by the post-process
  36889. * @return the render target texture used by the post-process
  36890. */
  36891. getPass(): RenderTargetTexture;
  36892. private _meshExcluded;
  36893. private _createPass;
  36894. private _updateMeshScreenCoordinates;
  36895. /**
  36896. * Creates a default mesh for the Volumeric Light Scattering post-process
  36897. * @param name The mesh name
  36898. * @param scene The scene where to create the mesh
  36899. * @return the default mesh
  36900. */
  36901. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36902. }
  36903. }
  36904. declare module BABYLON {
  36905. /**
  36906. * VRDistortionCorrectionPostProcess used for mobile VR
  36907. */
  36908. class VRDistortionCorrectionPostProcess extends PostProcess {
  36909. private _isRightEye;
  36910. private _distortionFactors;
  36911. private _postProcessScaleFactor;
  36912. private _lensCenterOffset;
  36913. private _scaleIn;
  36914. private _scaleFactor;
  36915. private _lensCenter;
  36916. /**
  36917. * Initializes the VRDistortionCorrectionPostProcess
  36918. * @param name The name of the effect.
  36919. * @param camera The camera to apply the render pass to.
  36920. * @param isRightEye If this is for the right eye distortion
  36921. * @param vrMetrics All the required metrics for the VR camera
  36922. */
  36923. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  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. * The name of the behavior
  41219. */
  41220. readonly name: string;
  41221. /**
  41222. * Initializes the behavior
  41223. */
  41224. init(): void;
  41225. private _tmpVector;
  41226. private _alternatePickedPoint;
  41227. private _worldDragAxis;
  41228. private _targetPosition;
  41229. private _attachedElement;
  41230. /**
  41231. * Attaches the drag behavior the passed in mesh
  41232. * @param ownerNode The mesh that will be dragged around once attached
  41233. */
  41234. attach(ownerNode: AbstractMesh): void;
  41235. /**
  41236. * Force relase the drag action by code.
  41237. */
  41238. releaseDrag(): void;
  41239. private _startDragRay;
  41240. private _lastPointerRay;
  41241. /**
  41242. * Simulates the start of a pointer drag event on the behavior
  41243. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41244. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41245. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41246. */
  41247. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41248. private _startDrag;
  41249. private _dragDelta;
  41250. private _moveDrag;
  41251. private _pickWithRayOnDragPlane;
  41252. private _pointA;
  41253. private _pointB;
  41254. private _pointC;
  41255. private _lineA;
  41256. private _lineB;
  41257. private _localAxis;
  41258. private _lookAt;
  41259. private _updateDragPlanePosition;
  41260. /**
  41261. * Detaches the behavior from the mesh
  41262. */
  41263. detach(): void;
  41264. }
  41265. }
  41266. declare module BABYLON {
  41267. /**
  41268. * 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
  41269. */
  41270. class SixDofDragBehavior implements Behavior<Mesh> {
  41271. private static _virtualScene;
  41272. private _ownerNode;
  41273. private _sceneRenderObserver;
  41274. private _scene;
  41275. private _targetPosition;
  41276. private _virtualOriginMesh;
  41277. private _virtualDragMesh;
  41278. private _pointerObserver;
  41279. private _moving;
  41280. private _startingOrientation;
  41281. /**
  41282. * 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)
  41283. */
  41284. private zDragFactor;
  41285. /**
  41286. * If the object should rotate to face the drag origin
  41287. */
  41288. rotateDraggedObject: boolean;
  41289. /**
  41290. * If the behavior is currently in a dragging state
  41291. */
  41292. dragging: boolean;
  41293. /**
  41294. * 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)
  41295. */
  41296. dragDeltaRatio: number;
  41297. /**
  41298. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41299. */
  41300. currentDraggingPointerID: number;
  41301. /**
  41302. * If camera controls should be detached during the drag
  41303. */
  41304. detachCameraControls: boolean;
  41305. /**
  41306. * Fires each time a drag starts
  41307. */
  41308. onDragStartObservable: Observable<{}>;
  41309. /**
  41310. * Fires each time a drag ends (eg. mouse release after drag)
  41311. */
  41312. onDragEndObservable: Observable<{}>;
  41313. /**
  41314. * 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
  41315. */
  41316. constructor();
  41317. /**
  41318. * The name of the behavior
  41319. */
  41320. readonly name: string;
  41321. /**
  41322. * Initializes the behavior
  41323. */
  41324. init(): void;
  41325. /**
  41326. * Attaches the scale behavior the passed in mesh
  41327. * @param ownerNode The mesh that will be scaled around once attached
  41328. */
  41329. attach(ownerNode: Mesh): void;
  41330. /**
  41331. * Detaches the behavior from the mesh
  41332. */
  41333. detach(): void;
  41334. }
  41335. }
  41336. declare module BABYLON {
  41337. /**
  41338. * Contains an array of blocks representing the octree
  41339. */
  41340. interface IOctreeContainer<T> {
  41341. /**
  41342. * Blocks within the octree
  41343. */
  41344. blocks: Array<OctreeBlock<T>>;
  41345. }
  41346. /**
  41347. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41349. */
  41350. class Octree<T> {
  41351. /** 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.) */
  41352. maxDepth: number;
  41353. /**
  41354. * Blocks within the octree containing objects
  41355. */
  41356. blocks: Array<OctreeBlock<T>>;
  41357. /**
  41358. * Content stored in the octree
  41359. */
  41360. dynamicContent: T[];
  41361. private _maxBlockCapacity;
  41362. private _selectionContent;
  41363. private _creationFunc;
  41364. /**
  41365. * Creates a octree
  41366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41367. * @param creationFunc function to be used to instatiate the octree
  41368. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41369. * @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.)
  41370. */
  41371. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41372. /** 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.) */
  41373. maxDepth?: number);
  41374. /**
  41375. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41376. * @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);
  41377. * @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);
  41378. * @param entries meshes to be added to the octree blocks
  41379. */
  41380. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41381. /**
  41382. * Adds a mesh to the octree
  41383. * @param entry Mesh to add to the octree
  41384. */
  41385. addMesh(entry: T): void;
  41386. /**
  41387. * Selects an array of meshes within the frustum
  41388. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41389. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41390. * @returns array of meshes within the frustum
  41391. */
  41392. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41393. /**
  41394. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41395. * @param sphereCenter defines the bounding sphere center
  41396. * @param sphereRadius defines the bounding sphere radius
  41397. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41398. * @returns an array of objects that intersect the sphere
  41399. */
  41400. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41401. /**
  41402. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41403. * @param ray defines the ray to test with
  41404. * @returns array of intersected objects
  41405. */
  41406. intersectsRay(ray: Ray): SmartArray<T>;
  41407. /**
  41408. * @hidden
  41409. */
  41410. 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;
  41411. /**
  41412. * Adds a mesh into the octree block if it intersects the block
  41413. */
  41414. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41415. /**
  41416. * Adds a submesh into the octree block if it intersects the block
  41417. */
  41418. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41419. }
  41420. }
  41421. declare module BABYLON {
  41422. /**
  41423. * Class used to store a cell in an octree
  41424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41425. */
  41426. class OctreeBlock<T> {
  41427. /**
  41428. * Gets the content of the current block
  41429. */
  41430. entries: T[];
  41431. /**
  41432. * Gets the list of block children
  41433. */
  41434. blocks: Array<OctreeBlock<T>>;
  41435. private _depth;
  41436. private _maxDepth;
  41437. private _capacity;
  41438. private _minPoint;
  41439. private _maxPoint;
  41440. private _boundingVectors;
  41441. private _creationFunc;
  41442. /**
  41443. * Creates a new block
  41444. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41445. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41446. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41447. * @param depth defines the current depth of this block in the octree
  41448. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41449. * @param creationFunc defines a callback to call when an element is added to the block
  41450. */
  41451. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41452. /**
  41453. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41454. */
  41455. readonly capacity: number;
  41456. /**
  41457. * Gets the minimum vector (in world space) of the block's bounding box
  41458. */
  41459. readonly minPoint: Vector3;
  41460. /**
  41461. * Gets the maximum vector (in world space) of the block's bounding box
  41462. */
  41463. readonly maxPoint: Vector3;
  41464. /**
  41465. * Add a new element to this block
  41466. * @param entry defines the element to add
  41467. */
  41468. addEntry(entry: T): void;
  41469. /**
  41470. * Add an array of elements to this block
  41471. * @param entries defines the array of elements to add
  41472. */
  41473. addEntries(entries: T[]): void;
  41474. /**
  41475. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41476. * @param frustumPlanes defines the frustum planes to test
  41477. * @param selection defines the array to store current content if selection is positive
  41478. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41479. */
  41480. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41481. /**
  41482. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41483. * @param sphereCenter defines the bounding sphere center
  41484. * @param sphereRadius defines the bounding sphere radius
  41485. * @param selection defines the array to store current content if selection is positive
  41486. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41487. */
  41488. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41489. /**
  41490. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41491. * @param ray defines the ray to test with
  41492. * @param selection defines the array to store current content if selection is positive
  41493. */
  41494. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41495. /**
  41496. * Subdivide the content into child blocks (this block will then be empty)
  41497. */
  41498. createInnerBlocks(): void;
  41499. }
  41500. }
  41501. declare module BABYLON {
  41502. interface Scene {
  41503. /**
  41504. * @hidden
  41505. * Backing Filed
  41506. */
  41507. _selectionOctree: Octree<AbstractMesh>;
  41508. /**
  41509. * Gets the octree used to boost mesh selection (picking)
  41510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41511. */
  41512. selectionOctree: Octree<AbstractMesh>;
  41513. /**
  41514. * Creates or updates the octree used to boost selection (picking)
  41515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41516. * @param maxCapacity defines the maximum capacity per leaf
  41517. * @param maxDepth defines the maximum depth of the octree
  41518. * @returns an octree of AbstractMesh
  41519. */
  41520. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41521. }
  41522. interface AbstractMesh {
  41523. /**
  41524. * @hidden
  41525. * Backing Field
  41526. */
  41527. _submeshesOctree: Octree<SubMesh>;
  41528. /**
  41529. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41530. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41531. * @param maxCapacity defines the maximum size of each block (64 by default)
  41532. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41533. * @returns the new octree
  41534. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41536. */
  41537. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41538. }
  41539. /**
  41540. * Defines the octree scene component responsible to manage any octrees
  41541. * in a given scene.
  41542. */
  41543. class OctreeSceneComponent {
  41544. /**
  41545. * The component name helpfull to identify the component in the list of scene components.
  41546. */
  41547. readonly name: string;
  41548. /**
  41549. * The scene the component belongs to.
  41550. */
  41551. scene: Scene;
  41552. /**
  41553. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41554. */
  41555. readonly checksIsEnabled: boolean;
  41556. /**
  41557. * Creates a new instance of the component for the given scene
  41558. * @param scene Defines the scene to register the component in
  41559. */
  41560. constructor(scene: Scene);
  41561. /**
  41562. * Registers the component in a given scene
  41563. */
  41564. register(): void;
  41565. /**
  41566. * Return the list of active meshes
  41567. * @returns the list of active meshes
  41568. */
  41569. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41570. /**
  41571. * Return the list of active sub meshes
  41572. * @param mesh The mesh to get the candidates sub meshes from
  41573. * @returns the list of active sub meshes
  41574. */
  41575. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41576. private _tempRay;
  41577. /**
  41578. * Return the list of sub meshes intersecting with a given local ray
  41579. * @param mesh defines the mesh to find the submesh for
  41580. * @param localRay defines the ray in local space
  41581. * @returns the list of intersecting sub meshes
  41582. */
  41583. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41584. /**
  41585. * Return the list of sub meshes colliding with a collider
  41586. * @param mesh defines the mesh to find the submesh for
  41587. * @param collider defines the collider to evaluate the collision against
  41588. * @returns the list of colliding sub meshes
  41589. */
  41590. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41591. /**
  41592. * Rebuilds the elements related to this component in case of
  41593. * context lost for instance.
  41594. */
  41595. rebuild(): void;
  41596. /**
  41597. * Disposes the component and the associated ressources.
  41598. */
  41599. dispose(): void;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Manage the gamepad inputs to control an arc rotate camera.
  41605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41606. */
  41607. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41608. /**
  41609. * Defines the camera the input is attached to.
  41610. */
  41611. camera: ArcRotateCamera;
  41612. /**
  41613. * Defines the gamepad the input is gathering event from.
  41614. */
  41615. gamepad: Nullable<Gamepad>;
  41616. /**
  41617. * Defines the gamepad rotation sensiblity.
  41618. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41619. */
  41620. gamepadRotationSensibility: number;
  41621. /**
  41622. * Defines the gamepad move sensiblity.
  41623. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41624. */
  41625. gamepadMoveSensibility: number;
  41626. private _onGamepadConnectedObserver;
  41627. private _onGamepadDisconnectedObserver;
  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. /**
  41635. * Detach the current controls from the specified dom element.
  41636. * @param element Defines the element to stop listening the inputs from
  41637. */
  41638. detachControl(element: Nullable<HTMLElement>): void;
  41639. /**
  41640. * Update the current camera state depending on the inputs that have been used this frame.
  41641. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41642. */
  41643. checkInputs(): void;
  41644. /**
  41645. * Gets the class name of the current intput.
  41646. * @returns the class name
  41647. */
  41648. getClassName(): string;
  41649. /**
  41650. * Get the friendly name associated with the input class.
  41651. * @returns the input friendly name
  41652. */
  41653. getSimpleName(): string;
  41654. }
  41655. }
  41656. declare module BABYLON {
  41657. /**
  41658. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41660. */
  41661. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41662. /**
  41663. * Defines the camera the input is attached to.
  41664. */
  41665. camera: ArcRotateCamera;
  41666. /**
  41667. * Defines the list of key codes associated with the up action (increase alpha)
  41668. */
  41669. keysUp: number[];
  41670. /**
  41671. * Defines the list of key codes associated with the down action (decrease alpha)
  41672. */
  41673. keysDown: number[];
  41674. /**
  41675. * Defines the list of key codes associated with the left action (increase beta)
  41676. */
  41677. keysLeft: number[];
  41678. /**
  41679. * Defines the list of key codes associated with the right action (decrease beta)
  41680. */
  41681. keysRight: number[];
  41682. /**
  41683. * Defines the list of key codes associated with the reset action.
  41684. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41685. */
  41686. keysReset: number[];
  41687. /**
  41688. * Defines the panning sensibility of the inputs.
  41689. * (How fast is the camera paning)
  41690. */
  41691. panningSensibility: number;
  41692. /**
  41693. * Defines the zooming sensibility of the inputs.
  41694. * (How fast is the camera zooming)
  41695. */
  41696. zoomingSensibility: number;
  41697. /**
  41698. * Defines wether maintaining the alt key down switch the movement mode from
  41699. * orientation to zoom.
  41700. */
  41701. useAltToZoom: boolean;
  41702. /**
  41703. * Rotation speed of the camera
  41704. */
  41705. angularSpeed: number;
  41706. private _keys;
  41707. private _ctrlPressed;
  41708. private _altPressed;
  41709. private _onCanvasBlurObserver;
  41710. private _onKeyboardObserver;
  41711. private _engine;
  41712. private _scene;
  41713. /**
  41714. * Attach the input controls to a specific dom element to get the input from.
  41715. * @param element Defines the element the controls should be listened from
  41716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41717. */
  41718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41719. /**
  41720. * Detach the current controls from the specified dom element.
  41721. * @param element Defines the element to stop listening the inputs from
  41722. */
  41723. detachControl(element: Nullable<HTMLElement>): void;
  41724. /**
  41725. * Update the current camera state depending on the inputs that have been used this frame.
  41726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41727. */
  41728. checkInputs(): void;
  41729. /**
  41730. * Gets the class name of the current intput.
  41731. * @returns the class name
  41732. */
  41733. getClassName(): string;
  41734. /**
  41735. * Get the friendly name associated with the input class.
  41736. * @returns the input friendly name
  41737. */
  41738. getSimpleName(): string;
  41739. }
  41740. }
  41741. declare module BABYLON {
  41742. /**
  41743. * Manage the mouse wheel inputs to control an arc rotate camera.
  41744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41745. */
  41746. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41747. /**
  41748. * Defines the camera the input is attached to.
  41749. */
  41750. camera: ArcRotateCamera;
  41751. /**
  41752. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41753. */
  41754. wheelPrecision: number;
  41755. /**
  41756. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41757. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41758. */
  41759. wheelDeltaPercentage: number;
  41760. private _wheel;
  41761. private _observer;
  41762. /**
  41763. * Attach the input controls to a specific dom element to get the input from.
  41764. * @param element Defines the element the controls should be listened from
  41765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41766. */
  41767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41768. /**
  41769. * Detach the current controls from the specified dom element.
  41770. * @param element Defines the element to stop listening the inputs from
  41771. */
  41772. detachControl(element: Nullable<HTMLElement>): void;
  41773. /**
  41774. * Gets the class name of the current intput.
  41775. * @returns the class name
  41776. */
  41777. getClassName(): string;
  41778. /**
  41779. * Get the friendly name associated with the input class.
  41780. * @returns the input friendly name
  41781. */
  41782. getSimpleName(): string;
  41783. }
  41784. }
  41785. declare module BABYLON {
  41786. /**
  41787. * Manage the pointers inputs to control an arc rotate camera.
  41788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41789. */
  41790. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41791. /**
  41792. * Defines the camera the input is attached to.
  41793. */
  41794. camera: ArcRotateCamera;
  41795. /**
  41796. * Defines the buttons associated with the input to handle camera move.
  41797. */
  41798. buttons: number[];
  41799. /**
  41800. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41801. */
  41802. angularSensibilityX: number;
  41803. /**
  41804. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41805. */
  41806. angularSensibilityY: number;
  41807. /**
  41808. * Defines the pointer pinch precision or how fast is the camera zooming.
  41809. */
  41810. pinchPrecision: number;
  41811. /**
  41812. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41813. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41814. */
  41815. pinchDeltaPercentage: number;
  41816. /**
  41817. * Defines the pointer panning sensibility or how fast is the camera moving.
  41818. */
  41819. panningSensibility: number;
  41820. /**
  41821. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41822. */
  41823. multiTouchPanning: boolean;
  41824. /**
  41825. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41826. */
  41827. multiTouchPanAndZoom: boolean;
  41828. /**
  41829. * Revers pinch action direction.
  41830. */
  41831. pinchInwards: boolean;
  41832. private _isPanClick;
  41833. private _pointerInput;
  41834. private _observer;
  41835. private _onMouseMove;
  41836. private _onGestureStart;
  41837. private _onGesture;
  41838. private _MSGestureHandler;
  41839. private _onLostFocus;
  41840. private _onContextMenu;
  41841. /**
  41842. * Attach the input controls to a specific dom element to get the input from.
  41843. * @param element Defines the element the controls should be listened from
  41844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41845. */
  41846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41847. /**
  41848. * Detach the current controls from the specified dom element.
  41849. * @param element Defines the element to stop listening the inputs from
  41850. */
  41851. detachControl(element: Nullable<HTMLElement>): 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 device orientation inputs (gyroscope) to control an arc rotate camera.
  41867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41868. */
  41869. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41870. /**
  41871. * Defines the camera the input is attached to.
  41872. */
  41873. camera: ArcRotateCamera;
  41874. /**
  41875. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41876. */
  41877. alphaCorrection: number;
  41878. /**
  41879. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41880. */
  41881. gammaCorrection: number;
  41882. private _alpha;
  41883. private _gamma;
  41884. private _dirty;
  41885. private _deviceOrientationHandler;
  41886. /**
  41887. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41888. */
  41889. constructor();
  41890. /**
  41891. * Attach the input controls to a specific dom element to get the input from.
  41892. * @param element Defines the element the controls should be listened from
  41893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41894. */
  41895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41896. /** @hidden */
  41897. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41898. /**
  41899. * Update the current camera state depending on the inputs that have been used this frame.
  41900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41901. */
  41902. checkInputs(): void;
  41903. /**
  41904. * Detach the current controls from the specified dom element.
  41905. * @param element Defines the element to stop listening the inputs from
  41906. */
  41907. detachControl(element: Nullable<HTMLElement>): void;
  41908. /**
  41909. * Gets the class name of the current intput.
  41910. * @returns the class name
  41911. */
  41912. getClassName(): string;
  41913. /**
  41914. * Get the friendly name associated with the input class.
  41915. * @returns the input friendly name
  41916. */
  41917. getSimpleName(): string;
  41918. }
  41919. }
  41920. declare module BABYLON {
  41921. /**
  41922. * Listen to keyboard events to control the camera.
  41923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41924. */
  41925. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41926. /**
  41927. * Defines the camera the input is attached to.
  41928. */
  41929. camera: FlyCamera;
  41930. /**
  41931. * The list of keyboard keys used to control the forward move of the camera.
  41932. */
  41933. keysForward: number[];
  41934. /**
  41935. * The list of keyboard keys used to control the backward move of the camera.
  41936. */
  41937. keysBackward: number[];
  41938. /**
  41939. * The list of keyboard keys used to control the forward move of the camera.
  41940. */
  41941. keysUp: number[];
  41942. /**
  41943. * The list of keyboard keys used to control the backward move of the camera.
  41944. */
  41945. keysDown: number[];
  41946. /**
  41947. * The list of keyboard keys used to control the right strafe move of the camera.
  41948. */
  41949. keysRight: number[];
  41950. /**
  41951. * The list of keyboard keys used to control the left strafe move of the camera.
  41952. */
  41953. keysLeft: number[];
  41954. private _keys;
  41955. private _onCanvasBlurObserver;
  41956. private _onKeyboardObserver;
  41957. private _engine;
  41958. private _scene;
  41959. /**
  41960. * Attach the input controls to a specific dom element to get the input from.
  41961. * @param element Defines the element the controls should be listened from
  41962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41963. */
  41964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41965. /**
  41966. * Detach the current controls from the specified dom element.
  41967. * @param element Defines the element to stop listening the inputs from
  41968. */
  41969. detachControl(element: Nullable<HTMLElement>): void;
  41970. /**
  41971. * Gets the class name of the current intput.
  41972. * @returns the class name
  41973. */
  41974. getClassName(): string;
  41975. /** @hidden */
  41976. _onLostFocus(e: FocusEvent): void;
  41977. /**
  41978. * Get the friendly name associated with the input class.
  41979. * @returns the input friendly name
  41980. */
  41981. getSimpleName(): string;
  41982. /**
  41983. * Update the current camera state depending on the inputs that have been used this frame.
  41984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41985. */
  41986. checkInputs(): void;
  41987. }
  41988. }
  41989. declare module BABYLON {
  41990. /**
  41991. * Listen to mouse events to control the camera.
  41992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41993. */
  41994. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41995. /**
  41996. * Defines the camera the input is attached to.
  41997. */
  41998. camera: FlyCamera;
  41999. /**
  42000. * Defines if touch is enabled. (Default is true.)
  42001. */
  42002. touchEnabled: boolean;
  42003. /**
  42004. * Defines the buttons associated with the input to handle camera rotation.
  42005. */
  42006. buttons: number[];
  42007. /**
  42008. * Assign buttons for Yaw control.
  42009. */
  42010. buttonsYaw: number[];
  42011. /**
  42012. * Assign buttons for Pitch control.
  42013. */
  42014. buttonsPitch: number[];
  42015. /**
  42016. * Assign buttons for Roll control.
  42017. */
  42018. buttonsRoll: number[];
  42019. /**
  42020. * Detect if any button is being pressed while mouse is moved.
  42021. * -1 = Mouse locked.
  42022. * 0 = Left button.
  42023. * 1 = Middle Button.
  42024. * 2 = Right Button.
  42025. */
  42026. activeButton: number;
  42027. /**
  42028. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42029. * Higher values reduce its sensitivity.
  42030. */
  42031. angularSensibility: number;
  42032. private _mousemoveCallback;
  42033. private _observer;
  42034. private _rollObserver;
  42035. private previousPosition;
  42036. private noPreventDefault;
  42037. private element;
  42038. /**
  42039. * Listen to mouse events to control the camera.
  42040. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42042. */
  42043. constructor(touchEnabled?: boolean);
  42044. /**
  42045. * Attach the mouse control to the HTML DOM element.
  42046. * @param element Defines the element that listens to the input events.
  42047. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42048. */
  42049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42050. /**
  42051. * Detach the current controls from the specified dom element.
  42052. * @param element Defines the element to stop listening the inputs from
  42053. */
  42054. detachControl(element: Nullable<HTMLElement>): void;
  42055. /**
  42056. * Gets the class name of the current input.
  42057. * @returns the class name.
  42058. */
  42059. getClassName(): string;
  42060. /**
  42061. * Get the friendly name associated with the input class.
  42062. * @returns the input's friendly name.
  42063. */
  42064. getSimpleName(): string;
  42065. private _pointerInput;
  42066. private _onMouseMove;
  42067. /**
  42068. * Rotate camera by mouse offset.
  42069. */
  42070. private rotateCamera;
  42071. }
  42072. }
  42073. declare module BABYLON {
  42074. /**
  42075. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42076. * Screen rotation is taken into account.
  42077. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42078. */
  42079. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42080. private _camera;
  42081. private _screenOrientationAngle;
  42082. private _constantTranform;
  42083. private _screenQuaternion;
  42084. private _alpha;
  42085. private _beta;
  42086. private _gamma;
  42087. /**
  42088. * Instantiates a new input
  42089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42090. */
  42091. constructor();
  42092. /**
  42093. * Define the camera controlled by the input.
  42094. */
  42095. camera: FreeCamera;
  42096. /**
  42097. * Attach the input controls to a specific dom element to get the input from.
  42098. * @param element Defines the element the controls should be listened from
  42099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42100. */
  42101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42102. private _orientationChanged;
  42103. private _deviceOrientation;
  42104. /**
  42105. * Detach the current controls from the specified dom element.
  42106. * @param element Defines the element to stop listening the inputs from
  42107. */
  42108. detachControl(element: Nullable<HTMLElement>): void;
  42109. /**
  42110. * Update the current camera state depending on the inputs that have been used this frame.
  42111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42112. */
  42113. checkInputs(): void;
  42114. /**
  42115. * Gets the class name of the current intput.
  42116. * @returns the class name
  42117. */
  42118. getClassName(): string;
  42119. /**
  42120. * Get the friendly name associated with the input class.
  42121. * @returns the input friendly name
  42122. */
  42123. getSimpleName(): string;
  42124. }
  42125. }
  42126. declare module BABYLON {
  42127. /**
  42128. * Manage the gamepad inputs to control a free camera.
  42129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42130. */
  42131. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42132. /**
  42133. * Define the camera the input is attached to.
  42134. */
  42135. camera: FreeCamera;
  42136. /**
  42137. * Define the Gamepad controlling the input
  42138. */
  42139. gamepad: Nullable<Gamepad>;
  42140. /**
  42141. * Defines the gamepad rotation sensiblity.
  42142. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42143. */
  42144. gamepadAngularSensibility: number;
  42145. /**
  42146. * Defines the gamepad move sensiblity.
  42147. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42148. */
  42149. gamepadMoveSensibility: number;
  42150. private _onGamepadConnectedObserver;
  42151. private _onGamepadDisconnectedObserver;
  42152. private _cameraTransform;
  42153. private _deltaTransform;
  42154. private _vector3;
  42155. private _vector2;
  42156. /**
  42157. * Attach the input controls to a specific dom element to get the input from.
  42158. * @param element Defines the element the controls should be listened from
  42159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42160. */
  42161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42162. /**
  42163. * Detach the current controls from the specified dom element.
  42164. * @param element Defines the element to stop listening the inputs from
  42165. */
  42166. detachControl(element: Nullable<HTMLElement>): void;
  42167. /**
  42168. * Update the current camera state depending on the inputs that have been used this frame.
  42169. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42170. */
  42171. checkInputs(): void;
  42172. /**
  42173. * Gets the class name of the current intput.
  42174. * @returns the class name
  42175. */
  42176. getClassName(): string;
  42177. /**
  42178. * Get the friendly name associated with the input class.
  42179. * @returns the input friendly name
  42180. */
  42181. getSimpleName(): string;
  42182. }
  42183. }
  42184. declare module BABYLON {
  42185. /**
  42186. * Manage the keyboard inputs to control the movement of a free camera.
  42187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42188. */
  42189. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42190. /**
  42191. * Defines the camera the input is attached to.
  42192. */
  42193. camera: FreeCamera;
  42194. /**
  42195. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42196. */
  42197. keysUp: number[];
  42198. /**
  42199. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42200. */
  42201. keysDown: number[];
  42202. /**
  42203. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42204. */
  42205. keysLeft: number[];
  42206. /**
  42207. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42208. */
  42209. keysRight: number[];
  42210. private _keys;
  42211. private _onCanvasBlurObserver;
  42212. private _onKeyboardObserver;
  42213. private _engine;
  42214. private _scene;
  42215. /**
  42216. * Attach the input controls to a specific dom element to get the input from.
  42217. * @param element Defines the element the controls should be listened from
  42218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42219. */
  42220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42221. /**
  42222. * Detach the current controls from the specified dom element.
  42223. * @param element Defines the element to stop listening the inputs from
  42224. */
  42225. detachControl(element: Nullable<HTMLElement>): void;
  42226. /**
  42227. * Update the current camera state depending on the inputs that have been used this frame.
  42228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42229. */
  42230. checkInputs(): void;
  42231. /**
  42232. * Gets the class name of the current intput.
  42233. * @returns the class name
  42234. */
  42235. getClassName(): string;
  42236. /** @hidden */
  42237. _onLostFocus(e: FocusEvent): void;
  42238. /**
  42239. * Get the friendly name associated with the input class.
  42240. * @returns the input friendly name
  42241. */
  42242. getSimpleName(): string;
  42243. }
  42244. }
  42245. declare module BABYLON {
  42246. /**
  42247. * Manage the mouse inputs to control the movement of a free camera.
  42248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42249. */
  42250. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42251. /**
  42252. * Define if touch is enabled in the mouse input
  42253. */
  42254. touchEnabled: boolean;
  42255. /**
  42256. * Defines the camera the input is attached to.
  42257. */
  42258. camera: FreeCamera;
  42259. /**
  42260. * Defines the buttons associated with the input to handle camera move.
  42261. */
  42262. buttons: number[];
  42263. /**
  42264. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42265. */
  42266. angularSensibility: number;
  42267. private _pointerInput;
  42268. private _onMouseMove;
  42269. private _observer;
  42270. private previousPosition;
  42271. /**
  42272. * Manage the mouse inputs to control the movement of a free camera.
  42273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42274. * @param touchEnabled Defines if touch is enabled or not
  42275. */
  42276. constructor(
  42277. /**
  42278. * Define if touch is enabled in the mouse input
  42279. */
  42280. touchEnabled?: boolean);
  42281. /**
  42282. * Attach the input controls to a specific dom element to get the input from.
  42283. * @param element Defines the element the controls should be listened from
  42284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42285. */
  42286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42287. /**
  42288. * Detach the current controls from the specified dom element.
  42289. * @param element Defines the element to stop listening the inputs from
  42290. */
  42291. detachControl(element: Nullable<HTMLElement>): void;
  42292. /**
  42293. * Gets the class name of the current intput.
  42294. * @returns the class name
  42295. */
  42296. getClassName(): string;
  42297. /**
  42298. * Get the friendly name associated with the input class.
  42299. * @returns the input friendly name
  42300. */
  42301. getSimpleName(): string;
  42302. }
  42303. }
  42304. declare module BABYLON {
  42305. /**
  42306. * Manage the touch inputs to control the movement of a free camera.
  42307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42308. */
  42309. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42310. /**
  42311. * Defines the camera the input is attached to.
  42312. */
  42313. camera: FreeCamera;
  42314. /**
  42315. * Defines the touch sensibility for rotation.
  42316. * The higher the faster.
  42317. */
  42318. touchAngularSensibility: number;
  42319. /**
  42320. * Defines the touch sensibility for move.
  42321. * The higher the faster.
  42322. */
  42323. touchMoveSensibility: number;
  42324. private _offsetX;
  42325. private _offsetY;
  42326. private _pointerPressed;
  42327. private _pointerInput;
  42328. private _observer;
  42329. private _onLostFocus;
  42330. /**
  42331. * Attach the input controls to a specific dom element to get the input from.
  42332. * @param element Defines the element the controls should be listened from
  42333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42334. */
  42335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42336. /**
  42337. * Detach the current controls from the specified dom element.
  42338. * @param element Defines the element to stop listening the inputs from
  42339. */
  42340. detachControl(element: Nullable<HTMLElement>): void;
  42341. /**
  42342. * Update the current camera state depending on the inputs that have been used this frame.
  42343. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42344. */
  42345. checkInputs(): void;
  42346. /**
  42347. * Gets the class name of the current intput.
  42348. * @returns the class name
  42349. */
  42350. getClassName(): string;
  42351. /**
  42352. * Get the friendly name associated with the input class.
  42353. * @returns the input friendly name
  42354. */
  42355. getSimpleName(): string;
  42356. }
  42357. }
  42358. declare module BABYLON {
  42359. /**
  42360. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42362. */
  42363. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42364. /**
  42365. * Defines the camera the input is attached to.
  42366. */
  42367. camera: FreeCamera;
  42368. private _leftjoystick;
  42369. private _rightjoystick;
  42370. /**
  42371. * Gets the left stick of the virtual joystick.
  42372. * @returns The virtual Joystick
  42373. */
  42374. getLeftJoystick(): VirtualJoystick;
  42375. /**
  42376. * Gets the right stick of the virtual joystick.
  42377. * @returns The virtual Joystick
  42378. */
  42379. getRightJoystick(): VirtualJoystick;
  42380. /**
  42381. * Update the current camera state depending on the inputs that have been used this frame.
  42382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42383. */
  42384. checkInputs(): void;
  42385. /**
  42386. * Attach the input controls to a specific dom element to get the input from.
  42387. * @param element Defines the element the controls should be listened from
  42388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42389. */
  42390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42391. /**
  42392. * Detach the current controls from the specified dom element.
  42393. * @param element Defines the element to stop listening the inputs from
  42394. */
  42395. detachControl(element: Nullable<HTMLElement>): void;
  42396. /**
  42397. * Gets the class name of the current intput.
  42398. * @returns the class name
  42399. */
  42400. getClassName(): string;
  42401. /**
  42402. * Get the friendly name associated with the input class.
  42403. * @returns the input friendly name
  42404. */
  42405. getSimpleName(): string;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42411. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42412. */
  42413. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42414. /**
  42415. * Creates a new AnaglyphArcRotateCamera
  42416. * @param name defines camera name
  42417. * @param alpha defines alpha angle (in radians)
  42418. * @param beta defines beta angle (in radians)
  42419. * @param radius defines radius
  42420. * @param target defines camera target
  42421. * @param interaxialDistance defines distance between each color axis
  42422. * @param scene defines the hosting scene
  42423. */
  42424. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42425. /**
  42426. * Gets camera class name
  42427. * @returns AnaglyphArcRotateCamera
  42428. */
  42429. getClassName(): string;
  42430. }
  42431. }
  42432. declare module BABYLON {
  42433. /**
  42434. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42435. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42436. */
  42437. class AnaglyphFreeCamera extends FreeCamera {
  42438. /**
  42439. * Creates a new AnaglyphFreeCamera
  42440. * @param name defines camera name
  42441. * @param position defines initial position
  42442. * @param interaxialDistance defines distance between each color axis
  42443. * @param scene defines the hosting scene
  42444. */
  42445. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42446. /**
  42447. * Gets camera class name
  42448. * @returns AnaglyphFreeCamera
  42449. */
  42450. getClassName(): string;
  42451. }
  42452. }
  42453. declare module BABYLON {
  42454. /**
  42455. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42456. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42457. */
  42458. class AnaglyphGamepadCamera extends GamepadCamera {
  42459. /**
  42460. * Creates a new AnaglyphGamepadCamera
  42461. * @param name defines camera name
  42462. * @param position defines initial position
  42463. * @param interaxialDistance defines distance between each color axis
  42464. * @param scene defines the hosting scene
  42465. */
  42466. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42467. /**
  42468. * Gets camera class name
  42469. * @returns AnaglyphGamepadCamera
  42470. */
  42471. getClassName(): string;
  42472. }
  42473. }
  42474. declare module BABYLON {
  42475. /**
  42476. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42477. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42478. */
  42479. class AnaglyphUniversalCamera extends UniversalCamera {
  42480. /**
  42481. * Creates a new AnaglyphUniversalCamera
  42482. * @param name defines camera name
  42483. * @param position defines initial position
  42484. * @param interaxialDistance defines distance between each color axis
  42485. * @param scene defines the hosting scene
  42486. */
  42487. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42488. /**
  42489. * Gets camera class name
  42490. * @returns AnaglyphUniversalCamera
  42491. */
  42492. getClassName(): string;
  42493. }
  42494. }
  42495. declare module BABYLON {
  42496. /**
  42497. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42498. * @see http://doc.babylonjs.com/features/cameras
  42499. */
  42500. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42501. /**
  42502. * Creates a new StereoscopicArcRotateCamera
  42503. * @param name defines camera name
  42504. * @param alpha defines alpha angle (in radians)
  42505. * @param beta defines beta angle (in radians)
  42506. * @param radius defines radius
  42507. * @param target defines camera target
  42508. * @param interaxialDistance defines distance between each color axis
  42509. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42510. * @param scene defines the hosting scene
  42511. */
  42512. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42513. /**
  42514. * Gets camera class name
  42515. * @returns StereoscopicArcRotateCamera
  42516. */
  42517. getClassName(): string;
  42518. }
  42519. }
  42520. declare module BABYLON {
  42521. /**
  42522. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42523. * @see http://doc.babylonjs.com/features/cameras
  42524. */
  42525. class StereoscopicFreeCamera extends FreeCamera {
  42526. /**
  42527. * Creates a new StereoscopicFreeCamera
  42528. * @param name defines camera name
  42529. * @param position defines initial position
  42530. * @param interaxialDistance defines distance between each color axis
  42531. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42532. * @param scene defines the hosting scene
  42533. */
  42534. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42535. /**
  42536. * Gets camera class name
  42537. * @returns StereoscopicFreeCamera
  42538. */
  42539. getClassName(): string;
  42540. }
  42541. }
  42542. declare module BABYLON {
  42543. /**
  42544. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42545. * @see http://doc.babylonjs.com/features/cameras
  42546. */
  42547. class StereoscopicGamepadCamera extends GamepadCamera {
  42548. /**
  42549. * Creates a new StereoscopicGamepadCamera
  42550. * @param name defines camera name
  42551. * @param position defines initial position
  42552. * @param interaxialDistance defines distance between each color axis
  42553. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42554. * @param scene defines the hosting scene
  42555. */
  42556. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42557. /**
  42558. * Gets camera class name
  42559. * @returns StereoscopicGamepadCamera
  42560. */
  42561. getClassName(): string;
  42562. }
  42563. }
  42564. declare module BABYLON {
  42565. /**
  42566. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42567. * @see http://doc.babylonjs.com/features/cameras
  42568. */
  42569. class StereoscopicUniversalCamera extends UniversalCamera {
  42570. /**
  42571. * Creates a new StereoscopicUniversalCamera
  42572. * @param name defines camera name
  42573. * @param position defines initial position
  42574. * @param interaxialDistance defines distance between each color axis
  42575. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42576. * @param scene defines the hosting scene
  42577. */
  42578. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42579. /**
  42580. * Gets camera class name
  42581. * @returns StereoscopicUniversalCamera
  42582. */
  42583. getClassName(): string;
  42584. }
  42585. }
  42586. declare module BABYLON {
  42587. /**
  42588. * WebXR Camera which holds the views for the xrSession
  42589. * @see https://doc.babylonjs.com/how_to/webxr
  42590. */
  42591. class WebXRCamera extends FreeCamera {
  42592. private static _TmpMatrix;
  42593. /**
  42594. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42595. * @param name the name of the camera
  42596. * @param scene the scene to add the camera to
  42597. */
  42598. constructor(name: string, scene: BABYLON.Scene);
  42599. private _updateNumberOfRigCameras;
  42600. /** @hidden */
  42601. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42602. /**
  42603. * Updates the cameras position from the current pose information of the XR session
  42604. * @param xrSessionManager the session containing pose information
  42605. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42606. */
  42607. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42608. }
  42609. }
  42610. declare module BABYLON {
  42611. /**
  42612. * Button which can be used to enter a different mode of XR
  42613. */
  42614. class WebXREnterExitUIButton {
  42615. /** button element */
  42616. element: HTMLElement;
  42617. /** XR initialization options for the button */
  42618. initializationOptions: XRSessionCreationOptions;
  42619. /**
  42620. * Creates a WebXREnterExitUIButton
  42621. * @param element button element
  42622. * @param initializationOptions XR initialization options for the button
  42623. */
  42624. constructor(
  42625. /** button element */
  42626. element: HTMLElement,
  42627. /** XR initialization options for the button */
  42628. initializationOptions: XRSessionCreationOptions);
  42629. /**
  42630. * Overwritable function which can be used to update the button's visuals when the state changes
  42631. * @param activeButton the current active button in the UI
  42632. */
  42633. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42634. }
  42635. /**
  42636. * Options to create the webXR UI
  42637. */
  42638. class WebXREnterExitUIOptions {
  42639. /**
  42640. * Context to enter xr with
  42641. */
  42642. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42643. /**
  42644. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42645. */
  42646. customButtons?: Array<WebXREnterExitUIButton>;
  42647. }
  42648. /**
  42649. * UI to allow the user to enter/exit XR mode
  42650. */
  42651. class WebXREnterExitUI implements IDisposable {
  42652. private scene;
  42653. private _overlay;
  42654. private _buttons;
  42655. private _activeButton;
  42656. /**
  42657. * Fired every time the active button is changed.
  42658. *
  42659. * When xr is entered via a button that launches xr that button will be the callback parameter
  42660. *
  42661. * When exiting xr the callback parameter will be null)
  42662. */
  42663. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42664. /**
  42665. * Creates UI to allow the user to enter/exit XR mode
  42666. * @param scene the scene to add the ui to
  42667. * @param helper the xr experience helper to enter/exit xr with
  42668. * @param options options to configure the UI
  42669. * @returns the created ui
  42670. */
  42671. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42672. private constructor();
  42673. private _updateButtons;
  42674. /**
  42675. * Disposes of the object
  42676. */
  42677. dispose(): void;
  42678. }
  42679. }
  42680. declare module BABYLON {
  42681. /**
  42682. * States of the webXR experience
  42683. */
  42684. enum WebXRState {
  42685. /**
  42686. * Transitioning to being in XR mode
  42687. */
  42688. ENTERING_XR = 0,
  42689. /**
  42690. * Transitioning to non XR mode
  42691. */
  42692. EXITING_XR = 1,
  42693. /**
  42694. * In XR mode and presenting
  42695. */
  42696. IN_XR = 2,
  42697. /**
  42698. * Not entered XR mode
  42699. */
  42700. NOT_IN_XR = 3
  42701. }
  42702. /**
  42703. * Helper class used to enable XR
  42704. * @see https://doc.babylonjs.com/how_to/webxr
  42705. */
  42706. class WebXRExperienceHelper implements IDisposable {
  42707. private scene;
  42708. /**
  42709. * 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
  42710. */
  42711. container: AbstractMesh;
  42712. /**
  42713. * Camera used to render xr content
  42714. */
  42715. camera: WebXRCamera;
  42716. /**
  42717. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42718. */
  42719. state: WebXRState;
  42720. private _setState;
  42721. private static _TmpVector;
  42722. /**
  42723. * Fires when the state of the experience helper has changed
  42724. */
  42725. onStateChangedObservable: Observable<WebXRState>;
  42726. /** @hidden */
  42727. _sessionManager: WebXRSessionManager;
  42728. private _nonVRCamera;
  42729. private _originalSceneAutoClear;
  42730. private _supported;
  42731. /**
  42732. * Creates the experience helper
  42733. * @param scene the scene to attach the experience helper to
  42734. * @returns a promise for the experience helper
  42735. */
  42736. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  42737. /**
  42738. * Creates a WebXRExperienceHelper
  42739. * @param scene The scene the helper should be created in
  42740. */
  42741. private constructor();
  42742. /**
  42743. * Exits XR mode and returns the scene to its original state
  42744. * @returns promise that resolves after xr mode has exited
  42745. */
  42746. exitXRAsync(): Promise<void>;
  42747. /**
  42748. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42749. * @param sessionCreationOptions options for the XR session
  42750. * @param frameOfReference frame of reference of the XR session
  42751. * @returns promise that resolves after xr mode has entered
  42752. */
  42753. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42754. /**
  42755. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42756. * @param ray ray to cast into the environment
  42757. * @returns Promise which resolves with a collision point in the environment if it exists
  42758. */
  42759. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42760. /**
  42761. * Updates the global position of the camera by moving the camera's container
  42762. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42763. * @param position The desired global position of the camera
  42764. */
  42765. setPositionOfCameraUsingContainer(position: Vector3): void;
  42766. /**
  42767. * Rotates the xr camera by rotating the camera's container around the camera's position
  42768. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42769. * @param rotation the desired quaternion rotation to apply to the camera
  42770. */
  42771. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42772. /**
  42773. * Checks if the creation options are supported by the xr session
  42774. * @param options creation options
  42775. * @returns true if supported
  42776. */
  42777. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42778. /**
  42779. * Disposes of the experience helper
  42780. */
  42781. dispose(): void;
  42782. }
  42783. }
  42784. declare module BABYLON {
  42785. /**
  42786. * Represents an XR input
  42787. */
  42788. class WebXRController {
  42789. /**
  42790. * 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
  42791. */
  42792. grip?: BABYLON.AbstractMesh;
  42793. /**
  42794. * Pointer which can be used to select objects or attach a visible laser to
  42795. */
  42796. pointer: BABYLON.AbstractMesh;
  42797. /**
  42798. * Creates the controller
  42799. * @see https://doc.babylonjs.com/how_to/webxr
  42800. * @param scene the scene which the controller should be associated to
  42801. */
  42802. constructor(scene: BABYLON.Scene);
  42803. /**
  42804. * Disposes of the object
  42805. */
  42806. dispose(): void;
  42807. }
  42808. /**
  42809. * XR input used to track XR inputs such as controllers/rays
  42810. */
  42811. class WebXRInput implements IDisposable {
  42812. private helper;
  42813. /**
  42814. * XR controllers being tracked
  42815. */
  42816. controllers: Array<WebXRController>;
  42817. private _tmpMatrix;
  42818. private _frameObserver;
  42819. /**
  42820. * Initializes the WebXRInput
  42821. * @param helper experience helper which the input should be created for
  42822. */
  42823. constructor(helper: WebXRExperienceHelper);
  42824. /**
  42825. * Disposes of the object
  42826. */
  42827. dispose(): void;
  42828. }
  42829. }
  42830. declare module BABYLON {
  42831. /**
  42832. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42833. */
  42834. class WebXRManagedOutputCanvas implements IDisposable {
  42835. private _canvas;
  42836. /**
  42837. * xrpresent context of the canvas which can be used to display/mirror xr content
  42838. */
  42839. canvasContext: Nullable<WebGLRenderingContext>;
  42840. /**
  42841. * Initializes the canvas to be added/removed upon entering/exiting xr
  42842. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42843. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42844. */
  42845. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42846. /**
  42847. * Disposes of the object
  42848. */
  42849. dispose(): void;
  42850. private _setManagedOutputCanvas;
  42851. private _addCanvas;
  42852. private _removeCanvas;
  42853. }
  42854. }
  42855. declare module BABYLON {
  42856. /**
  42857. * Manages an XRSession
  42858. * @see https://doc.babylonjs.com/how_to/webxr
  42859. */
  42860. class WebXRSessionManager implements IDisposable {
  42861. private scene;
  42862. /**
  42863. * Fires every time a new xrFrame arrives which can be used to update the camera
  42864. */
  42865. onXRFrameObservable: Observable<any>;
  42866. /**
  42867. * Fires when the xr session is ended either by the device or manually done
  42868. */
  42869. onXRSessionEnded: Observable<any>;
  42870. /** @hidden */
  42871. _xrSession: XRSession;
  42872. /** @hidden */
  42873. _frameOfReference: XRFrameOfReference;
  42874. /** @hidden */
  42875. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42876. /** @hidden */
  42877. _currentXRFrame: Nullable<XRFrame>;
  42878. private _xrNavigator;
  42879. private _xrDevice;
  42880. private _tmpMatrix;
  42881. /**
  42882. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42883. * @param scene The scene which the session should be created for
  42884. */
  42885. constructor(scene: BABYLON.Scene);
  42886. /**
  42887. * Initializes the manager
  42888. * After initialization enterXR can be called to start an XR session
  42889. * @returns Promise which resolves after it is initialized
  42890. */
  42891. initializeAsync(): Promise<void>;
  42892. /**
  42893. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  42894. * @param sessionCreationOptions xr options to create the session with
  42895. * @param frameOfReferenceType option to configure how the xr pose is expressed
  42896. * @returns Promise which resolves after it enters XR
  42897. */
  42898. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  42899. /**
  42900. * Stops the xrSession and restores the renderloop
  42901. * @returns Promise which resolves after it exits XR
  42902. */
  42903. exitXRAsync(): Promise<void>;
  42904. /**
  42905. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42906. * @param ray ray to cast into the environment
  42907. * @returns Promise which resolves with a collision point in the environment if it exists
  42908. */
  42909. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42910. /**
  42911. * Checks if a session would be supported for the creation options specified
  42912. * @param options creation options to check if they are supported
  42913. * @returns true if supported
  42914. */
  42915. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42916. /**
  42917. * @hidden
  42918. * Converts the render layer of xrSession to a render target
  42919. * @param session session to create render target for
  42920. * @param scene scene the new render target should be created for
  42921. */
  42922. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  42923. /**
  42924. * Disposes of the session manager
  42925. */
  42926. dispose(): void;
  42927. }
  42928. }
  42929. declare module BABYLON {
  42930. /**
  42931. * This represents all the required metrics to create a VR camera.
  42932. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42933. */
  42934. class VRCameraMetrics {
  42935. /**
  42936. * Define the horizontal resolution off the screen.
  42937. */
  42938. hResolution: number;
  42939. /**
  42940. * Define the vertical resolution off the screen.
  42941. */
  42942. vResolution: number;
  42943. /**
  42944. * Define the horizontal screen size.
  42945. */
  42946. hScreenSize: number;
  42947. /**
  42948. * Define the vertical screen size.
  42949. */
  42950. vScreenSize: number;
  42951. /**
  42952. * Define the vertical screen center position.
  42953. */
  42954. vScreenCenter: number;
  42955. /**
  42956. * Define the distance of the eyes to the screen.
  42957. */
  42958. eyeToScreenDistance: number;
  42959. /**
  42960. * Define the distance between both lenses
  42961. */
  42962. lensSeparationDistance: number;
  42963. /**
  42964. * Define the distance between both viewer's eyes.
  42965. */
  42966. interpupillaryDistance: number;
  42967. /**
  42968. * Define the distortion factor of the VR postprocess.
  42969. * Please, touch with care.
  42970. */
  42971. distortionK: number[];
  42972. /**
  42973. * Define the chromatic aberration correction factors for the VR post process.
  42974. */
  42975. chromaAbCorrection: number[];
  42976. /**
  42977. * Define the scale factor of the post process.
  42978. * The smaller the better but the slower.
  42979. */
  42980. postProcessScaleFactor: number;
  42981. /**
  42982. * Define an offset for the lens center.
  42983. */
  42984. lensCenterOffset: number;
  42985. /**
  42986. * Define if the current vr camera should compensate the distortion of the lense or not.
  42987. */
  42988. compensateDistortion: boolean;
  42989. /**
  42990. * Gets the rendering aspect ratio based on the provided resolutions.
  42991. */
  42992. readonly aspectRatio: number;
  42993. /**
  42994. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42995. */
  42996. readonly aspectRatioFov: number;
  42997. /**
  42998. * @hidden
  42999. */
  43000. readonly leftHMatrix: Matrix;
  43001. /**
  43002. * @hidden
  43003. */
  43004. readonly rightHMatrix: Matrix;
  43005. /**
  43006. * @hidden
  43007. */
  43008. readonly leftPreViewMatrix: Matrix;
  43009. /**
  43010. * @hidden
  43011. */
  43012. readonly rightPreViewMatrix: Matrix;
  43013. /**
  43014. * Get the default VRMetrics based on the most generic setup.
  43015. * @returns the default vr metrics
  43016. */
  43017. static GetDefault(): VRCameraMetrics;
  43018. }
  43019. }
  43020. declare module BABYLON {
  43021. /**
  43022. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43023. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43024. */
  43025. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43026. /**
  43027. * Creates a new VRDeviceOrientationArcRotateCamera
  43028. * @param name defines camera name
  43029. * @param alpha defines the camera rotation along the logitudinal axis
  43030. * @param beta defines the camera rotation along the latitudinal axis
  43031. * @param radius defines the camera distance from its target
  43032. * @param target defines the camera target
  43033. * @param scene defines the scene the camera belongs to
  43034. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43035. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43036. */
  43037. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43038. /**
  43039. * Gets camera class name
  43040. * @returns VRDeviceOrientationArcRotateCamera
  43041. */
  43042. getClassName(): string;
  43043. }
  43044. }
  43045. declare module BABYLON {
  43046. /**
  43047. * Camera used to simulate VR rendering (based on FreeCamera)
  43048. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43049. */
  43050. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43051. /**
  43052. * Creates a new VRDeviceOrientationFreeCamera
  43053. * @param name defines camera name
  43054. * @param position defines the start position of the camera
  43055. * @param scene defines the scene the camera belongs to
  43056. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43057. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43058. */
  43059. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43060. /**
  43061. * Gets camera class name
  43062. * @returns VRDeviceOrientationFreeCamera
  43063. */
  43064. getClassName(): string;
  43065. }
  43066. }
  43067. declare module BABYLON {
  43068. /**
  43069. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43070. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43071. */
  43072. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43073. /**
  43074. * Creates a new VRDeviceOrientationGamepadCamera
  43075. * @param name defines camera name
  43076. * @param position defines the start position of the camera
  43077. * @param scene defines the scene the camera belongs to
  43078. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43079. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43080. */
  43081. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43082. /**
  43083. * Gets camera class name
  43084. * @returns VRDeviceOrientationGamepadCamera
  43085. */
  43086. getClassName(): string;
  43087. }
  43088. }
  43089. declare module BABYLON {
  43090. /**
  43091. * Options to modify the vr teleportation behavior.
  43092. */
  43093. interface VRTeleportationOptions {
  43094. /**
  43095. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43096. */
  43097. floorMeshName?: string;
  43098. /**
  43099. * A list of meshes to be used as the teleportation floor. (default: empty)
  43100. */
  43101. floorMeshes?: Mesh[];
  43102. }
  43103. /**
  43104. * Options to modify the vr experience helper's behavior.
  43105. */
  43106. interface VRExperienceHelperOptions extends WebVROptions {
  43107. /**
  43108. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43109. */
  43110. createDeviceOrientationCamera?: boolean;
  43111. /**
  43112. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43113. */
  43114. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43115. /**
  43116. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43117. */
  43118. laserToggle?: boolean;
  43119. /**
  43120. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43121. */
  43122. floorMeshes?: Mesh[];
  43123. }
  43124. /**
  43125. * Helps to quickly add VR support to an existing scene.
  43126. * See http://doc.babylonjs.com/how_to/webvr_helper
  43127. */
  43128. class VRExperienceHelper {
  43129. /** Options to modify the vr experience helper's behavior. */
  43130. webVROptions: VRExperienceHelperOptions;
  43131. private _scene;
  43132. private _position;
  43133. private _btnVR;
  43134. private _btnVRDisplayed;
  43135. private _webVRsupported;
  43136. private _webVRready;
  43137. private _webVRrequesting;
  43138. private _webVRpresenting;
  43139. private _hasEnteredVR;
  43140. private _fullscreenVRpresenting;
  43141. private _canvas;
  43142. private _webVRCamera;
  43143. private _vrDeviceOrientationCamera;
  43144. private _deviceOrientationCamera;
  43145. private _existingCamera;
  43146. private _onKeyDown;
  43147. private _onVrDisplayPresentChange;
  43148. private _onVRDisplayChanged;
  43149. private _onVRRequestPresentStart;
  43150. private _onVRRequestPresentComplete;
  43151. /**
  43152. * Observable raised when entering VR.
  43153. */
  43154. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43155. /**
  43156. * Observable raised when exiting VR.
  43157. */
  43158. onExitingVRObservable: Observable<VRExperienceHelper>;
  43159. /**
  43160. * Observable raised when controller mesh is loaded.
  43161. */
  43162. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43163. /** Return this.onEnteringVRObservable
  43164. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43165. */
  43166. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43167. /** Return this.onExitingVRObservable
  43168. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43169. */
  43170. readonly onExitingVR: Observable<VRExperienceHelper>;
  43171. /** Return this.onControllerMeshLoadedObservable
  43172. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43173. */
  43174. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43175. private _rayLength;
  43176. private _useCustomVRButton;
  43177. private _teleportationRequested;
  43178. private _teleportActive;
  43179. private _floorMeshName;
  43180. private _floorMeshesCollection;
  43181. private _rotationAllowed;
  43182. private _teleportBackwardsVector;
  43183. private _teleportationTarget;
  43184. private _isDefaultTeleportationTarget;
  43185. private _postProcessMove;
  43186. private _teleportationFillColor;
  43187. private _teleportationBorderColor;
  43188. private _rotationAngle;
  43189. private _haloCenter;
  43190. private _cameraGazer;
  43191. private _padSensibilityUp;
  43192. private _padSensibilityDown;
  43193. private _leftController;
  43194. private _rightController;
  43195. /**
  43196. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43197. */
  43198. onNewMeshSelected: Observable<AbstractMesh>;
  43199. /**
  43200. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43201. */
  43202. onNewMeshPicked: Observable<PickingInfo>;
  43203. private _circleEase;
  43204. /**
  43205. * Observable raised before camera teleportation
  43206. */
  43207. onBeforeCameraTeleport: Observable<Vector3>;
  43208. /**
  43209. * Observable raised after camera teleportation
  43210. */
  43211. onAfterCameraTeleport: Observable<Vector3>;
  43212. /**
  43213. * Observable raised when current selected mesh gets unselected
  43214. */
  43215. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43216. private _raySelectionPredicate;
  43217. /**
  43218. * To be optionaly changed by user to define custom ray selection
  43219. */
  43220. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43221. /**
  43222. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43223. */
  43224. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43225. /**
  43226. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43227. */
  43228. teleportationEnabled: boolean;
  43229. private _defaultHeight;
  43230. private _teleportationInitialized;
  43231. private _interactionsEnabled;
  43232. private _interactionsRequested;
  43233. private _displayGaze;
  43234. private _displayLaserPointer;
  43235. /**
  43236. * The mesh used to display where the user is going to teleport.
  43237. */
  43238. /**
  43239. * Sets the mesh to be used to display where the user is going to teleport.
  43240. */
  43241. teleportationTarget: Mesh;
  43242. /**
  43243. * 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
  43244. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43245. * See http://doc.babylonjs.com/resources/baking_transformations
  43246. */
  43247. gazeTrackerMesh: Mesh;
  43248. /**
  43249. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43250. */
  43251. updateGazeTrackerScale: boolean;
  43252. /**
  43253. * The gaze tracking mesh corresponding to the left controller
  43254. */
  43255. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43256. /**
  43257. * The gaze tracking mesh corresponding to the right controller
  43258. */
  43259. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43260. /**
  43261. * If the ray of the gaze should be displayed.
  43262. */
  43263. /**
  43264. * Sets if the ray of the gaze should be displayed.
  43265. */
  43266. displayGaze: boolean;
  43267. /**
  43268. * If the ray of the LaserPointer should be displayed.
  43269. */
  43270. /**
  43271. * Sets if the ray of the LaserPointer should be displayed.
  43272. */
  43273. displayLaserPointer: boolean;
  43274. /**
  43275. * The deviceOrientationCamera used as the camera when not in VR.
  43276. */
  43277. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43278. /**
  43279. * Based on the current WebVR support, returns the current VR camera used.
  43280. */
  43281. readonly currentVRCamera: Nullable<Camera>;
  43282. /**
  43283. * The webVRCamera which is used when in VR.
  43284. */
  43285. readonly webVRCamera: WebVRFreeCamera;
  43286. /**
  43287. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43288. */
  43289. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43290. private readonly _teleportationRequestInitiated;
  43291. /**
  43292. * Instantiates a VRExperienceHelper.
  43293. * Helps to quickly add VR support to an existing scene.
  43294. * @param scene The scene the VRExperienceHelper belongs to.
  43295. * @param webVROptions Options to modify the vr experience helper's behavior.
  43296. */
  43297. constructor(scene: Scene,
  43298. /** Options to modify the vr experience helper's behavior. */
  43299. webVROptions?: VRExperienceHelperOptions);
  43300. private _onDefaultMeshLoaded;
  43301. private _onResize;
  43302. private _onFullscreenChange;
  43303. /**
  43304. * Gets a value indicating if we are currently in VR mode.
  43305. */
  43306. readonly isInVRMode: boolean;
  43307. private onVrDisplayPresentChange;
  43308. private onVRDisplayChanged;
  43309. private moveButtonToBottomRight;
  43310. private displayVRButton;
  43311. private updateButtonVisibility;
  43312. private _cachedAngularSensibility;
  43313. /**
  43314. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43315. * Otherwise, will use the fullscreen API.
  43316. */
  43317. enterVR(): void;
  43318. /**
  43319. * Attempt to exit VR, or fullscreen.
  43320. */
  43321. exitVR(): void;
  43322. /**
  43323. * The position of the vr experience helper.
  43324. */
  43325. /**
  43326. * Sets the position of the vr experience helper.
  43327. */
  43328. position: Vector3;
  43329. /**
  43330. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43331. */
  43332. enableInteractions(): void;
  43333. private readonly _noControllerIsActive;
  43334. private beforeRender;
  43335. private _isTeleportationFloor;
  43336. /**
  43337. * Adds a floor mesh to be used for teleportation.
  43338. * @param floorMesh the mesh to be used for teleportation.
  43339. */
  43340. addFloorMesh(floorMesh: Mesh): void;
  43341. /**
  43342. * Removes a floor mesh from being used for teleportation.
  43343. * @param floorMesh the mesh to be removed.
  43344. */
  43345. removeFloorMesh(floorMesh: Mesh): void;
  43346. /**
  43347. * Enables interactions and teleportation using the VR controllers and gaze.
  43348. * @param vrTeleportationOptions options to modify teleportation behavior.
  43349. */
  43350. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43351. private _onNewGamepadConnected;
  43352. private _tryEnableInteractionOnController;
  43353. private _onNewGamepadDisconnected;
  43354. private _enableInteractionOnController;
  43355. private _checkTeleportWithRay;
  43356. private _checkRotate;
  43357. private _checkTeleportBackwards;
  43358. private _enableTeleportationOnController;
  43359. private _createTeleportationCircles;
  43360. private _displayTeleportationTarget;
  43361. private _hideTeleportationTarget;
  43362. private _rotateCamera;
  43363. private _moveTeleportationSelectorTo;
  43364. private _workingVector;
  43365. private _workingQuaternion;
  43366. private _workingMatrix;
  43367. /**
  43368. * Teleports the users feet to the desired location
  43369. * @param location The location where the user's feet should be placed
  43370. */
  43371. teleportCamera(location: Vector3): void;
  43372. private _convertNormalToDirectionOfRay;
  43373. private _castRayAndSelectObject;
  43374. private _notifySelectedMeshUnselected;
  43375. /**
  43376. * Sets the color of the laser ray from the vr controllers.
  43377. * @param color new color for the ray.
  43378. */
  43379. changeLaserColor(color: Color3): void;
  43380. /**
  43381. * Sets the color of the ray from the vr headsets gaze.
  43382. * @param color new color for the ray.
  43383. */
  43384. changeGazeColor(color: Color3): void;
  43385. /**
  43386. * Exits VR and disposes of the vr experience helper
  43387. */
  43388. dispose(): void;
  43389. /**
  43390. * Gets the name of the VRExperienceHelper class
  43391. * @returns "VRExperienceHelper"
  43392. */
  43393. getClassName(): string;
  43394. }
  43395. }
  43396. declare module BABYLON {
  43397. /**
  43398. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  43399. * IMPORTANT!! The data is right-hand data.
  43400. * @export
  43401. * @interface DevicePose
  43402. */
  43403. interface DevicePose {
  43404. /**
  43405. * The position of the device, values in array are [x,y,z].
  43406. */
  43407. readonly position: Nullable<Float32Array>;
  43408. /**
  43409. * The linearVelocity of the device, values in array are [x,y,z].
  43410. */
  43411. readonly linearVelocity: Nullable<Float32Array>;
  43412. /**
  43413. * The linearAcceleration of the device, values in array are [x,y,z].
  43414. */
  43415. readonly linearAcceleration: Nullable<Float32Array>;
  43416. /**
  43417. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  43418. */
  43419. readonly orientation: Nullable<Float32Array>;
  43420. /**
  43421. * The angularVelocity of the device, values in array are [x,y,z].
  43422. */
  43423. readonly angularVelocity: Nullable<Float32Array>;
  43424. /**
  43425. * The angularAcceleration of the device, values in array are [x,y,z].
  43426. */
  43427. readonly angularAcceleration: Nullable<Float32Array>;
  43428. }
  43429. /**
  43430. * Interface representing a pose controlled object in Babylon.
  43431. * A pose controlled object has both regular pose values as well as pose values
  43432. * from an external device such as a VR head mounted display
  43433. */
  43434. interface PoseControlled {
  43435. /**
  43436. * The position of the object in babylon space.
  43437. */
  43438. position: Vector3;
  43439. /**
  43440. * The rotation quaternion of the object in babylon space.
  43441. */
  43442. rotationQuaternion: Quaternion;
  43443. /**
  43444. * The position of the device in babylon space.
  43445. */
  43446. devicePosition?: Vector3;
  43447. /**
  43448. * The rotation quaternion of the device in babylon space.
  43449. */
  43450. deviceRotationQuaternion: Quaternion;
  43451. /**
  43452. * The raw pose coming from the device.
  43453. */
  43454. rawPose: Nullable<DevicePose>;
  43455. /**
  43456. * The scale of the device to be used when translating from device space to babylon space.
  43457. */
  43458. deviceScaleFactor: number;
  43459. /**
  43460. * Updates the poseControlled values based on the input device pose.
  43461. * @param poseData the pose data to update the object with
  43462. */
  43463. updateFromDevice(poseData: DevicePose): void;
  43464. }
  43465. /**
  43466. * Set of options to customize the webVRCamera
  43467. */
  43468. interface WebVROptions {
  43469. /**
  43470. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  43471. */
  43472. trackPosition?: boolean;
  43473. /**
  43474. * Sets the scale of the vrDevice in babylon space. (default: 1)
  43475. */
  43476. positionScale?: number;
  43477. /**
  43478. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43479. */
  43480. displayName?: string;
  43481. /**
  43482. * Should the native controller meshes be initialized. (default: true)
  43483. */
  43484. controllerMeshes?: boolean;
  43485. /**
  43486. * Creating a default HemiLight only on controllers. (default: true)
  43487. */
  43488. defaultLightingOnControllers?: boolean;
  43489. /**
  43490. * If you don't want to use the default VR button of the helper. (default: false)
  43491. */
  43492. useCustomVRButton?: boolean;
  43493. /**
  43494. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43495. */
  43496. customVRButton?: HTMLButtonElement;
  43497. /**
  43498. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43499. */
  43500. rayLength?: number;
  43501. /**
  43502. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43503. */
  43504. defaultHeight?: number;
  43505. }
  43506. /**
  43507. * This represents a WebVR camera.
  43508. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43509. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43510. */
  43511. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43512. private webVROptions;
  43513. /**
  43514. * @hidden
  43515. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43516. */
  43517. _vrDevice: any;
  43518. /**
  43519. * The rawPose of the vrDevice.
  43520. */
  43521. rawPose: Nullable<DevicePose>;
  43522. private _onVREnabled;
  43523. private _specsVersion;
  43524. private _attached;
  43525. private _frameData;
  43526. protected _descendants: Array<Node>;
  43527. private _deviceRoomPosition;
  43528. /** @hidden */
  43529. _deviceRoomRotationQuaternion: Quaternion;
  43530. private _standingMatrix;
  43531. /**
  43532. * Represents device position in babylon space.
  43533. */
  43534. devicePosition: Vector3;
  43535. /**
  43536. * Represents device rotation in babylon space.
  43537. */
  43538. deviceRotationQuaternion: Quaternion;
  43539. /**
  43540. * The scale of the device to be used when translating from device space to babylon space.
  43541. */
  43542. deviceScaleFactor: number;
  43543. private _deviceToWorld;
  43544. private _worldToDevice;
  43545. /**
  43546. * References to the webVR controllers for the vrDevice.
  43547. */
  43548. controllers: Array<WebVRController>;
  43549. /**
  43550. * Emits an event when a controller is attached.
  43551. */
  43552. onControllersAttachedObservable: Observable<WebVRController[]>;
  43553. /**
  43554. * Emits an event when a controller's mesh has been loaded;
  43555. */
  43556. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43557. /**
  43558. * Emits an event when the HMD's pose has been updated.
  43559. */
  43560. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43561. private _poseSet;
  43562. /**
  43563. * If the rig cameras be used as parent instead of this camera.
  43564. */
  43565. rigParenting: boolean;
  43566. private _lightOnControllers;
  43567. private _defaultHeight?;
  43568. /**
  43569. * Instantiates a WebVRFreeCamera.
  43570. * @param name The name of the WebVRFreeCamera
  43571. * @param position The starting anchor position for the camera
  43572. * @param scene The scene the camera belongs to
  43573. * @param webVROptions a set of customizable options for the webVRCamera
  43574. */
  43575. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43576. /**
  43577. * Gets the device distance from the ground in meters.
  43578. * @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.
  43579. */
  43580. deviceDistanceToRoomGround(): number;
  43581. /**
  43582. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43583. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43584. */
  43585. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43586. /**
  43587. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43588. * @returns A promise with a boolean set to if the standing matrix is supported.
  43589. */
  43590. useStandingMatrixAsync(): Promise<boolean>;
  43591. /**
  43592. * Disposes the camera
  43593. */
  43594. dispose(): void;
  43595. /**
  43596. * Gets a vrController by name.
  43597. * @param name The name of the controller to retreive
  43598. * @returns the controller matching the name specified or null if not found
  43599. */
  43600. getControllerByName(name: string): Nullable<WebVRController>;
  43601. private _leftController;
  43602. /**
  43603. * The controller corrisponding to the users left hand.
  43604. */
  43605. readonly leftController: Nullable<WebVRController>;
  43606. private _rightController;
  43607. /**
  43608. * The controller corrisponding to the users right hand.
  43609. */
  43610. readonly rightController: Nullable<WebVRController>;
  43611. /**
  43612. * Casts a ray forward from the vrCamera's gaze.
  43613. * @param length Length of the ray (default: 100)
  43614. * @returns the ray corrisponding to the gaze
  43615. */
  43616. getForwardRay(length?: number): Ray;
  43617. /**
  43618. * @hidden
  43619. * Updates the camera based on device's frame data
  43620. */
  43621. _checkInputs(): void;
  43622. /**
  43623. * Updates the poseControlled values based on the input device pose.
  43624. * @param poseData Pose coming from the device
  43625. */
  43626. updateFromDevice(poseData: DevicePose): void;
  43627. private _htmlElementAttached;
  43628. private _detachIfAttached;
  43629. /**
  43630. * WebVR's attach control will start broadcasting frames to the device.
  43631. * Note that in certain browsers (chrome for example) this function must be called
  43632. * within a user-interaction callback. Example:
  43633. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43634. *
  43635. * @param element html element to attach the vrDevice to
  43636. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43637. */
  43638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43639. /**
  43640. * Detaches the camera from the html element and disables VR
  43641. *
  43642. * @param element html element to detach from
  43643. */
  43644. detachControl(element: HTMLElement): void;
  43645. /**
  43646. * @returns the name of this class
  43647. */
  43648. getClassName(): string;
  43649. /**
  43650. * Calls resetPose on the vrDisplay
  43651. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43652. */
  43653. resetToCurrentRotation(): void;
  43654. /**
  43655. * @hidden
  43656. * Updates the rig cameras (left and right eye)
  43657. */
  43658. _updateRigCameras(): void;
  43659. private _workingVector;
  43660. private _oneVector;
  43661. private _workingMatrix;
  43662. private updateCacheCalled;
  43663. private _correctPositionIfNotTrackPosition;
  43664. /**
  43665. * @hidden
  43666. * Updates the cached values of the camera
  43667. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43668. */
  43669. _updateCache(ignoreParentClass?: boolean): void;
  43670. /**
  43671. * @hidden
  43672. * Get current device position in babylon world
  43673. */
  43674. _computeDevicePosition(): void;
  43675. /**
  43676. * Updates the current device position and rotation in the babylon world
  43677. */
  43678. update(): void;
  43679. /**
  43680. * @hidden
  43681. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43682. * @returns an identity matrix
  43683. */
  43684. _getViewMatrix(): Matrix;
  43685. private _tmpMatrix;
  43686. /**
  43687. * This function is called by the two RIG cameras.
  43688. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43689. */
  43690. protected _getWebVRViewMatrix(): Matrix;
  43691. protected _getWebVRProjectionMatrix(): Matrix;
  43692. private _onGamepadConnectedObserver;
  43693. private _onGamepadDisconnectedObserver;
  43694. private _updateCacheWhenTrackingDisabledObserver;
  43695. /**
  43696. * Initializes the controllers and their meshes
  43697. */
  43698. initControllers(): void;
  43699. }
  43700. }
  43701. declare module BABYLON {
  43702. /** @hidden */
  43703. class _OcclusionDataStorage {
  43704. /** @hidden */
  43705. occlusionInternalRetryCounter: number;
  43706. /** @hidden */
  43707. isOcclusionQueryInProgress: boolean;
  43708. /** @hidden */
  43709. isOccluded: boolean;
  43710. /** @hidden */
  43711. occlusionRetryCount: number;
  43712. /** @hidden */
  43713. occlusionType: number;
  43714. /** @hidden */
  43715. occlusionQueryAlgorithmType: number;
  43716. }
  43717. interface Engine {
  43718. /**
  43719. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43720. * @return the new query
  43721. */
  43722. createQuery(): WebGLQuery;
  43723. /**
  43724. * Delete and release a webGL query
  43725. * @param query defines the query to delete
  43726. * @return the current engine
  43727. */
  43728. deleteQuery(query: WebGLQuery): Engine;
  43729. /**
  43730. * Check if a given query has resolved and got its value
  43731. * @param query defines the query to check
  43732. * @returns true if the query got its value
  43733. */
  43734. isQueryResultAvailable(query: WebGLQuery): boolean;
  43735. /**
  43736. * Gets the value of a given query
  43737. * @param query defines the query to check
  43738. * @returns the value of the query
  43739. */
  43740. getQueryResult(query: WebGLQuery): number;
  43741. /**
  43742. * Initiates an occlusion query
  43743. * @param algorithmType defines the algorithm to use
  43744. * @param query defines the query to use
  43745. * @returns the current engine
  43746. * @see http://doc.babylonjs.com/features/occlusionquery
  43747. */
  43748. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43749. /**
  43750. * Ends an occlusion query
  43751. * @see http://doc.babylonjs.com/features/occlusionquery
  43752. * @param algorithmType defines the algorithm to use
  43753. * @returns the current engine
  43754. */
  43755. endOcclusionQuery(algorithmType: number): Engine;
  43756. /**
  43757. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43758. * Please note that only one query can be issued at a time
  43759. * @returns a time token used to track the time span
  43760. */
  43761. startTimeQuery(): Nullable<_TimeToken>;
  43762. /**
  43763. * Ends a time query
  43764. * @param token defines the token used to measure the time span
  43765. * @returns the time spent (in ns)
  43766. */
  43767. endTimeQuery(token: _TimeToken): int;
  43768. /** @hidden */
  43769. _currentNonTimestampToken: Nullable<_TimeToken>;
  43770. /** @hidden */
  43771. _createTimeQuery(): WebGLQuery;
  43772. /** @hidden */
  43773. _deleteTimeQuery(query: WebGLQuery): void;
  43774. /** @hidden */
  43775. _getGlAlgorithmType(algorithmType: number): number;
  43776. /** @hidden */
  43777. _getTimeQueryResult(query: WebGLQuery): any;
  43778. /** @hidden */
  43779. _getTimeQueryAvailability(query: WebGLQuery): any;
  43780. }
  43781. interface AbstractMesh {
  43782. /**
  43783. * Backing filed
  43784. * @hidden
  43785. */
  43786. __occlusionDataStorage: _OcclusionDataStorage;
  43787. /**
  43788. * Access property
  43789. * @hidden
  43790. */
  43791. _occlusionDataStorage: _OcclusionDataStorage;
  43792. /**
  43793. * 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.
  43794. * The default value is -1 which means don't break the query and wait till the result
  43795. * @see http://doc.babylonjs.com/features/occlusionquery
  43796. */
  43797. occlusionRetryCount: number;
  43798. /**
  43799. * 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:
  43800. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43801. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43802. * * 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.
  43803. * @see http://doc.babylonjs.com/features/occlusionquery
  43804. */
  43805. occlusionType: number;
  43806. /**
  43807. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43808. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43809. * * 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.
  43810. * @see http://doc.babylonjs.com/features/occlusionquery
  43811. */
  43812. occlusionQueryAlgorithmType: number;
  43813. /**
  43814. * 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
  43815. * @see http://doc.babylonjs.com/features/occlusionquery
  43816. */
  43817. isOccluded: boolean;
  43818. /**
  43819. * Flag to check the progress status of the query
  43820. * @see http://doc.babylonjs.com/features/occlusionquery
  43821. */
  43822. isOcclusionQueryInProgress: boolean;
  43823. }
  43824. }
  43825. declare module BABYLON {
  43826. interface Engine {
  43827. /**
  43828. * Creates a webGL transform feedback object
  43829. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43830. * @returns the webGL transform feedback object
  43831. */
  43832. createTransformFeedback(): WebGLTransformFeedback;
  43833. /**
  43834. * Delete a webGL transform feedback object
  43835. * @param value defines the webGL transform feedback object to delete
  43836. */
  43837. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43838. /**
  43839. * Bind a webGL transform feedback object to the webgl context
  43840. * @param value defines the webGL transform feedback object to bind
  43841. */
  43842. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43843. /**
  43844. * Begins a transform feedback operation
  43845. * @param usePoints defines if points or triangles must be used
  43846. */
  43847. beginTransformFeedback(usePoints: boolean): void;
  43848. /**
  43849. * Ends a transform feedback operation
  43850. */
  43851. endTransformFeedback(): void;
  43852. /**
  43853. * Specify the varyings to use with transform feedback
  43854. * @param program defines the associated webGL program
  43855. * @param value defines the list of strings representing the varying names
  43856. */
  43857. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43858. /**
  43859. * Bind a webGL buffer for a transform feedback operation
  43860. * @param value defines the webGL buffer to bind
  43861. */
  43862. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43863. }
  43864. }
  43865. declare module BABYLON {
  43866. /**
  43867. * Google Daydream controller
  43868. */
  43869. class DaydreamController extends WebVRController {
  43870. /**
  43871. * Base Url for the controller model.
  43872. */
  43873. static MODEL_BASE_URL: string;
  43874. /**
  43875. * File name for the controller model.
  43876. */
  43877. static MODEL_FILENAME: string;
  43878. /**
  43879. * Gamepad Id prefix used to identify Daydream Controller.
  43880. */
  43881. static readonly GAMEPAD_ID_PREFIX: string;
  43882. /**
  43883. * Creates a new DaydreamController from a gamepad
  43884. * @param vrGamepad the gamepad that the controller should be created from
  43885. */
  43886. constructor(vrGamepad: any);
  43887. /**
  43888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43889. * @param scene scene in which to add meshes
  43890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43891. */
  43892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43893. /**
  43894. * Called once for each button that changed state since the last frame
  43895. * @param buttonIdx Which button index changed
  43896. * @param state New state of the button
  43897. * @param changes Which properties on the state changed since last frame
  43898. */
  43899. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43900. }
  43901. }
  43902. declare module BABYLON {
  43903. /**
  43904. * Gear VR Controller
  43905. */
  43906. class GearVRController extends WebVRController {
  43907. /**
  43908. * Base Url for the controller model.
  43909. */
  43910. static MODEL_BASE_URL: string;
  43911. /**
  43912. * File name for the controller model.
  43913. */
  43914. static MODEL_FILENAME: string;
  43915. /**
  43916. * Gamepad Id prefix used to identify this controller.
  43917. */
  43918. static readonly GAMEPAD_ID_PREFIX: string;
  43919. private readonly _buttonIndexToObservableNameMap;
  43920. /**
  43921. * Creates a new GearVRController from a gamepad
  43922. * @param vrGamepad the gamepad that the controller should be created from
  43923. */
  43924. constructor(vrGamepad: any);
  43925. /**
  43926. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43927. * @param scene scene in which to add meshes
  43928. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43929. */
  43930. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43931. /**
  43932. * Called once for each button that changed state since the last frame
  43933. * @param buttonIdx Which button index changed
  43934. * @param state New state of the button
  43935. * @param changes Which properties on the state changed since last frame
  43936. */
  43937. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43938. }
  43939. }
  43940. declare module BABYLON {
  43941. /**
  43942. * Generic Controller
  43943. */
  43944. class GenericController extends WebVRController {
  43945. /**
  43946. * Base Url for the controller model.
  43947. */
  43948. static readonly MODEL_BASE_URL: string;
  43949. /**
  43950. * File name for the controller model.
  43951. */
  43952. static readonly MODEL_FILENAME: string;
  43953. /**
  43954. * Creates a new GenericController from a gamepad
  43955. * @param vrGamepad the gamepad that the controller should be created from
  43956. */
  43957. constructor(vrGamepad: any);
  43958. /**
  43959. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43960. * @param scene scene in which to add meshes
  43961. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43962. */
  43963. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43964. /**
  43965. * Called once for each button that changed state since the last frame
  43966. * @param buttonIdx Which button index changed
  43967. * @param state New state of the button
  43968. * @param changes Which properties on the state changed since last frame
  43969. */
  43970. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43971. }
  43972. }
  43973. declare module BABYLON {
  43974. /**
  43975. * Oculus Touch Controller
  43976. */
  43977. class OculusTouchController extends WebVRController {
  43978. /**
  43979. * Base Url for the controller model.
  43980. */
  43981. static MODEL_BASE_URL: string;
  43982. /**
  43983. * File name for the left controller model.
  43984. */
  43985. static MODEL_LEFT_FILENAME: string;
  43986. /**
  43987. * File name for the right controller model.
  43988. */
  43989. static MODEL_RIGHT_FILENAME: string;
  43990. /**
  43991. * Fired when the secondary trigger on this controller is modified
  43992. */
  43993. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43994. /**
  43995. * Fired when the thumb rest on this controller is modified
  43996. */
  43997. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43998. /**
  43999. * Creates a new OculusTouchController from a gamepad
  44000. * @param vrGamepad the gamepad that the controller should be created from
  44001. */
  44002. constructor(vrGamepad: any);
  44003. /**
  44004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44005. * @param scene scene in which to add meshes
  44006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44007. */
  44008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44009. /**
  44010. * Fired when the A button on this controller is modified
  44011. */
  44012. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44013. /**
  44014. * Fired when the B button on this controller is modified
  44015. */
  44016. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44017. /**
  44018. * Fired when the X button on this controller is modified
  44019. */
  44020. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44021. /**
  44022. * Fired when the Y button on this controller is modified
  44023. */
  44024. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44025. /**
  44026. * Called once for each button that changed state since the last frame
  44027. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44028. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44029. * 2) secondary trigger (same)
  44030. * 3) A (right) X (left), touch, pressed = value
  44031. * 4) B / Y
  44032. * 5) thumb rest
  44033. * @param buttonIdx Which button index changed
  44034. * @param state New state of the button
  44035. * @param changes Which properties on the state changed since last frame
  44036. */
  44037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44038. }
  44039. }
  44040. declare module BABYLON {
  44041. /**
  44042. * Defines the types of pose enabled controllers that are supported
  44043. */
  44044. enum PoseEnabledControllerType {
  44045. /**
  44046. * HTC Vive
  44047. */
  44048. VIVE = 0,
  44049. /**
  44050. * Oculus Rift
  44051. */
  44052. OCULUS = 1,
  44053. /**
  44054. * Windows mixed reality
  44055. */
  44056. WINDOWS = 2,
  44057. /**
  44058. * Samsung gear VR
  44059. */
  44060. GEAR_VR = 3,
  44061. /**
  44062. * Google Daydream
  44063. */
  44064. DAYDREAM = 4,
  44065. /**
  44066. * Generic
  44067. */
  44068. GENERIC = 5
  44069. }
  44070. /**
  44071. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44072. */
  44073. interface MutableGamepadButton {
  44074. /**
  44075. * Value of the button/trigger
  44076. */
  44077. value: number;
  44078. /**
  44079. * If the button/trigger is currently touched
  44080. */
  44081. touched: boolean;
  44082. /**
  44083. * If the button/trigger is currently pressed
  44084. */
  44085. pressed: boolean;
  44086. }
  44087. /**
  44088. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44089. * @hidden
  44090. */
  44091. interface ExtendedGamepadButton extends GamepadButton {
  44092. /**
  44093. * If the button/trigger is currently pressed
  44094. */
  44095. readonly pressed: boolean;
  44096. /**
  44097. * If the button/trigger is currently touched
  44098. */
  44099. readonly touched: boolean;
  44100. /**
  44101. * Value of the button/trigger
  44102. */
  44103. readonly value: number;
  44104. }
  44105. /**
  44106. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44107. */
  44108. class PoseEnabledControllerHelper {
  44109. /**
  44110. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44111. * @param vrGamepad the gamepad to initialized
  44112. * @returns a vr controller of the type the gamepad identified as
  44113. */
  44114. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44115. }
  44116. /**
  44117. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44118. */
  44119. class PoseEnabledController extends Gamepad implements PoseControlled {
  44120. private _deviceRoomPosition;
  44121. private _deviceRoomRotationQuaternion;
  44122. /**
  44123. * The device position in babylon space
  44124. */
  44125. devicePosition: Vector3;
  44126. /**
  44127. * The device rotation in babylon space
  44128. */
  44129. deviceRotationQuaternion: Quaternion;
  44130. /**
  44131. * The scale factor of the device in babylon space
  44132. */
  44133. deviceScaleFactor: number;
  44134. /**
  44135. * (Likely devicePosition should be used instead) The device position in its room space
  44136. */
  44137. position: Vector3;
  44138. /**
  44139. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44140. */
  44141. rotationQuaternion: Quaternion;
  44142. /**
  44143. * The type of controller (Eg. Windows mixed reality)
  44144. */
  44145. controllerType: PoseEnabledControllerType;
  44146. protected _calculatedPosition: Vector3;
  44147. private _calculatedRotation;
  44148. /**
  44149. * The raw pose from the device
  44150. */
  44151. rawPose: DevicePose;
  44152. private _trackPosition;
  44153. private _maxRotationDistFromHeadset;
  44154. private _draggedRoomRotation;
  44155. /**
  44156. * @hidden
  44157. */
  44158. _disableTrackPosition(fixedPosition: Vector3): void;
  44159. /**
  44160. * Internal, the mesh attached to the controller
  44161. * @hidden
  44162. */
  44163. _mesh: Nullable<AbstractMesh>;
  44164. private _poseControlledCamera;
  44165. private _leftHandSystemQuaternion;
  44166. /**
  44167. * Internal, matrix used to convert room space to babylon space
  44168. * @hidden
  44169. */
  44170. _deviceToWorld: Matrix;
  44171. /**
  44172. * Node to be used when casting a ray from the controller
  44173. * @hidden
  44174. */
  44175. _pointingPoseNode: Nullable<TransformNode>;
  44176. /**
  44177. * Name of the child mesh that can be used to cast a ray from the controller
  44178. */
  44179. static readonly POINTING_POSE: string;
  44180. /**
  44181. * Creates a new PoseEnabledController from a gamepad
  44182. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44183. */
  44184. constructor(browserGamepad: any);
  44185. private _workingMatrix;
  44186. /**
  44187. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44188. */
  44189. update(): void;
  44190. /**
  44191. * Updates only the pose device and mesh without doing any button event checking
  44192. */
  44193. protected _updatePoseAndMesh(): void;
  44194. /**
  44195. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44196. * @param poseData raw pose fromthe device
  44197. */
  44198. updateFromDevice(poseData: DevicePose): void;
  44199. /**
  44200. * @hidden
  44201. */
  44202. _meshAttachedObservable: Observable<AbstractMesh>;
  44203. /**
  44204. * Attaches a mesh to the controller
  44205. * @param mesh the mesh to be attached
  44206. */
  44207. attachToMesh(mesh: AbstractMesh): void;
  44208. /**
  44209. * Attaches the controllers mesh to a camera
  44210. * @param camera the camera the mesh should be attached to
  44211. */
  44212. attachToPoseControlledCamera(camera: TargetCamera): void;
  44213. /**
  44214. * Disposes of the controller
  44215. */
  44216. dispose(): void;
  44217. /**
  44218. * The mesh that is attached to the controller
  44219. */
  44220. readonly mesh: Nullable<AbstractMesh>;
  44221. /**
  44222. * Gets the ray of the controller in the direction the controller is pointing
  44223. * @param length the length the resulting ray should be
  44224. * @returns a ray in the direction the controller is pointing
  44225. */
  44226. getForwardRay(length?: number): Ray;
  44227. }
  44228. }
  44229. declare module BABYLON {
  44230. /**
  44231. * Vive Controller
  44232. */
  44233. class ViveController extends WebVRController {
  44234. /**
  44235. * Base Url for the controller model.
  44236. */
  44237. static MODEL_BASE_URL: string;
  44238. /**
  44239. * File name for the controller model.
  44240. */
  44241. static MODEL_FILENAME: string;
  44242. /**
  44243. * Creates a new ViveController from a gamepad
  44244. * @param vrGamepad the gamepad that the controller should be created from
  44245. */
  44246. constructor(vrGamepad: any);
  44247. /**
  44248. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44249. * @param scene scene in which to add meshes
  44250. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44251. */
  44252. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44253. /**
  44254. * Fired when the left button on this controller is modified
  44255. */
  44256. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44257. /**
  44258. * Fired when the right button on this controller is modified
  44259. */
  44260. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44261. /**
  44262. * Fired when the menu button on this controller is modified
  44263. */
  44264. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44265. /**
  44266. * Called once for each button that changed state since the last frame
  44267. * Vive mapping:
  44268. * 0: touchpad
  44269. * 1: trigger
  44270. * 2: left AND right buttons
  44271. * 3: menu button
  44272. * @param buttonIdx Which button index changed
  44273. * @param state New state of the button
  44274. * @param changes Which properties on the state changed since last frame
  44275. */
  44276. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44277. }
  44278. }
  44279. declare module BABYLON {
  44280. /**
  44281. * Defines the WebVRController object that represents controllers tracked in 3D space
  44282. */
  44283. abstract class WebVRController extends PoseEnabledController {
  44284. /**
  44285. * Internal, the default controller model for the controller
  44286. */
  44287. protected _defaultModel: AbstractMesh;
  44288. /**
  44289. * Fired when the trigger state has changed
  44290. */
  44291. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44292. /**
  44293. * Fired when the main button state has changed
  44294. */
  44295. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44296. /**
  44297. * Fired when the secondary button state has changed
  44298. */
  44299. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44300. /**
  44301. * Fired when the pad state has changed
  44302. */
  44303. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44304. /**
  44305. * Fired when controllers stick values have changed
  44306. */
  44307. onPadValuesChangedObservable: Observable<StickValues>;
  44308. /**
  44309. * Array of button availible on the controller
  44310. */
  44311. protected _buttons: Array<MutableGamepadButton>;
  44312. private _onButtonStateChange;
  44313. /**
  44314. * Fired when a controller button's state has changed
  44315. * @param callback the callback containing the button that was modified
  44316. */
  44317. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44318. /**
  44319. * X and Y axis corrisponding to the controllers joystick
  44320. */
  44321. pad: StickValues;
  44322. /**
  44323. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44324. */
  44325. hand: string;
  44326. /**
  44327. * The default controller model for the controller
  44328. */
  44329. readonly defaultModel: AbstractMesh;
  44330. /**
  44331. * Creates a new WebVRController from a gamepad
  44332. * @param vrGamepad the gamepad that the WebVRController should be created from
  44333. */
  44334. constructor(vrGamepad: any);
  44335. /**
  44336. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44337. */
  44338. update(): void;
  44339. /**
  44340. * Function to be called when a button is modified
  44341. */
  44342. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44343. /**
  44344. * Loads a mesh and attaches it to the controller
  44345. * @param scene the scene the mesh should be added to
  44346. * @param meshLoaded callback for when the mesh has been loaded
  44347. */
  44348. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44349. private _setButtonValue;
  44350. private _changes;
  44351. private _checkChanges;
  44352. /**
  44353. * Disposes of th webVRCOntroller
  44354. */
  44355. dispose(): void;
  44356. }
  44357. }
  44358. declare module BABYLON {
  44359. /**
  44360. * Defines the WindowsMotionController object that the state of the windows motion controller
  44361. */
  44362. class WindowsMotionController extends WebVRController {
  44363. /**
  44364. * The base url used to load the left and right controller models
  44365. */
  44366. static MODEL_BASE_URL: string;
  44367. /**
  44368. * The name of the left controller model file
  44369. */
  44370. static MODEL_LEFT_FILENAME: string;
  44371. /**
  44372. * The name of the right controller model file
  44373. */
  44374. static MODEL_RIGHT_FILENAME: string;
  44375. /**
  44376. * The controller name prefix for this controller type
  44377. */
  44378. static readonly GAMEPAD_ID_PREFIX: string;
  44379. /**
  44380. * The controller id pattern for this controller type
  44381. */
  44382. private static readonly GAMEPAD_ID_PATTERN;
  44383. private _loadedMeshInfo;
  44384. private readonly _mapping;
  44385. /**
  44386. * Fired when the trackpad on this controller is clicked
  44387. */
  44388. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44389. /**
  44390. * Fired when the trackpad on this controller is modified
  44391. */
  44392. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44393. /**
  44394. * The current x and y values of this controller's trackpad
  44395. */
  44396. trackpad: StickValues;
  44397. /**
  44398. * Creates a new WindowsMotionController from a gamepad
  44399. * @param vrGamepad the gamepad that the controller should be created from
  44400. */
  44401. constructor(vrGamepad: any);
  44402. /**
  44403. * Fired when the trigger on this controller is modified
  44404. */
  44405. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44406. /**
  44407. * Fired when the menu button on this controller is modified
  44408. */
  44409. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44410. /**
  44411. * Fired when the grip button on this controller is modified
  44412. */
  44413. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44414. /**
  44415. * Fired when the thumbstick button on this controller is modified
  44416. */
  44417. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44418. /**
  44419. * Fired when the touchpad button on this controller is modified
  44420. */
  44421. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44422. /**
  44423. * Fired when the touchpad values on this controller are modified
  44424. */
  44425. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44426. private _updateTrackpad;
  44427. /**
  44428. * Called once per frame by the engine.
  44429. */
  44430. update(): void;
  44431. /**
  44432. * Called once for each button that changed state since the last frame
  44433. * @param buttonIdx Which button index changed
  44434. * @param state New state of the button
  44435. * @param changes Which properties on the state changed since last frame
  44436. */
  44437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44438. /**
  44439. * Moves the buttons on the controller mesh based on their current state
  44440. * @param buttonName the name of the button to move
  44441. * @param buttonValue the value of the button which determines the buttons new position
  44442. */
  44443. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44444. /**
  44445. * Moves the axis on the controller mesh based on its current state
  44446. * @param axis the index of the axis
  44447. * @param axisValue the value of the axis which determines the meshes new position
  44448. * @hidden
  44449. */
  44450. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44451. /**
  44452. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44453. * @param scene scene in which to add meshes
  44454. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44455. */
  44456. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44457. /**
  44458. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44459. * can be transformed by button presses and axes values, based on this._mapping.
  44460. *
  44461. * @param scene scene in which the meshes exist
  44462. * @param meshes list of meshes that make up the controller model to process
  44463. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44464. */
  44465. private processModel;
  44466. private createMeshInfo;
  44467. /**
  44468. * Gets the ray of the controller in the direction the controller is pointing
  44469. * @param length the length the resulting ray should be
  44470. * @returns a ray in the direction the controller is pointing
  44471. */
  44472. getForwardRay(length?: number): Ray;
  44473. /**
  44474. * Disposes of the controller
  44475. */
  44476. dispose(): void;
  44477. }
  44478. }
  44479. declare module BABYLON {
  44480. /**
  44481. * Interface to implement to create a shadow generator compatible with BJS.
  44482. */
  44483. interface IShadowGenerator {
  44484. /**
  44485. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44486. * @returns The render target texture if present otherwise, null
  44487. */
  44488. getShadowMap(): Nullable<RenderTargetTexture>;
  44489. /**
  44490. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44491. * @returns The render target texture if the shadow map is present otherwise, null
  44492. */
  44493. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44494. /**
  44495. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44496. * @param subMesh The submesh we want to render in the shadow map
  44497. * @param useInstances Defines wether will draw in the map using instances
  44498. * @returns true if ready otherwise, false
  44499. */
  44500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44501. /**
  44502. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44503. * @param defines Defines of the material we want to update
  44504. * @param lightIndex Index of the light in the enabled light list of the material
  44505. */
  44506. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44507. /**
  44508. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44509. * defined in the generator but impacting the effect).
  44510. * It implies the unifroms available on the materials are the standard BJS ones.
  44511. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44512. * @param effect The effect we are binfing the information for
  44513. */
  44514. bindShadowLight(lightIndex: string, effect: Effect): void;
  44515. /**
  44516. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44517. * (eq to shadow prjection matrix * light transform matrix)
  44518. * @returns The transform matrix used to create the shadow map
  44519. */
  44520. getTransformMatrix(): Matrix;
  44521. /**
  44522. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44523. * Cube and 2D textures for instance.
  44524. */
  44525. recreateShadowMap(): void;
  44526. /**
  44527. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44528. * @param onCompiled Callback triggered at the and of the effects compilation
  44529. * @param options Sets of optional options forcing the compilation with different modes
  44530. */
  44531. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44532. useInstances: boolean;
  44533. }>): void;
  44534. /**
  44535. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44536. * @param options Sets of optional options forcing the compilation with different modes
  44537. * @returns A promise that resolves when the compilation completes
  44538. */
  44539. forceCompilationAsync(options?: Partial<{
  44540. useInstances: boolean;
  44541. }>): Promise<void>;
  44542. /**
  44543. * Serializes the shadow generator setup to a json object.
  44544. * @returns The serialized JSON object
  44545. */
  44546. serialize(): any;
  44547. /**
  44548. * Disposes the Shadow map and related Textures and effects.
  44549. */
  44550. dispose(): void;
  44551. }
  44552. /**
  44553. * Default implementation IShadowGenerator.
  44554. * This is the main object responsible of generating shadows in the framework.
  44555. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44556. */
  44557. class ShadowGenerator implements IShadowGenerator {
  44558. /**
  44559. * Shadow generator mode None: no filtering applied.
  44560. */
  44561. static readonly FILTER_NONE: number;
  44562. /**
  44563. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44564. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44565. */
  44566. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44567. /**
  44568. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44569. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44570. */
  44571. static readonly FILTER_POISSONSAMPLING: number;
  44572. /**
  44573. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44574. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44575. */
  44576. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44577. /**
  44578. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44579. * edge artifacts on steep falloff.
  44580. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44581. */
  44582. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44583. /**
  44584. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44585. * edge artifacts on steep falloff.
  44586. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44587. */
  44588. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44589. /**
  44590. * Shadow generator mode PCF: Percentage Closer Filtering
  44591. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44592. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44593. */
  44594. static readonly FILTER_PCF: number;
  44595. /**
  44596. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44597. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44598. * Contact Hardening
  44599. */
  44600. static readonly FILTER_PCSS: number;
  44601. /**
  44602. * Reserved for PCF and PCSS
  44603. * Highest Quality.
  44604. *
  44605. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44606. *
  44607. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44608. */
  44609. static readonly QUALITY_HIGH: number;
  44610. /**
  44611. * Reserved for PCF and PCSS
  44612. * Good tradeoff for quality/perf cross devices
  44613. *
  44614. * Execute PCF on a 3*3 kernel.
  44615. *
  44616. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44617. */
  44618. static readonly QUALITY_MEDIUM: number;
  44619. /**
  44620. * Reserved for PCF and PCSS
  44621. * The lowest quality but the fastest.
  44622. *
  44623. * Execute PCF on a 1*1 kernel.
  44624. *
  44625. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44626. */
  44627. static readonly QUALITY_LOW: number;
  44628. private _bias;
  44629. /**
  44630. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44631. */
  44632. /**
  44633. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44634. */
  44635. bias: number;
  44636. private _normalBias;
  44637. /**
  44638. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44639. */
  44640. /**
  44641. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44642. */
  44643. normalBias: number;
  44644. private _blurBoxOffset;
  44645. /**
  44646. * Gets the blur box offset: offset applied during the blur pass.
  44647. * Only useful if useKernelBlur = false
  44648. */
  44649. /**
  44650. * Sets the blur box offset: offset applied during the blur pass.
  44651. * Only useful if useKernelBlur = false
  44652. */
  44653. blurBoxOffset: number;
  44654. private _blurScale;
  44655. /**
  44656. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44657. * 2 means half of the size.
  44658. */
  44659. /**
  44660. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44661. * 2 means half of the size.
  44662. */
  44663. blurScale: number;
  44664. private _blurKernel;
  44665. /**
  44666. * Gets the blur kernel: kernel size of the blur pass.
  44667. * Only useful if useKernelBlur = true
  44668. */
  44669. /**
  44670. * Sets the blur kernel: kernel size of the blur pass.
  44671. * Only useful if useKernelBlur = true
  44672. */
  44673. blurKernel: number;
  44674. private _useKernelBlur;
  44675. /**
  44676. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44677. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44678. */
  44679. /**
  44680. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44681. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44682. */
  44683. useKernelBlur: boolean;
  44684. private _depthScale;
  44685. /**
  44686. * Gets the depth scale used in ESM mode.
  44687. */
  44688. /**
  44689. * Sets the depth scale used in ESM mode.
  44690. * This can override the scale stored on the light.
  44691. */
  44692. depthScale: number;
  44693. private _filter;
  44694. /**
  44695. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44696. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44697. */
  44698. /**
  44699. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44700. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44701. */
  44702. filter: number;
  44703. /**
  44704. * Gets if the current filter is set to Poisson Sampling.
  44705. */
  44706. /**
  44707. * Sets the current filter to Poisson Sampling.
  44708. */
  44709. usePoissonSampling: boolean;
  44710. /**
  44711. * Gets if the current filter is set to ESM.
  44712. */
  44713. /**
  44714. * Sets the current filter is to ESM.
  44715. */
  44716. useExponentialShadowMap: boolean;
  44717. /**
  44718. * Gets if the current filter is set to filtered ESM.
  44719. */
  44720. /**
  44721. * Gets if the current filter is set to filtered ESM.
  44722. */
  44723. useBlurExponentialShadowMap: boolean;
  44724. /**
  44725. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44726. * exponential to prevent steep falloff artifacts).
  44727. */
  44728. /**
  44729. * Sets the current filter to "close ESM" (using the inverse of the
  44730. * exponential to prevent steep falloff artifacts).
  44731. */
  44732. useCloseExponentialShadowMap: boolean;
  44733. /**
  44734. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44735. * exponential to prevent steep falloff artifacts).
  44736. */
  44737. /**
  44738. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44739. * exponential to prevent steep falloff artifacts).
  44740. */
  44741. useBlurCloseExponentialShadowMap: boolean;
  44742. /**
  44743. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44744. */
  44745. /**
  44746. * Sets the current filter to "PCF" (percentage closer filtering).
  44747. */
  44748. usePercentageCloserFiltering: boolean;
  44749. private _filteringQuality;
  44750. /**
  44751. * Gets the PCF or PCSS Quality.
  44752. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44753. */
  44754. /**
  44755. * Sets the PCF or PCSS Quality.
  44756. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44757. */
  44758. filteringQuality: number;
  44759. /**
  44760. * Gets if the current filter is set to "PCSS" (contact hardening).
  44761. */
  44762. /**
  44763. * Sets the current filter to "PCSS" (contact hardening).
  44764. */
  44765. useContactHardeningShadow: boolean;
  44766. private _contactHardeningLightSizeUVRatio;
  44767. /**
  44768. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44769. * Using a ratio helps keeping shape stability independently of the map size.
  44770. *
  44771. * It does not account for the light projection as it was having too much
  44772. * instability during the light setup or during light position changes.
  44773. *
  44774. * Only valid if useContactHardeningShadow is true.
  44775. */
  44776. /**
  44777. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44778. * Using a ratio helps keeping shape stability independently of the map size.
  44779. *
  44780. * It does not account for the light projection as it was having too much
  44781. * instability during the light setup or during light position changes.
  44782. *
  44783. * Only valid if useContactHardeningShadow is true.
  44784. */
  44785. contactHardeningLightSizeUVRatio: number;
  44786. private _darkness;
  44787. /**
  44788. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44789. * 0 means strongest and 1 would means no shadow.
  44790. * @returns the darkness.
  44791. */
  44792. getDarkness(): number;
  44793. /**
  44794. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44795. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44796. * @returns the shadow generator allowing fluent coding.
  44797. */
  44798. setDarkness(darkness: number): ShadowGenerator;
  44799. private _transparencyShadow;
  44800. /**
  44801. * Sets the ability to have transparent shadow (boolean).
  44802. * @param transparent True if transparent else False
  44803. * @returns the shadow generator allowing fluent coding
  44804. */
  44805. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44806. private _shadowMap;
  44807. private _shadowMap2;
  44808. /**
  44809. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44810. * @returns The render target texture if present otherwise, null
  44811. */
  44812. getShadowMap(): Nullable<RenderTargetTexture>;
  44813. /**
  44814. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44815. * @returns The render target texture if the shadow map is present otherwise, null
  44816. */
  44817. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44818. /**
  44819. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44820. * @param mesh Mesh to add
  44821. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44822. * @returns the Shadow Generator itself
  44823. */
  44824. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44825. /**
  44826. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44827. * @param mesh Mesh to remove
  44828. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44829. * @returns the Shadow Generator itself
  44830. */
  44831. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44832. /**
  44833. * Controls the extent to which the shadows fade out at the edge of the frustum
  44834. * Used only by directionals and spots
  44835. */
  44836. frustumEdgeFalloff: number;
  44837. private _light;
  44838. /**
  44839. * Returns the associated light object.
  44840. * @returns the light generating the shadow
  44841. */
  44842. getLight(): IShadowLight;
  44843. /**
  44844. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44845. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44846. * It might on the other hand introduce peter panning.
  44847. */
  44848. forceBackFacesOnly: boolean;
  44849. private _scene;
  44850. private _lightDirection;
  44851. private _effect;
  44852. private _viewMatrix;
  44853. private _projectionMatrix;
  44854. private _transformMatrix;
  44855. private _cachedPosition;
  44856. private _cachedDirection;
  44857. private _cachedDefines;
  44858. private _currentRenderID;
  44859. private _boxBlurPostprocess;
  44860. private _kernelBlurXPostprocess;
  44861. private _kernelBlurYPostprocess;
  44862. private _blurPostProcesses;
  44863. private _mapSize;
  44864. private _currentFaceIndex;
  44865. private _currentFaceIndexCache;
  44866. private _textureType;
  44867. private _defaultTextureMatrix;
  44868. /**
  44869. * Creates a ShadowGenerator object.
  44870. * A ShadowGenerator is the required tool to use the shadows.
  44871. * Each light casting shadows needs to use its own ShadowGenerator.
  44872. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44873. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44874. * @param light The light object generating the shadows.
  44875. * @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.
  44876. */
  44877. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44878. private _initializeGenerator;
  44879. private _initializeShadowMap;
  44880. private _initializeBlurRTTAndPostProcesses;
  44881. private _renderForShadowMap;
  44882. private _renderSubMeshForShadowMap;
  44883. private _applyFilterValues;
  44884. /**
  44885. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44886. * @param onCompiled Callback triggered at the and of the effects compilation
  44887. * @param options Sets of optional options forcing the compilation with different modes
  44888. */
  44889. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44890. useInstances: boolean;
  44891. }>): void;
  44892. /**
  44893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44894. * @param options Sets of optional options forcing the compilation with different modes
  44895. * @returns A promise that resolves when the compilation completes
  44896. */
  44897. forceCompilationAsync(options?: Partial<{
  44898. useInstances: boolean;
  44899. }>): Promise<void>;
  44900. /**
  44901. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44902. * @param subMesh The submesh we want to render in the shadow map
  44903. * @param useInstances Defines wether will draw in the map using instances
  44904. * @returns true if ready otherwise, false
  44905. */
  44906. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44907. /**
  44908. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44909. * @param defines Defines of the material we want to update
  44910. * @param lightIndex Index of the light in the enabled light list of the material
  44911. */
  44912. prepareDefines(defines: any, lightIndex: number): void;
  44913. /**
  44914. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44915. * defined in the generator but impacting the effect).
  44916. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44917. * @param effect The effect we are binfing the information for
  44918. */
  44919. bindShadowLight(lightIndex: string, effect: Effect): void;
  44920. /**
  44921. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44922. * (eq to shadow prjection matrix * light transform matrix)
  44923. * @returns The transform matrix used to create the shadow map
  44924. */
  44925. getTransformMatrix(): Matrix;
  44926. /**
  44927. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44928. * Cube and 2D textures for instance.
  44929. */
  44930. recreateShadowMap(): void;
  44931. private _disposeBlurPostProcesses;
  44932. private _disposeRTTandPostProcesses;
  44933. /**
  44934. * Disposes the ShadowGenerator.
  44935. * Returns nothing.
  44936. */
  44937. dispose(): void;
  44938. /**
  44939. * Serializes the shadow generator setup to a json object.
  44940. * @returns The serialized JSON object
  44941. */
  44942. serialize(): any;
  44943. /**
  44944. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44945. * @param parsedShadowGenerator The JSON object to parse
  44946. * @param scene The scene to create the shadow map for
  44947. * @returns The parsed shadow generator
  44948. */
  44949. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44950. }
  44951. }
  44952. declare module BABYLON {
  44953. /**
  44954. * Defines the shadow generator component responsible to manage any shadow generators
  44955. * in a given scene.
  44956. */
  44957. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44958. /**
  44959. * The component name helpfull to identify the component in the list of scene components.
  44960. */
  44961. readonly name: string;
  44962. /**
  44963. * The scene the component belongs to.
  44964. */
  44965. scene: Scene;
  44966. /**
  44967. * Creates a new instance of the component for the given scene
  44968. * @param scene Defines the scene to register the component in
  44969. */
  44970. constructor(scene: Scene);
  44971. /**
  44972. * Registers the component in a given scene
  44973. */
  44974. register(): void;
  44975. /**
  44976. * Rebuilds the elements related to this component in case of
  44977. * context lost for instance.
  44978. */
  44979. rebuild(): void;
  44980. /**
  44981. * Serializes the component data to the specified json object
  44982. * @param serializationObject The object to serialize to
  44983. */
  44984. serialize(serializationObject: any): void;
  44985. /**
  44986. * Adds all the element from the container to the scene
  44987. * @param container the container holding the elements
  44988. */
  44989. addFromContainer(container: AbstractScene): void;
  44990. /**
  44991. * Removes all the elements in the container from the scene
  44992. * @param container contains the elements to remove
  44993. */
  44994. removeFromContainer(container: AbstractScene): void;
  44995. /**
  44996. * Rebuilds the elements related to this component in case of
  44997. * context lost for instance.
  44998. */
  44999. dispose(): void;
  45000. private _gatherRenderTargets;
  45001. }
  45002. }
  45003. declare module BABYLON {
  45004. /**
  45005. * Background material used to create an efficient environement around your scene.
  45006. */
  45007. class BackgroundMaterial extends PushMaterial {
  45008. /**
  45009. * Standard reflectance value at parallel view angle.
  45010. */
  45011. static StandardReflectance0: number;
  45012. /**
  45013. * Standard reflectance value at grazing angle.
  45014. */
  45015. static StandardReflectance90: number;
  45016. protected _primaryColor: Color3;
  45017. /**
  45018. * Key light Color (multiply against the environement texture)
  45019. */
  45020. primaryColor: Color3;
  45021. protected __perceptualColor: Nullable<Color3>;
  45022. /**
  45023. * Experimental Internal Use Only.
  45024. *
  45025. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45026. * This acts as a helper to set the primary color to a more "human friendly" value.
  45027. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45028. * output color as close as possible from the chosen value.
  45029. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45030. * part of lighting setup.)
  45031. */
  45032. _perceptualColor: Nullable<Color3>;
  45033. protected _primaryColorShadowLevel: float;
  45034. /**
  45035. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45036. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45037. */
  45038. primaryColorShadowLevel: float;
  45039. protected _primaryColorHighlightLevel: float;
  45040. /**
  45041. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45042. * The primary color is used at the level chosen to define what the white area would look.
  45043. */
  45044. primaryColorHighlightLevel: float;
  45045. protected _reflectionTexture: Nullable<BaseTexture>;
  45046. /**
  45047. * Reflection Texture used in the material.
  45048. * Should be author in a specific way for the best result (refer to the documentation).
  45049. */
  45050. reflectionTexture: Nullable<BaseTexture>;
  45051. protected _reflectionBlur: float;
  45052. /**
  45053. * Reflection Texture level of blur.
  45054. *
  45055. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45056. * texture twice.
  45057. */
  45058. reflectionBlur: float;
  45059. protected _diffuseTexture: Nullable<BaseTexture>;
  45060. /**
  45061. * Diffuse Texture used in the material.
  45062. * Should be author in a specific way for the best result (refer to the documentation).
  45063. */
  45064. diffuseTexture: Nullable<BaseTexture>;
  45065. protected _shadowLights: Nullable<IShadowLight[]>;
  45066. /**
  45067. * Specify the list of lights casting shadow on the material.
  45068. * All scene shadow lights will be included if null.
  45069. */
  45070. shadowLights: Nullable<IShadowLight[]>;
  45071. protected _shadowLevel: float;
  45072. /**
  45073. * Helps adjusting the shadow to a softer level if required.
  45074. * 0 means black shadows and 1 means no shadows.
  45075. */
  45076. shadowLevel: float;
  45077. protected _sceneCenter: Vector3;
  45078. /**
  45079. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45080. * It is usually zero but might be interesting to modify according to your setup.
  45081. */
  45082. sceneCenter: Vector3;
  45083. protected _opacityFresnel: boolean;
  45084. /**
  45085. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45086. * This helps ensuring a nice transition when the camera goes under the ground.
  45087. */
  45088. opacityFresnel: boolean;
  45089. protected _reflectionFresnel: boolean;
  45090. /**
  45091. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45092. * This helps adding a mirror texture on the ground.
  45093. */
  45094. reflectionFresnel: boolean;
  45095. protected _reflectionFalloffDistance: number;
  45096. /**
  45097. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45098. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45099. */
  45100. reflectionFalloffDistance: number;
  45101. protected _reflectionAmount: number;
  45102. /**
  45103. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45104. */
  45105. reflectionAmount: number;
  45106. protected _reflectionReflectance0: number;
  45107. /**
  45108. * This specifies the weight of the reflection at grazing angle.
  45109. */
  45110. reflectionReflectance0: number;
  45111. protected _reflectionReflectance90: number;
  45112. /**
  45113. * This specifies the weight of the reflection at a perpendicular point of view.
  45114. */
  45115. reflectionReflectance90: number;
  45116. /**
  45117. * Sets the reflection reflectance fresnel values according to the default standard
  45118. * empirically know to work well :-)
  45119. */
  45120. reflectionStandardFresnelWeight: number;
  45121. protected _useRGBColor: boolean;
  45122. /**
  45123. * Helps to directly use the maps channels instead of their level.
  45124. */
  45125. useRGBColor: boolean;
  45126. protected _enableNoise: boolean;
  45127. /**
  45128. * This helps reducing the banding effect that could occur on the background.
  45129. */
  45130. enableNoise: boolean;
  45131. /**
  45132. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45133. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45134. * Recommended to be keep at 1.0 except for special cases.
  45135. */
  45136. fovMultiplier: number;
  45137. private _fovMultiplier;
  45138. /**
  45139. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45140. */
  45141. useEquirectangularFOV: boolean;
  45142. private _maxSimultaneousLights;
  45143. /**
  45144. * Number of Simultaneous lights allowed on the material.
  45145. */
  45146. maxSimultaneousLights: int;
  45147. /**
  45148. * Default configuration related to image processing available in the Background Material.
  45149. */
  45150. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45151. /**
  45152. * Keep track of the image processing observer to allow dispose and replace.
  45153. */
  45154. private _imageProcessingObserver;
  45155. /**
  45156. * Attaches a new image processing configuration to the PBR Material.
  45157. * @param configuration (if null the scene configuration will be use)
  45158. */
  45159. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45160. /**
  45161. * Gets the image processing configuration used either in this material.
  45162. */
  45163. /**
  45164. * Sets the Default image processing configuration used either in the this material.
  45165. *
  45166. * If sets to null, the scene one is in use.
  45167. */
  45168. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45169. /**
  45170. * Gets wether the color curves effect is enabled.
  45171. */
  45172. /**
  45173. * Sets wether the color curves effect is enabled.
  45174. */
  45175. cameraColorCurvesEnabled: boolean;
  45176. /**
  45177. * Gets wether the color grading effect is enabled.
  45178. */
  45179. /**
  45180. * Gets wether the color grading effect is enabled.
  45181. */
  45182. cameraColorGradingEnabled: boolean;
  45183. /**
  45184. * Gets wether tonemapping is enabled or not.
  45185. */
  45186. /**
  45187. * Sets wether tonemapping is enabled or not
  45188. */
  45189. cameraToneMappingEnabled: boolean;
  45190. /**
  45191. * The camera exposure used on this material.
  45192. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45193. * This corresponds to a photographic exposure.
  45194. */
  45195. /**
  45196. * The camera exposure used on this material.
  45197. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45198. * This corresponds to a photographic exposure.
  45199. */
  45200. cameraExposure: float;
  45201. /**
  45202. * Gets The camera contrast used on this material.
  45203. */
  45204. /**
  45205. * Sets The camera contrast used on this material.
  45206. */
  45207. cameraContrast: float;
  45208. /**
  45209. * Gets the Color Grading 2D Lookup Texture.
  45210. */
  45211. /**
  45212. * Sets the Color Grading 2D Lookup Texture.
  45213. */
  45214. cameraColorGradingTexture: Nullable<BaseTexture>;
  45215. /**
  45216. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45217. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45218. * 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;
  45219. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45220. */
  45221. /**
  45222. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45223. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45224. * 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;
  45225. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45226. */
  45227. cameraColorCurves: Nullable<ColorCurves>;
  45228. /**
  45229. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45230. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45231. */
  45232. switchToBGR: boolean;
  45233. private _renderTargets;
  45234. private _reflectionControls;
  45235. private _white;
  45236. private _primaryShadowColor;
  45237. private _primaryHighlightColor;
  45238. /**
  45239. * Instantiates a Background Material in the given scene
  45240. * @param name The friendly name of the material
  45241. * @param scene The scene to add the material to
  45242. */
  45243. constructor(name: string, scene: Scene);
  45244. /**
  45245. * Gets a boolean indicating that current material needs to register RTT
  45246. */
  45247. readonly hasRenderTargetTextures: boolean;
  45248. /**
  45249. * The entire material has been created in order to prevent overdraw.
  45250. * @returns false
  45251. */
  45252. needAlphaTesting(): boolean;
  45253. /**
  45254. * The entire material has been created in order to prevent overdraw.
  45255. * @returns true if blending is enable
  45256. */
  45257. needAlphaBlending(): boolean;
  45258. /**
  45259. * Checks wether the material is ready to be rendered for a given mesh.
  45260. * @param mesh The mesh to render
  45261. * @param subMesh The submesh to check against
  45262. * @param useInstances Specify wether or not the material is used with instances
  45263. * @returns true if all the dependencies are ready (Textures, Effects...)
  45264. */
  45265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45266. /**
  45267. * Compute the primary color according to the chosen perceptual color.
  45268. */
  45269. private _computePrimaryColorFromPerceptualColor;
  45270. /**
  45271. * Compute the highlights and shadow colors according to their chosen levels.
  45272. */
  45273. private _computePrimaryColors;
  45274. /**
  45275. * Build the uniform buffer used in the material.
  45276. */
  45277. buildUniformLayout(): void;
  45278. /**
  45279. * Unbind the material.
  45280. */
  45281. unbind(): void;
  45282. /**
  45283. * Bind only the world matrix to the material.
  45284. * @param world The world matrix to bind.
  45285. */
  45286. bindOnlyWorldMatrix(world: Matrix): void;
  45287. /**
  45288. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45289. * @param world The world matrix to bind.
  45290. * @param subMesh The submesh to bind for.
  45291. */
  45292. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45293. /**
  45294. * Dispose the material.
  45295. * @param forceDisposeEffect Force disposal of the associated effect.
  45296. * @param forceDisposeTextures Force disposal of the associated textures.
  45297. */
  45298. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45299. /**
  45300. * Clones the material.
  45301. * @param name The cloned name.
  45302. * @returns The cloned material.
  45303. */
  45304. clone(name: string): BackgroundMaterial;
  45305. /**
  45306. * Serializes the current material to its JSON representation.
  45307. * @returns The JSON representation.
  45308. */
  45309. serialize(): any;
  45310. /**
  45311. * Gets the class name of the material
  45312. * @returns "BackgroundMaterial"
  45313. */
  45314. getClassName(): string;
  45315. /**
  45316. * Parse a JSON input to create back a background material.
  45317. * @param source The JSON data to parse
  45318. * @param scene The scene to create the parsed material in
  45319. * @param rootUrl The root url of the assets the material depends upon
  45320. * @returns the instantiated BackgroundMaterial.
  45321. */
  45322. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45323. }
  45324. }
  45325. declare module BABYLON {
  45326. /**
  45327. * The Physically based material base class of BJS.
  45328. *
  45329. * This offers the main features of a standard PBR material.
  45330. * For more information, please refer to the documentation :
  45331. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45332. */
  45333. abstract class PBRBaseMaterial extends PushMaterial {
  45334. /**
  45335. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45336. */
  45337. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45338. /**
  45339. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45340. * to enhance interoperability with other engines.
  45341. */
  45342. static readonly LIGHTFALLOFF_GLTF: number;
  45343. /**
  45344. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45345. * to enhance interoperability with other materials.
  45346. */
  45347. static readonly LIGHTFALLOFF_STANDARD: number;
  45348. /**
  45349. * Intensity of the direct lights e.g. the four lights available in your scene.
  45350. * This impacts both the direct diffuse and specular highlights.
  45351. */
  45352. protected _directIntensity: number;
  45353. /**
  45354. * Intensity of the emissive part of the material.
  45355. * This helps controlling the emissive effect without modifying the emissive color.
  45356. */
  45357. protected _emissiveIntensity: number;
  45358. /**
  45359. * Intensity of the environment e.g. how much the environment will light the object
  45360. * either through harmonics for rough material or through the refelction for shiny ones.
  45361. */
  45362. protected _environmentIntensity: number;
  45363. /**
  45364. * This is a special control allowing the reduction of the specular highlights coming from the
  45365. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45366. */
  45367. protected _specularIntensity: number;
  45368. /**
  45369. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45370. */
  45371. private _lightingInfos;
  45372. /**
  45373. * Debug Control allowing disabling the bump map on this material.
  45374. */
  45375. protected _disableBumpMap: boolean;
  45376. /**
  45377. * AKA Diffuse Texture in standard nomenclature.
  45378. */
  45379. protected _albedoTexture: BaseTexture;
  45380. /**
  45381. * AKA Occlusion Texture in other nomenclature.
  45382. */
  45383. protected _ambientTexture: BaseTexture;
  45384. /**
  45385. * AKA Occlusion Texture Intensity in other nomenclature.
  45386. */
  45387. protected _ambientTextureStrength: number;
  45388. /**
  45389. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45390. * 1 means it completely occludes it
  45391. * 0 mean it has no impact
  45392. */
  45393. protected _ambientTextureImpactOnAnalyticalLights: number;
  45394. /**
  45395. * Stores the alpha values in a texture.
  45396. */
  45397. protected _opacityTexture: BaseTexture;
  45398. /**
  45399. * Stores the reflection values in a texture.
  45400. */
  45401. protected _reflectionTexture: BaseTexture;
  45402. /**
  45403. * Stores the refraction values in a texture.
  45404. */
  45405. protected _refractionTexture: BaseTexture;
  45406. /**
  45407. * Stores the emissive values in a texture.
  45408. */
  45409. protected _emissiveTexture: BaseTexture;
  45410. /**
  45411. * AKA Specular texture in other nomenclature.
  45412. */
  45413. protected _reflectivityTexture: BaseTexture;
  45414. /**
  45415. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45416. */
  45417. protected _metallicTexture: BaseTexture;
  45418. /**
  45419. * Specifies the metallic scalar of the metallic/roughness workflow.
  45420. * Can also be used to scale the metalness values of the metallic texture.
  45421. */
  45422. protected _metallic: Nullable<number>;
  45423. /**
  45424. * Specifies the roughness scalar of the metallic/roughness workflow.
  45425. * Can also be used to scale the roughness values of the metallic texture.
  45426. */
  45427. protected _roughness: Nullable<number>;
  45428. /**
  45429. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45430. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45431. */
  45432. protected _microSurfaceTexture: BaseTexture;
  45433. /**
  45434. * Stores surface normal data used to displace a mesh in a texture.
  45435. */
  45436. protected _bumpTexture: BaseTexture;
  45437. /**
  45438. * Stores the pre-calculated light information of a mesh in a texture.
  45439. */
  45440. protected _lightmapTexture: BaseTexture;
  45441. /**
  45442. * The color of a material in ambient lighting.
  45443. */
  45444. protected _ambientColor: Color3;
  45445. /**
  45446. * AKA Diffuse Color in other nomenclature.
  45447. */
  45448. protected _albedoColor: Color3;
  45449. /**
  45450. * AKA Specular Color in other nomenclature.
  45451. */
  45452. protected _reflectivityColor: Color3;
  45453. /**
  45454. * The color applied when light is reflected from a material.
  45455. */
  45456. protected _reflectionColor: Color3;
  45457. /**
  45458. * The color applied when light is emitted from a material.
  45459. */
  45460. protected _emissiveColor: Color3;
  45461. /**
  45462. * AKA Glossiness in other nomenclature.
  45463. */
  45464. protected _microSurface: number;
  45465. /**
  45466. * source material index of refraction (IOR)' / 'destination material IOR.
  45467. */
  45468. protected _indexOfRefraction: number;
  45469. /**
  45470. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45471. */
  45472. protected _invertRefractionY: boolean;
  45473. /**
  45474. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45475. * Materials half opaque for instance using refraction could benefit from this control.
  45476. */
  45477. protected _linkRefractionWithTransparency: boolean;
  45478. /**
  45479. * Specifies that the material will use the light map as a show map.
  45480. */
  45481. protected _useLightmapAsShadowmap: boolean;
  45482. /**
  45483. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45484. * makes the reflect vector face the model (under horizon).
  45485. */
  45486. protected _useHorizonOcclusion: boolean;
  45487. /**
  45488. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45489. * too much the area relying on ambient texture to define their ambient occlusion.
  45490. */
  45491. protected _useRadianceOcclusion: boolean;
  45492. /**
  45493. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45494. */
  45495. protected _useAlphaFromAlbedoTexture: boolean;
  45496. /**
  45497. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45498. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45499. */
  45500. protected _useSpecularOverAlpha: boolean;
  45501. /**
  45502. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45503. */
  45504. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45505. /**
  45506. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45507. */
  45508. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45509. /**
  45510. * Specifies if the metallic texture contains the roughness information in its green channel.
  45511. */
  45512. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45513. /**
  45514. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45515. */
  45516. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45517. /**
  45518. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45519. */
  45520. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45521. /**
  45522. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45523. */
  45524. protected _useAmbientInGrayScale: boolean;
  45525. /**
  45526. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45527. * The material will try to infer what glossiness each pixel should be.
  45528. */
  45529. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45530. /**
  45531. * Defines the falloff type used in this material.
  45532. * It by default is Physical.
  45533. */
  45534. protected _lightFalloff: number;
  45535. /**
  45536. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45537. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45538. */
  45539. protected _useRadianceOverAlpha: boolean;
  45540. /**
  45541. * Allows using an object space normal map (instead of tangent space).
  45542. */
  45543. protected _useObjectSpaceNormalMap: boolean;
  45544. /**
  45545. * Allows using the bump map in parallax mode.
  45546. */
  45547. protected _useParallax: boolean;
  45548. /**
  45549. * Allows using the bump map in parallax occlusion mode.
  45550. */
  45551. protected _useParallaxOcclusion: boolean;
  45552. /**
  45553. * Controls the scale bias of the parallax mode.
  45554. */
  45555. protected _parallaxScaleBias: number;
  45556. /**
  45557. * If sets to true, disables all the lights affecting the material.
  45558. */
  45559. protected _disableLighting: boolean;
  45560. /**
  45561. * Number of Simultaneous lights allowed on the material.
  45562. */
  45563. protected _maxSimultaneousLights: number;
  45564. /**
  45565. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45566. */
  45567. protected _invertNormalMapX: boolean;
  45568. /**
  45569. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45570. */
  45571. protected _invertNormalMapY: boolean;
  45572. /**
  45573. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45574. */
  45575. protected _twoSidedLighting: boolean;
  45576. /**
  45577. * Defines the alpha limits in alpha test mode.
  45578. */
  45579. protected _alphaCutOff: number;
  45580. /**
  45581. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45582. */
  45583. protected _forceAlphaTest: boolean;
  45584. /**
  45585. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45586. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45587. */
  45588. protected _useAlphaFresnel: boolean;
  45589. /**
  45590. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45591. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45592. */
  45593. protected _useLinearAlphaFresnel: boolean;
  45594. /**
  45595. * The transparency mode of the material.
  45596. */
  45597. protected _transparencyMode: Nullable<number>;
  45598. /**
  45599. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45600. * from cos thetav and roughness:
  45601. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45602. */
  45603. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45604. /**
  45605. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45606. */
  45607. protected _forceIrradianceInFragment: boolean;
  45608. /**
  45609. * Force normal to face away from face.
  45610. */
  45611. protected _forceNormalForward: boolean;
  45612. /**
  45613. * Enables specular anti aliasing in the PBR shader.
  45614. * It will both interacts on the Geometry for analytical and IBL lighting.
  45615. * It also prefilter the roughness map based on the bump values.
  45616. */
  45617. protected _enableSpecularAntiAliasing: boolean;
  45618. /**
  45619. * Default configuration related to image processing available in the PBR Material.
  45620. */
  45621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45622. /**
  45623. * Keep track of the image processing observer to allow dispose and replace.
  45624. */
  45625. private _imageProcessingObserver;
  45626. /**
  45627. * Attaches a new image processing configuration to the PBR Material.
  45628. * @param configuration
  45629. */
  45630. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45631. /**
  45632. * Stores the available render targets.
  45633. */
  45634. private _renderTargets;
  45635. /**
  45636. * Sets the global ambient color for the material used in lighting calculations.
  45637. */
  45638. private _globalAmbientColor;
  45639. /**
  45640. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45641. */
  45642. private _useLogarithmicDepth;
  45643. /**
  45644. * If set to true, no lighting calculations will be applied.
  45645. */
  45646. private _unlit;
  45647. /**
  45648. * Instantiates a new PBRMaterial instance.
  45649. *
  45650. * @param name The material name
  45651. * @param scene The scene the material will be use in.
  45652. */
  45653. constructor(name: string, scene: Scene);
  45654. /**
  45655. * Gets a boolean indicating that current material needs to register RTT
  45656. */
  45657. readonly hasRenderTargetTextures: boolean;
  45658. /**
  45659. * Gets the name of the material class.
  45660. */
  45661. getClassName(): string;
  45662. /**
  45663. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45664. */
  45665. /**
  45666. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45667. */
  45668. useLogarithmicDepth: boolean;
  45669. /**
  45670. * Gets the current transparency mode.
  45671. */
  45672. /**
  45673. * Sets the transparency mode of the material.
  45674. *
  45675. * | Value | Type | Description |
  45676. * | ----- | ----------------------------------- | ----------- |
  45677. * | 0 | OPAQUE | |
  45678. * | 1 | ALPHATEST | |
  45679. * | 2 | ALPHABLEND | |
  45680. * | 3 | ALPHATESTANDBLEND | |
  45681. *
  45682. */
  45683. transparencyMode: Nullable<number>;
  45684. /**
  45685. * Returns true if alpha blending should be disabled.
  45686. */
  45687. private readonly _disableAlphaBlending;
  45688. /**
  45689. * Specifies whether or not this material should be rendered in alpha blend mode.
  45690. */
  45691. needAlphaBlending(): boolean;
  45692. /**
  45693. * Specifies if the mesh will require alpha blending.
  45694. * @param mesh - BJS mesh.
  45695. */
  45696. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45697. /**
  45698. * Specifies whether or not this material should be rendered in alpha test mode.
  45699. */
  45700. needAlphaTesting(): boolean;
  45701. /**
  45702. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45703. */
  45704. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45705. /**
  45706. * Gets the texture used for the alpha test.
  45707. */
  45708. getAlphaTestTexture(): BaseTexture;
  45709. /**
  45710. * Stores the reflectivity values based on metallic roughness workflow.
  45711. */
  45712. private static _scaledReflectivity;
  45713. /**
  45714. * Specifies that the submesh is ready to be used.
  45715. * @param mesh - BJS mesh.
  45716. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45717. * @param useInstances - Specifies that instances should be used.
  45718. * @returns - boolean indicating that the submesh is ready or not.
  45719. */
  45720. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45721. /**
  45722. * Specifies if the material uses metallic roughness workflow.
  45723. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45724. */
  45725. isMetallicWorkflow(): boolean;
  45726. private _prepareEffect;
  45727. private _prepareDefines;
  45728. /**
  45729. * Force shader compilation
  45730. */
  45731. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45732. clipPlane: boolean;
  45733. }>): void;
  45734. /**
  45735. * Initializes the uniform buffer layout for the shader.
  45736. */
  45737. buildUniformLayout(): void;
  45738. /**
  45739. * Unbinds the textures.
  45740. */
  45741. unbind(): void;
  45742. /**
  45743. * Binds the submesh data.
  45744. * @param world - The world matrix.
  45745. * @param mesh - The BJS mesh.
  45746. * @param subMesh - A submesh of the BJS mesh.
  45747. */
  45748. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45749. /**
  45750. * Returns the animatable textures.
  45751. * @returns - Array of animatable textures.
  45752. */
  45753. getAnimatables(): IAnimatable[];
  45754. /**
  45755. * Returns the texture used for reflections.
  45756. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45757. */
  45758. private _getReflectionTexture;
  45759. /**
  45760. * Returns the texture used for refraction or null if none is used.
  45761. * @returns - Refection texture if present. If no refraction texture and refraction
  45762. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45763. */
  45764. private _getRefractionTexture;
  45765. /**
  45766. * Disposes the resources of the material.
  45767. * @param forceDisposeEffect - Forces the disposal of effects.
  45768. * @param forceDisposeTextures - Forces the disposal of all textures.
  45769. */
  45770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45771. }
  45772. }
  45773. declare module BABYLON {
  45774. /**
  45775. * The Physically based simple base material of BJS.
  45776. *
  45777. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45778. * It is used as the base class for both the specGloss and metalRough conventions.
  45779. */
  45780. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45781. /**
  45782. * Number of Simultaneous lights allowed on the material.
  45783. */
  45784. maxSimultaneousLights: number;
  45785. /**
  45786. * If sets to true, disables all the lights affecting the material.
  45787. */
  45788. disableLighting: boolean;
  45789. /**
  45790. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45791. */
  45792. environmentTexture: BaseTexture;
  45793. /**
  45794. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45795. */
  45796. invertNormalMapX: boolean;
  45797. /**
  45798. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45799. */
  45800. invertNormalMapY: boolean;
  45801. /**
  45802. * Normal map used in the model.
  45803. */
  45804. normalTexture: BaseTexture;
  45805. /**
  45806. * Emissivie color used to self-illuminate the model.
  45807. */
  45808. emissiveColor: Color3;
  45809. /**
  45810. * Emissivie texture used to self-illuminate the model.
  45811. */
  45812. emissiveTexture: BaseTexture;
  45813. /**
  45814. * Occlusion Channel Strenght.
  45815. */
  45816. occlusionStrength: number;
  45817. /**
  45818. * Occlusion Texture of the material (adding extra occlusion effects).
  45819. */
  45820. occlusionTexture: BaseTexture;
  45821. /**
  45822. * Defines the alpha limits in alpha test mode.
  45823. */
  45824. alphaCutOff: number;
  45825. /**
  45826. * Gets the current double sided mode.
  45827. */
  45828. /**
  45829. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45830. */
  45831. doubleSided: boolean;
  45832. /**
  45833. * Stores the pre-calculated light information of a mesh in a texture.
  45834. */
  45835. lightmapTexture: BaseTexture;
  45836. /**
  45837. * If true, the light map contains occlusion information instead of lighting info.
  45838. */
  45839. useLightmapAsShadowmap: boolean;
  45840. /**
  45841. * Return the active textures of the material.
  45842. */
  45843. getActiveTextures(): BaseTexture[];
  45844. hasTexture(texture: BaseTexture): boolean;
  45845. /**
  45846. * Instantiates a new PBRMaterial instance.
  45847. *
  45848. * @param name The material name
  45849. * @param scene The scene the material will be use in.
  45850. */
  45851. constructor(name: string, scene: Scene);
  45852. getClassName(): string;
  45853. }
  45854. }
  45855. declare module BABYLON {
  45856. /**
  45857. * The Physically based material of BJS.
  45858. *
  45859. * This offers the main features of a standard PBR material.
  45860. * For more information, please refer to the documentation :
  45861. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45862. */
  45863. class PBRMaterial extends PBRBaseMaterial {
  45864. /**
  45865. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45866. */
  45867. static readonly PBRMATERIAL_OPAQUE: number;
  45868. /**
  45869. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45870. */
  45871. static readonly PBRMATERIAL_ALPHATEST: number;
  45872. /**
  45873. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45874. */
  45875. static readonly PBRMATERIAL_ALPHABLEND: number;
  45876. /**
  45877. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45878. * They are also discarded below the alpha cutoff threshold to improve performances.
  45879. */
  45880. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45881. /**
  45882. * Defines the default value of how much AO map is occluding the analytical lights
  45883. * (point spot...).
  45884. */
  45885. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45886. /**
  45887. * Intensity of the direct lights e.g. the four lights available in your scene.
  45888. * This impacts both the direct diffuse and specular highlights.
  45889. */
  45890. directIntensity: number;
  45891. /**
  45892. * Intensity of the emissive part of the material.
  45893. * This helps controlling the emissive effect without modifying the emissive color.
  45894. */
  45895. emissiveIntensity: number;
  45896. /**
  45897. * Intensity of the environment e.g. how much the environment will light the object
  45898. * either through harmonics for rough material or through the refelction for shiny ones.
  45899. */
  45900. environmentIntensity: number;
  45901. /**
  45902. * This is a special control allowing the reduction of the specular highlights coming from the
  45903. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45904. */
  45905. specularIntensity: number;
  45906. /**
  45907. * Debug Control allowing disabling the bump map on this material.
  45908. */
  45909. disableBumpMap: boolean;
  45910. /**
  45911. * AKA Diffuse Texture in standard nomenclature.
  45912. */
  45913. albedoTexture: BaseTexture;
  45914. /**
  45915. * AKA Occlusion Texture in other nomenclature.
  45916. */
  45917. ambientTexture: BaseTexture;
  45918. /**
  45919. * AKA Occlusion Texture Intensity in other nomenclature.
  45920. */
  45921. ambientTextureStrength: number;
  45922. /**
  45923. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45924. * 1 means it completely occludes it
  45925. * 0 mean it has no impact
  45926. */
  45927. ambientTextureImpactOnAnalyticalLights: number;
  45928. /**
  45929. * Stores the alpha values in a texture.
  45930. */
  45931. opacityTexture: BaseTexture;
  45932. /**
  45933. * Stores the reflection values in a texture.
  45934. */
  45935. reflectionTexture: Nullable<BaseTexture>;
  45936. /**
  45937. * Stores the emissive values in a texture.
  45938. */
  45939. emissiveTexture: BaseTexture;
  45940. /**
  45941. * AKA Specular texture in other nomenclature.
  45942. */
  45943. reflectivityTexture: BaseTexture;
  45944. /**
  45945. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45946. */
  45947. metallicTexture: BaseTexture;
  45948. /**
  45949. * Specifies the metallic scalar of the metallic/roughness workflow.
  45950. * Can also be used to scale the metalness values of the metallic texture.
  45951. */
  45952. metallic: Nullable<number>;
  45953. /**
  45954. * Specifies the roughness scalar of the metallic/roughness workflow.
  45955. * Can also be used to scale the roughness values of the metallic texture.
  45956. */
  45957. roughness: Nullable<number>;
  45958. /**
  45959. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45960. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45961. */
  45962. microSurfaceTexture: BaseTexture;
  45963. /**
  45964. * Stores surface normal data used to displace a mesh in a texture.
  45965. */
  45966. bumpTexture: BaseTexture;
  45967. /**
  45968. * Stores the pre-calculated light information of a mesh in a texture.
  45969. */
  45970. lightmapTexture: BaseTexture;
  45971. /**
  45972. * Stores the refracted light information in a texture.
  45973. */
  45974. refractionTexture: BaseTexture;
  45975. /**
  45976. * The color of a material in ambient lighting.
  45977. */
  45978. ambientColor: Color3;
  45979. /**
  45980. * AKA Diffuse Color in other nomenclature.
  45981. */
  45982. albedoColor: Color3;
  45983. /**
  45984. * AKA Specular Color in other nomenclature.
  45985. */
  45986. reflectivityColor: Color3;
  45987. /**
  45988. * The color reflected from the material.
  45989. */
  45990. reflectionColor: Color3;
  45991. /**
  45992. * The color emitted from the material.
  45993. */
  45994. emissiveColor: Color3;
  45995. /**
  45996. * AKA Glossiness in other nomenclature.
  45997. */
  45998. microSurface: number;
  45999. /**
  46000. * source material index of refraction (IOR)' / 'destination material IOR.
  46001. */
  46002. indexOfRefraction: number;
  46003. /**
  46004. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46005. */
  46006. invertRefractionY: boolean;
  46007. /**
  46008. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46009. * Materials half opaque for instance using refraction could benefit from this control.
  46010. */
  46011. linkRefractionWithTransparency: boolean;
  46012. /**
  46013. * If true, the light map contains occlusion information instead of lighting info.
  46014. */
  46015. useLightmapAsShadowmap: boolean;
  46016. /**
  46017. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46018. */
  46019. useAlphaFromAlbedoTexture: boolean;
  46020. /**
  46021. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46022. */
  46023. forceAlphaTest: boolean;
  46024. /**
  46025. * Defines the alpha limits in alpha test mode.
  46026. */
  46027. alphaCutOff: number;
  46028. /**
  46029. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46030. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46031. */
  46032. useSpecularOverAlpha: boolean;
  46033. /**
  46034. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46035. */
  46036. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46037. /**
  46038. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46039. */
  46040. useRoughnessFromMetallicTextureAlpha: boolean;
  46041. /**
  46042. * Specifies if the metallic texture contains the roughness information in its green channel.
  46043. */
  46044. useRoughnessFromMetallicTextureGreen: boolean;
  46045. /**
  46046. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46047. */
  46048. useMetallnessFromMetallicTextureBlue: boolean;
  46049. /**
  46050. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46051. */
  46052. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46053. /**
  46054. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46055. */
  46056. useAmbientInGrayScale: boolean;
  46057. /**
  46058. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46059. * The material will try to infer what glossiness each pixel should be.
  46060. */
  46061. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46062. /**
  46063. * BJS is using an harcoded light falloff based on a manually sets up range.
  46064. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46065. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46066. */
  46067. /**
  46068. * BJS is using an harcoded light falloff based on a manually sets up range.
  46069. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46070. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46071. */
  46072. usePhysicalLightFalloff: boolean;
  46073. /**
  46074. * In order to support the falloff compatibility with gltf, a special mode has been added
  46075. * to reproduce the gltf light falloff.
  46076. */
  46077. /**
  46078. * In order to support the falloff compatibility with gltf, a special mode has been added
  46079. * to reproduce the gltf light falloff.
  46080. */
  46081. useGLTFLightFalloff: boolean;
  46082. /**
  46083. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46084. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46085. */
  46086. useRadianceOverAlpha: boolean;
  46087. /**
  46088. * Allows using an object space normal map (instead of tangent space).
  46089. */
  46090. useObjectSpaceNormalMap: boolean;
  46091. /**
  46092. * Allows using the bump map in parallax mode.
  46093. */
  46094. useParallax: boolean;
  46095. /**
  46096. * Allows using the bump map in parallax occlusion mode.
  46097. */
  46098. useParallaxOcclusion: boolean;
  46099. /**
  46100. * Controls the scale bias of the parallax mode.
  46101. */
  46102. parallaxScaleBias: number;
  46103. /**
  46104. * If sets to true, disables all the lights affecting the material.
  46105. */
  46106. disableLighting: boolean;
  46107. /**
  46108. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46109. */
  46110. forceIrradianceInFragment: boolean;
  46111. /**
  46112. * Number of Simultaneous lights allowed on the material.
  46113. */
  46114. maxSimultaneousLights: number;
  46115. /**
  46116. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46117. */
  46118. invertNormalMapX: boolean;
  46119. /**
  46120. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46121. */
  46122. invertNormalMapY: boolean;
  46123. /**
  46124. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46125. */
  46126. twoSidedLighting: boolean;
  46127. /**
  46128. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46129. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46130. */
  46131. useAlphaFresnel: boolean;
  46132. /**
  46133. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46134. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46135. */
  46136. useLinearAlphaFresnel: boolean;
  46137. /**
  46138. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46139. * And/Or occlude the blended part.
  46140. */
  46141. environmentBRDFTexture: Nullable<BaseTexture>;
  46142. /**
  46143. * Force normal to face away from face.
  46144. */
  46145. forceNormalForward: boolean;
  46146. /**
  46147. * Enables specular anti aliasing in the PBR shader.
  46148. * It will both interacts on the Geometry for analytical and IBL lighting.
  46149. * It also prefilter the roughness map based on the bump values.
  46150. */
  46151. enableSpecularAntiAliasing: boolean;
  46152. /**
  46153. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46154. * makes the reflect vector face the model (under horizon).
  46155. */
  46156. useHorizonOcclusion: boolean;
  46157. /**
  46158. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46159. * too much the area relying on ambient texture to define their ambient occlusion.
  46160. */
  46161. useRadianceOcclusion: boolean;
  46162. /**
  46163. * If set to true, no lighting calculations will be applied.
  46164. */
  46165. unlit: boolean;
  46166. /**
  46167. * Gets the image processing configuration used either in this material.
  46168. */
  46169. /**
  46170. * Sets the Default image processing configuration used either in the this material.
  46171. *
  46172. * If sets to null, the scene one is in use.
  46173. */
  46174. imageProcessingConfiguration: ImageProcessingConfiguration;
  46175. /**
  46176. * Gets wether the color curves effect is enabled.
  46177. */
  46178. /**
  46179. * Sets wether the color curves effect is enabled.
  46180. */
  46181. cameraColorCurvesEnabled: boolean;
  46182. /**
  46183. * Gets wether the color grading effect is enabled.
  46184. */
  46185. /**
  46186. * Gets wether the color grading effect is enabled.
  46187. */
  46188. cameraColorGradingEnabled: boolean;
  46189. /**
  46190. * Gets wether tonemapping is enabled or not.
  46191. */
  46192. /**
  46193. * Sets wether tonemapping is enabled or not
  46194. */
  46195. cameraToneMappingEnabled: boolean;
  46196. /**
  46197. * The camera exposure used on this material.
  46198. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46199. * This corresponds to a photographic exposure.
  46200. */
  46201. /**
  46202. * The camera exposure used on this material.
  46203. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46204. * This corresponds to a photographic exposure.
  46205. */
  46206. cameraExposure: number;
  46207. /**
  46208. * Gets The camera contrast used on this material.
  46209. */
  46210. /**
  46211. * Sets The camera contrast used on this material.
  46212. */
  46213. cameraContrast: number;
  46214. /**
  46215. * Gets the Color Grading 2D Lookup Texture.
  46216. */
  46217. /**
  46218. * Sets the Color Grading 2D Lookup Texture.
  46219. */
  46220. cameraColorGradingTexture: Nullable<BaseTexture>;
  46221. /**
  46222. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46223. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46224. * 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;
  46225. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46226. */
  46227. /**
  46228. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46229. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46230. * 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;
  46231. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46232. */
  46233. cameraColorCurves: Nullable<ColorCurves>;
  46234. /**
  46235. * Instantiates a new PBRMaterial instance.
  46236. *
  46237. * @param name The material name
  46238. * @param scene The scene the material will be use in.
  46239. */
  46240. constructor(name: string, scene: Scene);
  46241. /**
  46242. * Returns the name of this material class.
  46243. */
  46244. getClassName(): string;
  46245. /**
  46246. * Returns an array of the actively used textures.
  46247. * @returns - Array of BaseTextures
  46248. */
  46249. getActiveTextures(): BaseTexture[];
  46250. /**
  46251. * Checks to see if a texture is used in the material.
  46252. * @param texture - Base texture to use.
  46253. * @returns - Boolean specifying if a texture is used in the material.
  46254. */
  46255. hasTexture(texture: BaseTexture): boolean;
  46256. /**
  46257. * Makes a duplicate of the current material.
  46258. * @param name - name to use for the new material.
  46259. */
  46260. clone(name: string): PBRMaterial;
  46261. /**
  46262. * Serializes this PBR Material.
  46263. * @returns - An object with the serialized material.
  46264. */
  46265. serialize(): any;
  46266. /**
  46267. * Parses a PBR Material from a serialized object.
  46268. * @param source - Serialized object.
  46269. * @param scene - BJS scene instance.
  46270. * @param rootUrl - url for the scene object
  46271. * @returns - PBRMaterial
  46272. */
  46273. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46274. }
  46275. }
  46276. declare module BABYLON {
  46277. /**
  46278. * The PBR material of BJS following the metal roughness convention.
  46279. *
  46280. * This fits to the PBR convention in the GLTF definition:
  46281. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46282. */
  46283. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46284. /**
  46285. * The base color has two different interpretations depending on the value of metalness.
  46286. * When the material is a metal, the base color is the specific measured reflectance value
  46287. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46288. * of the material.
  46289. */
  46290. baseColor: Color3;
  46291. /**
  46292. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46293. * well as opacity information in the alpha channel.
  46294. */
  46295. baseTexture: BaseTexture;
  46296. /**
  46297. * Specifies the metallic scalar value of the material.
  46298. * Can also be used to scale the metalness values of the metallic texture.
  46299. */
  46300. metallic: number;
  46301. /**
  46302. * Specifies the roughness scalar value of the material.
  46303. * Can also be used to scale the roughness values of the metallic texture.
  46304. */
  46305. roughness: number;
  46306. /**
  46307. * Texture containing both the metallic value in the B channel and the
  46308. * roughness value in the G channel to keep better precision.
  46309. */
  46310. metallicRoughnessTexture: BaseTexture;
  46311. /**
  46312. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46313. *
  46314. * @param name The material name
  46315. * @param scene The scene the material will be use in.
  46316. */
  46317. constructor(name: string, scene: Scene);
  46318. /**
  46319. * Return the currrent class name of the material.
  46320. */
  46321. getClassName(): string;
  46322. /**
  46323. * Return the active textures of the material.
  46324. */
  46325. getActiveTextures(): BaseTexture[];
  46326. /**
  46327. * Checks to see if a texture is used in the material.
  46328. * @param texture - Base texture to use.
  46329. * @returns - Boolean specifying if a texture is used in the material.
  46330. */
  46331. hasTexture(texture: BaseTexture): boolean;
  46332. /**
  46333. * Makes a duplicate of the current material.
  46334. * @param name - name to use for the new material.
  46335. */
  46336. clone(name: string): PBRMetallicRoughnessMaterial;
  46337. /**
  46338. * Serialize the material to a parsable JSON object.
  46339. */
  46340. serialize(): any;
  46341. /**
  46342. * Parses a JSON object correponding to the serialize function.
  46343. */
  46344. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46345. }
  46346. }
  46347. declare module BABYLON {
  46348. /**
  46349. * The PBR material of BJS following the specular glossiness convention.
  46350. *
  46351. * This fits to the PBR convention in the GLTF definition:
  46352. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46353. */
  46354. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46355. /**
  46356. * Specifies the diffuse color of the material.
  46357. */
  46358. diffuseColor: Color3;
  46359. /**
  46360. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46361. * channel.
  46362. */
  46363. diffuseTexture: BaseTexture;
  46364. /**
  46365. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46366. */
  46367. specularColor: Color3;
  46368. /**
  46369. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46370. */
  46371. glossiness: number;
  46372. /**
  46373. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46374. */
  46375. specularGlossinessTexture: BaseTexture;
  46376. /**
  46377. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46378. *
  46379. * @param name The material name
  46380. * @param scene The scene the material will be use in.
  46381. */
  46382. constructor(name: string, scene: Scene);
  46383. /**
  46384. * Return the currrent class name of the material.
  46385. */
  46386. getClassName(): string;
  46387. /**
  46388. * Return the active textures of the material.
  46389. */
  46390. getActiveTextures(): BaseTexture[];
  46391. /**
  46392. * Checks to see if a texture is used in the material.
  46393. * @param texture - Base texture to use.
  46394. * @returns - Boolean specifying if a texture is used in the material.
  46395. */
  46396. hasTexture(texture: BaseTexture): boolean;
  46397. /**
  46398. * Makes a duplicate of the current material.
  46399. * @param name - name to use for the new material.
  46400. */
  46401. clone(name: string): PBRSpecularGlossinessMaterial;
  46402. /**
  46403. * Serialize the material to a parsable JSON object.
  46404. */
  46405. serialize(): any;
  46406. /**
  46407. * Parses a JSON object correponding to the serialize function.
  46408. */
  46409. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46410. }
  46411. }
  46412. declare module BABYLON {
  46413. /**
  46414. * Base class of all the textures in babylon.
  46415. * It groups all the common properties the materials, post process, lights... might need
  46416. * in order to make a correct use of the texture.
  46417. */
  46418. class BaseTexture {
  46419. /**
  46420. * Default anisotropic filtering level for the application.
  46421. * It is set to 4 as a good tradeoff between perf and quality.
  46422. */
  46423. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46424. /**
  46425. * Gets or sets the unique id of the texture
  46426. */
  46427. uniqueId: number;
  46428. /**
  46429. * Define the name of the texture.
  46430. */
  46431. name: string;
  46432. /**
  46433. * Gets or sets an object used to store user defined information.
  46434. */
  46435. metadata: any;
  46436. /**
  46437. * For internal use only. Please do not use.
  46438. */
  46439. reservedDataStore: any;
  46440. private _hasAlpha;
  46441. /**
  46442. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46443. */
  46444. hasAlpha: boolean;
  46445. /**
  46446. * Defines if the alpha value should be determined via the rgb values.
  46447. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46448. */
  46449. getAlphaFromRGB: boolean;
  46450. /**
  46451. * Intensity or strength of the texture.
  46452. * It is commonly used by materials to fine tune the intensity of the texture
  46453. */
  46454. level: number;
  46455. /**
  46456. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46457. * This is part of the texture as textures usually maps to one uv set.
  46458. */
  46459. coordinatesIndex: number;
  46460. private _coordinatesMode;
  46461. /**
  46462. * How a texture is mapped.
  46463. *
  46464. * | Value | Type | Description |
  46465. * | ----- | ----------------------------------- | ----------- |
  46466. * | 0 | EXPLICIT_MODE | |
  46467. * | 1 | SPHERICAL_MODE | |
  46468. * | 2 | PLANAR_MODE | |
  46469. * | 3 | CUBIC_MODE | |
  46470. * | 4 | PROJECTION_MODE | |
  46471. * | 5 | SKYBOX_MODE | |
  46472. * | 6 | INVCUBIC_MODE | |
  46473. * | 7 | EQUIRECTANGULAR_MODE | |
  46474. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46475. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46476. */
  46477. coordinatesMode: number;
  46478. /**
  46479. * | Value | Type | Description |
  46480. * | ----- | ------------------ | ----------- |
  46481. * | 0 | CLAMP_ADDRESSMODE | |
  46482. * | 1 | WRAP_ADDRESSMODE | |
  46483. * | 2 | MIRROR_ADDRESSMODE | |
  46484. */
  46485. wrapU: number;
  46486. /**
  46487. * | Value | Type | Description |
  46488. * | ----- | ------------------ | ----------- |
  46489. * | 0 | CLAMP_ADDRESSMODE | |
  46490. * | 1 | WRAP_ADDRESSMODE | |
  46491. * | 2 | MIRROR_ADDRESSMODE | |
  46492. */
  46493. wrapV: number;
  46494. /**
  46495. * | Value | Type | Description |
  46496. * | ----- | ------------------ | ----------- |
  46497. * | 0 | CLAMP_ADDRESSMODE | |
  46498. * | 1 | WRAP_ADDRESSMODE | |
  46499. * | 2 | MIRROR_ADDRESSMODE | |
  46500. */
  46501. wrapR: number;
  46502. /**
  46503. * With compliant hardware and browser (supporting anisotropic filtering)
  46504. * this defines the level of anisotropic filtering in the texture.
  46505. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46506. */
  46507. anisotropicFilteringLevel: number;
  46508. /**
  46509. * Define if the texture is a cube texture or if false a 2d texture.
  46510. */
  46511. isCube: boolean;
  46512. /**
  46513. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46514. */
  46515. is3D: boolean;
  46516. /**
  46517. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46518. * HDR texture are usually stored in linear space.
  46519. * This only impacts the PBR and Background materials
  46520. */
  46521. gammaSpace: boolean;
  46522. /**
  46523. * Gets whether or not the texture contains RGBD data.
  46524. */
  46525. readonly isRGBD: boolean;
  46526. /**
  46527. * Is Z inverted in the texture (useful in a cube texture).
  46528. */
  46529. invertZ: boolean;
  46530. /**
  46531. * Are mip maps generated for this texture or not.
  46532. */
  46533. readonly noMipmap: boolean;
  46534. /**
  46535. * @hidden
  46536. */
  46537. lodLevelInAlpha: boolean;
  46538. /**
  46539. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46540. */
  46541. lodGenerationOffset: number;
  46542. /**
  46543. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46544. */
  46545. lodGenerationScale: number;
  46546. /**
  46547. * Define if the texture is a render target.
  46548. */
  46549. isRenderTarget: boolean;
  46550. /**
  46551. * Define the unique id of the texture in the scene.
  46552. */
  46553. readonly uid: string;
  46554. /**
  46555. * Return a string representation of the texture.
  46556. * @returns the texture as a string
  46557. */
  46558. toString(): string;
  46559. /**
  46560. * Get the class name of the texture.
  46561. * @returns "BaseTexture"
  46562. */
  46563. getClassName(): string;
  46564. /**
  46565. * Define the list of animation attached to the texture.
  46566. */
  46567. animations: Animation[];
  46568. /**
  46569. * An event triggered when the texture is disposed.
  46570. */
  46571. onDisposeObservable: Observable<BaseTexture>;
  46572. private _onDisposeObserver;
  46573. /**
  46574. * Callback triggered when the texture has been disposed.
  46575. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46576. */
  46577. onDispose: () => void;
  46578. /**
  46579. * Define the current state of the loading sequence when in delayed load mode.
  46580. */
  46581. delayLoadState: number;
  46582. private _scene;
  46583. /** @hidden */
  46584. _texture: Nullable<InternalTexture>;
  46585. private _uid;
  46586. /**
  46587. * Define if the texture is preventinga material to render or not.
  46588. * If not and the texture is not ready, the engine will use a default black texture instead.
  46589. */
  46590. readonly isBlocking: boolean;
  46591. /**
  46592. * Instantiates a new BaseTexture.
  46593. * Base class of all the textures in babylon.
  46594. * It groups all the common properties the materials, post process, lights... might need
  46595. * in order to make a correct use of the texture.
  46596. * @param scene Define the scene the texture blongs to
  46597. */
  46598. constructor(scene: Nullable<Scene>);
  46599. /**
  46600. * Get the scene the texture belongs to.
  46601. * @returns the scene or null if undefined
  46602. */
  46603. getScene(): Nullable<Scene>;
  46604. /**
  46605. * Get the texture transform matrix used to offset tile the texture for istance.
  46606. * @returns the transformation matrix
  46607. */
  46608. getTextureMatrix(): Matrix;
  46609. /**
  46610. * Get the texture reflection matrix used to rotate/transform the reflection.
  46611. * @returns the reflection matrix
  46612. */
  46613. getReflectionTextureMatrix(): Matrix;
  46614. /**
  46615. * Get the underlying lower level texture from Babylon.
  46616. * @returns the insternal texture
  46617. */
  46618. getInternalTexture(): Nullable<InternalTexture>;
  46619. /**
  46620. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46621. * @returns true if ready or not blocking
  46622. */
  46623. isReadyOrNotBlocking(): boolean;
  46624. /**
  46625. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46626. * @returns true if fully ready
  46627. */
  46628. isReady(): boolean;
  46629. private _cachedSize;
  46630. /**
  46631. * Get the size of the texture.
  46632. * @returns the texture size.
  46633. */
  46634. getSize(): ISize;
  46635. /**
  46636. * Get the base size of the texture.
  46637. * It can be different from the size if the texture has been resized for POT for instance
  46638. * @returns the base size
  46639. */
  46640. getBaseSize(): ISize;
  46641. /**
  46642. * Update the sampling mode of the texture.
  46643. * Default is Trilinear mode.
  46644. *
  46645. * | Value | Type | Description |
  46646. * | ----- | ------------------ | ----------- |
  46647. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46648. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46649. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46650. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46651. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46652. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46653. * | 7 | NEAREST_LINEAR | |
  46654. * | 8 | NEAREST_NEAREST | |
  46655. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46656. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46657. * | 11 | LINEAR_LINEAR | |
  46658. * | 12 | LINEAR_NEAREST | |
  46659. *
  46660. * > _mag_: magnification filter (close to the viewer)
  46661. * > _min_: minification filter (far from the viewer)
  46662. * > _mip_: filter used between mip map levels
  46663. *@param samplingMode Define the new sampling mode of the texture
  46664. */
  46665. updateSamplingMode(samplingMode: number): void;
  46666. /**
  46667. * Scales the texture if is `canRescale()`
  46668. * @param ratio the resize factor we want to use to rescale
  46669. */
  46670. scale(ratio: number): void;
  46671. /**
  46672. * Get if the texture can rescale.
  46673. */
  46674. readonly canRescale: boolean;
  46675. /** @hidden */
  46676. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46677. /** @hidden */
  46678. _rebuild(): void;
  46679. /**
  46680. * Triggers the load sequence in delayed load mode.
  46681. */
  46682. delayLoad(): void;
  46683. /**
  46684. * Clones the texture.
  46685. * @returns the cloned texture
  46686. */
  46687. clone(): Nullable<BaseTexture>;
  46688. /**
  46689. * Get the texture underlying type (INT, FLOAT...)
  46690. */
  46691. readonly textureType: number;
  46692. /**
  46693. * Get the texture underlying format (RGB, RGBA...)
  46694. */
  46695. readonly textureFormat: number;
  46696. /**
  46697. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46698. * This will returns an RGBA array buffer containing either in values (0-255) or
  46699. * float values (0-1) depending of the underlying buffer type.
  46700. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46701. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46702. * @param buffer defines a user defined buffer to fill with data (can be null)
  46703. * @returns The Array buffer containing the pixels data.
  46704. */
  46705. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46706. /**
  46707. * Release and destroy the underlying lower level texture aka internalTexture.
  46708. */
  46709. releaseInternalTexture(): void;
  46710. /**
  46711. * Get the polynomial representation of the texture data.
  46712. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46713. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46714. */
  46715. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46716. /** @hidden */
  46717. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46718. /** @hidden */
  46719. readonly _lodTextureMid: Nullable<BaseTexture>;
  46720. /** @hidden */
  46721. readonly _lodTextureLow: Nullable<BaseTexture>;
  46722. /**
  46723. * Dispose the texture and release its associated resources.
  46724. */
  46725. dispose(): void;
  46726. /**
  46727. * Serialize the texture into a JSON representation that can be parsed later on.
  46728. * @returns the JSON representation of the texture
  46729. */
  46730. serialize(): any;
  46731. /**
  46732. * Helper function to be called back once a list of texture contains only ready textures.
  46733. * @param textures Define the list of textures to wait for
  46734. * @param callback Define the callback triggered once the entire list will be ready
  46735. */
  46736. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46737. }
  46738. }
  46739. declare module BABYLON {
  46740. /**
  46741. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46742. * It can help converting any input color in a desired output one. This can then be used to create effects
  46743. * from sepia, black and white to sixties or futuristic rendering...
  46744. *
  46745. * The only supported format is currently 3dl.
  46746. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46747. */
  46748. class ColorGradingTexture extends BaseTexture {
  46749. /**
  46750. * The current texture matrix. (will always be identity in color grading texture)
  46751. */
  46752. private _textureMatrix;
  46753. /**
  46754. * The texture URL.
  46755. */
  46756. url: string;
  46757. /**
  46758. * Empty line regex stored for GC.
  46759. */
  46760. private static _noneEmptyLineRegex;
  46761. private _engine;
  46762. /**
  46763. * Instantiates a ColorGradingTexture from the following parameters.
  46764. *
  46765. * @param url The location of the color gradind data (currently only supporting 3dl)
  46766. * @param scene The scene the texture will be used in
  46767. */
  46768. constructor(url: string, scene: Scene);
  46769. /**
  46770. * Returns the texture matrix used in most of the material.
  46771. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46772. */
  46773. getTextureMatrix(): Matrix;
  46774. /**
  46775. * Occurs when the file being loaded is a .3dl LUT file.
  46776. */
  46777. private load3dlTexture;
  46778. /**
  46779. * Starts the loading process of the texture.
  46780. */
  46781. private loadTexture;
  46782. /**
  46783. * Clones the color gradind texture.
  46784. */
  46785. clone(): ColorGradingTexture;
  46786. /**
  46787. * Called during delayed load for textures.
  46788. */
  46789. delayLoad(): void;
  46790. /**
  46791. * Parses a color grading texture serialized by Babylon.
  46792. * @param parsedTexture The texture information being parsedTexture
  46793. * @param scene The scene to load the texture in
  46794. * @param rootUrl The root url of the data assets to load
  46795. * @return A color gradind texture
  46796. */
  46797. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46798. /**
  46799. * Serializes the LUT texture to json format.
  46800. */
  46801. serialize(): any;
  46802. }
  46803. }
  46804. declare module BABYLON {
  46805. /**
  46806. * Class for creating a cube texture
  46807. */
  46808. class CubeTexture extends BaseTexture {
  46809. private _delayedOnLoad;
  46810. /**
  46811. * The url of the texture
  46812. */
  46813. url: string;
  46814. /**
  46815. * Gets or sets the center of the bounding box associated with the cube texture.
  46816. * It must define where the camera used to render the texture was set
  46817. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46818. */
  46819. boundingBoxPosition: Vector3;
  46820. private _boundingBoxSize;
  46821. /**
  46822. * Gets or sets the size of the bounding box associated with the cube texture
  46823. * When defined, the cubemap will switch to local mode
  46824. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46825. * @example https://www.babylonjs-playground.com/#RNASML
  46826. */
  46827. /**
  46828. * Returns the bounding box size
  46829. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46830. */
  46831. boundingBoxSize: Vector3;
  46832. protected _rotationY: number;
  46833. /**
  46834. * Sets texture matrix rotation angle around Y axis in radians.
  46835. */
  46836. /**
  46837. * Gets texture matrix rotation angle around Y axis radians.
  46838. */
  46839. rotationY: number;
  46840. /**
  46841. * Are mip maps generated for this texture or not.
  46842. */
  46843. readonly noMipmap: boolean;
  46844. private _noMipmap;
  46845. private _files;
  46846. private _extensions;
  46847. private _textureMatrix;
  46848. private _format;
  46849. private _createPolynomials;
  46850. /** @hidden */
  46851. _prefiltered: boolean;
  46852. /**
  46853. * Creates a cube texture from an array of image urls
  46854. * @param files defines an array of image urls
  46855. * @param scene defines the hosting scene
  46856. * @param noMipmap specifies if mip maps are not used
  46857. * @returns a cube texture
  46858. */
  46859. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46860. /**
  46861. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46862. * @param url defines the url of the prefiltered texture
  46863. * @param scene defines the scene the texture is attached to
  46864. * @param forcedExtension defines the extension of the file if different from the url
  46865. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46866. * @return the prefiltered texture
  46867. */
  46868. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46869. /**
  46870. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46871. * as prefiltered data.
  46872. * @param rootUrl defines the url of the texture or the root name of the six images
  46873. * @param scene defines the scene the texture is attached to
  46874. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46875. * @param noMipmap defines if mipmaps should be created or not
  46876. * @param files defines the six files to load for the different faces
  46877. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46878. * @param onError defines a callback triggered in case of error during load
  46879. * @param format defines the internal format to use for the texture once loaded
  46880. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46881. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46882. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46883. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46884. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46885. * @return the cube texture
  46886. */
  46887. 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);
  46888. /**
  46889. * Get the current class name of the texture useful for serialization or dynamic coding.
  46890. * @returns "CubeTexture"
  46891. */
  46892. getClassName(): string;
  46893. /**
  46894. * Update the url (and optional buffer) of this texture if url was null during construction.
  46895. * @param url the url of the texture
  46896. * @param forcedExtension defines the extension to use
  46897. * @param onLoad callback called when the texture is loaded (defaults to null)
  46898. */
  46899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46900. /**
  46901. * Delays loading of the cube texture
  46902. * @param forcedExtension defines the extension to use
  46903. */
  46904. delayLoad(forcedExtension?: string): void;
  46905. /**
  46906. * Returns the reflection texture matrix
  46907. * @returns the reflection texture matrix
  46908. */
  46909. getReflectionTextureMatrix(): Matrix;
  46910. /**
  46911. * Sets the reflection texture matrix
  46912. * @param value Reflection texture matrix
  46913. */
  46914. setReflectionTextureMatrix(value: Matrix): void;
  46915. /**
  46916. * Parses text to create a cube texture
  46917. * @param parsedTexture define the serialized text to read from
  46918. * @param scene defines the hosting scene
  46919. * @param rootUrl defines the root url of the cube texture
  46920. * @returns a cube texture
  46921. */
  46922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46923. /**
  46924. * Makes a clone, or deep copy, of the cube texture
  46925. * @returns a new cube texture
  46926. */
  46927. clone(): CubeTexture;
  46928. }
  46929. }
  46930. declare module BABYLON {
  46931. /**
  46932. * A class extending Texture allowing drawing on a texture
  46933. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46934. */
  46935. class DynamicTexture extends Texture {
  46936. private _generateMipMaps;
  46937. private _canvas;
  46938. private _context;
  46939. private _engine;
  46940. /**
  46941. * Creates a DynamicTexture
  46942. * @param name defines the name of the texture
  46943. * @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
  46944. * @param scene defines the scene where you want the texture
  46945. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46946. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46947. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46948. */
  46949. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46950. /**
  46951. * Get the current class name of the texture useful for serialization or dynamic coding.
  46952. * @returns "DynamicTexture"
  46953. */
  46954. getClassName(): string;
  46955. /**
  46956. * Gets the current state of canRescale
  46957. */
  46958. readonly canRescale: boolean;
  46959. private _recreate;
  46960. /**
  46961. * Scales the texture
  46962. * @param ratio the scale factor to apply to both width and height
  46963. */
  46964. scale(ratio: number): void;
  46965. /**
  46966. * Resizes the texture
  46967. * @param width the new width
  46968. * @param height the new height
  46969. */
  46970. scaleTo(width: number, height: number): void;
  46971. /**
  46972. * Gets the context of the canvas used by the texture
  46973. * @returns the canvas context of the dynamic texture
  46974. */
  46975. getContext(): CanvasRenderingContext2D;
  46976. /**
  46977. * Clears the texture
  46978. */
  46979. clear(): void;
  46980. /**
  46981. * Updates the texture
  46982. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46983. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46984. */
  46985. update(invertY?: boolean, premulAlpha?: boolean): void;
  46986. /**
  46987. * Draws text onto the texture
  46988. * @param text defines the text to be drawn
  46989. * @param x defines the placement of the text from the left
  46990. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46991. * @param font defines the font to be used with font-style, font-size, font-name
  46992. * @param color defines the color used for the text
  46993. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46994. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46995. * @param update defines whether texture is immediately update (default is true)
  46996. */
  46997. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46998. /**
  46999. * Clones the texture
  47000. * @returns the clone of the texture.
  47001. */
  47002. clone(): DynamicTexture;
  47003. /**
  47004. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47005. * @returns a serialized dynamic texture object
  47006. */
  47007. serialize(): any;
  47008. /** @hidden */
  47009. _rebuild(): void;
  47010. }
  47011. }
  47012. declare module BABYLON {
  47013. /**
  47014. * This represents a texture coming from an HDR input.
  47015. *
  47016. * The only supported format is currently panorama picture stored in RGBE format.
  47017. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47018. */
  47019. class HDRCubeTexture extends BaseTexture {
  47020. private static _facesMapping;
  47021. private _generateHarmonics;
  47022. private _noMipmap;
  47023. private _textureMatrix;
  47024. private _size;
  47025. private _onLoad;
  47026. private _onError;
  47027. /**
  47028. * The texture URL.
  47029. */
  47030. url: string;
  47031. /**
  47032. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47033. */
  47034. coordinatesMode: number;
  47035. protected _isBlocking: boolean;
  47036. /**
  47037. * Sets wether or not the texture is blocking during loading.
  47038. */
  47039. /**
  47040. * Gets wether or not the texture is blocking during loading.
  47041. */
  47042. isBlocking: boolean;
  47043. protected _rotationY: number;
  47044. /**
  47045. * Sets texture matrix rotation angle around Y axis in radians.
  47046. */
  47047. /**
  47048. * Gets texture matrix rotation angle around Y axis radians.
  47049. */
  47050. rotationY: number;
  47051. /**
  47052. * Gets or sets the center of the bounding box associated with the cube texture
  47053. * It must define where the camera used to render the texture was set
  47054. */
  47055. boundingBoxPosition: Vector3;
  47056. private _boundingBoxSize;
  47057. /**
  47058. * Gets or sets the size of the bounding box associated with the cube texture
  47059. * When defined, the cubemap will switch to local mode
  47060. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47061. * @example https://www.babylonjs-playground.com/#RNASML
  47062. */
  47063. boundingBoxSize: Vector3;
  47064. /**
  47065. * Instantiates an HDRTexture from the following parameters.
  47066. *
  47067. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47068. * @param scene The scene the texture will be used in
  47069. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47070. * @param noMipmap Forces to not generate the mipmap if true
  47071. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47072. * @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)
  47073. * @param reserved Reserved flag for internal use.
  47074. */
  47075. 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>);
  47076. /**
  47077. * Get the current class name of the texture useful for serialization or dynamic coding.
  47078. * @returns "HDRCubeTexture"
  47079. */
  47080. getClassName(): string;
  47081. /**
  47082. * Occurs when the file is raw .hdr file.
  47083. */
  47084. private loadTexture;
  47085. clone(): HDRCubeTexture;
  47086. delayLoad(): void;
  47087. /**
  47088. * Get the texture reflection matrix used to rotate/transform the reflection.
  47089. * @returns the reflection matrix
  47090. */
  47091. getReflectionTextureMatrix(): Matrix;
  47092. /**
  47093. * Set the texture reflection matrix used to rotate/transform the reflection.
  47094. * @param value Define the reflection matrix to set
  47095. */
  47096. setReflectionTextureMatrix(value: Matrix): void;
  47097. /**
  47098. * Parses a JSON representation of an HDR Texture in order to create the texture
  47099. * @param parsedTexture Define the JSON representation
  47100. * @param scene Define the scene the texture should be created in
  47101. * @param rootUrl Define the root url in case we need to load relative dependencies
  47102. * @returns the newly created texture after parsing
  47103. */
  47104. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47105. serialize(): any;
  47106. }
  47107. }
  47108. declare module BABYLON {
  47109. /**
  47110. * Class used to store data associated with WebGL texture data for the engine
  47111. * This class should not be used directly
  47112. */
  47113. class InternalTexture implements IInternalTextureTracker {
  47114. /**
  47115. * The source of the texture data is unknown
  47116. */
  47117. static DATASOURCE_UNKNOWN: number;
  47118. /**
  47119. * Texture data comes from an URL
  47120. */
  47121. static DATASOURCE_URL: number;
  47122. /**
  47123. * Texture data is only used for temporary storage
  47124. */
  47125. static DATASOURCE_TEMP: number;
  47126. /**
  47127. * Texture data comes from raw data (ArrayBuffer)
  47128. */
  47129. static DATASOURCE_RAW: number;
  47130. /**
  47131. * Texture content is dynamic (video or dynamic texture)
  47132. */
  47133. static DATASOURCE_DYNAMIC: number;
  47134. /**
  47135. * Texture content is generated by rendering to it
  47136. */
  47137. static DATASOURCE_RENDERTARGET: number;
  47138. /**
  47139. * Texture content is part of a multi render target process
  47140. */
  47141. static DATASOURCE_MULTIRENDERTARGET: number;
  47142. /**
  47143. * Texture data comes from a cube data file
  47144. */
  47145. static DATASOURCE_CUBE: number;
  47146. /**
  47147. * Texture data comes from a raw cube data
  47148. */
  47149. static DATASOURCE_CUBERAW: number;
  47150. /**
  47151. * Texture data come from a prefiltered cube data file
  47152. */
  47153. static DATASOURCE_CUBEPREFILTERED: number;
  47154. /**
  47155. * Texture content is raw 3D data
  47156. */
  47157. static DATASOURCE_RAW3D: number;
  47158. /**
  47159. * Texture content is a depth texture
  47160. */
  47161. static DATASOURCE_DEPTHTEXTURE: number;
  47162. /**
  47163. * Texture data comes from a raw cube data encoded with RGBD
  47164. */
  47165. static DATASOURCE_CUBERAW_RGBD: number;
  47166. /**
  47167. * Defines if the texture is ready
  47168. */
  47169. isReady: boolean;
  47170. /**
  47171. * Defines if the texture is a cube texture
  47172. */
  47173. isCube: boolean;
  47174. /**
  47175. * Defines if the texture contains 3D data
  47176. */
  47177. is3D: boolean;
  47178. /**
  47179. * Gets the URL used to load this texture
  47180. */
  47181. url: string;
  47182. /**
  47183. * Gets the sampling mode of the texture
  47184. */
  47185. samplingMode: number;
  47186. /**
  47187. * Gets a boolean indicating if the texture needs mipmaps generation
  47188. */
  47189. generateMipMaps: boolean;
  47190. /**
  47191. * Gets the number of samples used by the texture (WebGL2+ only)
  47192. */
  47193. samples: number;
  47194. /**
  47195. * Gets the type of the texture (int, float...)
  47196. */
  47197. type: number;
  47198. /**
  47199. * Gets the format of the texture (RGB, RGBA...)
  47200. */
  47201. format: number;
  47202. /**
  47203. * Observable called when the texture is loaded
  47204. */
  47205. onLoadedObservable: Observable<InternalTexture>;
  47206. /**
  47207. * Gets the width of the texture
  47208. */
  47209. width: number;
  47210. /**
  47211. * Gets the height of the texture
  47212. */
  47213. height: number;
  47214. /**
  47215. * Gets the depth of the texture
  47216. */
  47217. depth: number;
  47218. /**
  47219. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47220. */
  47221. baseWidth: number;
  47222. /**
  47223. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47224. */
  47225. baseHeight: number;
  47226. /**
  47227. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47228. */
  47229. baseDepth: number;
  47230. /**
  47231. * Gets a boolean indicating if the texture is inverted on Y axis
  47232. */
  47233. invertY: boolean;
  47234. /**
  47235. * Gets or set the previous tracker in the list
  47236. */
  47237. previous: Nullable<IInternalTextureTracker>;
  47238. /**
  47239. * Gets or set the next tracker in the list
  47240. */
  47241. next: Nullable<IInternalTextureTracker>;
  47242. /** @hidden */
  47243. _invertVScale: boolean;
  47244. /** @hidden */
  47245. _initialSlot: number;
  47246. /** @hidden */
  47247. _designatedSlot: number;
  47248. /** @hidden */
  47249. _dataSource: number;
  47250. /** @hidden */
  47251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47252. /** @hidden */
  47253. _bufferView: Nullable<ArrayBufferView>;
  47254. /** @hidden */
  47255. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47256. /** @hidden */
  47257. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47258. /** @hidden */
  47259. _size: number;
  47260. /** @hidden */
  47261. _extension: string;
  47262. /** @hidden */
  47263. _files: Nullable<string[]>;
  47264. /** @hidden */
  47265. _workingCanvas: HTMLCanvasElement;
  47266. /** @hidden */
  47267. _workingContext: CanvasRenderingContext2D;
  47268. /** @hidden */
  47269. _framebuffer: Nullable<WebGLFramebuffer>;
  47270. /** @hidden */
  47271. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47272. /** @hidden */
  47273. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47274. /** @hidden */
  47275. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47276. /** @hidden */
  47277. _attachments: Nullable<number[]>;
  47278. /** @hidden */
  47279. _cachedCoordinatesMode: Nullable<number>;
  47280. /** @hidden */
  47281. _cachedWrapU: Nullable<number>;
  47282. /** @hidden */
  47283. _cachedWrapV: Nullable<number>;
  47284. /** @hidden */
  47285. _cachedWrapR: Nullable<number>;
  47286. /** @hidden */
  47287. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47288. /** @hidden */
  47289. _isDisabled: boolean;
  47290. /** @hidden */
  47291. _compression: Nullable<string>;
  47292. /** @hidden */
  47293. _generateStencilBuffer: boolean;
  47294. /** @hidden */
  47295. _generateDepthBuffer: boolean;
  47296. /** @hidden */
  47297. _comparisonFunction: number;
  47298. /** @hidden */
  47299. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47300. /** @hidden */
  47301. _lodGenerationScale: number;
  47302. /** @hidden */
  47303. _lodGenerationOffset: number;
  47304. /** @hidden */
  47305. _lodTextureHigh: BaseTexture;
  47306. /** @hidden */
  47307. _lodTextureMid: BaseTexture;
  47308. /** @hidden */
  47309. _lodTextureLow: BaseTexture;
  47310. /** @hidden */
  47311. _isRGBD: boolean;
  47312. /** @hidden */
  47313. _webGLTexture: Nullable<WebGLTexture>;
  47314. /** @hidden */
  47315. _references: number;
  47316. private _engine;
  47317. /**
  47318. * Gets the Engine the texture belongs to.
  47319. * @returns The babylon engine
  47320. */
  47321. getEngine(): Engine;
  47322. /**
  47323. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47324. */
  47325. readonly dataSource: number;
  47326. /**
  47327. * Creates a new InternalTexture
  47328. * @param engine defines the engine to use
  47329. * @param dataSource defines the type of data that will be used
  47330. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47331. */
  47332. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47333. /**
  47334. * Increments the number of references (ie. the number of Texture that point to it)
  47335. */
  47336. incrementReferences(): void;
  47337. /**
  47338. * Change the size of the texture (not the size of the content)
  47339. * @param width defines the new width
  47340. * @param height defines the new height
  47341. * @param depth defines the new depth (1 by default)
  47342. */
  47343. updateSize(width: int, height: int, depth?: int): void;
  47344. /** @hidden */
  47345. _rebuild(): void;
  47346. /** @hidden */
  47347. _swapAndDie(target: InternalTexture): void;
  47348. /**
  47349. * Dispose the current allocated resources
  47350. */
  47351. dispose(): void;
  47352. }
  47353. }
  47354. declare module BABYLON {
  47355. /**
  47356. * This represents the required contract to create a new type of texture loader.
  47357. */
  47358. interface IInternalTextureLoader {
  47359. /**
  47360. * Defines wether the loader supports cascade loading the different faces.
  47361. */
  47362. supportCascades: boolean;
  47363. /**
  47364. * This returns if the loader support the current file information.
  47365. * @param extension defines the file extension of the file being loaded
  47366. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47367. * @param fallback defines the fallback internal texture if any
  47368. * @param isBase64 defines whether the texture is encoded as a base64
  47369. * @param isBuffer defines whether the texture data are stored as a buffer
  47370. * @returns true if the loader can load the specified file
  47371. */
  47372. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47373. /**
  47374. * Transform the url before loading if required.
  47375. * @param rootUrl the url of the texture
  47376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47377. * @returns the transformed texture
  47378. */
  47379. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47380. /**
  47381. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47382. * @param rootUrl the url of the texture
  47383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47384. * @returns the fallback texture
  47385. */
  47386. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47387. /**
  47388. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47389. * @param data contains the texture data
  47390. * @param texture defines the BabylonJS internal texture
  47391. * @param createPolynomials will be true if polynomials have been requested
  47392. * @param onLoad defines the callback to trigger once the texture is ready
  47393. * @param onError defines the callback to trigger in case of error
  47394. */
  47395. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47396. /**
  47397. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47398. * @param data contains the texture data
  47399. * @param texture defines the BabylonJS internal texture
  47400. * @param callback defines the method to call once ready to upload
  47401. */
  47402. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47403. }
  47404. }
  47405. declare module BABYLON {
  47406. /**
  47407. * Internal interface used to track InternalTexture already bound to the GL context
  47408. */
  47409. interface IInternalTextureTracker {
  47410. /**
  47411. * Gets or set the previous tracker in the list
  47412. */
  47413. previous: Nullable<IInternalTextureTracker>;
  47414. /**
  47415. * Gets or set the next tracker in the list
  47416. */
  47417. next: Nullable<IInternalTextureTracker>;
  47418. }
  47419. /**
  47420. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47421. */
  47422. class DummyInternalTextureTracker {
  47423. /**
  47424. * Gets or set the previous tracker in the list
  47425. */
  47426. previous: Nullable<IInternalTextureTracker>;
  47427. /**
  47428. * Gets or set the next tracker in the list
  47429. */
  47430. next: Nullable<IInternalTextureTracker>;
  47431. }
  47432. }
  47433. declare module BABYLON {
  47434. /**
  47435. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47436. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47437. * You can then easily use it as a reflectionTexture on a flat surface.
  47438. * In case the surface is not a plane, please consider relying on reflection probes.
  47439. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47440. */
  47441. class MirrorTexture extends RenderTargetTexture {
  47442. private scene;
  47443. /**
  47444. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47445. * 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.
  47446. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47447. */
  47448. mirrorPlane: Plane;
  47449. /**
  47450. * Define the blur ratio used to blur the reflection if needed.
  47451. */
  47452. blurRatio: number;
  47453. /**
  47454. * Define the adaptive blur kernel used to blur the reflection if needed.
  47455. * This will autocompute the closest best match for the `blurKernel`
  47456. */
  47457. adaptiveBlurKernel: number;
  47458. /**
  47459. * Define the blur kernel used to blur the reflection if needed.
  47460. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47461. */
  47462. blurKernel: number;
  47463. /**
  47464. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47465. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47466. */
  47467. blurKernelX: number;
  47468. /**
  47469. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47470. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47471. */
  47472. blurKernelY: number;
  47473. private _autoComputeBlurKernel;
  47474. protected _onRatioRescale(): void;
  47475. private _updateGammaSpace;
  47476. private _imageProcessingConfigChangeObserver;
  47477. private _transformMatrix;
  47478. private _mirrorMatrix;
  47479. private _savedViewMatrix;
  47480. private _blurX;
  47481. private _blurY;
  47482. private _adaptiveBlurKernel;
  47483. private _blurKernelX;
  47484. private _blurKernelY;
  47485. private _blurRatio;
  47486. /**
  47487. * Instantiates a Mirror Texture.
  47488. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47489. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47490. * You can then easily use it as a reflectionTexture on a flat surface.
  47491. * In case the surface is not a plane, please consider relying on reflection probes.
  47492. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47493. * @param name
  47494. * @param size
  47495. * @param scene
  47496. * @param generateMipMaps
  47497. * @param type
  47498. * @param samplingMode
  47499. * @param generateDepthBuffer
  47500. */
  47501. constructor(name: string, size: number | {
  47502. width: number;
  47503. height: number;
  47504. } | {
  47505. ratio: number;
  47506. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47507. private _preparePostProcesses;
  47508. /**
  47509. * Clone the mirror texture.
  47510. * @returns the cloned texture
  47511. */
  47512. clone(): MirrorTexture;
  47513. /**
  47514. * Serialize the texture to a JSON representation you could use in Parse later on
  47515. * @returns the serialized JSON representation
  47516. */
  47517. serialize(): any;
  47518. /**
  47519. * Dispose the texture and release its associated resources.
  47520. */
  47521. dispose(): void;
  47522. }
  47523. }
  47524. declare module BABYLON {
  47525. /**
  47526. * Creation options of the multi render target texture.
  47527. */
  47528. interface IMultiRenderTargetOptions {
  47529. /**
  47530. * Define if the texture needs to create mip maps after render.
  47531. */
  47532. generateMipMaps?: boolean;
  47533. /**
  47534. * Define the types of all the draw buffers we want to create
  47535. */
  47536. types?: number[];
  47537. /**
  47538. * Define the sampling modes of all the draw buffers we want to create
  47539. */
  47540. samplingModes?: number[];
  47541. /**
  47542. * Define if a depth buffer is required
  47543. */
  47544. generateDepthBuffer?: boolean;
  47545. /**
  47546. * Define if a stencil buffer is required
  47547. */
  47548. generateStencilBuffer?: boolean;
  47549. /**
  47550. * Define if a depth texture is required instead of a depth buffer
  47551. */
  47552. generateDepthTexture?: boolean;
  47553. /**
  47554. * Define the number of desired draw buffers
  47555. */
  47556. textureCount?: number;
  47557. /**
  47558. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47559. */
  47560. doNotChangeAspectRatio?: boolean;
  47561. /**
  47562. * Define the default type of the buffers we are creating
  47563. */
  47564. defaultType?: number;
  47565. }
  47566. /**
  47567. * A multi render target, like a render target provides the ability to render to a texture.
  47568. * Unlike the render target, it can render to several draw buffers in one draw.
  47569. * This is specially interesting in deferred rendering or for any effects requiring more than
  47570. * just one color from a single pass.
  47571. */
  47572. class MultiRenderTarget extends RenderTargetTexture {
  47573. private _internalTextures;
  47574. private _textures;
  47575. private _multiRenderTargetOptions;
  47576. /**
  47577. * Get if draw buffers are currently supported by the used hardware and browser.
  47578. */
  47579. readonly isSupported: boolean;
  47580. /**
  47581. * Get the list of textures generated by the multi render target.
  47582. */
  47583. readonly textures: Texture[];
  47584. /**
  47585. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47586. */
  47587. readonly depthTexture: Texture;
  47588. /**
  47589. * Set the wrapping mode on U of all the textures we are rendering to.
  47590. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47591. */
  47592. wrapU: number;
  47593. /**
  47594. * Set the wrapping mode on V of all the textures we are rendering to.
  47595. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47596. */
  47597. wrapV: number;
  47598. /**
  47599. * Instantiate a new multi render target texture.
  47600. * A multi render target, like a render target provides the ability to render to a texture.
  47601. * Unlike the render target, it can render to several draw buffers in one draw.
  47602. * This is specially interesting in deferred rendering or for any effects requiring more than
  47603. * just one color from a single pass.
  47604. * @param name Define the name of the texture
  47605. * @param size Define the size of the buffers to render to
  47606. * @param count Define the number of target we are rendering into
  47607. * @param scene Define the scene the texture belongs to
  47608. * @param options Define the options used to create the multi render target
  47609. */
  47610. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47611. /** @hidden */
  47612. _rebuild(): void;
  47613. private _createInternalTextures;
  47614. private _createTextures;
  47615. /**
  47616. * Define the number of samples used if MSAA is enabled.
  47617. */
  47618. samples: number;
  47619. /**
  47620. * Resize all the textures in the multi render target.
  47621. * Be carrefull as it will recreate all the data in the new texture.
  47622. * @param size Define the new size
  47623. */
  47624. resize(size: any): void;
  47625. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47626. /**
  47627. * Dispose the render targets and their associated resources
  47628. */
  47629. dispose(): void;
  47630. /**
  47631. * Release all the underlying texture used as draw buffers.
  47632. */
  47633. releaseInternalTextures(): void;
  47634. }
  47635. }
  47636. declare module BABYLON {
  47637. /**
  47638. * Raw cube texture where the raw buffers are passed in
  47639. */
  47640. class RawCubeTexture extends CubeTexture {
  47641. /**
  47642. * Creates a cube texture where the raw buffers are passed in.
  47643. * @param scene defines the scene the texture is attached to
  47644. * @param data defines the array of data to use to create each face
  47645. * @param size defines the size of the textures
  47646. * @param format defines the format of the data
  47647. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47648. * @param generateMipMaps defines if the engine should generate the mip levels
  47649. * @param invertY defines if data must be stored with Y axis inverted
  47650. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47651. * @param compression defines the compression used (null by default)
  47652. */
  47653. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47654. /**
  47655. * Updates the raw cube texture.
  47656. * @param data defines the data to store
  47657. * @param format defines the data format
  47658. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47659. * @param invertY defines if data must be stored with Y axis inverted
  47660. * @param compression defines the compression used (null by default)
  47661. * @param level defines which level of the texture to update
  47662. */
  47663. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47664. /**
  47665. * Updates a raw cube texture with RGBD encoded data.
  47666. * @param data defines the array of data [mipmap][face] to use to create each face
  47667. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47668. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47669. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47670. * @returns a promsie that resolves when the operation is complete
  47671. */
  47672. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47673. /**
  47674. * Clones the raw cube texture.
  47675. * @return a new cube texture
  47676. */
  47677. clone(): CubeTexture;
  47678. /** @hidden */
  47679. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47680. }
  47681. }
  47682. declare module BABYLON {
  47683. /**
  47684. * Raw texture can help creating a texture directly from an array of data.
  47685. * This can be super useful if you either get the data from an uncompressed source or
  47686. * if you wish to create your texture pixel by pixel.
  47687. */
  47688. class RawTexture extends Texture {
  47689. /**
  47690. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47691. */
  47692. format: number;
  47693. private _engine;
  47694. /**
  47695. * Instantiates a new RawTexture.
  47696. * Raw texture can help creating a texture directly from an array of data.
  47697. * This can be super useful if you either get the data from an uncompressed source or
  47698. * if you wish to create your texture pixel by pixel.
  47699. * @param data define the array of data to use to create the texture
  47700. * @param width define the width of the texture
  47701. * @param height define the height of the texture
  47702. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47703. * @param scene define the scene the texture belongs to
  47704. * @param generateMipMaps define whether mip maps should be generated or not
  47705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47707. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47708. */
  47709. constructor(data: ArrayBufferView, width: number, height: number,
  47710. /**
  47711. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47712. */
  47713. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47714. /**
  47715. * Updates the texture underlying data.
  47716. * @param data Define the new data of the texture
  47717. */
  47718. update(data: ArrayBufferView): void;
  47719. /**
  47720. * Creates a luminance texture from some data.
  47721. * @param data Define the texture data
  47722. * @param width Define the width of the texture
  47723. * @param height Define the height of the texture
  47724. * @param scene Define the scene the texture belongs to
  47725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47728. * @returns the luminance texture
  47729. */
  47730. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47731. /**
  47732. * Creates a luminance alpha texture from some data.
  47733. * @param data Define the texture data
  47734. * @param width Define the width of the texture
  47735. * @param height Define the height of the texture
  47736. * @param scene Define the scene the texture belongs to
  47737. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47738. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47739. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47740. * @returns the luminance alpha texture
  47741. */
  47742. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47743. /**
  47744. * Creates an alpha texture from some data.
  47745. * @param data Define the texture data
  47746. * @param width Define the width of the texture
  47747. * @param height Define the height of the texture
  47748. * @param scene Define the scene the texture belongs to
  47749. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47750. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47751. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47752. * @returns the alpha texture
  47753. */
  47754. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47755. /**
  47756. * Creates a RGB texture from some data.
  47757. * @param data Define the texture data
  47758. * @param width Define the width of the texture
  47759. * @param height Define the height of the texture
  47760. * @param scene Define the scene the texture belongs to
  47761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47765. * @returns the RGB alpha texture
  47766. */
  47767. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47768. /**
  47769. * Creates a RGBA texture from some data.
  47770. * @param data Define the texture data
  47771. * @param width Define the width of the texture
  47772. * @param height Define the height of the texture
  47773. * @param scene Define the scene the texture belongs to
  47774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47778. * @returns the RGBA texture
  47779. */
  47780. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47781. /**
  47782. * Creates a R texture from some data.
  47783. * @param data Define the texture data
  47784. * @param width Define the width of the texture
  47785. * @param height Define the height of the texture
  47786. * @param scene Define the scene the texture belongs to
  47787. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47788. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47789. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47790. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47791. * @returns the R texture
  47792. */
  47793. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47794. }
  47795. }
  47796. declare module BABYLON {
  47797. /**
  47798. * Class used to store 3D textures containing user data
  47799. */
  47800. class RawTexture3D extends Texture {
  47801. /** Gets or sets the texture format to use */
  47802. format: number;
  47803. private _engine;
  47804. /**
  47805. * Create a new RawTexture3D
  47806. * @param data defines the data of the texture
  47807. * @param width defines the width of the texture
  47808. * @param height defines the height of the texture
  47809. * @param depth defines the depth of the texture
  47810. * @param format defines the texture format to use
  47811. * @param scene defines the hosting scene
  47812. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47813. * @param invertY defines if texture must be stored with Y axis inverted
  47814. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47815. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47816. */
  47817. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47818. /** Gets or sets the texture format to use */
  47819. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47820. /**
  47821. * Update the texture with new data
  47822. * @param data defines the data to store in the texture
  47823. */
  47824. update(data: ArrayBufferView): void;
  47825. }
  47826. }
  47827. declare module BABYLON {
  47828. /**
  47829. * Creates a refraction texture used by refraction channel of the standard material.
  47830. * It is like a mirror but to see through a material.
  47831. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47832. */
  47833. class RefractionTexture extends RenderTargetTexture {
  47834. /**
  47835. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47836. * 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.
  47837. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47838. */
  47839. refractionPlane: Plane;
  47840. /**
  47841. * Define how deep under the surface we should see.
  47842. */
  47843. depth: number;
  47844. /**
  47845. * Creates a refraction texture used by refraction channel of the standard material.
  47846. * It is like a mirror but to see through a material.
  47847. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47848. * @param name Define the texture name
  47849. * @param size Define the size of the underlying texture
  47850. * @param scene Define the scene the refraction belongs to
  47851. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47852. */
  47853. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47854. /**
  47855. * Clone the refraction texture.
  47856. * @returns the cloned texture
  47857. */
  47858. clone(): RefractionTexture;
  47859. /**
  47860. * Serialize the texture to a JSON representation you could use in Parse later on
  47861. * @returns the serialized JSON representation
  47862. */
  47863. serialize(): any;
  47864. }
  47865. }
  47866. declare module BABYLON {
  47867. /**
  47868. * This Helps creating a texture that will be created from a camera in your scene.
  47869. * It is basically a dynamic texture that could be used to create special effects for instance.
  47870. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47871. */
  47872. class RenderTargetTexture extends Texture {
  47873. isCube: boolean;
  47874. /**
  47875. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47876. */
  47877. static readonly REFRESHRATE_RENDER_ONCE: number;
  47878. /**
  47879. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47880. */
  47881. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47882. /**
  47883. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47884. * the central point of your effect and can save a lot of performances.
  47885. */
  47886. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47887. /**
  47888. * Use this predicate to dynamically define the list of mesh you want to render.
  47889. * If set, the renderList property will be overwritten.
  47890. */
  47891. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47892. private _renderList;
  47893. /**
  47894. * Use this list to define the list of mesh you want to render.
  47895. */
  47896. renderList: Nullable<Array<AbstractMesh>>;
  47897. private _hookArray;
  47898. /**
  47899. * Define if particles should be rendered in your texture.
  47900. */
  47901. renderParticles: boolean;
  47902. /**
  47903. * Define if sprites should be rendered in your texture.
  47904. */
  47905. renderSprites: boolean;
  47906. /**
  47907. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47908. */
  47909. coordinatesMode: number;
  47910. /**
  47911. * Define the camera used to render the texture.
  47912. */
  47913. activeCamera: Nullable<Camera>;
  47914. /**
  47915. * Override the render function of the texture with your own one.
  47916. */
  47917. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47918. /**
  47919. * Define if camera post processes should be use while rendering the texture.
  47920. */
  47921. useCameraPostProcesses: boolean;
  47922. /**
  47923. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47924. */
  47925. ignoreCameraViewport: boolean;
  47926. private _postProcessManager;
  47927. private _postProcesses;
  47928. private _resizeObserver;
  47929. /**
  47930. * An event triggered when the texture is unbind.
  47931. */
  47932. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47933. /**
  47934. * An event triggered when the texture is unbind.
  47935. */
  47936. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47937. private _onAfterUnbindObserver;
  47938. /**
  47939. * Set a after unbind callback in the texture.
  47940. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47941. */
  47942. onAfterUnbind: () => void;
  47943. /**
  47944. * An event triggered before rendering the texture
  47945. */
  47946. onBeforeRenderObservable: Observable<number>;
  47947. private _onBeforeRenderObserver;
  47948. /**
  47949. * Set a before render callback in the texture.
  47950. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47951. */
  47952. onBeforeRender: (faceIndex: number) => void;
  47953. /**
  47954. * An event triggered after rendering the texture
  47955. */
  47956. onAfterRenderObservable: Observable<number>;
  47957. private _onAfterRenderObserver;
  47958. /**
  47959. * Set a after render callback in the texture.
  47960. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47961. */
  47962. onAfterRender: (faceIndex: number) => void;
  47963. /**
  47964. * An event triggered after the texture clear
  47965. */
  47966. onClearObservable: Observable<Engine>;
  47967. private _onClearObserver;
  47968. /**
  47969. * Set a clear callback in the texture.
  47970. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47971. */
  47972. onClear: (Engine: Engine) => void;
  47973. /**
  47974. * Define the clear color of the Render Target if it should be different from the scene.
  47975. */
  47976. clearColor: Color4;
  47977. protected _size: number | {
  47978. width: number;
  47979. height: number;
  47980. };
  47981. protected _initialSizeParameter: number | {
  47982. width: number;
  47983. height: number;
  47984. } | {
  47985. ratio: number;
  47986. };
  47987. protected _sizeRatio: Nullable<number>;
  47988. /** @hidden */
  47989. _generateMipMaps: boolean;
  47990. protected _renderingManager: RenderingManager;
  47991. /** @hidden */
  47992. _waitingRenderList: string[];
  47993. protected _doNotChangeAspectRatio: boolean;
  47994. protected _currentRefreshId: number;
  47995. protected _refreshRate: number;
  47996. protected _textureMatrix: Matrix;
  47997. protected _samples: number;
  47998. protected _renderTargetOptions: RenderTargetCreationOptions;
  47999. /**
  48000. * Gets render target creation options that were used.
  48001. */
  48002. readonly renderTargetOptions: RenderTargetCreationOptions;
  48003. protected _engine: Engine;
  48004. protected _onRatioRescale(): void;
  48005. /**
  48006. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  48007. * It must define where the camera used to render the texture is set
  48008. */
  48009. boundingBoxPosition: Vector3;
  48010. private _boundingBoxSize;
  48011. /**
  48012. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  48013. * When defined, the cubemap will switch to local mode
  48014. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48015. * @example https://www.babylonjs-playground.com/#RNASML
  48016. */
  48017. boundingBoxSize: Vector3;
  48018. /**
  48019. * In case the RTT has been created with a depth texture, get the associated
  48020. * depth texture.
  48021. * Otherwise, return null.
  48022. */
  48023. depthStencilTexture: Nullable<InternalTexture>;
  48024. /**
  48025. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  48026. * or used a shadow, depth texture...
  48027. * @param name The friendly name of the texture
  48028. * @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)
  48029. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  48030. * @param generateMipMaps True if mip maps need to be generated after render.
  48031. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  48032. * @param type The type of the buffer in the RTT (int, half float, float...)
  48033. * @param isCube True if a cube texture needs to be created
  48034. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  48035. * @param generateDepthBuffer True to generate a depth buffer
  48036. * @param generateStencilBuffer True to generate a stencil buffer
  48037. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  48038. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  48039. * @param delayAllocation if the texture allocation should be delayed (default: false)
  48040. */
  48041. constructor(name: string, size: number | {
  48042. width: number;
  48043. height: number;
  48044. } | {
  48045. ratio: number;
  48046. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  48047. /**
  48048. * Creates a depth stencil texture.
  48049. * This is only available in WebGL 2 or with the depth texture extension available.
  48050. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48051. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48052. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48053. */
  48054. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48055. private _processSizeParameter;
  48056. /**
  48057. * Define the number of samples to use in case of MSAA.
  48058. * It defaults to one meaning no MSAA has been enabled.
  48059. */
  48060. samples: number;
  48061. /**
  48062. * Resets the refresh counter of the texture and start bak from scratch.
  48063. * Could be useful to regenerate the texture if it is setup to render only once.
  48064. */
  48065. resetRefreshCounter(): void;
  48066. /**
  48067. * Define the refresh rate of the texture or the rendering frequency.
  48068. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48069. */
  48070. refreshRate: number;
  48071. /**
  48072. * Adds a post process to the render target rendering passes.
  48073. * @param postProcess define the post process to add
  48074. */
  48075. addPostProcess(postProcess: PostProcess): void;
  48076. /**
  48077. * Clear all the post processes attached to the render target
  48078. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48079. */
  48080. clearPostProcesses(dispose?: boolean): void;
  48081. /**
  48082. * Remove one of the post process from the list of attached post processes to the texture
  48083. * @param postProcess define the post process to remove from the list
  48084. */
  48085. removePostProcess(postProcess: PostProcess): void;
  48086. /** @hidden */
  48087. _shouldRender(): boolean;
  48088. /**
  48089. * Gets the actual render size of the texture.
  48090. * @returns the width of the render size
  48091. */
  48092. getRenderSize(): number;
  48093. /**
  48094. * Gets the actual render width of the texture.
  48095. * @returns the width of the render size
  48096. */
  48097. getRenderWidth(): number;
  48098. /**
  48099. * Gets the actual render height of the texture.
  48100. * @returns the height of the render size
  48101. */
  48102. getRenderHeight(): number;
  48103. /**
  48104. * Get if the texture can be rescaled or not.
  48105. */
  48106. readonly canRescale: boolean;
  48107. /**
  48108. * Resize the texture using a ratio.
  48109. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48110. */
  48111. scale(ratio: number): void;
  48112. /**
  48113. * Get the texture reflection matrix used to rotate/transform the reflection.
  48114. * @returns the reflection matrix
  48115. */
  48116. getReflectionTextureMatrix(): Matrix;
  48117. /**
  48118. * Resize the texture to a new desired size.
  48119. * Be carrefull as it will recreate all the data in the new texture.
  48120. * @param size Define the new size. It can be:
  48121. * - a number for squared texture,
  48122. * - an object containing { width: number, height: number }
  48123. * - or an object containing a ratio { ratio: number }
  48124. */
  48125. resize(size: number | {
  48126. width: number;
  48127. height: number;
  48128. } | {
  48129. ratio: number;
  48130. }): void;
  48131. /**
  48132. * Renders all the objects from the render list into the texture.
  48133. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48134. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48135. */
  48136. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48137. private _bestReflectionRenderTargetDimension;
  48138. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48139. private renderToTarget;
  48140. /**
  48141. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48142. * This allowed control for front to back rendering or reversly depending of the special needs.
  48143. *
  48144. * @param renderingGroupId The rendering group id corresponding to its index
  48145. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48146. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48147. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48148. */
  48149. 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;
  48150. /**
  48151. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48152. *
  48153. * @param renderingGroupId The rendering group id corresponding to its index
  48154. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48155. */
  48156. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48157. /**
  48158. * Clones the texture.
  48159. * @returns the cloned texture
  48160. */
  48161. clone(): RenderTargetTexture;
  48162. /**
  48163. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48164. * @returns The JSON representation of the texture
  48165. */
  48166. serialize(): any;
  48167. /**
  48168. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48169. */
  48170. disposeFramebufferObjects(): void;
  48171. /**
  48172. * Dispose the texture and release its associated resources.
  48173. */
  48174. dispose(): void;
  48175. /** @hidden */
  48176. _rebuild(): void;
  48177. /**
  48178. * Clear the info related to rendering groups preventing retention point in material dispose.
  48179. */
  48180. freeRenderingGroups(): void;
  48181. }
  48182. }
  48183. declare module BABYLON {
  48184. /**
  48185. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48186. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48187. */
  48188. class Texture extends BaseTexture {
  48189. /** nearest is mag = nearest and min = nearest and mip = linear */
  48190. static readonly NEAREST_SAMPLINGMODE: number;
  48191. /** nearest is mag = nearest and min = nearest and mip = linear */
  48192. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48194. static readonly BILINEAR_SAMPLINGMODE: number;
  48195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48196. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48197. /** Trilinear is mag = linear and min = linear and mip = linear */
  48198. static readonly TRILINEAR_SAMPLINGMODE: number;
  48199. /** Trilinear is mag = linear and min = linear and mip = linear */
  48200. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48201. /** mag = nearest and min = nearest and mip = nearest */
  48202. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48203. /** mag = nearest and min = linear and mip = nearest */
  48204. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48205. /** mag = nearest and min = linear and mip = linear */
  48206. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48207. /** mag = nearest and min = linear and mip = none */
  48208. static readonly NEAREST_LINEAR: number;
  48209. /** mag = nearest and min = nearest and mip = none */
  48210. static readonly NEAREST_NEAREST: number;
  48211. /** mag = linear and min = nearest and mip = nearest */
  48212. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48213. /** mag = linear and min = nearest and mip = linear */
  48214. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48215. /** mag = linear and min = linear and mip = none */
  48216. static readonly LINEAR_LINEAR: number;
  48217. /** mag = linear and min = nearest and mip = none */
  48218. static readonly LINEAR_NEAREST: number;
  48219. /** Explicit coordinates mode */
  48220. static readonly EXPLICIT_MODE: number;
  48221. /** Spherical coordinates mode */
  48222. static readonly SPHERICAL_MODE: number;
  48223. /** Planar coordinates mode */
  48224. static readonly PLANAR_MODE: number;
  48225. /** Cubic coordinates mode */
  48226. static readonly CUBIC_MODE: number;
  48227. /** Projection coordinates mode */
  48228. static readonly PROJECTION_MODE: number;
  48229. /** Inverse Cubic coordinates mode */
  48230. static readonly SKYBOX_MODE: number;
  48231. /** Inverse Cubic coordinates mode */
  48232. static readonly INVCUBIC_MODE: number;
  48233. /** Equirectangular coordinates mode */
  48234. static readonly EQUIRECTANGULAR_MODE: number;
  48235. /** Equirectangular Fixed coordinates mode */
  48236. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48237. /** Equirectangular Fixed Mirrored coordinates mode */
  48238. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48239. /** Texture is not repeating outside of 0..1 UVs */
  48240. static readonly CLAMP_ADDRESSMODE: number;
  48241. /** Texture is repeating outside of 0..1 UVs */
  48242. static readonly WRAP_ADDRESSMODE: number;
  48243. /** Texture is repeating and mirrored */
  48244. static readonly MIRROR_ADDRESSMODE: number;
  48245. /**
  48246. * 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
  48247. */
  48248. static UseSerializedUrlIfAny: boolean;
  48249. /**
  48250. * Define the url of the texture.
  48251. */
  48252. url: Nullable<string>;
  48253. /**
  48254. * Define an offset on the texture to offset the u coordinates of the UVs
  48255. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48256. */
  48257. uOffset: number;
  48258. /**
  48259. * Define an offset on the texture to offset the v coordinates of the UVs
  48260. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48261. */
  48262. vOffset: number;
  48263. /**
  48264. * Define an offset on the texture to scale the u coordinates of the UVs
  48265. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48266. */
  48267. uScale: number;
  48268. /**
  48269. * Define an offset on the texture to scale the v coordinates of the UVs
  48270. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48271. */
  48272. vScale: number;
  48273. /**
  48274. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48275. * @see http://doc.babylonjs.com/how_to/more_materials
  48276. */
  48277. uAng: number;
  48278. /**
  48279. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48280. * @see http://doc.babylonjs.com/how_to/more_materials
  48281. */
  48282. vAng: number;
  48283. /**
  48284. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48285. * @see http://doc.babylonjs.com/how_to/more_materials
  48286. */
  48287. wAng: number;
  48288. /**
  48289. * Defines the center of rotation (U)
  48290. */
  48291. uRotationCenter: number;
  48292. /**
  48293. * Defines the center of rotation (V)
  48294. */
  48295. vRotationCenter: number;
  48296. /**
  48297. * Defines the center of rotation (W)
  48298. */
  48299. wRotationCenter: number;
  48300. /**
  48301. * Are mip maps generated for this texture or not.
  48302. */
  48303. readonly noMipmap: boolean;
  48304. private _noMipmap;
  48305. /** @hidden */
  48306. _invertY: boolean;
  48307. private _rowGenerationMatrix;
  48308. private _cachedTextureMatrix;
  48309. private _projectionModeMatrix;
  48310. private _t0;
  48311. private _t1;
  48312. private _t2;
  48313. private _cachedUOffset;
  48314. private _cachedVOffset;
  48315. private _cachedUScale;
  48316. private _cachedVScale;
  48317. private _cachedUAng;
  48318. private _cachedVAng;
  48319. private _cachedWAng;
  48320. private _cachedProjectionMatrixId;
  48321. private _cachedCoordinatesMode;
  48322. /** @hidden */
  48323. protected _initialSamplingMode: number;
  48324. /** @hidden */
  48325. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48326. private _deleteBuffer;
  48327. protected _format: Nullable<number>;
  48328. private _delayedOnLoad;
  48329. private _delayedOnError;
  48330. /**
  48331. * Observable triggered once the texture has been loaded.
  48332. */
  48333. onLoadObservable: Observable<Texture>;
  48334. protected _isBlocking: boolean;
  48335. /**
  48336. * Is the texture preventing material to render while loading.
  48337. * If false, a default texture will be used instead of the loading one during the preparation step.
  48338. */
  48339. isBlocking: boolean;
  48340. /**
  48341. * Get the current sampling mode associated with the texture.
  48342. */
  48343. readonly samplingMode: number;
  48344. /**
  48345. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48346. */
  48347. readonly invertY: boolean;
  48348. /**
  48349. * Instantiates a new texture.
  48350. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48351. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48352. * @param url define the url of the picture to load as a texture
  48353. * @param scene define the scene the texture will belong to
  48354. * @param noMipmap define if the texture will require mip maps or not
  48355. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48356. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48357. * @param onLoad define a callback triggered when the texture has been loaded
  48358. * @param onError define a callback triggered when an error occurred during the loading session
  48359. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48360. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48361. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48362. */
  48363. 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);
  48364. /**
  48365. * Update the url (and optional buffer) of this texture if url was null during construction.
  48366. * @param url the url of the texture
  48367. * @param buffer the buffer of the texture (defaults to null)
  48368. * @param onLoad callback called when the texture is loaded (defaults to null)
  48369. */
  48370. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48371. /**
  48372. * Finish the loading sequence of a texture flagged as delayed load.
  48373. * @hidden
  48374. */
  48375. delayLoad(): void;
  48376. private _prepareRowForTextureGeneration;
  48377. /**
  48378. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48379. * @returns the transform matrix of the texture.
  48380. */
  48381. getTextureMatrix(): Matrix;
  48382. /**
  48383. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48384. * @returns The reflection texture transform
  48385. */
  48386. getReflectionTextureMatrix(): Matrix;
  48387. /**
  48388. * Clones the texture.
  48389. * @returns the cloned texture
  48390. */
  48391. clone(): Texture;
  48392. /**
  48393. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48394. * @returns The JSON representation of the texture
  48395. */
  48396. serialize(): any;
  48397. /**
  48398. * Get the current class name of the texture useful for serialization or dynamic coding.
  48399. * @returns "Texture"
  48400. */
  48401. getClassName(): string;
  48402. /**
  48403. * Dispose the texture and release its associated resources.
  48404. */
  48405. dispose(): void;
  48406. /**
  48407. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48408. * @param parsedTexture Define the JSON representation of the texture
  48409. * @param scene Define the scene the parsed texture should be instantiated in
  48410. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48411. * @returns The parsed texture if successful
  48412. */
  48413. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48414. /**
  48415. * Creates a texture from its base 64 representation.
  48416. * @param data Define the base64 payload without the data: prefix
  48417. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48418. * @param scene Define the scene the texture should belong to
  48419. * @param noMipmap Forces the texture to not create mip map information if true
  48420. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48421. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48422. * @param onLoad define a callback triggered when the texture has been loaded
  48423. * @param onError define a callback triggered when an error occurred during the loading session
  48424. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48425. * @returns the created texture
  48426. */
  48427. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48428. /**
  48429. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48430. * @param data Define the base64 payload without the data: prefix
  48431. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48432. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48433. * @param scene Define the scene the texture should belong to
  48434. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48435. * @param noMipmap Forces the texture to not create mip map information if true
  48436. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48437. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48438. * @param onLoad define a callback triggered when the texture has been loaded
  48439. * @param onError define a callback triggered when an error occurred during the loading session
  48440. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48441. * @returns the created texture
  48442. */
  48443. 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;
  48444. }
  48445. }
  48446. declare module BABYLON {
  48447. /**
  48448. * Settings for finer control over video usage
  48449. */
  48450. interface VideoTextureSettings {
  48451. /**
  48452. * Applies `autoplay` to video, if specified
  48453. */
  48454. autoPlay?: boolean;
  48455. /**
  48456. * Applies `loop` to video, if specified
  48457. */
  48458. loop?: boolean;
  48459. /**
  48460. * Automatically updates internal texture from video at every frame in the render loop
  48461. */
  48462. autoUpdateTexture: boolean;
  48463. /**
  48464. * Image src displayed during the video loading or until the user interacts with the video.
  48465. */
  48466. poster?: string;
  48467. }
  48468. /**
  48469. * If you want to display a video in your scene, this is the special texture for that.
  48470. * This special texture works similar to other textures, with the exception of a few parameters.
  48471. * @see https://doc.babylonjs.com/how_to/video_texture
  48472. */
  48473. class VideoTexture extends Texture {
  48474. /**
  48475. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48476. */
  48477. readonly autoUpdateTexture: boolean;
  48478. /**
  48479. * The video instance used by the texture internally
  48480. */
  48481. readonly video: HTMLVideoElement;
  48482. private _onUserActionRequestedObservable;
  48483. /**
  48484. * Event triggerd when a dom action is required by the user to play the video.
  48485. * This happens due to recent changes in browser policies preventing video to auto start.
  48486. */
  48487. readonly onUserActionRequestedObservable: Observable<Texture>;
  48488. private _generateMipMaps;
  48489. private _engine;
  48490. private _stillImageCaptured;
  48491. private _displayingPosterTexture;
  48492. private _settings;
  48493. private _createInternalTextureOnEvent;
  48494. /**
  48495. * Creates a video texture.
  48496. * If you want to display a video in your scene, this is the special texture for that.
  48497. * This special texture works similar to other textures, with the exception of a few parameters.
  48498. * @see https://doc.babylonjs.com/how_to/video_texture
  48499. * @param name optional name, will detect from video source, if not defined
  48500. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48501. * @param scene is obviously the current scene.
  48502. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48503. * @param invertY is false by default but can be used to invert video on Y axis
  48504. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48505. * @param settings allows finer control over video usage
  48506. */
  48507. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48508. private _getName;
  48509. private _getVideo;
  48510. private _createInternalTexture;
  48511. private reset;
  48512. /**
  48513. * @hidden Internal method to initiate `update`.
  48514. */
  48515. _rebuild(): void;
  48516. /**
  48517. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48518. */
  48519. update(): void;
  48520. /**
  48521. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48522. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48523. */
  48524. updateTexture(isVisible: boolean): void;
  48525. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48526. /**
  48527. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48528. * @param url New url.
  48529. */
  48530. updateURL(url: string): void;
  48531. /**
  48532. * Dispose the texture and release its associated resources.
  48533. */
  48534. dispose(): void;
  48535. /**
  48536. * Creates a video texture straight from your WebCam video feed.
  48537. * @param scene Define the scene the texture should be created in
  48538. * @param onReady Define a callback to triggered once the texture will be ready
  48539. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48540. */
  48541. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48542. minWidth: number;
  48543. maxWidth: number;
  48544. minHeight: number;
  48545. maxHeight: number;
  48546. deviceId: string;
  48547. }): void;
  48548. }
  48549. }
  48550. declare var DracoDecoderModule: any;
  48551. declare var WebAssembly: any;
  48552. declare module BABYLON {
  48553. /**
  48554. * Configuration for Draco compression
  48555. */
  48556. interface IDracoCompressionConfiguration {
  48557. /**
  48558. * Configuration for the decoder.
  48559. */
  48560. decoder?: {
  48561. /**
  48562. * The url to the WebAssembly module.
  48563. */
  48564. wasmUrl?: string;
  48565. /**
  48566. * The url to the WebAssembly binary.
  48567. */
  48568. wasmBinaryUrl?: string;
  48569. /**
  48570. * The url to the fallback JavaScript module.
  48571. */
  48572. fallbackUrl?: string;
  48573. };
  48574. }
  48575. /**
  48576. * Draco compression (https://google.github.io/draco/)
  48577. *
  48578. * This class wraps the Draco module.
  48579. *
  48580. * **Encoder**
  48581. *
  48582. * The encoder is not currently implemented.
  48583. *
  48584. * **Decoder**
  48585. *
  48586. * 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.
  48587. *
  48588. * To update the configuration, use the following code:
  48589. * ```javascript
  48590. * BABYLON.DracoCompression.Configuration = {
  48591. * decoder: {
  48592. * wasmUrl: "<url to the WebAssembly library>",
  48593. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48594. * fallbackUrl: "<url to the fallback JavaScript library>",
  48595. * }
  48596. * };
  48597. * ```
  48598. *
  48599. * 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.
  48600. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48601. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48602. *
  48603. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48604. * ```javascript
  48605. * var dracoCompression = new BABYLON.DracoCompression();
  48606. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48607. * [BABYLON.VertexBuffer.PositionKind]: 0
  48608. * });
  48609. * ```
  48610. *
  48611. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48612. */
  48613. class DracoCompression implements IDisposable {
  48614. private static _DecoderModulePromise;
  48615. /**
  48616. * The configuration. Defaults to the following urls:
  48617. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48618. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48619. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48620. */
  48621. static Configuration: IDracoCompressionConfiguration;
  48622. /**
  48623. * Returns true if the decoder is available.
  48624. */
  48625. static readonly DecoderAvailable: boolean;
  48626. /**
  48627. * Constructor
  48628. */
  48629. constructor();
  48630. /**
  48631. * Stop all async operations and release resources.
  48632. */
  48633. dispose(): void;
  48634. /**
  48635. * Decode Draco compressed mesh data to vertex data.
  48636. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48637. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48638. * @returns A promise that resolves with the decoded vertex data
  48639. */
  48640. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48641. [kind: string]: number;
  48642. }): Promise<VertexData>;
  48643. private static _GetDecoderModule;
  48644. private static _LoadScriptAsync;
  48645. private static _LoadFileAsync;
  48646. }
  48647. }
  48648. declare module BABYLON {
  48649. }
  48650. declare module BABYLON {
  48651. /**
  48652. * AmmoJS Physics plugin
  48653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48654. * @see https://github.com/kripken/ammo.js/
  48655. */
  48656. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48657. private _useDeltaForWorldStep;
  48658. /**
  48659. * Reference to the Ammo library
  48660. */
  48661. bjsAMMO: any;
  48662. /**
  48663. * Created ammoJS world which physics bodies are added to
  48664. */
  48665. world: any;
  48666. /**
  48667. * Name of the plugin
  48668. */
  48669. name: string;
  48670. private _timeStep;
  48671. private _fixedTimeStep;
  48672. private _maxSteps;
  48673. private _tmpQuaternion;
  48674. private _tmpAmmoTransform;
  48675. private _tmpAmmoQuaternion;
  48676. private _tmpAmmoConcreteContactResultCallback;
  48677. private _collisionConfiguration;
  48678. private _dispatcher;
  48679. private _overlappingPairCache;
  48680. private _solver;
  48681. private _tmpAmmoVectorA;
  48682. private _tmpAmmoVectorB;
  48683. private _tmpAmmoVectorC;
  48684. private _tmpContactCallbackResult;
  48685. private static readonly DISABLE_COLLISION_FLAG;
  48686. private static readonly KINEMATIC_FLAG;
  48687. private static readonly DISABLE_DEACTIVATION_FLAG;
  48688. /**
  48689. * Initializes the ammoJS plugin
  48690. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48691. */
  48692. constructor(_useDeltaForWorldStep?: boolean);
  48693. /**
  48694. * Sets the gravity of the physics world (m/(s^2))
  48695. * @param gravity Gravity to set
  48696. */
  48697. setGravity(gravity: Vector3): void;
  48698. /**
  48699. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48700. * @param timeStep timestep to use in seconds
  48701. */
  48702. setTimeStep(timeStep: number): void;
  48703. /**
  48704. * 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)
  48705. * @param fixedTimeStep fixedTimeStep to use in seconds
  48706. */
  48707. setFixedTimeStep(fixedTimeStep: number): void;
  48708. /**
  48709. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48710. * @param maxSteps the maximum number of steps by the physics engine per frame
  48711. */
  48712. setMaxSteps(maxSteps: number): void;
  48713. /**
  48714. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48715. * @returns the current timestep in seconds
  48716. */
  48717. getTimeStep(): number;
  48718. private _isImpostorInContact;
  48719. private _isImpostorPairInContact;
  48720. private _stepSimulation;
  48721. /**
  48722. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48723. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48724. * After the step the babylon meshes are set to the position of the physics imposters
  48725. * @param delta amount of time to step forward
  48726. * @param impostors array of imposters to update before/after the step
  48727. */
  48728. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48729. /**
  48730. * Applies an implulse on the imposter
  48731. * @param impostor imposter to apply impulse
  48732. * @param force amount of force to be applied to the imposter
  48733. * @param contactPoint the location to apply the impulse on the imposter
  48734. */
  48735. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48736. /**
  48737. * Applies a force on the imposter
  48738. * @param impostor imposter to apply force
  48739. * @param force amount of force to be applied to the imposter
  48740. * @param contactPoint the location to apply the force on the imposter
  48741. */
  48742. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48743. /**
  48744. * Creates a physics body using the plugin
  48745. * @param impostor the imposter to create the physics body on
  48746. */
  48747. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48748. /**
  48749. * Removes the physics body from the imposter and disposes of the body's memory
  48750. * @param impostor imposter to remove the physics body from
  48751. */
  48752. removePhysicsBody(impostor: PhysicsImpostor): void;
  48753. /**
  48754. * Generates a joint
  48755. * @param impostorJoint the imposter joint to create the joint with
  48756. */
  48757. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48758. /**
  48759. * Removes a joint
  48760. * @param impostorJoint the imposter joint to remove the joint from
  48761. */
  48762. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48763. private _addMeshVerts;
  48764. private _createShape;
  48765. /**
  48766. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48767. * @param impostor imposter containing the physics body and babylon object
  48768. */
  48769. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48770. /**
  48771. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48772. * @param impostor imposter containing the physics body and babylon object
  48773. * @param newPosition new position
  48774. * @param newRotation new rotation
  48775. */
  48776. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48777. /**
  48778. * If this plugin is supported
  48779. * @returns true if its supported
  48780. */
  48781. isSupported(): boolean;
  48782. /**
  48783. * Sets the linear velocity of the physics body
  48784. * @param impostor imposter to set the velocity on
  48785. * @param velocity velocity to set
  48786. */
  48787. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48788. /**
  48789. * Sets the angular velocity of the physics body
  48790. * @param impostor imposter to set the velocity on
  48791. * @param velocity velocity to set
  48792. */
  48793. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48794. /**
  48795. * gets the linear velocity
  48796. * @param impostor imposter to get linear velocity from
  48797. * @returns linear velocity
  48798. */
  48799. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48800. /**
  48801. * gets the angular velocity
  48802. * @param impostor imposter to get angular velocity from
  48803. * @returns angular velocity
  48804. */
  48805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48806. /**
  48807. * Sets the mass of physics body
  48808. * @param impostor imposter to set the mass on
  48809. * @param mass mass to set
  48810. */
  48811. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48812. /**
  48813. * Gets the mass of the physics body
  48814. * @param impostor imposter to get the mass from
  48815. * @returns mass
  48816. */
  48817. getBodyMass(impostor: PhysicsImpostor): number;
  48818. /**
  48819. * Gets friction of the impostor
  48820. * @param impostor impostor to get friction from
  48821. * @returns friction value
  48822. */
  48823. getBodyFriction(impostor: PhysicsImpostor): number;
  48824. /**
  48825. * Sets friction of the impostor
  48826. * @param impostor impostor to set friction on
  48827. * @param friction friction value
  48828. */
  48829. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48830. /**
  48831. * Gets restitution of the impostor
  48832. * @param impostor impostor to get restitution from
  48833. * @returns restitution value
  48834. */
  48835. getBodyRestitution(impostor: PhysicsImpostor): number;
  48836. /**
  48837. * Sets resitution of the impostor
  48838. * @param impostor impostor to set resitution on
  48839. * @param restitution resitution value
  48840. */
  48841. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48842. /**
  48843. * Sleeps the physics body and stops it from being active
  48844. * @param impostor impostor to sleep
  48845. */
  48846. sleepBody(impostor: PhysicsImpostor): void;
  48847. /**
  48848. * Activates the physics body
  48849. * @param impostor impostor to activate
  48850. */
  48851. wakeUpBody(impostor: PhysicsImpostor): void;
  48852. /**
  48853. * Updates the distance parameters of the joint
  48854. * @param joint joint to update
  48855. * @param maxDistance maximum distance of the joint
  48856. * @param minDistance minimum distance of the joint
  48857. */
  48858. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48859. /**
  48860. * Sets a motor on the joint
  48861. * @param joint joint to set motor on
  48862. * @param speed speed of the motor
  48863. * @param maxForce maximum force of the motor
  48864. * @param motorIndex index of the motor
  48865. */
  48866. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48867. /**
  48868. * Sets the motors limit
  48869. * @param joint joint to set limit on
  48870. * @param upperLimit upper limit
  48871. * @param lowerLimit lower limit
  48872. */
  48873. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48874. /**
  48875. * Syncs the position and rotation of a mesh with the impostor
  48876. * @param mesh mesh to sync
  48877. * @param impostor impostor to update the mesh with
  48878. */
  48879. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48880. /**
  48881. * Gets the radius of the impostor
  48882. * @param impostor impostor to get radius from
  48883. * @returns the radius
  48884. */
  48885. getRadius(impostor: PhysicsImpostor): number;
  48886. /**
  48887. * Gets the box size of the impostor
  48888. * @param impostor impostor to get box size from
  48889. * @param result the resulting box size
  48890. */
  48891. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48892. /**
  48893. * Disposes of the impostor
  48894. */
  48895. dispose(): void;
  48896. }
  48897. }
  48898. declare module BABYLON {
  48899. /** @hidden */
  48900. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48901. private _useDeltaForWorldStep;
  48902. world: any;
  48903. name: string;
  48904. private _physicsMaterials;
  48905. private _fixedTimeStep;
  48906. BJSCANNON: any;
  48907. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48908. setGravity(gravity: Vector3): void;
  48909. setTimeStep(timeStep: number): void;
  48910. getTimeStep(): number;
  48911. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48912. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48913. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48914. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48915. private _processChildMeshes;
  48916. removePhysicsBody(impostor: PhysicsImpostor): void;
  48917. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48918. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48919. private _addMaterial;
  48920. private _checkWithEpsilon;
  48921. private _createShape;
  48922. private _createHeightmap;
  48923. private _minus90X;
  48924. private _plus90X;
  48925. private _tmpPosition;
  48926. private _tmpDeltaPosition;
  48927. private _tmpUnityRotation;
  48928. private _updatePhysicsBodyTransformation;
  48929. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48930. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48931. isSupported(): boolean;
  48932. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48933. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48934. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48935. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48936. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48937. getBodyMass(impostor: PhysicsImpostor): number;
  48938. getBodyFriction(impostor: PhysicsImpostor): number;
  48939. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48940. getBodyRestitution(impostor: PhysicsImpostor): number;
  48941. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48942. sleepBody(impostor: PhysicsImpostor): void;
  48943. wakeUpBody(impostor: PhysicsImpostor): void;
  48944. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48945. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48946. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48947. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48948. getRadius(impostor: PhysicsImpostor): number;
  48949. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48950. dispose(): void;
  48951. private _extendNamespace;
  48952. }
  48953. }
  48954. declare module BABYLON {
  48955. /** @hidden */
  48956. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48957. world: any;
  48958. name: string;
  48959. BJSOIMO: any;
  48960. constructor(iterations?: number);
  48961. setGravity(gravity: Vector3): void;
  48962. setTimeStep(timeStep: number): void;
  48963. getTimeStep(): number;
  48964. private _tmpImpostorsArray;
  48965. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48966. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48967. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48968. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48969. private _tmpPositionVector;
  48970. removePhysicsBody(impostor: PhysicsImpostor): void;
  48971. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48972. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48973. isSupported(): boolean;
  48974. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48975. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48976. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48977. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48978. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48979. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48980. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48981. getBodyMass(impostor: PhysicsImpostor): number;
  48982. getBodyFriction(impostor: PhysicsImpostor): number;
  48983. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48984. getBodyRestitution(impostor: PhysicsImpostor): number;
  48985. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48986. sleepBody(impostor: PhysicsImpostor): void;
  48987. wakeUpBody(impostor: PhysicsImpostor): void;
  48988. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48989. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48990. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48991. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48992. getRadius(impostor: PhysicsImpostor): number;
  48993. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48994. dispose(): void;
  48995. }
  48996. }
  48997. declare module BABYLON {
  48998. /**
  48999. * Particle emitter emitting particles from the inside of a box.
  49000. * It emits the particles randomly between 2 given directions.
  49001. */
  49002. class BoxParticleEmitter implements IParticleEmitterType {
  49003. /**
  49004. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49005. */
  49006. direction1: Vector3;
  49007. /**
  49008. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49009. */
  49010. direction2: Vector3;
  49011. /**
  49012. * 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.
  49013. */
  49014. minEmitBox: Vector3;
  49015. /**
  49016. * 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.
  49017. */
  49018. maxEmitBox: Vector3;
  49019. /**
  49020. * Creates a new instance BoxParticleEmitter
  49021. */
  49022. constructor();
  49023. /**
  49024. * Called by the particle System when the direction is computed for the created particle.
  49025. * @param worldMatrix is the world matrix of the particle system
  49026. * @param directionToUpdate is the direction vector to update with the result
  49027. * @param particle is the particle we are computed the direction for
  49028. */
  49029. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49030. /**
  49031. * Called by the particle System when the position is computed for the created particle.
  49032. * @param worldMatrix is the world matrix of the particle system
  49033. * @param positionToUpdate is the position vector to update with the result
  49034. * @param particle is the particle we are computed the position for
  49035. */
  49036. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49037. /**
  49038. * Clones the current emitter and returns a copy of it
  49039. * @returns the new emitter
  49040. */
  49041. clone(): BoxParticleEmitter;
  49042. /**
  49043. * Called by the GPUParticleSystem to setup the update shader
  49044. * @param effect defines the update shader
  49045. */
  49046. applyToShader(effect: Effect): void;
  49047. /**
  49048. * Returns a string to use to update the GPU particles update shader
  49049. * @returns a string containng the defines string
  49050. */
  49051. getEffectDefines(): string;
  49052. /**
  49053. * Returns the string "BoxParticleEmitter"
  49054. * @returns a string containing the class name
  49055. */
  49056. getClassName(): string;
  49057. /**
  49058. * Serializes the particle system to a JSON object.
  49059. * @returns the JSON object
  49060. */
  49061. serialize(): any;
  49062. /**
  49063. * Parse properties from a JSON object
  49064. * @param serializationObject defines the JSON object
  49065. */
  49066. parse(serializationObject: any): void;
  49067. }
  49068. }
  49069. declare module BABYLON {
  49070. /**
  49071. * Particle emitter emitting particles from the inside of a cone.
  49072. * It emits the particles alongside the cone volume from the base to the particle.
  49073. * The emission direction might be randomized.
  49074. */
  49075. class ConeParticleEmitter implements IParticleEmitterType {
  49076. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  49077. directionRandomizer: number;
  49078. private _radius;
  49079. private _angle;
  49080. private _height;
  49081. /**
  49082. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  49083. */
  49084. radiusRange: number;
  49085. /**
  49086. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  49087. */
  49088. heightRange: number;
  49089. /**
  49090. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  49091. */
  49092. emitFromSpawnPointOnly: boolean;
  49093. /**
  49094. * Gets or sets the radius of the emission cone
  49095. */
  49096. radius: number;
  49097. /**
  49098. * Gets or sets the angle of the emission cone
  49099. */
  49100. angle: number;
  49101. private _buildHeight;
  49102. /**
  49103. * Creates a new instance ConeParticleEmitter
  49104. * @param radius the radius of the emission cone (1 by default)
  49105. * @param angles the cone base angle (PI by default)
  49106. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  49107. */
  49108. constructor(radius?: number, angle?: number,
  49109. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  49110. directionRandomizer?: number);
  49111. /**
  49112. * Called by the particle System when the direction is computed for the created particle.
  49113. * @param worldMatrix is the world matrix of the particle system
  49114. * @param directionToUpdate is the direction vector to update with the result
  49115. * @param particle is the particle we are computed the direction for
  49116. */
  49117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49118. /**
  49119. * Called by the particle System when the position is computed for the created particle.
  49120. * @param worldMatrix is the world matrix of the particle system
  49121. * @param positionToUpdate is the position vector to update with the result
  49122. * @param particle is the particle we are computed the position for
  49123. */
  49124. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49125. /**
  49126. * Clones the current emitter and returns a copy of it
  49127. * @returns the new emitter
  49128. */
  49129. clone(): ConeParticleEmitter;
  49130. /**
  49131. * Called by the GPUParticleSystem to setup the update shader
  49132. * @param effect defines the update shader
  49133. */
  49134. applyToShader(effect: Effect): void;
  49135. /**
  49136. * Returns a string to use to update the GPU particles update shader
  49137. * @returns a string containng the defines string
  49138. */
  49139. getEffectDefines(): string;
  49140. /**
  49141. * Returns the string "ConeParticleEmitter"
  49142. * @returns a string containing the class name
  49143. */
  49144. getClassName(): string;
  49145. /**
  49146. * Serializes the particle system to a JSON object.
  49147. * @returns the JSON object
  49148. */
  49149. serialize(): any;
  49150. /**
  49151. * Parse properties from a JSON object
  49152. * @param serializationObject defines the JSON object
  49153. */
  49154. parse(serializationObject: any): void;
  49155. }
  49156. }
  49157. declare module BABYLON {
  49158. /**
  49159. * Particle emitter emitting particles from the inside of a cylinder.
  49160. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  49161. */
  49162. class CylinderParticleEmitter implements IParticleEmitterType {
  49163. /**
  49164. * The radius of the emission cylinder.
  49165. */
  49166. radius: number;
  49167. /**
  49168. * The height of the emission cylinder.
  49169. */
  49170. height: number;
  49171. /**
  49172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49173. */
  49174. radiusRange: number;
  49175. /**
  49176. * How much to randomize the particle direction [0-1].
  49177. */
  49178. directionRandomizer: number;
  49179. /**
  49180. * Creates a new instance CylinderParticleEmitter
  49181. * @param radius the radius of the emission cylinder (1 by default)
  49182. * @param height the height of the emission cylinder (1 by default)
  49183. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49184. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49185. */
  49186. constructor(
  49187. /**
  49188. * The radius of the emission cylinder.
  49189. */
  49190. radius?: number,
  49191. /**
  49192. * The height of the emission cylinder.
  49193. */
  49194. height?: number,
  49195. /**
  49196. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49197. */
  49198. radiusRange?: number,
  49199. /**
  49200. * How much to randomize the particle direction [0-1].
  49201. */
  49202. directionRandomizer?: number);
  49203. /**
  49204. * Called by the particle System when the direction is computed for the created particle.
  49205. * @param worldMatrix is the world matrix of the particle system
  49206. * @param directionToUpdate is the direction vector to update with the result
  49207. * @param particle is the particle we are computed the direction for
  49208. */
  49209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49210. /**
  49211. * Called by the particle System when the position is computed for the created particle.
  49212. * @param worldMatrix is the world matrix of the particle system
  49213. * @param positionToUpdate is the position vector to update with the result
  49214. * @param particle is the particle we are computed the position for
  49215. */
  49216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49217. /**
  49218. * Clones the current emitter and returns a copy of it
  49219. * @returns the new emitter
  49220. */
  49221. clone(): CylinderParticleEmitter;
  49222. /**
  49223. * Called by the GPUParticleSystem to setup the update shader
  49224. * @param effect defines the update shader
  49225. */
  49226. applyToShader(effect: Effect): void;
  49227. /**
  49228. * Returns a string to use to update the GPU particles update shader
  49229. * @returns a string containng the defines string
  49230. */
  49231. getEffectDefines(): string;
  49232. /**
  49233. * Returns the string "CylinderParticleEmitter"
  49234. * @returns a string containing the class name
  49235. */
  49236. getClassName(): string;
  49237. /**
  49238. * Serializes the particle system to a JSON object.
  49239. * @returns the JSON object
  49240. */
  49241. serialize(): any;
  49242. /**
  49243. * Parse properties from a JSON object
  49244. * @param serializationObject defines the JSON object
  49245. */
  49246. parse(serializationObject: any): void;
  49247. }
  49248. /**
  49249. * Particle emitter emitting particles from the inside of a cylinder.
  49250. * It emits the particles randomly between two vectors.
  49251. */
  49252. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  49253. /**
  49254. * The min limit of the emission direction.
  49255. */
  49256. direction1: Vector3;
  49257. /**
  49258. * The max limit of the emission direction.
  49259. */
  49260. direction2: Vector3;
  49261. /**
  49262. * Creates a new instance CylinderDirectedParticleEmitter
  49263. * @param radius the radius of the emission cylinder (1 by default)
  49264. * @param height the height of the emission cylinder (1 by default)
  49265. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49266. * @param direction1 the min limit of the emission direction (up vector by default)
  49267. * @param direction2 the max limit of the emission direction (up vector by default)
  49268. */
  49269. constructor(radius?: number, height?: number, radiusRange?: number,
  49270. /**
  49271. * The min limit of the emission direction.
  49272. */
  49273. direction1?: Vector3,
  49274. /**
  49275. * The max limit of the emission direction.
  49276. */
  49277. direction2?: Vector3);
  49278. /**
  49279. * Called by the particle System when the direction is computed for the created particle.
  49280. * @param worldMatrix is the world matrix of the particle system
  49281. * @param directionToUpdate is the direction vector to update with the result
  49282. * @param particle is the particle we are computed the direction for
  49283. */
  49284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49285. /**
  49286. * Clones the current emitter and returns a copy of it
  49287. * @returns the new emitter
  49288. */
  49289. clone(): CylinderDirectedParticleEmitter;
  49290. /**
  49291. * Called by the GPUParticleSystem to setup the update shader
  49292. * @param effect defines the update shader
  49293. */
  49294. applyToShader(effect: Effect): void;
  49295. /**
  49296. * Returns a string to use to update the GPU particles update shader
  49297. * @returns a string containng the defines string
  49298. */
  49299. getEffectDefines(): string;
  49300. /**
  49301. * Returns the string "CylinderDirectedParticleEmitter"
  49302. * @returns a string containing the class name
  49303. */
  49304. getClassName(): string;
  49305. /**
  49306. * Serializes the particle system to a JSON object.
  49307. * @returns the JSON object
  49308. */
  49309. serialize(): any;
  49310. /**
  49311. * Parse properties from a JSON object
  49312. * @param serializationObject defines the JSON object
  49313. */
  49314. parse(serializationObject: any): void;
  49315. }
  49316. }
  49317. declare module BABYLON {
  49318. /**
  49319. * Particle emitter emitting particles from the inside of a hemisphere.
  49320. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  49321. */
  49322. class HemisphericParticleEmitter implements IParticleEmitterType {
  49323. /**
  49324. * The radius of the emission hemisphere.
  49325. */
  49326. radius: number;
  49327. /**
  49328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49329. */
  49330. radiusRange: number;
  49331. /**
  49332. * How much to randomize the particle direction [0-1].
  49333. */
  49334. directionRandomizer: number;
  49335. /**
  49336. * Creates a new instance HemisphericParticleEmitter
  49337. * @param radius the radius of the emission hemisphere (1 by default)
  49338. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49339. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49340. */
  49341. constructor(
  49342. /**
  49343. * The radius of the emission hemisphere.
  49344. */
  49345. radius?: number,
  49346. /**
  49347. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49348. */
  49349. radiusRange?: number,
  49350. /**
  49351. * How much to randomize the particle direction [0-1].
  49352. */
  49353. directionRandomizer?: number);
  49354. /**
  49355. * Called by the particle System when the direction is computed for the created particle.
  49356. * @param worldMatrix is the world matrix of the particle system
  49357. * @param directionToUpdate is the direction vector to update with the result
  49358. * @param particle is the particle we are computed the direction for
  49359. */
  49360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49361. /**
  49362. * Called by the particle System when the position is computed for the created particle.
  49363. * @param worldMatrix is the world matrix of the particle system
  49364. * @param positionToUpdate is the position vector to update with the result
  49365. * @param particle is the particle we are computed the position for
  49366. */
  49367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49368. /**
  49369. * Clones the current emitter and returns a copy of it
  49370. * @returns the new emitter
  49371. */
  49372. clone(): HemisphericParticleEmitter;
  49373. /**
  49374. * Called by the GPUParticleSystem to setup the update shader
  49375. * @param effect defines the update shader
  49376. */
  49377. applyToShader(effect: Effect): void;
  49378. /**
  49379. * Returns a string to use to update the GPU particles update shader
  49380. * @returns a string containng the defines string
  49381. */
  49382. getEffectDefines(): string;
  49383. /**
  49384. * Returns the string "HemisphericParticleEmitter"
  49385. * @returns a string containing the class name
  49386. */
  49387. getClassName(): string;
  49388. /**
  49389. * Serializes the particle system to a JSON object.
  49390. * @returns the JSON object
  49391. */
  49392. serialize(): any;
  49393. /**
  49394. * Parse properties from a JSON object
  49395. * @param serializationObject defines the JSON object
  49396. */
  49397. parse(serializationObject: any): void;
  49398. }
  49399. }
  49400. declare module BABYLON {
  49401. /**
  49402. * Particle emitter represents a volume emitting particles.
  49403. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49404. */
  49405. interface IParticleEmitterType {
  49406. /**
  49407. * Called by the particle System when the direction is computed for the created particle.
  49408. * @param worldMatrix is the world matrix of the particle system
  49409. * @param directionToUpdate is the direction vector to update with the result
  49410. * @param particle is the particle we are computed the direction for
  49411. */
  49412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49413. /**
  49414. * Called by the particle System when the position is computed for the created particle.
  49415. * @param worldMatrix is the world matrix of the particle system
  49416. * @param positionToUpdate is the position vector to update with the result
  49417. * @param particle is the particle we are computed the position for
  49418. */
  49419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49420. /**
  49421. * Clones the current emitter and returns a copy of it
  49422. * @returns the new emitter
  49423. */
  49424. clone(): IParticleEmitterType;
  49425. /**
  49426. * Called by the GPUParticleSystem to setup the update shader
  49427. * @param effect defines the update shader
  49428. */
  49429. applyToShader(effect: Effect): void;
  49430. /**
  49431. * Returns a string to use to update the GPU particles update shader
  49432. * @returns the effect defines string
  49433. */
  49434. getEffectDefines(): string;
  49435. /**
  49436. * Returns a string representing the class name
  49437. * @returns a string containing the class name
  49438. */
  49439. getClassName(): string;
  49440. /**
  49441. * Serializes the particle system to a JSON object.
  49442. * @returns the JSON object
  49443. */
  49444. serialize(): any;
  49445. /**
  49446. * Parse properties from a JSON object
  49447. * @param serializationObject defines the JSON object
  49448. */
  49449. parse(serializationObject: any): void;
  49450. }
  49451. }
  49452. declare module BABYLON {
  49453. /**
  49454. * Particle emitter emitting particles from a point.
  49455. * It emits the particles randomly between 2 given directions.
  49456. */
  49457. class PointParticleEmitter implements IParticleEmitterType {
  49458. /**
  49459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49460. */
  49461. direction1: Vector3;
  49462. /**
  49463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49464. */
  49465. direction2: Vector3;
  49466. /**
  49467. * Creates a new instance PointParticleEmitter
  49468. */
  49469. constructor();
  49470. /**
  49471. * Called by the particle System when the direction is computed for the created particle.
  49472. * @param worldMatrix is the world matrix of the particle system
  49473. * @param directionToUpdate is the direction vector to update with the result
  49474. * @param particle is the particle we are computed the direction for
  49475. */
  49476. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49477. /**
  49478. * Called by the particle System when the position is computed for the created particle.
  49479. * @param worldMatrix is the world matrix of the particle system
  49480. * @param positionToUpdate is the position vector to update with the result
  49481. * @param particle is the particle we are computed the position for
  49482. */
  49483. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49484. /**
  49485. * Clones the current emitter and returns a copy of it
  49486. * @returns the new emitter
  49487. */
  49488. clone(): PointParticleEmitter;
  49489. /**
  49490. * Called by the GPUParticleSystem to setup the update shader
  49491. * @param effect defines the update shader
  49492. */
  49493. applyToShader(effect: Effect): void;
  49494. /**
  49495. * Returns a string to use to update the GPU particles update shader
  49496. * @returns a string containng the defines string
  49497. */
  49498. getEffectDefines(): string;
  49499. /**
  49500. * Returns the string "PointParticleEmitter"
  49501. * @returns a string containing the class name
  49502. */
  49503. getClassName(): string;
  49504. /**
  49505. * Serializes the particle system to a JSON object.
  49506. * @returns the JSON object
  49507. */
  49508. serialize(): any;
  49509. /**
  49510. * Parse properties from a JSON object
  49511. * @param serializationObject defines the JSON object
  49512. */
  49513. parse(serializationObject: any): void;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * Particle emitter emitting particles from the inside of a sphere.
  49519. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49520. */
  49521. class SphereParticleEmitter implements IParticleEmitterType {
  49522. /**
  49523. * The radius of the emission sphere.
  49524. */
  49525. radius: number;
  49526. /**
  49527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49528. */
  49529. radiusRange: number;
  49530. /**
  49531. * How much to randomize the particle direction [0-1].
  49532. */
  49533. directionRandomizer: number;
  49534. /**
  49535. * Creates a new instance SphereParticleEmitter
  49536. * @param radius the radius of the emission sphere (1 by default)
  49537. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49538. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49539. */
  49540. constructor(
  49541. /**
  49542. * The radius of the emission sphere.
  49543. */
  49544. radius?: number,
  49545. /**
  49546. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49547. */
  49548. radiusRange?: number,
  49549. /**
  49550. * How much to randomize the particle direction [0-1].
  49551. */
  49552. directionRandomizer?: number);
  49553. /**
  49554. * Called by the particle System when the direction is computed for the created particle.
  49555. * @param worldMatrix is the world matrix of the particle system
  49556. * @param directionToUpdate is the direction vector to update with the result
  49557. * @param particle is the particle we are computed the direction for
  49558. */
  49559. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49560. /**
  49561. * Called by the particle System when the position is computed for the created particle.
  49562. * @param worldMatrix is the world matrix of the particle system
  49563. * @param positionToUpdate is the position vector to update with the result
  49564. * @param particle is the particle we are computed the position for
  49565. */
  49566. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49567. /**
  49568. * Clones the current emitter and returns a copy of it
  49569. * @returns the new emitter
  49570. */
  49571. clone(): SphereParticleEmitter;
  49572. /**
  49573. * Called by the GPUParticleSystem to setup the update shader
  49574. * @param effect defines the update shader
  49575. */
  49576. applyToShader(effect: Effect): void;
  49577. /**
  49578. * Returns a string to use to update the GPU particles update shader
  49579. * @returns a string containng the defines string
  49580. */
  49581. getEffectDefines(): string;
  49582. /**
  49583. * Returns the string "SphereParticleEmitter"
  49584. * @returns a string containing the class name
  49585. */
  49586. getClassName(): string;
  49587. /**
  49588. * Serializes the particle system to a JSON object.
  49589. * @returns the JSON object
  49590. */
  49591. serialize(): any;
  49592. /**
  49593. * Parse properties from a JSON object
  49594. * @param serializationObject defines the JSON object
  49595. */
  49596. parse(serializationObject: any): void;
  49597. }
  49598. /**
  49599. * Particle emitter emitting particles from the inside of a sphere.
  49600. * It emits the particles randomly between two vectors.
  49601. */
  49602. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49603. /**
  49604. * The min limit of the emission direction.
  49605. */
  49606. direction1: Vector3;
  49607. /**
  49608. * The max limit of the emission direction.
  49609. */
  49610. direction2: Vector3;
  49611. /**
  49612. * Creates a new instance SphereDirectedParticleEmitter
  49613. * @param radius the radius of the emission sphere (1 by default)
  49614. * @param direction1 the min limit of the emission direction (up vector by default)
  49615. * @param direction2 the max limit of the emission direction (up vector by default)
  49616. */
  49617. constructor(radius?: number,
  49618. /**
  49619. * The min limit of the emission direction.
  49620. */
  49621. direction1?: Vector3,
  49622. /**
  49623. * The max limit of the emission direction.
  49624. */
  49625. direction2?: Vector3);
  49626. /**
  49627. * Called by the particle System when the direction is computed for the created particle.
  49628. * @param worldMatrix is the world matrix of the particle system
  49629. * @param directionToUpdate is the direction vector to update with the result
  49630. * @param particle is the particle we are computed the direction for
  49631. */
  49632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49633. /**
  49634. * Clones the current emitter and returns a copy of it
  49635. * @returns the new emitter
  49636. */
  49637. clone(): SphereDirectedParticleEmitter;
  49638. /**
  49639. * Called by the GPUParticleSystem to setup the update shader
  49640. * @param effect defines the update shader
  49641. */
  49642. applyToShader(effect: Effect): void;
  49643. /**
  49644. * Returns a string to use to update the GPU particles update shader
  49645. * @returns a string containng the defines string
  49646. */
  49647. getEffectDefines(): string;
  49648. /**
  49649. * Returns the string "SphereDirectedParticleEmitter"
  49650. * @returns a string containing the class name
  49651. */
  49652. getClassName(): string;
  49653. /**
  49654. * Serializes the particle system to a JSON object.
  49655. * @returns the JSON object
  49656. */
  49657. serialize(): any;
  49658. /**
  49659. * Parse properties from a JSON object
  49660. * @param serializationObject defines the JSON object
  49661. */
  49662. parse(serializationObject: any): void;
  49663. }
  49664. }
  49665. declare module BABYLON {
  49666. /**
  49667. * This represents a set of one or more post processes in Babylon.
  49668. * A post process can be used to apply a shader to a texture after it is rendered.
  49669. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49670. */
  49671. class PostProcessRenderEffect {
  49672. private _postProcesses;
  49673. private _getPostProcesses;
  49674. private _singleInstance;
  49675. private _cameras;
  49676. private _indicesForCamera;
  49677. /**
  49678. * Name of the effect
  49679. * @hidden
  49680. */
  49681. _name: string;
  49682. /**
  49683. * Instantiates a post process render effect.
  49684. * A post process can be used to apply a shader to a texture after it is rendered.
  49685. * @param engine The engine the effect is tied to
  49686. * @param name The name of the effect
  49687. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49688. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49689. */
  49690. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49691. /**
  49692. * Checks if all the post processes in the effect are supported.
  49693. */
  49694. readonly isSupported: boolean;
  49695. /**
  49696. * Updates the current state of the effect
  49697. * @hidden
  49698. */
  49699. _update(): void;
  49700. /**
  49701. * Attaches the effect on cameras
  49702. * @param cameras The camera to attach to.
  49703. * @hidden
  49704. */
  49705. _attachCameras(cameras: Camera): void;
  49706. /**
  49707. * Attaches the effect on cameras
  49708. * @param cameras The camera to attach to.
  49709. * @hidden
  49710. */
  49711. _attachCameras(cameras: Camera[]): void;
  49712. /**
  49713. * Detatches the effect on cameras
  49714. * @param cameras The camera to detatch from.
  49715. * @hidden
  49716. */
  49717. _detachCameras(cameras: Camera): void;
  49718. /**
  49719. * Detatches the effect on cameras
  49720. * @param cameras The camera to detatch from.
  49721. * @hidden
  49722. */
  49723. _detachCameras(cameras: Camera[]): void;
  49724. /**
  49725. * Enables the effect on given cameras
  49726. * @param cameras The camera to enable.
  49727. * @hidden
  49728. */
  49729. _enable(cameras: Camera): void;
  49730. /**
  49731. * Enables the effect on given cameras
  49732. * @param cameras The camera to enable.
  49733. * @hidden
  49734. */
  49735. _enable(cameras: Nullable<Camera[]>): void;
  49736. /**
  49737. * Disables the effect on the given cameras
  49738. * @param cameras The camera to disable.
  49739. * @hidden
  49740. */
  49741. _disable(cameras: Camera): void;
  49742. /**
  49743. * Disables the effect on the given cameras
  49744. * @param cameras The camera to disable.
  49745. * @hidden
  49746. */
  49747. _disable(cameras: Nullable<Camera[]>): void;
  49748. /**
  49749. * Gets a list of the post processes contained in the effect.
  49750. * @param camera The camera to get the post processes on.
  49751. * @returns The list of the post processes in the effect.
  49752. */
  49753. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49754. }
  49755. }
  49756. declare module BABYLON {
  49757. /**
  49758. * PostProcessRenderPipeline
  49759. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49760. */
  49761. class PostProcessRenderPipeline {
  49762. private engine;
  49763. private _renderEffects;
  49764. private _renderEffectsForIsolatedPass;
  49765. /**
  49766. * @hidden
  49767. */
  49768. protected _cameras: Camera[];
  49769. /** @hidden */
  49770. _name: string;
  49771. /**
  49772. * Initializes a PostProcessRenderPipeline
  49773. * @param engine engine to add the pipeline to
  49774. * @param name name of the pipeline
  49775. */
  49776. constructor(engine: Engine, name: string);
  49777. /**
  49778. * "PostProcessRenderPipeline"
  49779. * @returns "PostProcessRenderPipeline"
  49780. */
  49781. getClassName(): string;
  49782. /**
  49783. * If all the render effects in the pipeline are support
  49784. */
  49785. readonly isSupported: boolean;
  49786. /**
  49787. * Adds an effect to the pipeline
  49788. * @param renderEffect the effect to add
  49789. */
  49790. addEffect(renderEffect: PostProcessRenderEffect): void;
  49791. /** @hidden */
  49792. _rebuild(): void;
  49793. /** @hidden */
  49794. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49795. /** @hidden */
  49796. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49797. /** @hidden */
  49798. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49799. /** @hidden */
  49800. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49801. /** @hidden */
  49802. _attachCameras(cameras: Camera, unique: boolean): void;
  49803. /** @hidden */
  49804. _attachCameras(cameras: Camera[], unique: boolean): void;
  49805. /** @hidden */
  49806. _detachCameras(cameras: Camera): void;
  49807. /** @hidden */
  49808. _detachCameras(cameras: Nullable<Camera[]>): void;
  49809. /** @hidden */
  49810. _update(): void;
  49811. /** @hidden */
  49812. _reset(): void;
  49813. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49814. /**
  49815. * Disposes of the pipeline
  49816. */
  49817. dispose(): void;
  49818. }
  49819. }
  49820. declare module BABYLON {
  49821. /**
  49822. * PostProcessRenderPipelineManager class
  49823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49824. */
  49825. class PostProcessRenderPipelineManager {
  49826. private _renderPipelines;
  49827. /**
  49828. * Initializes a PostProcessRenderPipelineManager
  49829. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49830. */
  49831. constructor();
  49832. /**
  49833. * Adds a pipeline to the manager
  49834. * @param renderPipeline The pipeline to add
  49835. */
  49836. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49837. /**
  49838. * Attaches a camera to the pipeline
  49839. * @param renderPipelineName The name of the pipeline to attach to
  49840. * @param cameras the camera to attach
  49841. * @param unique if the camera can be attached multiple times to the pipeline
  49842. */
  49843. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49844. /**
  49845. * Detaches a camera from the pipeline
  49846. * @param renderPipelineName The name of the pipeline to detach from
  49847. * @param cameras the camera to detach
  49848. */
  49849. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49850. /**
  49851. * Enables an effect by name on a pipeline
  49852. * @param renderPipelineName the name of the pipeline to enable the effect in
  49853. * @param renderEffectName the name of the effect to enable
  49854. * @param cameras the cameras that the effect should be enabled on
  49855. */
  49856. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49857. /**
  49858. * Disables an effect by name on a pipeline
  49859. * @param renderPipelineName the name of the pipeline to disable the effect in
  49860. * @param renderEffectName the name of the effect to disable
  49861. * @param cameras the cameras that the effect should be disabled on
  49862. */
  49863. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49864. /**
  49865. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49866. */
  49867. update(): void;
  49868. /** @hidden */
  49869. _rebuild(): void;
  49870. /**
  49871. * Disposes of the manager and pipelines
  49872. */
  49873. dispose(): void;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. interface Scene {
  49878. /** @hidden (Backing field) */
  49879. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49880. /**
  49881. * Gets the postprocess render pipeline manager
  49882. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49883. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49884. */
  49885. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49886. }
  49887. /**
  49888. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49889. */
  49890. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49891. /**
  49892. * The component name helpfull to identify the component in the list of scene components.
  49893. */
  49894. readonly name: string;
  49895. /**
  49896. * The scene the component belongs to.
  49897. */
  49898. scene: Scene;
  49899. /**
  49900. * Creates a new instance of the component for the given scene
  49901. * @param scene Defines the scene to register the component in
  49902. */
  49903. constructor(scene: Scene);
  49904. /**
  49905. * Registers the component in a given scene
  49906. */
  49907. register(): void;
  49908. /**
  49909. * Rebuilds the elements related to this component in case of
  49910. * context lost for instance.
  49911. */
  49912. rebuild(): void;
  49913. /**
  49914. * Disposes the component and the associated ressources
  49915. */
  49916. dispose(): void;
  49917. private _gatherRenderTargets;
  49918. }
  49919. }
  49920. declare module BABYLON {
  49921. /**
  49922. * Helper class dealing with the extraction of spherical polynomial dataArray
  49923. * from a cube map.
  49924. */
  49925. class CubeMapToSphericalPolynomialTools {
  49926. private static FileFaces;
  49927. /**
  49928. * Converts a texture to the according Spherical Polynomial data.
  49929. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49930. *
  49931. * @param texture The texture to extract the information from.
  49932. * @return The Spherical Polynomial data.
  49933. */
  49934. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49935. /**
  49936. * Converts a cubemap to the according Spherical Polynomial data.
  49937. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49938. *
  49939. * @param cubeInfo The Cube map to extract the information from.
  49940. * @return The Spherical Polynomial data.
  49941. */
  49942. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49943. }
  49944. }
  49945. declare module BABYLON {
  49946. /**
  49947. * Header information of HDR texture files.
  49948. */
  49949. interface HDRInfo {
  49950. /**
  49951. * The height of the texture in pixels.
  49952. */
  49953. height: number;
  49954. /**
  49955. * The width of the texture in pixels.
  49956. */
  49957. width: number;
  49958. /**
  49959. * The index of the beginning of the data in the binary file.
  49960. */
  49961. dataPosition: number;
  49962. }
  49963. /**
  49964. * This groups tools to convert HDR texture to native colors array.
  49965. */
  49966. class HDRTools {
  49967. private static Ldexp;
  49968. private static Rgbe2float;
  49969. private static readStringLine;
  49970. /**
  49971. * Reads header information from an RGBE texture stored in a native array.
  49972. * More information on this format are available here:
  49973. * https://en.wikipedia.org/wiki/RGBE_image_format
  49974. *
  49975. * @param uint8array The binary file stored in native array.
  49976. * @return The header information.
  49977. */
  49978. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49979. /**
  49980. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49981. * This RGBE texture needs to store the information as a panorama.
  49982. *
  49983. * More information on this format are available here:
  49984. * https://en.wikipedia.org/wiki/RGBE_image_format
  49985. *
  49986. * @param buffer The binary file stored in an array buffer.
  49987. * @param size The expected size of the extracted cubemap.
  49988. * @return The Cube Map information.
  49989. */
  49990. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49991. /**
  49992. * Returns the pixels data extracted from an RGBE texture.
  49993. * This pixels will be stored left to right up to down in the R G B order in one array.
  49994. *
  49995. * More information on this format are available here:
  49996. * https://en.wikipedia.org/wiki/RGBE_image_format
  49997. *
  49998. * @param uint8array The binary file stored in an array buffer.
  49999. * @param hdrInfo The header information of the file.
  50000. * @return The pixels data in RGB right to left up to down order.
  50001. */
  50002. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50003. private static RGBE_ReadPixels_RLE;
  50004. }
  50005. }
  50006. declare module BABYLON {
  50007. /**
  50008. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50009. */
  50010. interface CubeMapInfo {
  50011. /**
  50012. * The pixel array for the front face.
  50013. * This is stored in format, left to right, up to down format.
  50014. */
  50015. front: Nullable<ArrayBufferView>;
  50016. /**
  50017. * The pixel array for the back face.
  50018. * This is stored in format, left to right, up to down format.
  50019. */
  50020. back: Nullable<ArrayBufferView>;
  50021. /**
  50022. * The pixel array for the left face.
  50023. * This is stored in format, left to right, up to down format.
  50024. */
  50025. left: Nullable<ArrayBufferView>;
  50026. /**
  50027. * The pixel array for the right face.
  50028. * This is stored in format, left to right, up to down format.
  50029. */
  50030. right: Nullable<ArrayBufferView>;
  50031. /**
  50032. * The pixel array for the up face.
  50033. * This is stored in format, left to right, up to down format.
  50034. */
  50035. up: Nullable<ArrayBufferView>;
  50036. /**
  50037. * The pixel array for the down face.
  50038. * This is stored in format, left to right, up to down format.
  50039. */
  50040. down: Nullable<ArrayBufferView>;
  50041. /**
  50042. * The size of the cubemap stored.
  50043. *
  50044. * Each faces will be size * size pixels.
  50045. */
  50046. size: number;
  50047. /**
  50048. * The format of the texture.
  50049. *
  50050. * RGBA, RGB.
  50051. */
  50052. format: number;
  50053. /**
  50054. * The type of the texture data.
  50055. *
  50056. * UNSIGNED_INT, FLOAT.
  50057. */
  50058. type: number;
  50059. /**
  50060. * Specifies whether the texture is in gamma space.
  50061. */
  50062. gammaSpace: boolean;
  50063. }
  50064. /**
  50065. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50066. */
  50067. class PanoramaToCubeMapTools {
  50068. private static FACE_FRONT;
  50069. private static FACE_BACK;
  50070. private static FACE_RIGHT;
  50071. private static FACE_LEFT;
  50072. private static FACE_DOWN;
  50073. private static FACE_UP;
  50074. /**
  50075. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50076. *
  50077. * @param float32Array The source data.
  50078. * @param inputWidth The width of the input panorama.
  50079. * @param inputHeight The height of the input panorama.
  50080. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50081. * @return The cubemap data
  50082. */
  50083. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50084. private static CreateCubemapTexture;
  50085. private static CalcProjectionSpherical;
  50086. }
  50087. }
  50088. declare module BABYLON {
  50089. }
  50090. declare module BABYLON {
  50091. }
  50092. declare module BABYLON {
  50093. }
  50094. declare module BABYLON {
  50095. }
  50096. declare module BABYLON {
  50097. /**
  50098. * 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.
  50099. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50100. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50101. */
  50102. class CustomProceduralTexture extends ProceduralTexture {
  50103. private _animate;
  50104. private _time;
  50105. private _config;
  50106. private _texturePath;
  50107. /**
  50108. * Instantiates a new Custom Procedural Texture.
  50109. * 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.
  50110. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50111. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50112. * @param name Define the name of the texture
  50113. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50114. * @param size Define the size of the texture to create
  50115. * @param scene Define the scene the texture belongs to
  50116. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50117. * @param generateMipMaps Define if the texture should creates mip maps or not
  50118. */
  50119. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50120. private _loadJson;
  50121. /**
  50122. * Is the texture ready to be used ? (rendered at least once)
  50123. * @returns true if ready, otherwise, false.
  50124. */
  50125. isReady(): boolean;
  50126. /**
  50127. * Render the texture to its associated render target.
  50128. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50129. */
  50130. render(useCameraPostProcess?: boolean): void;
  50131. /**
  50132. * Update the list of dependant textures samplers in the shader.
  50133. */
  50134. updateTextures(): void;
  50135. /**
  50136. * Update the uniform values of the procedural texture in the shader.
  50137. */
  50138. updateShaderUniforms(): void;
  50139. /**
  50140. * Define if the texture animates or not.
  50141. */
  50142. animate: boolean;
  50143. }
  50144. }
  50145. declare module BABYLON {
  50146. /**
  50147. * Class used to generate noise procedural textures
  50148. */
  50149. class NoiseProceduralTexture extends ProceduralTexture {
  50150. private _time;
  50151. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50152. brightness: number;
  50153. /** Defines the number of octaves to process */
  50154. octaves: number;
  50155. /** Defines the level of persistence (0.8 by default) */
  50156. persistence: number;
  50157. /** Gets or sets animation speed factor (default is 1) */
  50158. animationSpeedFactor: number;
  50159. /**
  50160. * Creates a new NoiseProceduralTexture
  50161. * @param name defines the name fo the texture
  50162. * @param size defines the size of the texture (default is 256)
  50163. * @param scene defines the hosting scene
  50164. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50165. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50166. */
  50167. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50168. private _updateShaderUniforms;
  50169. protected _getDefines(): string;
  50170. /** Generate the current state of the procedural texture */
  50171. render(useCameraPostProcess?: boolean): void;
  50172. /**
  50173. * Serializes this noise procedural texture
  50174. * @returns a serialized noise procedural texture object
  50175. */
  50176. serialize(): any;
  50177. /**
  50178. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50179. * @param parsedTexture defines parsed texture data
  50180. * @param scene defines the current scene
  50181. * @param rootUrl defines the root URL containing noise procedural texture information
  50182. * @returns a parsed NoiseProceduralTexture
  50183. */
  50184. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50185. }
  50186. }
  50187. declare module BABYLON {
  50188. /**
  50189. * 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.
  50190. * This is the base class of any Procedural texture and contains most of the shareable code.
  50191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50192. */
  50193. class ProceduralTexture extends Texture {
  50194. isCube: boolean;
  50195. /**
  50196. * Define if the texture is enabled or not (disabled texture will not render)
  50197. */
  50198. isEnabled: boolean;
  50199. /**
  50200. * Define if the texture must be cleared before rendering (default is true)
  50201. */
  50202. autoClear: boolean;
  50203. /**
  50204. * Callback called when the texture is generated
  50205. */
  50206. onGenerated: () => void;
  50207. /**
  50208. * Event raised when the texture is generated
  50209. */
  50210. onGeneratedObservable: Observable<ProceduralTexture>;
  50211. /** @hidden */
  50212. _generateMipMaps: boolean;
  50213. /** @hidden **/
  50214. _effect: Effect;
  50215. /** @hidden */
  50216. _textures: {
  50217. [key: string]: Texture;
  50218. };
  50219. private _size;
  50220. private _currentRefreshId;
  50221. private _refreshRate;
  50222. private _vertexBuffers;
  50223. private _indexBuffer;
  50224. private _uniforms;
  50225. private _samplers;
  50226. private _fragment;
  50227. private _floats;
  50228. private _ints;
  50229. private _floatsArrays;
  50230. private _colors3;
  50231. private _colors4;
  50232. private _vectors2;
  50233. private _vectors3;
  50234. private _matrices;
  50235. private _fallbackTexture;
  50236. private _fallbackTextureUsed;
  50237. private _engine;
  50238. private _cachedDefines;
  50239. private _contentUpdateId;
  50240. private _contentData;
  50241. /**
  50242. * Instantiates a new procedural texture.
  50243. * 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.
  50244. * This is the base class of any Procedural texture and contains most of the shareable code.
  50245. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50246. * @param name Define the name of the texture
  50247. * @param size Define the size of the texture to create
  50248. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50249. * @param scene Define the scene the texture belongs to
  50250. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50251. * @param generateMipMaps Define if the texture should creates mip maps or not
  50252. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50253. */
  50254. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50255. /**
  50256. * The effect that is created when initializing the post process.
  50257. * @returns The created effect corrisponding the the postprocess.
  50258. */
  50259. getEffect(): Effect;
  50260. /**
  50261. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50262. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50263. */
  50264. getContent(): Nullable<ArrayBufferView>;
  50265. private _createIndexBuffer;
  50266. /** @hidden */
  50267. _rebuild(): void;
  50268. /**
  50269. * Resets the texture in order to recreate its associated resources.
  50270. * This can be called in case of context loss
  50271. */
  50272. reset(): void;
  50273. protected _getDefines(): string;
  50274. /**
  50275. * Is the texture ready to be used ? (rendered at least once)
  50276. * @returns true if ready, otherwise, false.
  50277. */
  50278. isReady(): boolean;
  50279. /**
  50280. * Resets the refresh counter of the texture and start bak from scratch.
  50281. * Could be useful to regenerate the texture if it is setup to render only once.
  50282. */
  50283. resetRefreshCounter(): void;
  50284. /**
  50285. * Set the fragment shader to use in order to render the texture.
  50286. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50287. */
  50288. setFragment(fragment: any): void;
  50289. /**
  50290. * Define the refresh rate of the texture or the rendering frequency.
  50291. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50292. */
  50293. refreshRate: number;
  50294. /** @hidden */
  50295. _shouldRender(): boolean;
  50296. /**
  50297. * Get the size the texture is rendering at.
  50298. * @returns the size (texture is always squared)
  50299. */
  50300. getRenderSize(): number;
  50301. /**
  50302. * Resize the texture to new value.
  50303. * @param size Define the new size the texture should have
  50304. * @param generateMipMaps Define whether the new texture should create mip maps
  50305. */
  50306. resize(size: number, generateMipMaps: boolean): void;
  50307. private _checkUniform;
  50308. /**
  50309. * Set a texture in the shader program used to render.
  50310. * @param name Define the name of the uniform samplers as defined in the shader
  50311. * @param texture Define the texture to bind to this sampler
  50312. * @return the texture itself allowing "fluent" like uniform updates
  50313. */
  50314. setTexture(name: string, texture: Texture): ProceduralTexture;
  50315. /**
  50316. * Set a float in the shader.
  50317. * @param name Define the name of the uniform as defined in the shader
  50318. * @param value Define the value to give to the uniform
  50319. * @return the texture itself allowing "fluent" like uniform updates
  50320. */
  50321. setFloat(name: string, value: number): ProceduralTexture;
  50322. /**
  50323. * Set a int in the shader.
  50324. * @param name Define the name of the uniform as defined in the shader
  50325. * @param value Define the value to give to the uniform
  50326. * @return the texture itself allowing "fluent" like uniform updates
  50327. */
  50328. setInt(name: string, value: number): ProceduralTexture;
  50329. /**
  50330. * Set an array of floats in the shader.
  50331. * @param name Define the name of the uniform as defined in the shader
  50332. * @param value Define the value to give to the uniform
  50333. * @return the texture itself allowing "fluent" like uniform updates
  50334. */
  50335. setFloats(name: string, value: number[]): ProceduralTexture;
  50336. /**
  50337. * Set a vec3 in the shader from a Color3.
  50338. * @param name Define the name of the uniform as defined in the shader
  50339. * @param value Define the value to give to the uniform
  50340. * @return the texture itself allowing "fluent" like uniform updates
  50341. */
  50342. setColor3(name: string, value: Color3): ProceduralTexture;
  50343. /**
  50344. * Set a vec4 in the shader from a Color4.
  50345. * @param name Define the name of the uniform as defined in the shader
  50346. * @param value Define the value to give to the uniform
  50347. * @return the texture itself allowing "fluent" like uniform updates
  50348. */
  50349. setColor4(name: string, value: Color4): ProceduralTexture;
  50350. /**
  50351. * Set a vec2 in the shader from a Vector2.
  50352. * @param name Define the name of the uniform as defined in the shader
  50353. * @param value Define the value to give to the uniform
  50354. * @return the texture itself allowing "fluent" like uniform updates
  50355. */
  50356. setVector2(name: string, value: Vector2): ProceduralTexture;
  50357. /**
  50358. * Set a vec3 in the shader from a Vector3.
  50359. * @param name Define the name of the uniform as defined in the shader
  50360. * @param value Define the value to give to the uniform
  50361. * @return the texture itself allowing "fluent" like uniform updates
  50362. */
  50363. setVector3(name: string, value: Vector3): ProceduralTexture;
  50364. /**
  50365. * Set a mat4 in the shader from a MAtrix.
  50366. * @param name Define the name of the uniform as defined in the shader
  50367. * @param value Define the value to give to the uniform
  50368. * @return the texture itself allowing "fluent" like uniform updates
  50369. */
  50370. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50371. /**
  50372. * Render the texture to its associated render target.
  50373. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50374. */
  50375. render(useCameraPostProcess?: boolean): void;
  50376. /**
  50377. * Clone the texture.
  50378. * @returns the cloned texture
  50379. */
  50380. clone(): ProceduralTexture;
  50381. /**
  50382. * Dispose the texture and release its asoociated resources.
  50383. */
  50384. dispose(): void;
  50385. }
  50386. }
  50387. declare module BABYLON {
  50388. interface AbstractScene {
  50389. /**
  50390. * The list of procedural textures added to the scene
  50391. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50392. */
  50393. proceduralTextures: Array<ProceduralTexture>;
  50394. }
  50395. /**
  50396. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50397. * in a given scene.
  50398. */
  50399. class ProceduralTextureSceneComponent implements ISceneComponent {
  50400. /**
  50401. * The component name helpfull to identify the component in the list of scene components.
  50402. */
  50403. readonly name: string;
  50404. /**
  50405. * The scene the component belongs to.
  50406. */
  50407. scene: Scene;
  50408. /**
  50409. * Creates a new instance of the component for the given scene
  50410. * @param scene Defines the scene to register the component in
  50411. */
  50412. constructor(scene: Scene);
  50413. /**
  50414. * Registers the component in a given scene
  50415. */
  50416. register(): void;
  50417. /**
  50418. * Rebuilds the elements related to this component in case of
  50419. * context lost for instance.
  50420. */
  50421. rebuild(): void;
  50422. /**
  50423. * Disposes the component and the associated ressources.
  50424. */
  50425. dispose(): void;
  50426. private _beforeClear;
  50427. }
  50428. }
  50429. declare module BABYLON {
  50430. /**
  50431. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50432. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50433. */
  50434. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50435. private _scene;
  50436. private _camerasToBeAttached;
  50437. /**
  50438. * ID of the sharpen post process,
  50439. */
  50440. private readonly SharpenPostProcessId;
  50441. /**
  50442. * @ignore
  50443. * ID of the image processing post process;
  50444. */
  50445. readonly ImageProcessingPostProcessId: string;
  50446. /**
  50447. * @ignore
  50448. * ID of the Fast Approximate Anti-Aliasing post process;
  50449. */
  50450. readonly FxaaPostProcessId: string;
  50451. /**
  50452. * ID of the chromatic aberration post process,
  50453. */
  50454. private readonly ChromaticAberrationPostProcessId;
  50455. /**
  50456. * ID of the grain post process
  50457. */
  50458. private readonly GrainPostProcessId;
  50459. /**
  50460. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50461. */
  50462. sharpen: SharpenPostProcess;
  50463. private _sharpenEffect;
  50464. private bloom;
  50465. /**
  50466. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50467. */
  50468. depthOfField: DepthOfFieldEffect;
  50469. /**
  50470. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50471. */
  50472. fxaa: FxaaPostProcess;
  50473. /**
  50474. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50475. */
  50476. imageProcessing: ImageProcessingPostProcess;
  50477. /**
  50478. * Chromatic aberration post process which will shift rgb colors in the image
  50479. */
  50480. chromaticAberration: ChromaticAberrationPostProcess;
  50481. private _chromaticAberrationEffect;
  50482. /**
  50483. * Grain post process which add noise to the image
  50484. */
  50485. grain: GrainPostProcess;
  50486. private _grainEffect;
  50487. /**
  50488. * Glow post process which adds a glow to emmisive areas of the image
  50489. */
  50490. private _glowLayer;
  50491. /**
  50492. * Animations which can be used to tweak settings over a period of time
  50493. */
  50494. animations: Animation[];
  50495. private _imageProcessingConfigurationObserver;
  50496. private _sharpenEnabled;
  50497. private _bloomEnabled;
  50498. private _depthOfFieldEnabled;
  50499. private _depthOfFieldBlurLevel;
  50500. private _fxaaEnabled;
  50501. private _imageProcessingEnabled;
  50502. private _defaultPipelineTextureType;
  50503. private _bloomScale;
  50504. private _chromaticAberrationEnabled;
  50505. private _grainEnabled;
  50506. private _buildAllowed;
  50507. /**
  50508. * Enable or disable the sharpen process from the pipeline
  50509. */
  50510. sharpenEnabled: boolean;
  50511. private _resizeObserver;
  50512. private _hardwareScaleLevel;
  50513. private _bloomKernel;
  50514. /**
  50515. * Specifies the size of the bloom blur kernel, relative to the final output size
  50516. */
  50517. bloomKernel: number;
  50518. /**
  50519. * Specifies the weight of the bloom in the final rendering
  50520. */
  50521. private _bloomWeight;
  50522. /**
  50523. * Specifies the luma threshold for the area that will be blurred by the bloom
  50524. */
  50525. private _bloomThreshold;
  50526. private _hdr;
  50527. /**
  50528. * The strength of the bloom.
  50529. */
  50530. bloomWeight: number;
  50531. /**
  50532. * The strength of the bloom.
  50533. */
  50534. bloomThreshold: number;
  50535. /**
  50536. * The scale of the bloom, lower value will provide better performance.
  50537. */
  50538. bloomScale: number;
  50539. /**
  50540. * Enable or disable the bloom from the pipeline
  50541. */
  50542. bloomEnabled: boolean;
  50543. private _rebuildBloom;
  50544. /**
  50545. * If the depth of field is enabled.
  50546. */
  50547. depthOfFieldEnabled: boolean;
  50548. /**
  50549. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50550. */
  50551. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50552. /**
  50553. * If the anti aliasing is enabled.
  50554. */
  50555. fxaaEnabled: boolean;
  50556. private _samples;
  50557. /**
  50558. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50559. */
  50560. samples: number;
  50561. /**
  50562. * If image processing is enabled.
  50563. */
  50564. imageProcessingEnabled: boolean;
  50565. /**
  50566. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50567. */
  50568. glowLayerEnabled: boolean;
  50569. /**
  50570. * Enable or disable the chromaticAberration process from the pipeline
  50571. */
  50572. chromaticAberrationEnabled: boolean;
  50573. /**
  50574. * Enable or disable the grain process from the pipeline
  50575. */
  50576. grainEnabled: boolean;
  50577. /**
  50578. * @constructor
  50579. * @param name - The rendering pipeline name (default: "")
  50580. * @param hdr - If high dynamic range textures should be used (default: true)
  50581. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50582. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50583. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50584. */
  50585. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50586. /**
  50587. * Force the compilation of the entire pipeline.
  50588. */
  50589. prepare(): void;
  50590. private _hasCleared;
  50591. private _prevPostProcess;
  50592. private _prevPrevPostProcess;
  50593. private _setAutoClearAndTextureSharing;
  50594. private _depthOfFieldSceneObserver;
  50595. private _buildPipeline;
  50596. private _disposePostProcesses;
  50597. /**
  50598. * Adds a camera to the pipeline
  50599. * @param camera the camera to be added
  50600. */
  50601. addCamera(camera: Camera): void;
  50602. /**
  50603. * Removes a camera from the pipeline
  50604. * @param camera the camera to remove
  50605. */
  50606. removeCamera(camera: Camera): void;
  50607. /**
  50608. * Dispose of the pipeline and stop all post processes
  50609. */
  50610. dispose(): void;
  50611. /**
  50612. * Serialize the rendering pipeline (Used when exporting)
  50613. * @returns the serialized object
  50614. */
  50615. serialize(): any;
  50616. /**
  50617. * Parse the serialized pipeline
  50618. * @param source Source pipeline.
  50619. * @param scene The scene to load the pipeline to.
  50620. * @param rootUrl The URL of the serialized pipeline.
  50621. * @returns An instantiated pipeline from the serialized object.
  50622. */
  50623. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50624. }
  50625. }
  50626. declare module BABYLON {
  50627. /**
  50628. * BABYLON.JS Chromatic Aberration GLSL Shader
  50629. * Author: Olivier Guyot
  50630. * Separates very slightly R, G and B colors on the edges of the screen
  50631. * Inspired by Francois Tarlier & Martins Upitis
  50632. */
  50633. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50634. /**
  50635. * @ignore
  50636. * The chromatic aberration PostProcess id in the pipeline
  50637. */
  50638. LensChromaticAberrationEffect: string;
  50639. /**
  50640. * @ignore
  50641. * The highlights enhancing PostProcess id in the pipeline
  50642. */
  50643. HighlightsEnhancingEffect: string;
  50644. /**
  50645. * @ignore
  50646. * The depth-of-field PostProcess id in the pipeline
  50647. */
  50648. LensDepthOfFieldEffect: string;
  50649. private _scene;
  50650. private _depthTexture;
  50651. private _grainTexture;
  50652. private _chromaticAberrationPostProcess;
  50653. private _highlightsPostProcess;
  50654. private _depthOfFieldPostProcess;
  50655. private _edgeBlur;
  50656. private _grainAmount;
  50657. private _chromaticAberration;
  50658. private _distortion;
  50659. private _highlightsGain;
  50660. private _highlightsThreshold;
  50661. private _dofDistance;
  50662. private _dofAperture;
  50663. private _dofDarken;
  50664. private _dofPentagon;
  50665. private _blurNoise;
  50666. /**
  50667. * @constructor
  50668. *
  50669. * Effect parameters are as follow:
  50670. * {
  50671. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50672. * edge_blur: number; // from 0 to x (1 for realism)
  50673. * distortion: number; // from 0 to x (1 for realism)
  50674. * grain_amount: number; // from 0 to 1
  50675. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50676. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50677. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50678. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50679. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50680. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50681. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50682. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50683. * }
  50684. * Note: if an effect parameter is unset, effect is disabled
  50685. *
  50686. * @param name The rendering pipeline name
  50687. * @param parameters - An object containing all parameters (see above)
  50688. * @param scene The scene linked to this pipeline
  50689. * @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)
  50690. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50691. */
  50692. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50693. /**
  50694. * Sets the amount of blur at the edges
  50695. * @param amount blur amount
  50696. */
  50697. setEdgeBlur(amount: number): void;
  50698. /**
  50699. * Sets edge blur to 0
  50700. */
  50701. disableEdgeBlur(): void;
  50702. /**
  50703. * Sets the amout of grain
  50704. * @param amount Amount of grain
  50705. */
  50706. setGrainAmount(amount: number): void;
  50707. /**
  50708. * Set grain amount to 0
  50709. */
  50710. disableGrain(): void;
  50711. /**
  50712. * Sets the chromatic aberration amount
  50713. * @param amount amount of chromatic aberration
  50714. */
  50715. setChromaticAberration(amount: number): void;
  50716. /**
  50717. * Sets chromatic aberration amount to 0
  50718. */
  50719. disableChromaticAberration(): void;
  50720. /**
  50721. * Sets the EdgeDistortion amount
  50722. * @param amount amount of EdgeDistortion
  50723. */
  50724. setEdgeDistortion(amount: number): void;
  50725. /**
  50726. * Sets edge distortion to 0
  50727. */
  50728. disableEdgeDistortion(): void;
  50729. /**
  50730. * Sets the FocusDistance amount
  50731. * @param amount amount of FocusDistance
  50732. */
  50733. setFocusDistance(amount: number): void;
  50734. /**
  50735. * Disables depth of field
  50736. */
  50737. disableDepthOfField(): void;
  50738. /**
  50739. * Sets the Aperture amount
  50740. * @param amount amount of Aperture
  50741. */
  50742. setAperture(amount: number): void;
  50743. /**
  50744. * Sets the DarkenOutOfFocus amount
  50745. * @param amount amount of DarkenOutOfFocus
  50746. */
  50747. setDarkenOutOfFocus(amount: number): void;
  50748. /**
  50749. * Creates a pentagon bokeh effect
  50750. */
  50751. enablePentagonBokeh(): void;
  50752. /**
  50753. * Disables the pentagon bokeh effect
  50754. */
  50755. disablePentagonBokeh(): void;
  50756. /**
  50757. * Enables noise blur
  50758. */
  50759. enableNoiseBlur(): void;
  50760. /**
  50761. * Disables noise blur
  50762. */
  50763. disableNoiseBlur(): void;
  50764. /**
  50765. * Sets the HighlightsGain amount
  50766. * @param amount amount of HighlightsGain
  50767. */
  50768. setHighlightsGain(amount: number): void;
  50769. /**
  50770. * Sets the HighlightsThreshold amount
  50771. * @param amount amount of HighlightsThreshold
  50772. */
  50773. setHighlightsThreshold(amount: number): void;
  50774. /**
  50775. * Disables highlights
  50776. */
  50777. disableHighlights(): void;
  50778. /**
  50779. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50780. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50781. */
  50782. dispose(disableDepthRender?: boolean): void;
  50783. private _createChromaticAberrationPostProcess;
  50784. private _createHighlightsPostProcess;
  50785. private _createDepthOfFieldPostProcess;
  50786. private _createGrainTexture;
  50787. }
  50788. }
  50789. declare module BABYLON {
  50790. /**
  50791. * Render pipeline to produce ssao effect
  50792. */
  50793. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50794. /**
  50795. * @ignore
  50796. * The PassPostProcess id in the pipeline that contains the original scene color
  50797. */
  50798. SSAOOriginalSceneColorEffect: string;
  50799. /**
  50800. * @ignore
  50801. * The SSAO PostProcess id in the pipeline
  50802. */
  50803. SSAORenderEffect: string;
  50804. /**
  50805. * @ignore
  50806. * The horizontal blur PostProcess id in the pipeline
  50807. */
  50808. SSAOBlurHRenderEffect: string;
  50809. /**
  50810. * @ignore
  50811. * The vertical blur PostProcess id in the pipeline
  50812. */
  50813. SSAOBlurVRenderEffect: string;
  50814. /**
  50815. * @ignore
  50816. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50817. */
  50818. SSAOCombineRenderEffect: string;
  50819. /**
  50820. * The output strength of the SSAO post-process. Default value is 1.0.
  50821. */
  50822. totalStrength: number;
  50823. /**
  50824. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50825. */
  50826. maxZ: number;
  50827. /**
  50828. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50829. */
  50830. minZAspect: number;
  50831. private _samples;
  50832. /**
  50833. * Number of samples used for the SSAO calculations. Default value is 8
  50834. */
  50835. samples: number;
  50836. private _textureSamples;
  50837. /**
  50838. * Number of samples to use for antialiasing
  50839. */
  50840. textureSamples: number;
  50841. /**
  50842. * Ratio object used for SSAO ratio and blur ratio
  50843. */
  50844. private _ratio;
  50845. /**
  50846. * Dynamically generated sphere sampler.
  50847. */
  50848. private _sampleSphere;
  50849. /**
  50850. * Blur filter offsets
  50851. */
  50852. private _samplerOffsets;
  50853. private _expensiveBlur;
  50854. /**
  50855. * If bilateral blur should be used
  50856. */
  50857. expensiveBlur: boolean;
  50858. /**
  50859. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50860. */
  50861. radius: number;
  50862. /**
  50863. * The base color of the SSAO post-process
  50864. * The final result is "base + ssao" between [0, 1]
  50865. */
  50866. base: number;
  50867. /**
  50868. * Support test.
  50869. */
  50870. static readonly IsSupported: boolean;
  50871. private _scene;
  50872. private _depthTexture;
  50873. private _normalTexture;
  50874. private _randomTexture;
  50875. private _originalColorPostProcess;
  50876. private _ssaoPostProcess;
  50877. private _blurHPostProcess;
  50878. private _blurVPostProcess;
  50879. private _ssaoCombinePostProcess;
  50880. private _firstUpdate;
  50881. /**
  50882. * @constructor
  50883. * @param name The rendering pipeline name
  50884. * @param scene The scene linked to this pipeline
  50885. * @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 }
  50886. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50887. */
  50888. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50889. /**
  50890. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50891. */
  50892. dispose(disableGeometryBufferRenderer?: boolean): void;
  50893. private _createBlurPostProcess;
  50894. /** @hidden */
  50895. _rebuild(): void;
  50896. private _bits;
  50897. private _radicalInverse_VdC;
  50898. private _hammersley;
  50899. private _hemisphereSample_uniform;
  50900. private _generateHemisphere;
  50901. private _createSSAOPostProcess;
  50902. private _createSSAOCombinePostProcess;
  50903. private _createRandomTexture;
  50904. /**
  50905. * Serialize the rendering pipeline (Used when exporting)
  50906. * @returns the serialized object
  50907. */
  50908. serialize(): any;
  50909. /**
  50910. * Parse the serialized pipeline
  50911. * @param source Source pipeline.
  50912. * @param scene The scene to load the pipeline to.
  50913. * @param rootUrl The URL of the serialized pipeline.
  50914. * @returns An instantiated pipeline from the serialized object.
  50915. */
  50916. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50917. }
  50918. }
  50919. declare module BABYLON {
  50920. /**
  50921. * Render pipeline to produce ssao effect
  50922. */
  50923. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50924. /**
  50925. * @ignore
  50926. * The PassPostProcess id in the pipeline that contains the original scene color
  50927. */
  50928. SSAOOriginalSceneColorEffect: string;
  50929. /**
  50930. * @ignore
  50931. * The SSAO PostProcess id in the pipeline
  50932. */
  50933. SSAORenderEffect: string;
  50934. /**
  50935. * @ignore
  50936. * The horizontal blur PostProcess id in the pipeline
  50937. */
  50938. SSAOBlurHRenderEffect: string;
  50939. /**
  50940. * @ignore
  50941. * The vertical blur PostProcess id in the pipeline
  50942. */
  50943. SSAOBlurVRenderEffect: string;
  50944. /**
  50945. * @ignore
  50946. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50947. */
  50948. SSAOCombineRenderEffect: string;
  50949. /**
  50950. * The output strength of the SSAO post-process. Default value is 1.0.
  50951. */
  50952. totalStrength: number;
  50953. /**
  50954. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50955. */
  50956. radius: number;
  50957. /**
  50958. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50959. * Must not be equal to fallOff and superior to fallOff.
  50960. * Default value is 0.975
  50961. */
  50962. area: number;
  50963. /**
  50964. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50965. * Must not be equal to area and inferior to area.
  50966. * Default value is 0.0
  50967. */
  50968. fallOff: number;
  50969. /**
  50970. * The base color of the SSAO post-process
  50971. * The final result is "base + ssao" between [0, 1]
  50972. */
  50973. base: number;
  50974. private _scene;
  50975. private _depthTexture;
  50976. private _randomTexture;
  50977. private _originalColorPostProcess;
  50978. private _ssaoPostProcess;
  50979. private _blurHPostProcess;
  50980. private _blurVPostProcess;
  50981. private _ssaoCombinePostProcess;
  50982. private _firstUpdate;
  50983. /**
  50984. * @constructor
  50985. * @param name - The rendering pipeline name
  50986. * @param scene - The scene linked to this pipeline
  50987. * @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 }
  50988. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50989. */
  50990. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50991. /**
  50992. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50993. */
  50994. dispose(disableDepthRender?: boolean): void;
  50995. private _createBlurPostProcess;
  50996. /** @hidden */
  50997. _rebuild(): void;
  50998. private _createSSAOPostProcess;
  50999. private _createSSAOCombinePostProcess;
  51000. private _createRandomTexture;
  51001. }
  51002. }
  51003. declare module BABYLON {
  51004. /**
  51005. * Standard rendering pipeline
  51006. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51007. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51008. */
  51009. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51010. /**
  51011. * Public members
  51012. */
  51013. /**
  51014. * Post-process which contains the original scene color before the pipeline applies all the effects
  51015. */
  51016. originalPostProcess: Nullable<PostProcess>;
  51017. /**
  51018. * Post-process used to down scale an image x4
  51019. */
  51020. downSampleX4PostProcess: Nullable<PostProcess>;
  51021. /**
  51022. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51023. */
  51024. brightPassPostProcess: Nullable<PostProcess>;
  51025. /**
  51026. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51027. */
  51028. blurHPostProcesses: PostProcess[];
  51029. /**
  51030. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51031. */
  51032. blurVPostProcesses: PostProcess[];
  51033. /**
  51034. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51035. */
  51036. textureAdderPostProcess: Nullable<PostProcess>;
  51037. /**
  51038. * Post-process used to create volumetric lighting effect
  51039. */
  51040. volumetricLightPostProcess: Nullable<PostProcess>;
  51041. /**
  51042. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51043. */
  51044. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51045. /**
  51046. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51047. */
  51048. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51049. /**
  51050. * Post-process used to merge the volumetric light effect and the real scene color
  51051. */
  51052. volumetricLightMergePostProces: Nullable<PostProcess>;
  51053. /**
  51054. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51055. */
  51056. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51057. /**
  51058. * Base post-process used to calculate the average luminance of the final image for HDR
  51059. */
  51060. luminancePostProcess: Nullable<PostProcess>;
  51061. /**
  51062. * Post-processes used to create down sample post-processes in order to get
  51063. * the average luminance of the final image for HDR
  51064. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51065. */
  51066. luminanceDownSamplePostProcesses: PostProcess[];
  51067. /**
  51068. * Post-process used to create a HDR effect (light adaptation)
  51069. */
  51070. hdrPostProcess: Nullable<PostProcess>;
  51071. /**
  51072. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51073. */
  51074. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51075. /**
  51076. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51077. */
  51078. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51079. /**
  51080. * Post-process used to merge the final HDR post-process and the real scene color
  51081. */
  51082. hdrFinalPostProcess: Nullable<PostProcess>;
  51083. /**
  51084. * Post-process used to create a lens flare effect
  51085. */
  51086. lensFlarePostProcess: Nullable<PostProcess>;
  51087. /**
  51088. * Post-process that merges the result of the lens flare post-process and the real scene color
  51089. */
  51090. lensFlareComposePostProcess: Nullable<PostProcess>;
  51091. /**
  51092. * Post-process used to create a motion blur effect
  51093. */
  51094. motionBlurPostProcess: Nullable<PostProcess>;
  51095. /**
  51096. * Post-process used to create a depth of field effect
  51097. */
  51098. depthOfFieldPostProcess: Nullable<PostProcess>;
  51099. /**
  51100. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51101. */
  51102. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51103. /**
  51104. * Represents the brightness threshold in order to configure the illuminated surfaces
  51105. */
  51106. brightThreshold: number;
  51107. /**
  51108. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51109. */
  51110. blurWidth: number;
  51111. /**
  51112. * Sets if the blur for highlighted surfaces must be only horizontal
  51113. */
  51114. horizontalBlur: boolean;
  51115. /**
  51116. * Sets the overall exposure used by the pipeline
  51117. */
  51118. exposure: number;
  51119. /**
  51120. * Texture used typically to simulate "dirty" on camera lens
  51121. */
  51122. lensTexture: Nullable<Texture>;
  51123. /**
  51124. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51125. */
  51126. volumetricLightCoefficient: number;
  51127. /**
  51128. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51129. */
  51130. volumetricLightPower: number;
  51131. /**
  51132. * Used the set the blur intensity to smooth the volumetric lights
  51133. */
  51134. volumetricLightBlurScale: number;
  51135. /**
  51136. * Light (spot or directional) used to generate the volumetric lights rays
  51137. * The source light must have a shadow generate so the pipeline can get its
  51138. * depth map
  51139. */
  51140. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51141. /**
  51142. * For eye adaptation, represents the minimum luminance the eye can see
  51143. */
  51144. hdrMinimumLuminance: number;
  51145. /**
  51146. * For eye adaptation, represents the decrease luminance speed
  51147. */
  51148. hdrDecreaseRate: number;
  51149. /**
  51150. * For eye adaptation, represents the increase luminance speed
  51151. */
  51152. hdrIncreaseRate: number;
  51153. /**
  51154. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51155. */
  51156. lensColorTexture: Nullable<Texture>;
  51157. /**
  51158. * The overall strengh for the lens flare effect
  51159. */
  51160. lensFlareStrength: number;
  51161. /**
  51162. * Dispersion coefficient for lens flare ghosts
  51163. */
  51164. lensFlareGhostDispersal: number;
  51165. /**
  51166. * Main lens flare halo width
  51167. */
  51168. lensFlareHaloWidth: number;
  51169. /**
  51170. * Based on the lens distortion effect, defines how much the lens flare result
  51171. * is distorted
  51172. */
  51173. lensFlareDistortionStrength: number;
  51174. /**
  51175. * Lens star texture must be used to simulate rays on the flares and is available
  51176. * in the documentation
  51177. */
  51178. lensStarTexture: Nullable<Texture>;
  51179. /**
  51180. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51181. * flare effect by taking account of the dirt texture
  51182. */
  51183. lensFlareDirtTexture: Nullable<Texture>;
  51184. /**
  51185. * Represents the focal length for the depth of field effect
  51186. */
  51187. depthOfFieldDistance: number;
  51188. /**
  51189. * Represents the blur intensity for the blurred part of the depth of field effect
  51190. */
  51191. depthOfFieldBlurWidth: number;
  51192. /**
  51193. * For motion blur, defines how much the image is blurred by the movement
  51194. */
  51195. motionStrength: number;
  51196. /**
  51197. * List of animations for the pipeline (IAnimatable implementation)
  51198. */
  51199. animations: Animation[];
  51200. /**
  51201. * Private members
  51202. */
  51203. private _scene;
  51204. private _currentDepthOfFieldSource;
  51205. private _basePostProcess;
  51206. private _hdrCurrentLuminance;
  51207. private _floatTextureType;
  51208. private _ratio;
  51209. private _bloomEnabled;
  51210. private _depthOfFieldEnabled;
  51211. private _vlsEnabled;
  51212. private _lensFlareEnabled;
  51213. private _hdrEnabled;
  51214. private _motionBlurEnabled;
  51215. private _fxaaEnabled;
  51216. private _motionBlurSamples;
  51217. private _volumetricLightStepsCount;
  51218. private _samples;
  51219. /**
  51220. * @ignore
  51221. * Specifies if the bloom pipeline is enabled
  51222. */
  51223. BloomEnabled: boolean;
  51224. /**
  51225. * @ignore
  51226. * Specifies if the depth of field pipeline is enabed
  51227. */
  51228. DepthOfFieldEnabled: boolean;
  51229. /**
  51230. * @ignore
  51231. * Specifies if the lens flare pipeline is enabed
  51232. */
  51233. LensFlareEnabled: boolean;
  51234. /**
  51235. * @ignore
  51236. * Specifies if the HDR pipeline is enabled
  51237. */
  51238. HDREnabled: boolean;
  51239. /**
  51240. * @ignore
  51241. * Specifies if the volumetric lights scattering effect is enabled
  51242. */
  51243. VLSEnabled: boolean;
  51244. /**
  51245. * @ignore
  51246. * Specifies if the motion blur effect is enabled
  51247. */
  51248. MotionBlurEnabled: boolean;
  51249. /**
  51250. * Specifies if anti-aliasing is enabled
  51251. */
  51252. fxaaEnabled: boolean;
  51253. /**
  51254. * Specifies the number of steps used to calculate the volumetric lights
  51255. * Typically in interval [50, 200]
  51256. */
  51257. volumetricLightStepsCount: number;
  51258. /**
  51259. * Specifies the number of samples used for the motion blur effect
  51260. * Typically in interval [16, 64]
  51261. */
  51262. motionBlurSamples: number;
  51263. /**
  51264. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51265. */
  51266. samples: number;
  51267. /**
  51268. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51269. * @constructor
  51270. * @param name The rendering pipeline name
  51271. * @param scene The scene linked to this pipeline
  51272. * @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)
  51273. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51274. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51275. */
  51276. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51277. private _buildPipeline;
  51278. private _createDownSampleX4PostProcess;
  51279. private _createBrightPassPostProcess;
  51280. private _createBlurPostProcesses;
  51281. private _createTextureAdderPostProcess;
  51282. private _createVolumetricLightPostProcess;
  51283. private _createLuminancePostProcesses;
  51284. private _createHdrPostProcess;
  51285. private _createLensFlarePostProcess;
  51286. private _createDepthOfFieldPostProcess;
  51287. private _createMotionBlurPostProcess;
  51288. private _getDepthTexture;
  51289. private _disposePostProcesses;
  51290. /**
  51291. * Dispose of the pipeline and stop all post processes
  51292. */
  51293. dispose(): void;
  51294. /**
  51295. * Serialize the rendering pipeline (Used when exporting)
  51296. * @returns the serialized object
  51297. */
  51298. serialize(): any;
  51299. /**
  51300. * Parse the serialized pipeline
  51301. * @param source Source pipeline.
  51302. * @param scene The scene to load the pipeline to.
  51303. * @param rootUrl The URL of the serialized pipeline.
  51304. * @returns An instantiated pipeline from the serialized object.
  51305. */
  51306. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51307. /**
  51308. * Luminance steps
  51309. */
  51310. static LuminanceSteps: number;
  51311. }
  51312. }